1
0
mirror of https://e.coding.net/circlecloud/CityBuild.git synced 2024-11-21 10:48:49 +00:00

change list to type add jiaohu jiance...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-05-19 21:17:22 +08:00
parent fd5bab9e5b
commit f89d2d4f43
3 changed files with 255 additions and 217 deletions

View File

@ -15,7 +15,7 @@ public class CityBuild extends JavaPlugin implements CommandExecutor {
public boolean tipplayer; public boolean tipplayer;
public void onLoad() { public void onLoad() {
Config.load(this, "1.0"); Config.load(this, "1.1");
servername = getmessage("servername"); servername = getmessage("servername");
pluginname = getmessage("pluginname"); pluginname = getmessage("pluginname");
tipplayer = Config.getInstance().getBoolean("tipplayer"); tipplayer = Config.getInstance().getBoolean("tipplayer");

View File

@ -8,6 +8,7 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -15,6 +16,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class Build implements Listener { public class Build implements Listener {
@ -24,18 +26,46 @@ public class Build implements Listener {
plugin = main; plugin = main;
} }
// PlayerInteractEvent.class
@EventHandler(ignoreCancelled = true)
public void playerInteract(PlayerInteractEvent event) {
event.setCancelled(CancelEvent(event.getPlayer(), event.getMaterial()));
}
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void blockBreak(BlockBreakEvent event) { public void blockBreak(BlockBreakEvent event) {
if (CancelEvent(event.getPlayer(), event.getBlock(), false)) { event.setCancelled(CancelEvent(event.getPlayer(), event.getBlock(),
event.setCancelled(true); false));
}
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void blockplace(BlockPlaceEvent event) { public void blockplace(BlockPlaceEvent event) {
if (CancelEvent(event.getPlayer(), event.getBlock(), true)) { event.setCancelled(CancelEvent(event.getPlayer(), event.getBlock(),
event.setCancelled(true); true));
} }
public boolean CancelEvent(Player p, Material m) {
ClaimedResidence res = Residence.getResidenceManager().getByLoc(
p.getLocation());
if (res == null && !p.hasPermission("cb.build")) {
String blockname = m.name();
for (String protectworld : Config.getInstance().getStringList(
"ProtectWorld")) {
if (protectworld.equalsIgnoreCase(p.getWorld().getName())) {
for (String notallowblock : Config.getInstance()
.getStringList("NotAllowList")) {
if (blockname.equalsIgnoreCase(notallowblock)) {
if (plugin.tipplayer)
p.getPlayer().sendMessage(
plugin.getfullmsg("Message.NotAllow"));
return true;
}
}
}
}
}
return false;
} }
public boolean CancelEvent(Player p, Block b, boolean place) { public boolean CancelEvent(Player p, Block b, boolean place) {

View File

@ -1,5 +1,5 @@
#本文件为保护插件的主配置文件 #本文件为保护插件的主配置文件
version: '1.0' version: '1.1'
#服务器名称 #服务器名称
servername: '' servername: ''
#插件名称 #插件名称
@ -27,6 +27,8 @@ Message:
#解除限制说明 #解除限制说明
Relieve: '&c如需解除限制请圈地,&6工具木锄&c,&b价格0.3元/方块&c' Relieve: '&c如需解除限制请圈地,&6工具木锄&c,&b价格0.3元/方块&c'
#不允许交互的提示
NotAllow: '&c当前物品不允许在领地外使用!'
#城市保护配置 #城市保护配置
#未圈地最大高度 #未圈地最大高度
@ -57,3 +59,9 @@ AllowList:
- RED_ROSE - RED_ROSE
- LOG_2 - LOG_2
- LOG - LOG
- YELLOW_FLOWER
#领地外阻止交互的物品
NotAllowList:
- WATER_BUCKET
- LAVA_BUCKET