1
0
mirror of https://e.coding.net/circlecloud/Residence.git synced 2025-11-24 21:46:16 +00:00

整理代码 清理无效return...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092
2015-12-12 11:55:00 +08:00
parent dd4b04ce68
commit c0f233b4de
16 changed files with 1682 additions and 1751 deletions

View File

@@ -205,9 +205,8 @@ public class ResidenceMain extends JavaPlugin {
final ClaimedResidence res = rmanager.getByLoc(loc); final ClaimedResidence res = rmanager.getByLoc(loc);
if (res != null) { if (res != null) {
return res.getPermissions(); return res.getPermissions();
} else {
return wmanager.getPerms(loc.getWorld().getName());
} }
return wmanager.getPerms(loc.getWorld().getName());
} }
public FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) { public FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
@@ -692,14 +691,13 @@ public class ResidenceMain extends JavaPlugin {
} }
if (cmanager.getResidenceNameRegex() == null) { if (cmanager.getResidenceNameRegex() == null) {
return true; return true;
} else { }
final String namecheck = name.replaceAll(cmanager.getResidenceNameRegex(), ""); final String namecheck = name.replaceAll(cmanager.getResidenceNameRegex(), "");
if (!name.equals(namecheck)) { if (!name.equals(namecheck)) {
return false; return false;
} }
return true; return true;
} }
}
private boolean checkNewLanguageVersion(final String lang) throws IOException, FileNotFoundException, InvalidConfigurationException { private boolean checkNewLanguageVersion(final String lang) throws IOException, FileNotFoundException, InvalidConfigurationException {
final File outFile = new File(new File(this.getDataFolder(), "Language"), lang + ".yml"); final File outFile = new File(new File(this.getDataFolder(), "Language"), lang + ".yml");

View File

@@ -50,7 +50,6 @@ public class CommandLease extends BaseCommand {
} else { } else {
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire")); player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
} }
return;
} else { } else {
final String area = rmanager.getNameByLoc(player.getLocation()); final String area = rmanager.getNameByLoc(player.getLocation());
final ClaimedResidence res = rmanager.getByName(area); final ClaimedResidence res = rmanager.getByName(area);
@@ -64,7 +63,6 @@ public class CommandLease extends BaseCommand {
} else { } else {
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire")); player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
} }
return;
} }
} }
} else if (args.length == 3) { } else if (args.length == 3) {
@@ -80,7 +78,6 @@ public class CommandLease extends BaseCommand {
} else { } else {
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire")); player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
} }
return;
} else { } else {
int days; int days;
try { try {
@@ -90,7 +87,6 @@ public class CommandLease extends BaseCommand {
return; return;
} }
leasemanager.setExpireTime(player, args[1], days); leasemanager.setExpireTime(player, args[1], days);
return;
} }
} }
} }

View File

@@ -45,7 +45,6 @@ public class CommandRemove extends BaseCommand {
} else { } else {
rmanager.removeResidence(player, area, resadmin); rmanager.removeResidence(player, area, resadmin);
} }
return;
} else { } else {
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) { if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + area + ChatColor.RED)); player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + area + ChatColor.RED));
@@ -53,8 +52,8 @@ public class CommandRemove extends BaseCommand {
} else { } else {
rmanager.removeResidence(player, area, resadmin); rmanager.removeResidence(player, area, resadmin);
} }
return;
} }
return;
} }
} }
if (args.length != 1) { if (args.length != 1) {

View File

@@ -59,10 +59,8 @@ public class CommandSubZone extends BaseCommand {
return; return;
} }
res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin); res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin);
return;
} else { } else {
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints")); player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
return;
} }
} }

View File

