Some dead code elimination

This commit is contained in:
Olof Larsson 2011-10-24 03:02:25 +02:00
parent 46161f61db
commit 074be07510
10 changed files with 40 additions and 296 deletions

View File

@ -35,7 +35,6 @@ permissions:
factions.flag.any: true factions.flag.any: true
factions.perm.any: true factions.perm.any: true
factions.kick.any: true factions.kick.any: true
factions.ownershipbypass: true
factions.kit.fullplayer: factions.kit.fullplayer:
default: true default: true
description: Can also create new factions. description: Can also create new factions.
@ -64,10 +63,7 @@ permissions:
factions.map: true factions.map: true
factions.officer: true factions.officer: true
factions.money.kit.standard: true factions.money.kit.standard: true
factions.noboom: true
factions.open: true factions.open: true
factions.owner: true
factions.ownerlist: true
factions.power: true factions.power: true
factions.power.any: true factions.power.any: true
factions.relation: true factions.relation: true
@ -167,12 +163,6 @@ permissions:
factions.money.p2f: true factions.money.p2f: true
factions.open: factions.open:
description: switch if invitation is required to join description: switch if invitation is required to join
factions.owner:
description: set ownership of claimed land
factions.ownerlist:
description: list owner(s) of this claimed land
factions.ownershipbypass:
description: bypass ownership restrictions within own faction's territory
factions.power: factions.power:
description: show player power info description: show player power info
factions.power.any: factions.power.any:

View File

