mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-21 14:51:19 +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 payInCreative;
|
||||||
protected boolean payExploringWhenFlying;
|
protected boolean payExploringWhenFlying;
|
||||||
protected boolean addXpPlayer;
|
protected boolean addXpPlayer;
|
||||||
|
public boolean payItemDurabilityLoss;
|
||||||
protected boolean hideJobsWithoutPermission;
|
protected boolean hideJobsWithoutPermission;
|
||||||
protected int maxJobs;
|
protected int maxJobs;
|
||||||
protected boolean payNearSpawner;
|
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");
|
c.addComment("add-xp-player", "Adds the Jobs xp received to the player's Minecraft XP bar");
|
||||||
addXpPlayer = c.get("add-xp-player", false);
|
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.");
|
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);
|
modifyChat = c.get("modify-chat.use", true);
|
||||||
modifyChatPrefix = c.get("modify-chat.prefix", "&c[");
|
modifyChatPrefix = c.get("modify-chat.prefix", "&c[");
|
||||||
|
@ -23,7 +23,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -296,6 +295,12 @@ public class JobsPaymentListener implements Listener {
|
|||||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||||
return;
|
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
|
// pay
|
||||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
if (jDamager == null)
|
if (jDamager == null)
|
||||||
@ -395,6 +400,10 @@ public class JobsPaymentListener implements Listener {
|
|||||||
// Item in hand
|
// Item in hand
|
||||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
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
|
// Protection for block break with silktouch
|
||||||
if (Jobs.getGCManager().useSilkTouchProtection && item != null) {
|
if (Jobs.getGCManager().useSilkTouchProtection && item != null) {
|
||||||
for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) {
|
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()))
|
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||||
return;
|
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) {
|
if (event.getState().equals(PlayerFishEvent.State.CAUGHT_FISH) && event.getCaught() instanceof Item) {
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
if (jPlayer == null)
|
if (jPlayer == null)
|
||||||
@ -847,6 +862,12 @@ public class JobsPaymentListener implements Listener {
|
|||||||
if (!payIfCreative(player))
|
if (!payIfCreative(player))
|
||||||
return;
|
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);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
|
|
||||||
if (jPlayer == null)
|
if (jPlayer == null)
|
||||||
@ -1091,6 +1112,12 @@ public class JobsPaymentListener implements Listener {
|
|||||||
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
|
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
|
||||||
return;
|
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
|
// pay
|
||||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
||||||
|
|
||||||
@ -1521,6 +1548,9 @@ public class JobsPaymentListener implements Listener {
|
|||||||
event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
ItemStack iih = Jobs.getNms().getItemInMainHand(event.getPlayer());
|
ItemStack iih = Jobs.getNms().getItemInMainHand(event.getPlayer());
|
||||||
if (iih.getType().toString().endsWith("_AXE")) {
|
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 Location loc = event.getClickedBlock().getLocation();
|
||||||
final JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
|
final JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
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) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
List<String> completionList = new ArrayList<>();
|
List<String> completionList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (!args[0].equalsIgnoreCase("jobs"))
|
||||||
|
return Collections.emptyList();
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String PartOfCommand = args[0];
|
String PartOfCommand = args[0];
|
||||||
List<String> temp = new ArrayList<>();
|
List<String> temp = new ArrayList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user