@@ -18,73 +18,74 @@ public class EssentialsEcoAdapter implements EconomyInterface {
Essentials plugin; Essentials plugin;
public EssentialsEcoAdapter(Essentials p) { public EssentialsEcoAdapter(final Essentials p) {
plugin = p; plugin = p;
String serverland = "Server Land"; final String serverland = "Server Land";
if (!Economy.playerExists(serverland)) { if (!Economy.playerExists(serverland)) {
Economy.createNPC(serverland); Economy.createNPC(serverland);
} }
} }
@Override @Override
public double getBalance(String playerName) { public boolean add(final String playerName, final double amount) {
try {
if (Economy.playerExists(playerName)) { if (Economy.playerExists(playerName)) {
return Economy.getMoney(playerName); try {
} else { Economy.add(playerName, amount);
return 0; return true;
} catch (final UserDoesNotExistException ex) {
return false;
} catch (final NoLoanPermittedException ex) {
return false;
} }
} catch (UserDoesNotExistException ex) {
return 0;
} }
return false;
} }
@Override @Override
public boolean canAfford(String playerName, double amount) { public boolean canAfford(final String playerName, final double amount) {
try { try {
if (Economy.playerExists(playerName)) { if (Economy.playerExists(playerName)) {
return Economy.hasEnough(playerName, amount); return Economy.hasEnough(playerName, amount);
} }
return false; return false;
} catch (UserDoesNotExistException ex) { } catch (final UserDoesNotExistException ex) {
return false; return false;
} }
} }
@Override @Override
public boolean add(String playerName, double amount) { public double getBalance(final String playerName) {
if (Economy.playerExists(playerName)) {
try { try {
Economy.add(playerName, amount); if (Economy.playerExists(playerName)) {
return true; return Economy.getMoney(playerName);
} catch (UserDoesNotExistException ex) {
return false;
} catch (NoLoanPermittedException ex) {
return false;
} }
} else { } catch (final UserDoesNotExistException ex) {
return false;
} }
return 0;
} }
@Override @Override
public boolean subtract(String playerName, double amount) { public String getName() {
return "EssentialsEconomy";
}
@Override
public boolean subtract(final String playerName, final double amount) {
if (Economy.playerExists(playerName)) { if (Economy.playerExists(playerName)) {
try { try {
Economy.subtract(playerName, amount); Economy.subtract(playerName, amount);
return true; return true;
} catch (UserDoesNotExistException ex) { } catch (final UserDoesNotExistException ex) {
return false; return false;
} catch (NoLoanPermittedException ex) { } catch (final NoLoanPermittedException ex) {
return false; return false;
} }
} else {
return false;
} }
return false;
} }
@Override @Override
public boolean transfer(String playerFrom, String playerTo, double amount) { public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
try { try {
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) { if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
if (!subtract(playerFrom, amount)) if (!subtract(playerFrom, amount))
@@ -95,15 +96,10 @@ public class EssentialsEcoAdapter implements EconomyInterface {
} }
return true; return true;
} }
} catch (UserDoesNotExistException ex) { } catch (final UserDoesNotExistException ex) {
return false; return false;
} }
return false; return false;
} }
@Override
public String getName() {
return "EssentialsEconomy";
}
} }

View File