@ -106,15 +106,13 @@ public class Conf
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3; public static int noPVPDamageToOthersForXSecondsAfterLogin = 3;
public static boolean peacefulTerritoryDisablePVP = true; //public static boolean peacefulMembersDisablePowerLoss = true;
public static boolean peacefulTerritoryDisableMonsters = false;
public static boolean peacefulMembersDisablePowerLoss = true;
public static boolean claimsMustBeConnected = false; public static boolean claimsMustBeConnected = false;
public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true; public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true;
public static int claimsRequireMinFactionMembers = 1; public static int claimsRequireMinFactionMembers = 1;
public static double considerFactionsReallyOfflineAfterXMinutes = 0.0; //public static double considerFactionsReallyOfflineAfterXMinutes = 0.0;
public static int actionDeniedPainAmount = 2; public static int actionDeniedPainAmount = 2;
@ -123,77 +121,8 @@ public class Conf
public static Set<String> territoryEnemyDenyCommands = new HashSet<String>(); public static Set<String> territoryEnemyDenyCommands = new HashSet<String>();
public static double territoryShieldFactor = 0.3; public static double territoryShieldFactor = 0.3;
/*public static boolean territoryDenyBuild = true;
public static boolean territoryDenyBuildWhenOffline = true;
public static boolean territoryPainBuild = false;
public static boolean territoryPainBuildWhenOffline = false;
public static boolean territoryDenyUseage = true;
public static boolean territoryEnemyDenyBuild = true;
public static boolean territoryEnemyDenyBuildWhenOffline = true;
public static boolean territoryEnemyPainBuild = false;
public static boolean territoryEnemyPainBuildWhenOffline = false;
public static boolean territoryEnemyDenyUseage = true;
public static boolean territoryEnemyProtectMaterials = true;
public static boolean territoryAllyDenyBuild = true;
public static boolean territoryAllyDenyBuildWhenOffline = true;
public static boolean territoryAllyPainBuild = false;
public static boolean territoryAllyPainBuildWhenOffline = false;
public static boolean territoryAllyDenyUseage = true;
public static boolean territoryAllyProtectMaterials = true;
public static boolean territoryTruceDenyBuild = true;
public static boolean territoryTruceDenyBuildWhenOffline = true;
public static boolean territoryTrucePainBuild = false;
public static boolean territoryTrucePainBuildWhenOffline = false;
public static boolean territoryTruceDenyUseage = true;
public static boolean territoryTruceProtectMaterials = true;
public static boolean territoryBlockCreepers = false;
public static boolean territoryBlockCreepersWhenOffline = false;
public static boolean territoryBlockFireballs = false;
public static boolean territoryBlockFireballsWhenOffline = false;
public static boolean territoryBlockTNT = false;
public static boolean territoryBlockTNTWhenOffline = false;
public static boolean territoryDenyEndermanBlocks = true;
public static boolean territoryDenyEndermanBlocksWhenOffline = true;*/
/*public static boolean safeZoneDenyBuild = true;
public static boolean safeZoneDenyUseage = true;
public static boolean safeZoneBlockTNT = true;
public static boolean safeZonePreventAllDamageToPlayers = false;
public static boolean safeZoneDenyEndermanBlocks = true;
public static boolean warZoneDenyBuild = true;
public static boolean warZoneDenyUseage = true;
public static boolean warZoneBlockCreepers = false;
public static boolean warZoneBlockFireballs = false;
public static boolean warZoneBlockTNT = true;
public static boolean warZonePowerLoss = true;
public static boolean warZoneFriendlyFire = false;
public static boolean warZoneDenyEndermanBlocks = true;
*/
/*public static boolean wildernessDenyBuild = false;
public static boolean wildernessDenyUseage = false;
public static boolean wildernessBlockCreepers = false;
public static boolean wildernessBlockFireballs = false;
public static boolean wildernessBlockTNT = false;
public static boolean wildernessPowerLoss = true;
public static boolean wildernessDenyEndermanBlocks = false;*/
// for claimed areas where further faction-member ownership can be defined // for claimed areas where further faction-member ownership can be defined
public static boolean ownedAreasEnabled = true;
public static int ownedAreasLimitPerFaction = 0;
public static boolean ownedAreasModeratorsCanSet = false;
public static boolean ownedAreaModeratorsBypass = true;
public static boolean ownedAreaDenyBuild = true;
public static boolean ownedAreaPainBuild = false;
public static boolean ownedAreaProtectMaterials = true;
public static boolean ownedAreaDenyUseage = true;
public static String ownedLandMessage = "Owner(s): ";
public static String publicLandMessage = "Public faction land.";
public static boolean ownedMessageOnBorder = true;
public static boolean ownedMessageInsideTerritory = true;
public static boolean ownedMessageByChunk = false;
public static boolean pistonProtectionThroughDenyBuild = true; public static boolean pistonProtectionThroughDenyBuild = true;
@ -266,7 +195,7 @@ public class Conf
public static Set<String> worldsNoPowerLoss = new HashSet<String>(); public static Set<String> worldsNoPowerLoss = new HashSet<String>();
public static Set<String> worldsIgnorePvP = new HashSet<String>(); public static Set<String> worldsIgnorePvP = new HashSet<String>();
// TODO: A better solution Would be to have One wilderness faction per world. // TODO: A better solution Would be to have One wilderness faction per world.
public static Set<String> worldsNoWildernessProtection = new HashSet<String>(); //public static Set<String> worldsNoWildernessProtection = new HashSet<String>();
public static transient int mapHeight = 8; public static transient int mapHeight = 8;
public static transient int mapWidth = 39; public static transient int mapWidth = 39;
@ -314,24 +243,6 @@ public class Conf
materialsEditTools.add(Material.BUCKET); materialsEditTools.add(Material.BUCKET);
materialsEditTools.add(Material.WATER_BUCKET); materialsEditTools.add(Material.WATER_BUCKET);
materialsEditTools.add(Material.LAVA_BUCKET); materialsEditTools.add(Material.LAVA_BUCKET);
/*
territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR);
territoryProtectedMaterialsWhenOffline.add(Material.TRAP_DOOR);
territoryProtectedMaterialsWhenOffline.add(Material.FENCE_GATE);
territoryProtectedMaterialsWhenOffline.add(Material.DISPENSER);
territoryProtectedMaterialsWhenOffline.add(Material.CHEST);
territoryProtectedMaterialsWhenOffline.add(Material.FURNACE);
territoryProtectedMaterialsWhenOffline.add(Material.BURNING_FURNACE);
territoryProtectedMaterialsWhenOffline.add(Material.DIODE_BLOCK_OFF);
territoryProtectedMaterialsWhenOffline.add(Material.DIODE_BLOCK_ON);
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL);
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);*/
monsters.add(CreatureType.CAVE_SPIDER); monsters.add(CreatureType.CAVE_SPIDER);
monsters.add(CreatureType.CREEPER); monsters.add(CreatureType.CREEPER);

