diff --git a/pom.xml b/pom.xml index 731f03d..66b7c64 100644 --- a/pom.xml +++ b/pom.xml @@ -1,39 +1,97 @@ - - 4.0.0 - cn.CityCraft - ProtectItem - 0.0.1-SNAPSHOT - ProtectItem - - src - - - src - - **/*.java - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - - - org.spigotmc - spigot-api - jar - 1.8.3-R0.1-SNAPSHOT - - - - UTF-8 - - - GitHub - - https://git.coding.net/502647092/ProtectItem.git + + 4.0.0 + cn.CityCraft + ProtectItem + 0.0.1-SNAPSHOT + ProtectItem + + ${project.name} + + + src/main/resources + true + + + + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + + false + true + + + cn.citycraft:PluginHelper + org.mcstats.*:* + + + + + org.mcstats + ${project.groupId}.${project.artifactId}.mcstats + + + cn.citycraft.PluginHelper + ${project.groupId}.${project.artifactId} + + + + + + package + + shade + + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + citycraft-repo + http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/ + + + Plugin Metrics + http://repo.mcstats.org/content/repositories/public + + + + + org.spigotmc + spigot-api + jar + 1.8.3-R0.1-SNAPSHOT + + + cn.citycraft + PluginHelper + jar + 1.0 + + + org.mcstats.bukkit + metrics + R8-SNAPSHOT + compile + + + + UTF-8 + \ No newline at end of file diff --git a/src/cn/citycraft/ProtectItem/ProtectItem.java b/src/main/java/cn/citycraft/ProtectItem/ProtectItem.java similarity index 58% rename from src/cn/citycraft/ProtectItem/ProtectItem.java rename to src/main/java/cn/citycraft/ProtectItem/ProtectItem.java index f9c5676..123e77f 100644 --- a/src/cn/citycraft/ProtectItem/ProtectItem.java +++ b/src/main/java/cn/citycraft/ProtectItem/ProtectItem.java @@ -13,30 +13,29 @@ import cn.citycraft.ProtectItem.listen.DropItemListen; import cn.citycraft.ProtectItem.listen.PickupItemListen; public class ProtectItem extends JavaPlugin { - public static String getItemName(ItemStack i) { - String name = i.getType().name(); - int dur = i.getDurability(); - String dura = i.getMaxStackSize() != 1 ? dur != 0 ? "_" + dur : "" : ""; - String iname = name + dura; - return iname; - } public String servername; - public String pluginname; - public boolean checkevent(Player p, ItemStack i, String type) { - if (p.hasPermission("pi.bypass")) + public static String getItemName(final ItemStack i) { + final String name = i.getType().name(); + final int dur = i.getDurability(); + final String dura = i.getMaxStackSize() != 1 ? dur != 0 ? "_" + dur : "" : ""; + final String iname = name + dura; + return iname; + } + + public boolean checkevent(final Player p, final ItemStack i, final String type) { + if (p.hasPermission("pi.bypass")) { return false; - String iname = getItemName(i); - Location l = p.getLocation(); - World pw = l.getWorld(); - for (String protectworld : getConfig().getStringList("ProtectWorld")) { + } + final String iname = getItemName(i); + final Location l = p.getLocation(); + final World pw = l.getWorld(); + for (final String protectworld : getConfig().getStringList("ProtectWorld")) { if (pw.getName().equalsIgnoreCase(protectworld)) { - for (String protectitem : getConfig().getStringList( - "ProtectItem")) { + for (final String protectitem : getConfig().getStringList("ProtectItem")) { if (iname.equalsIgnoreCase(protectitem)) { - p.sendMessage(pluginname - + getmessage("Message." + type)); + p.sendMessage(pluginname + getmessage("Message." + type)); return true; } } @@ -45,27 +44,27 @@ public class ProtectItem extends JavaPlugin { return false; } - public String getmessage(String path) { - String message = getConfig().getString(path).replaceAll("&", "§"); + public String getmessage(final String path) { + final String message = getConfig().getString(path).replaceAll("&", "§"); return message; } @Override - public boolean onCommand(CommandSender sender, Command cmd, String string, - String[] args) { - Player p = (Player) sender; + public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) { + final Player p = (Player) sender; switch (args.length) { case 0: - ItemStack item = p.getItemInHand(); + final ItemStack item = p.getItemInHand(); p.sendMessage("\u00a7a手上物品类型名称为: \u00a76" + getItemName(item)); return true; case 1: - if (p.hasPermission("pi.bypass")) + if (p.hasPermission("pi.bypass")) { if (args[0].equalsIgnoreCase("reload")) { this.reloadConfig(); p.sendMessage("\u00a7a配置文件已重载..."); return true; } + } break; default: } @@ -75,12 +74,10 @@ public class ProtectItem extends JavaPlugin { @Override public void onEnable() { if (getConfig().getBoolean("Protect.Drop", true)) { - Bukkit.getPluginManager().registerEvents(new DropItemListen(this), - this); + Bukkit.getPluginManager().registerEvents(new DropItemListen(this), this); } if (getConfig().getBoolean("Protect.Pickup", true)) { - Bukkit.getPluginManager().registerEvents( - new PickupItemListen(this), this); + Bukkit.getPluginManager().registerEvents(new PickupItemListen(this), this); } // if (getConfig().getBoolean("Protect.Break", true)) // Bukkit.getPluginManager().registerEvents( diff --git a/src/cn/citycraft/ProtectItem/listen/DropItemListen.java b/src/main/java/cn/citycraft/ProtectItem/listen/DropItemListen.java similarity index 68% rename from src/cn/citycraft/ProtectItem/listen/DropItemListen.java rename to src/main/java/cn/citycraft/ProtectItem/listen/DropItemListen.java index b12d9d3..9058a41 100644 --- a/src/cn/citycraft/ProtectItem/listen/DropItemListen.java +++ b/src/main/java/cn/citycraft/ProtectItem/listen/DropItemListen.java @@ -11,14 +11,14 @@ import cn.citycraft.ProtectItem.ProtectItem; public class DropItemListen implements Listener { ProtectItem plugin; - public DropItemListen(ProtectItem main) { + public DropItemListen(final ProtectItem main) { plugin = main; } @EventHandler(ignoreCancelled = true) - public void onDropItem(PlayerDropItemEvent e) { - Player p = e.getPlayer(); - ItemStack i = e.getItemDrop().getItemStack(); + public void onDropItem(final PlayerDropItemEvent e) { + final Player p = e.getPlayer(); + final ItemStack i = e.getItemDrop().getItemStack(); e.setCancelled(plugin.checkevent(p, i, "Drop")); } } diff --git a/src/cn/citycraft/ProtectItem/listen/PickupItemListen.java b/src/main/java/cn/citycraft/ProtectItem/listen/PickupItemListen.java similarity index 68% rename from src/cn/citycraft/ProtectItem/listen/PickupItemListen.java rename to src/main/java/cn/citycraft/ProtectItem/listen/PickupItemListen.java index 223ebdc..8d4151a 100644 --- a/src/cn/citycraft/ProtectItem/listen/PickupItemListen.java +++ b/src/main/java/cn/citycraft/ProtectItem/listen/PickupItemListen.java @@ -11,15 +11,14 @@ import cn.citycraft.ProtectItem.ProtectItem; public class PickupItemListen implements Listener { ProtectItem plugin; - public PickupItemListen(ProtectItem main) { + public PickupItemListen(final ProtectItem main) { plugin = main; } @EventHandler(ignoreCancelled = true) - public void onPickupItem(PlayerPickupItemEvent e) { - Player p = e.getPlayer(); - ItemStack i = e.getItem().getItemStack(); + public void onPickupItem(final PlayerPickupItemEvent e) { + final Player p = e.getPlayer(); + final ItemStack i = e.getItem().getItemStack(); e.setCancelled(plugin.checkevent(p, i, "Pickup")); } - } diff --git a/src/config.yml b/src/main/resources/config.yml similarity index 100% rename from src/config.yml rename to src/main/resources/config.yml diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..fda7e8b --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,13 @@ +name: ${project.artifactId} +description: ${project.description} +main: ${project.groupId}.${project.artifactId}.${project.artifactId} +version: ${project.version} +author: 喵♂呜 +website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/ +commands: + pishow: + description: 物品保护插件 + usage: 使用/pishow 查看物品名称! +permissions: + pi.bypass: + default: op \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml deleted file mode 100644 index 4df4980..0000000 --- a/src/plugin.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: ProtectItem -main: cn.citycraft.ProtectItem.Main -version: 1.0 -auther: 喵♂呜 -commands: - pishow: - description: 物品保护插件 - usage: 使用/pishow 查看物品名称! -permissions: - pi.bypass: - default: op \ No newline at end of file