@@ -4,13 +4,13 @@
*/ */
package cn.citycraft.Residence.itemlist; package cn.citycraft.Residence.itemlist;
import org.bukkit.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -21,130 +21,69 @@ import org.bukkit.entity.Player;
*/ */
public class ItemList { public class ItemList {
public static enum ListType {
BLACKLIST,
WHITELIST,
IGNORELIST,
OTHER
}
protected List<Material> list; protected List<Material> list;
protected ListType type; protected ListType type;
public ItemList(ListType listType) public ItemList(final ListType listType) {
{
this(); this();
type = listType; type = listType;
} }
protected ItemList() protected ItemList() {
{
list = new ArrayList<Material>(); list = new ArrayList<Material>();
} }
public static enum ListType public static ItemList load(final Map<String, Object> map) {
{ final ItemList newlist = new ItemList();
BLACKLIST,WHITELIST,IGNORELIST,OTHER return load(map, newlist);
} }
public ListType getType() public static ItemList readList(final ConfigurationSection node) {
{
return type;
}
public boolean contains(Material mat)
{
return list.contains(mat);
}
public void add(Material mat)
{
if(!list.contains(mat))
list.add(mat);
}
public boolean toggle(Material mat)
{
if(list.contains(mat))
{
list.remove(mat);
return false;
}
else
{
list.add(mat);
return true;
}
}
public void remove(Material mat)
{
list.remove(mat);
}
public boolean isAllowed(Material mat)
{
if(type == ListType.BLACKLIST)
{
if(list.contains(mat))
{
return false;
}
return true;
}
else if(type == ListType.WHITELIST)
{
if(list.contains(mat))
{
return true;
}
return false;
}
return true;
}
public boolean isIgnored(Material mat)
{
if(type == ListType.IGNORELIST)
{
if(list.contains(mat))
{
return true;
}
}
return false;
}
public boolean isListed(Material mat)
{
return this.contains(mat);
}
public int getListSize()
{
return list.size();
}
public static ItemList readList(ConfigurationSection node)
{
return ItemList.readList(node, new ItemList()); return ItemList.readList(node, new ItemList());
} }
@SuppressWarnings("unchecked")
protected static ItemList load(final Map<String, Object> map, final ItemList newlist) {
try {
newlist.type = ListType.valueOf((String) map.get("Type"));
final List<String> list = (List<String>) map.get("ItemList");
for (final String item : list) {
newlist.add(Material.valueOf(item));
}
} catch (final Exception ex) {
}
return newlist;
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected static ItemList readList(ConfigurationSection node, ItemList list) protected static ItemList readList(final ConfigurationSection node, final ItemList list) {
{ final ListType type = ListType.valueOf(node.getString("Type", "").toUpperCase());
ListType type = ListType.valueOf(node.getString("Type","").toUpperCase());
list.type = type; list.type = type;
List<String> items = node.getStringList("Items"); final List<String> items = node.getStringList("Items");
if (items != null) { if (items != null) {
for (String item : items) { for (final String item : items) {
int parse = -1; int parse = -1;
try { try {
parse = Integer.parseInt(item); parse = Integer.parseInt(item);
} catch (Exception ex) { } catch (final Exception ex) {
} }
if (parse == -1) { if (parse == -1) {
try { try {
list.add(Material.valueOf(item.toUpperCase())); list.add(Material.valueOf(item.toUpperCase()));
} catch (Exception ex) { } catch (final Exception ex) {
} }
} else { } else {
try { try {
list.add(Material.getMaterial(parse)); list.add(Material.getMaterial(parse));
} catch (Exception ex) { } catch (final Exception ex) {
} }
} }
} }
@@ -152,12 +91,55 @@ public class ItemList {
return list; return list;
} }
public void printList(Player player) public void add(final Material mat) {
{ if (!list.contains(mat))
StringBuilder builder = new StringBuilder(); list.add(mat);
}
public boolean contains(final Material mat) {
return list.contains(mat);
}
public int getListSize() {
return list.size();
}
public ListType getType() {
return type;
}
public boolean isAllowed(final Material mat) {
if (type == ListType.BLACKLIST) {
if (list.contains(mat)) {
return false;
}
return true;
} else if (type == ListType.WHITELIST) {
if (list.contains(mat)) {
return true;
}
return false;
}
return true;
}
public boolean isIgnored(final Material mat) {
if (type == ListType.IGNORELIST) {
if (list.contains(mat)) {
return true;
}
}
return false;
}
public boolean isListed(final Material mat) {
return this.contains(mat);
}
public void printList(final Player player) {
final StringBuilder builder = new StringBuilder();
boolean first = true; boolean first = true;
for(Material mat : list) for (final Material mat : list) {
{
if (!first) if (!first)
builder.append(", "); builder.append(", ");
else else
@@ -168,51 +150,37 @@ public class ItemList {
player.sendMessage(builder.toString()); player.sendMessage(builder.toString());
} }
public Material[] toArray() public void remove(final Material mat) {
{ list.remove(mat);
Material mats[] = new Material[list.size()];
int i = 0;
for(Material mat : list)
{
mats[i] = mat;
i++;
}
return mats;
} }
public Map<String,Object> save() public Map<String, Object> save() {
{ final Map<String, Object> saveMap = new LinkedHashMap<String, Object>();
Map<String, Object> saveMap = new LinkedHashMap<String,Object>();
saveMap.put("Type", type.toString()); saveMap.put("Type", type.toString());
List<String> saveList = new ArrayList<String>(); final List<String> saveList = new ArrayList<String>();
for(Material mat : list) for (final Material mat : list) {
{
saveList.add(mat.toString()); saveList.add(mat.toString());
} }
saveMap.put("ItemList", saveList); saveMap.put("ItemList", saveList);
return saveMap; return saveMap;
} }
public static ItemList load(Map<String,Object> map) public Material[] toArray() {
{ final Material mats[] = new Material[list.size()];
ItemList newlist = new ItemList(); int i = 0;
return load(map,newlist); for (final Material mat : list) {
mats[i] = mat;
i++;
}
return mats;
} }
@SuppressWarnings("unchecked") public boolean toggle(final Material mat) {
protected static ItemList load(Map<String,Object> map, ItemList newlist) if (list.contains(mat)) {
{ list.remove(mat);
try return false;
{ }
newlist.type = ListType.valueOf((String) map.get("Type")); list.add(mat);
List<String> list = (List<String>) map.get("ItemList"); return true;
for(String item : list)
{
newlist.add(Material.valueOf(item));
}
}
catch (Exception ex)
{}
return newlist;
} }
} }

View File

@@ -351,11 +351,9 @@ public class ResidencePlayerListener implements Listener {
if (hasuse || checkMat.getValue().equals("container")) { if (hasuse || checkMat.getValue().equals("container")) {
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue())); player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
return;
} else { } else {
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use")); player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
return;
} }
} }
} }
@@ -528,8 +526,7 @@ public class ResidencePlayerListener implements Listener {
private boolean isCanUseEntity_BothClick(final Material mat, final Block block) { private boolean isCanUseEntity_BothClick(final Material mat, final Block block) {
return mat == Material.LEVER || mat == Material.STONE_BUTTON || mat == Material.WOOD_BUTTON || mat == Material.WOODEN_DOOR || mat == Material.TRAP_DOOR || mat == Material.FENCE_GATE return mat == Material.LEVER || mat == Material.STONE_BUTTON || mat == Material.WOOD_BUTTON || mat == Material.WOODEN_DOOR || mat == Material.TRAP_DOOR || mat == Material.FENCE_GATE
|| mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG || mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG || plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())
|| plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())
|| (plugin.isGt1_8() && (mat == Material.SPRUCE_DOOR || mat == Material.BIRCH_DOOR || mat == Material.JUNGLE_DOOR || mat == Material.ACACIA_DOOR || mat == Material.DARK_OAK_DOOR || (plugin.isGt1_8() && (mat == Material.SPRUCE_DOOR || mat == Material.BIRCH_DOOR || mat == Material.JUNGLE_DOOR || mat == Material.ACACIA_DOOR || mat == Material.DARK_OAK_DOOR
|| mat == Material.SPRUCE_FENCE_GATE || mat == Material.BIRCH_FENCE_GATE || mat == Material.JUNGLE_FENCE_GATE || mat == Material.ACACIA_FENCE_GATE || mat == Material.SPRUCE_FENCE_GATE || mat == Material.BIRCH_FENCE_GATE || mat == Material.JUNGLE_FENCE_GATE || mat == Material.ACACIA_FENCE_GATE
|| mat == Material.DARK_OAK_FENCE_GATE)); || mat == Material.DARK_OAK_FENCE_GATE));

View File

@@ -83,9 +83,8 @@ public class PermissionManager {
final String group = this.getPermissionsGroup(player, world); final String group = this.getPermissionsGroup(player, world);
if (group == null || !groups.containsKey(group)) { if (group == null || !groups.containsKey(group)) {
return plugin.getConfigManager().getDefaultGroup().toLowerCase(); return plugin.getConfigManager().getDefaultGroup().toLowerCase();
} else {
return group;
} }
return group;
} }
public String getPermissionsGroup(final Player player) { public String getPermissionsGroup(final Player player) {
@@ -121,9 +120,8 @@ public class PermissionManager {
perms = vault; perms = vault;
plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName()); plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName());
return; return;
} else {
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
} }
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
} }
} }

