diff --git a/libs/WildStackerAPI-2023.2.jar b/libs/WildStackerAPI-2023.2.jar new file mode 100644 index 00000000..51918427 Binary files /dev/null and b/libs/WildStackerAPI-2023.2.jar differ diff --git a/libs/WildStackerAPI-latest.jar b/libs/WildStackerAPI-latest.jar deleted file mode 100644 index 4f77b7a8..00000000 Binary files a/libs/WildStackerAPI-latest.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index 7d83800d..ff5d5824 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,5 @@ - + 4.0.0 Jobs jobs @@ -10,6 +8,8 @@ http://maven.apache.org + 17 + 17 UTF-8 @@ -17,9 +17,9 @@ io.papermc.paper paper-api - 1.17.1-R0.1-SNAPSHOT + 1.20.1-R0.1-SNAPSHOT provided - + org.ow2.asm asm-commons @@ -80,12 +80,12 @@ 4.11.0 provided - - io.lumine - Mythic-Dist - 5.1.0-SNAPSHOT - provided - + + io.lumine + Mythic-Dist + 5.1.0-SNAPSHOT + provided + com.sk89q @@ -200,12 +200,13 @@ ${basedir}/libs/CMILib1.4.0.0.jar + com.bgsoftware WildStackerAPI latest system - ${basedir}/libs/WildStackerAPI-latest.jar + ${basedir}/libs/WildStackerAPI-2023.2.jar @@ -275,20 +276,19 @@ maven-compiler-plugin - 3.8.1 1.8 1.8 - + org.apache.maven.plugins maven-jar-plugin 2.3.1 - D:\MC\Server 1.20\plugins\ + D:\MC\Server 1.20\plugins\ - + \ No newline at end of file diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 55a8c183..f264fa9a 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -98,6 +98,7 @@ import com.gamingmesh.jobs.listeners.JobsPayment14Listener; import com.gamingmesh.jobs.listeners.JobsPaymentListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener; import com.gamingmesh.jobs.listeners.JobsPayment16Listener; +import com.gamingmesh.jobs.listeners.PlayerSignEdit1_20Listeners; import com.gamingmesh.jobs.selection.SelectionManager; import com.gamingmesh.jobs.stuff.Loging; import com.gamingmesh.jobs.stuff.TabComplete; @@ -155,7 +156,7 @@ public final class Jobs extends JavaPlugin { private GuiManager guiManager; private static JobsDAO dao; - private static List jobs; + private static List jobs = new ArrayList(); private static Job noneJob; private static Map usedSlots = new WeakHashMap<>(); @@ -799,6 +800,9 @@ public final class Jobs extends JavaPlugin { pm.registerEvents(new JobsPayment16Listener(), getInstance()); } + if (Version.isCurrentEqualOrHigher(Version.v1_20_R1)) { + pm.registerEvents(new PlayerSignEdit1_20Listeners(), getInstance()); + } if (getGCManager().useBlockProtection) { pm.registerEvents(new PistonProtectionListener(), getInstance()); } diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index e3af33ad..2b67b2c8 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -582,7 +582,8 @@ public class Placeholder { return convert(true); case maxjobs: - return Integer.toString(Jobs.getPlayerManager().getMaxJobs(user)); + int max = Jobs.getPlayerManager().getMaxJobs(user); + return Integer.toString(max == -1 ? 99 : max); default: break; diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 224963d1..15ef2a66 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -63,9 +63,9 @@ import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.stuff.Util; import net.Zrips.CMILib.ActionBar.CMIActionBar; +import net.Zrips.CMILib.Container.CMINumber; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.NBT.CMINBT; import net.Zrips.CMILib.Version.Version; @@ -488,10 +488,10 @@ public class PlayerManager { Jobs.getSignUtil().updateAllSign(job); job.updateTotalPlayers(); - jPlayer.maxJobsEquation = getMaxJobs(jPlayer); - + jPlayer.maxJobsEquation = CMINumber.clamp(getMaxJobs(jPlayer), 0, 9999); + // Removing from cached item boost for recalculation - cache.remove(jPlayer.getUniqueId()); + cache.remove(jPlayer.getUniqueId()); } private static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) { @@ -533,10 +533,10 @@ public class PlayerManager { Jobs.getSignUtil().updateAllSign(job); job.updateTotalPlayers(); - + // Removing from cached item boost for recalculation - cache.remove(jPlayer.getUniqueId()); - + cache.remove(jPlayer.getUniqueId()); + return true; } @@ -931,7 +931,8 @@ public class PlayerManager { * @return true if the player is under the given jobs size */ public boolean getJobsLimit(JobsPlayer jPlayer, short currentCount) { - return getMaxJobs(jPlayer) > currentCount; + int max = getMaxJobs(jPlayer); + return max == -1 ? true : max > currentCount; } /** @@ -1064,7 +1065,7 @@ public class PlayerManager { continue; } } - + jitems.add(getJobsItemByNbt(item)); } } @@ -1214,11 +1215,11 @@ public class PlayerManager { int playerMaxJobs = getMaxJobs(jPlayer); int playerCurrentJobs = jPlayer.progression.size(); - if (playerMaxJobs <= 0 || playerCurrentJobs >= playerMaxJobs) + if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs) return; for (Job one : Jobs.getJobs()) { - if (jPlayer.progression.size() >= playerMaxJobs) + if (playerMaxJobs != -1 && jPlayer.progression.size() >= playerMaxJobs) return; if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots()) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/give.java b/src/main/java/com/gamingmesh/jobs/commands/list/give.java index a631bb71..9f8ff994 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/give.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/give.java @@ -103,6 +103,7 @@ public class give implements Cmd { default: break; } + return true; } } \ No newline at end of file diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/limit.java b/src/main/java/com/gamingmesh/jobs/commands/list/limit.java index 72d30567..e76b5f41 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/limit.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/limit.java @@ -1,5 +1,7 @@ package com.gamingmesh.jobs.commands.list; +import java.text.DecimalFormat; + import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,7 +13,6 @@ import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.i18n.Language; import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Time.CMITimeManager; @@ -38,7 +39,7 @@ public class limit implements Cmd { } if (disabled) { - Language.sendMessage(sender,"command.limit.output.notenabled"); + Language.sendMessage(sender, "command.limit.output.notenabled"); return true; } @@ -64,7 +65,7 @@ public class limit implements Cmd { Language.sendMessage(sender, "command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type))); Language.sendMessage(sender, "command.limit.output." + typeName + "Limit", - "%current%", (int) (limit.getAmount(type) * 100) / 100D, + "%current%", new DecimalFormat("##.##").format(limit.getAmount(type)), "%total%", JPlayer.getLimit(type)); } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java b/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java index 8a8df026..67afc768 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java @@ -46,7 +46,8 @@ public class transfer implements Cmd { "%newjobname%", newjob.getDisplayName()); } Language.sendMessage(sender, "general.admin.success"); - } + } else + Language.sendMessage(sender, "general.admin.error"); } catch (Exception e) { Language.sendMessage(sender, "general.admin.error"); } diff --git a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java index c4e56e14..75321afd 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; @@ -107,7 +106,7 @@ public class BlockProtectionManager { // If timer is under 2 hours, we can run scheduler to remove it when time comes if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2) - Bp.setScheduler(CMIScheduler.get().runTaskLater(() -> { + Bp.setScheduler(CMIScheduler.get().runAtLocationLater(loc, () -> { remove(loc); }, (time - System.currentTimeMillis()) / 50)); diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 48256ef8..22cbc821 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang3.StringEscapeUtils; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -1572,6 +1572,8 @@ public class ConfigManager { return job; } } + + return null; } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index a4a98967..db601aaa 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -45,6 +45,7 @@ import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Version.Version; @@ -110,7 +111,7 @@ public class GeneralConfigManager { DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled, LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false, payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting; - + public boolean jobsshopenabled; public boolean DailyQuestsEnabled; @@ -272,11 +273,24 @@ public class GeneralConfigManager { // Load locale Jobs.getLanguageManager().load(); // title settings - Jobs.getTitleManager().load(); + try { + Jobs.getTitleManager().load(); + } catch (Throwable e) { + e.printStackTrace(); + } // restricted areas - Jobs.getRestrictedAreaManager().load(); + try { + Jobs.getRestrictedAreaManager().load(); + } catch (Throwable e) { + e.printStackTrace(); + } // restricted blocks - Jobs.getRestrictedBlockManager().load(); + try { + Jobs.getRestrictedBlockManager().load(); + } catch (Throwable e) { + e.printStackTrace(); + } + // Item/Block/mobs name list Jobs.getNameTranslatorManager().load(); // signs information @@ -425,7 +439,7 @@ public class GeneralConfigManager { c.addComment("DailyQuests.Enabled", "Enables or disables daily quests"); DailyQuestsEnabled = c.get("DailyQuests.Enabled", true); - + c.addComment("DailyQuests.ResetTime", "Defines time in 24hour format when we want to give out new daily quests", "Any daily quests given before reset will be invalid and new ones will be given out"); ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4); @@ -442,7 +456,7 @@ public class GeneralConfigManager { "For this to work, the player needs to get a new job for the timer to start.", "Counting in hours"); jobExpiryTime = c.get("JobExpirationTime", 0); - c.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use 0 for no maximum", "Keep in mind that jobs.max.[amount] will bypass this setting"); + c.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use -1 to disable limitations", "Keep in mind that jobs.max.[amount] will bypass this setting"); maxJobs = c.get("max-jobs", 3); c.addComment("disable-payment-if-max-level-reached", "Disabling the payment if the user reached the maximum level of a job."); @@ -456,7 +470,7 @@ public class GeneralConfigManager { c.addComment("prevent-shop-item-enchanting", "Prevent players to enchant items from the shop in the anvil with enchanted books"); preventShopItemEnchanting = c.get("prevent-shop-item-enchanting", true); - + c.addComment("jobs-shop-enabled", "Enables or disables jobs shop"); jobsshopenabled = c.get("jobs-shop-enabled", true); diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 72bad4a6..44c546ef 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -580,7 +580,7 @@ public class LanguageManager { c.get("command.transfer.help.info", "Transfer a player's job from an old job to a new job."); c.get("command.transfer.help.args", "[playername] [oldjob] [newjob]"); Jobs.getGCManager().getCommandArgs().put("transfer", Arrays.asList("[playername]", "[oldjob]", "[newjob]")); - c.get("command.transfer.output.target", "You have been transferred from %oldjobname% to %newjobname%."); + c.get("command.transfer.output.target", "&fYou have been transferred from %oldjobname% &fto %newjobname%."); c.get("command.promote.help.info", "Promote the player X levels in a job."); c.get("command.promote.help.args", "[playername] [jobname] [levels] (-cmd)"); diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index cdf3a685..08ac41fc 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -237,7 +237,7 @@ public class Job { if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty) now = Jobs.getGCManager().DynamicPaymentMaxPenalty; - + if (Double.isNaN(now)) now = 0; @@ -310,7 +310,7 @@ public class Job { }; String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName()); - + for (JobInfo info : getJobInfo(action.getType())) { if (condition.test(info, action)) { if (!info.isInLevelRange(level)) { diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 0a51170f..520bef13 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -43,6 +43,7 @@ import com.gamingmesh.jobs.economy.PaymentData; import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Container.CMINumber; import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Logs.CMIDebug; @@ -442,7 +443,7 @@ public class JobsPlayer { Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation(); eq.setVariable("totallevel", getTotalLevels()); - maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this); + maxJobsEquation = CMINumber.clamp(Jobs.getPlayerManager().getMaxJobs(this), 0, 9999); limits.put(type, (int) eq.getValue()); setSaved(false); } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index ed1a91b7..5d15387d 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -328,10 +328,10 @@ public class JobsListener implements Listener { String line1 = CMIChatColor.stripColor(plugin.getComplement().getLine(event, 1)); - if (CMIChatColor.stripColor(plugin.getComplement().getLine(event, 0)) - .equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !line1.equalsIgnoreCase("toplist")) + if (CMIChatColor.stripColor(plugin.getComplement().getLine(event, 0)).equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !line1.equalsIgnoreCase( + "toplist")) { event.setLine(0, convert(Jobs.getLanguage().getMessage("signs.topline"))); - else + } else return; if (!event.getPlayer().hasPermission("jobs.command.signs")) { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index b55614fc..aeca72d0 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -789,7 +789,7 @@ public final class JobsPaymentListener implements Listener { // HACK! The API doesn't allow us to easily determine the resulting number of // crafted items, so we're forced to compare the inventory before and after. - private void schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) { + public static void schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) { final ItemStack[] preInv = player.getInventory().getContents(); // Clone the array. The content may (was for me) be mutable. for (int i = 0; i < preInv.length; i++) { @@ -822,7 +822,7 @@ public final class JobsPaymentListener implements Listener { }, 1); } - private static boolean hasItems(ItemStack stack) { + public static boolean hasItems(ItemStack stack) { return stack != null && stack.getAmount() > 0; } @@ -838,7 +838,7 @@ public final class JobsPaymentListener implements Listener { Objects.equal(a.getEnchantments(), b.getEnchantments()); } - private static boolean isStackSumLegal(ItemStack a, ItemStack b) { + public static boolean isStackSumLegal(ItemStack a, ItemStack b) { // See if we can create a new item stack with the combined elements of a and b if (a == null || b == null) return true;// Treat null as an empty stack @@ -1602,6 +1602,9 @@ public final class JobsPaymentListener implements Listener { if (!Jobs.getGCManager().useBreederFinder || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) return; + if (event.getEntity().getType().equals(EntityType.TURTLE)) + CMIDebug.d(event.getSpawnReason()); + if (!event.getSpawnReason().toString().equalsIgnoreCase("BREEDING") && !event.getSpawnReason().toString().equalsIgnoreCase("EGG")) return; @@ -1840,7 +1843,7 @@ public final class JobsPaymentListener implements Listener { // either it's version 1.13+ and we're trying to strip a normal log like oak, // or it's 1.16+ and we're trying to strip a fungi like warped stem if ((Version.isCurrentEqualOrHigher(Version.v1_13_R1) && (block.getType().toString().endsWith("_LOG") || block.getType().toString().endsWith("_WOOD"))) || - (Version.isCurrentEqualOrHigher(Version.v1_16_R1) && (block.getType().toString().endsWith("_STEM") || block.getType().toString().endsWith("_HYPHAE")))) { + (Version.isCurrentEqualOrHigher(Version.v1_16_R1) && (block.getType().toString().endsWith("_STEM") || block.getType().toString().endsWith("_HYPHAE")))) { CMIScheduler.get().runTaskLater(() -> Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block), 1); } } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/PlayerSignEdit1_20Listeners.java b/src/main/java/com/gamingmesh/jobs/listeners/PlayerSignEdit1_20Listeners.java new file mode 100644 index 00000000..22b5b403 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/listeners/PlayerSignEdit1_20Listeners.java @@ -0,0 +1,97 @@ +package com.gamingmesh.jobs.listeners; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.block.sign.SignSide; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.event.inventory.SmithItemEvent; +import org.bukkit.event.player.PlayerSignOpenEvent; +import org.bukkit.event.player.PlayerSignOpenEvent.Cause; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.actions.ItemActionInfo; +import com.gamingmesh.jobs.container.ActionType; +import com.gamingmesh.jobs.container.JobsPlayer; + +import net.Zrips.CMILib.Colors.CMIChatColor; + +public class PlayerSignEdit1_20Listeners implements Listener { + + public PlayerSignEdit1_20Listeners() { + } + + Set signEditCache = new HashSet(); + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerSignOpenEvent(PlayerSignOpenEvent event) { + + if (!event.getCause().equals(Cause.INTERACT)) + return; + + SignSide side = event.getSign().getSide(event.getSide()); + + if (!event.getPlayer().hasPermission("jobs.command.signs") && CMIChatColor.stripColor(side.getLine(0)).equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline")))) { + event.setCancelled(true); + } + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onInventoryCraft(SmithItemEvent event) { + + // If event is nothing or place, do nothing + switch (event.getAction()) { + case NOTHING: + case PLACE_ONE: + case PLACE_ALL: + case PLACE_SOME: + return; + default: + break; + } + + if (event.getSlotType() != SlotType.CRAFTING) + return; + + if (!event.isLeftClick() && !event.isRightClick()) + return; + + if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) + return; + + if (!(event.getWhoClicked() instanceof Player)) + return; + + Player player = (Player) event.getWhoClicked(); + + //Check if inventory is full and using shift click, possible money dupping fix + if (player.getInventory().firstEmpty() == -1 && event.isShiftClick()) { + player.sendMessage(Jobs.getLanguage().getMessage("message.crafting.fullinventory")); + return; + } + + if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) + return; + + // check if player is riding + if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) + return; + + // check if in creative + if (!JobsPaymentListener.payIfCreative(player)) + return; + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); + if (jPlayer == null) + return; + + Jobs.action(jPlayer, new ItemActionInfo(event.getInventory().getResult(), ActionType.CRAFT)); + + } +} diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index 5e82a31f..0b71622d 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -3,6 +3,7 @@ package com.gamingmesh.jobs.stuff; import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; @@ -63,6 +64,12 @@ public final class Util { return blocks; } + private final static DecimalFormat dcf = new DecimalFormat("##.##"); + + public static String format2Decimals(double number) { + return dcf.format(number); + } + public static String getRealType(Entity entity) { if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) { return entity.getType().name();