1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +01:00

Fix signs command parsing issue on click

Now on the 3rd line the trailing spaces will get removed to successfully parse for example the join command.
This commit is contained in:
montlikadani 2021-03-20 09:54:02 +01:00
parent 9df1810732
commit 0d138d6664
12 changed files with 130 additions and 157 deletions

View File

@ -111,18 +111,6 @@ public class ItemBoostManager {
if (one.equalsIgnoreCase("exampleBoost")) if (one.equalsIgnoreCase("exampleBoost"))
continue; continue;
CMIMaterial mat = null;
if (cfg.getC().isString(one + ".id")) {
mat = CMIMaterial.get(cfg.get(one + ".id", "Stone"));
}
String name = null;
if (cfg.getC().isString(one + ".name")) {
name = cfg.get(one + ".name", "");
}
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
if (cfg.getC().isList(one + ".lore")) { if (cfg.getC().isList(one + ".lore")) {
for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) { for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) {
@ -130,15 +118,17 @@ public class ItemBoostManager {
} }
} }
HashMap<Enchantment, Integer> enchants = new HashMap<>(); Map<Enchantment, Integer> enchants = new HashMap<>();
if (cfg.getC().isList(one + ".enchants")) if (cfg.getC().isList(one + ".enchants"))
for (String eachLine : cfg.get(one + ".enchants", Arrays.asList(""))) { for (String eachLine : cfg.get(one + ".enchants", Arrays.asList(""))) {
if (!eachLine.contains("=")) if (!eachLine.contains("="))
continue; continue;
Enchantment ench = CMIEnchantment.getEnchantment(eachLine.split("=")[0]);
String[] split = eachLine.split("=", 2);
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
Integer level = -1; Integer level = -1;
try { try {
level = Integer.parseInt(eachLine.split("=")[1]); level = Integer.parseInt(split[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
continue; continue;
} }
@ -148,28 +138,36 @@ public class ItemBoostManager {
BoostMultiplier b = new BoostMultiplier(); BoostMultiplier b = new BoostMultiplier();
for (CurrencyType oneC : CurrencyType.values()) { for (CurrencyType oneC : CurrencyType.values()) {
if (cfg.getC().isDouble(one + "." + oneC.toString().toLowerCase() + "Boost") || cfg.getC().isInt(one + "." + oneC.toString().toLowerCase() + "Boost")) String typeName = oneC.toString().toLowerCase();
b.add(oneC, cfg.get(one + "." + oneC.toString().toLowerCase() + "Boost", 1D) - 1); if (cfg.getC().isDouble(one + "." + typeName + "Boost") || cfg.getC().isInt(one + "." + typeName + "Boost"))
b.add(oneC, cfg.get(one + "." + typeName + "Boost", 1D) - 1);
} }
List<Job> jobs = new ArrayList<>(); List<Job> jobs = new ArrayList<>();
for (String oneJ : cfg.get(one + ".jobs", Arrays.asList(""))) { for (String oneJ : cfg.get(one + ".jobs", Arrays.asList(""))) {
Job job = Jobs.getJob(oneJ); if (oneJ.equalsIgnoreCase("all")) {
if (job == null && !oneJ.equalsIgnoreCase("all")) {
Jobs.getPluginLogger().warning("Cant determine job by " + oneJ + " name for " + one + " boosted item!");
continue;
}
if (oneJ.equalsIgnoreCase("all"))
jobs.addAll(Jobs.getJobs()); jobs.addAll(Jobs.getJobs());
else if (job != null) } else {
jobs.add(job); Job job = Jobs.getJob(oneJ);
if (job != null) {
jobs.add(job);
} else {
Jobs.getPluginLogger().warning("Cant determine job by " + oneJ + " name for " + one + " boosted item!");
}
}
} }
if (jobs.isEmpty()) { if (jobs.isEmpty()) {
Jobs.getPluginLogger().warning("Jobs list is empty for " + one + " boosted item!"); Jobs.getPluginLogger().warning("Jobs list is empty for " + one + " boosted item!");
continue; continue;
} }
JobItems item = new JobItems(one.toLowerCase(), mat, 1, name, lore, enchants, b, jobs);
CMIMaterial mat = cfg.getC().isString(one + ".id") ? CMIMaterial.get(cfg.get(one + ".id", "Stone")) : null;
String name = cfg.getC().isString(one + ".name") ? cfg.get(one + ".name", "") : null;
String node = one.toLowerCase();
JobItems item = new JobItems(node, mat, 1, name, lore, enchants, b, jobs);
if (cfg.getC().isInt(one + ".levelFrom")) if (cfg.getC().isInt(one + ".levelFrom"))
item.setFromLevel(cfg.get(one + ".levelFrom", 0)); item.setFromLevel(cfg.get(one + ".levelFrom", 0));
@ -178,16 +176,16 @@ public class ItemBoostManager {
item.setUntilLevel(cfg.get(one + ".levelUntil", 1000)); item.setUntilLevel(cfg.get(one + ".levelUntil", 1000));
for (Job oneJ : jobs) { for (Job oneJ : jobs) {
oneJ.getItemBonus().put(one.toLowerCase(), item); oneJ.getItemBonus().put(node, item);
} }
// Lets add into legacy map // Lets add into legacy map
if (one.contains("_")) { if (one.contains("_")) {
item.setLegacyKey((one.split("_")[1]).toLowerCase()); item.setLegacyKey(one.split("_")[1].toLowerCase());
LEGACY.put(item.getLegacyKey(), item); LEGACY.put(item.getLegacyKey(), item);
} }
ITEMS.put(one.toLowerCase(), item);
ITEMS.put(node, item);
} }
cfg.save(); cfg.save();

View File

@ -189,27 +189,30 @@ public class Placeholder {
} }
public String getName() { public String getName() {
return pref + "_" + this.name(); return pref + "_" + name();
} }
public String getFull() { public String getFull() {
if (this.isComplex()) { if (isComplex()) {
String name = this.getName(); String name = getName();
int i = 0; int i = 0;
for (String one : this.getName().split("_")) { for (String one : getName().split("_")) {
if (!one.startsWith("$")) if (!one.startsWith("$"))
continue; continue;
if (vars.length >= i - 1) if (vars.length >= i - 1)
name = name.replace(one, "[" + vars[i] + "]"); name = name.replace(one, "[" + vars[i] + "]");
i++; i++;
} }
return "%" + name + "%"; return "%" + name + "%";
} }
return "%" + this.getName() + "%";
return "%" + getName() + "%";
} }
public String getMVdW() { /*public String getMVdW() {
if (this.isComplex()) { if (this.isComplex()) {
String name = this.getName(); String name = this.getName();
int i = 0; int i = 0;
@ -224,7 +227,7 @@ public class Placeholder {
return name; return name;
} }
return this.getName(); return this.getName();
} }*/
public List<String> getComplexRegexMatchers(String text) { public List<String> getComplexRegexMatchers(String text) {
List<String> lsInLs = new ArrayList<>(); List<String> lsInLs = new ArrayList<>();

View File

@ -123,15 +123,21 @@ public class PlayerManager {
} }
public void addPlayerToCache(JobsPlayer jPlayer) { public void addPlayerToCache(JobsPlayer jPlayer) {
if (!playersCache.containsKey(jPlayer.getName().toLowerCase())) String jName = jPlayer.getName().toLowerCase();
playersCache.put(jPlayer.getName().toLowerCase(), jPlayer);
if (!playersCache.containsKey(jName))
playersCache.put(jName, jPlayer);
if (jPlayer.getUniqueId() != null && !playersUUIDCache.containsKey(jPlayer.getUniqueId())) if (jPlayer.getUniqueId() != null && !playersUUIDCache.containsKey(jPlayer.getUniqueId()))
playersUUIDCache.put(jPlayer.getUniqueId(), jPlayer); playersUUIDCache.put(jPlayer.getUniqueId(), jPlayer);
} }
public void addPlayer(JobsPlayer jPlayer) { public void addPlayer(JobsPlayer jPlayer) {
if (!players.containsKey(jPlayer.getName().toLowerCase())) String jName = jPlayer.getName().toLowerCase();
players.put(jPlayer.getName().toLowerCase(), jPlayer);
if (!players.containsKey(jName))
players.put(jName, jPlayer);
if (jPlayer.getUniqueId() != null && !playersUUID.containsKey(jPlayer.getUniqueId())) if (jPlayer.getUniqueId() != null && !playersUUID.containsKey(jPlayer.getUniqueId()))
playersUUID.put(jPlayer.getUniqueId(), jPlayer); playersUUID.put(jPlayer.getUniqueId(), jPlayer);
} }
@ -334,9 +340,8 @@ public class PlayerManager {
dao.recordPlayersLimits(jPlayer); dao.recordPlayersLimits(jPlayer);
i++; i++;
y++;
if (y >= 1000) { if (y++ >= 1000) {
Jobs.consoleMsg("&e[Jobs] Saved " + i + "/" + total + " players data"); Jobs.consoleMsg("&e[Jobs] Saved " + i + "/" + total + " players data");
y = 0; y = 0;
} }
@ -380,8 +385,10 @@ public class PlayerManager {
* @return {@link JobsPlayer} the player job info of the player * @return {@link JobsPlayer} the player job info of the player
*/ */
public JobsPlayer getJobsPlayer(String playerName) { public JobsPlayer getJobsPlayer(String playerName) {
JobsPlayer jPlayer = players.get(playerName.toLowerCase()); playerName = playerName.toLowerCase();
return jPlayer != null ? jPlayer : playersCache.get(playerName.toLowerCase());
JobsPlayer jPlayer = players.get(playerName);
return jPlayer != null ? jPlayer : playersCache.get(playerName);
} }
/** /**
@ -530,15 +537,11 @@ public class PlayerManager {
* @param newjob - the new job * @param newjob - the new job
*/ */
public boolean transferJob(JobsPlayer jPlayer, Job oldjob, Job newjob) { public boolean transferJob(JobsPlayer jPlayer, Job oldjob, Job newjob) {
if (!jPlayer.transferJob(oldjob, newjob)) if (!jPlayer.transferJob(oldjob, newjob) || !Jobs.getJobsDAO().quitJob(jPlayer, oldjob))
return false;
JobsDAO dao = Jobs.getJobsDAO();
if (!dao.quitJob(jPlayer, oldjob))
return false; return false;
oldjob.updateTotalPlayers(); oldjob.updateTotalPlayers();
dao.joinJob(jPlayer, jPlayer.getJobProgression(newjob)); Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(newjob));
newjob.updateTotalPlayers(); newjob.updateTotalPlayers();
jPlayer.save(); jPlayer.save();
return true; return true;
@ -836,11 +839,11 @@ public class PlayerManager {
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel); performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
Jobs.getSignUtil().updateAllSign(job); Jobs.getSignUtil().updateAllSign(job);
if (Jobs.getGCManager().titleMessageMaxLevelReached && prog.getLevel() == jPlayer.getMaxJobLevelAllowed(prog.getJob())) { if (Jobs.getGCManager().titleMessageMaxLevelReached && player != null && prog.getLevel() == jPlayer.getMaxJobLevelAllowed(prog.getJob())) {
TitleMessageManager.send(jPlayer.getPlayer(), Jobs.getLanguage().getMessage("message.max-level-reached.title", TitleMessageManager.send(player, Jobs.getLanguage().getMessage("message.max-level-reached.title",
"%jobname%", prog.getJob().getNameWithColor()), "%jobname%", prog.getJob().getNameWithColor()),
Jobs.getLanguage().getMessage("message.max-level-reached.subtitle", "%jobname%", prog.getJob().getNameWithColor()), 20, 40, 20); Jobs.getLanguage().getMessage("message.max-level-reached.subtitle", "%jobname%", prog.getJob().getNameWithColor()), 20, 40, 20);
jPlayer.getPlayer().sendMessage(Jobs.getLanguage().getMessage("message.max-level-reached.chat", "%jobname%", prog.getJob().getNameWithColor())); player.sendMessage(Jobs.getLanguage().getMessage("message.max-level-reached.chat", "%jobname%", prog.getJob().getNameWithColor()));
} }
} }
@ -864,8 +867,8 @@ public class PlayerManager {
&& newLevel <= command.getLevelUntil()) { && newLevel <= command.getLevelUntil()) {
for (String commandString : new ArrayList<>(command.getCommands())) { for (String commandString : new ArrayList<>(command.getCommands())) {
commandString = commandString.replace("[player]", player.getName()); commandString = commandString.replace("[player]", player.getName());
commandString = commandString.replace("[oldlevel]", String.valueOf(oldLevel)); commandString = commandString.replace("[oldlevel]", Integer.toString(oldLevel));
commandString = commandString.replace("[newlevel]", String.valueOf(newLevel)); commandString = commandString.replace("[newlevel]", Integer.toString(newLevel));
commandString = commandString.replace("[jobname]", job.getName()); commandString = commandString.replace("[jobname]", job.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandString); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandString);
} }
@ -984,7 +987,7 @@ public class PlayerManager {
if (oneArmor != null && oneArmor.getType() != org.bukkit.Material.AIR) { if (oneArmor != null && oneArmor.getType() != org.bukkit.Material.AIR) {
jitems.add(getJobsItemByNbt(oneArmor)); jitems.add(getJobsItemByNbt(oneArmor));
} }
} }
} }
for (JobItems jitem : jitems) { for (JobItems jitem : jitems) {
@ -1063,8 +1066,10 @@ public class PlayerManager {
if (player == null || !player.isOnline() || prog == null) if (player == null || !player.isOnline() || prog == null)
return boost; return boost;
Player pl = player.getPlayer();
if (HookManager.getMcMMOManager().mcMMOPresent || HookManager.getMcMMOManager().mcMMOOverHaul) if (HookManager.getMcMMOManager().mcMMOPresent || HookManager.getMcMMOManager().mcMMOOverHaul)
boost.add(BoostOf.McMMO, new BoostMultiplier().add(HookManager.getMcMMOManager().getMultiplier(player.getPlayer()))); boost.add(BoostOf.McMMO, new BoostMultiplier().add(HookManager.getMcMMOManager().getMultiplier(pl)));
double petPay = 0D; double petPay = 0D;
@ -1077,7 +1082,7 @@ public class PlayerManager {
} }
} }
if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent, player.getPlayer())) { if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent, pl)) {
if (petPay == 0D) if (petPay == 0D)
petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false); petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false);
if (petPay != 0D) if (petPay != 0D)
@ -1093,10 +1098,11 @@ public class PlayerManager {
if (getall) { if (getall) {
if (petPay == 0D) if (petPay == 0D)
petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force, false); petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force, false);
if (petPay != 0D) else
boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay));
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force); Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
if (amount != null) if (amount != 0D)
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount)); boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));
} }
@ -1106,10 +1112,13 @@ public class PlayerManager {
if (Jobs.getGCManager().useDynamicPayment) if (Jobs.getGCManager().useDynamicPayment)
boost.add(BoostOf.Dynamic, new BoostMultiplier().add(prog.getBonus())); boost.add(BoostOf.Dynamic, new BoostMultiplier().add(prog.getBonus()));
boost.add(BoostOf.Item, getItemBoostNBT(player.getPlayer(), prog)); if (pl != null) {
boost.add(BoostOf.Item, getItemBoostNBT(pl, prog));
}
if (!Jobs.getRestrictedAreaManager().getRestrictedAres().isEmpty()) if (!Jobs.getRestrictedAreaManager().getRestrictedAres().isEmpty())
boost.add(BoostOf.Area, new BoostMultiplier().add(Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player.getPlayer()))); boost.add(BoostOf.Area, new BoostMultiplier().add(Jobs.getRestrictedAreaManager().getRestrictedMultiplier(pl)));
return boost; return boost;
} }

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -24,10 +25,10 @@ import com.gamingmesh.jobs.container.TopList;
public class SignUtil { public class SignUtil {
private final HashMap<String, HashMap<String, jobsSign>> signsByType = new HashMap<>(); private final Map<String, Map<String, jobsSign>> signsByType = new HashMap<>();
private final HashMap<String, jobsSign> signsByLocation = new HashMap<>(); private final Map<String, jobsSign> signsByLocation = new HashMap<>();
public HashMap<String, HashMap<String, jobsSign>> getSigns() { public Map<String, Map<String, jobsSign>> getSigns() {
return signsByType; return signsByType;
} }
@ -36,10 +37,11 @@ public class SignUtil {
if (jSign == null) if (jSign == null)
return false; return false;
HashMap<String, jobsSign> sub = signsByType.get(jSign.getIdentifier().toLowerCase()); Map<String, jobsSign> sub = signsByType.get(jSign.getIdentifier().toLowerCase());
if (sub != null) { if (sub != null) {
sub.remove(jSign.locToBlockString()); sub.remove(jSign.locToBlockString());
} }
return true; return true;
} }
@ -53,15 +55,16 @@ public class SignUtil {
signsByLocation.put(jSign.locToBlockString(), jSign); signsByLocation.put(jSign.locToBlockString(), jSign);
HashMap<String, jobsSign> old = signsByType.get(jSign.getIdentifier().toLowerCase()); String identifier = jSign.getIdentifier().toLowerCase();
Map<String, jobsSign> old = signsByType.get(identifier);
if (old == null) { if (old == null) {
old = new HashMap<>(); old = new HashMap<>();
signsByType.put(jSign.getIdentifier().toLowerCase(), old); signsByType.put(identifier, old);
} }
old.put(jSign.locToBlockString(), jSign); old.put(jSign.locToBlockString(), jSign);
signsByType.put(jSign.getIdentifier().toLowerCase(), old); signsByType.put(identifier, old);
} }
public void LoadSigns() { public void LoadSigns() {
@ -78,7 +81,7 @@ public class SignUtil {
return; return;
ConfigurationSection confCategory = f.getConfigurationSection("Signs"); ConfigurationSection confCategory = f.getConfigurationSection("Signs");
ArrayList<String> categoriesList = new ArrayList<>(confCategory.getKeys(false)); List<String> categoriesList = new ArrayList<>(confCategory.getKeys(false));
if (categoriesList.isEmpty()) if (categoriesList.isEmpty())
return; return;
@ -104,11 +107,13 @@ public class SignUtil {
} }
newTemp.setSpecial(nameSection.getBoolean("Special")); newTemp.setSpecial(nameSection.getBoolean("Special"));
HashMap<String, jobsSign> old = signsByType.get(newTemp.getIdentifier().toLowerCase()); String identifier = newTemp.getIdentifier().toLowerCase();
Map<String, jobsSign> old = signsByType.get(identifier);
if (old == null) { if (old == null) {
old = new HashMap<>(); old = new HashMap<>();
signsByType.put(newTemp.getIdentifier().toLowerCase(), old); signsByType.put(identifier, old);
} }
String loc = newTemp.locToBlockString(); String loc = newTemp.locToBlockString();
old.put(loc, newTemp); old.put(loc, newTemp);
signsByLocation.put(loc, newTemp); signsByLocation.put(loc, newTemp);
@ -133,8 +138,7 @@ public class SignUtil {
int i = 0; int i = 0;
for (jobsSign sign : signsByLocation.values()) { for (jobsSign sign : signsByLocation.values()) {
++i; String path = "Signs." + ++i;
String path = "Signs." + i;
reader.set(path + ".Loc", sign.locToBlockString()); reader.set(path + ".Loc", sign.locToBlockString());
reader.set(path + ".Number", sign.getNumber()); reader.set(path + ".Number", sign.getNumber());
reader.set(path + ".Type", sign.getType().toString()); reader.set(path + ".Type", sign.getType().toString());
@ -169,7 +173,7 @@ public class SignUtil {
String jobNameOrType = jobsSign.getIdentifier(job, type); String jobNameOrType = jobsSign.getIdentifier(job, type);
HashMap<String, jobsSign> signs = this.signsByType.get(jobNameOrType.toLowerCase()); Map<String, jobsSign> signs = signsByType.get(jobNameOrType.toLowerCase());
if (signs == null || signs.isEmpty()) if (signs == null || signs.isEmpty())
return false; return false;
@ -188,7 +192,7 @@ public class SignUtil {
int timelapse = 1; int timelapse = 1;
HashMap<String, List<TopList>> temp = new HashMap<>(); Map<String, List<TopList>> temp = new HashMap<>();
boolean save = false; boolean save = false;
for (jobsSign jSign : (new HashMap<>(signs)).values()) { for (jobsSign jSign : (new HashMap<>(signs)).values()) {
@ -199,13 +203,13 @@ public class SignUtil {
Block block = loc.getBlock(); Block block = loc.getBlock();
if (!(block.getState() instanceof Sign)) { if (!(block.getState() instanceof Sign)) {
if (!jobNameOrType.isEmpty()) { if (!jobNameOrType.isEmpty()) {
HashMap<String, jobsSign> tt = this.signsByType.get(jobNameOrType.toLowerCase()); Map<String, jobsSign> tt = signsByType.get(jobNameOrType.toLowerCase());
if (tt != null) { if (tt != null) {
tt.remove(jSign.locToBlockString()); tt.remove(jSign.locToBlockString());
} }
} }
this.signsByLocation.remove(jSign.locToBlockString()); signsByLocation.remove(jSign.locToBlockString());
save = true; save = true;
continue; continue;
} }
@ -253,7 +257,7 @@ public class SignUtil {
Jobs.getInstance().getComplement().setLine(sign, i, line); Jobs.getInstance().getComplement().setLine(sign, i, line);
} }
sign.update(); sign.update();
if (!UpdateHead(sign, playerList.get(0).getPlayerInfo().getName(), timelapse)) { if (!updateHead(sign, playerList.get(0).getPlayerInfo().getName(), timelapse)) {
timelapse--; timelapse--;
} }
} else { } else {
@ -284,7 +288,7 @@ public class SignUtil {
Jobs.getInstance().getComplement().setLine(sign, 3, translateSignLine("signs.SpecialList.bottom", no, playerName, pl.getLevel(), signJobName)); Jobs.getInstance().getComplement().setLine(sign, 3, translateSignLine("signs.SpecialList.bottom", no, playerName, pl.getLevel(), signJobName));
sign.update(); sign.update();
if (!UpdateHead(sign, pl.getPlayerInfo().getName(), timelapse)) { if (!updateHead(sign, pl.getPlayerInfo().getName(), timelapse)) {
timelapse--; timelapse--;
} }
} }
@ -306,7 +310,7 @@ public class SignUtil {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean UpdateHead(final Sign sign, final String playerName, int timelapse) { public boolean updateHead(final Sign sign, final String playerName, int timelapse) {
if (playerName == null) if (playerName == null)
return false; return false;

View File

@ -69,11 +69,9 @@ public class join implements Cmd {
} }
JobProgression ajp = jPlayer.getArchivedJobProgression(job); JobProgression ajp = jPlayer.getArchivedJobProgression(job);
if (ajp != null) { if (ajp != null && !ajp.canRejoin()) {
if (!ajp.canRejoin()) { pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage()));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage())); return true;
return true;
}
} }
Jobs.getPlayerManager().joinJob(jPlayer, job); Jobs.getPlayerManager().joinJob(jPlayer, job);

View File

@ -24,7 +24,7 @@ public class placeholders implements Cmd {
if (sender instanceof Player && args[0].startsWith("-p:")) { if (sender instanceof Player && args[0].startsWith("-p:")) {
try { try {
page = Integer.parseInt(args[0].substring("-p:".length())); page = Integer.parseInt(args[0].substring("-p:".length()));
} catch (Throwable e) { } catch (Exception e) {
} }
} else if (!(sender instanceof Player)) { } else if (!(sender instanceof Player)) {
player = Bukkit.getPlayer(args[0]); player = Bukkit.getPlayer(args[0]);
@ -69,8 +69,7 @@ public class placeholders implements Cmd {
String place = one.getFull(); String place = one.getFull();
String hover = ""; String hover = "";
if (plugin.isPlaceholderAPIEnabled()) { if (plugin.isPlaceholderAPIEnabled()) {
place = one.getFull(); hover = place = one.getFull();
hover = one.getFull();
} }
// For MVdWPlaceholderAPI // For MVdWPlaceholderAPI
// if (plugin.isMVdWPlaceholderAPIEnabled()) { // if (plugin.isMVdWPlaceholderAPIEnabled()) {

View File

@ -54,7 +54,7 @@ public class JobItems {
private int fromLevel = 0; private int fromLevel = 0;
private int untilLevel = Integer.MAX_VALUE; private int untilLevel = Integer.MAX_VALUE;
public JobItems(String node, CMIMaterial mat, int amount, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, BoostMultiplier boostMultiplier, List<Job> jobs) { public JobItems(String node, CMIMaterial mat, int amount, String name, List<String> lore, Map<Enchantment, Integer> enchants, BoostMultiplier boostMultiplier, List<Job> jobs) {
this(node, mat, amount, name, lore, enchants, boostMultiplier, jobs, null); this(node, mat, amount, name, lore, enchants, boostMultiplier, jobs, null);
} }

View File

@ -28,19 +28,13 @@ import com.gamingmesh.jobs.container.CurrencyType;
public class BufferedPayment { public class BufferedPayment {
private OfflinePlayer offlinePlayer; private OfflinePlayer offlinePlayer;
private final Map<CurrencyType, Double> payments = new HashMap<>();
@Deprecated private final Map<CurrencyType, Double> payments = new HashMap<>();
public BufferedPayment(OfflinePlayer offlinePlayer, double amount, double points, double exp) {
this.offlinePlayer = offlinePlayer;
this.payments.put(CurrencyType.MONEY, amount);
this.payments.put(CurrencyType.EXP, exp);
this.payments.put(CurrencyType.POINTS, points);
}
public BufferedPayment(OfflinePlayer offlinePlayer, Map<CurrencyType, Double> payments) { public BufferedPayment(OfflinePlayer offlinePlayer, Map<CurrencyType, Double> payments) {
this.offlinePlayer = offlinePlayer; this.offlinePlayer = offlinePlayer;
// This can contain only one value instead of all posible ones
// This can contain only one value instead of all possible ones
this.payments.putAll(payments); this.payments.putAll(payments);
} }
@ -48,45 +42,12 @@ public class BufferedPayment {
return offlinePlayer; return offlinePlayer;
} }
@Deprecated
public Double getAmount() {
Double amount = this.payments.get(CurrencyType.MONEY);
return amount == null ? 0 : amount;
}
@Deprecated
public double getPoints() {
Double amount = this.payments.get(CurrencyType.POINTS);
return amount == null ? 0 : amount;
}
@Deprecated
public double getExp() {
Double amount = this.payments.get(CurrencyType.EXP);
return amount == null ? 0 : amount;
}
@Deprecated
public void setAmount(double amount) {
this.payments.put(CurrencyType.MONEY, amount);
}
@Deprecated
public void setPoints(double points) {
this.payments.put(CurrencyType.POINTS, points);
}
@Deprecated
public void setExp(double exp) {
this.payments.put(CurrencyType.EXP, exp);
}
public Double get(CurrencyType type) { public Double get(CurrencyType type) {
return payments.getOrDefault(type, 0d); return payments.getOrDefault(type, 0d);
} }
public Double set(CurrencyType type, double amount) { public Double set(CurrencyType type, double amount) {
return this.payments.put(type, amount); return payments.put(type, amount);
} }
public boolean containsPayment() { public boolean containsPayment() {

View File

@ -9,7 +9,7 @@ public class PaymentData {
private Long lastAnnouced = 0L; private Long lastAnnouced = 0L;
private final HashMap<CurrencyType, LimitsData> payments = new HashMap<>(); private final java.util.Map<CurrencyType, LimitsData> payments = new HashMap<>();
private boolean informed = false; private boolean informed = false;

View File

@ -29,8 +29,12 @@ public class MyPetManager extends HookPlugin {
} }
MyPetPlayer myPetPlayer = mp.getMyPetPlayer(owner); MyPetPlayer myPetPlayer = mp.getMyPetPlayer(owner);
return myPetPlayer.hasMyPet() && myPetPlayer.getMyPet().getEntity().isPresent() && if (!myPetPlayer.hasMyPet()) {
myPetPlayer.getMyPet().getEntity().get().getType() == entity.getType(); return false;
}
java.util.Optional<MyPetBukkitEntity> opt = myPetPlayer.getMyPet().getEntity();
return opt.isPresent() && opt.get().getType() == entity.getType();
} }
public UUID getOwnerOfPet(Entity ent) { public UUID getOwnerOfPet(Entity ent) {

View File

@ -19,14 +19,13 @@ public class MythicMobs4Listener implements Listener {
@EventHandler @EventHandler
public void OnMythicMobDeath(MythicMobDeathEvent event) { public void OnMythicMobDeath(MythicMobDeathEvent event) {
//disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
// Entity that died must be living // Entity that died must be living
if (!(event.getEntity() instanceof LivingEntity)) if (!(event.getEntity() instanceof LivingEntity))
return; return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return;
Player pDamager = null; Player pDamager = null;
// Checking if killer is player // Checking if killer is player
@ -49,16 +48,14 @@ public class MythicMobs4Listener implements Listener {
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName())) if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
return; return;
// pay
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager); JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
if (jDamager == null) if (jDamager == null)
return; return;
// pay
MythicMob lVictim = event.getMobType(); MythicMob lVictim = event.getMobType();
if (lVictim == null) { if (lVictim != null) {
return; Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
} }
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
} }
} }

View File

@ -137,8 +137,7 @@ public class JobsListener implements Listener {
} }
if (Jobs.getSelectionManager().hasPlacedBoth(player)) { if (Jobs.getSelectionManager().hasPlacedBoth(player)) {
JobsAreaSelectionEvent jobsAreaSelectionEvent = new JobsAreaSelectionEvent(player, Jobs.getSelectionManager().getSelectionCuboid(player)); plugin.getServer().getPluginManager().callEvent(new JobsAreaSelectionEvent(player, Jobs.getSelectionManager().getSelectionCuboid(player)));
plugin.getServer().getPluginManager().callEvent(jobsAreaSelectionEvent);
} }
} }
@ -209,7 +208,8 @@ public class JobsListener implements Listener {
} }
player.performCommand("jobs " + command + " " + CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 2)) player.performCommand("jobs " + command + " " + CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 2))
+ " " + CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 3))); + " " + CMIChatColor.stripColor(plugin.getComplement()
.getLine(sign, 3)).replace(" ", "")); // Replace trailing spaces at 3rd line to parse command
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
@ -313,8 +313,7 @@ public class JobsListener implements Listener {
if (CMIChatColor.stripColor(plugin.getComplement().getLine(event, 0)) if (CMIChatColor.stripColor(plugin.getComplement().getLine(event, 0))
.equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !CMIChatColor.stripColor( .equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !CMIChatColor.stripColor(
plugin.getComplement().getLine(event, 1)) plugin.getComplement().getLine(event, 1)).equalsIgnoreCase("toplist"))
.equalsIgnoreCase("toplist"))
plugin.getComplement().setLine(event, 0, convert(Jobs.getLanguage().getMessage("signs.topline"))); plugin.getComplement().setLine(event, 0, convert(Jobs.getLanguage().getMessage("signs.topline")));
else else
return; return;
@ -327,8 +326,9 @@ public class JobsListener implements Listener {
String command = CMIChatColor.stripColor(plugin.getComplement().getLine(event, 1)).toLowerCase(); String command = CMIChatColor.stripColor(plugin.getComplement().getLine(event, 1)).toLowerCase();
for (String key : Jobs.getLanguageManager().signKeys) { for (String key : Jobs.getLanguageManager().signKeys) {
if (command.equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.secondline." + key)))) { String secondLine = Jobs.getLanguage().getMessage("signs.secondline." + key);
plugin.getComplement().setLine(event, 1, convert(Jobs.getLanguage().getMessage("signs.secondline." + key))); if (command.equalsIgnoreCase(CMIChatColor.stripColor(secondLine))) {
plugin.getComplement().setLine(event, 1, convert(secondLine));
break; break;
} }
} }
@ -350,8 +350,9 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldLoad(WorldLoadEvent event) { public void onWorldLoad(WorldLoadEvent event) {
PluginManager pm = plugin.getServer().getPluginManager(); PluginManager pm = plugin.getServer().getPluginManager();
if (pm.getPermission("jobs.world." + event.getWorld().getName().toLowerCase()) == null) String name = event.getWorld().getName().toLowerCase();
pm.addPermission(new Permission("jobs.world." + event.getWorld().getName().toLowerCase(), PermissionDefault.TRUE)); if (pm.getPermission("jobs.world." + name) == null)
pm.addPermission(new Permission("jobs.world." + name, PermissionDefault.TRUE));
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
@ -452,11 +453,10 @@ public class JobsListener implements Listener {
return; return;
boolean shift = false, numberkey = false; boolean shift = false, numberkey = false;
ClickType click = event.getClick(); if (event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT)
if (click == ClickType.SHIFT_LEFT || click == ClickType.SHIFT_RIGHT)
shift = true; shift = true;
if (click == ClickType.NUMBER_KEY) if (event.getClick() == ClickType.NUMBER_KEY)
numberkey = true; numberkey = true;
SlotType slotType = event.getSlotType(); SlotType slotType = event.getSlotType();