mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2024-10-31 22:38:48 +00:00
update Residence load class...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
3acbbb2c49
commit
8621508737
@ -85,6 +85,7 @@ public class Residence extends JavaPlugin {
|
||||
protected static Server server;
|
||||
protected static HelpEntry helppages;
|
||||
protected static Language language;
|
||||
protected static Logger log;
|
||||
protected static EconomyInterface economy;
|
||||
public final static int saveVersion = 1;
|
||||
protected static File dataFolder;
|
||||
@ -135,6 +136,10 @@ public class Residence extends JavaPlugin {
|
||||
return leasemanager;
|
||||
}
|
||||
|
||||
public static Logger getLog() {
|
||||
return log;
|
||||
}
|
||||
|
||||
public static PermissionManager getPermissionManager() {
|
||||
return gmanager;
|
||||
}
|
||||
@ -333,8 +338,8 @@ public class Residence extends JavaPlugin {
|
||||
try {
|
||||
File worldFolder = new File(saveFolder, "Worlds");
|
||||
if (!saveFolder.isDirectory()) {
|
||||
this.getLogger().warning("保存目录不存在...");
|
||||
this.getLogger().warning("请重新启动服务器");
|
||||
this.getLogger().warning("领地数据保存目录不存在...");
|
||||
this.getLogger().warning("请重新启动服务器生成新的文件...");
|
||||
return true;
|
||||
}
|
||||
YMLSaveHelper yml;
|
||||
@ -409,6 +414,7 @@ public class Residence extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
log = this.getLogger();
|
||||
bukkitver = this.getServer().getBukkitVersion().substring(0, 5);
|
||||
initsuccess = false;
|
||||
deleteConfirm = new HashMap<String, String>();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* To change this template, choose Tools | Templates and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.bekvon.bukkit.residence.protection;
|
||||
@ -42,6 +41,7 @@ public class ResidenceManager {
|
||||
// For more info, see CraftBukkit.CraftWorld.getChunkAt( Location )
|
||||
return val >> 4;
|
||||
}
|
||||
|
||||
private final int z;
|
||||
private final int x;
|
||||
|
||||
@ -49,6 +49,7 @@ public class ResidenceManager {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public ChunkRef(Location loc) {
|
||||
this.x = getChunkCoord(loc.getBlockX());
|
||||
this.z = getChunkCoord(loc.getBlockZ());
|
||||
@ -74,13 +75,14 @@ public class ResidenceManager {
|
||||
/**
|
||||
* Useful for debug
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( "{ x: " ).append(x).append( ", z: " ).append( z ).append( " }" );
|
||||
return sb.toString();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{ x: ").append(x).append(", z: ").append(z).append(" }");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ChunkRef> getChunks(ClaimedResidence res) {
|
||||
List<ChunkRef> chunks = new ArrayList<ChunkRef>();
|
||||
for (CuboidArea area : res.getAreaArray()) {
|
||||
@ -95,13 +97,12 @@ public class ResidenceManager {
|
||||
if (root == null)
|
||||
return resm;
|
||||
for (World world : Residence.getServ().getWorlds()) {
|
||||
Map<String, Object> reslist = (Map<String, Object>) root.get(world
|
||||
.getName());
|
||||
Map<String, Object> reslist = (Map<String, Object>) root.get(world.getName());
|
||||
if (reslist != null) {
|
||||
try {
|
||||
resm.chunkResidences.put(world.getName(), loadMap(reslist, resm));
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Error in loading save file for world: " + world.getName());
|
||||
Residence.getLog().warning("载入世界: " + world.getName() + "的领地数据时发生错误!");
|
||||
if (Residence.getConfigManager().stopOnSaveError())
|
||||
throw (ex);
|
||||
}
|
||||
@ -111,7 +112,8 @@ 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()) {
|
||||
@ -128,7 +130,8 @@ public class ResidenceManager {
|
||||
}
|
||||
resm.residences.put(res.getKey(), residence);
|
||||
} catch (Exception ex) {
|
||||
System.out.print("[Residence] Failed to load residence (" + res.getKey() + ")! Reason:" + ex.getMessage() + " Error Log:");
|
||||
System.out.print("[Residence] Failed to load residence (" + res.getKey()
|
||||
+ ")! Reason:" + ex.getMessage() + " Error Log:");
|
||||
Logger.getLogger(ResidenceManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
if (Residence.getConfigManager().stopOnSaveError())
|
||||
throw (ex);
|
||||
@ -147,34 +150,43 @@ 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 + Residence.getLanguage().getPhrase("InvalidNameCharacters"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("InvalidNameCharacters"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (loc1 == null || loc2 == null || !loc1.getWorld().getName().equals(loc2.getWorld().getName())) {
|
||||
if (loc1 == null || loc2 == null
|
||||
|| !loc1.getWorld().getName().equals(loc2.getWorld().getName())) {
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("SelectPoints"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
PermissionGroup group = Residence.getPermissionManager().getGroup(owner, loc1.getWorld().getName());
|
||||
boolean createpermission = group.canCreateResidences() || (player == null ? true : player.hasPermission("residence.create"));
|
||||
PermissionGroup group = Residence.getPermissionManager().getGroup(owner,
|
||||
loc1.getWorld().getName());
|
||||
boolean createpermission = group.canCreateResidences()
|
||||
|| (player == null ? true : player.hasPermission("residence.create"));
|
||||
if (!createpermission && !resadmin) {
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (player != null) {
|
||||
if (getOwnedZoneCount(player.getName()) >= group.getMaxZones() && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceTooMany"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("ResidenceTooMany"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -192,7 +204,9 @@ public class ResidenceManager {
|
||||
name = resevent.getResidenceName();
|
||||
if (residences.containsKey(name)) {
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceAlreadyExists", ChatColor.YELLOW + name + ChatColor.RED));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("ResidenceAlreadyExists",
|
||||
ChatColor.YELLOW + name + ChatColor.RED));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -206,11 +220,14 @@ public class ResidenceManager {
|
||||
calculateChunks(name);
|
||||
Residence.getLeaseManager().removeExpireTime(name);
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("ResidenceCreate", ChatColor.YELLOW + name + ChatColor.GREEN));
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ Residence.getLanguage().getPhrase("ResidenceCreate",
|
||||
ChatColor.YELLOW + name + ChatColor.GREEN));
|
||||
}
|
||||
if (Residence.getConfigManager().useLeases()) {
|
||||
if (player != null) {
|
||||
Residence.getLeaseManager().setExpireTime(player, name, group.getLeaseGiveTime());
|
||||
Residence.getLeaseManager().setExpireTime(player, name,
|
||||
group.getLeaseGiveTime());
|
||||
} else {
|
||||
Residence.getLeaseManager().setExpireTime(name, group.getLeaseGiveTime());
|
||||
}
|
||||
@ -262,7 +279,7 @@ public class ResidenceManager {
|
||||
ClaimedResidence res = null;
|
||||
boolean found = false;
|
||||
String world = loc.getWorld().getName();
|
||||
ChunkRef chunk = new ChunkRef( loc );
|
||||
ChunkRef chunk = new ChunkRef(loc);
|
||||
if (chunkResidences.get(world) != null) {
|
||||
if (chunkResidences.get(world).get(chunk) != null) {
|
||||
for (String key : chunkResidences.get(world).get(chunk)) {
|
||||
@ -306,7 +323,7 @@ public class ResidenceManager {
|
||||
String name = null;
|
||||
boolean found = false;
|
||||
String world = loc.getWorld().getName();
|
||||
ChunkRef chunk = new ChunkRef( loc );
|
||||
ChunkRef chunk = new ChunkRef(loc);
|
||||
if (chunkResidences.get(world) != null) {
|
||||
if (chunkResidences.get(world).get(chunk) != null) {
|
||||
for (String key : chunkResidences.get(world).get(chunk)) {
|
||||
@ -365,44 +382,55 @@ 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(), res.getValue(), list, formattedOutput);
|
||||
this.getResidenceList(targetplayer, showhidden, showsubzones, "", res.getKey(),
|
||||
res.getValue(), list, formattedOutput);
|
||||
}
|
||||
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 || res.getPermissions().getOwner().equalsIgnoreCase(targetplayer)) {
|
||||
if (targetplayer == null
|
||||
|| res.getPermissions().getOwner().equalsIgnoreCase(targetplayer)) {
|
||||
if (formattedOutput) {
|
||||
list.add(ChatColor.GREEN + parentzone + resname + ChatColor.YELLOW + " - " + Residence.getLanguage().getPhrase("World") + ": " + res.getWorld());
|
||||
list.add(ChatColor.GREEN + parentzone + resname + ChatColor.YELLOW + " - "
|
||||
+ Residence.getLanguage().getPhrase("World") + ": " + res.getWorld());
|
||||
} else {
|
||||
list.add(parentzone + resname);
|
||||
}
|
||||
}
|
||||
if (showsubzones) {
|
||||
for (Entry<String, ClaimedResidence> sz : res.subzones.entrySet()) {
|
||||
this.getResidenceList(targetplayer, showhidden, showsubzones, parentzone + resname + ".", sz.getKey(), sz.getValue(), list, formattedOutput);
|
||||
this.getResidenceList(targetplayer, showhidden, showsubzones, parentzone
|
||||
+ resname + ".", sz.getKey(), sz.getValue(), list, formattedOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 + Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
reqPlayer.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!res.getPermissions().hasResidencePermission(reqPlayer, true) && !resadmin) {
|
||||
reqPlayer.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
||||
reqPlayer
|
||||
.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
Player giveplayer = Residence.getServ().getPlayer(targPlayer);
|
||||
@ -413,25 +441,35 @@ public class ResidenceManager {
|
||||
CuboidArea[] areas = res.getAreaArray();
|
||||
PermissionGroup g = Residence.getPermissionManager().getGroup(giveplayer);
|
||||
if (areas.length > g.getMaxPhysicalPerResidence() && !resadmin) {
|
||||
reqPlayer.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
|
||||
reqPlayer.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
|
||||
return;
|
||||
}
|
||||
if (getOwnedZoneCount(giveplayer.getName()) >= g.getMaxZones() && !resadmin) {
|
||||
reqPlayer.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
|
||||
reqPlayer.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
|
||||
return;
|
||||
}
|
||||
if (!resadmin) {
|
||||
for (CuboidArea area : areas) {
|
||||
if (!g.inLimits(area)) {
|
||||
reqPlayer.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
|
||||
reqPlayer.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
res.getPermissions().setOwner(giveplayer.getName(), true);
|
||||
// Fix phrases here
|
||||
reqPlayer.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("ResidenceGive", ChatColor.YELLOW + residence + ChatColor.GREEN + "." + ChatColor.YELLOW + giveplayer.getName() + ChatColor.GREEN));
|
||||
giveplayer.sendMessage(Residence.getLanguage().getPhrase("ResidenceRecieve", ChatColor.GREEN + residence + ChatColor.YELLOW + "." + ChatColor.GREEN + reqPlayer.getName() + ChatColor.YELLOW));
|
||||
reqPlayer.sendMessage(ChatColor.GREEN
|
||||
+ Residence.getLanguage().getPhrase(
|
||||
"ResidenceGive",
|
||||
ChatColor.YELLOW + residence + ChatColor.GREEN + "." + ChatColor.YELLOW
|
||||
+ giveplayer.getName() + ChatColor.GREEN));
|
||||
giveplayer.sendMessage(Residence.getLanguage().getPhrase(
|
||||
"ResidenceRecieve",
|
||||
ChatColor.GREEN + residence + ChatColor.YELLOW + "." + ChatColor.GREEN
|
||||
+ reqPlayer.getName() + ChatColor.YELLOW));
|
||||
}
|
||||
|
||||
public void listAllResidences(Player player, int page) {
|
||||
@ -446,7 +484,8 @@ public class ResidenceManager {
|
||||
if (showhidden && !Residence.isResAdminOn(player)) {
|
||||
showhidden = false;
|
||||
}
|
||||
InformationPager.printInfo(player, Residence.getLanguage().getPhrase("Residences"), this.getResidenceList(null, showhidden, showsubzones, true), page);
|
||||
InformationPager.printInfo(player, Residence.getLanguage().getPhrase("Residences"),
|
||||
this.getResidenceList(null, showhidden, showsubzones, true), page);
|
||||
}
|
||||
|
||||
public void listResidences(Player player) {
|
||||
@ -473,23 +512,29 @@ 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;
|
||||
}
|
||||
InformationPager.printInfo(player, Residence.getLanguage().getPhrase("Residences") + " - " + targetplayer, this.getResidenceList(targetplayer, showhidden, showsubzones, true), page);
|
||||
InformationPager.printInfo(player, Residence.getLanguage().getPhrase("Residences") + " - "
|
||||
+ targetplayer,
|
||||
this.getResidenceList(targetplayer, showhidden, showsubzones, true), page);
|
||||
}
|
||||
|
||||
public void mirrorPerms(Player reqPlayer, String targetArea, String sourceArea, boolean resadmin) {
|
||||
ClaimedResidence reciever = this.getByName(targetArea);
|
||||
ClaimedResidence source = this.getByName(sourceArea);
|
||||
if (source == null || reciever == null) {
|
||||
reqPlayer.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
reqPlayer.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!resadmin) {
|
||||
if (!reciever.getPermissions().hasResidencePermission(reqPlayer, true) || !source.getPermissions().hasResidencePermission(reqPlayer, true)) {
|
||||
reqPlayer.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
||||
if (!reciever.getPermissions().hasResidencePermission(reqPlayer, true)
|
||||
|| !source.getPermissions().hasResidencePermission(reqPlayer, true)) {
|
||||
reqPlayer.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -499,35 +544,78 @@ public class ResidenceManager {
|
||||
public void printAreaInfo(String areaname, Player player) {
|
||||
ClaimedResidence res = this.getByName(areaname);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
ResidencePermissions perms = res.getPermissions();
|
||||
if (Residence.getConfigManager().enableEconomy()) {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Residence") + ":" + ChatColor.DARK_GREEN + " " + areaname + " " + ChatColor.YELLOW + "Bank: " + ChatColor.GOLD + res.getBank().getStoredMoney());
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Residence")
|
||||
+ ":" + ChatColor.DARK_GREEN + " " + areaname + " " + ChatColor.YELLOW
|
||||
+ "Bank: " + ChatColor.GOLD + res.getBank().getStoredMoney());
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Residence") + ":" + ChatColor.DARK_GREEN + " " + areaname);
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Residence")
|
||||
+ ":" + ChatColor.DARK_GREEN + " " + areaname);
|
||||
}
|
||||
if (Residence.getConfigManager().enabledRentSystem() && Residence.getRentManager().isRented(areaname)) {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Owner") + ":" + ChatColor.RED + " " + perms.getOwner() + ChatColor.YELLOW + " Rented by: " + ChatColor.RED + Residence.getRentManager().getRentingPlayer(areaname));
|
||||
if (Residence.getConfigManager().enabledRentSystem()
|
||||
&& Residence.getRentManager().isRented(areaname)) {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Owner") + ":"
|
||||
+ ChatColor.RED + " " + perms.getOwner() + ChatColor.YELLOW + " Rented by: "
|
||||
+ ChatColor.RED + Residence.getRentManager().getRentingPlayer(areaname));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Owner") + ":" + ChatColor.RED + " " + perms.getOwner() + ChatColor.YELLOW + " - " + Residence.getLanguage().getPhrase("World") + ": " + ChatColor.RED + perms.getWorld());
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Owner") + ":"
|
||||
+ ChatColor.RED + " " + perms.getOwner() + ChatColor.YELLOW + " - "
|
||||
+ Residence.getLanguage().getPhrase("World") + ": " + ChatColor.RED
|
||||
+ perms.getWorld());
|
||||
}
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Flags") + ":" + ChatColor.BLUE + " " + perms.listFlags());
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Your.Flags") + ": " + ChatColor.GREEN + perms.listPlayerFlags(player.getName()));
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Group.Flags") + ":" + ChatColor.RED + " " + perms.listGroupFlags());
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Others.Flags") + ":" + ChatColor.RED + " " + perms.listOtherPlayersFlags(player.getName()));
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Flags") + ":"
|
||||
+ ChatColor.BLUE + " " + perms.listFlags());
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Your.Flags")
|
||||
+ ": " + ChatColor.GREEN + perms.listPlayerFlags(player.getName()));
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Group.Flags")
|
||||
+ ":" + ChatColor.RED + " " + perms.listGroupFlags());
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Others.Flags")
|
||||
+ ":" + ChatColor.RED + " " + perms.listOtherPlayersFlags(player.getName()));
|
||||
String aid = res.getAreaIDbyLoc(player.getLocation());
|
||||
if (aid != null) {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("CurrentArea") + ": " + ChatColor.GOLD + aid);
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("CurrentArea")
|
||||
+ ": " + ChatColor.GOLD + aid);
|
||||
}
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Total.Size") + ":" + ChatColor.LIGHT_PURPLE + " " + res.getTotalSize());
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("Total.Size") + ":"
|
||||
+ ChatColor.LIGHT_PURPLE + " " + res.getTotalSize());
|
||||
if (aid != null) {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("CoordsT") + ": " + ChatColor.LIGHT_PURPLE + Residence.getLanguage().getPhrase("CoordsTop", res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockX() + "." + res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockZ()));
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("CoordsB") + ": " + ChatColor.LIGHT_PURPLE + Residence.getLanguage().getPhrase("CoordsBottom", res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockZ()));
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
+ Residence.getLanguage().getPhrase("CoordsT")
|
||||
+ ": "
|
||||
+ ChatColor.LIGHT_PURPLE
|
||||
+ Residence.getLanguage().getPhrase(
|
||||
"CoordsTop",
|
||||
res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockX()
|
||||
+ "."
|
||||
+ res.getAreaByLoc(player.getLocation()).getHighLoc()
|
||||
.getBlockY()
|
||||
+ "."
|
||||
+ res.getAreaByLoc(player.getLocation()).getHighLoc()
|
||||
.getBlockZ()));
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
+ Residence.getLanguage().getPhrase("CoordsB")
|
||||
+ ": "
|
||||
+ ChatColor.LIGHT_PURPLE
|
||||
+ Residence.getLanguage().getPhrase(
|
||||
"CoordsBottom",
|
||||
res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX()
|
||||
+ "."
|
||||
+ res.getAreaByLoc(player.getLocation()).getLowLoc()
|
||||
.getBlockY()
|
||||
+ "."
|
||||
+ res.getAreaByLoc(player.getLocation()).getLowLoc()
|
||||
.getBlockZ()));
|
||||
}
|
||||
if (Residence.getConfigManager().useLeases() && Residence.getLeaseManager().leaseExpires(areaname)) {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("LeaseExpire") + ":" + ChatColor.GREEN + " " + Residence.getLeaseManager().getExpireTime(areaname));
|
||||
if (Residence.getConfigManager().useLeases()
|
||||
&& Residence.getLeaseManager().leaseExpires(areaname)) {
|
||||
player.sendMessage(ChatColor.YELLOW + Residence.getLanguage().getPhrase("LeaseExpire")
|
||||
+ ":" + ChatColor.GREEN + " "
|
||||
+ Residence.getLeaseManager().getExpireTime(areaname));
|
||||
}
|
||||
}
|
||||
|
||||
@ -535,12 +623,14 @@ 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();
|
||||
if (res.getOwner().equalsIgnoreCase(owner)) {
|
||||
ResidenceDeleteEvent resevent = new ResidenceDeleteEvent(player, res, player == null ? DeleteCause.OTHER : DeleteCause.PLAYER_DELETE);
|
||||
ResidenceDeleteEvent resevent = new ResidenceDeleteEvent(player, res,
|
||||
player == null ? DeleteCause.OTHER : DeleteCause.PLAYER_DELETE);
|
||||
Residence.getServ().getPluginManager().callEvent(resevent);
|
||||
if (resevent.isCancelled())
|
||||
return;
|
||||
@ -569,9 +659,11 @@ public class ResidenceManager {
|
||||
chunkResidences.remove(world);
|
||||
chunkResidences.put(world, new HashMap<ChunkRef, List<String>>());
|
||||
if (count == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "No residences found in world: " + ChatColor.YELLOW + world);
|
||||
sender.sendMessage(ChatColor.RED + "No residences found in world: " + ChatColor.YELLOW
|
||||
+ world);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Removed " + ChatColor.YELLOW + count + ChatColor.RED + " residences in world: " + ChatColor.YELLOW + world);
|
||||
sender.sendMessage(ChatColor.RED + "Removed " + ChatColor.YELLOW + count
|
||||
+ ChatColor.RED + " residences in world: " + ChatColor.YELLOW + world);
|
||||
}
|
||||
}
|
||||
|
||||
@ -597,11 +689,13 @@ public class ResidenceManager {
|
||||
if (res != null) {
|
||||
if (player != null && !resadmin) {
|
||||
if (!res.getPermissions().hasResidencePermission(player, true) && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
ResidenceDeleteEvent resevent = new ResidenceDeleteEvent(player, res, player == null ? DeleteCause.OTHER : DeleteCause.PLAYER_DELETE);
|
||||
ResidenceDeleteEvent resevent = new ResidenceDeleteEvent(player, res,
|
||||
player == null ? DeleteCause.OTHER : DeleteCause.PLAYER_DELETE);
|
||||
Residence.getServ().getPluginManager().callEvent(resevent);
|
||||
if (resevent.isCancelled())
|
||||
return;
|
||||
@ -610,7 +704,9 @@ public class ResidenceManager {
|
||||
removeChunkList(name);
|
||||
residences.remove(name);
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("ResidenceRemove", ChatColor.YELLOW + name + ChatColor.GREEN));
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ Residence.getLanguage().getPhrase("ResidenceRemove",
|
||||
ChatColor.YELLOW + name + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
String[] split = name.split("\\.");
|
||||
@ -627,7 +723,8 @@ public class ResidenceManager {
|
||||
|
||||
} else {
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -638,13 +735,15 @@ public class ResidenceManager {
|
||||
|
||||
public boolean renameResidence(Player player, String oldName, String newName, boolean resadmin) {
|
||||
if (!Residence.validName(newName)) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidNameCharacters"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("InvalidNameCharacters"));
|
||||
return false;
|
||||
}
|
||||
ClaimedResidence res = this.getByName(oldName);
|
||||
if (res == null) {
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("InvalidResidence"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -652,7 +751,9 @@ public class ResidenceManager {
|
||||
if (res.getParent() == null) {
|
||||
if (residences.containsKey(newName)) {
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceAlreadyExists", ChatColor.YELLOW + newName + ChatColor.RED));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("ResidenceAlreadyExists",
|
||||
ChatColor.YELLOW + newName + ChatColor.RED));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -669,7 +770,11 @@ public class ResidenceManager {
|
||||
Residence.getRentManager().updateRentableName(oldName, newName);
|
||||
}
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("ResidenceRename", ChatColor.YELLOW + oldName + ChatColor.GREEN + "." + ChatColor.YELLOW + newName + ChatColor.GREEN));
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ Residence.getLanguage().getPhrase(
|
||||
"ResidenceRename",
|
||||
ChatColor.YELLOW + oldName + ChatColor.GREEN + "."
|
||||
+ ChatColor.YELLOW + newName + ChatColor.GREEN));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -679,7 +784,8 @@ public class ResidenceManager {
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ Residence.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -698,8 +804,10 @@ public class ResidenceManager {
|
||||
try {
|
||||
resmap.put(res.getKey(), res.getValue().save());
|
||||
} catch (Exception ex) {
|
||||
System.out.println("[Residence] Failed to save residence (" + res.getKey() + ")!");
|
||||
Logger.getLogger(ResidenceManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
System.out.println("[Residence] Failed to save residence (" + res.getKey()
|
||||
+ ")!");
|
||||
Logger.getLogger(ResidenceManager.class.getName()).log(Level.SEVERE, null,
|
||||
ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user