Skip to content

Commit

Permalink
fix: paper spigot load error
Browse files Browse the repository at this point in the history
  • Loading branch information
milkwalk committed Oct 19, 2019
1 parent 1b82fa5 commit 4763a9c
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 70 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Change Log
## [3.2.2] - 18/10/2019

### Added
- lang strings for `/xpboost info` command
- lang string for non existent command

### Fixed
- issue with start up on paper spigot

## [3.2.1] - 13/10/2019

Expand Down
34 changes: 6 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cz.dubcat.plugins</groupId>
<artifactId>xpboost</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<name>XPBoost</name>

<properties>
Expand All @@ -29,26 +29,6 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>commons-io:commons-io</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -79,6 +59,10 @@
<id>inventive-repo</id>
<url>https://repo.inventivetalent.org/content/groups/public/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
Expand All @@ -90,7 +74,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.2-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- MVdWPlaceholderAPI -->
Expand Down Expand Up @@ -213,11 +197,5 @@
<version>4.9.5</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
4 changes: 4 additions & 0 deletions resources/lang_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ lang:
factions_expire: '&cBoost for you faction has expired!'
factions_buy: '&c%player% &fhas bought a boost of &c%boost%x &ffor whole faction for &c%time% seconds!'
factions_one_boost: 'You cannot purchase any boosts while faction boost is active.'
command_not_found: '&cThis command doesnt exist.'
info_command:
boost: 'Boost: &6%boost%'
boost_type: 'Boost type:'
#Three lores on a given item, you can have up to 5 lines
item:
lore1: '&fBoost: &a%boost%x'
Expand Down
39 changes: 20 additions & 19 deletions src/cz/dubcat/xpboost/XPBoostMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;

