cancel event and add message...

Signed-off-by: j502647092 <jtb1@163.com>
Custom
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"/>
</attributes>
</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">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package cn.citycraft.CarryEnchantBench;
@ -20,14 +20,33 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;
/**
* @author
* 20158243:48:42
* TODO
* @author 20158243:48:42 TODO
*/
public class CarryEnchantBench extends JavaPlugin implements Listener {
Location loc = null;
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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
@ -46,6 +65,7 @@ public class CarryEnchantBench extends JavaPlugin implements Listener {
if (args[0].equalsIgnoreCase("set")) {
if (sender.hasPermission("ceb.set")) {
if (!setList.contains(sender.getName())) {
sender.sendMessage("§b请点击目标附魔台配置为随身附魔台!");
setList.add(sender.getName());
}
}
@ -56,26 +76,6 @@ public class CarryEnchantBench extends JavaPlugin implements Listener {
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
public void onEnable() {
this.saveDefaultConfig();