diff --git a/libs/StackMob-5.5.3.jar b/libs/StackMob-5.5.3.jar new file mode 100644 index 00000000..43c48557 Binary files /dev/null and b/libs/StackMob-5.5.3.jar differ diff --git a/pom.xml b/pom.xml index 1668b745..a8719d74 100644 --- a/pom.xml +++ b/pom.xml @@ -156,6 +156,10 @@ org.apache.logging.log4j log4j-slf4j-impl + + org.bukkit + bukkit + @@ -187,8 +191,9 @@ com.github.Nathat23 StackMob-5 - master-SNAPSHOT - provided + 5.5.3 + system + ${basedir}/libs/StackMob-5.5.3.jar diff --git a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java index c909840e..a959f224 100644 --- a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java +++ b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java @@ -111,6 +111,25 @@ public class ItemBoostManager { if (one.equalsIgnoreCase("exampleBoost")) continue; + List jobs = new ArrayList<>(); + for (String oneJ : cfg.get(one + ".jobs", Arrays.asList(""))) { + if (oneJ.equalsIgnoreCase("all")) { + jobs.addAll(Jobs.getJobs()); + } else { + 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()) { + Jobs.getPluginLogger().warning("Jobs list is empty for " + one + " boosted item!"); + continue; + } + List lore = new ArrayList<>(); if (cfg.getC().isList(one + ".lore")) { for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) { @@ -143,25 +162,6 @@ public class ItemBoostManager { b.add(oneC, cfg.get(one + "." + typeName + "Boost", 1D) - 1); } - List jobs = new ArrayList<>(); - for (String oneJ : cfg.get(one + ".jobs", Arrays.asList(""))) { - if (oneJ.equalsIgnoreCase("all")) { - jobs.addAll(Jobs.getJobs()); - } else { - 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()) { - Jobs.getPluginLogger().warning("Jobs list is empty for " + one + " boosted item!"); - continue; - } - 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; @@ -181,7 +181,7 @@ public class ItemBoostManager { // Lets add into legacy map if (one.contains("_")) { - item.setLegacyKey(one.split("_")[1].toLowerCase()); + item.setLegacyKey(one.split("_", 2)[1].toLowerCase()); LEGACY.put(item.getLegacyKey(), item); } diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index c73a7043..57292733 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -374,17 +374,17 @@ public class Placeholder { } private static JobProgression getProgFromValue(JobsPlayer user, String value) { - JobProgression j = null; try { int id = Integer.parseInt(value); if (id > 0) - j = user.getJobProgression().get(id - 1); - } catch (Exception e) { + return user.getJobProgression().get(id - 1); + } catch (IndexOutOfBoundsException | NumberFormatException e) { Job job = Jobs.getJob(value); if (job != null) - j = user.getJobProgression(job); + return user.getJobProgression(job); } - return j; + + return null; } private static Job getJobFromValue(String value) { diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 72655d1b..36e6761e 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -337,6 +337,7 @@ public class PlayerManager { for (JobProgression oneJ : jPlayer.getJobProgression()) dao.insertJob(jPlayer, oneJ); + dao.saveLog(jPlayer); dao.savePoints(jPlayer); dao.recordPlayersLimits(jPlayer); @@ -850,13 +851,16 @@ public class PlayerManager { if (cmd.contains(":")) { String[] split = cmd.split(":", 2); - String command = split[1]; - command = command.replace("[playerName]", player.getName()); - command = command.replace("[job]", job.getName()); + String command = ""; + if (split.length > 1) { + command = split[1]; + command = command.replace("[playerName]", player.getName()); + command = command.replace("[job]", job.getName()); + } if (split[0].equalsIgnoreCase("player:")) { player.performCommand(command); - } else if (split[0].equalsIgnoreCase("console:")) { + } else { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); } } else { @@ -1108,7 +1112,7 @@ public class PlayerManager { boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); } - if (victim != null && victim.hasMetadata(getMobSpawnerMetadata())) { + if (victim != null && victim.hasMetadata(mobSpawnerMetadata)) { Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", false, false); if (amount != 0D) boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount)); diff --git a/src/main/java/com/gamingmesh/jobs/Signs/jobsSign.java b/src/main/java/com/gamingmesh/jobs/Signs/jobsSign.java index 2771c611..9c40b50b 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/jobsSign.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/jobsSign.java @@ -138,9 +138,12 @@ public class jobsSign { } public String getIdentifier() { - if (getType() != SignTopType.toplist) - return getType().toString(); - return jobName != null ? jobName + ":" + getType().toString() : getType().toString(); + SignTopType type = getType(); + + if (type != SignTopType.toplist) + return type.toString(); + + return jobName != null ? jobName + ":" + type.toString() : type.toString(); } public static String getIdentifier(Job job, SignTopType type) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/area.java b/src/main/java/com/gamingmesh/jobs/commands/list/area.java index 6f7ad836..55ca40c6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/area.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/area.java @@ -25,27 +25,28 @@ public class area implements Cmd { Player player = (Player) sender; - RestrictedAreaManager ra = Jobs.getRestrictedAreaManager(); - if (args.length == 3) { if (args[0].equalsIgnoreCase("add")) { if (!Jobs.hasPermission(player, "jobs.area.add", true)) return true; - String name = args[1]; double bonus = 0D; try { bonus = Double.parseDouble(args[2]); } catch (NumberFormatException e) { return false; } + boolean wg = false; + String name = args[1]; if (name.startsWith("wg:")) { wg = true; name = name.substring("wg:".length(), name.length()); } + RestrictedAreaManager ra = Jobs.getRestrictedAreaManager(); + if (ra.isExist(name)) { sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist")); return true; @@ -78,6 +79,7 @@ public class area implements Cmd { if (!Jobs.hasPermission(player, "jobs.area.remove", true)) return true; + RestrictedAreaManager ra = Jobs.getRestrictedAreaManager(); String name = args[1]; if (!ra.isExist(name)) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java index b8de0de2..3b489027 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java @@ -421,7 +421,7 @@ public class editjobs implements Cmd { String materialName = jInfo.getName().toLowerCase().replace('_', ' '); materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1); - materialName = Jobs.getNameTranslatorManager().Translate(materialName, jInfo); + materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo); materialName = CMIChatColor.translate(materialName); rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName())) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java b/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java index 7964ccf7..650fcf11 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java @@ -133,7 +133,7 @@ public class editquests implements Cmd { String objName = target.toLowerCase().replace('_', ' '); objName = Character.toUpperCase(objName.charAt(0)) + objName.substring(1); if (o != null) - objName = Jobs.getNameTranslatorManager().Translate(objName, o.getAction(), o.getTargetId(), + objName = Jobs.getNameTranslatorManager().translate(objName, o.getAction(), o.getTargetId(), o.getTargetMeta(), target); objName = org.bukkit.ChatColor.translateAlternateColorCodes('&', objName); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java index b55e1105..0625b124 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java @@ -105,7 +105,7 @@ public class quests implements Cmd { for (java.util.Map oneAction : q.getQuest().getObjectives().values()) { for (Entry oneObjective : oneAction.entrySet()) { hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " + - Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue() + Jobs.getNameTranslatorManager().translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue() .getTargetMeta(), oneObjective.getValue().getTargetName()) + " " + q.getAmountDone(oneObjective.getValue()) + "/" + oneObjective.getValue().getAmount()); diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index 35a9b02d..e3429d34 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -25,11 +25,11 @@ public class NameTranslatorManager { private final List ListOfEntities = new ArrayList<>(), ListOfColors = new ArrayList<>(); private final Map ListOfEnchants = new HashMap<>(), ListOfMMEntities = new HashMap<>(); - public String Translate(String materialName, JobInfo info) { - return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName()); + public String translate(String materialName, JobInfo info) { + return translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName()); } - public String Translate(String materialName, ActionType action, Integer id, String meta, String name) { + public String translate(String materialName, ActionType action, Integer id, String meta, String name) { // Translating name to user friendly if (Jobs.getGCManager().UseCustomNames) switch (action) { diff --git a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java index 7c384379..09a4fb98 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java @@ -321,7 +321,7 @@ public class ShopManager { int i = 0; int y = 1; - for (String category : new java.util.HashSet<>(categories)) { + for (String category : new ArrayList<>(categories)) { ConfigurationSection nameSection = confCategory.getConfigurationSection(category); if (nameSection == null) { continue; @@ -372,12 +372,12 @@ public class ShopManager { sItem.setRequiredTotalLevels(nameSection.getInt("RequiredTotalLevels")); if (nameSection.isList("RequiredJobLevels")) { - HashMap requiredJobs = new HashMap<>(); + Map requiredJobs = new HashMap<>(); for (String one : nameSection.getStringList("RequiredJobLevels")) { if (!one.contains("-")) continue; - String[] split = one.split("-"); + String[] split = one.split("-", 2); String job = split[0]; int lvl = 1; if (split.length > 1) { @@ -430,7 +430,7 @@ public class ShopManager { if (!eachLine.contains("=")) continue; - String[] split = eachLine.split("="); + String[] split = eachLine.split("=", 2); Enchantment ench = CMIEnchantment.getEnchantment(split[0]); Integer level = 1; if (split.length > 1) { diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index 055448aa..c09df044 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -543,10 +543,6 @@ public class Job { this.quests.addAll(quests == null ? new ArrayList<>() : quests); } -// public Quest getNextQuest() { -// return getNextQuest(null, null); -// } - public Quest getNextQuest(List excludeQuests, Integer level) { List ls = new ArrayList<>(quests); Collections.shuffle(ls); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobConditions.java b/src/main/java/com/gamingmesh/jobs/container/JobConditions.java index 338b28d4..00ed35df 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobConditions.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobConditions.java @@ -35,30 +35,34 @@ public class JobConditions { this.node = node; for (String one : requires) { - if (one.toLowerCase().contains("j:")) { - String jobName = one.toLowerCase().replace("j:", "").split("-")[0]; + String cond = one.toLowerCase(); + + if (cond.contains("j:")) { + String[] split = cond.replace("j:", "").split("-", 2); int jobLevel = 0; try { - jobLevel = Integer.valueOf(one.toLowerCase().replace("j:", "").split("-")[1]); + jobLevel = Integer.valueOf(split[1]); } catch (NumberFormatException e) { continue; } - requiresJobs.put(jobName, jobLevel); + requiresJobs.put(split[0], jobLevel); } - if (one.toLowerCase().contains("p:")) { + if (cond.contains("p:")) { requiresPerm.add(one.replace("p:", "")); } } for (String one : perform) { - if (!one.toLowerCase().contains("p:")) + one = one.toLowerCase(); + + if (!one.contains("p:")) continue; - String clean = one.toLowerCase().substring("p:".length()); + String clean = one.substring("p:".length()); if (clean.contains("-")) { - String[] split = clean.split("-"); + String[] split = clean.split("-", 2); performPerm.put(split[0], split[1].equalsIgnoreCase("true")); } else { performPerm.put(clean, true); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobInfo.java b/src/main/java/com/gamingmesh/jobs/container/JobInfo.java index 5e7076dd..cc37bf12 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobInfo.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobInfo.java @@ -77,9 +77,9 @@ public class JobInfo { } public String getRealisticName() { - String materialName = getName().toLowerCase().replace('_', ' '); + String materialName = name.toLowerCase().replace('_', ' '); materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1); - materialName = Jobs.getNameTranslatorManager().Translate(actionType == ActionType.MMKILL ? getName() : materialName, this); + materialName = Jobs.getNameTranslatorManager().translate(actionType == ActionType.MMKILL ? name : materialName, this); materialName = CMIChatColor.translate(materialName); return materialName; } diff --git a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java index 9bbfc926..fd068908 100644 --- a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java +++ b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java @@ -165,7 +165,8 @@ public class BlockOwnerShip { } public int getTotal(UUID uuid) { - return blockOwnerShips.getOrDefault(uuid, new ArrayList<>()).size(); + List list = blockOwnerShips.get(uuid); + return list == null ? 0 : list.size(); } public void load() { @@ -192,12 +193,13 @@ public class BlockOwnerShip { for (String one : section.getKeys(false)) { String value = section.getString(one); List ls = new ArrayList<>(); + if (value.contains(";")) ls.addAll(Arrays.asList(value.split(";"))); else ls.add(value); - UUID uuid = null; + UUID uuid; try { uuid = UUID.fromString(one); } catch (IllegalArgumentException e) { @@ -255,6 +257,7 @@ public class BlockOwnerShip { for (Map.Entry> one : blockOwnerShips.entrySet()) { String full = ""; + for (blockLoc oneL : one.getValue()) { if (!full.isEmpty()) full += ";"; diff --git a/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java b/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java index c0cffb07..f92d55a9 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java @@ -1,6 +1,6 @@ package com.gamingmesh.jobs.hooks.stackMob; -import java.util.HashSet; +import java.util.Collection; import org.bukkit.entity.LivingEntity; import org.bukkit.plugin.java.JavaPlugin; @@ -16,7 +16,7 @@ public class StackMobHandler extends HookPlugin { return getPlugin().getEntityManager().isStackedEntity(entity); } - public HashSet getStackEntities() { + public Collection getStackEntities() { return getPlugin().getEntityManager().getStackEntities(); } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 048fe167..36e7a355 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -303,10 +303,18 @@ public class JobsPaymentListener implements Listener { if (jDamager == null || sheep.getColor() == null) return; - if (Jobs.getGCManager().payForStackedEntities && JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(sheep)) { - for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) { - if (stacked.getType() == sheep.getType()) { - Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getLivingEntity()).getColor().name(), ActionType.SHEAR)); + if (Jobs.getGCManager().payForStackedEntities) { + if (JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(sheep)) { + for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) { + if (stacked.getType() == sheep.getType()) { + Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getLivingEntity()).getColor().name(), ActionType.SHEAR)); + } + } + } else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(sheep)) { + for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) { + if (stacked.getEntity().getType() == sheep.getType()) { + Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getEntity()).getColor().name(), ActionType.SHEAR)); + } } } } @@ -537,10 +545,18 @@ public class JobsPaymentListener implements Listener { if (jDamager == null) return; - if (Jobs.getGCManager().payForStackedEntities && JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(animal)) { - for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) { - if (stacked.getType() == animal.getType()) { - Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.TAME)); + if (Jobs.getGCManager().payForStackedEntities) { + if (JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(animal)) { + for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) { + if (stacked.getType() == animal.getType()) { + Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.TAME)); + } + } + } else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(animal)) { + for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) { + if (stacked.getEntity().getType() == animal.getType()) { + Jobs.action(jDamager, new EntityActionInfo(stacked.getEntity(), ActionType.TAME)); + } } } } @@ -1230,10 +1246,18 @@ public class JobsPaymentListener implements Listener { return; } - if (Jobs.getGCManager().payForStackedEntities && JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(lVictim)) { - for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) { - if (stacked.getType() == lVictim.getType()) { - Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.KILL), e.getDamager(), stacked.getLivingEntity()); + if (Jobs.getGCManager().payForStackedEntities) { + if (JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(lVictim)) { + for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) { + if (stacked.getType() == lVictim.getType()) { + Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.KILL), e.getDamager(), stacked.getLivingEntity()); + } + } + } else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(lVictim)) { + for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) { + if (stacked.getEntity().getType() == lVictim.getType()) { + Jobs.action(jDamager, new EntityActionInfo(stacked.getEntity(), ActionType.KILL), e.getDamager(), stacked.getEntity()); + } } } }