1
0
mirror of https://e.coding.net/circlecloud/Residence.git synced 2024-10-31 22:38:48 +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);
if (res != null) {
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) {
@ -692,13 +691,12 @@ public class ResidenceMain extends JavaPlugin {
}
if (cmanager.getResidenceNameRegex() == null) {
return true;
} else {
final String namecheck = name.replaceAll(cmanager.getResidenceNameRegex(), "");
if (!name.equals(namecheck)) {
return false;
}
return true;
}
final String namecheck = name.replaceAll(cmanager.getResidenceNameRegex(), "");
if (!name.equals(namecheck)) {
return false;
}
return true;
}
private boolean checkNewLanguageVersion(final String lang) throws IOException, FileNotFoundException, InvalidConfigurationException {

View File

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

View File

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

View File

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

View File

@ -11,99 +11,95 @@ import com.earth2me.essentials.api.NoLoanPermittedException;
import com.earth2me.essentials.api.UserDoesNotExistException;
/**
*
*
* @author Administrator
*/
public class EssentialsEcoAdapter implements EconomyInterface {
Essentials plugin;
Essentials plugin;
public EssentialsEcoAdapter(Essentials p) {
plugin = p;
String serverland = "Server Land";
if (!Economy.playerExists(serverland)) {
Economy.createNPC(serverland);
}
}
public EssentialsEcoAdapter(final Essentials p) {
plugin = p;
final String serverland = "Server Land";
if (!Economy.playerExists(serverland)) {
Economy.createNPC(serverland);
}
}
@Override
public double getBalance(String playerName) {
try {
if (Economy.playerExists(playerName)) {
return Economy.getMoney(playerName);
} else {
return 0;
}
} catch (UserDoesNotExistException ex) {
return 0;
}
}
@Override
public boolean add(final String playerName, final double amount) {
if (Economy.playerExists(playerName)) {
try {
Economy.add(playerName, amount);
return true;
} catch (final UserDoesNotExistException ex) {
return false;
} catch (final NoLoanPermittedException ex) {
return false;
}
}
return false;
}
@Override
public boolean canAfford(String playerName, double amount) {
try {
if (Economy.playerExists(playerName)) {
return Economy.hasEnough(playerName, amount);
}
return false;
} catch (UserDoesNotExistException ex) {
return false;
}
}
@Override
public boolean canAfford(final String playerName, final double amount) {
try {
if (Economy.playerExists(playerName)) {
return Economy.hasEnough(playerName, amount);
}
return false;
} catch (final UserDoesNotExistException ex) {
return false;
}
}
@Override
public boolean add(String playerName, double amount) {
if (Economy.playerExists(playerName)) {
try {
Economy.add(playerName, amount);
return true;
} catch (UserDoesNotExistException ex) {
return false;
} catch (NoLoanPermittedException ex) {
return false;
}
} else {
return false;
}
}
@Override
public double getBalance(final String playerName) {
try {
if (Economy.playerExists(playerName)) {
return Economy.getMoney(playerName);
}
} catch (final UserDoesNotExistException ex) {
}
return 0;
}
@Override
public boolean subtract(String playerName, double amount) {
if (Economy.playerExists(playerName)) {
try {
Economy.subtract(playerName, amount);
return true;
} catch (UserDoesNotExistException ex) {
return false;
} catch (NoLoanPermittedException ex) {
return false;
}
} else {
return false;
}
}
@Override
public String getName() {
return "EssentialsEconomy";
}
@Override
public boolean transfer(String playerFrom, String playerTo, double amount) {
try {
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
if (!subtract(playerFrom, amount))
return false;
if (!add(playerTo, amount)) {
add(playerFrom, amount);
return false;
}
return true;
}
} catch (UserDoesNotExistException ex) {
return false;
}
return false;
}
@Override
public boolean subtract(final String playerName, final double amount) {
if (Economy.playerExists(playerName)) {
try {
Economy.subtract(playerName, amount);
return true;
} catch (final UserDoesNotExistException ex) {
return false;
} catch (final NoLoanPermittedException ex) {
return false;
}
}
return false;
}
@Override
public String getName() {
return "EssentialsEconomy";
}
@Override
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
try {
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
if (!subtract(playerFrom, amount))
return false;
if (!add(playerTo, amount)) {
add(playerFrom, amount);
return false;
}
return true;
}
} catch (final UserDoesNotExistException ex) {
return false;
}
return false;
}
}

