Loads of UPlayer --> MPlayer renames

This commit is contained in:
Olof Larsson
2014-09-17 13:29:58 +02:00
parent 529ae45ede
commit 0b60a5ad1a
43 changed files with 303 additions and 305 deletions

View File

@@ -99,7 +99,7 @@ public class Board extends Entity<Board> implements BoardInterface
{
if (ps == null) return null;
TerritoryAccess ta = this.getTerritoryAccessAt(ps);
return ta.getHostFaction(this);
return ta.getHostFaction();
}
// SET

View File

@@ -407,9 +407,9 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
return this.getInvitedPlayerIds().contains(playerId);
}
public boolean isInvited(MPlayer uplayer)
public boolean isInvited(MPlayer mplayer)
{
return this.isInvited(uplayer.getId());
return this.isInvited(mplayer.getId());
}
public boolean setInvited(String playerId, boolean invited)
@@ -429,9 +429,9 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
}
public void setInvited(MPlayer uplayer, boolean invited)
public void setInvited(MPlayer mplayer, boolean invited)
{
this.setInvited(uplayer.getId(), invited);
this.setInvited(mplayer.getId(), invited);
}
// -------------------------------------------- //
@@ -774,9 +774,9 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
if (this.getFlag(FFlag.INFPOWER)) return 999999;
double ret = 0;
for (MPlayer uplayer : this.getUPlayers())
for (MPlayer mplayer : this.getMPlayers())
{
ret += uplayer.getPower();
ret += mplayer.getPower();
}
double factionPowerMax = MConf.get().factionPowerMax;
@@ -795,9 +795,9 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
if (this.getFlag(FFlag.INFPOWER)) return 999999;
double ret = 0;
for (MPlayer uplayer : this.getUPlayers())
for (MPlayer mplayer : this.getMPlayers())
{
ret += uplayer.getPowerMax();
ret += mplayer.getPowerMax();
}
double factionPowerMax = MConf.get().factionPowerMax;
@@ -836,13 +836,13 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
}
// -------------------------------------------- //
// FOREIGN KEY: UPLAYER
// FOREIGN KEY: MPLAYER
// -------------------------------------------- //
protected transient List<MPlayer> uplayers = new ArrayList<MPlayer>();
public void reindexUPlayers()
protected transient List<MPlayer> mplayers = new ArrayList<MPlayer>();
public void reindexMPlayers()
{
this.uplayers.clear();
this.mplayers.clear();
String factionId = this.getId();
if (factionId == null) return;
@@ -850,42 +850,42 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
for (MPlayer mplayer : MPlayerColl.get().getAll())
{
if (!MUtil.equals(factionId, mplayer.getFactionId())) continue;
this.uplayers.add(mplayer);
this.mplayers.add(mplayer);
}
}
// TODO: Even though this check method removeds the invalid entries it's not a true solution.
// TODO: Find the bug causing non-attached UPlayers to be present in the index.
private void checkUPlayerIndex()
// TODO: Find the bug causing non-attached MPlayers to be present in the index.
private void checkMPlayerIndex()
{
Iterator<MPlayer> iter = this.uplayers.iterator();
Iterator<MPlayer> iter = this.mplayers.iterator();
while (iter.hasNext())
{
MPlayer uplayer = iter.next();
if (!uplayer.attached())
MPlayer mplayer = iter.next();
if (!mplayer.attached())
{
String msg = Txt.parse("<rose>WARN: <i>Faction <h>%s <i>aka <h>%s <i>had unattached uplayer in index:", this.getName(), this.getId());
String msg = Txt.parse("<rose>WARN: <i>Faction <h>%s <i>aka <h>%s <i>had unattached mplayer in index:", this.getName(), this.getId());
Factions.get().log(msg);
Factions.get().log(Factions.get().gson.toJson(uplayer));
Factions.get().log(Factions.get().gson.toJson(mplayer));
iter.remove();
}
}
}
public List<MPlayer> getUPlayers()
public List<MPlayer> getMPlayers()
{
this.checkUPlayerIndex();
return new ArrayList<MPlayer>(this.uplayers);
this.checkMPlayerIndex();
return new ArrayList<MPlayer>(this.mplayers);
}
public List<MPlayer> getUPlayersWhereOnline(boolean online)
public List<MPlayer> getMPlayersWhereOnline(boolean online)
{
List<MPlayer> ret = this.getUPlayers();
List<MPlayer> ret = this.getMPlayers();
Iterator<MPlayer> iter = ret.iterator();
while (iter.hasNext())
{
MPlayer uplayer = iter.next();
if (uplayer.isOnline() != online)
MPlayer mplayer = iter.next();
if (mplayer.isOnline() != online)
{
iter.remove();
}
@@ -893,14 +893,14 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
return ret;
}
public List<MPlayer> getUPlayersWhereRole(Rel role)
public List<MPlayer> getMPlayersWhereRole(Rel role)
{
List<MPlayer> ret = this.getUPlayers();
List<MPlayer> ret = this.getMPlayers();
Iterator<MPlayer> iter = ret.iterator();
while (iter.hasNext())
{
MPlayer uplayer = iter.next();
if (uplayer.getRole() != role)
MPlayer mplayer = iter.next();
if (mplayer.getRole() != role)
{
iter.remove();
}
@@ -910,14 +910,14 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public MPlayer getLeader()
{
List<MPlayer> ret = this.getUPlayers();
List<MPlayer> ret = this.getMPlayers();
Iterator<MPlayer> iter = ret.iterator();
while (iter.hasNext())
{
MPlayer uplayer = iter.next();
if (uplayer.getRole() == Rel.LEADER)
MPlayer mplayer = iter.next();
if (mplayer.getRole() == Rel.LEADER)
{
return uplayer;
return mplayer;
}
}
return null;
@@ -928,9 +928,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
List<CommandSender> ret = new ArrayList<CommandSender>();
for (CommandSender player : IdUtil.getOnlineSenders())
{
MPlayer uplayer = MPlayer.get(player);
if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue;
if (uplayer.getFaction() != this) continue;
MPlayer mplayer = MPlayer.get(player);
if (mplayer.getFaction() != this) continue;
ret.add(player);
}
return ret;
@@ -941,9 +940,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
List<Player> ret = new ArrayList<Player>();
for (Player player : Bukkit.getOnlinePlayers())
{
MPlayer uplayer = MPlayer.get(player);
if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue;
if (uplayer.getFaction() != this) continue;
MPlayer mplayer = MPlayer.get(player);
if (mplayer.getFaction() != this) continue;
ret.add(player);
}
return ret;
@@ -958,10 +956,10 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
MPlayer oldLeader = this.getLeader();
// get list of officers, or list of normal members if there are no officers
List<MPlayer> replacements = this.getUPlayersWhereRole(Rel.OFFICER);
List<MPlayer> replacements = this.getMPlayersWhereRole(Rel.OFFICER);
if (replacements == null || replacements.isEmpty())
{
replacements = this.getUPlayersWhereRole(Rel.MEMBER);
replacements = this.getMPlayersWhereRole(Rel.MEMBER);
}
if (replacements == null || replacements.isEmpty())
@@ -1007,19 +1005,19 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
// FACTION ONLINE STATE
// -------------------------------------------- //
public boolean isAllUPlayersOffline()
public boolean isAllMPlayersOffline()
{
return this.getUPlayersWhereOnline(true).size() == 0;
return this.getMPlayersWhereOnline(true).size() == 0;
}
public boolean isAnyUPlayersOnline()
public boolean isAnyMPlayersOnline()
{
return !this.isAllUPlayersOffline();
return !this.isAllMPlayersOffline();
}
public boolean isFactionConsideredOffline()
{
return this.isAllUPlayersOffline();
return this.isAllMPlayersOffline();
}
public boolean isFactionConsideredOnline()

View File

@@ -50,7 +50,7 @@ public class FactionColl extends Coll<Faction>
// Example Reason: When creating the special factions for the first time "createSpecialFactions" a clean would be triggered otherwise.
if (ret == null && Factions.get().isDatabaseInitialized())
{
String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and uplayers.", this.fixId(oid));
String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and mplayers.", this.fixId(oid));
Factions.get().log(message);
BoardColl.get().clean();
@@ -64,11 +64,11 @@ public class FactionColl extends Coll<Faction>
// INDEX
// -------------------------------------------- //
public void reindexUPlayers()
public void reindexMPlayers()
{
for (Faction faction : this.getAll())
{
faction.reindexUPlayers();
faction.reindexMPlayers();
}
}
@@ -199,7 +199,7 @@ public class FactionColl extends Coll<Faction>
int landCount = faction.getLandCount();
if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0)
{
List<MPlayer> players = faction.getUPlayers();
List<MPlayer> players = faction.getMPlayers();
int playerCount = players.size();
double reward = econLandReward * landCount / playerCount;
for (MPlayer player : players)
@@ -320,11 +320,11 @@ public class FactionColl extends Coll<Faction>
// INDEX
// -------------------------------------------- //
public void reindexUPlayers()
public void reindexMPlayers()
{
for (FactionColl coll : this.getColls())
{
coll.reindexUPlayers();
coll.reindexMPlayers();
}
}
*/

View File

@@ -77,7 +77,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
// ... update the index.
Faction faction = this.getFaction();
faction.uplayers.add(this);
faction.mplayers.add(this);
//Factions.get().log(Txt.parse("<g>postAttach added <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
}
@@ -90,7 +90,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
// ... update the index.
Faction faction = this.getFaction();
faction.uplayers.remove(this);
faction.mplayers.remove(this);
//Factions.get().log(Txt.parse("<b>preDetach removed <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
}
@@ -140,7 +140,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
// Null means false
private Boolean usingAdminMode = null;
// The id for the faction this uplayer is currently autoclaiming for.
// The id for the faction this player is currently autoclaiming for.
// NOTE: This field will not be saved to the database ever.
// Null means the player isn't auto claiming.
private transient Faction autoClaimFaction = null;
@@ -214,8 +214,8 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
Faction oldFaction = Faction.get(oldFactionId);
Faction faction = this.getFaction();
if (oldFaction != null) oldFaction.uplayers.remove(this);
if (faction != null) faction.uplayers.add(this);
if (oldFaction != null) oldFaction.mplayers.remove(this);
if (faction != null) faction.mplayers.add(this);
String oldFactionIdDesc = "NULL";
String oldFactionNameDesc = "NULL";
@@ -556,9 +556,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
{
return this.getNameAndTitle(this.getColorTo(faction).toString());
}
public String getNameAndTitle(MPlayer uplayer)
public String getNameAndTitle(MPlayer mplayer)
{
return this.getNameAndTitle(this.getColorTo(uplayer).toString());
return this.getNameAndTitle(this.getColorTo(mplayer).toString());
}
// -------------------------------------------- //
@@ -637,7 +637,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
boolean permanent = myFaction.getFlag(FFlag.PERMANENT);
if (myFaction.getUPlayers().size() > 1)
if (myFaction.getMPlayers().size() > 1)
{
if (!permanent && this.getRole() == Rel.LEADER)
{
@@ -659,9 +659,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
if (myFaction.isNormal())
{
for (MPlayer uplayer : myFaction.getUPlayersWhereOnline(true))
for (MPlayer mplayer : myFaction.getMPlayersWhereOnline(true))
{
uplayer.msg("%s<i> left %s<i>.", this.describeTo(uplayer, true), myFaction.describeTo(uplayer));
mplayer.msg("%s<i> left %s<i>.", this.describeTo(mplayer, true), myFaction.describeTo(mplayer));
}
if (MConf.get().logFactionLeave)
@@ -672,7 +672,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
this.resetFactionData();
if (myFaction.isNormal() && !permanent && myFaction.getUPlayers().isEmpty())
if (myFaction.isNormal() && !permanent && myFaction.getMPlayers().isEmpty())
{
// Remove this faction
for (MPlayer mplayer : MPlayerColl.get().getAllOnline())
@@ -717,7 +717,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
return false;
}
if (newFaction.getUPlayers().size() < mconf.claimsRequireMinFactionMembers)
if (newFaction.getMPlayers().size() < mconf.claimsRequireMinFactionMembers)
{
msg("Factions must have at least <h>%s<b> members to claim land.", mconf.claimsRequireMinFactionMembers);
return false;
@@ -804,11 +804,11 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
informees.add(this);
if (newFaction.isNormal())
{
informees.addAll(newFaction.getUPlayers());
informees.addAll(newFaction.getMPlayers());
}
if (oldFaction.isNormal())
{
informees.addAll(oldFaction.getUPlayers());
informees.addAll(oldFaction.getMPlayers());
}
if (MConf.get().logLandClaims)
{

View File

@@ -30,14 +30,14 @@ public class MPlayerColl extends SenderColl<MPlayer>
public void clean()
{
String universe = this.getUniverse();
for (MPlayer uplayer : this.getAll())
for (MPlayer mplayer : this.getAll())
{
String factionId = uplayer.getFactionId();
String factionId = mplayer.getFactionId();
if (FactionColl.get().containsId(factionId)) continue;
uplayer.resetFactionData();
mplayer.resetFactionData();
String message = Txt.parse("<i>Reset data for <h>%s <i>in <h>%s <i>universe. Unknown factionId <h>%s", uplayer.getDisplayName(IdUtil.getConsole()), universe, factionId);
String message = Txt.parse("<i>Reset data for <h>%s <i>in <h>%s <i>universe. Unknown factionId <h>%s", mplayer.getDisplayName(IdUtil.getConsole()), universe, factionId);
Factions.get().log(message);
}
}
@@ -49,31 +49,31 @@ public class MPlayerColl extends SenderColl<MPlayer>
long now = System.currentTimeMillis();
double toleranceMillis = MConf.get().removePlayerDataAfterInactiveDays * TimeUnit.MILLIS_PER_DAY;
for (MPlayer uplayer : this.getAll())
for (MPlayer mplayer : this.getAll())
{
Long lastPlayed = Mixin.getLastPlayed(uplayer.getId());
Long lastPlayed = Mixin.getLastPlayed(mplayer.getId());
if (lastPlayed == null) continue;
if (uplayer.isOnline()) continue;
if (mplayer.isOnline()) continue;
if (now - lastPlayed <= toleranceMillis) continue;
if (MConf.get().logFactionLeave || MConf.get().logFactionKick)
{
Factions.get().log("Player "+uplayer.getName()+" was auto-removed due to inactivity.");
Factions.get().log("Player "+mplayer.getName()+" was auto-removed due to inactivity.");
}
// if player is faction leader, sort out the faction since he's going away
if (uplayer.getRole() == Rel.LEADER)
if (mplayer.getRole() == Rel.LEADER)
{
Faction faction = uplayer.getFaction();
Faction faction = mplayer.getFaction();
if (faction != null)
{
uplayer.getFaction().promoteNewLeader();
mplayer.getFaction().promoteNewLeader();
}
}
uplayer.leave();
uplayer.detach();
mplayer.leave();
mplayer.detach();
}
}
@@ -89,18 +89,18 @@ public class MPlayerColl extends SenderColl<MPlayer>
if ( ! oldFile.exists()) return;
// Read the file content through GSON.
Type type = new TypeToken<Map<String, UPlayer>>(){}.getType();
Map<String, UPlayer> id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
Type type = new TypeToken<Map<String, MPlayer>>(){}.getType();
Map<String, MPlayer> id2mplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
// The Coll
UPlayerColl coll = this.getForUniverse(MassiveCore.DEFAULT);
MPlayerColl coll = this.getForUniverse(MassiveCore.DEFAULT);
// Set the data
for (Entry<String, UPlayer> entry : id2uplayer.entrySet())
for (Entry<String, MPlayer> entry : id2mplayer.entrySet())
{
String playerId = entry.getKey();
UPlayer uplayer = entry.getValue();
coll.attach(uplayer, playerId);
MPlayer mplayer = entry.getValue();
coll.attach(mplayer, playerId);
}
// Mark as migrated
@@ -113,7 +113,7 @@ public class MPlayerColl extends SenderColl<MPlayer>
public void clean()
{
for (UPlayerColl coll : this.getColls())
for (MPlayerColl coll : this.getColls())
{
coll.clean();
}