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 HelpEntry helppages;
protected static Language language; protected static Language language;
protected static Logger log; protected static Logger log;
protected static boolean useWorldEdit;
protected static EconomyInterface economy; protected static EconomyInterface economy;
public final static int saveVersion = 1; public final static int saveVersion = 1;
protected static File dataFolder; protected static File dataFolder;
@ -208,6 +209,10 @@ public class Residence extends JavaPlugin {
return false; return false;
} }
public static boolean isUseWorldEdit() {
return useWorldEdit;
}
public static void turnResAdminOn(Player player) { public static void turnResAdminOn(Player player) {
resadminToggle.add(player.getName()); resadminToggle.add(player.getName());
} }
@ -400,7 +405,7 @@ public class Residence extends JavaPlugin {
} }
this.getLogger().info( this.getLogger().info(
"从配置文件中读取领地数据,耗时" + ((float) (System.currentTimeMillis() - time) / 1000) "从配置文件中读取领地数据,耗时" + ((float) (System.currentTimeMillis() - time) / 1000)
+ " 秒)"); + " 秒)");
// System.out.print("[Residence] Loaded..."); // System.out.print("[Residence] Loaded...");
return true; return true;
} catch (Exception ex) { } catch (Exception ex) {
@ -539,9 +544,11 @@ public class Residence extends JavaPlugin {
Plugin p = server.getPluginManager().getPlugin("WorldEdit"); Plugin p = server.getPluginManager().getPlugin("WorldEdit");
if (p != null) { if (p != null) {
smanager = new WorldEditSelectionManager(server); smanager = new WorldEditSelectionManager(server);
useWorldEdit = true;
this.getLogger().info("发现 WorldEdit"); this.getLogger().info("发现 WorldEdit");
} else { } else {
smanager = new SelectionManager(server); smanager = new SelectionManager(server);
useWorldEdit = false;
this.getLogger().warning("WorldEdit 未找到!"); this.getLogger().warning("WorldEdit 未找到!");
} }

View File

@ -16,6 +16,7 @@ import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; 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.event.ResidenceRenameEvent;
import com.bekvon.bukkit.residence.permissions.PermissionGroup; import com.bekvon.bukkit.residence.permissions.PermissionGroup;
import com.bekvon.bukkit.residence.text.help.InformationPager; 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") @SuppressWarnings("unchecked")
public static Map<ChunkRef, List<String>> loadMap(Map<String, Object> root, public static Map<ChunkRef, List<String>> loadMap(Map<String, Object> root, ResidenceManager resm) throws Exception {
ResidenceManager resm) throws Exception {
Map<ChunkRef, List<String>> retRes = new HashMap<ChunkRef, List<String>>(); Map<ChunkRef, List<String>> retRes = new HashMap<ChunkRef, List<String>>();
if (root != null) { if (root != null) {
for (Entry<String, Object> res : root.entrySet()) { for (Entry<String, Object> res : root.entrySet()) {
@ -150,13 +153,11 @@ public class ResidenceManager {
chunkResidences = new HashMap<String, Map<ChunkRef, List<String>>>(); chunkResidences = new HashMap<String, Map<ChunkRef, List<String>>>();
} }
public boolean addResidence(Player player, String name, Location loc1, Location loc2, public boolean addResidence(Player player, String name, Location loc1, Location loc2, boolean resadmin) {
boolean resadmin) {
return this.addResidence(player, player.getName(), name, loc1, loc2, resadmin); return this.addResidence(player, player.getName(), name, loc1, loc2, resadmin);
} }
public boolean addResidence(Player player, String owner, String name, Location loc1, public boolean addResidence(Player player, String owner, String name, Location loc1, Location loc2, boolean resadmin) {
Location loc2, boolean resadmin) {
if (!Residence.validName(name)) { if (!Residence.validName(name)) {
if (player != null) { if (player != null) {
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
@ -382,13 +383,11 @@ public class ResidenceManager {
return this.getResidenceList(null, showhidden, showsubzones, false); return this.getResidenceList(null, showhidden, showsubzones, false);
} }
public ArrayList<String> getResidenceList(String targetplayer, boolean showhidden, public ArrayList<String> getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones) {
boolean showsubzones) {
return this.getResidenceList(targetplayer, showhidden, showsubzones, false); return this.getResidenceList(targetplayer, showhidden, showsubzones, false);
} }
public ArrayList<String> getResidenceList(String targetplayer, boolean showhidden, public ArrayList<String> getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, boolean formattedOutput) {
boolean showsubzones, boolean formattedOutput) {
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<String>();
for (Entry<String, ClaimedResidence> res : residences.entrySet()) { for (Entry<String, ClaimedResidence> res : residences.entrySet()) {
this.getResidenceList(targetplayer, showhidden, showsubzones, "", res.getKey(), this.getResidenceList(targetplayer, showhidden, showsubzones, "", res.getKey(),
@ -397,9 +396,7 @@ public class ResidenceManager {
return list; return list;
} }
private void getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, private void getResidenceList(String targetplayer, boolean showhidden, boolean showsubzones, String parentzone, String resname, ClaimedResidence res, ArrayList<String> list, boolean formattedOutput) {
String parentzone, String resname, ClaimedResidence res, ArrayList<String> list,
boolean formattedOutput) {
boolean hidden = res.getPermissions().has("hidden", false); boolean hidden = res.getPermissions().has("hidden", false);
if ((showhidden) || (!showhidden && !hidden)) { if ((showhidden) || (!showhidden && !hidden)) {
if (targetplayer == null if (targetplayer == null
@ -420,8 +417,7 @@ public class ResidenceManager {
} }
} }
public void giveResidence(Player reqPlayer, String targPlayer, String residence, public void giveResidence(Player reqPlayer, String targPlayer, String residence, boolean resadmin) {
boolean resadmin) {
ClaimedResidence res = getByName(residence); ClaimedResidence res = getByName(residence);
if (res == null) { if (res == null) {
reqPlayer.sendMessage(ChatColor.RED reqPlayer.sendMessage(ChatColor.RED
@ -512,8 +508,7 @@ public class ResidenceManager {
this.listResidences(player, targetplayer, page, showhidden, false); this.listResidences(player, targetplayer, page, showhidden, false);
} }
public void listResidences(Player player, String targetplayer, int page, boolean showhidden, public void listResidences(Player player, String targetplayer, int page, boolean showhidden, boolean showsubzones) {
boolean showsubzones) {
if (showhidden && !Residence.isResAdminOn(player) && !player.getName().equals(targetplayer)) { if (showhidden && !Residence.isResAdminOn(player) && !player.getName().equals(targetplayer)) {
showhidden = false; showhidden = false;
} }
@ -610,6 +605,14 @@ public class ResidenceManager {
+ "." + "."
+ res.getAreaByLoc(player.getLocation()).getLowLoc() + res.getAreaByLoc(player.getLocation()).getLowLoc()
.getBlockZ())); .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() if (Residence.getConfigManager().useLeases()
&& Residence.getLeaseManager().leaseExpires(areaname)) { && Residence.getLeaseManager().leaseExpires(areaname)) {
@ -623,8 +626,7 @@ public class ResidenceManager {
this.removeAllByOwner(player, owner, residences); this.removeAllByOwner(player, owner, residences);
} }
private void removeAllByOwner(Player player, String owner, private void removeAllByOwner(Player player, String owner, Map<String, ClaimedResidence> resholder) {
Map<String, ClaimedResidence> resholder) {
Iterator<ClaimedResidence> it = resholder.values().iterator(); Iterator<ClaimedResidence> it = resholder.values().iterator();
while (it.hasNext()) { while (it.hasNext()) {
ClaimedResidence res = it.next(); ClaimedResidence res = it.next();