mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-27 04:35:21 +01:00
Possible converted FPlayer
This commit is contained in:
parent
3e68c38861
commit
76f3f044ca
@ -139,7 +139,7 @@ public enum FPerm
|
||||
|
||||
if (testSubject instanceof Player)
|
||||
{
|
||||
rpSubject = FPlayerColl.i.get((Player)testSubject);
|
||||
rpSubject = FPlayerColl.get().get(testSubject);
|
||||
}
|
||||
else if (testSubject instanceof RelationParticipator)
|
||||
{
|
||||
@ -185,7 +185,7 @@ public enum FPerm
|
||||
{
|
||||
FPlayer notify = null;
|
||||
if (testSubject instanceof Player)
|
||||
notify = FPlayerColl.i.get((Player)testSubject);
|
||||
notify = FPlayerColl.get().get(testSubject);
|
||||
else if (testSubject instanceof FPlayer)
|
||||
notify = (FPlayer)testSubject;
|
||||
if (notify != null)
|
||||
|
@ -17,36 +17,27 @@ import com.massivecraft.factions.integration.LWCFeatures;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.store.SenderEntity;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
|
||||
public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipator
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// PERSISTANCE
|
||||
// META
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean shouldBeSaved()
|
||||
public static FPlayer get(Object oid)
|
||||
{
|
||||
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));
|
||||
return FPlayerColl.get().get(oid);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: ENTITY
|
||||
// -------------------------------------------- //
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public FPlayer load(FPlayer that)
|
||||
{
|
||||
this.factionId = that.factionId;
|
||||
@ -58,7 +49,16 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
this.lastLoginTime = that.lastLoginTime;
|
||||
|
||||
return this;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault()
|
||||
{
|
||||
if (this.hasFaction()) return false;
|
||||
if (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(ConfServer.powerPlayerStarting)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS: RAW PERMANENT
|
||||
@ -68,7 +68,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
private String factionId;
|
||||
public Faction getFaction() { if(this.factionId == null) {return null;} return FactionColl.i.get(this.factionId); }
|
||||
public String getFactionId() { return this.factionId; }
|
||||
public boolean hasFaction() { return ! factionId.equals("0"); }
|
||||
public boolean hasFaction() { return this.factionId != null && ! factionId.equals("0"); }
|
||||
public void setFaction(Faction faction)
|
||||
{
|
||||
Faction oldFaction = this.getFaction();
|
||||
@ -545,7 +545,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty())
|
||||
{
|
||||
// Remove this faction
|
||||
for (FPlayer fplayer : FPlayerColl.i.getOnline())
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
|
||||
}
|
||||
|
@ -3,39 +3,72 @@ package com.massivecraft.factions;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.massivecraft.mcore.store.MStore;
|
||||
import com.massivecraft.mcore.store.SenderColl;
|
||||
import com.massivecraft.mcore.util.DiscUtil;
|
||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
||||
import com.massivecraft.factions.zcore.persist.PlayerEntityCollection;
|
||||
|
||||
public class FPlayerColl extends PlayerEntityCollection<FPlayer>
|
||||
public class FPlayerColl extends SenderColl<FPlayer>
|
||||
{
|
||||
public static FPlayerColl i = new FPlayerColl();
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static FPlayerColl i = new FPlayerColl();
|
||||
public static FPlayerColl get() { return i; }
|
||||
private FPlayerColl()
|
||||
{
|
||||
super
|
||||
(
|
||||
FPlayer.class,
|
||||
new CopyOnWriteArrayList<FPlayer>(),
|
||||
new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER),
|
||||
new File(Factions.get().getDataFolder(), "players.json"),
|
||||
Factions.get().gson
|
||||
);
|
||||
|
||||
this.setCreative(true);
|
||||
super(MStore.getDb(ConfServer.dburi), Factions.get(), Const.COLLECTION_BASENAME_PLAYER, FPlayer.class, true, true);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
// TODO: Init and migration routine!
|
||||
|
||||
@Override
|
||||
public Type getMapType()
|
||||
public void init()
|
||||
{
|
||||
return new TypeToken<Map<String, FPlayer>>(){}.getType();
|
||||
super.init();
|
||||
|
||||
this.migrate();
|
||||
}
|
||||
|
||||
public void migrate()
|
||||
{
|
||||
// Create file objects
|
||||
File oldFile = new File(Factions.get().getDataFolder(), "players.json");
|
||||
File newFile = new File(Factions.get().getDataFolder(), "players.json.migrated");
|
||||
|
||||
// Already migrated?
|
||||
if ( ! oldFile.exists()) return;
|
||||
|
||||
// Read the file content through GSON.
|
||||
Type type = new TypeToken<Map<String, FPlayer>>(){}.getType();
|
||||
Map<String, FPlayer> id2fplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
||||
|
||||
// Set the data
|
||||
for (Entry<String, FPlayer> entry : id2fplayer.entrySet())
|
||||
{
|
||||
String playerId = entry.getKey();
|
||||
FPlayer fplayer = entry.getValue();
|
||||
FPlayerColl.get().create(playerId).load(fplayer);
|
||||
}
|
||||
|
||||
// Mark as migrated
|
||||
oldFile.renameTo(newFile);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void clean()
|
||||
{
|
||||
for (FPlayer fplayer : this.get())
|
||||
for (FPlayer fplayer : this.getAll())
|
||||
{
|
||||
if ( ! FactionColl.i.exists(fplayer.getFactionId()))
|
||||
{
|
||||
@ -55,7 +88,7 @@ public class FPlayerColl extends PlayerEntityCollection<FPlayer>
|
||||
long now = System.currentTimeMillis();
|
||||
double toleranceMillis = ConfServer.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000;
|
||||
|
||||
for (FPlayer fplayer : FPlayerColl.i.get())
|
||||
for (FPlayer fplayer : this.getAll())
|
||||
{
|
||||
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis)
|
||||
{
|
||||
|
@ -49,6 +49,26 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
return this;
|
||||
}*/
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Persistance and entity management
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void postDetach()
|
||||
{
|
||||
if (Econ.shouldBeUsed())
|
||||
{
|
||||
Econ.setBalance(getAccountId(), 0);
|
||||
}
|
||||
|
||||
// Clean the board
|
||||
// TODO: Use events for this instead
|
||||
BoardColl.get().clean();
|
||||
|
||||
// Clean the fplayers
|
||||
FPlayerColl.get().clean();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS: RAW
|
||||
// -------------------------------------------- //
|
||||
@ -477,7 +497,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
fplayers.clear();
|
||||
if (this.isNone()) return;
|
||||
|
||||
for (FPlayer fplayer : FPlayerColl.i.get())
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAll())
|
||||
{
|
||||
if (fplayer.getFaction() == this)
|
||||
{
|
||||
@ -550,6 +570,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
return ret;
|
||||
}
|
||||
|
||||
// TODO: Makes use of bukkit instead of mixin. Fix that?
|
||||
public ArrayList<Player> getOnlinePlayers()
|
||||
{
|
||||
ArrayList<Player> ret = new ArrayList<Player>();
|
||||
@ -557,7 +578,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
|
||||
for (Player player: Factions.get().getServer().getOnlinePlayers())
|
||||
{
|
||||
FPlayer fplayer = FPlayerColl.i.get(player);
|
||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
||||
if (fplayer.getFaction() == this)
|
||||
{
|
||||
ret.add(player);
|
||||
@ -593,7 +614,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
if (ConfServer.logFactionDisband)
|
||||
Factions.get().log("The faction "+this.getTag()+" ("+this.getId()+") has been disbanded since it has no members left.");
|
||||
|
||||
for (FPlayer fplayer : FPlayerColl.i.getOnline())
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
fplayer.msg("The faction %s<i> was disbanded.", this.getTag(fplayer));
|
||||
}
|
||||
@ -614,7 +635,8 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
// Messages
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void msg(String message, Object... args)
|
||||
// TODO: Invalid code since Mixin introduction. Fix this.
|
||||
public boolean msg(String message, Object... args)
|
||||
{
|
||||
message = Txt.parse(message, args);
|
||||
|
||||
@ -622,6 +644,8 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
{
|
||||
fplayer.sendMessage(message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void sendMessage(String message)
|
||||
@ -640,23 +664,5 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Persistance and entity management
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void postDetach()
|
||||
{
|
||||
if (Econ.shouldBeUsed())
|
||||
{
|
||||
Econ.setBalance(getAccountId(), 0);
|
||||
}
|
||||
|
||||
// Clean the board
|
||||
// TODO: Use events for this instead
|
||||
BoardColl.get().clean();
|
||||
|
||||
// Clean the fplayers
|
||||
FPlayerColl.i.clean();
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class FactionColl extends EntityCollection<Faction>
|
||||
{
|
||||
Factions.get().log(Level.WARNING, "Non existing factionId "+id+" requested! Issuing cleaning!");
|
||||
BoardColl.get().clean();
|
||||
FPlayerColl.i.clean();
|
||||
FPlayerColl.get().clean();
|
||||
}
|
||||
|
||||
return super.get(id);
|
||||
|
@ -56,9 +56,9 @@ public class Factions extends MPlugin
|
||||
public FactionsBlockListener blockListener;
|
||||
|
||||
// Persistance related
|
||||
private boolean locked = false;
|
||||
public boolean getLocked() {return this.locked;}
|
||||
public void setLocked(boolean val) {this.locked = val; this.setAutoSave(val);}
|
||||
//private boolean locked = false;
|
||||
//public boolean getLocked() {return this.locked;}
|
||||
//public void setLocked(boolean val) {this.locked = val; this.setAutoSave(val);}
|
||||
private Integer AutoLeaveTask = null;
|
||||
private Integer econLandRewardTaskID = null;
|
||||
|
||||
@ -79,7 +79,7 @@ public class Factions extends MPlugin
|
||||
ConfServer.get().load();
|
||||
|
||||
// Load Conf from disk
|
||||
FPlayerColl.i.loadFromDisc();
|
||||
FPlayerColl.get().init();
|
||||
FactionColl.i.loadFromDisc();
|
||||
BoardColl.get().init();
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class TerritoryAccess
|
||||
if (testSubject instanceof String)
|
||||
return hostFactionId.equals((String)testSubject);
|
||||
else if (testSubject instanceof Player)
|
||||
return hostFactionId.equals(FPlayerColl.i.get((Player)testSubject).getFactionId());
|
||||
return hostFactionId.equals(FPlayerColl.get().get(testSubject).getFactionId());
|
||||
else if (testSubject instanceof FPlayer)
|
||||
return hostFactionId.equals(((FPlayer)testSubject).getFactionId());
|
||||
else if (testSubject instanceof Faction)
|
||||
@ -154,7 +154,7 @@ public class TerritoryAccess
|
||||
public boolean subjectHasAccess(Object testSubject)
|
||||
{
|
||||
if (testSubject instanceof Player)
|
||||
return fPlayerHasAccess(FPlayerColl.i.get((Player)testSubject));
|
||||
return fPlayerHasAccess(FPlayerColl.get().get(testSubject));
|
||||
else if (testSubject instanceof FPlayer)
|
||||
return fPlayerHasAccess((FPlayer)testSubject);
|
||||
else if (testSubject instanceof Faction)
|
||||
|
@ -26,7 +26,6 @@ public class CmdFactions extends FCommand
|
||||
public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
|
||||
public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave();
|
||||
public CmdFactionsList cmdFactionsList = new CmdFactionsList();
|
||||
public CmdFactionsLock cmdFactionsLock = new CmdFactionsLock();
|
||||
public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap();
|
||||
public CmdFactionsOfficer cmdFactionsOfficer = new CmdFactionsOfficer();
|
||||
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
|
||||
@ -39,8 +38,6 @@ public class CmdFactions extends FCommand
|
||||
public CmdFactionsRelationEnemy cmdFactionsRelationEnemy = new CmdFactionsRelationEnemy();
|
||||
public CmdFactionsRelationNeutral cmdFactionsRelationNeutral = new CmdFactionsRelationNeutral();
|
||||
public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce();
|
||||
public CmdFactionsReload cmdFactionsReload = new CmdFactionsReload();
|
||||
public CmdFactionsSaveAll cmdFactionsSaveAll = new CmdFactionsSaveAll();
|
||||
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
|
||||
public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
|
||||
public CmdFactionsShow cmdFactionsShow = new CmdFactionsShow();
|
||||
@ -67,8 +64,6 @@ public class CmdFactions extends FCommand
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
|
||||
this.disableOnLock = false;
|
||||
|
||||
this.setHelpShort("The faction base command");
|
||||
this.helpLong.add(Txt.parse("<i>This command contains all faction stuff."));
|
||||
|
||||
@ -110,9 +105,6 @@ public class CmdFactions extends FCommand
|
||||
this.addSubCommand(this.cmdFactionsAdmin);
|
||||
this.addSubCommand(this.cmdFactionsPowerBoost);
|
||||
this.addSubCommand(this.cmdFactionsPromote);
|
||||
this.addSubCommand(this.cmdFactionsLock);
|
||||
this.addSubCommand(this.cmdFactionsReload);
|
||||
this.addSubCommand(this.cmdFactionsSaveAll);
|
||||
this.addSubCommand(this.cmdFactionsVersion);
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,6 @@ public class CmdFactionsAccess extends FCommand
|
||||
this.optionalArgs.put("name", "you");
|
||||
|
||||
this.setHelpShort("view or grant access for the claimed territory you are in");
|
||||
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -14,7 +14,6 @@ public class CmdFactionsAdmin extends FCommand
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Perm.ADMIN.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -15,7 +15,6 @@ public class CmdFactionsAutoClaim extends FCommand
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Perm.AUTOCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -16,8 +16,6 @@ public abstract class CmdFactionsCapeAbstract extends FCommand
|
||||
{
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
|
@ -20,7 +20,6 @@ public class CmdFactionsClaim extends FCommand
|
||||
this.optionalArgs.put("radius", "1");
|
||||
|
||||
this.permission = Perm.CLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -26,7 +26,6 @@ public class CmdFactionsCreate extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.CREATE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
@ -79,18 +78,18 @@ public class CmdFactionsCreate extends FCommand
|
||||
}
|
||||
|
||||
// finish setting up the Faction
|
||||
faction.setTag(tag);
|
||||
|
||||
// trigger the faction join event for the creator
|
||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.i.get(me),faction,FPlayerJoinEvent.PlayerJoinReason.CREATE);
|
||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||
// join event cannot be cancelled or you'll have an empty faction
|
||||
|
||||
// finish setting up the FPlayer
|
||||
faction.setTag(tag);
|
||||
|
||||
// trigger the faction join event for the creator
|
||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(me),faction,FPlayerJoinEvent.PlayerJoinReason.CREATE);
|
||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||
// join event cannot be cancelled or you'll have an empty faction
|
||||
|
||||
// finish setting up the FPlayer
|
||||
fme.setRole(Rel.LEADER);
|
||||
fme.setFaction(faction);
|
||||
|
||||
for (FPlayer follower : FPlayerColl.i.getOnline())
|
||||
for (FPlayer follower : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ public class CmdFactionsDeinvite extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.DEINVITE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -16,7 +16,6 @@ public class CmdFactionsDemote extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.DEMOTE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
//To demote someone from member -> recruit you must be an officer.
|
||||
//To demote someone from officer -> member you must be a leader.
|
||||
|
@ -18,7 +18,6 @@ public class CmdFactionsDescription extends FCommand
|
||||
//this.optionalArgs
|
||||
|
||||
this.permission = Perm.DESCRIPTION.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
@ -43,7 +42,7 @@ public class CmdFactionsDescription extends FCommand
|
||||
}
|
||||
|
||||
// Broadcast the description to everyone
|
||||
for (FPlayer fplayer : FPlayerColl.i.getOnline())
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
fplayer.msg("<h>%s<i> changed their description to:", myFaction.describeTo(fplayer));
|
||||
fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description, thus exploitable (masquerade as server messages or whatever); by the way, &k is particularly interesting looking
|
||||
|
@ -26,7 +26,6 @@ public class CmdFactionsDisband extends FCommand
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Perm.DISBAND.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
@ -60,7 +59,7 @@ public class CmdFactionsDisband extends FCommand
|
||||
}
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayerColl.i.getOnline())
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer);
|
||||
if (fplayer.getFaction() == faction)
|
||||
|
@ -19,7 +19,6 @@ public class CmdFactionsFlag extends FCommand
|
||||
this.optionalArgs.put("yes/no", "read");
|
||||
|
||||
this.permission = Perm.FLAG.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
|
@ -32,7 +32,6 @@ public class CmdFactionsHome extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.HOME.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
@ -107,7 +106,7 @@ public class CmdFactionsHome extends FCommand
|
||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
|
||||
continue;
|
||||
|
||||
FPlayer fp = FPlayerColl.i.get(p);
|
||||
FPlayer fp = FPlayerColl.get().get(p);
|
||||
if (fme.getRelationTo(fp) != Rel.ENEMY)
|
||||
continue;
|
||||
|
||||
|
@ -17,7 +17,6 @@ public class CmdFactionsInvite extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.INVITE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -21,7 +21,6 @@ public class CmdFactionsJoin extends FCommand
|
||||
this.optionalArgs.put("player", "you");
|
||||
|
||||
this.permission = Perm.JOIN.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
@ -80,7 +79,7 @@ public class CmdFactionsJoin extends FCommand
|
||||
if (samePlayer && ! canAffordCommand(ConfServer.econCostJoin, "to join a faction")) return;
|
||||
|
||||
// trigger the join event (cancellable)
|
||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.i.get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||
if (joinEvent.isCancelled()) return;
|
||||
|
||||
|
@ -23,7 +23,6 @@ public class CmdFactionsKick extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.KICK.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -22,7 +22,6 @@ public class CmdFactionsLeader extends FCommand
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Perm.LEADER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
@ -71,7 +70,7 @@ public class CmdFactionsLeader extends FCommand
|
||||
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
||||
if (newLeader.getFaction() != targetFaction)
|
||||
{
|
||||
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayerColl.i.get(me),targetFaction,FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
||||
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayerColl.get().get(me),targetFaction,FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return;
|
||||
}
|
||||
@ -95,7 +94,7 @@ public class CmdFactionsLeader extends FCommand
|
||||
msg("<i>You have promoted %s<i> to the position of faction leader.", newLeader.describeTo(fme, true));
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayerColl.i.getOnline())
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ public class CmdFactionsLeave extends FCommand {
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.LEAVE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
|
@ -24,7 +24,6 @@ public class CmdFactionsList extends FCommand
|
||||
this.optionalArgs.put("page", "1");
|
||||
|
||||
this.permission = Perm.LIST.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
|
@ -1,46 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
|
||||
public class CmdFactionsLock extends FCommand {
|
||||
|
||||
// TODO: This solution needs refactoring.
|
||||
/*
|
||||
factions.lock:
|
||||
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
||||
default: op
|
||||
*/
|
||||
|
||||
public CmdFactionsLock()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("lock");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Perm.LOCK.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
p.setLocked(this.argAsBool(0, ! p.getLocked()));
|
||||
|
||||
if( p.getLocked())
|
||||
{
|
||||
msg("<i>Factions is now locked");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("<i>Factions in now unlocked");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,6 @@ public class CmdFactionsMap extends FCommand
|
||||
this.optionalArgs.put("on/off", "once");
|
||||
|
||||
this.permission = Perm.MAP.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -17,7 +17,6 @@ public class CmdFactionsOfficer extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.OFFICER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
|
@ -16,7 +16,6 @@ public class CmdFactionsOpen extends FCommand
|
||||
this.optionalArgs.put("yes/no", "flip");
|
||||
|
||||
this.permission = Perm.OPEN.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -20,7 +20,6 @@ public class CmdFactionsPerm extends FCommand
|
||||
this.optionalArgs.put("yes/no", "read");
|
||||
|
||||
this.permission = Perm.PERM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
this.errorOnToManyArgs = false;
|
||||
|
||||
|
@ -17,7 +17,6 @@ public class CmdFactionsPower extends FCommand
|
||||
this.optionalArgs.put("player", "you");
|
||||
|
||||
this.permission = Perm.POWER.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
|
@ -17,7 +17,6 @@ public class CmdFactionsPowerBoost extends FCommand
|
||||
this.requiredArgs.add("#");
|
||||
|
||||
this.permission = Perm.POWERBOOST.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
|
@ -16,7 +16,6 @@ public class CmdFactionsPromote extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.PROMOTE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
//To promote someone from recruit -> member you must be an officer.
|
||||
//To promote someone from member -> officer you must be a leader.
|
||||
|
@ -21,7 +21,6 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.RELATION.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -1,64 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.FactionColl;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
|
||||
public class CmdFactionsReload extends FCommand
|
||||
{
|
||||
|
||||
public CmdFactionsReload()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("reload");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("file", "all");
|
||||
|
||||
this.permission = Perm.RELOAD.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
long timeInitStart = System.currentTimeMillis();
|
||||
String file = this.argAsString(0, "all").toLowerCase();
|
||||
|
||||
String fileName;
|
||||
|
||||
if (file.startsWith("f"))
|
||||
{
|
||||
FactionColl.i.loadFromDisc();
|
||||
fileName = "factions.json";
|
||||
}
|
||||
else if (file.startsWith("p"))
|
||||
{
|
||||
FPlayerColl.i.loadFromDisc();
|
||||
fileName = "players.json";
|
||||
}
|
||||
else if (file.startsWith("a"))
|
||||
{
|
||||
fileName = "all";
|
||||
FPlayerColl.i.loadFromDisc();
|
||||
FactionColl.i.loadFromDisc();
|
||||
}
|
||||
else
|
||||
{
|
||||
Factions.get().log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
||||
msg("<b>Invalid file specified. <i>Valid files: all, board, factions, players");
|
||||
return;
|
||||
}
|
||||
|
||||
long timeReload = (System.currentTimeMillis()-timeInitStart);
|
||||
|
||||
msg("<i>Reloaded <h>%s <i>from disk, took <h>%dms<i>.", fileName, timeReload);
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.FactionColl;
|
||||
import com.massivecraft.factions.Perm;
|
||||
|
||||
public class CmdFactionsSaveAll extends FCommand
|
||||
{
|
||||
|
||||
public CmdFactionsSaveAll()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("saveall");
|
||||
this.aliases.add("save");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.SAVE.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
FPlayerColl.i.saveToDisc();
|
||||
FactionColl.i.saveToDisc();
|
||||
msg("<i>Factions saved to disk!");
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,6 @@ public class CmdFactionsSeeChunk extends FCommand
|
||||
this.aliases.add("seechunk");
|
||||
|
||||
this.permission = Perm.SEE_CHUNK.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -17,7 +17,6 @@ public class CmdFactionsSethome extends FCommand
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Perm.SETHOME.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -12,6 +12,7 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.mcore.mixin.Mixin;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class CmdFactionsShow extends FCommand
|
||||
@ -25,7 +26,6 @@ public class CmdFactionsShow extends FCommand
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Perm.SHOW.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
@ -114,7 +114,7 @@ public class CmdFactionsShow extends FCommand
|
||||
|
||||
for (FPlayer follower : admins)
|
||||
{
|
||||
if (follower.isOnlineAndVisibleTo(me))
|
||||
if (follower.isOnline() && Mixin.isVisible(me, follower.getId()))
|
||||
{
|
||||
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class CmdFactionsShow extends FCommand
|
||||
|
||||
for (FPlayer follower : mods)
|
||||
{
|
||||
if (follower.isOnlineAndVisibleTo(me))
|
||||
if (follower.isOnline() && Mixin.isVisible(me, follower.getId()))
|
||||
{
|
||||
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
@ -138,7 +138,7 @@ public class CmdFactionsShow extends FCommand
|
||||
|
||||
for (FPlayer follower : normals)
|
||||
{
|
||||
if (follower.isOnlineAndVisibleTo(me))
|
||||
if (follower.isOnline() && Mixin.isVisible(me, follower.getId()))
|
||||
{
|
||||
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ public class CmdFactionsTag extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.TAG.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -16,7 +16,6 @@ public class CmdFactionsTitle extends FCommand
|
||||
this.optionalArgs.put("title", "");
|
||||
|
||||
this.permission = Perm.TITLE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -24,7 +24,6 @@ public class CmdFactionsUnclaim extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.UNCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -21,7 +21,6 @@ public class CmdFactionsUnclaimall extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.UNCLAIM_ALL.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
@ -14,7 +14,6 @@ public class CmdFactionsVersion extends FCommand
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Perm.VERSION.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
|
@ -21,8 +21,6 @@ import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public abstract class FCommand extends MCommand<Factions>
|
||||
{
|
||||
public boolean disableOnLock;
|
||||
|
||||
public FPlayer fme;
|
||||
public Faction myFaction;
|
||||
|
||||
@ -37,9 +35,6 @@ public abstract class FCommand extends MCommand<Factions>
|
||||
{
|
||||
super(Factions.get());
|
||||
|
||||
// Due to safety reasons it defaults to disable on lock.
|
||||
disableOnLock = true;
|
||||
|
||||
// The money commands must be disabled if money should not be used.
|
||||
isMoneyCommand = false;
|
||||
|
||||
@ -53,7 +48,7 @@ public abstract class FCommand extends MCommand<Factions>
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
this.fme = FPlayerColl.i.get((Player)sender);
|
||||
this.fme = FPlayerColl.get().get(sender);
|
||||
this.myFaction = this.fme.getFaction();
|
||||
}
|
||||
else
|
||||
@ -66,13 +61,7 @@ public abstract class FCommand extends MCommand<Factions>
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
if (p.getLocked() && this.disableOnLock)
|
||||
{
|
||||
msg("<b>Factions was locked by an admin. Please try again later.");
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
if (this.isMoneyCommand && ! ConfServer.econEnabled)
|
||||
{
|
||||
msg("<b>Faction economy features are disabled on this server.");
|
||||
@ -98,7 +87,7 @@ public abstract class FCommand extends MCommand<Factions>
|
||||
|
||||
if ( ! (sender instanceof Player)) return false;
|
||||
|
||||
FPlayer fplayer = FPlayerColl.i.get((Player)sender);
|
||||
FPlayer fplayer = FPlayerColl.get().get((Player)sender);
|
||||
|
||||
if ( ! fplayer.hasFaction())
|
||||
{
|
||||
@ -165,7 +154,7 @@ public abstract class FCommand extends MCommand<Factions>
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
FPlayer fplayer = FPlayerColl.i.get(name);
|
||||
FPlayer fplayer = FPlayerColl.get().get(name);
|
||||
if (fplayer != null)
|
||||
{
|
||||
ret = fplayer;
|
||||
@ -199,7 +188,9 @@ public abstract class FCommand extends MCommand<Factions>
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
FPlayer fplayer = FPlayerColl.i.getBestIdMatch(name);
|
||||
// TODO: Easy fix for now
|
||||
//FPlayer fplayer = FPlayerColl.get().getBestIdMatch(name);
|
||||
FPlayer fplayer = FPlayerColl.get().getId2entity().get(name);
|
||||
if (fplayer != null)
|
||||
{
|
||||
ret = fplayer;
|
||||
@ -250,7 +241,10 @@ public abstract class FCommand extends MCommand<Factions>
|
||||
// Next we match player names
|
||||
if (faction == null)
|
||||
{
|
||||
FPlayer fplayer = FPlayerColl.i.getBestIdMatch(name);
|
||||
// TODO: Easy fix for now
|
||||
//FPlayer fplayer = FPlayerColl.get().getBestIdMatch(name);
|
||||
FPlayer fplayer = FPlayerColl.get().getId2entity().get(name);
|
||||
|
||||
if (fplayer != null)
|
||||
{
|
||||
faction = fplayer.getFaction();
|
||||
|
@ -3,11 +3,9 @@ package com.massivecraft.factions.cmd.req;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
import com.massivecraft.mcore.cmd.req.ReqAbstract;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class ReqRoleIsAtLeast extends ReqAbstract
|
||||
@ -35,8 +33,7 @@ public class ReqRoleIsAtLeast extends ReqAbstract
|
||||
@Override
|
||||
public boolean apply(CommandSender sender, MCommand command)
|
||||
{
|
||||
|
||||
FPlayer fplayer = FPlayerColl.i.get(SenderUtil.getSenderId(sender));
|
||||
FPlayer fplayer = FPlayer.get(sender);
|
||||
return fplayer.getRole().isAtLeast(this.rel);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.FactionColl;
|
||||
|
||||
public class FactionCreateEvent extends Event implements Cancellable
|
||||
@ -36,7 +35,7 @@ public class FactionCreateEvent extends Event implements Cancellable
|
||||
|
||||
public FPlayer getFPlayer()
|
||||
{
|
||||
return FPlayerColl.i.get(sender);
|
||||
return FPlayer.get(this.sender);
|
||||
}
|
||||
|
||||
public String getFactionId()
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionColl;
|
||||
|
||||
@ -40,7 +39,7 @@ public class FactionDisbandEvent extends Event implements Cancellable
|
||||
|
||||
public FPlayer getFPlayer()
|
||||
{
|
||||
return FPlayerColl.i.get(sender);
|
||||
return FPlayer.get(sender);
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
|
@ -4,6 +4,5 @@ package com.massivecraft.factions.iface;
|
||||
public interface EconomyParticipator extends RelationParticipator
|
||||
{
|
||||
public String getAccountId();
|
||||
|
||||
public void msg(String str, Object... args);
|
||||
public boolean msg(String msg, Object... args);
|
||||
}
|
@ -13,7 +13,7 @@ import org.bukkit.block.BlockState;
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.lwc.LWCPlugin;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
@ -63,7 +63,7 @@ public class LWCFeatures
|
||||
{
|
||||
if(lwc.findProtection(chests.get(x)) != null)
|
||||
{
|
||||
if(!faction.getFPlayers().contains(FPlayerColl.i.get(lwc.findProtection(chests.get(x)).getOwner())))
|
||||
if(!faction.getFPlayers().contains(FPlayer.get(lwc.findProtection(chests.get(x)).getOwner())))
|
||||
lwc.findProtection(chests.get(x)).remove();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.integration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@ -73,7 +74,7 @@ public class SpoutFeatures
|
||||
|
||||
for (Player player : fromPlayers)
|
||||
{
|
||||
FPlayer fplayer = FPlayerColl.i.get(player);
|
||||
FPlayer fplayer = FPlayer.get(player);
|
||||
SpoutPlayer splayer = SpoutManager.getPlayer(player);
|
||||
Faction faction = fplayer.getFaction();
|
||||
|
||||
@ -137,13 +138,13 @@ public class SpoutFeatures
|
||||
|
||||
for (Player player : fromPlayers)
|
||||
{
|
||||
FPlayer fplayer = FPlayerColl.i.get(player);
|
||||
FPlayer fplayer = FPlayer.get(player);
|
||||
SpoutPlayer splayer = SpoutManager.getPlayer(player);
|
||||
Faction faction = fplayer.getFaction();
|
||||
|
||||
for (Player playerTo : toPlayers)
|
||||
{
|
||||
FPlayer fplayerTo = FPlayerColl.i.get(playerTo);
|
||||
FPlayer fplayerTo = FPlayer.get(playerTo);
|
||||
SpoutPlayer splayerTo = SpoutManager.getPlayer(playerTo);
|
||||
Faction factionTo = fplayerTo.getFaction();
|
||||
|
||||
@ -250,7 +251,7 @@ public class SpoutFeatures
|
||||
{
|
||||
if ( ! isEnabled()) return;
|
||||
|
||||
Set<FPlayer> players = FPlayerColl.i.getOnline();
|
||||
Collection<FPlayer> players = FPlayerColl.get().getAllOnline();
|
||||
|
||||
for (FPlayer player : players)
|
||||
{
|
||||
@ -279,7 +280,7 @@ public class SpoutFeatures
|
||||
|
||||
chunk = chunk.getChunk(true);
|
||||
|
||||
Set<FPlayer> players = FPlayerColl.i.getOnline();
|
||||
Collection<FPlayer> players = FPlayerColl.get().getAllOnline();
|
||||
|
||||
for (FPlayer player : players)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ public class SpoutMainListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
||||
{
|
||||
final FPlayer me = FPlayerColl.i.get(event.getPlayer());
|
||||
final FPlayer me = FPlayerColl.get().get(event.getPlayer());
|
||||
|
||||
SpoutFeatures.updateTitle(me, null);
|
||||
SpoutFeatures.updateTitle(null, me);
|
||||
|
@ -209,15 +209,16 @@ public abstract class FactionsChannelAbstract implements Channel
|
||||
|
||||
public abstract Set<Rel> getTargetRelations();
|
||||
|
||||
// TODO: When I add in universes I will need to separate the channel per universe.
|
||||
public Set<Player> getRecipients(Player sender)
|
||||
{
|
||||
Set<Player> ret = new HashSet<Player>();
|
||||
|
||||
FPlayer fpsender = FPlayerColl.i.get(sender);
|
||||
FPlayer fpsender = FPlayerColl.get().get(sender);
|
||||
Faction faction = fpsender.getFaction();
|
||||
ret.addAll(faction.getOnlinePlayers());
|
||||
|
||||
for (FPlayer fplayer : FPlayerColl.i.getOnline())
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
if(this.getTargetRelations().contains(faction.getRelationTo(fplayer)))
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ public class HerochatListener implements Listener
|
||||
if ( ! ConfServer.chatParseTags) return;
|
||||
|
||||
Player from = event.getSender().getPlayer();
|
||||
FPlayer fpfrom = FPlayerColl.i.get(from);
|
||||
FPlayer fpfrom = FPlayerColl.get().get(from);
|
||||
String format = event.getFormat();
|
||||
|
||||
format = format.replaceAll("&r", "§r");
|
||||
|
@ -22,7 +22,6 @@ import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
@ -88,7 +87,7 @@ public class FactionsBlockListener implements Listener
|
||||
String name = player.getName();
|
||||
if (ConfServer.playersWhoBypassAllProtection.contains(name)) return true;
|
||||
|
||||
FPlayer me = FPlayerColl.i.get(name);
|
||||
FPlayer me = FPlayer.get(name);
|
||||
if (me.hasAdminMode()) return true;
|
||||
|
||||
PS ps = PS.valueOf(location);
|
||||
|
@ -84,7 +84,7 @@ public class FactionsChatListener implements Listener
|
||||
//if (ConfServer.chatTagHandledByAnotherPlugin) return;
|
||||
|
||||
Player from = event.getPlayer();
|
||||
FPlayer fpfrom = FPlayerColl.i.get(from);
|
||||
FPlayer fpfrom = FPlayerColl.get().get(from);
|
||||
String format = event.getFormat();
|
||||
String message = event.getMessage();
|
||||
|
||||
@ -113,7 +113,7 @@ public class FactionsChatListener implements Listener
|
||||
// 4. We send out the messages to each player with relation color.
|
||||
for (Player to : event.getRecipients())
|
||||
{
|
||||
FPlayer fpto = FPlayerColl.i.get(to);
|
||||
FPlayer fpto = FPlayerColl.get().get(to);
|
||||
String formatWithColor = parseTags(format, from, fpfrom, to, fpto);
|
||||
to.sendMessage(String.format(formatWithColor, from.getDisplayName(), message));
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class FactionsChatListener implements Listener
|
||||
|
||||
public static String parseTags(String str, Player from)
|
||||
{
|
||||
FPlayer fpfrom = FPlayerColl.i.get(from);
|
||||
FPlayer fpfrom = FPlayerColl.get().get(from);
|
||||
return parseTags(str, from, fpfrom, null, null);
|
||||
}
|
||||
public static String parseTags(String str, Player from, FPlayer fpfrom)
|
||||
@ -187,8 +187,8 @@ public class FactionsChatListener implements Listener
|
||||
}
|
||||
public static String parseTags(String str, Player from, Player to)
|
||||
{
|
||||
FPlayer fpfrom = FPlayerColl.i.get(from);
|
||||
FPlayer fpto = FPlayerColl.i.get(to);
|
||||
FPlayer fpfrom = FPlayerColl.get().get(from);
|
||||
FPlayer fpto = FPlayerColl.get().get(to);
|
||||
return parseTags(str, from, fpfrom, to, fpto);
|
||||
}
|
||||
public static String parseTags(String str, Player from, FPlayer fpfrom, Player to, FPlayer fpto)
|
||||
|
@ -59,7 +59,7 @@ public class FactionsEntityListener implements Listener
|
||||
if ( ! (entity instanceof Player)) return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
FPlayer fplayer = FPlayerColl.i.get(player);
|
||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
||||
|
||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player));
|
||||
|
||||
@ -221,7 +221,7 @@ public class FactionsEntityListener implements Listener
|
||||
|
||||
if ( ! (damagee instanceof Player)) return true;
|
||||
|
||||
FPlayer defender = FPlayerColl.i.get((Player)damagee);
|
||||
FPlayer defender = FPlayerColl.get().get(damagee);
|
||||
|
||||
if (defender == null || defender.getPlayer() == null)
|
||||
return true;
|
||||
@ -245,7 +245,7 @@ public class FactionsEntityListener implements Listener
|
||||
{
|
||||
if (notify)
|
||||
{
|
||||
FPlayer attacker = FPlayerColl.i.get((Player)damager);
|
||||
FPlayer attacker = FPlayerColl.get().get((Player)damager);
|
||||
attacker.msg("<i>PVP is disabled in %s.", defLocFaction.describeTo(attacker));
|
||||
}
|
||||
return false;
|
||||
@ -256,7 +256,7 @@ public class FactionsEntityListener implements Listener
|
||||
if ( ! (damager instanceof Player))
|
||||
return true;
|
||||
|
||||
FPlayer attacker = FPlayerColl.i.get((Player)damager);
|
||||
FPlayer attacker = FPlayerColl.get().get((Player)damager);
|
||||
|
||||
if (attacker == null || attacker.getPlayer() == null)
|
||||
return true;
|
||||
|
@ -44,7 +44,7 @@ public class FactionsPlayerListener implements Listener
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
// Make sure that all online players do have a fplayer.
|
||||
final FPlayer me = FPlayerColl.i.get(event.getPlayer());
|
||||
final FPlayer me = FPlayerColl.get().get(event.getPlayer());
|
||||
|
||||
// Update the lastLoginTime for this fplayer
|
||||
me.setLastLoginTime(System.currentTimeMillis());
|
||||
@ -61,7 +61,7 @@ public class FactionsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
FPlayer me = FPlayerColl.i.get(event.getPlayer());
|
||||
FPlayer me = FPlayerColl.get().get(event.getPlayer());
|
||||
|
||||
// Make sure player's power is up to date when they log off.
|
||||
me.getPower();
|
||||
@ -88,7 +88,7 @@ public class FactionsPlayerListener implements Listener
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
FPlayer me = FPlayerColl.i.get(player);
|
||||
FPlayer me = FPlayerColl.get().get(player);
|
||||
|
||||
// Did we change coord?
|
||||
PS chunkFrom = me.getCurrentChunk();
|
||||
@ -158,7 +158,7 @@ public class FactionsPlayerListener implements Listener
|
||||
int count = attempt.increment();
|
||||
if (count >= 10)
|
||||
{
|
||||
FPlayer me = FPlayerColl.i.get(name);
|
||||
FPlayer me = FPlayerColl.get().get(name);
|
||||
me.msg("<b>Ouch, that is starting to hurt. You should give it a rest.");
|
||||
player.damage(NumberConversions.floor((double)count / 10));
|
||||
}
|
||||
@ -204,7 +204,7 @@ public class FactionsPlayerListener implements Listener
|
||||
String name = player.getName();
|
||||
if (ConfServer.playersWhoBypassAllProtection.contains(name)) return true;
|
||||
|
||||
FPlayer me = FPlayerColl.i.get(name);
|
||||
FPlayer me = FPlayerColl.get().get(name);
|
||||
if (me.hasAdminMode()) return true;
|
||||
if (Const.MATERIALS_EDIT_TOOLS.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false;
|
||||
return true;
|
||||
@ -214,7 +214,7 @@ public class FactionsPlayerListener implements Listener
|
||||
String name = player.getName();
|
||||
if (ConfServer.playersWhoBypassAllProtection.contains(name)) return true;
|
||||
|
||||
FPlayer me = FPlayerColl.i.get(name);
|
||||
FPlayer me = FPlayerColl.get().get(name);
|
||||
if (me.hasAdminMode()) return true;
|
||||
Location loc = block.getLocation();
|
||||
Material material = block.getType();
|
||||
@ -230,7 +230,7 @@ public class FactionsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
FPlayer me = FPlayerColl.i.get(event.getPlayer());
|
||||
FPlayer me = FPlayerColl.get().get(event.getPlayer());
|
||||
|
||||
me.getPower(); // update power, so they won't have gained any while dead
|
||||
|
||||
@ -290,7 +290,7 @@ public class FactionsPlayerListener implements Listener
|
||||
{
|
||||
// Get the player
|
||||
Player player = event.getPlayer();
|
||||
FPlayer me = FPlayerColl.i.get(player);
|
||||
FPlayer me = FPlayerColl.get().get(player);
|
||||
|
||||
// With adminmode no commands are denied.
|
||||
if (me.hasAdminMode()) return;
|
||||
@ -349,7 +349,7 @@ public class FactionsPlayerListener implements Listener
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
FPlayer badGuy = FPlayerColl.i.get(event.getPlayer());
|
||||
FPlayer badGuy = FPlayerColl.get().get(event.getPlayer());
|
||||
if (badGuy == null)
|
||||
{
|
||||
return;
|
||||
|
@ -15,7 +15,7 @@ public class AutoLeaveTask implements Runnable
|
||||
|
||||
public void run()
|
||||
{
|
||||
FPlayerColl.i.autoLeaveOnInactivityRoutine();
|
||||
FPlayerColl.get().autoLeaveOnInactivityRoutine();
|
||||
|
||||
// maybe setting has been changed? if so, restart task at new rate
|
||||
if (this.rate != ConfServer.autoLeaveRoutineRunsEveryXMinutes)
|
||||
|
Loading…
Reference in New Issue
Block a user