From a8b92a19a0c673f7bbbac247c1348adf852ea5e0 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Thu, 13 Aug 2015 22:32:41 +0800 Subject: [PATCH] fix sethome and home command... Signed-off-by: j502647092 --- .../SimpleEssential/command/CommandHome.java | 22 ++++++++------- .../command/CommandSetHome.java | 27 +++++++++---------- src/plugin.yml | 14 +++++++++- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/cn/citycraft/SimpleEssential/command/CommandHome.java b/src/cn/citycraft/SimpleEssential/command/CommandHome.java index ea29807..ff58944 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandHome.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandHome.java @@ -1,5 +1,5 @@ /** - * + * */ package cn.citycraft.SimpleEssential.command; @@ -11,9 +11,7 @@ import org.bukkit.entity.Player; import cn.citycraft.SimpleEssential.SimpleEssential; /** - * @author 蒋天蓓 - * 2015年8月12日下午2:04:05 - * TODO + * @author 蒋天蓓 2015年8月12日下午2:04:05 TODO */ public class CommandHome extends SimpleEssentialCommand { SimpleEssential plugin; @@ -27,8 +25,14 @@ public class CommandHome extends SimpleEssentialCommand { } @Override - public String getPossibleArguments() { - return ""; + public void execute(CommandSender sender, String label, String[] args) throws CommandException { + Player p = (Player) sender; + Location loc = p.getBedSpawnLocation(); + if (loc == null) { + p.sendMessage("§c你的床丢失了或者被方块阻挡了!"); + return; + } + plugin.tpcontrol.magicTeleport(p, loc); } @Override @@ -37,9 +41,7 @@ public class CommandHome extends SimpleEssentialCommand { } @Override - public void execute(CommandSender sender, String label, String[] args) throws CommandException { - Player p = (Player) sender; - Location loc = p.getBedSpawnLocation(); - plugin.tpcontrol.magicTeleport(p, loc); + public String getPossibleArguments() { + return ""; } } diff --git a/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java b/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java index a4da9a4..4dfb8aa 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java @@ -1,5 +1,5 @@ /** - * + * */ package cn.citycraft.SimpleEssential.command; @@ -12,9 +12,7 @@ import org.bukkit.entity.Player; import cn.citycraft.SimpleEssential.SimpleEssential; /** - * @author 蒋天蓓 - * 2015年8月12日下午2:04:05 - * TODO + * @author 蒋天蓓 2015年8月12日下午2:04:05 TODO */ public class CommandSetHome extends SimpleEssentialCommand { SimpleEssential plugin; @@ -28,8 +26,15 @@ public class CommandSetHome extends SimpleEssentialCommand { } @Override - public String getPossibleArguments() { - return ""; + public void execute(CommandSender sender, String label, String[] args) throws CommandException { + Player p = (Player) sender; + Block b = p.getLocation().getBlock(); + if (b.getType() == Material.BED_BLOCK) { + p.setBedSpawnLocation(b.getLocation(), true); + p.sendMessage("§a家设置成功!"); + } else { + p.sendMessage("§c请站在床上设置家!"); + } } @Override @@ -38,13 +43,7 @@ public class CommandSetHome extends SimpleEssentialCommand { } @Override - public void execute(CommandSender sender, String label, String[] args) throws CommandException { - Player p = (Player) sender; - Block b = p.getLocation().add(0, -1, 0).getBlock(); - if (b.getType() == Material.BED_BLOCK) { - - } else { - - } + public String getPossibleArguments() { + return ""; } } diff --git a/src/plugin.yml b/src/plugin.yml index b2d3321..f877910 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -40,11 +40,23 @@ commands: permission: se.back permission-message: §c你没有 的权限来执行此命令! top: - description: 回到上一个TP地点 + description: 传送到最高方块 aliases: [setop] usage: §b使用/top 传送到当前位置最高方块! permission: se.top permission-message: §c你没有 的权限来执行此命令! + home: + description: 传送到家里 + aliases: [sehome] + usage: §b使用/home 传送到家里! + permission: se.home + permission-message: §c你没有 的权限来执行此命令! + sethome: + description: 设置当前位置为家 + aliases: [sesethome] + usage: §b使用/sethome 设置当前位置为家! + permission: se.sethome + permission-message: §c你没有 的权限来执行此命令! permissions: se.*: description: 简单基础插件所有权限!