mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
fix PermissionManager error...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
@@ -60,8 +60,8 @@ public class ConfigManager {
|
|||||||
|
|
||||||
public ConfigManager(final Residence plugin) {
|
public ConfigManager(final Residence plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
globalCreatorDefaults = new FlagPermissions(plugin);
|
globalCreatorDefaults = new FlagPermissions();
|
||||||
globalResidenceDefaults = new FlagPermissions(plugin);
|
globalResidenceDefaults = new FlagPermissions();
|
||||||
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
||||||
this.load(plugin.getConfig());
|
this.load(plugin.getConfig());
|
||||||
}
|
}
|
||||||
@@ -247,17 +247,14 @@ public class ConfigManager {
|
|||||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||||
final ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
final ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||||
|
|
||||||
if (!plugin.is1_8()) {
|
if (!plugin.is1_8())
|
||||||
actionBar = false;
|
actionBar = false;
|
||||||
}
|
|
||||||
|
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
final Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
final Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||||
if (keys != null) {
|
if (keys != null)
|
||||||
for (final String key : keys) {
|
for (final String key : keys)
|
||||||
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ public class Residence extends JavaPlugin {
|
|||||||
public static float bukkitver;
|
public static float bukkitver;
|
||||||
|
|
||||||
public final static int saveVersion = 1;
|
public final static int saveVersion = 1;
|
||||||
public final static String[] validLanguages = { "English", "Chinese" };
|
public final static String[] validLanguages = { "English",
|
||||||
|
"Chinese" };
|
||||||
|
protected static Residence instance;
|
||||||
protected ResidenceBlockListener blistener;
|
protected ResidenceBlockListener blistener;
|
||||||
protected ChatManager chatmanager;
|
protected ChatManager chatmanager;
|
||||||
protected ConfigManager cmanager;
|
protected ConfigManager cmanager;
|
||||||
@@ -113,6 +115,10 @@ public class Residence extends JavaPlugin {
|
|||||||
protected boolean useWorldEdit;
|
protected boolean useWorldEdit;
|
||||||
protected WorldFlagManager wmanager;
|
protected WorldFlagManager wmanager;
|
||||||
|
|
||||||
|
public static Residence getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public ResidenceBlockListener getBlockListener() {
|
public ResidenceBlockListener getBlockListener() {
|
||||||
return blistener;
|
return blistener;
|
||||||
}
|
}
|
||||||
@@ -428,7 +434,7 @@ public class Residence extends JavaPlugin {
|
|||||||
if (!this.isEnabled()) {
|
if (!this.isEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FlagPermissions.initValidFlags();
|
FlagPermissions.initValidFlags(this);
|
||||||
final Plugin wep = this.getServer().getPluginManager().getPlugin("WorldEdit");
|
final Plugin wep = this.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
if (wep != null) {
|
if (wep != null) {
|
||||||
smanager = new WorldEditSelectionManager(this);
|
smanager = new WorldEditSelectionManager(this);
|
||||||
@@ -492,9 +498,10 @@ public class Residence extends JavaPlugin {
|
|||||||
init = true;
|
init = true;
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
init = false;
|
init = false;
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
setEnabled(false);
|
||||||
this.getLogger().warning(" - 初始化失败! 卸载插件! 请报告以下错误给作者,谢谢!");
|
this.getLogger().warning(" - 初始化失败! 卸载插件! 请报告以下错误给作者,谢谢!");
|
||||||
this.getLogger().warning("错误: " + ex);
|
this.getLogger().warning("错误: " + ex);
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
new VersionChecker(this);
|
new VersionChecker(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public class CommandSelect extends BaseCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
|
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
|
|||||||
@@ -58,24 +58,22 @@ public class PermissionGroup {
|
|||||||
protected int xmax;
|
protected int xmax;
|
||||||
protected int ymax;
|
protected int ymax;
|
||||||
protected int zmax;
|
protected int zmax;
|
||||||
Residence plugin;
|
|
||||||
|
|
||||||
public PermissionGroup(final Residence plugin, final String name) {
|
public PermissionGroup(final String name) {
|
||||||
this.plugin = plugin;
|
flagPerms = new FlagPermissions();
|
||||||
flagPerms = new FlagPermissions(plugin);
|
|
||||||
creatorDefaultFlags = new HashMap<String, Boolean>();
|
creatorDefaultFlags = new HashMap<String, Boolean>();
|
||||||
residenceDefaultFlags = new HashMap<String, Boolean>();
|
residenceDefaultFlags = new HashMap<String, Boolean>();
|
||||||
groupDefaultFlags = new HashMap<String, Map<String, Boolean>>();
|
groupDefaultFlags = new HashMap<String, Map<String, Boolean>>();
|
||||||
groupname = name;
|
groupname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionGroup(final Residence plugin, final String name, final ConfigurationSection node) {
|
public PermissionGroup(final String name, final ConfigurationSection node) {
|
||||||
this(plugin, name);
|
this(name);
|
||||||
this.parseGroup(node);
|
this.parseGroup(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionGroup(final Residence plugin, final String name, final ConfigurationSection node, final FlagPermissions parentFlagPerms) {
|
public PermissionGroup(final String name, final ConfigurationSection node, final FlagPermissions parentFlagPerms) {
|
||||||
this(plugin, name, node);
|
this(name, node);
|
||||||
flagPerms.setParent(parentFlagPerms);
|
flagPerms.setParent(parentFlagPerms);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +201,7 @@ public class PermissionGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void printLimits(final Player player) {
|
public void printLimits(final Player player) {
|
||||||
|
final Residence plugin = Residence.getInstance();
|
||||||
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
||||||
player.sendMessage(ChatColor.YELLOW + "权限 组:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().getPermissionsGroup(player));
|
player.sendMessage(ChatColor.YELLOW + "权限 组:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().getPermissionsGroup(player));
|
||||||
player.sendMessage(ChatColor.YELLOW + "领地 组:" + ChatColor.DARK_AQUA + " " + groupname);
|
player.sendMessage(ChatColor.YELLOW + "领地 组:" + ChatColor.DARK_AQUA + " " + groupname);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class PermissionManager {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
groups = Collections.synchronizedMap(new HashMap<String, PermissionGroup>());
|
groups = Collections.synchronizedMap(new HashMap<String, PermissionGroup>());
|
||||||
playersGroup = Collections.synchronizedMap(new HashMap<String, String>());
|
playersGroup = Collections.synchronizedMap(new HashMap<String, String>());
|
||||||
globalFlagPerms = new FlagPermissions(plugin);
|
globalFlagPerms = new FlagPermissions();
|
||||||
this.readConfig(plugin.getConfig());
|
this.readConfig(plugin.getConfig());
|
||||||
final boolean enable = plugin.getConfig().getBoolean("Global.EnablePermissions", true);
|
final boolean enable = plugin.getConfig().getBoolean("Global.EnablePermissions", true);
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@@ -135,10 +135,10 @@ public class PermissionManager {
|
|||||||
final Set<String> entrys = nodes.getKeys(false);
|
final Set<String> entrys = nodes.getKeys(false);
|
||||||
for (final String key : entrys) {
|
for (final String key : entrys) {
|
||||||
try {
|
try {
|
||||||
groups.put(key.toLowerCase(), new PermissionGroup(plugin, key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
groups.put(key.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||||
final List<String> mirrors = nodes.getConfigurationSection(key).getStringList("Mirror");
|
final List<String> mirrors = nodes.getConfigurationSection(key).getStringList("Mirror");
|
||||||
for (final String group : mirrors) {
|
for (final String group : mirrors) {
|
||||||
groups.put(group.toLowerCase(), new PermissionGroup(plugin, key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
groups.put(group.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
plugin.getLogger().info("错误 从配置文件读取:" + key + " 抛出异常:" + ex);
|
plugin.getLogger().info("错误 从配置文件读取:" + key + " 抛出异常:" + ex);
|
||||||
@@ -146,7 +146,7 @@ public class PermissionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!groups.containsKey(defaultGroup)) {
|
if (!groups.containsKey(defaultGroup)) {
|
||||||
groups.put(defaultGroup, new PermissionGroup(plugin, defaultGroup));
|
groups.put(defaultGroup, new PermissionGroup(defaultGroup));
|
||||||
}
|
}
|
||||||
final Set<String> keys = config.getConfigurationSection("GroupAssignments").getKeys(false);
|
final Set<String> keys = config.getConfigurationSection("GroupAssignments").getKeys(false);
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ import com.bekvon.bukkit.residence.Residence;
|
|||||||
*/
|
*/
|
||||||
public class FlagPermissions {
|
public class FlagPermissions {
|
||||||
|
|
||||||
|
public static enum FlagState {
|
||||||
|
FALSE,
|
||||||
|
INVALID,
|
||||||
|
NEITHER,
|
||||||
|
TRUE
|
||||||
|
}
|
||||||
|
|
||||||
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>();
|
||||||
@@ -36,10 +43,10 @@ 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(final Residence plugin) {
|
public FlagPermissions() {
|
||||||
FlagPermissions.plugin = plugin;
|
|
||||||
cuboidFlags = Collections.synchronizedMap(new HashMap<String, Boolean>());
|
cuboidFlags = Collections.synchronizedMap(new HashMap<String, Boolean>());
|
||||||
playerFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
playerFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
||||||
groupFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
groupFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
||||||
@@ -97,7 +104,8 @@ public class FlagPermissions {
|
|||||||
return (EnumMap<Material, String>) matUseFlagList;
|
return (EnumMap<Material, String>) matUseFlagList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initValidFlags() {
|
public static void initValidFlags(final Residence plugin) {
|
||||||
|
FlagPermissions.plugin = plugin;
|
||||||
validAreaFlags.clear();
|
validAreaFlags.clear();
|
||||||
validPlayerFlags.clear();
|
validPlayerFlags.clear();
|
||||||
validFlags.clear();
|
validFlags.clear();
|
||||||
@@ -225,12 +233,12 @@ public class FlagPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FlagPermissions load(final Map<String, Object> root) throws Exception {
|
public static FlagPermissions load(final Map<String, Object> root) throws Exception {
|
||||||
final FlagPermissions newperms = new FlagPermissions(plugin);
|
final FlagPermissions newperms = new FlagPermissions();
|
||||||
return FlagPermissions.load(root, newperms);
|
return FlagPermissions.load(root, newperms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FlagPermissions parseFromConfigNode(final String name, final ConfigurationSection node) {
|
public static FlagPermissions parseFromConfigNode(final String name, final ConfigurationSection node) {
|
||||||
final FlagPermissions list = new FlagPermissions(plugin);
|
final FlagPermissions list = new FlagPermissions();
|
||||||
final Set<String> keys = node.getConfigurationSection(name).getKeys(false);
|
final Set<String> keys = node.getConfigurationSection(name).getKeys(false);
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
@@ -624,12 +632,4 @@ public class FlagPermissions {
|
|||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum FlagState {
|
|
||||||
|
|
||||||
FALSE,
|
|
||||||
INVALID,
|
|
||||||
NEITHER,
|
|
||||||
TRUE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class PermissionListManager {
|
|||||||
}
|
}
|
||||||
FlagPermissions perms = get.get(listname);
|
FlagPermissions perms = get.get(listname);
|
||||||
if (perms == null) {
|
if (perms == null) {
|
||||||
perms = new FlagPermissions(plugin);
|
perms = new FlagPermissions();
|
||||||
get.put(listname, perms);
|
get.put(listname, perms);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ListCreate", listname));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ListCreate", listname));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
Residence plugin;
|
Residence plugin;
|
||||||
|
|
||||||
public ResidencePermissions(final Residence plugin, final ClaimedResidence res) {
|
public ResidencePermissions(final Residence plugin, final ClaimedResidence res) {
|
||||||
super(plugin);
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.pm = plugin.getServer().getPluginManager();
|
this.pm = plugin.getServer().getPluginManager();
|
||||||
residence = res;
|
residence = res;
|
||||||
@@ -52,30 +51,24 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
public static ResidencePermissions load(final Residence plugin, final ClaimedResidence res, final Map<String, Object> root) throws Exception {
|
public static ResidencePermissions load(final Residence plugin, final ClaimedResidence res, final Map<String, Object> root) throws Exception {
|
||||||
final ResidencePermissions newperms = new ResidencePermissions(plugin, res);
|
final ResidencePermissions newperms = new ResidencePermissions(plugin, res);
|
||||||
newperms.owner = (String) root.get("Owner");
|
newperms.owner = (String) root.get("Owner");
|
||||||
if (newperms.owner == null) {
|
if (newperms.owner == null)
|
||||||
newperms.owner = (String) root.get("OwnerLastKnownName");
|
newperms.owner = (String) root.get("OwnerLastKnownName");
|
||||||
}
|
|
||||||
if (newperms.owner == null) {
|
if (newperms.owner == null) {
|
||||||
plugin.getLogger().warning("发现未知所有者的领地,转换为Server Land...");
|
plugin.getLogger().warning("发现未知所有者的领地,转换为Server Land...");
|
||||||
newperms.owner = "Server Land";
|
newperms.owner = "Server Land";
|
||||||
}
|
}
|
||||||
newperms.world = (String) root.get("World");
|
newperms.world = (String) root.get("World");
|
||||||
FlagPermissions.load(root, newperms);
|
FlagPermissions.load(root, newperms);
|
||||||
if (newperms.owner == null) {
|
if (newperms.owner == null)
|
||||||
throw new Exception("错误的Owner数据...");
|
throw new Exception("错误的Owner数据...");
|
||||||
}
|
if (newperms.world == null)
|
||||||
if (newperms.world == null) {
|
|
||||||
throw new Exception("错误的World数据...");
|
throw new Exception("错误的World数据...");
|
||||||
}
|
if (newperms.playerFlags == null)
|
||||||
if (newperms.playerFlags == null) {
|
|
||||||
throw new Exception("错误的PlayerFlags数据...");
|
throw new Exception("错误的PlayerFlags数据...");
|
||||||
}
|
if (newperms.groupFlags == null)
|
||||||
if (newperms.groupFlags == null) {
|
|
||||||
throw new Exception("错误的GroupFlags数据...");
|
throw new Exception("错误的GroupFlags数据...");
|
||||||
}
|
if (newperms.cuboidFlags == null)
|
||||||
if (newperms.cuboidFlags == null) {
|
|
||||||
throw new Exception("错误的CuboidFlags数据...");
|
throw new Exception("错误的CuboidFlags数据...");
|
||||||
}
|
|
||||||
newperms.fixNames();
|
newperms.fixNames();
|
||||||
return newperms;
|
return newperms;
|
||||||
}
|
}
|
||||||
@@ -87,33 +80,25 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
final Set<Entry<String, Boolean>> dcflags = group.getDefaultCreatorFlags();
|
final Set<Entry<String, Boolean>> dcflags = group.getDefaultCreatorFlags();
|
||||||
final Set<Entry<String, Map<String, Boolean>>> dgflags = group.getDefaultGroupFlags();
|
final Set<Entry<String, Map<String, Boolean>>> dgflags = group.getDefaultGroupFlags();
|
||||||
this.applyGlobalDefaults();
|
this.applyGlobalDefaults();
|
||||||
for (final Entry<String, Boolean> next : dflags) {
|
for (final Entry<String, Boolean> next : dflags)
|
||||||
if (this.checkValidFlag(next.getKey(), true)) {
|
if (this.checkValidFlag(next.getKey(), true))
|
||||||
if (next.getValue()) {
|
if (next.getValue())
|
||||||
this.setFlag(next.getKey(), FlagState.TRUE);
|
this.setFlag(next.getKey(), FlagState.TRUE);
|
||||||
} else {
|
else
|
||||||
this.setFlag(next.getKey(), FlagState.FALSE);
|
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);
|
this.setPlayerFlag(owner, next.getKey(), FlagState.TRUE);
|
||||||
} else {
|
else
|
||||||
this.setPlayerFlag(owner, next.getKey(), FlagState.FALSE);
|
this.setPlayerFlag(owner, next.getKey(), FlagState.FALSE);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (final Entry<String, Map<String, Boolean>> entry : dgflags) {
|
for (final Entry<String, Map<String, Boolean>> entry : dgflags) {
|
||||||
final Map<String, Boolean> value = entry.getValue();
|
final Map<String, Boolean> value = entry.getValue();
|
||||||
for (final Entry<String, Boolean> flag : value.entrySet()) {
|
for (final Entry<String, Boolean> flag : value.entrySet())
|
||||||
if (flag.getValue()) {
|
if (flag.getValue())
|
||||||
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.TRUE);
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.TRUE);
|
||||||
} else {
|
else
|
||||||
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.FALSE);
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.FALSE);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +106,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
if (this.hasResidencePermission(player, true) || resadmin) {
|
if (this.hasResidencePermission(player, true) || resadmin) {
|
||||||
this.applyDefaultFlags();
|
this.applyDefaultFlags();
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("FlagsDefault"));
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("FlagsDefault"));
|
||||||
} else {
|
} else
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyGlobalDefaults() {
|
public void applyGlobalDefaults() {
|
||||||
@@ -131,29 +115,22 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
final FlagPermissions gRD = plugin.getConfigManager().getGlobalResidenceDefaultFlags();
|
final FlagPermissions gRD = plugin.getConfigManager().getGlobalResidenceDefaultFlags();
|
||||||
final FlagPermissions gCD = plugin.getConfigManager().getGlobalCreatorDefaultFlags();
|
final FlagPermissions gCD = plugin.getConfigManager().getGlobalCreatorDefaultFlags();
|
||||||
final Map<String, FlagPermissions> gGD = plugin.getConfigManager().getGlobalGroupDefaultFlags();
|
final Map<String, FlagPermissions> gGD = plugin.getConfigManager().getGlobalGroupDefaultFlags();
|
||||||
for (final Entry<String, Boolean> entry : gRD.cuboidFlags.entrySet()) {
|
for (final Entry<String, Boolean> entry : gRD.cuboidFlags.entrySet())
|
||||||
if (entry.getValue()) {
|
if (entry.getValue())
|
||||||
this.setFlag(entry.getKey(), FlagState.TRUE);
|
this.setFlag(entry.getKey(), FlagState.TRUE);
|
||||||
} else {
|
else
|
||||||
this.setFlag(entry.getKey(), FlagState.FALSE);
|
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);
|
this.setPlayerFlag(owner, entry.getKey(), FlagState.TRUE);
|
||||||
} else {
|
else
|
||||||
this.setPlayerFlag(owner, entry.getKey(), FlagState.FALSE);
|
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())
|
||||||
for (final Entry<String, FlagPermissions> entry : gGD.entrySet()) {
|
if (flag.getValue())
|
||||||
for (final Entry<String, Boolean> flag : entry.getValue().cuboidFlags.entrySet()) {
|
|
||||||
if (flag.getValue()) {
|
|
||||||
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.TRUE);
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.TRUE);
|
||||||
} else {
|
else
|
||||||
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.FALSE);
|
this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.FALSE);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyTemplate(final Player player, final FlagPermissions list, boolean resadmin) {
|
public void applyTemplate(final Player player, final FlagPermissions list, boolean resadmin) {
|
||||||
@@ -162,44 +139,32 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
resadmin = true;
|
resadmin = true;
|
||||||
}
|
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(owner, world);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(owner, world);
|
||||||
for (final Entry<String, Boolean> flag : list.cuboidFlags.entrySet()) {
|
for (final Entry<String, Boolean> flag : list.cuboidFlags.entrySet())
|
||||||
if (group.hasFlagAccess(flag.getKey()) || resadmin) {
|
if (group.hasFlagAccess(flag.getKey()) || resadmin)
|
||||||
this.cuboidFlags.put(flag.getKey(), flag.getValue());
|
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));
|
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 (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.put(plists.getKey(), Collections.synchronizedMap(new HashMap<String, Boolean>()));
|
||||||
}
|
|
||||||
this.playerFlags.get(plists.getKey()).put(flag.getKey(), flag.getValue());
|
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));
|
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 (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.put(glists.getKey(), Collections.synchronizedMap(new HashMap<String, Boolean>()));
|
||||||
}
|
|
||||||
this.groupFlags.get(glists.getKey()).put(flag.getKey(), flag.getValue());
|
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));
|
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"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("PermissionsApply"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fixNames() {
|
public void fixNames() {
|
||||||
@@ -207,9 +172,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
final Iterator<Entry<String, Map<String, Boolean>>> it = playerFlags.entrySet().iterator();
|
final Iterator<Entry<String, Map<String, Boolean>>> it = playerFlags.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
final String name = it.next().getKey();
|
final String name = it.next().getKey();
|
||||||
if (!name.equals(name.toLowerCase())) {
|
if (!name.equals(name.toLowerCase()))
|
||||||
fixNames.add(name);
|
fixNames.add(name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (final String name : fixNames) {
|
for (final String name : fixNames) {
|
||||||
final Map<String, Boolean> get = playerFlags.get(name);
|
final Map<String, Boolean> get = playerFlags.get(name);
|
||||||
@@ -230,9 +194,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
public boolean groupHas(final String group, final String flag, final boolean def) {
|
public boolean groupHas(final String group, final String flag, final boolean def) {
|
||||||
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.GROUP, group, def);
|
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.GROUP, group, def);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isOverriden()) {
|
if (fc.isOverriden())
|
||||||
return fc.getOverrideValue();
|
return fc.getOverrideValue();
|
||||||
}
|
|
||||||
return super.groupHas(group, flag, def);
|
return super.groupHas(group, flag, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,9 +203,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
public boolean has(final String flag, final boolean def) {
|
public boolean has(final String flag, final boolean def) {
|
||||||
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.RESIDENCE, null, def);
|
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.RESIDENCE, null, def);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isOverriden()) {
|
if (fc.isOverriden())
|
||||||
return fc.getOverrideValue();
|
return fc.getOverrideValue();
|
||||||
}
|
|
||||||
return super.has(flag, def);
|
return super.has(flag, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,20 +216,17 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||||
final String resname = residence.getName();
|
final String resname = residence.getName();
|
||||||
if (plugin.getRentManager().isRented(resname)) {
|
if (plugin.getRentManager().isRented(resname)) {
|
||||||
if (requireOwner) {
|
if (requireOwner)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
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 {
|
else
|
||||||
return (playerHas(player.getName(), "admin", false));
|
return (playerHas(player.getName(), "admin", false));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requireOwner) {
|
if (requireOwner)
|
||||||
return (owner.equalsIgnoreCase(player.getName()));
|
return (owner.equalsIgnoreCase(player.getName()));
|
||||||
}
|
|
||||||
return (playerHas(player.getName(), "admin", false) || owner.equalsIgnoreCase(player.getName()));
|
return (playerHas(player.getName(), "admin", false) || owner.equalsIgnoreCase(player.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,9 +238,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
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) {
|
||||||
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.PLAYER, player, def);
|
final ResidenceFlagCheckEvent fc = new ResidenceFlagCheckEvent(residence, flag, FlagType.PLAYER, player, def);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isOverriden()) {
|
if (fc.isOverriden())
|
||||||
return fc.getOverrideValue();
|
return fc.getOverrideValue();
|
||||||
}
|
|
||||||
return super.playerHas(player, world, flag, def);
|
return super.playerHas(player, world, flag, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,9 +247,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
if (this.hasResidencePermission(player, false) || resadmin) {
|
if (this.hasResidencePermission(player, false) || resadmin) {
|
||||||
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, "ALL", ResidenceFlagChangeEvent.FlagType.GROUP, FlagState.NEITHER, null);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, "ALL", ResidenceFlagChangeEvent.FlagType.GROUP, FlagState.NEITHER, null);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
super.removeAllGroupFlags(group);
|
super.removeAllGroupFlags(group);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
||||||
return true;
|
return true;
|
||||||
@@ -303,9 +260,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
if (this.hasResidencePermission(player, false) || resadmin) {
|
if (this.hasResidencePermission(player, false) || resadmin) {
|
||||||
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, "ALL", ResidenceFlagChangeEvent.FlagType.RESIDENCE, FlagState.NEITHER, null);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, "ALL", ResidenceFlagChangeEvent.FlagType.RESIDENCE, FlagState.NEITHER, null);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
super.removeAllPlayerFlags(targetPlayer);
|
super.removeAllPlayerFlags(targetPlayer);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
||||||
return true;
|
return true;
|
||||||
@@ -322,16 +278,14 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean setFlag(final Player player, final String flag, final String flagstate, final boolean resadmin) {
|
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);
|
return this.setFlagGroup(player, flag, flagstate, resadmin);
|
||||||
}
|
|
||||||
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
||||||
if (checkCanSetFlag(player, flag, state, true, resadmin)) {
|
if (checkCanSetFlag(player, flag, state, true, resadmin)) {
|
||||||
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.RESIDENCE, state, null);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.RESIDENCE, state, null);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if (super.setFlag(flag, state)) {
|
if (super.setFlag(flag, state)) {
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
||||||
return true;
|
return true;
|
||||||
@@ -344,9 +298,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
public boolean setFlag(final String flag, final FlagState state) {
|
public boolean setFlag(final String flag, final FlagState state) {
|
||||||
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, null, flag, ResidenceFlagChangeEvent.FlagType.RESIDENCE, state, null);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, null, flag, ResidenceFlagChangeEvent.FlagType.RESIDENCE, state, null);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return super.setFlag(flag, state);
|
return super.setFlag(flag, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,11 +307,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
||||||
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (final String flag : flags) {
|
for (final String flag : flags)
|
||||||
if (this.setFlag(player, flag, state, resadmin)) {
|
if (this.setFlag(player, flag, state, resadmin))
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -368,11 +319,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
||||||
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (final String flag : flags) {
|
for (final String flag : flags)
|
||||||
if (this.setGroupFlag(player, group, flag, state, resadmin)) {
|
if (this.setGroupFlag(player, group, flag, state, resadmin))
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -382,11 +331,9 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
if (ResidencePermissions.validFlagGroups.containsKey(flaggroup)) {
|
||||||
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
final ArrayList<String> flags = ResidencePermissions.validFlagGroups.get(flaggroup);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (final String flag : flags) {
|
for (final String flag : flags)
|
||||||
if (this.setPlayerFlag(player, target, flag, state, resadmin)) {
|
if (this.setPlayerFlag(player, target, flag, state, resadmin))
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -394,17 +341,15 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
|
|
||||||
public boolean setGroupFlag(final Player player, String group, final String flag, final String flagstate, final boolean resadmin) {
|
public boolean setGroupFlag(final Player player, String group, final String flag, final String flagstate, final boolean resadmin) {
|
||||||
group = group.toLowerCase();
|
group = group.toLowerCase();
|
||||||
if (validFlagGroups.containsKey(flag)) {
|
if (validFlagGroups.containsKey(flag))
|
||||||
return this.setFlagGroupOnGroup(player, flag, group, flagstate, resadmin);
|
return this.setFlagGroupOnGroup(player, flag, group, flagstate, resadmin);
|
||||||
}
|
|
||||||
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
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)) {
|
if (plugin.getPermissionManager().hasGroup(group)) {
|
||||||
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.GROUP, state, group);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.GROUP, state, group);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if (super.setGroupFlag(group, flag, state)) {
|
if (super.setGroupFlag(group, flag, state)) {
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
||||||
return true;
|
return true;
|
||||||
@@ -413,7 +358,6 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidGroup"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidGroup"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,9 +365,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
public boolean setGroupFlag(final String group, final String flag, final FlagState state) {
|
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);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, null, flag, ResidenceFlagChangeEvent.FlagType.GROUP, state, group);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return super.setGroupFlag(group, flag, state);
|
return super.setGroupFlag(group, flag, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,22 +374,19 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
final ResidenceOwnerChangeEvent ownerchange = new ResidenceOwnerChangeEvent(residence, newOwner);
|
final ResidenceOwnerChangeEvent ownerchange = new ResidenceOwnerChangeEvent(residence, newOwner);
|
||||||
pm.callEvent(ownerchange);
|
pm.callEvent(ownerchange);
|
||||||
owner = newOwner;
|
owner = newOwner;
|
||||||
if (resetFlags) {
|
if (resetFlags)
|
||||||
this.applyDefaultFlags();
|
this.applyDefaultFlags();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setPlayerFlag(final Player player, final String targetPlayer, final String flag, final String flagstate, final boolean resadmin) {
|
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);
|
return this.setFlagGroupOnPlayer(player, targetPlayer, flag, flagstate, resadmin);
|
||||||
}
|
|
||||||
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
final FlagState state = FlagPermissions.stringToFlagState(flagstate);
|
||||||
if (checkCanSetFlag(player, flag, state, false, resadmin)) {
|
if (checkCanSetFlag(player, flag, state, false, resadmin)) {
|
||||||
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.PLAYER, state, targetPlayer);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, player, flag, ResidenceFlagChangeEvent.FlagType.PLAYER, state, targetPlayer);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if (super.setPlayerFlag(targetPlayer, flag, state)) {
|
if (super.setPlayerFlag(targetPlayer, flag, state)) {
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("FlagSet"));
|
||||||
return true;
|
return true;
|
||||||
@@ -459,9 +399,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
public boolean setPlayerFlag(final String player, final String flag, final FlagState state) {
|
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);
|
final ResidenceFlagChangeEvent fc = new ResidenceFlagChangeEvent(residence, null, flag, ResidenceFlagChangeEvent.FlagType.PLAYER, state, player);
|
||||||
pm.callEvent(fc);
|
pm.callEvent(fc);
|
||||||
if (fc.isCancelled()) {
|
if (fc.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return super.setPlayerFlag(player, flag, state);
|
return super.setPlayerFlag(player, flag, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class WorldFlagManager {
|
|||||||
|
|
||||||
public WorldFlagManager(final Residence plugin) {
|
public WorldFlagManager(final Residence plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
globaldefaults = new FlagPermissions(plugin);
|
globaldefaults = new FlagPermissions();
|
||||||
worldperms = new HashMap<String, FlagPermissions>();
|
worldperms = new HashMap<String, FlagPermissions>();
|
||||||
groupperms = new HashMap<String, Map<String, FlagPermissions>>();
|
groupperms = new HashMap<String, Map<String, FlagPermissions>>();
|
||||||
}
|
}
|
||||||
@@ -46,13 +46,11 @@ public class WorldFlagManager {
|
|||||||
public FlagPermissions getPerms(String world) {
|
public FlagPermissions getPerms(String world) {
|
||||||
world = world.toLowerCase();
|
world = world.toLowerCase();
|
||||||
final FlagPermissions list = worldperms.get(world);
|
final FlagPermissions list = worldperms.get(world);
|
||||||
if (list == null) {
|
if (list == null)
|
||||||
if (globaldefaults == null) {
|
if (globaldefaults == null)
|
||||||
return new FlagPermissions(plugin);
|
return new FlagPermissions();
|
||||||
} else {
|
else
|
||||||
return globaldefaults;
|
return globaldefaults;
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,18 +58,15 @@ public class WorldFlagManager {
|
|||||||
world = world.toLowerCase();
|
world = world.toLowerCase();
|
||||||
group = group.toLowerCase();
|
group = group.toLowerCase();
|
||||||
final Map<String, FlagPermissions> groupworldperms = groupperms.get(group);
|
final Map<String, FlagPermissions> groupworldperms = groupperms.get(group);
|
||||||
if (groupworldperms == null) {
|
if (groupworldperms == null)
|
||||||
return this.getPerms(world);
|
return this.getPerms(world);
|
||||||
}
|
|
||||||
FlagPermissions list = groupworldperms.get(world);
|
FlagPermissions list = groupworldperms.get(world);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = groupworldperms.get("global." + world);
|
list = groupworldperms.get("global." + world);
|
||||||
if (list == null) {
|
if (list == null)
|
||||||
list = groupworldperms.get("global");
|
list = groupworldperms.get("global");
|
||||||
}
|
if (list == null)
|
||||||
if (list == null) {
|
|
||||||
return this.getPerms(world);
|
return this.getPerms(world);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -80,20 +75,16 @@ public class WorldFlagManager {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
Set<String> keys = config.getConfigurationSection("Global.Flags").getKeys(false);
|
Set<String> keys = config.getConfigurationSection("Global.Flags").getKeys(false);
|
||||||
if (keys != null) {
|
if (keys != null)
|
||||||
for (final String key : keys) {
|
for (final String key : keys)
|
||||||
if (key.equalsIgnoreCase("Global")) {
|
if (key.equalsIgnoreCase("Global"))
|
||||||
globaldefaults = FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.Flags"));
|
globaldefaults = FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.Flags"));
|
||||||
} else {
|
else
|
||||||
worldperms.put(key.toLowerCase(), FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.Flags")));
|
worldperms.put(key.toLowerCase(), FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.Flags")));
|
||||||
}
|
for (final Entry<String, FlagPermissions> entry : worldperms.entrySet())
|
||||||
}
|
|
||||||
}
|
|
||||||
for (final Entry<String, FlagPermissions> entry : worldperms.entrySet()) {
|
|
||||||
entry.getValue().setParent(globaldefaults);
|
entry.getValue().setParent(globaldefaults);
|
||||||
}
|
|
||||||
keys = config.getConfigurationSection("Groups").getKeys(false);
|
keys = config.getConfigurationSection("Groups").getKeys(false);
|
||||||
if (keys != null) {
|
if (keys != null)
|
||||||
for (final String key : keys) {
|
for (final String key : keys) {
|
||||||
final ConfigurationSection worldkeylist = config.getConfigurationSection("Groups." + key + ".Flags.World");
|
final ConfigurationSection worldkeylist = config.getConfigurationSection("Groups." + key + ".Flags.World");
|
||||||
if (worldkeylist != null) {
|
if (worldkeylist != null) {
|
||||||
@@ -110,28 +101,24 @@ public class WorldFlagManager {
|
|||||||
list.setParent(worldperm.getValue());
|
list.setParent(worldperm.getValue());
|
||||||
perms.put("global." + worldperm.getKey().toLowerCase(), list);
|
perms.put("global." + worldperm.getKey().toLowerCase(), list);
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
perms.put(wkey.toLowerCase(), list);
|
perms.put(wkey.toLowerCase(), list);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (final Entry<String, FlagPermissions> entry : perms.entrySet()) {
|
for (final Entry<String, FlagPermissions> entry : perms.entrySet()) {
|
||||||
final String wkey = entry.getKey();
|
final String wkey = entry.getKey();
|
||||||
final FlagPermissions list = entry.getValue();
|
final FlagPermissions list = entry.getValue();
|
||||||
if (!wkey.startsWith("global.")) {
|
if (!wkey.startsWith("global.")) {
|
||||||
list.setParent(perms.get("global." + wkey));
|
list.setParent(perms.get("global." + wkey));
|
||||||
if (list.getParent() == null) {
|
if (list.getParent() == null)
|
||||||
list.setParent(worldperms.get(wkey));
|
list.setParent(worldperms.get(wkey));
|
||||||
}
|
if (list.getParent() == null)
|
||||||
if (list.getParent() == null) {
|
|
||||||
list.setParent(globaldefaults);
|
list.setParent(globaldefaults);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
groupperms.put(key.toLowerCase(), perms);
|
groupperms.put(key.toLowerCase(), perms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
Logger.getLogger(WorldFlagManager.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(WorldFlagManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user