mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-18 05:11:32 +01:00
Added option to prevent item durability loss to pay, #8
- Fix tab-complete overwrites the server tab-complete, so if tab-complete set to -1, then its working again.
This commit is contained in:
parent
12b2419f88
commit
29c353214d
@ -50,6 +50,7 @@ public class GeneralConfigManager {
|
||||
protected boolean payInCreative;
|
||||
protected boolean payExploringWhenFlying;
|
||||
protected boolean addXpPlayer;
|
||||
public boolean payItemDurabilityLoss;
|
||||
protected boolean hideJobsWithoutPermission;
|
||||
protected int maxJobs;
|
||||
protected boolean payNearSpawner;
|
||||
@ -518,6 +519,10 @@ public class GeneralConfigManager {
|
||||
c.addComment("add-xp-player", "Adds the Jobs xp received to the player's Minecraft XP bar");
|
||||
addXpPlayer = c.get("add-xp-player", false);
|
||||
|
||||
c.addComment("enable-pay-when-item-durability-loss", "Allows, when losing maximum durability of item then it does not pay the player until it is repaired.",
|
||||
"E.g. the player wants to enchant a item with enchanting table and the item has durability loss then not paying.");
|
||||
payItemDurabilityLoss = c.get("enable-pay-when-item-durability-loss", true);
|
||||
|
||||
c.addComment("modify-chat", "Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this.");
|
||||
modifyChat = c.get("modify-chat.use", true);
|
||||
modifyChatPrefix = c.get("modify-chat.prefix", "&c[");
|
||||
|
@ -23,7 +23,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -296,6 +295,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && item.getType().getMaxDurability() - item.getDurability() != item.getType().getMaxDurability())
|
||||
return;
|
||||
|
||||
// pay
|
||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jDamager == null)
|
||||
@ -395,6 +400,10 @@ public class JobsPaymentListener implements Listener {
|
||||
// Item in hand
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && item.getType().getMaxDurability() - item.getDurability() != item.getType().getMaxDurability())
|
||||
return;
|
||||
|
||||
// Protection for block break with silktouch
|
||||
if (Jobs.getGCManager().useSilkTouchProtection && item != null) {
|
||||
for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) {
|
||||
@ -465,6 +474,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && item.getType().getMaxDurability() - item.getDurability() != item.getType().getMaxDurability())
|
||||
return;
|
||||
|
||||
if (event.getState().equals(PlayerFishEvent.State.CAUGHT_FISH) && event.getCaught() instanceof Item) {
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
@ -847,6 +862,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
|
||||
ItemStack item = inv.getItem(0);
|
||||
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && item.getType().getMaxDurability() - item.getDurability() != item.getType().getMaxDurability())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
if (jPlayer == null)
|
||||
@ -1091,6 +1112,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(pDamager);
|
||||
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && item.getType().getMaxDurability() - item.getDurability() != item.getType().getMaxDurability())
|
||||
return;
|
||||
|
||||
// pay
|
||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
||||
|
||||
@ -1521,6 +1548,9 @@ public class JobsPaymentListener implements Listener {
|
||||
event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(event.getPlayer());
|
||||
if (iih.getType().toString().endsWith("_AXE")) {
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && iih.getType().getMaxDurability() - iih.getDurability() != iih.getType().getMaxDurability())
|
||||
return;
|
||||
final Location loc = event.getClickedBlock().getLocation();
|
||||
final JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
@ -27,6 +27,9 @@ public class TabComplete implements TabCompleter {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||
List<String> completionList = new ArrayList<>();
|
||||
|
||||
if (!args[0].equalsIgnoreCase("jobs"))
|
||||
return Collections.emptyList();
|
||||
|
||||
if (args.length == 1) {
|
||||
String PartOfCommand = args[0];
|
||||
List<String> temp = new ArrayList<>();
|
||||
|
Loading…
Reference in New Issue
Block a user