mirror of
https://e.coding.net/circlecloud/ProtectItem.git
synced 2024-12-27 20:48:51 +00:00
update Main class name...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
0b5b0212d6
commit
e9b8630284
@ -12,31 +12,42 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import cn.citycraft.ProtectItem.listen.DropItemListen;
|
||||
import cn.citycraft.ProtectItem.listen.PickupItemListen;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
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 void onLoad() {
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname") + " ";
|
||||
public boolean checkevent(Player p, ItemStack i, 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")) {
|
||||
if (pw.getName().equalsIgnoreCase(protectworld)) {
|
||||
for (String protectitem : getConfig().getStringList(
|
||||
"ProtectItem")) {
|
||||
if (iname.equalsIgnoreCase(protectitem)) {
|
||||
p.sendMessage(pluginname
|
||||
+ getmessage("Message." + type));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
if (getConfig().getBoolean("Protect.Drop", true))
|
||||
Bukkit.getPluginManager().registerEvents(new DropItemListen(this),
|
||||
this);
|
||||
if (getConfig().getBoolean("Protect.Pickup", true))
|
||||
Bukkit.getPluginManager().registerEvents(
|
||||
new PickupItemListen(this), this);
|
||||
// if (getConfig().getBoolean("Protect.Break", true))
|
||||
// Bukkit.getPluginManager().registerEvents(
|
||||
// new BreakBlockListen(this), this);
|
||||
// if (getConfig().getBoolean("Protect.Place", true))
|
||||
// Bukkit.getPluginManager().registerEvents(
|
||||
// new PlaceBlockListen(this), this);
|
||||
getLogger().info("ProtectItem已加载!");
|
||||
public String getmessage(String path) {
|
||||
String message = getConfig().getString(path).replaceAll("&", "§");
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,36 +72,30 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkevent(Player p, ItemStack i, 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")) {
|
||||
if (pw.getName().equalsIgnoreCase(protectworld))
|
||||
for (String protectitem : getConfig().getStringList(
|
||||
"ProtectItem")) {
|
||||
if (iname.equalsIgnoreCase(protectitem)) {
|
||||
p.sendMessage(pluginname
|
||||
+ getmessage("Message." + type));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (getConfig().getBoolean("Protect.Drop", true)) {
|
||||
Bukkit.getPluginManager().registerEvents(new DropItemListen(this),
|
||||
this);
|
||||
}
|
||||
return false;
|
||||
if (getConfig().getBoolean("Protect.Pickup", true)) {
|
||||
Bukkit.getPluginManager().registerEvents(
|
||||
new PickupItemListen(this), this);
|
||||
}
|
||||
// if (getConfig().getBoolean("Protect.Break", true))
|
||||
// Bukkit.getPluginManager().registerEvents(
|
||||
// new BreakBlockListen(this), this);
|
||||
// if (getConfig().getBoolean("Protect.Place", true))
|
||||
// Bukkit.getPluginManager().registerEvents(
|
||||
// new PlaceBlockListen(this), this);
|
||||
getLogger().info("ProtectItem已加载!");
|
||||
}
|
||||
|
||||
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 getmessage(String path) {
|
||||
String message = getConfig().getString(path).replaceAll("&", "§");
|
||||
return message;
|
||||
@Override
|
||||
public void onLoad() {
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname") + " ";
|
||||
}
|
||||
}
|
@ -6,12 +6,12 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.ProtectItem.Main;
|
||||
import cn.citycraft.ProtectItem.ProtectItem;
|
||||
|
||||
public class DropItemListen implements Listener {
|
||||
Main plugin;
|
||||
ProtectItem plugin;
|
||||
|
||||
public DropItemListen(Main main) {
|
||||
public DropItemListen(ProtectItem main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@ -19,6 +19,6 @@ public class DropItemListen implements Listener {
|
||||
public void onDropItem(PlayerDropItemEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack i = e.getItemDrop().getItemStack();
|
||||
e.setCancelled(plugin.checkevent(p, i, "Drop"));
|
||||
e.setCancelled(plugin.checkevent(p, i, "Drop"));
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.ProtectItem.Main;
|
||||
import cn.citycraft.ProtectItem.ProtectItem;
|
||||
|
||||
public class PickupItemListen implements Listener {
|
||||
Main plugin;
|
||||
ProtectItem plugin;
|
||||
|
||||
public PickupItemListen(Main main) {
|
||||
public PickupItemListen(ProtectItem main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ public class PickupItemListen implements Listener {
|
||||
public void onPickupItem(PlayerPickupItemEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack i = e.getItem().getItemStack();
|
||||
e.setCancelled(plugin.checkevent(p, i, "Pickup"));
|
||||
e.setCancelled(plugin.checkevent(p, i, "Pickup"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user