View File

@@ -8,6 +8,7 @@ package cn.citycraft.Residence.text;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
/** /**
@@ -21,42 +22,38 @@ public class Language {
text = new HashMap<String, String>(); text = new HashMap<String, String>();
} }
public void setText(String key, String intext) { public static Language parseText(final FileConfiguration node, final String topkey) {
text.put(key, intext); final Language newholder = new Language();
final Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
for (final String key : keys) {
newholder.text.put(key, node.getString(topkey + "." + key));
}
return newholder;
} }
private String getText(String key) { public String getPhrase(final String key) {
String t = text.get(key); final String[] split = key.split("\\.");
if (t == null) {
t = "<missing language key: " + key + ">";
}
return t;
}
public String getPhrase(String key) {
String[] split = key.split("\\.");
return getPhrase(split); return getPhrase(split);
} }
public String getPhrase(String[] keys) { public String getPhrase(final String key, final String words) {
return this.getPhrase(keys, (String[]) null);
}
public String getPhrase(String key, String words) {
return this.getPhrase(key.split("\\."), words); return this.getPhrase(key.split("\\."), words);
} }
public String getPhrase(String[] keys, String words) { public String getPhrase(final String[] keys) {
if (words == null) {
return this.getPhrase(keys, (String[]) null); return this.getPhrase(keys, (String[]) null);
} else {
return this.getPhrase(keys, words.split("\\."));
}
} }
public String getPhrase(String[] keys, String[] words) { public String getPhrase(final String[] keys, final String words) {
if (words == null) {
return this.getPhrase(keys, (String[]) null);
}
return this.getPhrase(keys, words.split("\\."));
}
public String getPhrase(final String[] keys, final String[] words) {
String sentence = ""; String sentence = "";
for (String key : keys) { for (final String key : keys) {
if (sentence.length() == 0) { if (sentence.length() == 0) {
sentence = this.getText(key); sentence = this.getText(key);
} else { } else {
@@ -71,12 +68,15 @@ public class Language {
return sentence; return sentence;
} }
public static Language parseText(FileConfiguration node, String topkey) { public void setText(final String key, final String intext) {
Language newholder = new Language(); text.put(key, intext);
Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
for (String key : keys) {
newholder.text.put(key, node.getString(topkey + "." + key));
} }
return newholder;
private String getText(final String key) {
String t = text.get(key);
if (t == null) {
t = "<missing language key: " + key + ">";
}
return t;
} }
} }

View File

@@ -5,16 +5,15 @@
package cn.citycraft.Residence.vaultinterface; package cn.citycraft.Residence.vaultinterface;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import cn.citycraft.Residence.economy.EconomyInterface; import cn.citycraft.Residence.economy.EconomyInterface;
import cn.citycraft.Residence.permissions.PermissionsInterface; import cn.citycraft.Residence.permissions.PermissionsInterface;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
/** /**
* *
@@ -26,7 +25,7 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
public static Economy economy = null; public static Economy economy = null;
public static Chat chat = null; public static Chat chat = null;
public ResidenceVaultAdapter(Server s) { public ResidenceVaultAdapter(final Server s) {
this.setupPermissions(s); this.setupPermissions(s);
this.setupEconomy(s); this.setupEconomy(s);
this.setupChat(s); this.setupChat(s);
@@ -34,13 +33,13 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public boolean add(String playerName, double amount) { public boolean add(final String playerName, final double amount) {
return economy.depositPlayer(playerName, amount).transactionSuccess(); return economy.depositPlayer(playerName, amount).transactionSuccess();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public boolean canAfford(String playerName, double amount) { public boolean canAfford(final String playerName, final double amount) {
return economy.has(playerName, amount); return economy.has(playerName, amount);
} }
@@ -54,7 +53,7 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public double getBalance(String playerName) { public double getBalance(final String playerName) {
return economy.getBalance(playerName); return economy.getBalance(playerName);
} }
@@ -82,21 +81,19 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
} }
@Override @Override
public String getPlayerGroup(Player player) { public String getPlayerGroup(final Player player) {
String group = permissions.getPrimaryGroup(player).toLowerCase(); final String group = permissions.getPrimaryGroup(player).toLowerCase();
if (group == null) if (group == null)
return group; return group;
else
return group.toLowerCase(); return group.toLowerCase();
} }
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public String getPlayerGroup(String player, String world) { public String getPlayerGroup(final String player, final String world) {
String group = permissions.getPrimaryGroup(world, player); final String group = permissions.getPrimaryGroup(world, player);
if (group == null) if (group == null)
return group; return group;
else
return group.toLowerCase(); return group.toLowerCase();
} }
@@ -106,51 +103,45 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
return false; return false;
} }
private boolean setupChat(Server s) { @SuppressWarnings("deprecation")
RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration( @Override
net.milkbowl.vault.chat.Chat.class); public boolean subtract(final String playerName, final double amount) {
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
}
@SuppressWarnings("deprecation")
@Override
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
return true;
economy.depositPlayer(playerFrom, amount);
}
return false;
}
private boolean setupChat(final Server s) {
final RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) { if (chatProvider != null) {
chat = chatProvider.getProvider(); chat = chatProvider.getProvider();
} }
return (chat != null); return (chat != null);
} }
private boolean setupEconomy(Server s) { private boolean setupEconomy(final Server s) {
RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager() final RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
.getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) { if (economyProvider != null) {
economy = economyProvider.getProvider(); economy = economyProvider.getProvider();
} }
return (economy != null); return (economy != null);
} }
private boolean setupPermissions(Server s) { private boolean setupPermissions(final Server s) {
RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager() final RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
.getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) { if (permissionProvider != null) {
permissions = permissionProvider.getProvider(); permissions = permissionProvider.getProvider();
} }
return (permissions != null); return (permissions != null);
} }
@SuppressWarnings("deprecation")
@Override
public boolean subtract(String playerName, double amount) {
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
}
@SuppressWarnings("deprecation")
@Override
public boolean transfer(String playerFrom, String playerTo, double amount) {
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
return true;
else {
economy.depositPlayer(playerFrom, amount);
return false;
}
} else
return false;
}
} }

View File

@@ -88,9 +88,8 @@ public class Residence {
final ClaimedResidence res = getResidenceManager().getByLoc(loc); final ClaimedResidence res = getResidenceManager().getByLoc(loc);
if (res != null) { if (res != null) {
return res.getPermissions(); return res.getPermissions();
} else {
return getWorldFlags().getPerms(loc.getWorld().getName());
} }
return getWorldFlags().getPerms(loc.getWorld().getName());
} }
public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) { public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {

View File

@@ -221,9 +221,8 @@ public class ClaimedResidence {
public boolean addSubzone(final Player player, final Location loc1, final Location loc2, final String name, final boolean resadmin) { public boolean addSubzone(final Player player, final Location loc1, final Location loc2, final String name, final boolean resadmin) {
if (player == null) { if (player == null) {
return this.addSubzone(null, "Server Land", loc1, loc2, name, resadmin); return this.addSubzone(null, "Server Land", loc1, loc2, name, resadmin);
} else {
return this.addSubzone(player, player.getName(), loc1, loc2, name, resadmin);
} }
return this.addSubzone(player, player.getName(), loc1, loc2, name, resadmin);
} }
public boolean addSubzone(final Player player, final String owner, final Location loc1, final Location loc2, final String name, final boolean resadmin) { public boolean addSubzone(final Player player, final String owner, final Location loc1, final Location loc2, final String name, final boolean resadmin) {
@@ -292,13 +291,12 @@ public class ClaimedResidence {
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SubzoneCreate", ChatColor.YELLOW + name)); player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SubzoneCreate", ChatColor.YELLOW + name));
} }
return true; return true;
} else { }
if (player != null) { if (player != null) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SubzoneCreateFail", ChatColor.YELLOW + name)); player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SubzoneCreateFail", ChatColor.YELLOW + name));
} }
return false; return false;
} }
}
public boolean addSubzone(final String name, final Location loc1, final Location loc2) { public boolean addSubzone(final String name, final Location loc1, final Location loc2) {
return this.addSubzone(null, loc1, loc2, name, true); return this.addSubzone(null, loc1, loc2, name, true);
@@ -428,14 +426,13 @@ public class ClaimedResidence {
} }
if (found) { if (found) {
return newLoc; return newLoc;
} else { }
final World world = Bukkit.getServer().getWorld(perms.getWorld()); final World world = Bukkit.getServer().getWorld(perms.getWorld());
if (world != null) { if (world != null) {
return world.getSpawnLocation(); return world.getSpawnLocation();
} }
return insideLoc; return insideLoc;
} }
}
public String getOwner() { public String getOwner() {
return perms.getOwner(); return perms.getOwner();
@@ -690,11 +687,10 @@ public class ClaimedResidence {
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("AreaRename", oldName + "." + newName)); player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("AreaRename", oldName + "." + newName));
} }
return true; return true;
} else { }
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission")); player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
return false; return false;
} }
}
public boolean renameArea(final String oldName, final String newName) { public boolean renameArea(final String oldName, final String newName) {
return this.renameArea(null, oldName, newName, true); return this.renameArea(null, oldName, newName, true);

View File

@@ -27,8 +27,14 @@ import cn.citycraft.Residence.ResidenceMain;
*/ */
public class FlagPermissions { public class FlagPermissions {
protected static ResidenceMain plugin; public static enum FlagState {
FALSE,
INVALID,
NEITHER,
TRUE
}
protected static ResidenceMain plugin;
protected static ArrayList<String> validAreaFlags = new ArrayList<String>(); protected static ArrayList<String> validAreaFlags = new ArrayList<String>();
protected static HashMap<String, ArrayList<String>> validFlagGroups = new HashMap<String, ArrayList<String>>(); protected static HashMap<String, ArrayList<String>> validFlagGroups = new HashMap<String, ArrayList<String>>();
protected static ArrayList<String> validFlags = new ArrayList<String>(); protected static ArrayList<String> validFlags = new ArrayList<String>();
@@ -37,6 +43,7 @@ public class FlagPermissions {
protected Map<String, Boolean> cuboidFlags; protected Map<String, Boolean> cuboidFlags;
protected Map<String, Map<String, Boolean>> groupFlags; protected Map<String, Map<String, Boolean>> groupFlags;
protected FlagPermissions parent; protected FlagPermissions parent;
protected Map<String, Map<String, Boolean>> playerFlags; protected Map<String, Map<String, Boolean>> playerFlags;
public FlagPermissions() { public FlagPermissions() {
@@ -457,9 +464,8 @@ public class FlagPermissions {
sbuild.append("none"); sbuild.append("none");
} }
return sbuild.toString(); return sbuild.toString();
} else {
return "none";
} }
return "none";
} }
public String listOtherPlayersFlags(String player) { public String listOtherPlayersFlags(String player) {
@@ -509,9 +515,8 @@ public class FlagPermissions {
sbuild.append("none"); sbuild.append("none");
} }
return sbuild.toString(); return sbuild.toString();
} else {
return "none";
} }
return "none";
} }
public boolean playerHas(final String player, final String world, final String flag, final boolean def) { public boolean playerHas(final String player, final String world, final String flag, final boolean def) {
@@ -627,11 +632,4 @@ public class FlagPermissions {
} }
return def; return def;
} }
public static enum FlagState {
FALSE,
INVALID,
NEITHER,
TRUE
}
} }

