From d8b96ece2e0c28603ed6f36b405afa6ccdb2d8bd Mon Sep 17 00:00:00 2001 From: j502647092 Date: Thu, 4 Jun 2015 22:20:00 +0800 Subject: [PATCH] add show Constituency while use info command(Server need WorldEdit and Client need WECUI)... Signed-off-by: j502647092 --- .../bekvon/bukkit/residence/Residence.java | 9 ++++- .../protection/ResidenceManager.java | 40 ++++++++++--------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/com/bekvon/bukkit/residence/Residence.java b/src/com/bekvon/bukkit/residence/Residence.java index 7955da7..d73ea2d 100644 --- a/src/com/bekvon/bukkit/residence/Residence.java +++ b/src/com/bekvon/bukkit/residence/Residence.java @@ -86,6 +86,7 @@ public class Residence extends JavaPlugin { protected static HelpEntry helppages; protected static Language language; protected static Logger log; + protected static boolean useWorldEdit; protected static EconomyInterface economy; public final static int saveVersion = 1; protected static File dataFolder; @@ -208,6 +209,10 @@ public class Residence extends JavaPlugin { return false; } + public static boolean isUseWorldEdit() { + return useWorldEdit; + } + public static void turnResAdminOn(Player player) { resadminToggle.add(player.getName()); } @@ -400,7 +405,7 @@ public class Residence extends JavaPlugin { } this.getLogger().info( "从配置文件中读取领地数据,耗时" + ((float) (System.currentTimeMillis() - time) / 1000) - + " 秒)"); + + " 秒)"); // System.out.print("[Residence] Loaded..."); return true; } catch (Exception ex) { @@ -539,9 +544,11 @@ public class Residence extends JavaPlugin { Plugin p = server.getPluginManager().getPlugin("WorldEdit"); if (p != null) { smanager = new WorldEditSelectionManager(server); + useWorldEdit = true; this.getLogger().info("发现 WorldEdit"); } else { smanager = new SelectionManager(server); + useWorldEdit = false; this.getLogger().warning("WorldEdit 未找到!"); } diff --git a/src/com/bekvon/bukkit/residence/protection/ResidenceManager.java b/src/com/bekvon/bukkit/residence/protection/ResidenceManager.java index b95e8f4..aa7e329 100644 --- a/src/com/bekvon/bukkit/residence/protection/ResidenceManager.java +++ b/src/com/bekvon/bukkit/residence/protection/ResidenceManager.java @@ -16,6 +16,7 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; @@ -29,6 +30,9 @@ import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent.DeleteCause; import com.bekvon.bukkit.residence.event.ResidenceRenameEvent; import com.bekvon.bukkit.residence.permissions.PermissionGroup; import com.bekvon.bukkit.residence.text.help.InformationPager; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.bukkit.selections.CuboidSelection; +import com.sk89q.worldedit.bukkit.selections.Selection; /** * @@ -112,8 +116,7 @@ public class ResidenceManager { } @SuppressWarnings("unchecked") - public static Map> loadMap(Map root, - ResidenceManager resm) throws Exception { + public static Map> loadMap(Map root, ResidenceManager resm) throws Exception { Map> retRes = new HashMap>(); if (root != null) { for (Entry res : root.entrySet()) { @@ -150,13 +153,11 @@ public class ResidenceManager { chunkResidences = new HashMap>>(); } - public boolean addResidence(Player player, String name, Location loc1, Location loc2, - boolean resadmin) { + public boolean addResidence(Player player, String name, Location loc1, Location loc2, boolean resadmin) { return this.addResidence(player, player.getName(), name, loc1, loc2, resadmin); } - public boolean addResidence(Player player, String owner, String name, Location loc1, - Location loc2, boolean resadmin) { + public boolean addResidence(Player player, String owner, String name, Location loc1, Location loc2, boolean resadmin) { if (!Residence.validName(name)) { if (player != null) { player.sendMessage(ChatColor.RED @@ -382,13 +383,11 @@ public class ResidenceManager { return this.getResidenceList(null, showhidden, showsubzones, false); } - public ArrayList getResidenceList(String targetplayer, boolean showhidden, - boolean showsubzones) { + public ArrayList getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones) { return this.getResidenceList(targetplayer, showhidden, showsubzones, false); } - public ArrayList getResidenceList(String targetplayer, boolean showhidden, - boolean showsubzones, boolean formattedOutput) { + public ArrayList getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, boolean formattedOutput) { ArrayList list = new ArrayList(); for (Entry res : residences.entrySet()) { this.getResidenceList(targetplayer, showhidden, showsubzones, "", res.getKey(), @@ -397,9 +396,7 @@ public class ResidenceManager { return list; } - private void getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, - String parentzone, String resname, ClaimedResidence res, ArrayList list, - boolean formattedOutput) { + private void getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, String parentzone, String resname, ClaimedResidence res, ArrayList list, boolean formattedOutput) { boolean hidden = res.getPermissions().has("hidden", false); if ((showhidden) || (!showhidden && !hidden)) { if (targetplayer == null @@ -420,8 +417,7 @@ public class ResidenceManager { } } - public void giveResidence(Player reqPlayer, String targPlayer, String residence, - boolean resadmin) { + public void giveResidence(Player reqPlayer, String targPlayer, String residence, boolean resadmin) { ClaimedResidence res = getByName(residence); if (res == null) { reqPlayer.sendMessage(ChatColor.RED @@ -512,8 +508,7 @@ public class ResidenceManager { this.listResidences(player, targetplayer, page, showhidden, false); } - public void listResidences(Player player, String targetplayer, int page, boolean showhidden, - boolean showsubzones) { + public void listResidences(Player player, String targetplayer, int page, boolean showhidden, boolean showsubzones) { if (showhidden && !Residence.isResAdminOn(player) && !player.getName().equals(targetplayer)) { showhidden = false; } @@ -610,6 +605,14 @@ public class ResidenceManager { + "." + res.getAreaByLoc(player.getLocation()).getLowLoc() .getBlockZ())); + if (Residence.isUseWorldEdit()) { + WorldEditPlugin wep = (WorldEditPlugin) Residence.getServ().getPluginManager() + .getPlugin("WorldEdit"); + Selection selection = new CuboidSelection(Bukkit.getWorld(res.getWorld()), res + .getAreaByLoc(player.getLocation()).getLowLoc(), res.getAreaByLoc( + player.getLocation()).getHighLoc()); + wep.setSelection(player, selection); + } } if (Residence.getConfigManager().useLeases() && Residence.getLeaseManager().leaseExpires(areaname)) { @@ -623,8 +626,7 @@ public class ResidenceManager { this.removeAllByOwner(player, owner, residences); } - private void removeAllByOwner(Player player, String owner, - Map resholder) { + private void removeAllByOwner(Player player, String owner, Map resholder) { Iterator it = resholder.values().iterator(); while (it.hasNext()) { ClaimedResidence res = it.next();