View File

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

View File

@ -52,497 +52,494 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
@SuppressWarnings("deprecation")
public class ResidencePlayerListener implements Listener {
protected boolean chatenabled;
protected Map<String, String> currentRes;
protected Map<String, Location> lastOutsideLoc;
protected Map<String, Long> lastUpdate;
protected int minUpdateTime;
protected List<String> playerToggleChat;
ResidenceMain plugin;
protected boolean chatenabled;
protected Map<String, String> currentRes;
protected Map<String, Location> lastOutsideLoc;
protected Map<String, Long> lastUpdate;
protected int minUpdateTime;
protected List<String> playerToggleChat;
ResidenceMain plugin;
public ResidencePlayerListener(final ResidenceMain plugin) {
this.plugin = plugin;
currentRes = new HashMap<>();
lastUpdate = new HashMap<>();
lastOutsideLoc = new HashMap<>();
playerToggleChat = new ArrayList<>();
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
chatenabled = plugin.getConfigManager().chatEnabled();
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
lastUpdate.put(player.getName(), System.currentTimeMillis());
}
}
public ResidencePlayerListener(final ResidenceMain plugin) {
this.plugin = plugin;
currentRes = new HashMap<>();
lastUpdate = new HashMap<>();
lastOutsideLoc = new HashMap<>();
playerToggleChat = new ArrayList<>();
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
chatenabled = plugin.getConfigManager().chatEnabled();
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
lastUpdate.put(player.getName(), System.currentTimeMillis());
}
}
public String getCurrentResidenceName(final String player) {
return currentRes.get(player);
}
public String getCurrentResidenceName(final String player) {
return currentRes.get(player);
}
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
final String pname = player.getName();
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
final String pname = player.getName();
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
String areaname = null;
boolean chatchange = false;
String subzone = null;
if (res != null) {
areaname = plugin.getResidenceManager().getNameByLoc(loc);
while (res.getSubzoneByLoc(player.getLocation()) != null) {
subzone = res.getSubzoneNameByLoc(player.getLocation());
res = res.getSubzoneByLoc(player.getLocation());
areaname = areaname + "." + subzone;
}
}
ClaimedResidence ResOld = null;
if (currentRes.containsKey(pname)) {
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
if (ResOld == null) {
currentRes.remove(pname);
}
}
if (res == null) {
lastOutsideLoc.put(pname, loc);
if (ResOld != null) {
final String leave = ResOld.getLeaveMessage();
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
plugin.getServer().getPluginManager().callEvent(chgEvent);
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
String areaname = null;
boolean chatchange = false;
String subzone = null;
if (res != null) {
areaname = plugin.getResidenceManager().getNameByLoc(loc);
while (res.getSubzoneByLoc(player.getLocation()) != null) {
subzone = res.getSubzoneNameByLoc(player.getLocation());
res = res.getSubzoneByLoc(player.getLocation());
areaname = areaname + "." + subzone;
}
}
ClaimedResidence ResOld = null;
if (currentRes.containsKey(pname)) {
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
if (ResOld == null) {
currentRes.remove(pname);
}
}
if (res == null) {
lastOutsideLoc.put(pname, loc);
if (ResOld != null) {
final String leave = ResOld.getLeaveMessage();
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
plugin.getServer().getPluginManager().callEvent(chgEvent);
if (leave != null && !leave.equals("")) {
if (plugin.getConfigManager().useActionBar()) {
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
} else {
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
}
}
currentRes.remove(pname);
plugin.getChatManager().removeFromChannel(pname);
}
return;
}
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
final Location lastLoc = lastOutsideLoc.get(pname);
if (lastLoc != null) {
player.teleport(lastLoc);
} else {
player.teleport(res.getOutsideFreeLoc(loc));
}
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
return;
}
lastOutsideLoc.put(pname, loc);
if (!currentRes.containsKey(pname) || ResOld != res) {
currentRes.put(pname, areaname);
if (subzone == null) {
chatchange = true;
}
ClaimedResidence chgFrom = null;
if (ResOld != res && ResOld != null) {
final String leave = ResOld.getLeaveMessage();
chgFrom = ResOld;
if (leave != null && !leave.equals("")) {
if (plugin.getConfigManager().useActionBar()) {
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
} else {
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
}
}
currentRes.remove(pname);
plugin.getChatManager().removeFromChannel(pname);
}
return;
}
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
final Location lastLoc = lastOutsideLoc.get(pname);
if (lastLoc != null) {
player.teleport(lastLoc);
} else {
player.teleport(res.getOutsideFreeLoc(loc));
}
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
return;
}
lastOutsideLoc.put(pname, loc);
if (!currentRes.containsKey(pname) || ResOld != res) {
currentRes.put(pname, areaname);
if (subzone == null) {
chatchange = true;
}
ClaimedResidence chgFrom = null;
if (ResOld != res && ResOld != null) {
final String leave = ResOld.getLeaveMessage();
chgFrom = ResOld;
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
if (plugin.getConfigManager().useActionBar()) {
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
} else {
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
}
}
}
final String enterMessage = res.getEnterMessage();
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
plugin.getServer().getPluginManager().callEvent(chgEvent);
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
if (plugin.getConfigManager().useActionBar()) {
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
} else {
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
}
}
}
final String enterMessage = res.getEnterMessage();
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
plugin.getServer().getPluginManager().callEvent(chgEvent);
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
if (plugin.getConfigManager().useActionBar()) {
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
} else {
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
}
}
}
if (chatchange && chatenabled) {
plugin.getChatManager().setChannel(pname, areaname);
}
}
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
if (plugin.getConfigManager().useActionBar()) {
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
} else {
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
}
}
}
if (chatchange && chatenabled) {
plugin.getChatManager().setChannel(pname, areaname);
}
}
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
try {
message = message.replaceAll("%player", player.getName());
message = message.replaceAll("%owner", res.getPermissions().getOwner());
message = message.replaceAll("%residence", areaname);
message = ChatColor.translateAlternateColorCodes('&', message);
} catch (final Exception ex) {
return "";
}
return message;
}
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
try {
message = message.replaceAll("%player", player.getName());
message = message.replaceAll("%owner", res.getPermissions().getOwner());
message = message.replaceAll("%residence", areaname);
message = ChatColor.translateAlternateColorCodes('&', message);
} catch (final Exception ex) {
return "";
}
return message;
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
final Player player = event.getPlayer();
if (plugin.isResAdminOn(player)) {
return;
}
final String pname = player.getName();
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
if (res != null) {
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
if (plugin.getRentManager().isRented(res.getName())) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
event.setCancelled(true);
return;
}
}
}
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
if (!perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true))) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
final Player player = event.getPlayer();
if (plugin.isResAdminOn(player)) {
return;
}
final String pname = player.getName();
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
if (res != null) {
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
if (plugin.getRentManager().isRented(res.getName())) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
event.setCancelled(true);
return;
}
}
}
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
if (!perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true))) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
final Player player = event.getPlayer();
final String pname = player.getName();
if (plugin.isResAdminOn(player)) {
return;
}
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
if (res != null) {
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
if (plugin.getRentManager().isRented(res.getName())) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
event.setCancelled(true);
return;
}
}
}
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
final boolean hasbucket = perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true));
if (!hasbucket) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
final Player player = event.getPlayer();
final String pname = player.getName();
if (plugin.isResAdminOn(player)) {
return;
}
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
if (res != null) {
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
if (plugin.getRentManager().isRented(res.getName())) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
event.setCancelled(true);
return;
}
}
}
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
final boolean hasbucket = perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true));
if (!hasbucket) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(final AsyncPlayerChatEvent event) {
final String pname = event.getPlayer().getName();
if (chatenabled && playerToggleChat.contains(pname)) {
final String area = currentRes.get(pname);
if (area != null) {
final ChatChannel channel = plugin.getChatManager().getChannel(area);
if (channel != null) {
channel.chat(pname, event.getMessage());
}
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(final AsyncPlayerChatEvent event) {
final String pname = event.getPlayer().getName();
if (chatenabled && playerToggleChat.contains(pname)) {
final String area = currentRes.get(pname);
if (area != null) {
final ChatChannel channel = plugin.getChatManager().getChannel(area);
if (channel != null) {
channel.chat(pname, event.getMessage());
}
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
final Material heldItem = player.getItemInHand().getType();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
final Material mat = block.getType();
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|| event.getAction() == Action.PHYSICAL)) {
final int typeId = player.getItemInHand().getTypeId();
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
return;
}
}
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
final String world = player.getWorld().getName();
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
final boolean resadmin = plugin.isResAdminOn(player);
if (event.getAction() == Action.PHYSICAL) {
if (!resadmin) {
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
event.setCancelled(true);
return;
}
}
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
event.setCancelled(true);
return;
}
return;
}
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
event.setCancelled(true);
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
if (wep != null) {
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
return;
}
}
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
final Location loc = block.getLocation();
plugin.getSelectionManager().placeLoc1(player, loc);
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
event.setCancelled(true);
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
final Location loc = block.getLocation();
plugin.getSelectionManager().placeLoc2(player, loc);
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
}
}
}
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
final Location loc = block.getLocation();
final String res = plugin.getResidenceManager().getNameByLoc(loc);
if (res != null) {
plugin.getResidenceManager().printAreaInfo(res, player);
event.setCancelled(true);
} else {
event.setCancelled(true);
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
}
}
}
if (!resadmin) {
if (heldItem != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (player.getItemInHand().getTypeId() == 351) {
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17
&& (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
if (!perms.playerHas(player.getName(), world, "build", true)) {
event.setCancelled(true);
return;
}
}
}
if (plugin.isGt1_8()) {
if (heldItem == Material.ARMOR_STAND) {
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
if (!perms.playerHas(player.getName(), world, "build", true)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
event.setCancelled(true);
return;
}
}
}
}
}
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
if (mat == checkMat.getKey()) {
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
if (hasuse || checkMat.getValue().equals("container")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
return;
} else {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
return;
}
}
}
}
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
return;
}
}
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
if (!hasuse) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
return;
}
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
if (!hasuse) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
final Material heldItem = player.getItemInHand().getType();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
final Material mat = block.getType();
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|| event.getAction() == Action.PHYSICAL)) {
final int typeId = player.getItemInHand().getTypeId();
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
return;
}
}
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
final String world = player.getWorld().getName();
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
final boolean resadmin = plugin.isResAdminOn(player);
if (event.getAction() == Action.PHYSICAL) {
if (!resadmin) {
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
event.setCancelled(true);
return;
}
}
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
event.setCancelled(true);
return;
}
return;
}
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
event.setCancelled(true);
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
if (wep != null) {
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
return;
}
}
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
final Location loc = block.getLocation();
plugin.getSelectionManager().placeLoc1(player, loc);
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
event.setCancelled(true);
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
final Location loc = block.getLocation();
plugin.getSelectionManager().placeLoc2(player, loc);
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
}
}
}
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
final Location loc = block.getLocation();
final String res = plugin.getResidenceManager().getNameByLoc(loc);
if (res != null) {
plugin.getResidenceManager().printAreaInfo(res, player);
event.setCancelled(true);
} else {
event.setCancelled(true);
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
}
}
}
if (!resadmin) {
if (heldItem != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (player.getItemInHand().getTypeId() == 351) {
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17
&& (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
if (!perms.playerHas(player.getName(), world, "build", true)) {
event.setCancelled(true);
return;
}
}
}
if (plugin.isGt1_8()) {
if (heldItem == Material.ARMOR_STAND) {
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
if (!perms.playerHas(player.getName(), world, "build", true)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
event.setCancelled(true);
return;
}
}
}
}
}
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
if (mat == checkMat.getKey()) {
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
if (hasuse || checkMat.getValue().equals("container")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
} else {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
}
}
}
}
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
return;
}
}
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
if (!hasuse) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
return;
}
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
if (!hasuse) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
final Player player = event.getPlayer();
if (plugin.isResAdminOn(player)) {
return;
}
final Entity ent = event.getRightClicked();
/* Trade */
if (ent.getType() == EntityType.VILLAGER) {
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
final Player player = event.getPlayer();
if (plugin.isResAdminOn(player)) {
return;
}
final Entity ent = event.getRightClicked();
/* Trade */
if (ent.getType() == EntityType.VILLAGER) {
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
event.setCancelled(true);
}
}
/* Container - ItemFrame protection */
final Material heldItem = player.getItemInHand().getType();
if (!(ent instanceof Hanging)) {
return;
}
final Hanging hanging = (Hanging) ent;
if (hanging.getType() != EntityType.ITEM_FRAME) {
return;
}
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
final String world = player.getWorld().getName();
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
event.setCancelled(true);
return;
}
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
}
}
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
event.setCancelled(true);
}
}
/* Container - ItemFrame protection */
final Material heldItem = player.getItemInHand().getType();
if (!(ent instanceof Hanging)) {
return;
}
final Hanging hanging = (Hanging) ent;
if (hanging.getType() != EntityType.ITEM_FRAME) {
return;
}
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
final String world = player.getWorld().getName();
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
event.setCancelled(true);
return;
}
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
lastUpdate.put(player.getName(), 0L);
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
plugin.turnResAdminOn(player);
}
handleNewLocation(player, player.getLocation(), false);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
lastUpdate.put(player.getName(), 0L);
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
plugin.turnResAdminOn(player);
}
handleNewLocation(player, player.getLocation(), false);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) {
final Player player = event.getPlayer();
if (player == null) {
return;
}
final long now = System.currentTimeMillis();
if (!lastUpdate.containsKey(player.getName())) {
lastUpdate.put(player.getName(), now);
return;
}
final long last = lastUpdate.get(player.getName());
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
return;
}
lastUpdate.put(player.getName(), now);
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
if (event.getFrom().distance(event.getTo()) == 0) {
return;
}
}
handleNewLocation(player, event.getTo(), true);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) {
final Player player = event.getPlayer();
if (player == null) {
return;
}
final long now = System.currentTimeMillis();
if (!lastUpdate.containsKey(player.getName())) {
lastUpdate.put(player.getName(), now);
return;
}
final long last = lastUpdate.get(player.getName());
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
return;
}
lastUpdate.put(player.getName(), now);
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
if (event.getFrom().distance(event.getTo()) == 0) {
return;
}
}
handleNewLocation(player, event.getTo(), true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event) {
final String pname = event.getPlayer().getName();
currentRes.remove(pname);
lastUpdate.remove(pname);
lastOutsideLoc.remove(pname);
plugin.getChatManager().removeFromChannel(pname);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event) {
final String pname = event.getPlayer().getName();
currentRes.remove(pname);
lastUpdate.remove(pname);
lastOutsideLoc.remove(pname);
plugin.getChatManager().removeFromChannel(pname);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerSpawn(final PlayerRespawnEvent event) {
Location loc = event.getRespawnLocation();
final Boolean bed = event.isBedSpawn();
final Player player = event.getPlayer();
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
if (res == null) {
return;
}
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
return;
}
if (bed) {
loc = player.getWorld().getSpawnLocation();
}
res = plugin.getResidenceManager().getByLoc(loc);
if (res != null) {
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
loc = res.getOutsideFreeLoc(loc);
}
}
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
event.setRespawnLocation(loc);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerSpawn(final PlayerRespawnEvent event) {
Location loc = event.getRespawnLocation();
final Boolean bed = event.isBedSpawn();
final Player player = event.getPlayer();
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
if (res == null) {
return;
}
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
return;
}
if (bed) {
loc = player.getWorld().getSpawnLocation();
}
res = plugin.getResidenceManager().getByLoc(loc);
if (res != null) {
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
loc = res.getOutsideFreeLoc(loc);
}
}
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
event.setRespawnLocation(loc);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
final Location loc = event.getTo();
final Player player = event.getPlayer();
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
if (res != null) {
if (plugin.isResAdminOn(player) || ((res.getPermissions().playerHas(player.getName(), "tp", true) || player.hasPermission("residence.admin.tp"))
&& (res.getPermissions().playerHas(player.getName(), "move", true) || player.hasPermission("residence.admin.move")))) {
handleNewLocation(player, loc, false);
} else {
final String areaname = res.getName();
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
final Location loc = event.getTo();
final Player player = event.getPlayer();
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
if (res != null) {
if (plugin.isResAdminOn(player) || ((res.getPermissions().playerHas(player.getName(), "tp", true) || player.hasPermission("residence.admin.tp"))
&& (res.getPermissions().playerHas(player.getName(), "move", true) || player.hasPermission("residence.admin.move")))) {
handleNewLocation(player, loc, false);
} else {
final String areaname = res.getName();
event.setCancelled(true);
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
}
}
}
public void tooglePlayerResidenceChat(final Player player) {
final String pname = player.getName();
if (playerToggleChat.contains(pname)) {
playerToggleChat.remove(pname);
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
} else {
playerToggleChat.add(pname);
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
}
}
public void tooglePlayerResidenceChat(final Player player) {
final String pname = player.getName();
if (playerToggleChat.contains(pname)) {
playerToggleChat.remove(pname);
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
} else {
playerToggleChat.add(pname);
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
}
}
private boolean isCanUseEntity(final Material mat, final Block block) {
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, block);
}
private boolean isCanUseEntity(final Material mat, final Block block) {
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, 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
|| mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG
|| 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
|| 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));
}
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
|| mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG || 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
|| 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));
}
private boolean isCanUseEntity_RClickOnly(final Material mat, final Block block) {
return mat == Material.ITEM_FRAME || mat == Material.BEACON || mat == Material.FLOWER_POT || mat == Material.COMMAND || mat == Material.ANVIL || mat == Material.CAKE_BLOCK
|| mat == Material.NOTE_BLOCK || mat == Material.DIODE || mat == Material.DIODE_BLOCK_OFF || mat == Material.DIODE_BLOCK_ON || mat == Material.BED_BLOCK || mat == Material.WORKBENCH
|| mat == Material.BREWING_STAND || mat == Material.ENCHANTMENT_TABLE || plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId());
}
private boolean isCanUseEntity_RClickOnly(final Material mat, final Block block) {
return mat == Material.ITEM_FRAME || mat == Material.BEACON || mat == Material.FLOWER_POT || mat == Material.COMMAND || mat == Material.ANVIL || mat == Material.CAKE_BLOCK
|| mat == Material.NOTE_BLOCK || mat == Material.DIODE || mat == Material.DIODE_BLOCK_OFF || mat == Material.DIODE_BLOCK_ON || mat == Material.BED_BLOCK || mat == Material.WORKBENCH
|| mat == Material.BREWING_STAND || mat == Material.ENCHANTMENT_TABLE || plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId());
}
private boolean isContainer(final Material mat, final Block block) {
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
}
private boolean isContainer(final Material mat, final Block block) {
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
}
}