View File

@@ -25,8 +25,8 @@ import org.bukkit.plugin.PluginManager;
import com.bekvon.bukkit.residence.event.ResidenceCreationEvent; import com.bekvon.bukkit.residence.event.ResidenceCreationEvent;
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent; import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent;
import com.bekvon.bukkit.residence.event.ResidenceRenameEvent;
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent.DeleteCause; import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent.DeleteCause;
import com.bekvon.bukkit.residence.event.ResidenceRenameEvent;
import cn.citycraft.Residence.ResidenceMain; import cn.citycraft.Residence.ResidenceMain;
import cn.citycraft.Residence.permissions.PermissionGroup; import cn.citycraft.Residence.permissions.PermissionGroup;
@@ -545,11 +545,13 @@ public class ResidenceManager {
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Total.Size") + ":" + ChatColor.LIGHT_PURPLE + " " + res.getTotalSize()); player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Total.Size") + ":" + ChatColor.LIGHT_PURPLE + " " + res.getTotalSize());
if (aid != null) { if (aid != null) {
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsT") + ": " + ChatColor.LIGHT_PURPLE player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsT") + ": " + ChatColor.LIGHT_PURPLE
+ plugin.getLanguage().getPhrase("CoordsTop", res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockX() + "." + plugin.getLanguage().getPhrase("CoordsTop",
+ res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockZ())); res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockX() + "." + res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockY() + "."
+ res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockZ()));
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsB") + ": " + ChatColor.LIGHT_PURPLE player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsB") + ": " + ChatColor.LIGHT_PURPLE
+ plugin.getLanguage().getPhrase("CoordsBottom", res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX() + "." + plugin.getLanguage().getPhrase("CoordsBottom",
+ res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockZ())); res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockY() + "."
+ res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockZ()));
if (plugin.isUseWorldEdit()) { if (plugin.isUseWorldEdit()) {
WECUI.UPDATESELECT(res, player); WECUI.UPDATESELECT(res, player);
} }
@@ -683,18 +685,16 @@ public class ResidenceManager {
ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRename", ChatColor.YELLOW + oldName + ChatColor.GREEN + "." + ChatColor.YELLOW + newName + ChatColor.GREEN)); ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRename", ChatColor.YELLOW + oldName + ChatColor.GREEN + "." + ChatColor.YELLOW + newName + ChatColor.GREEN));
} }
return true; return true;
} else { }
final String[] oldname = oldName.split("\\."); final String[] oldname = oldName.split("\\.");
final ClaimedResidence parent = res.getParent(); final ClaimedResidence parent = res.getParent();
return parent.renameSubzone(player, oldname[oldname.length - 1], newName, resadmin); return parent.renameSubzone(player, oldname[oldname.length - 1], newName, resadmin);
} }
} else {
if (player != null) { if (player != null) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission")); player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
} }
return false; return false;
} }
}
public boolean renameResidence(final String oldName, final String newName) { public boolean renameResidence(final String oldName, final String newName) {
return this.renameResidence(null, oldName, newName, true); return this.renameResidence(null, oldName, newName, true);
@@ -719,8 +719,7 @@ public class ResidenceManager {
return worldmap; return worldmap;
} }
private void getResidenceList(final String targetplayer, final boolean showhidden, final boolean showsubzones, final String parentzone, final String resname, final ClaimedResidence res, private void getResidenceList(final String targetplayer, final boolean showhidden, final boolean showsubzones, final String parentzone, final String resname, final ClaimedResidence res, final ArrayList<String> list, final boolean formattedOutput) {
final ArrayList<String> list, final boolean formattedOutput) {
final boolean hidden = res.getPermissions().has("hidden", false); final boolean hidden = res.getPermissions().has("hidden", false);
if ((showhidden) || (!showhidden && !hidden)) { if ((showhidden) || (!showhidden && !hidden)) {
if (targetplayer == null || res.getPermissions().getOwner().equalsIgnoreCase(targetplayer)) { if (targetplayer == null || res.getPermissions().getOwner().equalsIgnoreCase(targetplayer)) {

View File

@@ -18,8 +18,8 @@ import org.bukkit.plugin.PluginManager;
import com.bekvon.bukkit.residence.event.ResidenceFlagChangeEvent; import com.bekvon.bukkit.residence.event.ResidenceFlagChangeEvent;
import com.bekvon.bukkit.residence.event.ResidenceFlagCheckEvent; import com.bekvon.bukkit.residence.event.ResidenceFlagCheckEvent;
import com.bekvon.bukkit.residence.event.ResidenceOwnerChangeEvent;
import com.bekvon.bukkit.residence.event.ResidenceFlagEvent.FlagType; import com.bekvon.bukkit.residence.event.ResidenceFlagEvent.FlagType;
import com.bekvon.bukkit.residence.event.ResidenceOwnerChangeEvent;
import cn.citycraft.Residence.ResidenceMain; import cn.citycraft.Residence.ResidenceMain;
import cn.citycraft.Residence.permissions.PermissionGroup; import cn.citycraft.Residence.permissions.PermissionGroup;
@@ -260,9 +260,8 @@ public class ResidencePermissions extends FlagPermissions {
final String renter = plugin.getRentManager().getRentingPlayer(resname); final String renter = plugin.getRentManager().getRentingPlayer(resname);
if (player.getName().equalsIgnoreCase(renter)) { if (player.getName().equalsIgnoreCase(renter)) {
return true; return true;
} else {
return (playerHas(player.getName(), "admin", false));
} }
return (playerHas(player.getName(), "admin", false));
} }
} }
if (requireOwner) { if (requireOwner) {

View File

@@ -45,9 +45,8 @@ public class WorldFlagManager {
if (list == null) { if (list == null) {
if (globaldefaults == null) { if (globaldefaults == null) {
return new FlagPermissions(); return new FlagPermissions();
} else {
return globaldefaults;
} }
return globaldefaults;
} }
return list; return list;
} }