Some minor changes before making bigger ones.
This commit is contained in:
parent
ea7d0f8305
commit
7693ac2010
@ -22,24 +22,49 @@ import com.massivecraft.mcore.ps.PS;
|
|||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logged in players always have exactly one FPlayer instance.
|
|
||||||
* Logged out players may or may not have an FPlayer instance. They will always have one if they are part of a faction.
|
|
||||||
* This is because only players with a faction are saved to disk (in order to not waste disk space).
|
|
||||||
*
|
|
||||||
* The FPlayer is linked to a minecraft player using the player name.
|
|
||||||
*
|
|
||||||
* The same instance is always returned for the same player.
|
|
||||||
* This means you can use the == operator. No .equals method necessary.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: The players are saved in non order.
|
|
||||||
public class FPlayer extends PlayerEntity implements EconomyParticipator
|
public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||||
{
|
{
|
||||||
// FIELD: lastStoodAt
|
// -------------------------------------------- //
|
||||||
|
// PERSISTANCE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldBeSaved()
|
||||||
|
{
|
||||||
|
if (this.hasFaction()) return true;
|
||||||
|
if (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(ConfServer.powerPlayerStarting)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This stuff from the economy participator interface... will it clash with the built in one from the MCore player entity?
|
||||||
|
public void msg(String str, Object... args)
|
||||||
|
{
|
||||||
|
this.sendMessage(Txt.parse(str, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE: ENTITY
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
public FPlayer load(FPlayer that)
|
||||||
|
{
|
||||||
|
this.factionId = that.factionId;
|
||||||
|
this.role = that.role;
|
||||||
|
this.title = that.title;
|
||||||
|
this.power = that.power;
|
||||||
|
this.powerBoost = that.powerBoost;
|
||||||
|
this.lastPowerUpdateTime = that.lastPowerUpdateTime;
|
||||||
|
this.lastLoginTime = that.lastLoginTime;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FIELDS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// Where did this player stand the last time we checked?
|
// Where did this player stand the last time we checked?
|
||||||
// This is a "chunk".
|
|
||||||
// Rename to "currentChunk"?
|
|
||||||
private transient PS currentChunk = null;
|
private transient PS currentChunk = null;
|
||||||
public PS getCurrentChunk() { return this.currentChunk; }
|
public PS getCurrentChunk() { return this.currentChunk; }
|
||||||
public void setCurrentChunk(PS currentChunk) { this.currentChunk = currentChunk.getChunk(true); }
|
public void setCurrentChunk(PS currentChunk) { this.currentChunk = currentChunk.getChunk(true); }
|
||||||
@ -190,9 +215,10 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
// -------------------------------------------- //
|
||||||
// TITLE, NAME, FACTION TAG AND CHAT
|
// TITLE, NAME, FACTION TAG AND CHAT
|
||||||
//----------------------------------------------//
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return getId();
|
return getId();
|
||||||
@ -273,9 +299,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
return this.getColorTo(fplayer)+getChatTag();
|
return this.getColorTo(fplayer)+getChatTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------------------- //
|
||||||
// RELATION AND RELATION COLORS
|
// RELATION AND RELATION COLORS
|
||||||
// -------------------------------
|
// -------------------------------------------- //
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describeTo(RelationParticipator observer, boolean ucfirst)
|
public String describeTo(RelationParticipator observer, boolean ucfirst)
|
||||||
@ -313,9 +339,10 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
return RelationUtil.getColorOfThatToMe(this, observer);
|
return RelationUtil.getColorOfThatToMe(this, observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
// -------------------------------------------- //
|
||||||
// HEALTH
|
// HEALTH
|
||||||
//----------------------------------------------//
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void heal(int amnt)
|
public void heal(int amnt)
|
||||||
{
|
{
|
||||||
Player player = this.getPlayer();
|
Player player = this.getPlayer();
|
||||||
@ -326,10 +353,10 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
player.setHealth(player.getHealth() + amnt);
|
player.setHealth(player.getHealth() + amnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
//----------------------------------------------//
|
|
||||||
// POWER
|
// POWER
|
||||||
//----------------------------------------------//
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public double getPower()
|
public double getPower()
|
||||||
{
|
{
|
||||||
this.updatePower();
|
this.updatePower();
|
||||||
@ -420,9 +447,10 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
this.alterPower(-ConfServer.powerPerDeath);
|
this.alterPower(-ConfServer.powerPerDeath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
// -------------------------------------------- //
|
||||||
// TERRITORY
|
// TERRITORY
|
||||||
//----------------------------------------------//
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public boolean isInOwnTerritory()
|
public boolean isInOwnTerritory()
|
||||||
{
|
{
|
||||||
// TODO: Use Mixin to get this PS instead
|
// TODO: Use Mixin to get this PS instead
|
||||||
@ -450,9 +478,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
this.sendMessage(msg);
|
this.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------------------- //
|
||||||
// ACTIONS
|
// ACTIONS
|
||||||
// -------------------------------
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void leave(boolean makePay)
|
public void leave(boolean makePay)
|
||||||
{
|
{
|
||||||
@ -668,20 +696,4 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// PERSISTANCE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldBeSaved()
|
|
||||||
{
|
|
||||||
if (this.hasFaction()) return true;
|
|
||||||
if (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(ConfServer.powerPlayerStarting)) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void msg(String str, Object... args)
|
|
||||||
{
|
|
||||||
this.sendMessage(Txt.parse(str, args));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ public class FactionColl extends EntityCollection<Faction>
|
|||||||
Faction faction = this.create("0");
|
Faction faction = this.create("0");
|
||||||
faction.setTag(ChatColor.DARK_GREEN+"Wilderness");
|
faction.setTag(ChatColor.DARK_GREEN+"Wilderness");
|
||||||
faction.setDescription("");
|
faction.setDescription("");
|
||||||
this.setFlagsForWilderness(faction);
|
|
||||||
|
setFlagsForWilderness(faction);
|
||||||
}
|
}
|
||||||
if ( ! this.exists("-1"))
|
if ( ! this.exists("-1"))
|
||||||
{
|
{
|
||||||
@ -65,14 +66,15 @@ public class FactionColl extends EntityCollection<Faction>
|
|||||||
faction.setTag("SafeZone");
|
faction.setTag("SafeZone");
|
||||||
faction.setDescription("Free from PVP and monsters");
|
faction.setDescription("Free from PVP and monsters");
|
||||||
|
|
||||||
this.setFlagsForSafeZone(faction);
|
setFlagsForSafeZone(faction);
|
||||||
}
|
}
|
||||||
if ( ! this.exists("-2"))
|
if ( ! this.exists("-2"))
|
||||||
{
|
{
|
||||||
Faction faction = this.create("-2");
|
Faction faction = this.create("-2");
|
||||||
faction.setTag("WarZone");
|
faction.setTag("WarZone");
|
||||||
faction.setDescription("Not the safest place to be");
|
faction.setDescription("Not the safest place to be");
|
||||||
this.setFlagsForWarZone(faction);
|
|
||||||
|
setFlagsForWarZone(faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -106,9 +108,9 @@ public class FactionColl extends EntityCollection<Faction>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Flag Setters
|
// FLAG SETTERS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
public void setFlagsForWilderness(Faction faction)
|
public static void setFlagsForWilderness(Faction faction)
|
||||||
{
|
{
|
||||||
faction.setOpen(false);
|
faction.setOpen(false);
|
||||||
|
|
||||||
@ -131,7 +133,7 @@ public class FactionColl extends EntityCollection<Faction>
|
|||||||
faction.setPermittedRelations(FPerm.LEVER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
faction.setPermittedRelations(FPerm.LEVER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagsForSafeZone(Faction faction)
|
public static void setFlagsForSafeZone(Faction faction)
|
||||||
{
|
{
|
||||||
faction.setOpen(false);
|
faction.setOpen(false);
|
||||||
|
|
||||||
@ -154,7 +156,7 @@ public class FactionColl extends EntityCollection<Faction>
|
|||||||
faction.setPermittedRelations(FPerm.TERRITORY, Rel.LEADER, Rel.OFFICER, Rel.MEMBER);
|
faction.setPermittedRelations(FPerm.TERRITORY, Rel.LEADER, Rel.OFFICER, Rel.MEMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagsForWarZone(Faction faction)
|
public static void setFlagsForWarZone(Faction faction)
|
||||||
{
|
{
|
||||||
faction.setOpen(false);
|
faction.setOpen(false);
|
||||||
|
|
||||||
@ -177,7 +179,6 @@ public class FactionColl extends EntityCollection<Faction>
|
|||||||
faction.setPermittedRelations(FPerm.TERRITORY, Rel.LEADER, Rel.OFFICER, Rel.MEMBER);
|
faction.setPermittedRelations(FPerm.TERRITORY, Rel.LEADER, Rel.OFFICER, Rel.MEMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// GET
|
// GET
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user