View File

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

View File

@ -8,75 +8,75 @@ package cn.citycraft.Residence.text;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration;
/**
*
*
* @author Administrator
*/
public class Language {
public Map<String, String> text;
public Map<String, String> text;
public Language() {
text = new HashMap<String, String>();
}
public Language() {
text = new HashMap<String, String>();
}
public void setText(String key, String intext) {
text.put(key, intext);
}
public static Language parseText(final FileConfiguration node, final String topkey) {
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) {
String t = text.get(key);
if (t == null) {
t = "<missing language key: " + key + ">";
}
return t;
}
public String getPhrase(final String key) {
final String[] split = key.split("\\.");
return getPhrase(split);
}
public String getPhrase(String key) {
String[] split = key.split("\\.");
return getPhrase(split);
}
public String getPhrase(final String key, final String words) {
return this.getPhrase(key.split("\\."), words);
}
public String getPhrase(String[] keys) {
return this.getPhrase(keys, (String[]) null);
}
public String getPhrase(final String[] keys) {
return this.getPhrase(keys, (String[]) null);
}
public String getPhrase(String key, String words) {
return this.getPhrase(key.split("\\."), 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(String[] keys, String words) {
if (words == null) {
return this.getPhrase(keys, (String[]) null);
} else {
return this.getPhrase(keys, words.split("\\."));
}
}
public String getPhrase(final String[] keys, final String[] words) {
String sentence = "";
for (final String key : keys) {
if (sentence.length() == 0) {
sentence = this.getText(key);
} else {
sentence = sentence + " " + this.getText(key).toLowerCase();
}
}
if (words != null) {
for (int i = 0; i < words.length; i++) {
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
}
}
return sentence;
}
public String getPhrase(String[] keys, String[] words) {
String sentence = "";
for (String key : keys) {
if (sentence.length() == 0) {
sentence = this.getText(key);
} else {
sentence = sentence + " " + this.getText(key).toLowerCase();
}
}
if (words != null) {
for (int i = 0; i < words.length; i++) {
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
}
}
return sentence;
}
public void setText(final String key, final String intext) {
text.put(key, intext);
}
public static Language parseText(FileConfiguration node, String topkey) {
Language newholder = new Language();
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;
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.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import cn.citycraft.Residence.economy.EconomyInterface;
import cn.citycraft.Residence.permissions.PermissionsInterface;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
/**
*
@ -22,11 +21,11 @@ import cn.citycraft.Residence.permissions.PermissionsInterface;
*/
public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInterface {
public static Permission permissions = null;
public static Economy economy = null;
public static Chat chat = null;
public static Permission permissions = null;
public static Economy economy = null;
public static Chat chat = null;
public ResidenceVaultAdapter(Server s) {
public ResidenceVaultAdapter(final Server s) {
this.setupPermissions(s);
this.setupEconomy(s);
this.setupChat(s);
@ -34,13 +33,13 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
@SuppressWarnings("deprecation")
@Override
public boolean add(String playerName, double amount) {
public boolean add(final String playerName, final double amount) {
return economy.depositPlayer(playerName, amount).transactionSuccess();
}
@SuppressWarnings("deprecation")
@Override
public boolean canAfford(String playerName, double amount) {
public boolean canAfford(final String playerName, final double amount) {
return economy.has(playerName, amount);
}
@ -54,7 +53,7 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
@SuppressWarnings("deprecation")
@Override
public double getBalance(String playerName) {
public double getBalance(final String playerName) {
return economy.getBalance(playerName);
}
@ -82,22 +81,20 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
}
@Override
public String getPlayerGroup(Player player) {
String group = permissions.getPrimaryGroup(player).toLowerCase();
public String getPlayerGroup(final Player player) {
final String group = permissions.getPrimaryGroup(player).toLowerCase();
if (group == null)
return group;
else
return group.toLowerCase();
return group.toLowerCase();
}
@Override
@SuppressWarnings("deprecation")
public String getPlayerGroup(String player, String world) {
String group = permissions.getPrimaryGroup(world, player);
public String getPlayerGroup(final String player, final String world) {
final String group = permissions.getPrimaryGroup(world, player);
if (group == null)
return group;
else
return group.toLowerCase();
return group.toLowerCase();
}
public boolean permissionsOK() {
@ -106,51 +103,45 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
return false;
}
private boolean setupChat(Server s) {
RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(
net.milkbowl.vault.chat.Chat.class);
@SuppressWarnings("deprecation")
@Override
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) {
chat = chatProvider.getProvider();
}
return (chat != null);
}
private boolean setupEconomy(Server s) {
RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager()
.getRegistration(net.milkbowl.vault.economy.Economy.class);
private boolean setupEconomy(final Server s) {
final RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
return (economy != null);
}
private boolean setupPermissions(Server s) {
RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager()
.getRegistration(net.milkbowl.vault.permission.Permission.class);
private boolean setupPermissions(final Server s) {
final RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permissions = permissionProvider.getProvider();
}
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);
if (res != null) {
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) {

View File

@ -27,8 +27,14 @@ import cn.citycraft.Residence.ResidenceMain;
*/
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 HashMap<String, ArrayList<String>> validFlagGroups = new HashMap<String, 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, Map<String, Boolean>> groupFlags;
protected FlagPermissions parent;
protected Map<String, Map<String, Boolean>> playerFlags;
public FlagPermissions() {
@ -457,9 +464,8 @@ public class FlagPermissions {
sbuild.append("none");
}
return sbuild.toString();
} else {
return "none";
}
return "none";
}
public String listOtherPlayersFlags(String player) {
@ -509,9 +515,8 @@ public class FlagPermissions {
sbuild.append("none");
}
return sbuild.toString();
} else {
return "none";
}
return "none";
}
public boolean playerHas(final String player, final String world, final String flag, final boolean def) {
@ -627,11 +632,4 @@ public class FlagPermissions {
}
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.ResidenceDeleteEvent;
import com.bekvon.bukkit.residence.event.ResidenceRenameEvent;
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent.DeleteCause;
import com.bekvon.bukkit.residence.event.ResidenceRenameEvent;
import cn.citycraft.Residence.ResidenceMain;
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());
if (aid != null) {
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsT") + ": " + ChatColor.LIGHT_PURPLE
+ plugin.getLanguage().getPhrase("CoordsTop", res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockX() + "."
+ res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockZ()));
+ plugin.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 + plugin.getLanguage().getPhrase("CoordsB") + ": " + ChatColor.LIGHT_PURPLE
+ plugin.getLanguage().getPhrase("CoordsBottom", res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX() + "."
+ res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockZ()));
+ plugin.getLanguage().getPhrase("CoordsBottom",
res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockY() + "."
+ res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockZ()));
if (plugin.isUseWorldEdit()) {
WECUI.UPDATESELECT(res, player);
}
@ -683,17 +685,15 @@ public class ResidenceManager {
ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRename", ChatColor.YELLOW + oldName + ChatColor.GREEN + "." + ChatColor.YELLOW + newName + ChatColor.GREEN));
}
return true;
} else {
final String[] oldname = oldName.split("\\.");
final ClaimedResidence parent = res.getParent();
return parent.renameSubzone(player, oldname[oldname.length - 1], newName, resadmin);
}
} else {
if (player != null) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
}
return false;
final String[] oldname = oldName.split("\\.");
final ClaimedResidence parent = res.getParent();
return parent.renameSubzone(player, oldname[oldname.length - 1], newName, resadmin);
}
if (player != null) {
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
}
return false;
}
public boolean renameResidence(final String oldName, final String newName) {
@ -719,8 +719,7 @@ public class ResidenceManager {
return worldmap;
}
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) {
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 boolean hidden = res.getPermissions().has("hidden", false);
if ((showhidden) || (!showhidden && !hidden)) {
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.ResidenceFlagCheckEvent;
import com.bekvon.bukkit.residence.event.ResidenceOwnerChangeEvent;
import com.bekvon.bukkit.residence.event.ResidenceFlagEvent.FlagType;
import com.bekvon.bukkit.residence.event.ResidenceOwnerChangeEvent;
import cn.citycraft.Residence.ResidenceMain;
import cn.citycraft.Residence.permissions.PermissionGroup;
@ -260,9 +260,8 @@ public class ResidencePermissions extends FlagPermissions {
final String renter = plugin.getRentManager().getRentingPlayer(resname);
if (player.getName().equalsIgnoreCase(renter)) {
return true;
} else {
return (playerHas(player.getName(), "admin", false));
}
return (playerHas(player.getName(), "admin", false));
}
}
if (requireOwner) {

View File

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