1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 15:03:36 +01:00

Fixed issue when used the enchanted books, then can't enchanted properly

- Added argument for signUpdate command
- Removed hack for removing items from inventory when in browse GUI
- Version up for player gliding, because not exists in the API
This commit is contained in:
montlikadani 2019-08-28 18:20:27 +02:00
parent b9069e0137
commit d62349badc
5 changed files with 47 additions and 17 deletions

View File

@ -21,16 +21,27 @@ public class signupdate implements Cmd {
return true; return true;
} }
if (args[0].equalsIgnoreCase("all")) {
Jobs.getJobs().forEach(Jobs.getSignUtil()::SignUpdate);
return true;
}
Job oldjob = Jobs.getJob(args[0]); Job oldjob = Jobs.getJob(args[0]);
if (oldjob == null) {
SignTopType type = SignTopType.getType(args[0]);
if (type == SignTopType.toplist && oldjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true; return true;
} }
if (args.length == 2) {
SignTopType type = SignTopType.getType(args[1]);
if (type != null) {
Jobs.getSignUtil().SignUpdate(oldjob, type); Jobs.getSignUtil().SignUpdate(oldjob, type);
}
return true;
}
Jobs.getSignUtil().SignUpdate(oldjob);
return true; return true;
} }

View File

@ -59,7 +59,7 @@ public class JobItems {
if (enchants != null) { if (enchants != null) {
if (mat == CMIMaterial.ENCHANTED_BOOK) { if (mat == CMIMaterial.ENCHANTED_BOOK) {
EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta; EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta;
for (Entry<Enchantment, Integer> oneEnch : bookMeta.getEnchants().entrySet()) { for (Entry<Enchantment, Integer> oneEnch : enchants.entrySet()) {
bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true); bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true);
} }
} else { } else {
@ -100,13 +100,20 @@ public class JobItems {
meta.setLore(TranslatedLore); meta.setLore(TranslatedLore);
} }
if (enchants != null) { if (enchants != null) {
if (item.getType() == CMIMaterial.ENCHANTED_BOOK.getMaterial()) {
EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta;
for (Entry<Enchantment, Integer> oneEnch : enchants.entrySet()) {
bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true);
}
} else {
for (Entry<Enchantment, Integer> OneEnchant : enchants.entrySet()) { for (Entry<Enchantment, Integer> OneEnchant : enchants.entrySet()) {
meta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true); meta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true);
} }
} }
}
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} catch (Throwable e) { } catch (Exception e) {
} }
return null; return null;
} }

View File

@ -238,7 +238,7 @@ public class JobsListener implements Listener {
return; return;
event.setCancelled(true); event.setCancelled(true);
final ItemStack clicked = event.getCurrentItem(); //final ItemStack clicked = event.getCurrentItem();
GuiInfoList joblist = Jobs.getGUIManager().GuiList.get(player.getUniqueId()); GuiInfoList joblist = Jobs.getGUIManager().GuiList.get(player.getUniqueId());
@ -272,14 +272,15 @@ public class JobsListener implements Listener {
} }
player.updateInventory(); player.updateInventory();
if (event.getClick().isShiftClick() && clicked != null && !clicked.getType().equals(Material.AIR)) // hack, we don't need to remove items
/*if (event.getClick().isShiftClick() && clicked != null && !clicked.getType().equals(Material.AIR))
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
player.getInventory().remove(clicked); player.getInventory().remove(clicked);
player.updateInventory(); player.updateInventory();
} }
}, 1L); }, 1L);*/
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)

View File

@ -479,6 +479,7 @@ public class JobsPaymentListener implements Listener {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return; return;
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), block); Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), block);
} }
@ -1009,7 +1010,7 @@ public class JobsPaymentListener implements Listener {
UUID uuid = null; UUID uuid = null;
try { try {
uuid = UUID.fromString(playerName); uuid = UUID.fromString(playerName);
} catch (Throwable e) { } catch (IllegalArgumentException e) {
} }
if (uuid == null) if (uuid == null)
return; return;
@ -1702,7 +1703,7 @@ public class JobsPaymentListener implements Listener {
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return; return;
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R1) if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R2)
&& !Jobs.getGCManager().payExploringWhenGliding && player.isGliding()) && !Jobs.getGCManager().payExploringWhenGliding && player.isGliding())
return; return;

View File

@ -9,13 +9,14 @@ import org.bukkit.ChatColor;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
public class GiveItem { public class GiveItem {
public static void GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore, public static void GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore,
HashMap<Enchantment, Integer> hashMap) { HashMap<Enchantment, Integer> enchants) {
ItemStack itemStack = CMIMaterial.get(id, meta).newItemStack(); ItemStack itemStack = CMIMaterial.get(id, meta).newItemStack();
itemStack.setAmount(qty); itemStack.setAmount(qty);
ItemMeta ItemMeta = itemStack.getItemMeta(); ItemMeta ItemMeta = itemStack.getItemMeta();
@ -29,9 +30,18 @@ public class GiveItem {
ItemMeta.setLore(TranslatedLore); ItemMeta.setLore(TranslatedLore);
} }
for (Entry<Enchantment, Integer> OneEnchant : hashMap.entrySet()) { if (enchants != null) {
if (itemStack.getType() == CMIMaterial.ENCHANTED_BOOK.getMaterial()) {
EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) ItemMeta;
for (Entry<Enchantment, Integer> oneEnch : enchants.entrySet()) {
bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), false);
}
} else {
for (Entry<Enchantment, Integer> OneEnchant : enchants.entrySet()) {
ItemMeta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true); ItemMeta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true);
} }
}
}
if (name != null) if (name != null)
ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));