diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index 607d3797..d8c6b10c 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -157,8 +157,7 @@ public class Faction extends Entity implements FactionsParticipator, MP // Null means default. private MassiveMapDef flags = new MassiveMapDef<>(); - // The perm overrides are modifications to the default values. - // Null means default. + private Map> perms = this.createNewPermMap(); // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/MPerm.java b/src/com/massivecraft/factions/entity/MPerm.java index 6de15a8c..67414c19 100644 --- a/src/com/massivecraft/factions/entity/MPerm.java +++ b/src/com/massivecraft/factions/entity/MPerm.java @@ -46,8 +46,8 @@ public class MPerm extends Entity implements Prioritized, Registerable, N public final static transient String ID_KICK = "kick"; public final static transient String ID_RANK = "rank"; public final static transient String ID_TITLE = "title"; - public final static transient String ID_WARP = "home"; - public final static transient String ID_SETWARP = "sethome"; + public final static transient String ID_WARP = "warp"; + public final static transient String ID_SETWARP = "setwarp"; public final static transient String ID_DEPOSIT = "deposit"; public final static transient String ID_WITHDRAW = "withdraw"; public final static transient String ID_TERRITORY = "territory"; @@ -149,8 +149,8 @@ public class MPerm extends Entity implements Prioritized, Registerable, N public static MPerm getPermKick() { return getCreative(PRIORITY_KICK, ID_KICK, ID_KICK, "kick members", MUtil.set("LEADER", "OFFICER"), false, true, true); } public static MPerm getPermRank() { return getCreative(PRIORITY_RANK, ID_RANK, ID_RANK, "change ranks", MUtil.set("LEADER", "OFFICER"), false, true, true); } public static MPerm getPermTitle() { return getCreative(PRIORITY_TITLE, ID_TITLE, ID_TITLE, "set titles", MUtil.set("LEADER", "OFFICER"), false, true, true); } - public static MPerm getPermWarp() { return getCreative(PRIORITY_WARP, ID_WARP, "warp", "teleport to warp", MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"), false, true, true); } - public static MPerm getPermSetwarp() { return getCreative(PRIORITY_SETWARP, ID_SETWARP, "setwarp", "set warps", MUtil.set("LEADER", "OFFICER"), false, true, true); } + public static MPerm getPermWarp() { return getCreative(PRIORITY_WARP, ID_WARP, ID_WARP, "teleport to warp", MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"), false, true, true); } + public static MPerm getPermSetwarp() { return getCreative(PRIORITY_SETWARP, ID_SETWARP, ID_SETWARP, "set warps", MUtil.set("LEADER", "OFFICER"), false, true, true); } public static MPerm getPermDeposit() { return getCreative(PRIORITY_DEPOSIT, ID_DEPOSIT, ID_DEPOSIT, "deposit money", MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY", "TRUCE", "NEUTRAL", "ENEMY"), false, false, false); } // non editable, non visible. public static MPerm getPermWithdraw() { return getCreative(PRIORITY_WITHDRAW, ID_WITHDRAW, ID_WITHDRAW, "withdraw money", MUtil.set("LEADER"), false, true, true); } public static MPerm getPermTerritory() { return getCreative(PRIORITY_TERRITORY, ID_TERRITORY, ID_TERRITORY, "claim or unclaim", MUtil.set("LEADER", "OFFICER"), false, true, true); } @@ -209,7 +209,6 @@ public class MPerm extends Entity implements Prioritized, Registerable, N public int version = 1; - // -------------------------------------------- // // FIELDS // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/MPermColl.java b/src/com/massivecraft/factions/entity/MPermColl.java index b092abd8..e0537408 100644 --- a/src/com/massivecraft/factions/entity/MPermColl.java +++ b/src/com/massivecraft/factions/entity/MPermColl.java @@ -1,9 +1,12 @@ package com.massivecraft.factions.entity; +import com.google.gson.JsonObject; import com.massivecraft.massivecore.store.Coll; +import com.massivecraft.massivecore.store.Modification; import java.util.ArrayList; import java.util.List; +import java.util.Map.Entry; public class MPermColl extends Coll { @@ -39,6 +42,45 @@ public class MPermColl extends Coll if (!active) return; MPerm.setupStandardPerms(); } + + private boolean initing = false; + + // Change the ids + @Override + public synchronized void loadFromRemoteFixed(String id, Entry remoteEntry) + { + boolean renamed = false; + if (initing) + { + if ("sethome".equalsIgnoreCase(id)) + { + id = "setwarp"; + renamed = true; + } + if ("home".equalsIgnoreCase(id)) + { + id = "home"; + renamed = true; + } + } + + super.loadFromRemoteFixed(id, remoteEntry); + if (renamed) + { + this.putIdentifiedModificationFixed(id, Modification.LOCAL_ATTACH); + this.syncIdFixed(id); + } + } + + @Override + public void initLoadAllFromRemote() + { + this.initing = true; + super.initLoadAllFromRemote(); + this.removeAtRemoteFixed("sethome"); + this.removeAtRemoteFixed("home"); + this.initing = false; + } // -------------------------------------------- // // EXTRAS