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