import org.apache.commons.io.FileUtils;
import org.bstats.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
Expand Down Expand Up @@ -99,12 +100,9 @@ public void onEnable() {

File boostFileGen = new File(XPBoostMain.getPlugin().getDataFolder() + "/boosts.yml");
if (!boostFileGen.exists()) {
try {
FileUtils.copyInputStreamToFile(getClass().getResourceAsStream("/boosts.yml"),
new File(XPBoostMain.getPlugin().getDataFolder() + "/boosts.yml"));
} catch (IOException e1) {
e1.printStackTrace();
}
InputStream initialStream = getClass().getResourceAsStream("/boosts.yml");
File targetFile = new File(XPBoostMain.getPlugin().getDataFolder() + "/boosts.yml");
this.copyInputStreamToFile(initialStream, targetFile);
}

this.copyLangFiles();
Expand Down Expand Up @@ -351,22 +349,25 @@ private void initializePlaceholder() {
private void copyLangFiles() {
File langNl = new File(XPBoostMain.getPlugin().getDataFolder() + "/lang/lang_NL.yml");
if (!langNl.exists()) {
InputStream stream = getClass().getResourceAsStream("/lang/lang_NL.yml");
try {
FileUtils.copyInputStreamToFile(stream, langNl);
} catch (IOException e) {
e.printStackTrace();
}
langNl.mkdirs();
this.copyInputStreamToFile(getClass().getResourceAsStream("/lang/lang_NL.yml"),
new File(XPBoostMain.getPlugin().getDataFolder() + "/lang/lang_NL.yml"));
}

File langZhs = new File(XPBoostMain.getPlugin().getDataFolder() + "/lang/lang_ZHS.yml");
if (!langZhs.exists()) {
InputStream stream = getClass().getResourceAsStream("/lang/lang_ZHS.yml");
try {
FileUtils.copyInputStreamToFile(stream, langZhs);
} catch (IOException e) {
e.printStackTrace();
}
langZhs.mkdirs();
this.copyInputStreamToFile(getClass().getResourceAsStream("/lang/lang_ZHS.yml"),
new File(XPBoostMain.getPlugin().getDataFolder() + "/lang/lang_ZHS.yml"));
}
}

private void copyInputStreamToFile(InputStream stream, File targetFile) {
try {
Files.copy(stream, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
1 change: 0 additions & 1 deletion src/cz/dubcat/xpboost/api/BoostAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.bukkit.entity.Player;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.constructors.BoostOptions;
import cz.dubcat.xpboost.constructors.XPBoost;
import cz.dubcat.xpboost.exceptions.BoostNotFoundException;
Expand Down
12 changes: 12 additions & 0 deletions src/cz/dubcat/xpboost/api/Condition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cz.dubcat.xpboost.api;

import cz.dubcat.xpboost.XPBoostMain;

public enum Condition {
VANILLA, SKILLAPI, MCMMO, RPGME, HEROES, JOBS, MYPET;
public static Condition[] CONDITIONS = new Condition[] { VANILLA, SKILLAPI, MCMMO, RPGME, HEROES, JOBS, MYPET };

public String getConditionTranslation() {
return XPBoostMain.getLang().getString("conditions." + this.name());
}
}
8 changes: 1 addition & 7 deletions src/cz/dubcat/xpboost/api/MainAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@
import cz.dubcat.xpboost.utils.XMaterial;

public class MainAPI {

public enum Condition {
VANILLA, SKILLAPI, MCMMO, RPGME, HEROES, JOBS, MYPET;
public static Condition[] CONDITIONS = new Condition[] { VANILLA, SKILLAPI, MCMMO, RPGME, HEROES, JOBS, MYPET };
}

public static File playersyml;
public static FileConfiguration playerCfg;
public static PlayerDataManager playerData;;
public static PlayerDataManager playerData;

public static XPBoost loadPlayer(UUID uuid) {
double boost = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/cz/dubcat/xpboost/commands/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI;

public class CommandHandler implements CommandExecutor {
Expand Down Expand Up @@ -37,7 +38,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
getExecutor(args[0]).onCommand(sender, cmd, commandLabel, args);
return true;
} else {
MainAPI.sendMessage("This command doesnt exist.", sender);
MainAPI.sendMessage(XPBoostMain.getLang().getString("lang.command_not_found"), sender);

return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/commands/GiveBoostCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.MainAPI;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.Debug;
import cz.dubcat.xpboost.constructors.XPBoost;
Expand Down
7 changes: 4 additions & 3 deletions src/cz/dubcat/xpboost/commands/InfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.bukkit.entity.Player;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.MainAPI;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.XPBoost;

Expand All @@ -23,10 +23,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,

if (XPBoostAPI.hasBoost(id)) {
XPBoost xpb = XPBoostAPI.getBoost(id);
MainAPI.sendMessage("Boost: &6" + xpb.getBoost(), player);
MainAPI.sendMessage(XPBoostMain.getLang().getString("lang.info_command.boost")
.replaceAll("%boost%", String.valueOf(xpb.getBoost())), player);
MainAPI.sendMessage(XPBoostMain.getLang().getString("lang.boostcountdown") + xpb.getTimeRemaining(), player);
if (xpb.getConditions().size() > 0) {
MainAPI.sendMessage("Boost type: ", player);
MainAPI.sendMessage(XPBoostMain.getLang().getString("lang.info_command.boost_type"), player);
for (Entry<Condition, Boolean> set : xpb.getConditions().entrySet()) {
if (set.getValue())
MainAPI.sendMessage(" &a" + set.getKey().name(), player);
Expand Down
5 changes: 5 additions & 0 deletions src/cz/dubcat/xpboost/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public void loadLangFile() {
setLine("lang.item.lore3", "&8Right-Click to gain boost.", cfg);
setLine("lang.reload", "&fConfig has been reloaded", cfg);

setLine("lang.info_command.boost", "Boost: &6%boost%", cfg);
setLine("lang.info_command.boost_type", "Boost type:", cfg);

setLine("lang.command_not_found", "&cThis command doesnt exist.", cfg);

setLine("lang.pluginmenu", Arrays.asList("/xpboost gui &f- Opens up GUI",
"/xpboost info &f- Shows time remaining", "/xpboost factions &f- Opens up a factions GUI",
"/xpboost on/off &f - Enables/disables global XP Boost",
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/constructors/XPBoost.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.MainAPI;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import lombok.Data;

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.bukkit.event.player.PlayerExpChangeEvent;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.MainAPI;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.Debug;
import cz.dubcat.xpboost.constructors.GlobalBoost;
Expand All @@ -35,10 +35,11 @@ public void onExpChange(PlayerExpChangeEvent event) {

if (XPBoostAPI.hasBoost(id)) {
XPBoost xpb = XPBoostAPI.getBoost(id);
if (xpb.hasCondition(CONDITION_NAME))
if (xpb.hasCondition(CONDITION_NAME)) {
expnew = (int) Math.round(exp * xpb.getBoost());
else
} else {
return;
}
}

if (gl.isEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/support/Heroes.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.herocraftonline.heroes.characters.classes.HeroClass.ExperienceType;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.GlobalBoost;
import cz.dubcat.xpboost.constructors.XPBoost;
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/support/JobsReborn.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.gamingmesh.jobs.api.JobsExpGainEvent;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.GlobalBoost;
import cz.dubcat.xpboost.constructors.XPBoost;
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/support/McMMO.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.GlobalBoost;
import cz.dubcat.xpboost.constructors.XPBoost;
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/support/MyPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.bukkit.event.Listener;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.GlobalBoost;
import cz.dubcat.xpboost.constructors.XPBoost;
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/support/RPGmE.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.bukkit.event.Listener;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.GlobalBoost;
import cz.dubcat.xpboost.constructors.XPBoost;
Expand Down
2 changes: 1 addition & 1 deletion src/cz/dubcat/xpboost/support/SkillApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.sucy.skill.api.player.PlayerData;

import cz.dubcat.xpboost.XPBoostMain;
import cz.dubcat.xpboost.api.MainAPI.Condition;
import cz.dubcat.xpboost.api.Condition;
import cz.dubcat.xpboost.api.XPBoostAPI;
import cz.dubcat.xpboost.constructors.GlobalBoost;
import cz.dubcat.xpboost.constructors.XPBoost;
Expand Down

0 comments on commit 4763a9c

Please sign in to comment.