Convert factions properly

This commit is contained in:
Magnus Ulf 2019-03-05 17:14:02 +01:00
parent 7961202809
commit c38181e5e9
4 changed files with 46 additions and 4 deletions

View File

@ -55,6 +55,7 @@ import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.entity.migrator.MigratorFaction001Invitations;
import com.massivecraft.factions.entity.migrator.MigratorFaction002Ranks;
import com.massivecraft.factions.entity.migrator.MigratorFaction003Warps;
import com.massivecraft.factions.entity.migrator.MigratorFaction004WarpsPerms;
import com.massivecraft.factions.entity.migrator.MigratorMConf001EnumerationUtil;
import com.massivecraft.factions.entity.migrator.MigratorMConf002CleanInactivity;
import com.massivecraft.factions.entity.migrator.MigratorMConf003CleanInactivity;
@ -145,6 +146,7 @@ public class Factions extends MassivePlugin
MigratorFaction001Invitations.class,
MigratorFaction002Ranks.class,
MigratorFaction003Warps.class,
MigratorFaction004WarpsPerms.class,
MigratorMConf001EnumerationUtil.class,
MigratorMConf002CleanInactivity.class,
MigratorMConf003CleanInactivity.class,

View File

@ -102,7 +102,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// VERSION
// -------------------------------------------- //
public int version = 3;
public int version = 4;
// -------------------------------------------- //
// FIELDS: RAW

View File

@ -3,9 +3,9 @@ package com.massivecraft.factions.entity;
import com.massivecraft.massivecore.store.EntityInternal;
import com.massivecraft.massivecore.store.EntityInternalMap;
import com.massivecraft.massivecore.util.Txt;
import org.apache.commons.lang.ObjectUtils.Null;
import org.bukkit.ChatColor;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
@ -28,10 +28,10 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable
{
for (Faction f : FactionColl.get().getAll())
{
for (Iterator<Entry<String, Set<String>>> it = f.getPerms().entrySet().iterator(); it.hasNext();)
for (Entry<String, Set<String>> entry : f.getPerms().entrySet())
{
Entry<String, Set<String>> entry = it.next();
Set<String> value = entry.getValue();
if (value == null) throw new NullPointerException(entry.getKey());
value.remove(id);
}
}

View File

@ -0,0 +1,40 @@
package com.massivecraft.factions.entity.migrator;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.store.migrator.MigratorRoot;
public class MigratorFaction004WarpsPerms extends MigratorRoot
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static MigratorFaction004WarpsPerms i = new MigratorFaction004WarpsPerms();
public static MigratorFaction004WarpsPerms get() { return i; }
private MigratorFaction004WarpsPerms()
{
super(Faction.class);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void migrateInner(JsonObject entity)
{
JsonElement perms = entity.get("perms");
if (perms == null || perms.isJsonNull() || !perms.isJsonObject()) return;
JsonObject permsO = perms.getAsJsonObject();
JsonElement home = permsO.remove("home");
if (home != null) permsO.add("warp", home);
JsonElement sethome = permsO.remove("sethome");
if (home != null) permsO.add("setwarp", home);
}
}