1
0
mirror of https://e.coding.net/circlecloud/Residence.git synced 2024-10-31 22:38:48 +00:00

add show Constituency

while use info command(Server need WorldEdit and Client need WECUI)...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-06-04 22:20:00 +08:00
parent 63d5721c60
commit d8b96ece2e
2 changed files with 29 additions and 20 deletions

View File

@ -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 未找到!");
}

View File

@ -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<ChunkRef, List<String>> loadMap(Map<String, Object> root,
ResidenceManager resm) throws Exception {
public static Map<ChunkRef, List<String>> loadMap(Map<String, Object> root, ResidenceManager resm) throws Exception {
Map<ChunkRef, List<String>> retRes = new HashMap<ChunkRef, List<String>>();
if (root != null) {
for (Entry<String, Object> res : root.entrySet()) {
@ -150,13 +153,11 @@ public class ResidenceManager {
chunkResidences = new HashMap<String, Map<ChunkRef, List<String>>>();
}
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<String> getResidenceList(String targetplayer, boolean showhidden,
boolean showsubzones) {
public ArrayList<String> getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones) {
return this.getResidenceList(targetplayer, showhidden, showsubzones, false);
}
public ArrayList<String> getResidenceList(String targetplayer, boolean showhidden,
boolean showsubzones, boolean formattedOutput) {
public ArrayList<String> getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, boolean formattedOutput) {
ArrayList<String> list = new ArrayList<String>();
for (Entry<String, ClaimedResidence> 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<String> list,
boolean formattedOutput) {
private void getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, String parentzone, String resname, ClaimedResidence res, ArrayList<String> 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<String, ClaimedResidence> resholder) {
private void removeAllByOwner(Player player, String owner, Map<String, ClaimedResidence> resholder) {
Iterator<ClaimedResidence> it = resholder.values().iterator();
while (it.hasNext()) {
ClaimedResidence res = it.next();