Rename sethome and home permissions

This commit is contained in:
Magnus Ulf 2019-02-17 11:09:10 +01:00
parent 994bf770e5
commit 32f52c1158
3 changed files with 47 additions and 7 deletions

View File

@ -157,8 +157,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// Null means default.
private MassiveMapDef<String, Boolean> flags = new MassiveMapDef<>();
// The perm overrides are modifications to the default values.
// Null means default.
private Map<String, Set<String>> perms = this.createNewPermMap();
// -------------------------------------------- //

View File

@ -46,8 +46,8 @@ public class MPerm extends Entity<MPerm> 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<MPerm> 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<MPerm> implements Prioritized, Registerable, N
public int version = 1;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //

View File

@ -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<MPerm>
{
@ -39,6 +42,45 @@ public class MPermColl extends Coll<MPerm>
if (!active) return;
MPerm.setupStandardPerms();
}
private boolean initing = false;
// Change the ids
@Override
public synchronized void loadFromRemoteFixed(String id, Entry<JsonObject, Long> 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