From 6e761d5cbd2c050797cc9cc50d73e9aef6aabcc4 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Sun, 4 Sep 2016 17:23:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9C=AA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=97=B6=E4=B9=9F=E5=8F=AF=E4=BB=A5=E6=89=93=E5=BC=80?= =?UTF-8?q?=E9=99=84=E9=AD=94=E5=8F=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../CarryEnchantBench/CarryEnchantBench.java | 125 +++++++++--------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/src/main/java/cn/citycraft/CarryEnchantBench/CarryEnchantBench.java b/src/main/java/cn/citycraft/CarryEnchantBench/CarryEnchantBench.java index d8a656d..c11eb83 100644 --- a/src/main/java/cn/citycraft/CarryEnchantBench/CarryEnchantBench.java +++ b/src/main/java/cn/citycraft/CarryEnchantBench/CarryEnchantBench.java @@ -18,73 +18,74 @@ import org.bukkit.plugin.java.JavaPlugin; /** * 随身附魔台主类 - * + * * @author 蒋天蓓 2015年8月24日下午3:48:42 */ public class CarryEnchantBench extends JavaPlugin implements Listener { - Location loc = null; - List setList = new ArrayList(); + Location loc = null; + List setList = new ArrayList<>(); - @EventHandler - public void onClick(PlayerInteractEvent e) { - Block b = e.getClickedBlock(); - Player p = e.getPlayer(); - if (setList.contains(p.getName())) { - if (b.getType() == Material.ENCHANTMENT_TABLE) { - loc = b.getLocation(); - this.getConfig().set("Location.World", loc.getWorld().getName()); - this.getConfig().set("Location.X", loc.getBlockX()); - this.getConfig().set("Location.Y", loc.getBlockY()); - this.getConfig().set("Location.Z", loc.getBlockZ()); - this.saveConfig(); - p.sendMessage("§a已成功配置随身附魔台的位置 §c请勿破坏 否则将会影响插件工作!"); - } else { - p.sendMessage("§c请点击附魔台配置随身附魔台位置!"); - } - setList.remove(p.getName()); - e.setCancelled(true); - } - } + @EventHandler + public void onClick(final PlayerInteractEvent e) { + final Block b = e.getClickedBlock(); + final Player p = e.getPlayer(); + if (setList.contains(p.getName())) { + if (b.getType() == Material.ENCHANTMENT_TABLE) { + loc = b.getLocation(); + this.getConfig().set("Location.World", loc.getWorld().getName()); + this.getConfig().set("Location.X", loc.getBlockX()); + this.getConfig().set("Location.Y", loc.getBlockY()); + this.getConfig().set("Location.Z", loc.getBlockZ()); + this.saveConfig(); + p.sendMessage("§a已成功配置随身附魔台的位置 §c请勿破坏 否则将会影响插件工作!"); + } else { + p.sendMessage("§c请点击附魔台配置随身附魔台位置!"); + } + setList.remove(p.getName()); + e.setCancelled(true); + } + } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) { - sender.sendMessage("§c控制台吃饱了撑着用毛线附魔台啊"); - } - switch (args.length) { - case 0: - Player p = (Player) sender; - if (loc.getBlock().getType() != Material.ENCHANTMENT_TABLE) { - p.sendMessage("§c管理员尚未配置随身附魔台的位置或附魔台被破坏!"); - } - p.openEnchanting(loc, true); - p.sendMessage("§a已打开随身附魔台!"); - return true; - case 1: - if (args[0].equalsIgnoreCase("set")) { - if (sender.hasPermission("ceb.set")) { - if (!setList.contains(sender.getName())) { - sender.sendMessage("§b请点击目标附魔台配置为随身附魔台!"); - setList.add(sender.getName()); - } - } - return true; - } - break; - } - return false; - } + @Override + public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage("§c控制台吃饱了撑着用毛线附魔台啊"); + } + switch (args.length) { + case 0: + final Player p = (Player) sender; + if (loc.getBlock().getType() != Material.ENCHANTMENT_TABLE) { + p.sendMessage("§c管理员尚未配置随身附魔台的位置或附魔台被破坏!"); + return true; + } + p.openEnchanting(loc, true); + p.sendMessage("§a已打开随身附魔台!"); + return true; + case 1: + if (args[0].equalsIgnoreCase("set")) { + if (sender.hasPermission("ceb.set")) { + if (!setList.contains(sender.getName())) { + sender.sendMessage("§b请点击目标附魔台配置为随身附魔台!"); + setList.add(sender.getName()); + } + } + return true; + } + break; + } + return false; + } - @Override - public void onEnable() { - this.saveDefaultConfig(); - String worldname = getConfig().getString("Location.World"); - World world = Bukkit.getWorld(worldname); - int x = getConfig().getInt("Location.X"); - int y = getConfig().getInt("Location.Y"); - int z = getConfig().getInt("Location.Z"); - loc = new Location(world, x, y, z); - this.getServer().getPluginManager().registerEvents(this, this); - } + @Override + public void onEnable() { + this.saveDefaultConfig(); + final String worldname = getConfig().getString("Location.World"); + final World world = Bukkit.getWorld(worldname); + final int x = getConfig().getInt("Location.X"); + final int y = getConfig().getInt("Location.Y"); + final int z = getConfig().getInt("Location.Z"); + loc = new Location(world, x, y, z); + this.getServer().getPluginManager().registerEvents(this, this); + } }