Mirror von
https://github.com/St3venAU/ArmorStandTools.git
synchronisiert 2024-12-28 04:20:08 +01:00
2.1.1 Fix errors in 1.8
Dieser Commit ist enthalten in:
Ursprung
d66c6c5e1e
Commit
20e4a34a1a
@ -42,7 +42,7 @@ class ArmorStandGUI implements Listener {
|
||||
im.setDisplayName(" ");
|
||||
filler.setItemMeta(im);
|
||||
invSlots.add(10);
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
invSlots.add(12);
|
||||
}
|
||||
invSlots.add(2);
|
||||
@ -68,7 +68,7 @@ class ArmorStandGUI implements Listener {
|
||||
i.setItem(tool.getSlot(), updateLore(tool));
|
||||
}
|
||||
}
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
i.setItem(10, as.getEquipment().getItemInMainHand());
|
||||
i.setItem(12, as.getEquipment().getItemInOffHand());
|
||||
} else {
|
||||
@ -253,7 +253,7 @@ class ArmorStandGUI implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
if(as == null || i == null) return;
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
as.getEquipment().setItemInMainHand(i.getItem(10));
|
||||
as.getEquipment().setItemInOffHand(i.getItem(12));
|
||||
} else {
|
||||
|
@ -123,7 +123,17 @@ public enum ArmorStandTool {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static ArmorStandTool get(Player p) {
|
||||
return get(Main.oneNine ? p.getInventory().getItemInMainHand() : p.getItemInHand());
|
||||
}
|
||||
|
||||
static boolean isTool(ItemStack is) {
|
||||
return get(is) != null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static boolean isHoldingTool(Player p) {
|
||||
return isTool(Main.oneNine ? p.getInventory().getItemInMainHand() : p.getItemInHand());
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ class Config {
|
||||
isOn, isOff, gravity, arms, invul, equip, locked,
|
||||
unLocked, notConsole, giveMsg1, giveMsg2, conReload,
|
||||
noRelPerm, noAirError, pleaseWait, appliedHead,
|
||||
noHead, invalidName, wgNoPerm, currently, headFailed,
|
||||
invalidName, wgNoPerm, currently, headFailed,
|
||||
noCommandPerm, generalNoPerm, armorStand, none,
|
||||
enabled, disabled, guiInUse;
|
||||
|
||||
@ -77,7 +77,6 @@ class Config {
|
||||
noAirError = languageConfig.getString("noAirError");
|
||||
pleaseWait = languageConfig.getString("pleaseWait");
|
||||
appliedHead = languageConfig.getString("appliedHead");
|
||||
noHead = languageConfig.getString("noHead");
|
||||
invalidName = languageConfig.getString("invalidName");
|
||||
wgNoPerm = languageConfig.getString("wgNoPerm");
|
||||
noCommandPerm = languageConfig.getString("noCommandPerm");
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
@ -27,12 +26,12 @@ public class Main extends JavaPlugin {
|
||||
public final HashMap<UUID, ItemStack[]> savedInventories = new HashMap<UUID, ItemStack[]>();
|
||||
private final EulerAngle zero = new EulerAngle(0D, 0D, 0D);
|
||||
static String NMS_VERSION;
|
||||
static boolean one_nine;
|
||||
static boolean oneNine;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NMS_VERSION = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
one_nine = NMS_VERSION.startsWith("v1_9");
|
||||
oneNine = NMS_VERSION.startsWith("v1_9");
|
||||
getServer().getPluginManager().registerEvents(new MainListener(this), this);
|
||||
CommandExecutor ce = new Commands(this);
|
||||
getCommand("astools").setExecutor(ce);
|
||||
@ -82,7 +81,7 @@ public class Main extends JavaPlugin {
|
||||
String hand, boots, legs, chest, helm, offHand = "0";
|
||||
int handDmg, offHandDmg = 0;
|
||||
|
||||
if(one_nine) {
|
||||
if(oneNine) {
|
||||
hand = as.getEquipment().getItemInMainHand() == null ? "air" : Utils.getNmsName(as.getEquipment().getItemInMainHand().getType());
|
||||
offHand = as.getEquipment().getItemInOffHand() == null ? "air" : Utils.getNmsName(as.getEquipment().getItemInOffHand().getType());
|
||||
boots = as.getBoots() == null ? "air" : Utils.getNmsName(as.getBoots().getType());
|
||||
@ -111,7 +110,7 @@ public class Main extends JavaPlugin {
|
||||
EulerAngle ra = as.getRightArmPose();
|
||||
EulerAngle bo = as.getBodyPose();
|
||||
String cmd;
|
||||
if(one_nine) {
|
||||
if(oneNine) {
|
||||
cmd = "summon ArmorStand " + Utils.twoDec(loc.getX()) + " " + Utils.twoDec(loc.getY()) + " " + Utils.twoDec(loc.getZ()) + " {"
|
||||
+ (as.getMaxHealth() != 20 ? "Attributes:[{Name:\"generic.maxHealth\", Base:" + as.getMaxHealth() + "}]," : "")
|
||||
+ (as.isVisible() ? "" : "Invisible:1,")
|
||||
@ -244,12 +243,7 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
BlockBreakEvent breakEvent = new BlockBreakEvent(b, p);
|
||||
Bukkit.getServer().getPluginManager().callEvent(breakEvent);
|
||||
if(breakEvent.isCancelled()){
|
||||
return false;
|
||||
}
|
||||
BlockPlaceEvent placeEvent = new BlockPlaceEvent(b, b.getState(), b, null, p, true);
|
||||
Bukkit.getServer().getPluginManager().callEvent(placeEvent);
|
||||
return !placeEvent.isCancelled();
|
||||
return !breakEvent.isCancelled();
|
||||
}
|
||||
|
||||
boolean playerHasPermission(Player p, Block b, ArmorStandTool tool) {
|
||||
|
@ -63,7 +63,7 @@ public class MainListener implements Listener {
|
||||
p.sendMessage(ChatColor.RED + Config.wgNoPerm);
|
||||
}
|
||||
}
|
||||
ArmorStandTool tool = ArmorStandTool.get(p.getInventory().getItemInMainHand());
|
||||
ArmorStandTool tool = ArmorStandTool.get(p);
|
||||
if(tool == null) return;
|
||||
ArmorStand as = (ArmorStand) event.getRightClicked();
|
||||
if (!plugin.playerHasPermission(p, event.getRightClicked().getLocation().getBlock(), tool)) {
|
||||
@ -163,7 +163,7 @@ public class MainListener implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (event.getRightClicked() instanceof ItemFrame && ArmorStandTool.isTool(event.getPlayer().getItemInHand())) {
|
||||
if (event.getRightClicked() instanceof ItemFrame && ArmorStandTool.isHoldingTool(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().updateInventory();
|
||||
}
|
||||
@ -172,7 +172,7 @@ public class MainListener implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (ArmorStandTool.isTool(event.getItemInHand())) {
|
||||
if (ArmorStandTool.isHoldingTool(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -326,9 +326,9 @@ public class MainListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if(event.getEntity() instanceof ArmorStand && event.getDamager() instanceof Player && ArmorStandTool.isTool(((Player) event.getDamager()).getInventory().getItemInMainHand())) {
|
||||
if(event.getEntity() instanceof ArmorStand && event.getDamager() instanceof Player && ArmorStandTool.isHoldingTool((Player) event.getDamager())) {
|
||||
event.setCancelled(true);
|
||||
if(noCooldown(event.getDamager())) {
|
||||
if (noCooldown(event.getDamager())) {
|
||||
Utils.cycleInventory((Player) event.getDamager());
|
||||
}
|
||||
}
|
||||
@ -349,7 +349,7 @@ public class MainListener implements Listener {
|
||||
as.setChestplate(Config.chest);
|
||||
as.setLeggings(Config.pants);
|
||||
as.setBoots(Config.boots);
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
as.getEquipment().setItemInMainHand(Config.itemInHand);
|
||||
as.getEquipment().setItemInOffHand(Config.itemInOffHand);
|
||||
} else {
|
||||
@ -401,10 +401,9 @@ public class MainListener implements Listener {
|
||||
}
|
||||
} else if(b.hasMetadata("setSkull")) {
|
||||
if(MC_USERNAME_PATTERN.matcher(input).matches()) {
|
||||
final String name = input;
|
||||
b.setMetadata("protected", new FixedMetadataValue(plugin, true));
|
||||
event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait);
|
||||
String cmd = "give " + event.getPlayer().getName() + " minecraft:skull 1 3 {SkullOwner:\"" + name + "\"}";
|
||||
String cmd = "give " + event.getPlayer().getName() + " minecraft:skull 1 3 {SkullOwner:\"" + input + "\"}";
|
||||
String current = b.getWorld().getGameRuleValue("sendCommandFeedback");
|
||||
b.getWorld().setGameRuleValue("sendCommandFeedback", "false");
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
|
||||
@ -413,9 +412,9 @@ public class MainListener implements Listener {
|
||||
for(int slot : event.getPlayer().getInventory().all(Material.SKULL_ITEM).keySet()) {
|
||||
ItemStack skull = event.getPlayer().getInventory().getItem(slot);
|
||||
SkullMeta sm = (SkullMeta) skull.getItemMeta();
|
||||
if(sm.hasOwner() && name.equalsIgnoreCase(sm.getOwner())) {
|
||||
if(sm.hasOwner() && input.equalsIgnoreCase(sm.getOwner())) {
|
||||
as.setHelmet(skull);
|
||||
event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + name);
|
||||
event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + input);
|
||||
event.getPlayer().getInventory().setItem(slot, null);
|
||||
found = true;
|
||||
break;
|
||||
|
@ -21,7 +21,7 @@ class NBT {
|
||||
static int getDisabledSlots(ArmorStand as) {
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
if(nmsEntity == null) return 0;
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
Field f;
|
||||
try {
|
||||
f = nmsEntity.getClass().getDeclaredField("bz");
|
||||
@ -46,7 +46,7 @@ class NBT {
|
||||
static void setSlotsDisabled(ArmorStand as, boolean slotsDisabled) {
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
if (nmsEntity == null) return;
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
Field f;
|
||||
try {
|
||||
f = nmsEntity.getClass().getDeclaredField("bz");
|
||||
@ -77,7 +77,7 @@ class NBT {
|
||||
static boolean isInvulnerable(ArmorStand as) {
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
if (nmsEntity == null) return false;
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
Field f;
|
||||
try {
|
||||
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
|
||||
@ -101,7 +101,7 @@ class NBT {
|
||||
static void setInvulnerable(ArmorStand as, boolean invulnerable) {
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
if (nmsEntity == null) return;
|
||||
if(Main.one_nine) {
|
||||
if(Main.oneNine) {
|
||||
Field f;
|
||||
try {
|
||||
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
|
||||
@ -194,6 +194,7 @@ class NBT {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static int getInt(Object tag, String name) {
|
||||
try {
|
||||
return (Integer) tag.getClass().getMethod("getInt", String.class).invoke(tag, name);
|
||||
@ -203,6 +204,7 @@ class NBT {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static boolean getBoolean(Object tag, String name) {
|
||||
try {
|
||||
return (Boolean) tag.getClass().getMethod("getBoolean", String.class).invoke(tag, name);
|
||||
@ -212,6 +214,7 @@ class NBT {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static void setInt(Object tag, String name, int value) {
|
||||
try {
|
||||
tag.getClass().getMethod("setInt", String.class, int.class).invoke(tag, name, value);
|
||||
@ -220,6 +223,7 @@ class NBT {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static void setBoolean(Object tag, String name, boolean value) {
|
||||
try {
|
||||
tag.getClass().getMethod("setBoolean", String.class, boolean.class).invoke(tag, name, value);
|
||||
|
@ -159,6 +159,7 @@ class Utils {
|
||||
return is;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
static String getNmsName(Material m) {
|
||||
try {
|
||||
Class block = getNMSClass("Block");
|
||||
@ -175,7 +176,6 @@ class Utils {
|
||||
return (String) regKey.getMethod("a").invoke(key);
|
||||
}
|
||||
}
|
||||
|
||||
registry = item.getDeclaredField("REGISTRY").get(null);
|
||||
set = (Set<Object>) registry.getClass().getMethod("keySet").invoke(registry);
|
||||
for(Object key : set) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Main Config
|
||||
#
|
||||
# File generated by: v2.1
|
||||
# File generated by: v2.1.1
|
||||
# (If this is not the version you are running, consider deleting this
|
||||
# config to allow it to be re-created. There may be new config options)
|
||||
#
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Language Config
|
||||
#
|
||||
# File generated by: v2.1
|
||||
# File generated by: v2.1.1
|
||||
# (If this is not the version you are running, consider deleting this
|
||||
# config to allow it to be re-created. There may be new config options)
|
||||
#
|
||||
@ -17,8 +17,8 @@
|
||||
# errors will occur.
|
||||
# Do not use ' marks inside the string itself.
|
||||
#
|
||||
# If you ever wish to return to the default language config
|
||||
# then delete this file and reload the plugin. A new default
|
||||
# If you ever wish to return to the default language config,
|
||||
# delete this file and reload the plugin. A new default language
|
||||
# file will be generated.
|
||||
#
|
||||
####################
|
||||
@ -51,9 +51,8 @@ giveMsg2: 'Run this command again to return your inventory.'
|
||||
conReload: 'Armor Stand Tools config reloaded'
|
||||
noRelPerm: 'You do not have permission to reload the plugin'
|
||||
noAirError: 'Error: Failed to find a near-by air block. Move and try again.'
|
||||
pleaseWait: 'Please wait, this may take a few seconds...'
|
||||
pleaseWait: 'Please wait. this may take a few seconds...'
|
||||
appliedHead: 'Applied the head of player'
|
||||
noHead: 'No player head found for player'
|
||||
invalidName: 'is not a valid minecraft username'
|
||||
wgNoPerm: 'No permission to alter an armor stand in this region'
|
||||
headFailed: 'Failed to apply the player head. Try again.'
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
|
||||
name: ArmorStandTools
|
||||
version: 2.1
|
||||
version: 2.1.1
|
||||
author: St3venAU
|
||||
description: Armor stand manipulation tools
|
||||
softdepend: [WorldGuard, PlotSquared]
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren