Remove Factions 1.8 update logic.
This commit is contained in:
parent
bdbc1c79a2
commit
2dfce5ea3a
@ -4,19 +4,6 @@ import org.bukkit.ChatColor;
|
|||||||
|
|
||||||
public class Const
|
public class Const
|
||||||
{
|
{
|
||||||
// Collections & Aspects
|
|
||||||
public static final String BASENAME = "factions";
|
|
||||||
public static final String BASENAME_ = BASENAME+"_";
|
|
||||||
|
|
||||||
public static final String COLLECTION_BOARD = BASENAME_+"board";
|
|
||||||
public static final String COLLECTION_FACTION = BASENAME_+"faction";
|
|
||||||
public static final String COLLECTION_MFLAG = BASENAME_+"mflag";
|
|
||||||
public static final String COLLECTION_MPERM = BASENAME_+"mperm";
|
|
||||||
public static final String COLLECTION_MPLAYER = BASENAME_+"mplayer";
|
|
||||||
public static final String COLLECTION_MCONF = BASENAME_+"mconf";
|
|
||||||
|
|
||||||
public static final String ASPECT = BASENAME;
|
|
||||||
|
|
||||||
// ASCII Map
|
// ASCII Map
|
||||||
public static final int MAP_WIDTH = 48;
|
public static final int MAP_WIDTH = 48;
|
||||||
public static final int MAP_HEIGHT = 8;
|
public static final int MAP_HEIGHT = 8;
|
||||||
@ -29,6 +16,8 @@ public class Const
|
|||||||
public static final String MAP_OVERFLOW_MESSAGE = MAP_KEY_OVERFLOW + ": Too Many Factions (>" + MAP_KEY_CHARS.length + ") on this Map.";
|
public static final String MAP_OVERFLOW_MESSAGE = MAP_KEY_OVERFLOW + ": Too Many Factions (>" + MAP_KEY_CHARS.length + ") on this Map.";
|
||||||
|
|
||||||
// SHOW
|
// SHOW
|
||||||
|
public static final String BASENAME = "factions";
|
||||||
|
public static final String BASENAME_ = BASENAME+"_";
|
||||||
|
|
||||||
public static final String SHOW_ID_FACTION_ID = BASENAME_ + "id";
|
public static final String SHOW_ID_FACTION_ID = BASENAME_ + "id";
|
||||||
public static final String SHOW_ID_FACTION_DESCRIPTION = BASENAME_ + "description";
|
public static final String SHOW_ID_FACTION_DESCRIPTION = BASENAME_ + "description";
|
||||||
|
@ -2,7 +2,6 @@ package com.massivecraft.factions;
|
|||||||
|
|
||||||
import com.massivecraft.factions.adapter.BoardAdapter;
|
import com.massivecraft.factions.adapter.BoardAdapter;
|
||||||
import com.massivecraft.factions.adapter.BoardMapAdapter;
|
import com.massivecraft.factions.adapter.BoardMapAdapter;
|
||||||
import com.massivecraft.factions.adapter.FactionPreprocessAdapter;
|
|
||||||
import com.massivecraft.factions.adapter.RelAdapter;
|
import com.massivecraft.factions.adapter.RelAdapter;
|
||||||
import com.massivecraft.factions.adapter.TerritoryAccessAdapter;
|
import com.massivecraft.factions.adapter.TerritoryAccessAdapter;
|
||||||
import com.massivecraft.factions.chat.modifier.ChatModifierLc;
|
import com.massivecraft.factions.chat.modifier.ChatModifierLc;
|
||||||
@ -45,7 +44,6 @@ import com.massivecraft.factions.engine.EngineTerritoryShield;
|
|||||||
import com.massivecraft.factions.engine.EngineVisualizations;
|
import com.massivecraft.factions.engine.EngineVisualizations;
|
||||||
import com.massivecraft.factions.entity.Board;
|
import com.massivecraft.factions.entity.Board;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColl;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
import com.massivecraft.factions.entity.FactionColl;
|
||||||
import com.massivecraft.factions.entity.MConfColl;
|
import com.massivecraft.factions.entity.MConfColl;
|
||||||
import com.massivecraft.factions.entity.MFlagColl;
|
import com.massivecraft.factions.entity.MFlagColl;
|
||||||
@ -62,14 +60,9 @@ import com.massivecraft.factions.task.TaskEconLandReward;
|
|||||||
import com.massivecraft.factions.task.TaskFlagPermCreate;
|
import com.massivecraft.factions.task.TaskFlagPermCreate;
|
||||||
import com.massivecraft.factions.task.TaskPlayerDataRemove;
|
import com.massivecraft.factions.task.TaskPlayerDataRemove;
|
||||||
import com.massivecraft.factions.task.TaskPlayerPowerUpdate;
|
import com.massivecraft.factions.task.TaskPlayerPowerUpdate;
|
||||||
import com.massivecraft.factions.update.UpdateUtil;
|
|
||||||
import com.massivecraft.massivecore.Aspect;
|
|
||||||
import com.massivecraft.massivecore.AspectColl;
|
|
||||||
import com.massivecraft.massivecore.MassivePlugin;
|
import com.massivecraft.massivecore.MassivePlugin;
|
||||||
import com.massivecraft.massivecore.Multiverse;
|
|
||||||
import com.massivecraft.massivecore.command.type.RegistryType;
|
import com.massivecraft.massivecore.command.type.RegistryType;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
import com.massivecraft.massivecore.xlib.gson.Gson;
|
|
||||||
import com.massivecraft.massivecore.xlib.gson.GsonBuilder;
|
import com.massivecraft.massivecore.xlib.gson.GsonBuilder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
@ -101,12 +94,6 @@ public class Factions extends MassivePlugin
|
|||||||
// FIELDS
|
// FIELDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// Aspects
|
|
||||||
// TODO: Remove in the future when the update has been removed.
|
|
||||||
private Aspect aspect;
|
|
||||||
public Aspect getAspect() { return this.aspect; }
|
|
||||||
public Multiverse getMultiverse() { return this.getAspect().getMultiverse(); }
|
|
||||||
|
|
||||||
// Database Initialized
|
// Database Initialized
|
||||||
private boolean databaseInitialized;
|
private boolean databaseInitialized;
|
||||||
public boolean isDatabaseInitialized() { return this.databaseInitialized; }
|
public boolean isDatabaseInitialized() { return this.databaseInitialized; }
|
||||||
@ -115,9 +102,6 @@ public class Factions extends MassivePlugin
|
|||||||
@Deprecated public PowerMixin getPowerMixin() { return PowerMixin.get(); }
|
@Deprecated public PowerMixin getPowerMixin() { return PowerMixin.get(); }
|
||||||
@Deprecated public void setPowerMixin(PowerMixin powerMixin) { PowerMixin.get().setInstance(powerMixin); }
|
@Deprecated public void setPowerMixin(PowerMixin powerMixin) { PowerMixin.get().setInstance(powerMixin); }
|
||||||
|
|
||||||
// Gson without preprocessors
|
|
||||||
public final Gson gsonWithoutPreprocessors = this.getGsonBuilderWithoutPreprocessors().create();
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -125,14 +109,6 @@ public class Factions extends MassivePlugin
|
|||||||
@Override
|
@Override
|
||||||
public void onEnableInner()
|
public void onEnableInner()
|
||||||
{
|
{
|
||||||
// Initialize Aspects
|
|
||||||
this.aspect = AspectColl.get().get(Const.ASPECT, true);
|
|
||||||
this.aspect.register();
|
|
||||||
this.aspect.setDesc(
|
|
||||||
"<i>If the factions system even is enabled and how it's configured.",
|
|
||||||
"<i>What factions exists and what players belong to them."
|
|
||||||
);
|
|
||||||
|
|
||||||
// Register types
|
// Register types
|
||||||
RegistryType.register(Rel.class, TypeRel.get());
|
RegistryType.register(Rel.class, TypeRel.get());
|
||||||
RegistryType.register(EventFactionsChunkChangeType.class, TypeFactionChunkChangeType.get());
|
RegistryType.register(EventFactionsChunkChangeType.class, TypeFactionChunkChangeType.get());
|
||||||
@ -143,19 +119,16 @@ public class Factions extends MassivePlugin
|
|||||||
|
|
||||||
// Initialize Database
|
// Initialize Database
|
||||||
this.databaseInitialized = false;
|
this.databaseInitialized = false;
|
||||||
|
|
||||||
MFlagColl.get().setActive(true);
|
MFlagColl.get().setActive(true);
|
||||||
MPermColl.get().setActive(true);
|
MPermColl.get().setActive(true);
|
||||||
MConfColl.get().setActive(true);
|
MConfColl.get().setActive(true);
|
||||||
|
|
||||||
UpdateUtil.update();
|
|
||||||
|
|
||||||
MPlayerColl.get().setActive(true);
|
MPlayerColl.get().setActive(true);
|
||||||
FactionColl.get().setActive(true);
|
FactionColl.get().setActive(true);
|
||||||
BoardColl.get().setActive(true);
|
BoardColl.get().setActive(true);
|
||||||
|
|
||||||
UpdateUtil.updateSpecialIds();
|
|
||||||
|
|
||||||
FactionColl.get().reindexMPlayers();
|
FactionColl.get().reindexMPlayers();
|
||||||
|
|
||||||
this.databaseInitialized = true;
|
this.databaseInitialized = true;
|
||||||
|
|
||||||
// Activate
|
// Activate
|
||||||
@ -221,7 +194,8 @@ public class Factions extends MassivePlugin
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GsonBuilder getGsonBuilderWithoutPreprocessors()
|
@Override
|
||||||
|
public GsonBuilder getGsonBuilder()
|
||||||
{
|
{
|
||||||
return super.getGsonBuilder()
|
return super.getGsonBuilder()
|
||||||
.registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get())
|
.registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get())
|
||||||
@ -231,12 +205,4 @@ public class Factions extends MassivePlugin
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public GsonBuilder getGsonBuilder()
|
|
||||||
{
|
|
||||||
return this.getGsonBuilderWithoutPreprocessors()
|
|
||||||
.registerTypeAdapter(Faction.class, FactionPreprocessAdapter.get())
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
package com.massivecraft.factions.adapter;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
|
|
||||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
|
|
||||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
|
|
||||||
import com.massivecraft.massivecore.xlib.gson.JsonObject;
|
|
||||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
public class FactionPreprocessAdapter implements JsonDeserializer<Faction>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static FactionPreprocessAdapter i = new FactionPreprocessAdapter();
|
|
||||||
public static FactionPreprocessAdapter get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Faction deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
preprocess(json);
|
|
||||||
return Factions.get().gsonWithoutPreprocessors.fromJson(json, typeOfT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void preprocess(JsonElement json)
|
|
||||||
{
|
|
||||||
JsonObject jsonObject = json.getAsJsonObject();
|
|
||||||
|
|
||||||
// Renamed fields
|
|
||||||
// 1.8.X --> 2.0.0
|
|
||||||
rename(jsonObject, "tag", "name");
|
|
||||||
rename(jsonObject, "invites", "invitedPlayerIds");
|
|
||||||
rename(jsonObject, "relationWish", "relationWishes");
|
|
||||||
rename(jsonObject, "flagOverrides", "flags");
|
|
||||||
rename(jsonObject, "permOverrides", "perms");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UTIL
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static void rename(final JsonObject jsonObject, final String from, final String to)
|
|
||||||
{
|
|
||||||
JsonElement element = jsonObject.remove(from);
|
|
||||||
if (element != null) jsonObject.add(to, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,222 +0,0 @@
|
|||||||
package com.massivecraft.factions.update;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Rel;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class OldConf extends Entity<OldConf>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// META
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public void transferTo(MConf mconf)
|
|
||||||
{
|
|
||||||
//mconf.enabled = this.enabled;
|
|
||||||
mconf.factionIdNone = this.factionIdNone;
|
|
||||||
mconf.factionIdSafezone = this.factionIdSafezone;
|
|
||||||
mconf.factionIdWarzone = this.factionIdWarzone;
|
|
||||||
mconf.defaultPlayerFactionId = this.defaultPlayerFactionId;
|
|
||||||
mconf.defaultPlayerRole = this.defaultPlayerRole;
|
|
||||||
mconf.defaultPlayerPower = this.defaultPlayerPower;
|
|
||||||
//mconf.defaultFactionOpen = this.defaultFactionOpen;
|
|
||||||
//mconf.defaultFactionFlags = this.defaultFactionFlags;
|
|
||||||
//mconf.defaultFactionPerms = this.defaultFactionPerms;
|
|
||||||
mconf.powerMax = this.powerMax;
|
|
||||||
mconf.powerMin = this.powerMin;
|
|
||||||
mconf.powerPerHour = this.powerPerHour;
|
|
||||||
mconf.powerPerDeath = this.powerPerDeath;
|
|
||||||
mconf.canLeaveWithNegativePower = this.canLeaveWithNegativePower;
|
|
||||||
mconf.factionMemberLimit = this.factionMemberLimit;
|
|
||||||
mconf.factionPowerMax = this.factionPowerMax;
|
|
||||||
mconf.factionNameLengthMin = this.factionNameLengthMin;
|
|
||||||
mconf.factionNameLengthMax = this.factionNameLengthMax;
|
|
||||||
mconf.factionNameForceUpperCase = this.factionNameForceUpperCase;
|
|
||||||
mconf.claimsMustBeConnected = this.claimsMustBeConnected;
|
|
||||||
mconf.claimingFromOthersAllowed = this.claimingFromOthersAllowed;
|
|
||||||
mconf.claimsCanBeUnconnectedIfOwnedByOtherFaction = this.claimsCanBeUnconnectedIfOwnedByOtherFaction;
|
|
||||||
mconf.claimsRequireMinFactionMembers = this.claimsRequireMinFactionMembers;
|
|
||||||
mconf.claimedLandsMax = this.claimedLandsMax;
|
|
||||||
mconf.homesEnabled = this.homesEnabled;
|
|
||||||
mconf.homesMustBeInClaimedTerritory = this.homesMustBeInClaimedTerritory;
|
|
||||||
mconf.homesTeleportCommandEnabled = this.homesTeleportCommandEnabled;
|
|
||||||
mconf.homesTeleportAllowedFromEnemyTerritory = this.homesTeleportAllowedFromEnemyTerritory;
|
|
||||||
mconf.homesTeleportAllowedFromDifferentWorld = this.homesTeleportAllowedFromDifferentWorld;
|
|
||||||
mconf.homesTeleportAllowedEnemyDistance = this.homesTeleportAllowedEnemyDistance;
|
|
||||||
mconf.homesTeleportIgnoreEnemiesIfInOwnTerritory = this.homesTeleportIgnoreEnemiesIfInOwnTerritory;
|
|
||||||
mconf.homesTeleportToOnDeathActive = this.homesTeleportToOnDeathActive;
|
|
||||||
mconf.homesTeleportToOnDeathPriority = this.homesTeleportToOnDeathPriority;
|
|
||||||
mconf.permanentFactionsDisableLeaderPromotion = this.permanentFactionsDisableLeaderPromotion;
|
|
||||||
mconf.actionDeniedPainAmount = this.actionDeniedPainAmount;
|
|
||||||
mconf.disablePVPForFactionlessPlayers = this.disablePVPForFactionlessPlayers;
|
|
||||||
mconf.enablePVPAgainstFactionlessInAttackersLand = this.enablePVPAgainstFactionlessInAttackersLand;
|
|
||||||
mconf.territoryShieldFactor = this.territoryShieldFactor;
|
|
||||||
mconf.denyCommandsPermanentFactionMember = this.denyCommandsPermanentFactionMember;
|
|
||||||
mconf.denyCommandsTerritoryRelation = this.denyCommandsTerritoryRelation;
|
|
||||||
mconf.lwcRemoveOnChange = this.lwcRemoveOnChange;
|
|
||||||
mconf.econEnabled = this.econEnabled;
|
|
||||||
mconf.econLandReward = this.econLandReward;
|
|
||||||
mconf.econUniverseAccount = this.econUniverseAccount;
|
|
||||||
mconf.econChunkCost = this.econChunkCost;
|
|
||||||
mconf.econCostCreate = this.econCostCreate;
|
|
||||||
mconf.econCostSethome = this.econCostSethome;
|
|
||||||
mconf.econCostJoin = this.econCostJoin;
|
|
||||||
mconf.econCostLeave = this.econCostLeave;
|
|
||||||
mconf.econCostKick = this.econCostKick;
|
|
||||||
mconf.econCostInvite = this.econCostInvite;
|
|
||||||
mconf.econCostDeinvite = this.econCostDeinvite;
|
|
||||||
mconf.econCostHome = this.econCostHome;
|
|
||||||
mconf.econCostName = this.econCostName;
|
|
||||||
mconf.econCostDescription = this.econCostDescription;
|
|
||||||
mconf.econCostTitle = this.econCostTitle;
|
|
||||||
mconf.econCostFlag = this.econCostOpen;
|
|
||||||
mconf.econRelCost = this.econRelCost;
|
|
||||||
mconf.bankEnabled = this.bankEnabled;
|
|
||||||
mconf.bankFactionPaysCosts = this.bankFactionPaysCosts;
|
|
||||||
mconf.bankFactionPaysLandCosts = this.bankFactionPaysLandCosts;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UNIVERSE ENABLE SWITCH
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean enabled = true;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// SPECIAL FACTION IDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public String factionIdNone = null;
|
|
||||||
public String factionIdSafezone = null;
|
|
||||||
public String factionIdWarzone = null;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// DEFAULTS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public String defaultPlayerFactionId = null;
|
|
||||||
public Rel defaultPlayerRole = null;
|
|
||||||
public double defaultPlayerPower = 0.0;
|
|
||||||
|
|
||||||
//public boolean defaultFactionOpen = false;
|
|
||||||
//public Map<FFlag, Boolean> defaultFactionFlags = null;
|
|
||||||
//public Map<FPerm, Set<Rel>> defaultFactionPerms = null;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// MESSAGES
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean broadcastNameChange = false;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// POWER
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public double powerMax = 10.0;
|
|
||||||
public double powerMin = 0.0;
|
|
||||||
public double powerPerHour = 2.0;
|
|
||||||
public double powerPerDeath = -2.0;
|
|
||||||
|
|
||||||
public boolean canLeaveWithNegativePower = true;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CORE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public int factionMemberLimit = 0;
|
|
||||||
public double factionPowerMax = 0.0;
|
|
||||||
|
|
||||||
public int factionNameLengthMin = 3;
|
|
||||||
public int factionNameLengthMax = 16;
|
|
||||||
public boolean factionNameForceUpperCase = false;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CLAIMS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean claimsMustBeConnected = true;
|
|
||||||
public boolean claimingFromOthersAllowed = true;
|
|
||||||
public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false;
|
|
||||||
public int claimsRequireMinFactionMembers = 1;
|
|
||||||
public int claimedLandsMax = 0;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// HOMES
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean homesEnabled = true;
|
|
||||||
public boolean homesMustBeInClaimedTerritory = true;
|
|
||||||
public boolean homesTeleportCommandEnabled = true;
|
|
||||||
public boolean homesTeleportAllowedFromEnemyTerritory = true;
|
|
||||||
public boolean homesTeleportAllowedFromDifferentWorld = true;
|
|
||||||
public double homesTeleportAllowedEnemyDistance = 32.0;
|
|
||||||
public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
|
|
||||||
|
|
||||||
public boolean homesTeleportToOnDeathActive = false;
|
|
||||||
public EventPriority homesTeleportToOnDeathPriority = null;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ASSORTED
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean permanentFactionsDisableLeaderPromotion = false;
|
|
||||||
public double actionDeniedPainAmount = 2.0D;
|
|
||||||
public boolean disablePVPForFactionlessPlayers = false;
|
|
||||||
public boolean enablePVPAgainstFactionlessInAttackersLand = false;
|
|
||||||
public double territoryShieldFactor = 0.3D;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// DENY COMMANDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// commands which will be prevented if the player is a member of a permanent faction
|
|
||||||
public List<String> denyCommandsPermanentFactionMember = null;
|
|
||||||
|
|
||||||
// commands which will be prevented when in claimed territory of another faction
|
|
||||||
public Map<Rel, List<String>> denyCommandsTerritoryRelation = null;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INTEGRATION: LWC
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public Map<EventFactionsChunkChangeType, Boolean> lwcRemoveOnChange = null;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INTEGRATION: ECONOMY
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean econEnabled = false;
|
|
||||||
|
|
||||||
// TODO: Rename to include unit.
|
|
||||||
public double econLandReward = 0.00;
|
|
||||||
|
|
||||||
public String econUniverseAccount = null;
|
|
||||||
|
|
||||||
public Map<EventFactionsChunkChangeType, Double> econChunkCost = null;
|
|
||||||
|
|
||||||
public double econCostCreate = 200.0;
|
|
||||||
public double econCostSethome = 0.0;
|
|
||||||
public double econCostJoin = 0.0;
|
|
||||||
public double econCostLeave = 0.0;
|
|
||||||
public double econCostKick = 0.0;
|
|
||||||
public double econCostInvite = 0.0;
|
|
||||||
public double econCostDeinvite = 0.0;
|
|
||||||
public double econCostHome = 0.0;
|
|
||||||
public double econCostName = 0.0;
|
|
||||||
public double econCostDescription = 0.0;
|
|
||||||
public double econCostTitle = 0.0;
|
|
||||||
public double econCostOpen = 0.0;
|
|
||||||
|
|
||||||
public Map<Rel, Double> econRelCost = null;
|
|
||||||
|
|
||||||
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
|
|
||||||
public boolean bankEnabled = true;
|
|
||||||
//public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
|
|
||||||
public boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
|
|
||||||
public boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.massivecraft.factions.update;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveCore;
|
|
||||||
import com.massivecraft.massivecore.store.Coll;
|
|
||||||
|
|
||||||
public class OldConfColl extends Coll<OldConf>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public OldConfColl(String id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive(boolean active)
|
|
||||||
{
|
|
||||||
super.setActive(active);
|
|
||||||
if ( ! active) return;
|
|
||||||
this.get(MassiveCore.INSTANCE, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
package com.massivecraft.factions.update;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.massivecore.Aspect;
|
|
||||||
import com.massivecraft.massivecore.MassiveCore;
|
|
||||||
import com.massivecraft.massivecore.store.Colls;
|
|
||||||
|
|
||||||
public class OldConfColls extends Colls<OldConfColl, OldConf>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static OldConfColls i = new OldConfColls();
|
|
||||||
public static OldConfColls get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE: COLLS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OldConfColl createColl(String collName)
|
|
||||||
{
|
|
||||||
return new OldConfColl(collName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Aspect getAspect()
|
|
||||||
{
|
|
||||||
return Factions.get().getAspect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBasename()
|
|
||||||
{
|
|
||||||
return "factions_uconf";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OldConf get2(Object worldNameExtractable)
|
|
||||||
{
|
|
||||||
OldConfColl coll = this.get(worldNameExtractable);
|
|
||||||
if (coll == null) return null;
|
|
||||||
return coll.get(MassiveCore.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,258 +0,0 @@
|
|||||||
package com.massivecraft.factions.update;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Const;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
|
||||||
import com.massivecraft.factions.entity.Board;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveCore;
|
|
||||||
import com.massivecraft.massivecore.store.Coll;
|
|
||||||
import com.massivecraft.massivecore.store.Db;
|
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
|
||||||
import com.massivecraft.massivecore.store.MStore;
|
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class UpdateUtil
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTANTS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static final List<String> oldCollnamePrefixes = MUtil.list(
|
|
||||||
"factions_board@",
|
|
||||||
"factions_faction@",
|
|
||||||
"factions_uplayer@",
|
|
||||||
"factions_uconf@"
|
|
||||||
);
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UPDATE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// Assumes the MConfColl has been inited!
|
|
||||||
|
|
||||||
public static void update()
|
|
||||||
{
|
|
||||||
// Select the old universe of our attention ...
|
|
||||||
String universe = getUniverse();
|
|
||||||
if (universe == null) return;
|
|
||||||
|
|
||||||
Factions.get().log("Updating Database to New Version!");
|
|
||||||
|
|
||||||
// ... load the old uconf data ...
|
|
||||||
OldConfColls.get().setActive(true);
|
|
||||||
OldConf oldConf = OldConfColls.get().getForUniverse(universe).get(MassiveCore.INSTANCE, true);
|
|
||||||
|
|
||||||
// ... transfer the old uconf data over to the new mconf ...
|
|
||||||
oldConf.transferTo(MConf.get());
|
|
||||||
MConf.get().changed();
|
|
||||||
MConf.get().sync();
|
|
||||||
|
|
||||||
// ... rename target collections ...
|
|
||||||
Db db = MStore.getDb();
|
|
||||||
|
|
||||||
// The old mplayer data we don't care much for.
|
|
||||||
// Could even delete it but let's just move it out of the way.
|
|
||||||
db.renameColl(Const.COLLECTION_MPLAYER, "old_"+Const.COLLECTION_MPLAYER);
|
|
||||||
|
|
||||||
db.renameColl("factions_board@" + universe, Const.COLLECTION_BOARD);
|
|
||||||
db.renameColl("factions_faction@" + universe, Const.COLLECTION_FACTION);
|
|
||||||
db.renameColl("factions_uplayer@" + universe, Const.COLLECTION_MPLAYER);
|
|
||||||
|
|
||||||
// ... rename remaining collections ...
|
|
||||||
for (String collname : db.getCollnames())
|
|
||||||
{
|
|
||||||
if (!collname.startsWith("factions_")) continue;
|
|
||||||
if (!collname.contains("@")) continue;
|
|
||||||
db.renameColl(collname, "old_" + collname);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UNIVERSE SELECTION
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static String getUniverse()
|
|
||||||
{
|
|
||||||
List<String> universes = getUniverses();
|
|
||||||
|
|
||||||
String ret = null;
|
|
||||||
int best = -1;
|
|
||||||
|
|
||||||
for (String universe : universes)
|
|
||||||
{
|
|
||||||
int count = getUniverseFactionCount(universe);
|
|
||||||
if (count > 0 && count > best)
|
|
||||||
{
|
|
||||||
ret = universe;
|
|
||||||
best = count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
||||||
public static int getUniverseFactionCount(String universe)
|
|
||||||
{
|
|
||||||
Coll coll = new Coll("factions_faction@"+universe, Entity.class, MStore.getDb(), Factions.get());
|
|
||||||
|
|
||||||
Collection<String> ids = MStore.getDb().getIds(coll);
|
|
||||||
|
|
||||||
return ids.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getUniverses()
|
|
||||||
{
|
|
||||||
List<String> ret = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String collname : MStore.getDb().getCollnames())
|
|
||||||
{
|
|
||||||
for (String prefix : oldCollnamePrefixes)
|
|
||||||
{
|
|
||||||
if (collname.startsWith(prefix))
|
|
||||||
{
|
|
||||||
ret.add(collname.substring(prefix.length()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UPDATE SPECIAL IDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static void updateSpecialIds()
|
|
||||||
{
|
|
||||||
if (MConf.get().factionIdNone != null)
|
|
||||||
{
|
|
||||||
updateSpecialId(MConf.get().factionIdNone, Factions.ID_NONE);
|
|
||||||
MConf.get().factionIdNone = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MConf.get().factionIdSafezone != null)
|
|
||||||
{
|
|
||||||
updateSpecialId(MConf.get().factionIdSafezone, Factions.ID_SAFEZONE);
|
|
||||||
MConf.get().factionIdSafezone = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MConf.get().factionIdWarzone != null)
|
|
||||||
{
|
|
||||||
updateSpecialId(MConf.get().factionIdWarzone, Factions.ID_WARZONE);
|
|
||||||
MConf.get().factionIdWarzone = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
MConf.get().sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateSpecialId(String from, String to)
|
|
||||||
{
|
|
||||||
// Get the coll.
|
|
||||||
FactionColl coll = FactionColl.get();
|
|
||||||
|
|
||||||
// Get the faction and detach it
|
|
||||||
Faction faction = coll.detachId(from);
|
|
||||||
if (faction == null) return;
|
|
||||||
coll.syncId(from);
|
|
||||||
|
|
||||||
// A faction may already be occupying the to-id.
|
|
||||||
// We must remove it to make space for renaming.
|
|
||||||
// This faction is simply an auto-created faction with no references yet.
|
|
||||||
coll.detachId(to);
|
|
||||||
coll.syncId(to);
|
|
||||||
|
|
||||||
// Attach it
|
|
||||||
coll.attach(faction, to);
|
|
||||||
coll.syncId(to);
|
|
||||||
|
|
||||||
// Update that config special config option.
|
|
||||||
if (MConf.get().defaultPlayerFactionId.equals(from))
|
|
||||||
{
|
|
||||||
MConf.get().defaultPlayerFactionId = to;
|
|
||||||
MConf.get().sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update all board entries.
|
|
||||||
updateBoards(from, to);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateBoards(String from, String to)
|
|
||||||
{
|
|
||||||
for (Board board : BoardColl.get().getAll())
|
|
||||||
{
|
|
||||||
updateBoard(board, from, to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateBoard(Board board, String from, String to)
|
|
||||||
{
|
|
||||||
boolean changed = false;
|
|
||||||
for (TerritoryAccess ta : board.getMap().values())
|
|
||||||
{
|
|
||||||
changed |= updateTerritoryAccess(ta, from, to);
|
|
||||||
}
|
|
||||||
if (changed)
|
|
||||||
{
|
|
||||||
board.changed();
|
|
||||||
board.sync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean updateTerritoryAccess(TerritoryAccess entity, String from, String to)
|
|
||||||
{
|
|
||||||
boolean changed = false;
|
|
||||||
changed |= updateTerritoryHostFactionId(entity, from, to);
|
|
||||||
changed |= updateTerritoryAccessFactionIds(entity, from, to);
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean updateTerritoryHostFactionId(TerritoryAccess entity, String from, String to)
|
|
||||||
{
|
|
||||||
String before = entity.hostFactionId;
|
|
||||||
if (before == null) return false;
|
|
||||||
if (!before.equals(from)) return false;
|
|
||||||
|
|
||||||
entity.hostFactionId = to;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean updateTerritoryAccessFactionIds(TerritoryAccess entity, String from, String to)
|
|
||||||
{
|
|
||||||
// Before and After
|
|
||||||
Set<String> before = entity.factionIds;
|
|
||||||
if (before == null) return false;
|
|
||||||
Set<String> after = new LinkedHashSet<>();
|
|
||||||
for (String id : before)
|
|
||||||
{
|
|
||||||
if (id == null) continue;
|
|
||||||
if (id.equals(from))
|
|
||||||
{
|
|
||||||
after.add(to);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
after.add(from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NoChange
|
|
||||||
if (MUtil.equals(before, after)) return false;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
entity.factionIds = after;
|
|
||||||
//entity.sync();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user