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:
parent
fd5bab9e5b
commit
f89d2d4f43
@ -1,52 +1,52 @@
|
||||
package cn.citycraft.CityBuild;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.CityBuild.config.Config;
|
||||
import cn.citycraft.CityBuild.listen.Build;
|
||||
|
||||
public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
public String servername;
|
||||
public String pluginname;
|
||||
public boolean tipplayer;
|
||||
|
||||
public void onLoad() {
|
||||
Config.load(this, "1.0");
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname");
|
||||
tipplayer = Config.getInstance().getBoolean("tipplayer");
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(new Build(this), this);
|
||||
getLogger().info(pluginname + "城市世界建筑保护已加载!");
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
||||
String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
onLoad();
|
||||
sender.sendMessage(pluginname + getmessage("Message.Reload"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
getLogger().info(pluginname + "城市世界建筑保护已卸载!");
|
||||
}
|
||||
|
||||
public String getfullmsg(String path) {
|
||||
return servername + pluginname + " " + getmessage(path);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
return Config.getMessage(path);
|
||||
}
|
||||
}
|
||||
package cn.citycraft.CityBuild;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.CityBuild.config.Config;
|
||||
import cn.citycraft.CityBuild.listen.Build;
|
||||
|
||||
public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
public String servername;
|
||||
public String pluginname;
|
||||
public boolean tipplayer;
|
||||
|
||||
public void onLoad() {
|
||||
Config.load(this, "1.1");
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname");
|
||||
tipplayer = Config.getInstance().getBoolean("tipplayer");
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(new Build(this), this);
|
||||
getLogger().info(pluginname + "城市世界建筑保护已加载!");
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
||||
String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
onLoad();
|
||||
sender.sendMessage(pluginname + getmessage("Message.Reload"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
getLogger().info(pluginname + "城市世界建筑保护已卸载!");
|
||||
}
|
||||
|
||||
public String getfullmsg(String path) {
|
||||
return servername + pluginname + " " + getmessage(path);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
return Config.getMessage(path);
|
||||
}
|
||||
}
|
||||
|
@ -1,106 +1,136 @@
|
||||
package cn.citycraft.CityBuild.listen;
|
||||
|
||||
import cn.citycraft.CityBuild.CityBuild;
|
||||
import cn.citycraft.CityBuild.config.Config;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class Build implements Listener {
|
||||
|
||||
CityBuild plugin;
|
||||
|
||||
public Build(CityBuild main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
if (CancelEvent(event.getPlayer(), event.getBlock(), false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockplace(BlockPlaceEvent event) {
|
||||
if (CancelEvent(event.getPlayer(), event.getBlock(), true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean CancelEvent(Player p, Block b, boolean place) {
|
||||
Location loc = b.getLocation();
|
||||
ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
|
||||
if (res == null && !p.hasPermission("cb.build")) {
|
||||
String blockname = b.getType().name();
|
||||
World blockw = b.getWorld();
|
||||
int blockx = b.getX();
|
||||
int blocky = b.getY();
|
||||
int blockz = b.getZ();
|
||||
for (String protectworld : Config.getInstance().getStringList(
|
||||
"ProtectWorld")) {
|
||||
if (protectworld.equalsIgnoreCase(blockw.getName())) {
|
||||
for (String allowblock : Config.getInstance()
|
||||
.getStringList("AllowList")) {
|
||||
if (blockname.equalsIgnoreCase(allowblock)) {
|
||||
for (String noticeblock : Config.getInstance()
|
||||
.getStringList("NoticeList")) {
|
||||
if (blockname.equalsIgnoreCase(noticeblock)
|
||||
&& place) {
|
||||
if (plugin.tipplayer)
|
||||
p.getPlayer()
|
||||
.sendMessage(
|
||||
plugin.getfullmsg("Message.Tip"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int maxheight = Config.getInstance().getInt(
|
||||
"MaxHeight");
|
||||
if (blocky > maxheight
|
||||
&& blockname.equalsIgnoreCase("Dirt")) {
|
||||
if (plugin.tipplayer)
|
||||
p.getPlayer().sendMessage(
|
||||
plugin.getfullmsg("Message.Max")
|
||||
.replaceAll("%maxheight%",
|
||||
maxheight + ""));
|
||||
Bukkit.broadcast(
|
||||
plugin.getfullmsg("Message.Notice1")
|
||||
.replaceAll("%player%",
|
||||
p.getDisplayName())
|
||||
.replaceAll("%maxheight%",
|
||||
maxheight + ""),
|
||||
"cb.notice");
|
||||
Bukkit.broadcast(
|
||||
plugin.getfullmsg("Message.Notice2")
|
||||
.replaceAll("%world%",
|
||||
blockw.getName())
|
||||
.replaceAll("%x%", blockx + "")
|
||||
.replaceAll("%z%", blockz + ""),
|
||||
"cb.notice");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
String[] message = { plugin.getfullmsg("Message.Wran"),
|
||||
plugin.getfullmsg("Message.Allow"),
|
||||
plugin.getfullmsg("Message.Relieve") };
|
||||
if (plugin.tipplayer)
|
||||
p.getPlayer().sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package cn.citycraft.CityBuild.listen;
|
||||
|
||||
import cn.citycraft.CityBuild.CityBuild;
|
||||
import cn.citycraft.CityBuild.config.Config;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class Build implements Listener {
|
||||
|
||||
CityBuild plugin;
|
||||
|
||||
public Build(CityBuild main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
// PlayerInteractEvent.class
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void playerInteract(PlayerInteractEvent event) {
|
||||
event.setCancelled(CancelEvent(event.getPlayer(), event.getMaterial()));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
event.setCancelled(CancelEvent(event.getPlayer(), event.getBlock(),
|
||||
false));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockplace(BlockPlaceEvent event) {
|
||||
event.setCancelled(CancelEvent(event.getPlayer(), event.getBlock(),
|
||||
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) {
|
||||
Location loc = b.getLocation();
|
||||
ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
|
||||
if (res == null && !p.hasPermission("cb.build")) {
|
||||
String blockname = b.getType().name();
|
||||
World blockw = b.getWorld();
|
||||
int blockx = b.getX();
|
||||
int blocky = b.getY();
|
||||
int blockz = b.getZ();
|
||||
for (String protectworld : Config.getInstance().getStringList(
|
||||
"ProtectWorld")) {
|
||||
if (protectworld.equalsIgnoreCase(blockw.getName())) {
|
||||
for (String allowblock : Config.getInstance()
|
||||
.getStringList("AllowList")) {
|
||||
if (blockname.equalsIgnoreCase(allowblock)) {
|
||||
for (String noticeblock : Config.getInstance()
|
||||
.getStringList("NoticeList")) {
|
||||
if (blockname.equalsIgnoreCase(noticeblock)
|
||||
&& place) {
|
||||
if (plugin.tipplayer)
|
||||
p.getPlayer()
|
||||
.sendMessage(
|
||||
plugin.getfullmsg("Message.Tip"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int maxheight = Config.getInstance().getInt(
|
||||
"MaxHeight");
|
||||
if (blocky > maxheight
|
||||
&& blockname.equalsIgnoreCase("Dirt")) {
|
||||
if (plugin.tipplayer)
|
||||
p.getPlayer().sendMessage(
|
||||
plugin.getfullmsg("Message.Max")
|
||||
.replaceAll("%maxheight%",
|
||||
maxheight + ""));
|
||||
Bukkit.broadcast(
|
||||
plugin.getfullmsg("Message.Notice1")
|
||||
.replaceAll("%player%",
|
||||
p.getDisplayName())
|
||||
.replaceAll("%maxheight%",
|
||||
maxheight + ""),
|
||||
"cb.notice");
|
||||
Bukkit.broadcast(
|
||||
plugin.getfullmsg("Message.Notice2")
|
||||
.replaceAll("%world%",
|
||||
blockw.getName())
|
||||
.replaceAll("%x%", blockx + "")
|
||||
.replaceAll("%z%", blockz + ""),
|
||||
"cb.notice");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
String[] message = { plugin.getfullmsg("Message.Wran"),
|
||||
plugin.getfullmsg("Message.Allow"),
|
||||
plugin.getfullmsg("Message.Relieve") };
|
||||
if (plugin.tipplayer)
|
||||
p.getPlayer().sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
126
src/config.yml
126
src/config.yml
@ -1,59 +1,67 @@
|
||||
#本文件为保护插件的主配置文件
|
||||
version: '1.0'
|
||||
#服务器名称
|
||||
servername: ''
|
||||
#插件名称
|
||||
pluginname: '&6[&3建筑保护&6]&r'
|
||||
#是否提示
|
||||
tipplayer: true
|
||||
#提示消息
|
||||
Message:
|
||||
Reload: '&a配置文件已重新载入!'
|
||||
#方块安全提示
|
||||
Tip: '&4未在领地内建筑 &c请确保您放置的方块安全 &e圈地后无提示!'
|
||||
|
||||
#未圈地超过建筑高度提示
|
||||
Max: '&c未在领地内建筑 请不要用&e泥土&c建造高于 &5%maxheight%&c 的建筑!'
|
||||
|
||||
#管理组收到的提示
|
||||
Notice1: '&6玩家&r:&a%player%&e未在领地内&c用&3泥土&c建筑高度超过 &5%maxheight%&c 的建筑物!'
|
||||
Notice2: '&5坐标定位&r:&a世界%world% &dX:%x% Z:%z% &4请管理到目标地点检查!'
|
||||
|
||||
#未圈地建筑提示
|
||||
#警告
|
||||
Wran: '&4城市世界除以下方块外禁止放置/破坏!'
|
||||
#允许的方块说明
|
||||
Allow: '&a允许的方块:&e箱子,&5熔炉,&a工作台,&6木板(树木),&d泥土,&9木门'
|
||||
#解除限制说明
|
||||
Relieve: '&c如需解除限制请圈地,&6工具:木锄&c,&b价格:0.3元/方块&c!'
|
||||
|
||||
|
||||
#城市保护配置
|
||||
#未圈地最大高度
|
||||
MaxHeight: 100
|
||||
|
||||
#受到保护的世界(不区分大小写)
|
||||
ProtectWorld:
|
||||
- FutureCity
|
||||
|
||||
#未圈地提示的ID列表
|
||||
NoticeList:
|
||||
- CHEST
|
||||
- FURNACE
|
||||
|
||||
#未圈地允许方块ID列表
|
||||
AllowList:
|
||||
- GRASS
|
||||
- DIRT
|
||||
- WOOD_DOOR
|
||||
- CHEST
|
||||
- FURNACE
|
||||
- WORKBENCH
|
||||
- WOOD
|
||||
- DIRT
|
||||
- TORCH
|
||||
- LONG_GRASS
|
||||
- DOUBLE_PLANT
|
||||
- RED_ROSE
|
||||
- LOG_2
|
||||
- LOG
|
||||
#本文件为保护插件的主配置文件
|
||||
version: '1.1'
|
||||
#服务器名称
|
||||
servername: ''
|
||||
#插件名称
|
||||
pluginname: '&6[&3建筑保护&6]&r'
|
||||
#是否提示
|
||||
tipplayer: true
|
||||
#提示消息
|
||||
Message:
|
||||
Reload: '&a配置文件已重新载入!'
|
||||
#方块安全提示
|
||||
Tip: '&4未在领地内建筑 &c请确保您放置的方块安全 &e圈地后无提示!'
|
||||
|
||||
#未圈地超过建筑高度提示
|
||||
Max: '&c未在领地内建筑 请不要用&e泥土&c建造高于 &5%maxheight%&c 的建筑!'
|
||||
|
||||
#管理组收到的提示
|
||||
Notice1: '&6玩家&r:&a%player%&e未在领地内&c用&3泥土&c建筑高度超过 &5%maxheight%&c 的建筑物!'
|
||||
Notice2: '&5坐标定位&r:&a世界%world% &dX:%x% Z:%z% &4请管理到目标地点检查!'
|
||||
|
||||
#未圈地建筑提示
|
||||
#警告
|
||||
Wran: '&4城市世界除以下方块外禁止放置/破坏!'
|
||||
#允许的方块说明
|
||||
Allow: '&a允许的方块:&e箱子,&5熔炉,&a工作台,&6木板(树木),&d泥土,&9木门'
|
||||
#解除限制说明
|
||||
Relieve: '&c如需解除限制请圈地,&6工具:木锄&c,&b价格:0.3元/方块&c!'
|
||||
|
||||
#不允许交互的提示
|
||||
NotAllow: '&c当前物品不允许在领地外使用!'
|
||||
|
||||
#城市保护配置
|
||||
#未圈地最大高度
|
||||
MaxHeight: 100
|
||||
|
||||
#受到保护的世界(不区分大小写)
|
||||
ProtectWorld:
|
||||
- FutureCity
|
||||
|
||||
#未圈地提示的ID列表
|
||||
NoticeList:
|
||||
- CHEST
|
||||
- FURNACE
|
||||
|
||||
#未圈地允许方块ID列表
|
||||
AllowList:
|
||||
- GRASS
|
||||
- DIRT
|
||||
- WOOD_DOOR
|
||||
- CHEST
|
||||
- FURNACE
|
||||
- WORKBENCH
|
||||
- WOOD
|
||||
- DIRT
|
||||
- TORCH
|
||||
- LONG_GRASS
|
||||
- DOUBLE_PLANT
|
||||
- RED_ROSE
|
||||
- LOG_2
|
||||
- LOG
|
||||
- YELLOW_FLOWER
|
||||
|
||||
#领地外阻止交互的物品
|
||||
NotAllowList:
|
||||
- WATER_BUCKET
|
||||
- LAVA_BUCKET
|
Loading…
Reference in New Issue
Block a user