1
0
mirror of https://e.coding.net/circlecloud/CarryEnchantBench.git synced 2025-11-24 23:56:01 +00:00

cancel event and add message...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092
2015-08-24 22:32:08 +08:00
parent bb7ccaafe2
commit e6f02a941b
2 changed files with 24 additions and 29 deletions

View File

@@ -17,11 +17,6 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>

View File

@@ -1,5 +1,5 @@
/** /**
* *
*/ */
package cn.citycraft.CarryEnchantBench; package cn.citycraft.CarryEnchantBench;
@@ -20,14 +20,33 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
/** /**
* @author 蒋天蓓 * @author 蒋天蓓 2015年8月24日下午3:48:42 TODO
* 2015年8月24日下午3:48:42
* TODO
*/ */
public class CarryEnchantBench extends JavaPlugin implements Listener { public class CarryEnchantBench extends JavaPlugin implements Listener {
Location loc = null; Location loc = null;
List<String> setList = new ArrayList<String>(); List<String> setList = new ArrayList<String>();
@EventHandler
public void onClick(PlayerInteractEvent e) {
Block b = e.getClickedBlock();
Player p = e.getPlayer();
if (setList.contains(p.getName())) {
if (b.getType() == Material.ENCHANTMENT_TABLE) {
loc = b.getLocation();
this.getConfig().set("Location.World", loc.getWorld().getName());
this.getConfig().set("Location.X", loc.getBlockX());
this.getConfig().set("Location.Y", loc.getBlockY());
this.getConfig().set("Location.Z", loc.getBlockZ());
this.saveConfig();
p.sendMessage("§a已成功配置随身附魔台的位置 §c请勿破坏 负责将会影响插件工作!");
} else {
p.sendMessage("§c请点击附魔台配置随身附魔台位置!");
}
setList.remove(p.getName());
e.setCancelled(true);
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
@@ -46,6 +65,7 @@ public class CarryEnchantBench extends JavaPlugin implements Listener {
if (args[0].equalsIgnoreCase("set")) { if (args[0].equalsIgnoreCase("set")) {
if (sender.hasPermission("ceb.set")) { if (sender.hasPermission("ceb.set")) {
if (!setList.contains(sender.getName())) { if (!setList.contains(sender.getName())) {
sender.sendMessage("§b请点击目标附魔台配置为随身附魔台!");
setList.add(sender.getName()); setList.add(sender.getName());
} }
} }
@@ -56,26 +76,6 @@ public class CarryEnchantBench extends JavaPlugin implements Listener {
return false; return false;
} }
@EventHandler
public void onClick(PlayerInteractEvent e) {
Block b = e.getClickedBlock();
Player p = e.getPlayer();
if (setList.contains(p.getName())) {
if (b.getType() == Material.ENCHANTMENT_TABLE) {
loc = b.getLocation();
this.getConfig().set("Location.World", loc.getWorld().getName());
this.getConfig().set("Location.X", loc.getBlockX());
this.getConfig().set("Location.Y", loc.getBlockY());
this.getConfig().set("Location.Z", loc.getBlockZ());
this.saveConfig();
p.sendMessage("§a已成功配置随身附魔台的位置 §c请勿破坏 负责将会影响插件工作!");
} else {
p.sendMessage("§c请点击附魔台配置随身附魔台位置!");
}
setList.remove(p.getName());
}
}
@Override @Override
public void onEnable() { public void onEnable() {
this.saveDefaultConfig(); this.saveDefaultConfig();