mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-22 18:26:12 +01:00
Resolved issue with 1.14 and fixed claiming for crates.
This commit is contained in:
parent
8a3c04c650
commit
3c5f4e5185
@ -201,7 +201,39 @@ public class GUIKitSelector extends AbstractGUI {
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
|
||||
inventory.setItem(index, item);
|
||||
registerClickable(index, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (type == ClickType.MIDDLE && player.hasPermission("ultimatekits.admin")) {
|
||||
kitsmode = !kitsmode;
|
||||
constructGUI();
|
||||
return;
|
||||
}
|
||||
|
||||
if (kitsmode) {
|
||||
if (type == ClickType.RIGHT) {
|
||||
plugin.getKitManager().moveKit(kit, true);
|
||||
} else if (type == ClickType.LEFT) {
|
||||
plugin.getKitManager().moveKit(kit, false);
|
||||
}
|
||||
setUpPage();
|
||||
constructGUI();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (type == ClickType.LEFT) {
|
||||
kit.display(player, this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ClickType.RIGHT) {
|
||||
kit.buy(player);
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
|
||||
id++;
|
||||
}
|
||||
|
||||
@ -248,40 +280,6 @@ public class GUIKitSelector extends AbstractGUI {
|
||||
|
||||
registerClickable(max - 5, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
registerClickable(glassless ? 0 : 10, glassless ? max : max - 11, (player1, inventory1, cursor, slot, type) -> {
|
||||
String kitName = inventory1.getItem(slot).getItemMeta().getDisplayName().replace(String.valueOf(ChatColor.COLOR_CHAR), "").split(":")[0];
|
||||
|
||||
if (type == ClickType.MIDDLE && player.hasPermission("ultimatekits.admin")) {
|
||||
kitsmode = !kitsmode;
|
||||
constructGUI();
|
||||
return;
|
||||
}
|
||||
|
||||
Kit kit = plugin.getKitManager().getKit(kitName);
|
||||
|
||||
if (kitsmode) {
|
||||
if (type == ClickType.RIGHT) {
|
||||
plugin.getKitManager().moveKit(kit, true);
|
||||
} else if (type == ClickType.LEFT) {
|
||||
plugin.getKitManager().moveKit(kit, false);
|
||||
}
|
||||
setUpPage();
|
||||
constructGUI();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (type == ClickType.LEFT) {
|
||||
kit.display(player, this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ClickType.RIGHT) {
|
||||
kit.buy(player);
|
||||
constructGUI();
|
||||
}
|
||||
});
|
||||
|
||||
registerClickable(max - 6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (page == 1) return;
|
||||
page --;
|
||||
|
@ -51,28 +51,24 @@ public class InteractListeners implements Listener {
|
||||
if (player.isSneaking()) return;
|
||||
event.setCancelled(true);
|
||||
|
||||
if (player.getItemInHand() != null && player.getItemInHand().getType() != null && player.getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
|
||||
if (player.getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
|
||||
event.setCancelled(true);
|
||||
kit.give(player, true, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (kitBlockData.getType() != KitType.PREVIEW) {
|
||||
if (kitBlockData.getType() == KitType.CRATE) {
|
||||
if (!kit.hasPermission(player)) {
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.general.noperms"));
|
||||
return;
|
||||
}
|
||||
if (kit.getNextUse(player) <= 0) {
|
||||
kit.give(player, false, false, false);
|
||||
kit.updateDelay(player);
|
||||
} else {
|
||||
long time = kit.getNextUse(player);
|
||||
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.crate.notyet", Methods.makeReadable(time))));
|
||||
} else if (kitBlockData.getType() == KitType.CLAIM) {
|
||||
if (!kit.hasPermission(player)) {
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.general.noperms"));
|
||||
return;
|
||||
}
|
||||
if (kit.getNextUse(player) <= 0) {
|
||||
kit.give(player, false, false, false);
|
||||
kit.updateDelay(player);
|
||||
} else {
|
||||
long time = kit.getNextUse(player);
|
||||
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.crate.notyet", Methods.makeReadable(time))));
|
||||
}
|
||||
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix()
|
||||
+ instance.getLocale().getMessage("event.crate.notyet", Methods.makeReadable(time))));
|
||||
}
|
||||
} else if (kit.getLink() != null || kit.getPrice() != 0) {
|
||||
kit.buy(player);
|
||||
@ -87,7 +83,7 @@ public class InteractListeners implements Listener {
|
||||
new GUIBlockEditor(instance, player, block.getLocation());
|
||||
return;
|
||||
}
|
||||
if (player.getItemInHand() != null && player.getItemInHand().getType() != null && player.getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
|
||||
if (player.getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
|
||||
event.setCancelled(true);
|
||||
kit.give(player, true, false, false);
|
||||
return;
|
||||
|
@ -1,26 +1,11 @@
|
||||
package com.songoda.ultimatekits.utils;
|
||||
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
|
||||
public class ItemSerializer {
|
||||
|
||||
@ -38,6 +23,7 @@ public class ItemSerializer {
|
||||
|
||||
private Method methodParseString;
|
||||
private Method methodCreateStack;
|
||||
private Method methodToItemStack;
|
||||
private Method methodTobItemStack;
|
||||
private Method methodTocItemStack;
|
||||
private Method methodSaveTagToStack;
|
||||
@ -52,7 +38,9 @@ public class ItemSerializer {
|
||||
*/
|
||||
public ItemSerializer() throws NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
methodParseString = classMojangsonParser.getMethod("parse", String.class);
|
||||
if (UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_11))
|
||||
if (UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
methodToItemStack = classItemStack.getMethod("a", classNBTTagCompound);
|
||||
else if (UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_11))
|
||||
constructorItemStack = classItemStack.getConstructor(classNBTTagCompound);
|
||||
else
|
||||
methodCreateStack = classItemStack.getMethod("createStack", classNBTTagCompound);
|
||||
@ -84,7 +72,14 @@ public class ItemSerializer {
|
||||
public ItemStack deserializeItemStackFromJson(String jsonString) {
|
||||
try {
|
||||
Object nbtTagCompound = methodParseString.invoke(null, jsonString);
|
||||
Object citemStack = UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_11) ? constructorItemStack.newInstance(nbtTagCompound) : methodCreateStack.invoke(null, nbtTagCompound);
|
||||
Object citemStack;
|
||||
|
||||
if (UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
citemStack = methodToItemStack.invoke(null, nbtTagCompound);
|
||||
else if (UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_11))
|
||||
citemStack = constructorItemStack.newInstance(nbtTagCompound);
|
||||
else
|
||||
citemStack = methodCreateStack.invoke(null, nbtTagCompound);
|
||||
|
||||
return (ItemStack) methodTobItemStack.invoke(null, citemStack);
|
||||
} catch (Exception ex) {
|
||||
|
@ -176,12 +176,12 @@ public class SettingsManager implements Listener {
|
||||
o5("Main.Dont Preview Commands In Kits", false),
|
||||
o6("Main.Hologram Layout", Arrays.asList("{TITLE}", "{LEFT-CLICK}", "{RIGHT-CLICK}")),
|
||||
o7("Main.Sounds Enabled", true),
|
||||
o8("Main.Sound Played While Clicking In Inventories", UltimateKits.getInstance().isServerVersion(ServerVersion.V1_13) ? "ENTITY_ENDERMAN_TELEPORT" : "ENTITY_ENDERMEN_TELEPORT"),
|
||||
o8("Main.Sound Played While Clicking In Inventories", UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_13) ? "ENTITY_ENDERMAN_TELEPORT" : "ENTITY_ENDERMEN_TELEPORT"),
|
||||
o85("Main.Prevent The Redeeming of a Kit When Inventory Is Full", true),
|
||||
o342("Main.Display Chance In Preview", true),
|
||||
CURRENCY_SYMBOL("Main.Currency Symbol", "$"),
|
||||
|
||||
EXIT_ICON("Interfaces.Exit Icon", UltimateKits.getInstance().isServerVersion(ServerVersion.V1_13) ? "OAK_DOOR" : "WOOD_DOOR"),
|
||||
EXIT_ICON("Interfaces.Exit Icon", UltimateKits.getInstance().isServerVersionAtLeast(ServerVersion.V1_13) ? "OAK_DOOR" : "WOOD_DOOR"),
|
||||
BUY_ICON("Interfaces.Buy Icon", "EMERALD"),
|
||||
GLASS_TYPE_1("Interfaces.Glass Type 1", 7),
|
||||
GLASS_TYPE_2("Interfaces.Glass Type 2", 11),
|
||||
|
Loading…
Reference in New Issue
Block a user