diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index 7a1fe156..7772c597 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -525,8 +525,10 @@ public class PlayerManager { if (Perm(player, "jobs.max.*")) return true; + int totalJobs = Jobs.getJobs().size() + 5; + short count = (short) ConfigManager.getJobsConfiguration().getMaxJobs(); - for (short ctr = 0; ctr < 30; ctr++) { + for (short ctr = 0; ctr < totalJobs; ctr++) { if (Perm(player, "jobs.max." + ctr)) count = ctr; if (count > currentCount) diff --git a/com/gamingmesh/jobs/Signs/SignUtil.java b/com/gamingmesh/jobs/Signs/SignUtil.java index 9471dc50..d99c2edb 100644 --- a/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/com/gamingmesh/jobs/Signs/SignUtil.java @@ -168,8 +168,8 @@ public class SignUtil { UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse); } else { String PlayerName = ((TopList) PlayerList.get(0)).getPlayerName(); - if (PlayerName.length() > 18) { - String PlayerNameStrip = PlayerName.split("(?<=\\G.{13})")[0]; + if (PlayerName.length() > 8) { + String PlayerNameStrip = PlayerName.split("(?<=\\G.{7})")[0]; PlayerName = PlayerNameStrip + "~"; } String line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".1"); diff --git a/com/gamingmesh/jobs/config/JobConfig.java b/com/gamingmesh/jobs/config/JobConfig.java index e85ab414..5dd8ce6c 100644 --- a/com/gamingmesh/jobs/config/JobConfig.java +++ b/com/gamingmesh/jobs/config/JobConfig.java @@ -461,8 +461,11 @@ public class JobConfig { if (entity != null && entity.isAlive()) { type = entity.toString(); - id = entity.getTypeId(); + + // using breeder finder + if (actionType == ActionType.BREED) + ConfigManager.getJobsConfiguration().setBreederFinder(true); } // Just to recognize wither skeleton @@ -511,6 +514,9 @@ public class JobConfig { continue; } + if (actionType == ActionType.TNTBREAK) + ConfigManager.getJobsConfiguration().setTntFinder(true); + double income = section.getDouble("income", 0.0); double experience = section.getDouble("experience", 0.0); diff --git a/com/gamingmesh/jobs/config/JobsConfiguration.java b/com/gamingmesh/jobs/config/JobsConfiguration.java index 1c6b197c..e155d5a8 100644 --- a/com/gamingmesh/jobs/config/JobsConfiguration.java +++ b/com/gamingmesh/jobs/config/JobsConfiguration.java @@ -84,7 +84,9 @@ public class JobsConfiguration { public boolean useBlockProtection; public boolean useBlockTimer; public boolean useMinimumOveralPayment; - public boolean useBreederFinder, CancelCowMilking; + public boolean useBreederFinder = false; + private boolean useTnTFinder = false; + public boolean CancelCowMilking; public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, EmptyServerAcountActionBar, JobsToggleEnabled, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, @@ -129,6 +131,22 @@ public class JobsConfiguration { return text; } + public void setBreederFinder(boolean state) { + this.useBreederFinder = state; + } + + public boolean isUseBreederFinder() { + return this.useBreederFinder; + } + + public void setTntFinder(boolean state) { + this.useTnTFinder = state; + } + + public boolean isUseTntFinder() { + return this.useTnTFinder; + } + /** * Get how often in minutes to save job information * @return how often in minutes to save job information @@ -172,7 +190,7 @@ public class JobsConfiguration { public synchronized boolean payInCreative() { return payInCreative; } - + /** * Function that tells if the player should be paid while exploring and flying * @return true - pay @@ -389,7 +407,7 @@ public class JobsConfiguration { "Theroticali this should work without issues, but if you havving some, just disable", "But then you can feal some small (100-200ms) lag spikes while performings some jobs commands"); LocalOfflinePlayersData = getBoolean("Optimizations.UseLocalOfflinePlayersData", true, config, writer); - + writer.addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics", "This is still in development and in feature it will expand"); LoggingUse = getBoolean("Logging.Use", false, config, writer); @@ -424,7 +442,7 @@ public class JobsConfiguration { writer.addComment("enable-pay-creative", "Option to allow payment to be made in creative mode"); payInCreative = getBoolean("enable-pay-creative", false, config, writer); - + writer.addComment("enable-pay-for-exploring-when-flying", "Option to allow payment to be made for exploring when player flyies"); payExploringWhenFlying = getBoolean("enable-pay-for-exploring-when-flying", false, config, writer); diff --git a/com/gamingmesh/jobs/container/ActionType.java b/com/gamingmesh/jobs/container/ActionType.java index d1f416ab..829f5856 100644 --- a/com/gamingmesh/jobs/container/ActionType.java +++ b/com/gamingmesh/jobs/container/ActionType.java @@ -20,6 +20,7 @@ package com.gamingmesh.jobs.container; public enum ActionType { BREAK("Break"), + TNTBREAK("TNTBreak"), PLACE("Place"), KILL("Kill"), MMKILL("MMKill"), @@ -35,6 +36,7 @@ public enum ActionType { SHEAR("Shear"), MILK("Milk"), EXPLORE("Explore"), + EAT("Eat"), CUSTOMKILL("custom-kill"); private String name; diff --git a/com/gamingmesh/jobs/listeners/JobsListener.java b/com/gamingmesh/jobs/listeners/JobsListener.java index 052e2585..c2662f5f 100644 --- a/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/com/gamingmesh/jobs/listeners/JobsListener.java @@ -425,7 +425,7 @@ public class JobsListener implements Listener { return; Player player = event.getPlayer(); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); - String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : ""; + String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; if (honorific.equalsIgnoreCase(" ")) honorific = ""; String format = event.getFormat(); @@ -444,7 +444,7 @@ public class JobsListener implements Listener { return; Player player = event.getPlayer(); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); - String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : ""; + String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; if (honorific.equalsIgnoreCase(" ")) honorific = ""; String format = event.getFormat(); diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index f426f740..2ec0b1c5 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -25,6 +25,7 @@ import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; @@ -45,8 +46,10 @@ import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityTameEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.SlimeSplitEvent; import org.bukkit.event.inventory.BrewEvent; import org.bukkit.event.inventory.CraftItemEvent; @@ -82,6 +85,7 @@ import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.i18n.Language; import com.gamingmesh.jobs.stuff.ActionBar; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Perm; import com.gmail.nossr50.api.AbilityAPI; import com.google.common.base.Objects; @@ -290,7 +294,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -1002,13 +1006,15 @@ public class JobsPaymentListener implements Listener { double closest = 30.0; Player player = null; for (Player i : Bukkit.getOnlinePlayers()) { - if (i.getWorld().getName().equals(animal.getWorld().getName())) { - double dist = i.getLocation().distance(animal.getLocation()); - if (closest > dist) { - closest = dist; - player = i; - } + if (!i.getWorld().getName().equals(animal.getWorld().getName())) + continue; + + double dist = i.getLocation().distance(animal.getLocation()); + if (closest > dist) { + closest = dist; + player = i; } + } if (player != null && closest < 30.0) { @@ -1036,6 +1042,120 @@ public class JobsPaymentListener implements Listener { } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerEat(FoodLevelChangeEvent event) { + + // make sure plugin is enabled + if (!plugin.isEnabled()) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + if (event.getEntity().hasMetadata("NPC")) + return; + + if (event.getFoodLevel() <= ((Player) event.getEntity()).getFoodLevel()) + return; + + Player player = (Player) event.getEntity(); + + if (!player.isOnline()) + return; + + // check if in creative + if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + return; + + if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) + return; + + // restricted area multiplier + double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); + + // Item in hand + ItemStack item = player.getItemInHand(); + + // Wearing armor + ItemStack[] armor = player.getInventory().getArmorContents(); + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); + if (jPlayer == null) + return; + + Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.EAT), multiplier, item, armor); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onTntExplode(EntityExplodeEvent event) { + + // make sure plugin is enabled + if (!plugin.isEnabled()) + return; + + if (!ConfigManager.getJobsConfiguration().isUseTntFinder()) + return; + + if (event.getEntityType() != EntityType.PRIMED_TNT && event.getEntityType() != EntityType.MINECART_TNT) + return; + + double closest = 30.0; + Player player = null; + Location loc = event.getEntity().getLocation(); + for (Player i : Bukkit.getOnlinePlayers()) { + + if (loc.getWorld() != i.getWorld()) + continue; + + double dist = i.getLocation().distance(loc); + if (closest > dist) { + closest = dist; + player = i; + } + } + + if (player == null || closest == 30.0) + return; + + if (!player.isOnline()) + return; + + // check if in creative + if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + return; + + if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) + return; + + // restricted area multiplier + double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); + + // Item in hand + ItemStack item = player.getItemInHand(); + + // Wearing armor + ItemStack[] armor = player.getInventory().getArmorContents(); + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); + if (jPlayer == null) + return; + + for (Block block : event.blockList()) { + if (block == null) + continue; + + if (block.getType().equals(Material.FURNACE) && block.hasMetadata(furnaceOwnerMetadata)) + block.removeMetadata(furnaceOwnerMetadata, plugin); + + if (ConfigManager.getJobsConfiguration().useBlockProtection) + if (block.getState().hasMetadata(BlockMetadata)) + return; + + BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.TNTBREAK); + Jobs.action(jPlayer, bInfo, multiplier, item, armor); + } + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { if (!plugin.isEnabled()) @@ -1060,7 +1180,7 @@ public class JobsPaymentListener implements Listener { @EventHandler public void onExplore(JobsChunkChangeEvent event) { - + if (!Jobs.getExplore().isExploreEnabled()) return; diff --git a/jobConfig.yml b/jobConfig.yml index 5f8625be..04c373f0 100644 --- a/jobConfig.yml +++ b/jobConfig.yml @@ -126,6 +126,11 @@ Jobs: income: 5.0 # base experience experience: 5.0 + # payment for breaking a block with tnt + TNTBreak: + LOG: + income: 5.0 + experience: 5.0 # payment for placing a block Place: SAPLING: @@ -165,6 +170,14 @@ Jobs: Wolf: income: 2.0 experience: 5.0 + # Eating food + Eat: + cooked_rabbit: + income: 5 + experience: 5 + baked_potato: + income: 5 + experience: 5 # Milking cows, only one option is available Milk: Cow: diff --git a/plugin.yml b/plugin.yml index 8b9ab422..064bafde 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 2.58.0 +version: 2.59.0 author: phrstbrn softdepend: [Vault, CoreProtect, MythicMobs, McMMO] commands: