3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-28 04:20:08 +01:00

v2.4.3 - Bugfix

Dieser Commit ist enthalten in:
Steven 2017-07-30 19:21:39 +08:00
Ursprung 03ed547630
Commit 528a2bfa6f
5 geänderte Dateien mit 27 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,7 @@ class ArmorStandGUI implements Listener {
private Main plugin; private Main plugin;
ArmorStandGUI(Main plugin, ArmorStand as, Player p) { ArmorStandGUI(Main plugin, ArmorStand as, Player p) {
if(inUse.contains(as.getEntityId())) { if(isInUse(as)) {
p.sendMessage(ChatColor.RED + Config.guiInUse); p.sendMessage(ChatColor.RED + Config.guiInUse);
return; return;
} }
@ -81,6 +81,10 @@ class ArmorStandGUI implements Listener {
p.openInventory(i); p.openInventory(i);
} }
public static boolean isInUse(ArmorStand as) {
return inUse.contains(as.getEntityId());
}
private ItemStack updateLore(ArmorStandTool tool) { private ItemStack updateLore(ArmorStandTool tool) {
ItemStack item = tool.getItem(); ItemStack item = tool.getItem();
switch (tool) { switch (tool) {
@ -117,7 +121,7 @@ class ArmorStandGUI implements Listener {
} }
@EventHandler @EventHandler
public void inInventoryClose(InventoryCloseEvent event) { public void onInventoryClose(InventoryCloseEvent event) {
if(!event.getInventory().equals(i)) return; if(!event.getInventory().equals(i)) return;
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
inUse.remove(as.getEntityId()); inUse.remove(as.getEntityId());

Datei anzeigen

@ -18,6 +18,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
@ -56,6 +57,11 @@ public class MainListener implements Listener {
if (event.getRightClicked() instanceof ArmorStand) { if (event.getRightClicked() instanceof ArmorStand) {
Player p = event.getPlayer(); Player p = event.getPlayer();
ArmorStand as = (ArmorStand) event.getRightClicked(); ArmorStand as = (ArmorStand) event.getRightClicked();
if(ArmorStandGUI.isInUse(as)) {
Main.nms.actionBarMsg(p, Config.guiInUse);
event.setCancelled(true);
return;
}
if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) { if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) {
if (plugin.playerHasPermission(p, plugin.carryingArmorStand.get(p.getUniqueId()).getLocation().getBlock(), null)) { if (plugin.playerHasPermission(p, plugin.carryingArmorStand.get(p.getUniqueId()).getLocation().getBlock(), null)) {
plugin.carryingArmorStand.remove(p.getUniqueId()); plugin.carryingArmorStand.remove(p.getUniqueId());
@ -359,7 +365,8 @@ public class MainListener implements Listener {
@EventHandler @EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(event.getEntity() instanceof ArmorStand) { if(event.getEntity() instanceof ArmorStand) {
if(Main.nms.isInvulnerable((ArmorStand) event.getEntity())) { ArmorStand as = (ArmorStand) event.getEntity();
if(ArmorStandGUI.isInUse(as) || Main.nms.isInvulnerable(as)) {
event.setCancelled(true); event.setCancelled(true);
} }
if(event.getDamager() instanceof Player && ArmorStandTool.isHoldingTool((Player) event.getDamager())) { if(event.getDamager() instanceof Player && ArmorStandTool.isHoldingTool((Player) event.getDamager())) {
@ -371,6 +378,16 @@ public class MainListener implements Listener {
} }
} }
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof ArmorStand) {
ArmorStand as = (ArmorStand) event.getEntity();
if(ArmorStandGUI.isInUse(as) || Main.nms.isInvulnerable(as)) {
event.setCancelled(true);
}
}
}
private boolean noCooldown(Entity e) { private boolean noCooldown(Entity e) {
for(MetadataValue meta : e.getMetadata("lastDrop")) { for(MetadataValue meta : e.getMetadata("lastDrop")) {
if(meta.getOwningPlugin() == plugin) { if(meta.getOwningPlugin() == plugin) {

Datei anzeigen

@ -4,7 +4,7 @@
# #
# Main Config # Main Config
# #
# File generated by: v2.4.2 # File generated by: v2.4.3
# (If this is not the version you are running, consider deleting this # (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) # config to allow it to be re-created. There may be new config options)
# #

Datei anzeigen

@ -4,7 +4,7 @@
# #
# Language Config # Language Config
# #
# File generated by: v2.4.2 # File generated by: v2.4.3
# (If this is not the version you are running, consider deleting this # (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) # config to allow it to be re-created. There may be new config options)
# #

Datei anzeigen

@ -1,6 +1,6 @@
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
name: ArmorStandTools name: ArmorStandTools
version: 2.4.2 version: 2.4.3
author: St3venAU author: St3venAU
description: Armor stand manipulation tools description: Armor stand manipulation tools
softdepend: [WorldGuard, PlotSquared] softdepend: [WorldGuard, PlotSquared]