Fix invalid calls to 1.12 methods
This commit is contained in:
parent
1a256855e2
commit
6565fc5f4f
@ -729,30 +729,7 @@ public class FlagWatcher {
|
||||
return;
|
||||
|
||||
if (itemStack == null && getDisguise().getEntity() instanceof LivingEntity) {
|
||||
EntityEquipment equip = ((LivingEntity) getDisguise().getEntity()).getEquipment();
|
||||
|
||||
switch (slot) {
|
||||
case HAND:
|
||||
itemStack = equip.getItemInMainHand();
|
||||
break;
|
||||
case OFF_HAND:
|
||||
itemStack = equip.getItemInOffHand();
|
||||
break;
|
||||
case HEAD:
|
||||
itemStack = equip.getHelmet();
|
||||
break;
|
||||
case CHEST:
|
||||
itemStack = equip.getChestplate();
|
||||
break;
|
||||
case LEGS:
|
||||
itemStack = equip.getLeggings();
|
||||
break;
|
||||
case FEET:
|
||||
itemStack = equip.getBoots();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
itemStack = ReflectionManager.getEquipment(slot, getDisguise().getEntity());
|
||||
}
|
||||
|
||||
Object itemToSend = ReflectionManager.getNmsItem(itemStack);
|
||||
|
@ -46,8 +46,10 @@ import org.bukkit.*;
|
||||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -2024,6 +2026,28 @@ public class DisguiseUtilities {
|
||||
return list.toArray(new String[0]);
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack getSlot(PlayerInventory equip, EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case HAND:
|
||||
return equip.getItemInMainHand();
|
||||
case OFF_HAND:
|
||||
return equip.getItemInOffHand();
|
||||
case HEAD:
|
||||
return equip.getHelmet();
|
||||
case CHEST:
|
||||
return equip.getChestplate();
|
||||
case LEGS:
|
||||
return equip.getLeggings();
|
||||
case FEET:
|
||||
return equip.getBoots();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the self disguise to the player
|
||||
*/
|
||||
@ -2122,11 +2146,11 @@ public class DisguiseUtilities {
|
||||
manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, list).createPacket(0, list));
|
||||
} else {
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
Object item = ReflectionManager.getNmsItem(getSlot(player.getInventory(), slot));
|
||||
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
||||
ReflectionManager.createEnumItemSlot(slot),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getItem(slot)))
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(slot),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getItem(slot))));
|
||||
ReflectionManager.createEnumItemSlot(slot), item)
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(slot), item));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1121,9 @@ public class ReflectionManager {
|
||||
Method toMinecraft = getCraftMethod("util.CraftMagicNumbers", "getMaterialFromInternalName",
|
||||
String.class);
|
||||
|
||||
return (Material) toMinecraft.invoke(null, name);
|
||||
Object instance = toMinecraft.getDeclaringClass().getField("INSTANCE").get(null);
|
||||
|
||||
return (Material) toMinecraft.invoke(instance, name);
|
||||
}
|
||||
|
||||
Object mcKey = getNmsConstructor("MinecraftKey", String.class).newInstance(name);
|
||||
@ -1140,7 +1142,12 @@ public class ReflectionManager {
|
||||
return (Material) getMaterial.invoke(null, item);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().severe("Error when trying to convert '" + name + "' into a Material");
|
||||
ex.printStackTrace();
|
||||
|
||||
if (ex.getCause() != null) {
|
||||
ex.getCause().printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user