View File

@ -15,7 +15,8 @@ public class FLocation
private int x = 0; private int x = 0;
private int z = 0; private int z = 0;
// private final static transient double cellSize = 16; // TODO: It would be wise to ask yourself is there is a better solution to creating loads of new object
// This object is create many times.
//----------------------------------------------// //----------------------------------------------//
// Constructors // Constructors

View File

@ -32,10 +32,14 @@ import com.nijikokun.register.payment.Method.MethodAccount;
* This means you can use the == operator. No .equals method necessary. * This means you can use the == operator. No .equals method necessary.
*/ */
// TODO: The players are saved in non order.
// TODO: To many players are saved. There must be ways to improve the selective saving functionality.
public class FPlayer extends PlayerEntity implements EconomyParticipator public class FPlayer extends PlayerEntity implements EconomyParticipator
{ {
//private transient String playerName; //private transient String playerName;
private transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked? private transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked?
public FLocation getLastStoodAt() { return this.lastStoodAt; }
public void setLastStoodAt(FLocation flocation) { this.lastStoodAt = flocation; }
// FIELD: factionId // FIELD: factionId
private String factionId; private String factionId;
@ -55,6 +59,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
// FIELD: title // FIELD: title
private String title; private String title;
public String getTitle() { return this.title; }
public void setTitle(String title) { this.title = title; }
// FIELD: power // FIELD: power
private double power; private double power;
@ -65,19 +71,23 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
// FIELD: lastLoginTime // FIELD: lastLoginTime
private long lastLoginTime; private long lastLoginTime;
// FIELD: mapAutoUpdating // FIELD: mapAutoUpdating
private transient boolean mapAutoUpdating; private transient boolean mapAutoUpdating;
public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; }
public boolean isMapAutoUpdating() { return mapAutoUpdating; }
// FIELD: autoClaimEnabled // FIELD: autoClaimEnabled
private transient Faction autoClaimFor; private transient Faction autoClaimFor;
public Faction getAutoClaimFor() public Faction getAutoClaimFor() { return autoClaimFor; }
{ public void setAutoClaimFor(Faction faction) { this.autoClaimFor = faction; }
return autoClaimFor;
}
public void setAutoClaimFor(Faction faction)
{
this.autoClaimFor = faction;
}
private transient boolean isAdminBypassing = false; private transient boolean isAdminBypassing = false;
public boolean isAdminBypassing() { return this.isAdminBypassing; } public boolean isAdminBypassing() { return this.isAdminBypassing; }
@ -87,7 +97,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
private transient boolean loginPvpDisabled; private transient boolean loginPvpDisabled;
// FIELD: deleteMe // FIELD: deleteMe
// TODO: This is not the way it is meant to be used... Check out the selective saving and improve it
private transient boolean deleteMe; private transient boolean deleteMe;
public void markForDeletion(boolean delete) { deleteMe = delete; }
// FIELD: chatMode // FIELD: chatMode
private ChatMode chatMode; private ChatMode chatMode;
@ -153,16 +165,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
// Getters And Setters // Getters And Setters
// -------------------------------------------- // // -------------------------------------------- //
public long getLastLoginTime() public long getLastLoginTime()
{ {
return lastLoginTime; return lastLoginTime;
} }
public void setLastLoginTime(long lastLoginTime) public void setLastLoginTime(long lastLoginTime)
{ {
losePowerFromBeingOffline(); losePowerFromBeingOffline();
@ -174,16 +181,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
} }
} }
public boolean isMapAutoUpdating()
{
return mapAutoUpdating;
}
public void setMapAutoUpdating(boolean mapAutoUpdating)
{
this.mapAutoUpdating = mapAutoUpdating;
}
public boolean hasLoginPvpDisabled() public boolean hasLoginPvpDisabled()
{ {
if (!loginPvpDisabled) if (!loginPvpDisabled)
@ -198,40 +195,17 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
return true; return true;
} }
public FLocation getLastStoodAt()
{
return this.lastStoodAt;
}
public void setLastStoodAt(FLocation flocation)
{
this.lastStoodAt = flocation;
}
public void markForDeletion(boolean delete)
{
deleteMe = delete;
}
//----------------------------------------------// //----------------------------------------------//
// Title, Name, Faction Tag and Chat // Title, Name, Faction Tag and Chat
//----------------------------------------------// //----------------------------------------------//
// Base: // Base:
public String getTitle()
{
return this.title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getName() public String getName()
{ {
return this.getId(); // TODO: ... display name or remove completeley return getId(); // TODO: ... display name or remove completeley
} }
public String getTag() public String getTag()
@ -277,35 +251,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
return this.getColorTo(fplayer)+this.getNameAndTitle(); return this.getColorTo(fplayer)+this.getNameAndTitle();
} }
/*public String getNameAndTag(Faction faction)
{
return this.getRelationColor(faction)+this.getNameAndTag();
}
public String getNameAndTag(FPlayer fplayer)
{
return this.getRelationColor(fplayer)+this.getNameAndTag();
}*/
// TODO: REmovded for refactoring.
/*public String getNameAndRelevant(Faction faction)
{
// Which relation?
Relation rel = this.getRelationTo(faction);
// For member we show title
if (rel == Relation.MEMBER) {
return rel.getColor() + this.getNameAndTitle();
}
// For non members we show tag
return rel.getColor() + this.getNameAndTag();
}
public String getNameAndRelevant(FPlayer fplayer)
{
return getNameAndRelevant(fplayer.getFaction());
}*/
// Chat Tag: // Chat Tag:
// These are injected into the format of global chat messages. // These are injected into the format of global chat messages.
@ -493,15 +438,15 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
return factionHere != null && factionHere.isNormal() && factionHere != this.getFaction(); return factionHere != null && factionHere.isNormal() && factionHere != this.getFaction();
}*/ }*/
public boolean isInAllyTerritory() /*public boolean isInAllyTerritory()
{ {
return Board.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.ALLY; return Board.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.ALLY;
} }*/
public boolean isInNeutralTerritory() /*public boolean isInNeutralTerritory()
{ {
return Board.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.NEUTRAL; return Board.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.NEUTRAL;
} }*/
public boolean isInEnemyTerritory() public boolean isInEnemyTerritory()
{ {

View File

@ -25,9 +25,9 @@ public class Faction extends Entity implements EconomyParticipator
// FIELD: invites // FIELD: invites
// Where string is a lowercase player name // Where string is a lowercase player name
private Set<String> invites; private Set<String> invites;
public void invite(FPlayer fplayer) { this.invites.add(fplayer.getName().toLowerCase()); } public void invite(FPlayer fplayer) { this.invites.add(fplayer.getId().toLowerCase()); }
public void deinvite(FPlayer fplayer) { this.invites.remove(fplayer.getName().toLowerCase()); } public void deinvite(FPlayer fplayer) { this.invites.remove(fplayer.getId().toLowerCase()); }
public boolean isInvited(FPlayer fplayer) { return this.invites.contains(fplayer.getName().toLowerCase()); } public boolean isInvited(FPlayer fplayer) { return this.invites.contains(fplayer.getId().toLowerCase()); }
// FIELD: open // FIELD: open
private boolean open; private boolean open;
@ -84,9 +84,6 @@ public class Faction extends Entity implements EconomyParticipator
this.home = null; this.home = null;
} }
// FIELD: lastPlayerLoggedOffTime
private transient long lastPlayerLoggedOffTime;
// FIELD: account (fake field) // FIELD: account (fake field)
// Bank functions // Bank functions
public double money; public double money;
@ -161,9 +158,6 @@ public class Faction extends Entity implements EconomyParticipator
this.open = Conf.newFactionsDefaultOpen; this.open = Conf.newFactionsDefaultOpen;
this.tag = "???"; this.tag = "???";
this.description = "Default faction description :("; this.description = "Default faction description :(";
this.lastPlayerLoggedOffTime = 0;
//this.peaceful = false;
//this.peacefulExplosionsEnabled = false;
this.money = 0.0; this.money = 0.0;
this.flagOverrides = new LinkedHashMap<FFlag, Boolean>(); this.flagOverrides = new LinkedHashMap<FFlag, Boolean>();
this.permOverrides = new LinkedHashMap<FPerm, Set<Rel>>(); this.permOverrides = new LinkedHashMap<FPerm, Set<Rel>>();
@ -242,6 +236,7 @@ public class Faction extends Entity implements EconomyParticipator
} }
} }
// TODO: Implement a has enough feature.
//----------------------------------------------// //----------------------------------------------//
// Power // Power
//----------------------------------------------// //----------------------------------------------//
@ -390,34 +385,6 @@ public class Faction extends Entity implements EconomyParticipator
return ret; return ret;
} }
// slightly faster check than getOnlinePlayers() if you just want to see if there are any players online
public boolean hasPlayersOnline()
{
// only real factions can have players online, not safe zone / war zone
//if (this.isPlayerFreeType()) return false;
for (Player player: P.p.getServer().getOnlinePlayers())
{
FPlayer fplayer = FPlayers.i.get(player);
if (fplayer.getFaction() == this)
{
return true;
}
}
// even if all players are technically logged off, maybe someone was on recently enough to not consider them officially offline yet
if (Conf.considerFactionsReallyOfflineAfterXMinutes > 0 && System.currentTimeMillis() < lastPlayerLoggedOffTime + (Conf.considerFactionsReallyOfflineAfterXMinutes * 60000))
{
return true;
}
return false;
}
public void memberLoggedOff()
{
lastPlayerLoggedOffTime = System.currentTimeMillis();
}
//----------------------------------------------// //----------------------------------------------//
// Messages // Messages
//----------------------------------------------// //----------------------------------------------//

View File

@ -243,9 +243,6 @@ public class P extends MPlugin
} }
// Is this chat message actually a Factions command, and thus should be left alone by other plugins? // Is this chat message actually a Factions command, and thus should be left alone by other plugins?
// TODO: GET THIS BACK AND WORKING
public boolean isFactionsCommand(String check) public boolean isFactionsCommand(String check)
{ {
if (check == null || check.isEmpty()) return false; if (check == null || check.isEmpty()) return false;

View File

@ -108,20 +108,7 @@ public class FactionsEntityListener extends EntityListener
return; return;
} }
} }
/*
public boolean isPlayerInSafeZone(Entity damagee)
{
if ( ! (damagee instanceof Player))
{
return false;
}
if (Board.getFactionAt(new FLocation(damagee.getLocation())).isSafeZone())
{
return true;
}
return false;
}
*/
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub)
{ {
Entity damager = sub.getDamager(); Entity damager = sub.getDamager();
@ -356,50 +343,4 @@ public class FactionsEntityListener extends EntityListener
event.setCancelled(true); event.setCancelled(true);
} }
/*private boolean stopEndermanBlockManipulation(Location loc)
{
if (loc == null)
{
return false;
}
// quick check to see if all Enderman deny options are enabled; if so, no need to check location
if
(
Conf.wildernessDenyEndermanBlocks
&&
Conf.territoryDenyEndermanBlocks
&&
Conf.territoryDenyEndermanBlocksWhenOffline
&&
Conf.safeZoneDenyEndermanBlocks
&&
Conf.warZoneDenyEndermanBlocks
)
{
return true;
}
FLocation fLoc = new FLocation(loc);
Faction claimFaction = Board.getFactionAt(fLoc);
if (claimFaction.isNone())
{
return Conf.wildernessDenyEndermanBlocks;
}
else if (claimFaction.isNormal())
{
return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline;
}
else if (claimFaction.isSafeZone())
{
return Conf.safeZoneDenyEndermanBlocks;
}
else if (claimFaction.isWarZone())
{
return Conf.warZoneDenyEndermanBlocks;
}
return false;
}*/
} }

View File

@ -162,11 +162,6 @@ public class FactionsPlayerListener extends PlayerListener
// Make sure player's power is up to date when they log off. // Make sure player's power is up to date when they log off.
FPlayer me = FPlayers.i.get(event.getPlayer()); FPlayer me = FPlayers.i.get(event.getPlayer());
me.getPower(); me.getPower();
Faction myFaction = me.getFaction();
if (myFaction != null)
{
myFaction.memberLoggedOff();
}
SpoutFeatures.playerDisconnect(me); SpoutFeatures.playerDisconnect(me);
} }
@ -176,14 +171,14 @@ public class FactionsPlayerListener extends PlayerListener
Player player = event.getPlayer(); Player player = event.getPlayer();
FPlayer me = FPlayers.i.get(player); FPlayer me = FPlayers.i.get(player);
// Did we change block?
if (event.getFrom().equals(event.getTo())) return;
// Did we change coord? // Did we change coord?
FLocation from = me.getLastStoodAt(); FLocation from = me.getLastStoodAt();
FLocation to = new FLocation(player.getLocation()); FLocation to = new FLocation(player.getLocation());
if (from.equals(to)) if (from.equals(to)) return;
{
return;
}
// Yes we did change coord (: // Yes we did change coord (:

View File

@ -18,6 +18,7 @@ public enum FFlag
// This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level // This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level
// (Faction) Territory flags // (Faction) Territory flags
// If a faction later could have many different territories this would probably be in another enum
POWERLOSS("powerloss", "<i>Is power lost on death in this territory?", true, false), POWERLOSS("powerloss", "<i>Is power lost on death in this territory?", true, false),
PVP("pvp", "<i>Can you PVP in territory?", true, false), PVP("pvp", "<i>Can you PVP in territory?", true, false),
FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false, false), FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false, false),

View File

@ -6,7 +6,6 @@ import com.massivecraft.factions.P;
public enum Permission public enum Permission
{ {
OWNERSHIP_BYPASS("ownershipbypass"),
LEADER("leader"), LEADER("leader"),
AUTOCLAIM("autoclaim"), AUTOCLAIM("autoclaim"),
BYPASS("bypass"), BYPASS("bypass"),
@ -41,10 +40,7 @@ public enum Permission
MONEY_F2F("money.f2f"), MONEY_F2F("money.f2f"),
MONEY_F2P("money.f2p"), MONEY_F2P("money.f2p"),
MONEY_P2F("money.p2f"), MONEY_P2F("money.p2f"),
NO_BOOM("noboom"),
OPEN("open"), OPEN("open"),
OWNER("owner"),
OWNERLIST("ownerlist"),
SET_PEACEFUL("setpeaceful"), SET_PEACEFUL("setpeaceful"),
POWER("power"), POWER("power"),
POWER_ANY("power.any"), POWER_ANY("power.any"),