mirror of
https://e.coding.net/circlecloud/ProtectItem.git
synced 2024-12-27 20:48:51 +00:00
初始化项目
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
commit
2264925f6a
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
*.class
|
||||
.metadata
|
||||
.recommenders
|
||||
.classpath
|
||||
.settings
|
||||
.project
|
||||
bin/
|
60
src/com/github/j502647092/BanDropDirt/Main.java
Normal file
60
src/com/github/j502647092/BanDropDirt/Main.java
Normal file
@ -0,0 +1,60 @@
|
||||
package com.github.j502647092.BanDropDirt;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.github.j502647092.BanDropDirt.listen.BreakBlockListen;
|
||||
import com.github.j502647092.BanDropDirt.listen.DropItemListen;
|
||||
import com.github.j502647092.BanDropDirt.listen.PickupItemListen;
|
||||
import com.github.j502647092.BanDropDirt.listen.PlaceBlockListen;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
public String servername;
|
||||
public String pluginname;
|
||||
|
||||
public void onLoad() {
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname") + " ";
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(new DropItemListen(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new PickupItemListen(this),
|
||||
this);
|
||||
Bukkit.getPluginManager().registerEvents(new BreakBlockListen(this),
|
||||
this);
|
||||
Bukkit.getPluginManager().registerEvents(new PlaceBlockListen(this),
|
||||
this);
|
||||
getLogger().info("BanDropDirt已加载!");
|
||||
}
|
||||
|
||||
public boolean checkevent(Player p, String i, String type) {
|
||||
if (p.hasPermission("bdd.bypass"))
|
||||
return false;
|
||||
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 (i.equalsIgnoreCase(protectitem)) {
|
||||
p.sendMessage(pluginname
|
||||
+ getmessage("Message." + type));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
String message = getConfig().getString(path).replaceAll("&", "§");
|
||||
return message;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.github.j502647092.BanDropDirt.listen;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.github.j502647092.BanDropDirt.Main;
|
||||
|
||||
public class BreakBlockListen implements Listener {
|
||||
Main plugin;
|
||||
|
||||
public BreakBlockListen(Main main) {
|
||||
// TODO Auto-generated constructor stub
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDropItem(BlockBreakEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String i = e.getBlock().getType().name();
|
||||
e.setCancelled(plugin.checkevent(p, i, "Break"));
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.github.j502647092.BanDropDirt.listen;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
import com.github.j502647092.BanDropDirt.Main;
|
||||
|
||||
public class DropItemListen implements Listener {
|
||||
Main plugin;
|
||||
|
||||
public DropItemListen(Main main) {
|
||||
// TODO Auto-generated constructor stub
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDropItem(PlayerDropItemEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String i = e.getItemDrop().getItemStack().getType().name();
|
||||
if (plugin.checkevent(p, i, "Drop"))
|
||||
e.getItemDrop().remove();
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.github.j502647092.BanDropDirt.listen;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
|
||||
import com.github.j502647092.BanDropDirt.Main;
|
||||
|
||||
public class PickupItemListen implements Listener {
|
||||
Main plugin;
|
||||
|
||||
public PickupItemListen(Main main) {
|
||||
// TODO Auto-generated constructor stub
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPickupItem(PlayerPickupItemEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String i = e.getItem().getItemStack().getType().name();
|
||||
if (plugin.checkevent(p, i, "Pickup"))
|
||||
e.getItem().remove();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.github.j502647092.BanDropDirt.listen;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import com.github.j502647092.BanDropDirt.Main;
|
||||
|
||||
public class PlaceBlockListen implements Listener {
|
||||
Main plugin;
|
||||
|
||||
public PlaceBlockListen(Main main) {
|
||||
// TODO Auto-generated constructor stub
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDropItem(BlockPlaceEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String i = e.getBlock().getType().name();
|
||||
e.setCancelled(plugin.checkevent(p, i, "Place"));
|
||||
}
|
||||
}
|
25
src/config.yml
Normal file
25
src/config.yml
Normal file
@ -0,0 +1,25 @@
|
||||
#本文件为保护插件的主配置文件
|
||||
#服务器名称
|
||||
servername: ''
|
||||
#插件名称
|
||||
pluginname: '&6[&3海岛保护&6]&r'
|
||||
|
||||
#提示消息
|
||||
Message:
|
||||
Reload: '&a配置文件已重新载入!'
|
||||
#方块安全提示
|
||||
Drop: '&c当前世界禁止丢弃泥土,丢弃的泥土已清空!'
|
||||
Pickup: '&c当前世界禁止拾取泥土,拾取的泥土已清空!'
|
||||
Place: '&c当前世界禁止放置泥土,箱子!'
|
||||
Break: '&c当前世界禁止破坏泥土,箱子!'
|
||||
#受到保护的世界(不区分大小写)
|
||||
ProtectWorld:
|
||||
- world
|
||||
- AcidIsland_nether
|
||||
|
||||
#保护的方块(不区分大小写)
|
||||
ProtectItem:
|
||||
- DIRT
|
||||
- GRASS
|
||||
- CHEST
|
||||
- TRAPPED_CHEST
|
3
src/plugin.yml
Normal file
3
src/plugin.yml
Normal file
@ -0,0 +1,3 @@
|
||||
name: BanDropDirt
|
||||
main: com.github.j502647092.BanDropDirt.Main
|
||||
version: 1.0
|
Loading…
Reference in New Issue
Block a user