红石添加提示开关...

Signed-off-by: 502647092 <jtb1@163.com>
master
502647092 2015-11-25 18:25:07 +08:00
parent ae86523045
commit d9f7ba3ff2
3 changed files with 36 additions and 28 deletions

11
pom.xml
View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.citycraft</groupId>
<artifactId>SimpleProtect</artifactId>
<version>1.3</version>
<version>1.3.1</version>
<name>SimpleProtect</name>
<description>Minecraft 服务器保护插件</description>
<build>
@ -53,6 +53,11 @@
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<update.description>&amp;c红石检测添加提示开关...</update.description>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
@ -77,8 +82,4 @@
<version>1.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
</properties>
</project>

View File

@ -20,43 +20,47 @@ import cn.citycraft.SimpleProtect.SimpleProtect;
public class HighRedstone implements Runnable, Listener {
HashMap<Block, Integer> map = new HashMap<Block, Integer>();
HashMap<Block, Player> pmap = new HashMap<Block, Player>();
SimpleProtect plugin;
HashMap<Block, Player> pmap = new HashMap<Block, Player>();
ArrayList<Player> tipop = new ArrayList<Player>();
public HighRedstone(SimpleProtect main) {
public HighRedstone(final SimpleProtect main) {
plugin = main;
}
@EventHandler
public void onRedClock(BlockRedstoneEvent event) {
Block rb = event.getBlock();
if (rb.getType() == Material.REDSTONE_WIRE)
public void onRedClock(final BlockRedstoneEvent event) {
final Block rb = event.getBlock();
if (rb.getType() == Material.REDSTONE_WIRE) {
put(event.getBlock());
}
}
@EventHandler(ignoreCancelled = true)
public void RedStonePlace(BlockPlaceEvent event) {
Block rb = event.getBlock();
Player rp = event.getPlayer();
if (rb.getType() == Material.REDSTONE_WIRE)
public void RedStonePlace(final BlockPlaceEvent event) {
final Block rb = event.getBlock();
final Player rp = event.getPlayer();
if (rb.getType() == Material.REDSTONE_WIRE) {
pmap.put(rb, rp);
}
}
@Override
public void run() {
List<Block> blocks = new ArrayList<Block>();
for (Entry<Block, Integer> entry : map.entrySet())
if (entry.getValue() > plugin.config.getLong("HighRedstone.Maxevents"))
final List<Block> blocks = new ArrayList<Block>();
for (final Entry<Block, Integer> entry : map.entrySet()) {
if (entry.getValue() > plugin.config.getLong("HighRedstone.Maxevents")) {
blocks.add(entry.getKey());
}
}
Boolean tip = true;
for (Block block : blocks) {
World rw = block.getWorld();
int rx = block.getX();
int ry = block.getY();
int rz = block.getZ();
Player rp = pmap.get(block);
if (rp != null)
for (final Block block : blocks) {
final World rw = block.getWorld();
final int rx = block.getX();
final int ry = block.getY();
final int rz = block.getZ();
final Player rp = pmap.get(block);
if (rp != null) {
if (rp.isOp() || rp.hasPermission("sp.ignore.highredstone")) {
if (!tipop.contains(rp)) {
rp.sendMessage(plugin.getfullmsg("HighRedstone.Admin"));
@ -64,7 +68,8 @@ public class HighRedstone implements Runnable, Listener {
}
continue;
}
if (tip) {
}
if (tip && plugin.config.getBoolean("HighRedstone.Tip")) {
Bukkit.broadcastMessage(plugin.getfullmsg("HighRedstone.Find").replaceAll("%world%", rw.getName()).replaceAll("%x%", rx + "").replaceAll("%y%", ry + "").replaceAll("%z%", rz + ""));
if (rp != null) {
Bukkit.broadcastMessage(plugin.getfullmsg("HighRedstone.Check").replaceAll("%player%", rp.getName()));
@ -77,11 +82,12 @@ public class HighRedstone implements Runnable, Listener {
map.clear();
}
private void put(Block block) {
private void put(final Block block) {
if (map.containsKey(block)) {
int i = map.remove(block);
final int i = map.remove(block);
map.put(block, i + 1);
} else
} else {
map.put(block, 1);
}
}
}

View File

@ -28,6 +28,7 @@ Explosion:
HighRedstone:
#是否开启
Enable: true
Tip: true
Maxevents: 35
Find: '&c发现高频红石 &3世界 %world% &d坐标 X:%x% Y:%y% Z:%z% &a已清理'
Check: '&c高频红石数据监测 &5上述高频红石由 &6玩家 &a%player% &6放置'