|
|
|
|
@@ -51,24 +51,30 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
public static ResidencePermissions load(final ResidenceMain plugin, final ClaimedResidence res, final Map<String, Object> root) throws Exception {
|
|
|
|
|
final ResidencePermissions newperms = new ResidencePermissions(plugin, res);
|
|
|
|
|
newperms.owner = (String) root.get("Owner");
|
|
|
|
|
if (newperms.owner == null)
|
|
|
|
|
if (newperms.owner == null) {
|
|
|
|
|
newperms.owner = (String) root.get("OwnerLastKnownName");
|
|
|
|
|
}
|
|
|
|
|
if (newperms.owner == null) {
|
|
|
|
|
plugin.getLogger().warning("发现未知所有者的领地,转换为Server Land...");
|
|
|
|
|
newperms.owner = "Server Land";
|
|
|
|
|
}
|
|
|
|
|
newperms.world = (String) root.get("World");
|
|
|
|
|
FlagPermissions.load(root, newperms);
|
|
|
|
|
if (newperms.owner == null)
|
|
|
|
|
throw new Exception("错误的Owner数据...");
|
|
|
|
|
if (newperms.world == null)
|
|
|
|
|
throw new Exception("错误的World数据...");
|
|
|
|
|
if (newperms.playerFlags == null)
|
|
|
|
|
throw new Exception("错误的PlayerFlags数据...");
|
|
|
|
|
if (newperms.groupFlags == null)
|
|
|
|
|
throw new Exception("错误的GroupFlags数据...");
|
|
|
|
|
if (newperms.cuboidFlags == null)
|
|
|
|
|
throw new Exception("错误的CuboidFlags数据...");
|
|
|
|
|
if (newperms.owner == null) {
|
|
|
|
|
throw new IllegalArgumentException("错误的Owner数据...");
|
|
|
|
|
}
|
|
|
|
|
if (newperms.world == null) {
|
|
|
|
|
throw new IllegalArgumentException("错误的World数据...");
|
|
|
|
|
}
|
|
|
|
|
if (newperms.playerFlags == null) {
|
|
|
|
|
throw new IllegalArgumentException("错误的PlayerFlags数据...");
|
|
|
|
|
}
|
|
|
|
|
if (newperms.groupFlags == null) {
|
|
|
|
|
throw new IllegalArgumentException("错误的GroupFlags数据...");
|
|
|
|
|
}
|
|
|
|
|
if (newperms.cuboidFlags == null) {
|
|
|
|
|
throw new IllegalArgumentException("错误的CuboidFlags数据...");
|
|
|
|
|
}
|
|
|
|
|
newperms.fixNames();
|
|
|
|
|
return newperms;
|
|
|
|
|
}
|
|
|
|
|
@@ -80,25 +86,33 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
final Set<Entry<String, Boolean>> dcflags = group.getDefaultCreatorFlags();
|
|
|
|
|
final Set<Entry<String, Map<String, Boolean>>> dgflags = group.getDefaultGroupFlags();
|
|
|
|
|
this.applyGlobalDefaults();
|
|
|
|
|
for (final Entry<String, Boolean> next : dflags)
|
|
|
|
|
if (this.checkValidFlag(next.getKey(), true))
|
|
|
|
|
if (next.getValue())
|
|
|
|
|
for (final Entry<String, Boolean> next : dflags) {
|
|
|
|
|
if (this.checkValidFlag(next.getKey(), true)) {
|
|
|
|
|
if (next.getValue()) {
|
|
|
|
|
this.setFlag(next.getKey(), FlagState.TRUE);
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
this.setFlag(next.getKey(), FlagState.FALSE);
|
|
|
|
|
for (final Entry<String, Boolean> next : dcflags)
|
|
|
|
|
if (this.checkValidFlag(next.getKey(), false))
|
|
|
|
|
if (next.getValue())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (final Entry<String, Boolean> next : dcflags) {
|
|
|
|
|
if (this.checkValidFlag(next.getKey(), false)) {
|
|
|
|
|
if (next.getValue()) {
|
|
|
|
|
this.setPlayerFlag(owner, next.getKey(), FlagState.TRUE);
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
this.setPlayerFlag(owner, next.getKey(), FlagState.FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (final Entry<String, Map<String, Boolean>> entry : dgflags) {
|
|
|
|
|
final Map<String, Boolean> value = entry.getValue();
|
|
|
|
|
for (final Entry<String, Boolean> flag : value.entrySet())
|
|
|
|
|
if (flag.getValue())
|
|
|
|
|
for (final Entry<String, Boolean> flag : value.entrySet()) {
|
|
|
|
|
if (flag.getValue()) {
|
|
|
|
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.TRUE);
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -106,8 +120,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
if (this.hasResidencePermission(player, true) || resadmin) {
|
|
|
|
|
this.applyDefaultFlags();
|
|
|
|
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("FlagsDefault"));
|
|
|
|
|
} else
|
|
|
|
|
} else {
|
|
|
|
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("NoPermission"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void applyGlobalDefaults() {
|
|
|
|
|
@@ -115,22 +130,29 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
final FlagPermissions gRD = plugin.getConfigManager().getGlobalResidenceDefaultFlags();
|
|
|
|
|
final FlagPermissions gCD = plugin.getConfigManager().getGlobalCreatorDefaultFlags();
|
|
|
|
|
final Map<String, FlagPermissions> gGD = plugin.getConfigManager().getGlobalGroupDefaultFlags();
|
|
|
|
|
for (final Entry<String, Boolean> entry : gRD.cuboidFlags.entrySet())
|
|
|
|
|
if (entry.getValue())
|
|
|
|
|
for (final Entry<String, Boolean> entry : gRD.cuboidFlags.entrySet()) {
|
|
|
|
|
if (entry.getValue()) {
|
|
|
|
|
this.setFlag(entry.getKey(), FlagState.TRUE);
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
this.setFlag(entry.getKey(), FlagState.FALSE);
|
|
|
|
|
for (final Entry<String, Boolean> entry : gCD.cuboidFlags.entrySet())
|
|
|
|
|
if (entry.getValue())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (final Entry<String, Boolean> entry : gCD.cuboidFlags.entrySet()) {
|
|
|
|
|
if (entry.getValue()) {
|
|
|
|
|
this.setPlayerFlag(owner, entry.getKey(), FlagState.TRUE);
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
this.setPlayerFlag(owner, entry.getKey(), FlagState.FALSE);
|
|
|
|
|
for (final Entry<String, FlagPermissions> entry : gGD.entrySet())
|
|
|
|
|
for (final Entry<String, Boolean> flag : entry.getValue().cuboidFlags.entrySet())
|
|
|
|
|
if (flag.getValue())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (final Entry<String, FlagPermissions> entry : gGD.entrySet()) {
|
|
|
|
|
for (final Entry<String, Boolean> flag : entry.getValue().cuboidFlags.entrySet()) {
|
|
|
|
|
if (flag.getValue()) {
|
|
|
|
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.TRUE);
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void applyTemplate(final Player player, final FlagPermissions list, boolean resadmin) {
|
|
|
|
|
@@ -139,32 +161,44 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
} else {
|
|
|
|
|
resadmin = true;
|
|
|
|
|
}
|
|
|
|
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(owner, world);
|
|
|
|
|
for (final Entry<String, Boolean> flag : list.cuboidFlags.entrySet())
|
|
|
|
|
if (group.hasFlagAccess(flag.getKey()) || resadmin)
|
|
|
|
|
for (final Entry<String, Boolean> flag : list.cuboidFlags.entrySet()) {
|
|
|
|
|
if (group.hasFlagAccess(flag.getKey()) || resadmin) {
|
|
|
|
|
this.cuboidFlags.put(flag.getKey(), flag.getValue());
|
|
|
|
|
else if (player != null)
|
|
|
|
|
} else if (player != null) {
|
|
|
|
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
|
|
|
|
|
for (final Entry<String, Map<String, Boolean>> plists : list.playerFlags.entrySet())
|
|
|
|
|
for (final Entry<String, Boolean> flag : plists.getValue().entrySet())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (final Entry<String, Map<String, Boolean>> plists : list.playerFlags.entrySet()) {
|
|
|
|
|
for (final Entry<String, Boolean> flag : plists.getValue().entrySet()) {
|
|
|
|
|
if (group.hasFlagAccess(flag.getKey()) || resadmin) {
|
|
|
|
|
if (!this.playerFlags.containsKey(plists.getKey()))
|
|
|
|
|
if (!this.playerFlags.containsKey(plists.getKey())) {
|
|
|
|
|
this.playerFlags.put(plists.getKey(), Collections.synchronizedMap(new HashMap<String, Boolean>()));
|
|
|
|
|
}
|
|
|
|
|
this.playerFlags.get(plists.getKey()).put(flag.getKey(), flag.getValue());
|
|
|
|
|
} else if (player != null)
|
|
|
|
|
} else if (player != null) {
|
|
|
|
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
|
|
|
|
|
for (final Entry<String, Map<String, Boolean>> glists : list.groupFlags.entrySet())
|
|
|
|
|
for (final Entry<String, Boolean> flag : glists.getValue().entrySet())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (final Entry<String, Map<String, Boolean>> glists : list.groupFlags.entrySet()) {
|
|
|
|
|
for (final Entry<String, Boolean> flag : glists.getValue().entrySet()) {
|
|
|
|
|
if (group.hasFlagAccess(flag.getKey()) || resadmin) {
|
|
|
|
|
if (!this.groupFlags.containsKey(glists.getKey()))
|
|
|
|
|
if (!this.groupFlags.containsKey(glists.getKey())) {
|
|
|
|
|
this.groupFlags.put(glists.getKey(), Collections.synchronizedMap(new HashMap<String, Boolean>()));
|
|
|
|
|
}
|
|
|
|
|
this.groupFlags.get(glists.getKey()).put(flag.getKey(), flag.getValue());
|
|
|
|
|
} else if (player != null)
|
|
|
|
|
} else if (player != null) {
|
|
|
|
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
|
|
|
|
|
if (player != null)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (player != null) {
|
|
|
|
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("PermissionsApply"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fixNames() {
|
|
|
|
|
@@ -172,8 +206,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
final Iterator<Entry<String, Map<String, Boolean>>> it = playerFlags.entrySet().iterator();
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
final String name = it.next().getKey();
|
|
|
|
|
if (!name.equals(name.toLowerCase()))
|
|
|
|
|
if (!name.equals(name.toLowerCase())) {
|
|
|
|
|
fixNames.add(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (final String name : fixNames) {
|
|
|
|
|
final Map<String, Boolean> get = playerFlags.get(name);
|
|
|
|
|
@@ -194,8 +229,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
public boolean groupHas(final String group, final String flag, final boolean def) {
|
|
|
|
|
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.GROUP, group, def);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isOverriden())
|
|
|
|
|
if (fc.isOverriden()) {
|
|
|
|
|
return fc.getOverrideValue();
|
|
|
|
|
}
|
|
|
|
|
return super.groupHas(group, flag, def);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -203,8 +239,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
public boolean has(final String flag, final boolean def) {
|
|
|
|
|
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.RESIDENCE, null, def);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isOverriden())
|
|
|
|
|
if (fc.isOverriden()) {
|
|
|
|
|
return fc.getOverrideValue();
|
|
|
|
|
}
|
|
|
|
|
return super.has(flag, def);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -216,17 +253,20 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
if (plugin.getConfigManager().enabledRentSystem()) {
|
|
|
|
|
final String resname = residence.getName();
|
|
|
|
|
if (plugin.getRentManager().isRented(resname)) {
|
|
|
|
|
if (requireOwner)
|
|
|
|
|
if (requireOwner) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
final String renter = plugin.getRentManager().getRentingPlayer(resname);
|
|
|
|
|
if (player.getName().equalsIgnoreCase(renter))
|
|
|
|
|
if (player.getName().equalsIgnoreCase(renter)) {
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
return (playerHas(player.getName(), "admin", false));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (requireOwner)
|
|
|
|
|
if (requireOwner) {
|
|
|
|
|
return (owner.equalsIgnoreCase(player.getName()));
|
|
|
|
|
}
|
|
|
|
|
return (playerHas(player.getName(), "admin", false) || owner.equalsIgnoreCase(player.getName()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -238,8 +278,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
public boolean playerHas(final String player, final String world, final String flag, final boolean def) {
|
|
|
|
|
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.PLAYER, player, def);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isOverriden())
|
|
|
|
|
if (fc.isOverriden()) {
|
|
|
|
|
return fc.getOverrideValue();
|
|
|
|
|
}
|
|
|
|
|
return super.playerHas(player, world, flag, def);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -247,8 +288,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
if (this.hasResidencePermission(player, false) || resadmin) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, "ALL", ResidenceFlagChangeEvent.FlagType.GROUP, FlagState.NEITHER, null);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
super.removeAllGroupFlags(group);
|
|
|
|
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
|
|
|
|
return true;
|
|
|
|
|
@@ -260,8 +302,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
if (this.hasResidencePermission(player, false) || resadmin) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, "ALL", ResidenceFlagChangeEvent.FlagType.RESIDENCE, FlagState.NEITHER, null);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
super.removeAllPlayerFlags(targetPlayer);
|
|
|
|
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
|
|
|
|
return true;
|
|
|
|
|
@@ -278,14 +321,16 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean setFlag(final Player player, final String flag, final String flagstate, final boolean resadmin) {
|
|
|
|
|
if (validFlagGroups.containsKey(flag))
|
|
|
|
|
if (validFlagGroups.containsKey(flag)) {
|
|
|
|
|
return this.setFlagGroup(player, flag, flagstate, resadmin);
|
|
|
|
|
}
|
|
|
|
|
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
|
|
|
|
if (checkCanSetFlag(player, flag, state, true, resadmin)) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.RESIDENCE, state, null);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (super.setFlag(flag, state)) {
|
|
|
|
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
|
|
|
|
return true;
|
|
|
|
|
@@ -298,8 +343,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
public boolean setFlag(final String flag, final FlagState state) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, null, flag, ResidenceFlagChangeEvent.FlagType.RESIDENCE, state, null);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return super.setFlag(flag, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -307,9 +353,11 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
|
|
|
|
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
|
|
|
|
boolean changed = false;
|
|
|
|
|
for (final String flag : flags)
|
|
|
|
|
if (this.setFlag(player, flag, state, resadmin))
|
|
|
|
|
for (final String flag : flags) {
|
|
|
|
|
if (this.setFlag(player, flag, state, resadmin)) {
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
@@ -319,9 +367,11 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
|
|
|
|
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
|
|
|
|
boolean changed = false;
|
|
|
|
|
for (final String flag : flags)
|
|
|
|
|
if (this.setGroupFlag(player, group, flag, state, resadmin))
|
|
|
|
|
for (final String flag : flags) {
|
|
|
|
|
if (this.setGroupFlag(player, group, flag, state, resadmin)) {
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
@@ -331,9 +381,11 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
|
|
|
|
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
|
|
|
|
boolean changed = false;
|
|
|
|
|
for (final String flag : flags)
|
|
|
|
|
if (this.setPlayerFlag(player, target, flag, state, resadmin))
|
|
|
|
|
for (final String flag : flags) {
|
|
|
|
|
if (this.setPlayerFlag(player, target, flag, state, resadmin)) {
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
@@ -341,15 +393,17 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
|
|
|
|
|
public boolean setGroupFlag(final Player player, String group, final String flag, final String flagstate, final boolean resadmin) {
|
|
|
|
|
group = group.toLowerCase();
|
|
|
|
|
if (validFlagGroups.containsKey(flag))
|
|
|
|
|
if (validFlagGroups.containsKey(flag)) {
|
|
|
|
|
return this.setFlagGroupOnGroup(player, flag, group, flagstate, resadmin);
|
|
|
|
|
}
|
|
|
|
|
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
|
|
|
|
if (checkCanSetFlag(player, flag, state, false, resadmin))
|
|
|
|
|
if (checkCanSetFlag(player, flag, state, false, resadmin)) {
|
|
|
|
|
if (plugin.getPermissionManager().hasGroup(group)) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.GROUP, state, group);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (super.setGroupFlag(group, flag, state)) {
|
|
|
|
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
|
|
|
|
return true;
|
|
|
|
|
@@ -358,6 +412,7 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidGroup"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -365,8 +420,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
public boolean setGroupFlag(final String group, final String flag, final FlagState state) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, null, flag, ResidenceFlagChangeEvent.FlagType.GROUP, state, group);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return super.setGroupFlag(group, flag, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -374,19 +430,22 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
final ResidenceOwnerChangeEvent ownerchange = new ResidenceOwnerChangeEvent(residence, newOwner);
|
|
|
|
|
pm.callEvent(ownerchange);
|
|
|
|
|
owner = newOwner;
|
|
|
|
|
if (resetFlags)
|
|
|
|
|
if (resetFlags) {
|
|
|
|
|
this.applyDefaultFlags();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean setPlayerFlag(final Player player, final String targetPlayer, final String flag, final String flagstate, final boolean resadmin) {
|
|
|
|
|
if (validFlagGroups.containsKey(flag))
|
|
|
|
|
if (validFlagGroups.containsKey(flag)) {
|
|
|
|
|
return this.setFlagGroupOnPlayer(player, targetPlayer, flag, flagstate, resadmin);
|
|
|
|
|
}
|
|
|
|
|
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
|
|
|
|
if (checkCanSetFlag(player, flag, state, false, resadmin)) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.PLAYER, state, targetPlayer);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (super.setPlayerFlag(targetPlayer, flag, state)) {
|
|
|
|
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
|
|
|
|
return true;
|
|
|
|
|
@@ -399,8 +458,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|
|
|
|
public boolean setPlayerFlag(final String player, final String flag, final FlagState state) {
|
|
|
|
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, null, flag, ResidenceFlagChangeEvent.FlagType.PLAYER, state, player);
|
|
|
|
|
pm.callEvent(fc);
|
|
|
|
|
if (fc.isCancelled())
|
|
|
|
|
if (fc.isCancelled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return super.setPlayerFlag(player, flag, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|