mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-24 14:33:51 +00:00
Merge branch '2.x' into 1.13
This commit is contained in:
commit
d1d5ae814f
41 changed files with 704 additions and 356 deletions
|
@ -170,7 +170,7 @@ public class MetaItemStack {
|
|||
try {
|
||||
// 1.8
|
||||
banner = Material.valueOf("BANNER");
|
||||
|
||||
|
||||
// 1.9
|
||||
shield = Material.valueOf("SHIELD");
|
||||
} catch(IllegalArgumentException ignored){}
|
||||
|
@ -189,7 +189,7 @@ public class MetaItemStack {
|
|||
meta.setLore(lore);
|
||||
stack.setItemMeta(meta);
|
||||
} else if (split[0].equalsIgnoreCase("unbreakable") && hasMetaPermission(sender, "unbreakable", false, true, ess)) {
|
||||
boolean value = split.length > 1 ? Boolean.valueOf(split[1]) : true;
|
||||
boolean value = split.length > 1 ? Boolean.valueOf(split[1]) : true;
|
||||
setUnbreakable(stack, value);
|
||||
} else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && (stack.getType() == Material.SKELETON_SKULL || stack.getType() == Material.WITHER_SKELETON_SKULL) && hasMetaPermission(sender, "head", false, true, ess)) {
|
||||
if (stack.getDurability() == 3) {
|
||||
|
@ -494,7 +494,7 @@ public class MetaItemStack {
|
|||
if (split.length < 2) {
|
||||
throw new Exception(tl("invalidBanner", split[1]));
|
||||
}
|
||||
|
||||
|
||||
PatternType patternType = null;
|
||||
try {
|
||||
patternType = PatternType.valueOf(split[0]);
|
||||
|
@ -560,22 +560,36 @@ public class MetaItemStack {
|
|||
}
|
||||
}
|
||||
|
||||
private static int bukkitUnbreakableSupport = -1;
|
||||
private static Method spigotMethod;
|
||||
private static Method setUnbreakableMethod;
|
||||
|
||||
private void setUnbreakable(ItemStack is, boolean unbreakable) {
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
try {
|
||||
if (spigotMethod == null) {
|
||||
spigotMethod = meta.getClass().getDeclaredMethod("spigot");
|
||||
spigotMethod.setAccessible(true);
|
||||
if (bukkitUnbreakableSupport == -1) {
|
||||
try {
|
||||
ItemMeta.class.getDeclaredMethod("setUnbreakable", boolean.class);
|
||||
bukkitUnbreakableSupport = 1;
|
||||
} catch (NoSuchMethodException | SecurityException ex) {
|
||||
bukkitUnbreakableSupport = 0;
|
||||
}
|
||||
}
|
||||
Object itemStackSpigot = spigotMethod.invoke(meta);
|
||||
if (setUnbreakableMethod == null) {
|
||||
setUnbreakableMethod = itemStackSpigot.getClass().getDeclaredMethod("setUnbreakable", Boolean.TYPE);
|
||||
setUnbreakableMethod.setAccessible(true);
|
||||
|
||||
if (bukkitUnbreakableSupport == 1) {
|
||||
meta.setUnbreakable(unbreakable);
|
||||
} else {
|
||||
if (spigotMethod == null) {
|
||||
spigotMethod = meta.getClass().getDeclaredMethod("spigot");
|
||||
spigotMethod.setAccessible(true);
|
||||
}
|
||||
Object itemStackSpigot = spigotMethod.invoke(meta);
|
||||
if (setUnbreakableMethod == null) {
|
||||
setUnbreakableMethod = itemStackSpigot.getClass().getDeclaredMethod("setUnbreakable", Boolean.TYPE);
|
||||
setUnbreakableMethod.setAccessible(true);
|
||||
}
|
||||
setUnbreakableMethod.invoke(itemStackSpigot, unbreakable);
|
||||
}
|
||||
setUnbreakableMethod.invoke(itemStackSpigot, unbreakable);
|
||||
is.setItemMeta(meta);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue