Some reformat
This commit is contained in:
parent
955958ce61
commit
dc54f78cc1
@ -173,33 +173,39 @@ public class Board {
|
||||
for (int dx = 0; dx < width; dx++) {
|
||||
if (dx == halfWidth && dz == halfHeight) {
|
||||
row += ChatColor.AQUA + "+";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
||||
Faction factionHere = getFactionAt(flocationHere);
|
||||
Relation relation = faction.getRelationTo(factionHere);
|
||||
if (factionHere.isNone()) {
|
||||
row += ChatColor.GRAY + "-";
|
||||
} else if (factionHere.isSafeZone()) {
|
||||
}
|
||||
else if (factionHere.isSafeZone()) {
|
||||
row += Conf.colorPeaceful + "+";
|
||||
} else if (factionHere.isWarZone()) {
|
||||
}
|
||||
else if (factionHere.isWarZone()) {
|
||||
row += ChatColor.DARK_RED + "+";
|
||||
} else if
|
||||
(
|
||||
factionHere == faction
|
||||
||
|
||||
factionHere == factionLoc
|
||||
||
|
||||
relation.isAtLeast(Relation.ALLY)
|
||||
||
|
||||
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|
||||
||
|
||||
(Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))
|
||||
) {
|
||||
if (!fList.containsKey(factionHere.getTag()))
|
||||
}
|
||||
else if
|
||||
(
|
||||
factionHere == faction
|
||||
||
|
||||
factionHere == factionLoc
|
||||
||
|
||||
relation.isAtLeast(Relation.ALLY)
|
||||
||
|
||||
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|
||||
||
|
||||
(Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))
|
||||
) {
|
||||
if (!fList.containsKey(factionHere.getTag())) {
|
||||
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
|
||||
}
|
||||
char tag = fList.get(factionHere.getTag());
|
||||
row += factionHere.getColorTo(faction) + "" + tag;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
row += ChatColor.GRAY + "-";
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class FLocation {
|
||||
//----------------------------------------------//
|
||||
public Set<FLocation> getCircle(double radius) {
|
||||
Set<FLocation> ret = new LinkedHashSet<FLocation>();
|
||||
if (radius <= 0) return ret;
|
||||
if (radius <= 0) { return ret; }
|
||||
|
||||
int xfrom = (int) Math.floor(this.x - radius);
|
||||
int xto = (int) Math.ceil(this.x + radius);
|
||||
@ -146,8 +146,7 @@ public class FLocation {
|
||||
for (int x = xfrom; x <= xto; x++) {
|
||||
for (int z = zfrom; z <= zto; z++) {
|
||||
FLocation potential = new FLocation(this.worldName, x, z);
|
||||
if (this.getDistanceTo(potential) <= radius)
|
||||
ret.add(potential);
|
||||
if (this.getDistanceTo(potential) <= radius) { ret.add(potential); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,10 +177,8 @@ public class FLocation {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (!(obj instanceof FLocation))
|
||||
return false;
|
||||
if (obj == this) { return true; }
|
||||
if (!(obj instanceof FLocation)) { return false; }
|
||||
|
||||
FLocation that = (FLocation) obj;
|
||||
return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName));
|
||||
|
@ -58,7 +58,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
|
||||
public void setFaction(Faction faction) {
|
||||
Faction oldFaction = this.getFaction();
|
||||
if (oldFaction != null) oldFaction.removeFPlayer(this);
|
||||
if (oldFaction != null) { oldFaction.removeFPlayer(this); }
|
||||
faction.addFPlayer(this);
|
||||
this.factionId = faction.getId();
|
||||
}
|
||||
@ -458,10 +458,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
|
||||
protected void alterPower(double delta) {
|
||||
this.power += delta;
|
||||
if (this.power > this.getPowerMax())
|
||||
this.power = this.getPowerMax();
|
||||
else if (this.power < this.getPowerMin())
|
||||
this.power = this.getPowerMin();
|
||||
if (this.power > this.getPowerMax()) { this.power = this.getPowerMax(); }
|
||||
else if (this.power < this.getPowerMin()) { this.power = this.getPowerMin(); }
|
||||
}
|
||||
|
||||
public double getPowerMax() {
|
||||
@ -496,8 +494,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
this.lastPowerUpdateTime = now;
|
||||
|
||||
Player thisPlayer = this.getPlayer();
|
||||
if (thisPlayer != null && thisPlayer.isDead())
|
||||
if (thisPlayer != null && thisPlayer.isDead()) {
|
||||
return; // don't let dead players regain power until they respawn
|
||||
}
|
||||
|
||||
int millisPerMinute = 60 * 1000;
|
||||
this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
|
||||
@ -581,21 +580,23 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
||||
if (makePay && !Econ.hasAtLeast(this, Conf.econCostLeave, "to leave your faction.")) return;
|
||||
if (makePay && !Econ.hasAtLeast(this, Conf.econCostLeave, "to leave your faction.")) { return; }
|
||||
|
||||
FPlayerLeaveEvent leaveEvent = new FPlayerLeaveEvent(this, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.LEAVE);
|
||||
Bukkit.getServer().getPluginManager().callEvent(leaveEvent);
|
||||
if (leaveEvent.isCancelled()) return;
|
||||
if (leaveEvent.isCancelled()) { return; }
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (makePay && !Econ.modifyMoney(this, -Conf.econCostLeave, "to leave your faction.", "for leaving your faction."))
|
||||
if (makePay && !Econ.modifyMoney(this, -Conf.econCostLeave, "to leave your faction.", "for leaving your faction.")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Am I the last one in the faction?
|
||||
if (myFaction.getFPlayers().size() == 1) {
|
||||
// Transfer all money
|
||||
if (Econ.shouldBeUsed())
|
||||
if (Econ.shouldBeUsed()) {
|
||||
Econ.transferMoney(this, myFaction, this, Econ.getBalance(myFaction.getAccountId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (myFaction.isNormal()) {
|
||||
@ -603,8 +604,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
fplayer.msg("%s<i> left %s<i>.", this.describeTo(fplayer, true), myFaction.describeTo(fplayer));
|
||||
}
|
||||
|
||||
if (Conf.logFactionLeave)
|
||||
P.p.log(this.getName() + " left the faction: " + myFaction.getTag());
|
||||
if (Conf.logFactionLeave) { P.p.log(this.getName() + " left the faction: " + myFaction.getTag()); }
|
||||
}
|
||||
|
||||
this.resetFactionData();
|
||||
@ -616,18 +616,19 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
myFaction.detach();
|
||||
if (Conf.logFactionDisband)
|
||||
if (Conf.logFactionDisband) {
|
||||
P.p.log("The faction " + myFaction.getTag() + " (" + myFaction.getId() + ") was disbanded due to the last player (" + this.getName() + ") leaving.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canClaimForFaction(Faction forFaction) {
|
||||
if (forFaction.isNone()) return false;
|
||||
if (forFaction.isNone()) { return false; }
|
||||
|
||||
if (this.isAdminBypassing()
|
||||
|| (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR))
|
||||
|| (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
|
||||
|| (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))) {
|
||||
|| (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR))
|
||||
|| (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
|
||||
|| (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -644,50 +645,70 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) {
|
||||
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||
error = P.p.txt.parse("<b>This land is protected");
|
||||
} else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
|
||||
}
|
||||
else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
|
||||
error = P.p.txt.parse("<b>Sorry, this world has land claiming disabled.");
|
||||
} else if (this.isAdminBypassing()) {
|
||||
}
|
||||
else if (this.isAdminBypassing()) {
|
||||
return true;
|
||||
} else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) {
|
||||
}
|
||||
else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) {
|
||||
return true;
|
||||
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
|
||||
}
|
||||
else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
|
||||
return true;
|
||||
} else if (myFaction != forFaction) {
|
||||
}
|
||||
else if (myFaction != forFaction) {
|
||||
error = P.p.txt.parse("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(this));
|
||||
} else if (forFaction == currentFaction) {
|
||||
}
|
||||
else if (forFaction == currentFaction) {
|
||||
error = P.p.txt.parse("%s<i> already own this land.", forFaction.describeTo(this, true));
|
||||
} else if (this.getRole().value < Role.MODERATOR.value) {
|
||||
}
|
||||
else if (this.getRole().value < Role.MODERATOR.value) {
|
||||
error = P.p.txt.parse("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
||||
} else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
|
||||
}
|
||||
else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
|
||||
error = P.p.txt.parse("Factions must have at least <h>%s<b> members to claim land.", Conf.claimsRequireMinFactionMembers);
|
||||
} else if (currentFaction.isSafeZone()) {
|
||||
}
|
||||
else if (currentFaction.isSafeZone()) {
|
||||
error = P.p.txt.parse("<b>You can not claim a Safe Zone.");
|
||||
} else if (currentFaction.isWarZone()) {
|
||||
}
|
||||
else if (currentFaction.isWarZone()) {
|
||||
error = P.p.txt.parse("<b>You can not claim a War Zone.");
|
||||
} else if (ownedLand >= forFaction.getPowerRounded()) {
|
||||
}
|
||||
else if (ownedLand >= forFaction.getPowerRounded()) {
|
||||
error = P.p.txt.parse("<b>You can't claim more land! You need more power!");
|
||||
} else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) {
|
||||
}
|
||||
else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) {
|
||||
error = P.p.txt.parse("<b>Limit reached. You can't claim more land!");
|
||||
} else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) {
|
||||
}
|
||||
else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) {
|
||||
error = P.p.txt.parse("<b>You can't claim the land of your allies.");
|
||||
} else if (Conf.claimsMustBeConnected
|
||||
&& !this.isAdminBypassing()
|
||||
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
|
||||
&& !Board.isConnectedLocation(flocation, myFaction)
|
||||
&& (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) {
|
||||
if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction)
|
||||
}
|
||||
else if (Conf.claimsMustBeConnected
|
||||
&& !this.isAdminBypassing()
|
||||
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
|
||||
&& !Board.isConnectedLocation(flocation, myFaction)
|
||||
&& (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) {
|
||||
if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) {
|
||||
error = P.p.txt.parse("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!");
|
||||
else
|
||||
}
|
||||
else {
|
||||
error = P.p.txt.parse("<b>You can only claim additional land which is connected to your first claim!");
|
||||
} else if (currentFaction.isNormal()) {
|
||||
}
|
||||
}
|
||||
else if (currentFaction.isNormal()) {
|
||||
if (myFaction.isPeaceful()) {
|
||||
error = P.p.txt.parse("%s<i> owns this land. Your faction is peaceful, so you cannot claim land from other factions.", currentFaction.getTag(this));
|
||||
} else if (currentFaction.isPeaceful()) {
|
||||
}
|
||||
else if (currentFaction.isPeaceful()) {
|
||||
error = P.p.txt.parse("%s<i> owns this land, and is a peaceful faction. You cannot claim land from them.", currentFaction.getTag(this));
|
||||
} else if (!currentFaction.hasLandInflation()) {
|
||||
}
|
||||
else if (!currentFaction.hasLandInflation()) {
|
||||
// TODO more messages WARN current faction most importantly
|
||||
error = P.p.txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this));
|
||||
} else if (!Board.isBorderLocation(flocation)) {
|
||||
}
|
||||
else if (!Board.isBorderLocation(flocation)) {
|
||||
error = P.p.txt.parse("<b>You must start claiming land at the border of the territory.");
|
||||
}
|
||||
}
|
||||
@ -707,7 +728,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
|
||||
int ownedLand = forFaction.getLandRounded();
|
||||
|
||||
if (!this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) return false;
|
||||
if (!this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) { return false; }
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
||||
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone();
|
||||
@ -716,23 +737,24 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
if (mustPay) {
|
||||
cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
||||
|
||||
if (Conf.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, forFaction))
|
||||
if (Conf.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, forFaction)) {
|
||||
cost += Conf.econClaimUnconnectedFee;
|
||||
}
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts && this.hasFaction())
|
||||
payee = this.getFaction();
|
||||
else
|
||||
payee = this;
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts && this.hasFaction()) { payee = this.getFaction(); }
|
||||
else { payee = this; }
|
||||
|
||||
if (!Econ.hasAtLeast(payee, cost, "to claim this land")) return false;
|
||||
if (!Econ.hasAtLeast(payee, cost, "to claim this land")) { return false; }
|
||||
}
|
||||
|
||||
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
|
||||
Bukkit.getServer().getPluginManager().callEvent(claimEvent);
|
||||
if (claimEvent.isCancelled()) return false;
|
||||
if (claimEvent.isCancelled()) { return false; }
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (mustPay && !Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) return false;
|
||||
if (mustPay && !Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// announce success
|
||||
Set<FPlayer> informTheseFPlayers = new HashSet<FPlayer>();
|
||||
@ -744,8 +766,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
|
||||
Board.setFactionAt(forFaction, flocation);
|
||||
|
||||
if (Conf.logLandClaims)
|
||||
if (Conf.logLandClaims) {
|
||||
P.p.log(this.getName() + " claimed land at (" + flocation.getCoordString() + ") for the faction: " + forFaction.getTag());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -756,8 +779,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
|
||||
@Override
|
||||
public boolean shouldBeSaved() {
|
||||
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting)))
|
||||
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) {
|
||||
return false;
|
||||
}
|
||||
return !this.deleteMe;
|
||||
}
|
||||
|
||||
|
@ -165,8 +165,9 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
public void confirmValidHome() {
|
||||
if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getFactionAt(new FLocation(this.home.getLocation())) == this))
|
||||
if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getFactionAt(new FLocation(this.home.getLocation())) == this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg("<b>Your faction home has been un-set since it is no longer in your territory.");
|
||||
this.home = null;
|
||||
@ -183,8 +184,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
String aid = "faction-" + this.getId();
|
||||
|
||||
// We need to override the default money given to players.
|
||||
if (!Econ.hasAccount(aid))
|
||||
Econ.setBalance(aid, 0);
|
||||
if (!Econ.hasAccount(aid)) { Econ.setBalance(aid, 0); }
|
||||
|
||||
return aid;
|
||||
}
|
||||
@ -312,7 +312,8 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
public void setRelationWish(Faction otherFaction, Relation relation) {
|
||||
if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Relation.NEUTRAL)) {
|
||||
this.relationWish.remove(otherFaction.getId());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.relationWish.put(otherFaction.getId(), relation);
|
||||
}
|
||||
}
|
||||
@ -377,7 +378,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
// maintain the reference list of FPlayers in this faction
|
||||
public void refreshFPlayers() {
|
||||
fplayers.clear();
|
||||
if (this.isPlayerFreeType()) return;
|
||||
if (this.isPlayerFreeType()) { return; }
|
||||
|
||||
for (FPlayer fplayer : FPlayers.i.get()) {
|
||||
if (fplayer.getFaction() == this) {
|
||||
@ -387,13 +388,13 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
protected boolean addFPlayer(FPlayer fplayer) {
|
||||
if (this.isPlayerFreeType()) return false;
|
||||
if (this.isPlayerFreeType()) { return false; }
|
||||
|
||||
return fplayers.add(fplayer);
|
||||
}
|
||||
|
||||
protected boolean removeFPlayer(FPlayer fplayer) {
|
||||
if (this.isPlayerFreeType()) return false;
|
||||
if (this.isPlayerFreeType()) { return false; }
|
||||
|
||||
return fplayers.remove(fplayer);
|
||||
}
|
||||
@ -417,7 +418,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
public FPlayer getFPlayerAdmin() {
|
||||
if (!this.isNormal()) return null;
|
||||
if (!this.isNormal()) { return null; }
|
||||
|
||||
for (FPlayer fplayer : fplayers) {
|
||||
if (fplayer.getRole() == Role.ADMIN) {
|
||||
@ -429,7 +430,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
|
||||
public ArrayList<FPlayer> getFPlayersWhereRole(Role role) {
|
||||
ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
if (!this.isNormal()) return ret;
|
||||
if (!this.isNormal()) { return ret; }
|
||||
|
||||
for (FPlayer fplayer : fplayers) {
|
||||
if (fplayer.getRole() == role) {
|
||||
@ -442,7 +443,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
|
||||
public ArrayList<Player> getOnlinePlayers() {
|
||||
ArrayList<Player> ret = new ArrayList<Player>();
|
||||
if (this.isPlayerFreeType()) return ret;
|
||||
if (this.isPlayerFreeType()) { return ret; }
|
||||
|
||||
for (Player player : P.p.getServer().getOnlinePlayers()) {
|
||||
FPlayer fplayer = FPlayers.i.get(player);
|
||||
@ -457,7 +458,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
// 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;
|
||||
if (this.isPlayerFreeType()) { return false; }
|
||||
|
||||
for (Player player : P.p.getServer().getOnlinePlayers()) {
|
||||
FPlayer fplayer = FPlayers.i.get(player);
|
||||
@ -481,35 +482,34 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
|
||||
// used when current leader is about to be removed from the faction; promotes new leader, or disbands faction if no other members left
|
||||
public void promoteNewLeader() {
|
||||
if (!this.isNormal()) return;
|
||||
if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) return;
|
||||
if (!this.isNormal()) { return; }
|
||||
if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) { return; }
|
||||
|
||||
FPlayer oldLeader = this.getFPlayerAdmin();
|
||||
|
||||
// get list of moderators, or list of normal members if there are no moderators
|
||||
ArrayList<FPlayer> replacements = this.getFPlayersWhereRole(Role.MODERATOR);
|
||||
if (replacements == null || replacements.isEmpty())
|
||||
replacements = this.getFPlayersWhereRole(Role.NORMAL);
|
||||
if (replacements == null || replacements.isEmpty()) { replacements = this.getFPlayersWhereRole(Role.NORMAL); }
|
||||
|
||||
if (replacements == null || replacements.isEmpty()) { // faction admin is the only member; one-man faction
|
||||
if (this.isPermanent()) {
|
||||
if (oldLeader != null)
|
||||
oldLeader.setRole(Role.NORMAL);
|
||||
if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); }
|
||||
return;
|
||||
}
|
||||
|
||||
// no members left and faction isn't permanent, so disband it
|
||||
if (Conf.logFactionDisband)
|
||||
if (Conf.logFactionDisband) {
|
||||
P.p.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left.");
|
||||
}
|
||||
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||
fplayer.msg("The faction %s<i> was disbanded.", this.getTag(fplayer));
|
||||
}
|
||||
|
||||
this.detach();
|
||||
} else { // promote new faction admin
|
||||
if (oldLeader != null)
|
||||
oldLeader.setRole(Role.NORMAL);
|
||||
}
|
||||
else { // promote new faction admin
|
||||
if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); }
|
||||
replacements.get(0).setRole(Role.ADMIN);
|
||||
this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
||||
P.p.log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName());
|
||||
@ -566,7 +566,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
for (Entry<FLocation, Set<String>> entry : claimOwnership.entrySet()) {
|
||||
ownerData = entry.getValue();
|
||||
|
||||
if (ownerData == null) continue;
|
||||
if (ownerData == null) { continue; }
|
||||
|
||||
Iterator<String> iter = ownerData.iterator();
|
||||
while (iter.hasNext()) {
|
||||
@ -653,21 +653,19 @@ public class Faction extends Entity implements EconomyParticipator {
|
||||
public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) {
|
||||
// in own faction, with sufficient role or permission to bypass ownership?
|
||||
if (fplayer.getFaction() == this
|
||||
&& (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN)
|
||||
|| Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) {
|
||||
&& (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN)
|
||||
|| Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// make sure claimOwnership is initialized
|
||||
if (claimOwnership.isEmpty())
|
||||
return true;
|
||||
if (claimOwnership.isEmpty()) { return true; }
|
||||
|
||||
// need to check the ownership list, then
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
|
||||
// if no owner list, owner list is empty, or player is in owner list, they're allowed
|
||||
if (ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId()))
|
||||
return true;
|
||||
if (ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId())) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -33,14 +33,15 @@ public class Factions extends EntityCollection<Faction> {
|
||||
|
||||
@Override
|
||||
public boolean loadFromDisc() {
|
||||
if (!super.loadFromDisc()) return false;
|
||||
if (!super.loadFromDisc()) { return false; }
|
||||
|
||||
// Make sure the default neutral faction exists
|
||||
if (!this.exists("0")) {
|
||||
Faction faction = this.create("0");
|
||||
faction.setTag(TL.WILDERNESS.toString());
|
||||
faction.setDescription(TL.WILDERNESS_DESCRIPTION.toString());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!this.get("0").getTag().equalsIgnoreCase(TL.WILDERNESS.toString())) {
|
||||
get("0").setTag(TL.WILDERNESS.toString());
|
||||
}
|
||||
@ -54,17 +55,17 @@ public class Factions extends EntityCollection<Faction> {
|
||||
Faction faction = this.create("-1");
|
||||
faction.setTag(TL.SAFEZONE.toString());
|
||||
faction.setDescription(TL.SAFEZONE_DESCRIPTION.toString());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!getSafeZone().getTag().equalsIgnoreCase(TL.SAFEZONE.toString())) {
|
||||
getSafeZone().setTag(TL.SAFEZONE.toString());
|
||||
}
|
||||
if(!getSafeZone().getDescription().equalsIgnoreCase(TL.SAFEZONE_DESCRIPTION.toString())) {
|
||||
if (!getSafeZone().getDescription().equalsIgnoreCase(TL.SAFEZONE_DESCRIPTION.toString())) {
|
||||
getSafeZone().setDescription(TL.SAFEZONE_DESCRIPTION.toString());
|
||||
}
|
||||
// if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||
Faction faction = this.getSafeZone();
|
||||
if (faction.getTag().contains(" "))
|
||||
faction.setTag(TL.SAFEZONE.toString());
|
||||
if (faction.getTag().contains(" ")) { faction.setTag(TL.SAFEZONE.toString()); }
|
||||
}
|
||||
|
||||
// Make sure the war zone faction exists
|
||||
@ -72,17 +73,17 @@ public class Factions extends EntityCollection<Faction> {
|
||||
Faction faction = this.create("-2");
|
||||
faction.setTag(TL.WARZONE.toString());
|
||||
faction.setDescription(TL.WARZONE_DESCRIPTION.toString());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!getWarZone().getTag().equalsIgnoreCase(TL.WARZONE.toString())) {
|
||||
getWarZone().setTag(TL.WARZONE.toString());
|
||||
}
|
||||
if(!getWarZone().getDescription().equalsIgnoreCase(TL.WARZONE_DESCRIPTION.toString())) {
|
||||
if (!getWarZone().getDescription().equalsIgnoreCase(TL.WARZONE_DESCRIPTION.toString())) {
|
||||
getWarZone().setDescription(TL.WARZONE_DESCRIPTION.toString());
|
||||
}
|
||||
// if WarZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||
Faction faction = this.getWarZone();
|
||||
if (faction.getTag().contains(" "))
|
||||
faction.setTag(TL.WARZONE.toString());
|
||||
if (faction.getTag().contains(" ")) { faction.setTag(TL.WARZONE.toString()); }
|
||||
}
|
||||
|
||||
// populate all faction player lists
|
||||
@ -166,7 +167,7 @@ public class Factions extends EntityCollection<Faction> {
|
||||
}
|
||||
|
||||
String tag = TextUtil.getBestStartWithCI(tag2faction.keySet(), searchFor);
|
||||
if (tag == null) return null;
|
||||
if (tag == null) { return null; }
|
||||
return tag2faction.get(tag);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class P extends MPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preEnable()) return;
|
||||
if (!preEnable()) { return; }
|
||||
this.loadSuccessful = false;
|
||||
|
||||
// Load Conf from disk
|
||||
@ -123,11 +123,11 @@ public class P extends MPlugin {
|
||||
}.getType();
|
||||
|
||||
return new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE)
|
||||
.registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter())
|
||||
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter());
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE)
|
||||
.registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter())
|
||||
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -146,7 +146,7 @@ public class P extends MPlugin {
|
||||
|
||||
public void startAutoLeaveTask(boolean restartIfRunning) {
|
||||
if (AutoLeaveTask != null) {
|
||||
if (!restartIfRunning) return;
|
||||
if (!restartIfRunning) { return; }
|
||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||
}
|
||||
|
||||
@ -169,8 +169,9 @@ public class P extends MPlugin {
|
||||
|
||||
@Override
|
||||
public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) {
|
||||
if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender))
|
||||
if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.handleCommand(sender, commandString, testOnly);
|
||||
}
|
||||
@ -178,7 +179,7 @@ public class P extends MPlugin {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
||||
// if bare command at this point, it has already been handled by MPlugin's command listeners
|
||||
if (split == null || split.length == 0) return true;
|
||||
if (split == null || split.length == 0) { return true; }
|
||||
|
||||
// otherwise, needs to be handled; presumably another plugin directly ran the command
|
||||
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
||||
@ -204,17 +205,17 @@ public class P extends MPlugin {
|
||||
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
|
||||
|
||||
public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) {
|
||||
if (event == null) return false;
|
||||
if (event == null) { return false; }
|
||||
return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
|
||||
}
|
||||
|
||||
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
|
||||
// local chat, or anything else which targets individual recipients, so Faction Chat can be done
|
||||
public boolean isPlayerFactionChatting(Player player) {
|
||||
if (player == null) return false;
|
||||
if (player == null) { return false; }
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
|
||||
if (me == null) return false;
|
||||
if (me == null) { return false; }
|
||||
return me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
||||
}
|
||||
|
||||
@ -223,7 +224,7 @@ public class P extends MPlugin {
|
||||
// TODO: GET THIS BACK AND WORKING
|
||||
|
||||
public boolean isFactionsCommand(String check) {
|
||||
if (check == null || check.isEmpty()) return false;
|
||||
if (check == null || check.isEmpty()) { return false; }
|
||||
return this.handleCommand(null, check, true);
|
||||
}
|
||||
|
||||
@ -236,37 +237,32 @@ public class P extends MPlugin {
|
||||
public String getPlayerFactionTagRelation(Player speaker, Player listener) {
|
||||
String tag = "~";
|
||||
|
||||
if (speaker == null)
|
||||
return tag;
|
||||
if (speaker == null) { return tag; }
|
||||
|
||||
FPlayer me = FPlayers.i.get(speaker);
|
||||
if (me == null)
|
||||
return tag;
|
||||
if (me == null) { return tag; }
|
||||
|
||||
// if listener isn't set, or config option is disabled, give back uncolored tag
|
||||
if (listener == null || !Conf.chatTagRelationColored) {
|
||||
tag = me.getChatTag().trim();
|
||||
} else {
|
||||
FPlayer you = FPlayers.i.get(listener);
|
||||
if (you == null)
|
||||
tag = me.getChatTag().trim();
|
||||
else // everything checks out, give the colored tag
|
||||
tag = me.getChatTag(you).trim();
|
||||
}
|
||||
if (tag.isEmpty())
|
||||
tag = "~";
|
||||
else {
|
||||
FPlayer you = FPlayers.i.get(listener);
|
||||
if (you == null) { tag = me.getChatTag().trim(); }
|
||||
else // everything checks out, give the colored tag
|
||||
{ tag = me.getChatTag(you).trim(); }
|
||||
}
|
||||
if (tag.isEmpty()) { tag = "~"; }
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
|
||||
public String getPlayerTitle(Player player) {
|
||||
if (player == null)
|
||||
return "";
|
||||
if (player == null) { return ""; }
|
||||
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
if (me == null)
|
||||
return "";
|
||||
if (me == null) { return ""; }
|
||||
|
||||
return me.getTitle().trim();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class CmdAdmin extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer fyou = this.argAsBestFPlayerMatch(0);
|
||||
if (fyou == null) return;
|
||||
if (fyou == null) { return; }
|
||||
|
||||
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
|
||||
Faction targetFaction = fyou.getFaction();
|
||||
@ -52,7 +52,7 @@ public class CmdAdmin extends FCommand {
|
||||
if (fyou.getFaction() != targetFaction) {
|
||||
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.i.get(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
}
|
||||
|
||||
FPlayer admin = targetFaction.getFPlayerAdmin();
|
||||
@ -66,8 +66,7 @@ public class CmdAdmin extends FCommand {
|
||||
}
|
||||
|
||||
// promote target player, and demote existing admin if one exists
|
||||
if (admin != null)
|
||||
admin.setRole(Role.MODERATOR);
|
||||
if (admin != null) { admin.setRole(Role.MODERATOR); }
|
||||
fyou.setRole(Role.ADMIN);
|
||||
msg("<i>You have promoted %s<i> to the position of faction admin.", fyou.describeTo(fme, true));
|
||||
|
||||
|
@ -31,10 +31,8 @@ public class CmdAutoClaim extends FCommand {
|
||||
}
|
||||
|
||||
if (!fme.canClaimForFaction(forFaction)) {
|
||||
if (myFaction == forFaction)
|
||||
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
||||
else
|
||||
msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme));
|
||||
if (myFaction == forFaction) { msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString()); }
|
||||
else { msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme)); }
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class CmdAutoHelp extends MCommand<P> {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (this.commandChain.size() == 0) return;
|
||||
if (this.commandChain.size() == 0) { return; }
|
||||
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
||||
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
|
@ -28,7 +28,7 @@ public class CmdBoom extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) return;
|
||||
if (!payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) { return; }
|
||||
|
||||
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled()));
|
||||
|
||||
|
@ -28,7 +28,8 @@ public class CmdBypass extends FCommand {
|
||||
if (fme.isAdminBypassing()) {
|
||||
fme.msg("<i>You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
|
||||
P.p.log(fme.getName() + " has ENABLED admin bypass mode.");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fme.msg("<i>You have disabled admin bypass mode.");
|
||||
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
||||
}
|
||||
|
@ -37,11 +37,14 @@ public class CmdChat extends FCommand {
|
||||
modeString.toLowerCase();
|
||||
if (modeString.startsWith("p")) {
|
||||
modeTarget = ChatMode.PUBLIC;
|
||||
} else if (modeString.startsWith("a")) {
|
||||
}
|
||||
else if (modeString.startsWith("a")) {
|
||||
modeTarget = ChatMode.ALLIANCE;
|
||||
} else if (modeString.startsWith("f")) {
|
||||
}
|
||||
else if (modeString.startsWith("f")) {
|
||||
modeTarget = ChatMode.FACTION;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
|
||||
return;
|
||||
}
|
||||
@ -51,9 +54,11 @@ public class CmdChat extends FCommand {
|
||||
|
||||
if (fme.getChatMode() == ChatMode.PUBLIC) {
|
||||
msg("<i>Public chat mode.");
|
||||
} else if (fme.getChatMode() == ChatMode.ALLIANCE) {
|
||||
}
|
||||
else if (fme.getChatMode() == ChatMode.ALLIANCE) {
|
||||
msg("<i>Alliance only chat mode.");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
msg("<i>Faction only chat mode.");
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ public class CmdChatSpy extends FCommand {
|
||||
if (fme.isSpyingChat()) {
|
||||
fme.msg("<i>You have enabled chat spying mode.");
|
||||
P.p.log(fme.getName() + " has ENABLED chat spying mode.");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fme.msg("<i>You have disabled chat spying mode.");
|
||||
P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ public class CmdClaim extends FCommand {
|
||||
if (radius < 2) {
|
||||
// single chunk
|
||||
fme.attemptClaim(forFaction, me.getLocation(), true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||
msg("<b>You do not have permission to claim in a radius.");
|
||||
@ -54,8 +55,7 @@ public class CmdClaim extends FCommand {
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true);
|
||||
if (success)
|
||||
failCount = 0;
|
||||
if (success) { failCount = 0; }
|
||||
else if (!success && failCount++ >= limit) {
|
||||
this.stop();
|
||||
return false;
|
||||
|
@ -72,7 +72,8 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
if (targetValue) {
|
||||
success = "\"" + fieldName + "\" option set to true (enabled).";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
success = "\"" + fieldName + "\" option set to false (disabled).";
|
||||
}
|
||||
}
|
||||
@ -231,8 +232,9 @@ public class CmdConfig extends FCommand {
|
||||
if (sender instanceof Player) {
|
||||
sendMessage(success);
|
||||
P.p.log(success + " Command was run by " + fme.getName() + ".");
|
||||
} else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
||||
P.p.log(success);
|
||||
}
|
||||
else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
||||
{ P.p.log(success); }
|
||||
}
|
||||
// save change to disk
|
||||
Conf.save();
|
||||
|
@ -48,15 +48,15 @@ public class CmdCreate extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!canAffordCommand(Conf.econCostCreate, "to create a new faction")) return;
|
||||
if (!canAffordCommand(Conf.econCostCreate, "to create a new faction")) { return; }
|
||||
|
||||
// trigger the faction creation event (cancellable)
|
||||
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag);
|
||||
Bukkit.getServer().getPluginManager().callEvent(createEvent);
|
||||
if (createEvent.isCancelled()) return;
|
||||
if (createEvent.isCancelled()) { return; }
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return;
|
||||
if (!payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) { return; }
|
||||
|
||||
Faction faction = Factions.i.create();
|
||||
|
||||
@ -84,8 +84,7 @@ public class CmdCreate extends FCommand {
|
||||
|
||||
msg("<i>You should now: %s", p.cmdBase.cmdDescription.getUseageTemplate());
|
||||
|
||||
if (Conf.logFactionCreate)
|
||||
P.p.log(fme.getName() + " created a new faction: " + tag);
|
||||
if (Conf.logFactionCreate) { P.p.log(fme.getName() + " created a new faction: " + tag); }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class CmdDeinvite extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) return;
|
||||
if (you == null) { return; }
|
||||
|
||||
if (you.getFaction() == myFaction) {
|
||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||
|
@ -27,8 +27,9 @@ public class CmdDescription extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description"))
|
||||
if (!payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description")) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("(&([a-f0-9]))", "& $2")); // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up
|
||||
|
||||
|
@ -30,13 +30,14 @@ public class CmdDisband extends FCommand {
|
||||
public void perform() {
|
||||
// The faction, default to your own.. but null if console sender.
|
||||
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
|
||||
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
||||
|
||||
if (isMyFaction) {
|
||||
if (!assertMinRole(Role.ADMIN)) return;
|
||||
} else {
|
||||
if (!assertMinRole(Role.ADMIN)) { return; }
|
||||
}
|
||||
else {
|
||||
if (!Permission.DISBAND_ANY.has(sender, true)) {
|
||||
return;
|
||||
}
|
||||
@ -53,7 +54,7 @@ public class CmdDisband extends FCommand {
|
||||
|
||||
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
|
||||
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
|
||||
if (disbandEvent.isCancelled()) return;
|
||||
if (disbandEvent.isCancelled()) { return; }
|
||||
|
||||
// Send FPlayerLeaveEvent for each player in the faction
|
||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||
@ -65,12 +66,14 @@ public class CmdDisband extends FCommand {
|
||||
String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer);
|
||||
if (fplayer.getFaction() == faction) {
|
||||
fplayer.msg("<h>%s<i> disbanded your faction.", who);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
||||
}
|
||||
}
|
||||
if (Conf.logFactionDisband)
|
||||
if (Conf.logFactionDisband) {
|
||||
P.p.log("The faction " + faction.getTag() + " (" + faction.getId() + ") was disbanded by " + (senderIsConsole ? "console command" : fme.getName()) + ".");
|
||||
}
|
||||
|
||||
if (Econ.shouldBeUsed() && !senderIsConsole) {
|
||||
//Give all the faction's money to the disbander
|
||||
|
@ -30,7 +30,7 @@ public class CmdHelp extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (helpPages == null) updateHelp();
|
||||
if (helpPages == null) { updateHelp(); }
|
||||
|
||||
int page = this.argAsInt(0, 1);
|
||||
|
||||
|
@ -87,12 +87,10 @@ public class CmdHome extends FCommand {
|
||||
double z = loc.getZ();
|
||||
|
||||
for (Player p : me.getServer().getOnlinePlayers()) {
|
||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
|
||||
continue;
|
||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { continue; }
|
||||
|
||||
FPlayer fp = FPlayers.i.get(p);
|
||||
if (fme.getRelationTo(fp) != Relation.ENEMY)
|
||||
continue;
|
||||
if (fme.getRelationTo(fp) != Relation.ENEMY) { continue; }
|
||||
|
||||
Location l = p.getLocation();
|
||||
double dx = Math.abs(x - l.getX());
|
||||
@ -101,8 +99,7 @@ public class CmdHome extends FCommand {
|
||||
double max = Conf.homesTeleportAllowedEnemyDistance;
|
||||
|
||||
// box-shaped distance check
|
||||
if (dx > max || dy > max || dz > max)
|
||||
continue;
|
||||
if (dx > max || dy > max || dz > max) { continue; }
|
||||
|
||||
fme.msg("<b>You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you.");
|
||||
return;
|
||||
@ -110,11 +107,12 @@ public class CmdHome extends FCommand {
|
||||
}
|
||||
|
||||
// if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
|
||||
if (Essentials.handleTeleport(me, myFaction.getHome())) return;
|
||||
if (Essentials.handleTeleport(me, myFaction.getHome())) { return; }
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home"))
|
||||
if (!payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
|
@ -25,7 +25,7 @@ public class CmdInvite extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) return;
|
||||
if (you == null) { return; }
|
||||
|
||||
if (you.getFaction() == myFaction) {
|
||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||
@ -34,7 +34,7 @@ public class CmdInvite extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) return;
|
||||
if (!payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) { return; }
|
||||
|
||||
myFaction.invite(you);
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class CmdJoin extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
|
||||
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);
|
||||
boolean samePlayer = fplayer == fme;
|
||||
@ -62,26 +62,26 @@ public class CmdJoin extends FCommand {
|
||||
|
||||
if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) {
|
||||
msg("<i>This faction requires invitation.");
|
||||
if (samePlayer)
|
||||
faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true));
|
||||
if (samePlayer) { faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true)); }
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (samePlayer && !canAffordCommand(Conf.econCostJoin, "to join a faction")) return;
|
||||
if (samePlayer && !canAffordCommand(Conf.econCostJoin, "to join a faction")) { return; }
|
||||
|
||||
// trigger the join event (cancellable)
|
||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||
if (joinEvent.isCancelled()) return;
|
||||
if (joinEvent.isCancelled()) { return; }
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (samePlayer && !payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) return;
|
||||
if (samePlayer && !payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) { return; }
|
||||
|
||||
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
|
||||
|
||||
if (!samePlayer)
|
||||
if (!samePlayer) {
|
||||
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
||||
}
|
||||
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
||||
|
||||
fplayer.resetFactionData();
|
||||
@ -89,10 +89,10 @@ public class CmdJoin extends FCommand {
|
||||
faction.deinvite(fplayer);
|
||||
|
||||
if (Conf.logFactionJoin) {
|
||||
if (samePlayer)
|
||||
P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag());
|
||||
else
|
||||
if (samePlayer) { P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag()); }
|
||||
else {
|
||||
P.p.log("%s moved the player %s into the faction %s.", fme.getName(), fplayer.getName(), faction.getTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class CmdKick extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) return;
|
||||
if (you == null) { return; }
|
||||
|
||||
if (fme == you) {
|
||||
msg("<b>You cannot kick yourself.");
|
||||
@ -60,16 +60,17 @@ public class CmdKick extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!canAffordCommand(Conf.econCostKick, "to kick someone from the faction")) return;
|
||||
if (!canAffordCommand(Conf.econCostKick, "to kick someone from the faction")) { return; }
|
||||
|
||||
// trigger the leave event (cancellable) [reason:kicked]
|
||||
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction"))
|
||||
if (!payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) {
|
||||
return;
|
||||
}
|
||||
|
||||
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
|
||||
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
|
||||
@ -77,11 +78,11 @@ public class CmdKick extends FCommand {
|
||||
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.describeTo(fme), yourFaction.describeTo(fme));
|
||||
}
|
||||
|
||||
if (Conf.logFactionKick)
|
||||
if (Conf.logFactionKick) {
|
||||
P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + you.getName() + " from the faction: " + yourFaction.getTag());
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.ADMIN)
|
||||
yourFaction.promoteNewLeader();
|
||||
if (you.getRole() == Role.ADMIN) { yourFaction.promoteNewLeader(); }
|
||||
|
||||
yourFaction.deinvite(you);
|
||||
you.resetFactionData();
|
||||
|
@ -32,7 +32,7 @@ public class CmdList extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return;
|
||||
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) { return; }
|
||||
|
||||
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
||||
factionList.remove(Factions.i.getNone());
|
||||
@ -45,10 +45,8 @@ public class CmdList extends FCommand {
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
int f1Size = f1.getFPlayers().size();
|
||||
int f2Size = f2.getFPlayers().size();
|
||||
if (f1Size < f2Size)
|
||||
return 1;
|
||||
else if (f1Size > f2Size)
|
||||
return -1;
|
||||
if (f1Size < f2Size) { return 1; }
|
||||
else if (f1Size > f2Size) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
@ -59,10 +57,8 @@ public class CmdList extends FCommand {
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||
if (f1Size < f2Size)
|
||||
return 1;
|
||||
else if (f1Size > f2Size)
|
||||
return -1;
|
||||
if (f1Size < f2Size) { return 1; }
|
||||
else if (f1Size > f2Size) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
@ -91,14 +87,11 @@ public class CmdList extends FCommand {
|
||||
final int pageheight = 9;
|
||||
int pagenumber = this.argAsInt(0, 1);
|
||||
int pagecount = (factionList.size() / pageheight) + 1;
|
||||
if (pagenumber > pagecount)
|
||||
pagenumber = pagecount;
|
||||
else if (pagenumber < 1)
|
||||
pagenumber = 1;
|
||||
if (pagenumber > pagecount) { pagenumber = pagecount; }
|
||||
else if (pagenumber < 1) { pagenumber = 1; }
|
||||
int start = (pagenumber - 1) * pageheight;
|
||||
int end = start + pageheight;
|
||||
if (end > factionList.size())
|
||||
end = factionList.size();
|
||||
if (end > factionList.size()) { end = factionList.size(); }
|
||||
|
||||
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount));
|
||||
|
||||
@ -108,12 +101,12 @@ public class CmdList extends FCommand {
|
||||
continue;
|
||||
}
|
||||
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
||||
faction.getTag(fme),
|
||||
faction.getFPlayersWhereOnline(true).size(),
|
||||
faction.getFPlayers().size(),
|
||||
faction.getLandRounded(),
|
||||
faction.getPowerRounded(),
|
||||
faction.getPowerMaxRounded())
|
||||
faction.getTag(fme),
|
||||
faction.getFPlayersWhereOnline(true).size(),
|
||||
faction.getFPlayers().size(),
|
||||
faction.getLandRounded(),
|
||||
faction.getPowerRounded(),
|
||||
faction.getPowerMaxRounded())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,8 @@ public class CmdLock extends FCommand {
|
||||
|
||||
if (p.getLocked()) {
|
||||
msg("<i>Factions is now locked");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
msg("<i>Factions in now unlocked");
|
||||
}
|
||||
}
|
||||
|
@ -30,21 +30,23 @@ public class CmdMap extends FCommand {
|
||||
// Turn on
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return;
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
||||
|
||||
fme.setMapAutoUpdating(true);
|
||||
msg("<i>Map auto update <green>ENABLED.");
|
||||
|
||||
// And show the map once
|
||||
showMap();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Turn off
|
||||
fme.setMapAutoUpdating(false);
|
||||
msg("<i>Map auto update <red>DISABLED.");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return;
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
||||
|
||||
showMap();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class CmdMod extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) return;
|
||||
if (you == null) { return; }
|
||||
|
||||
boolean permAny = Permission.MOD_ANY.has(sender, false);
|
||||
Faction targetFaction = you.getFaction();
|
||||
@ -56,7 +56,8 @@ public class CmdMod extends FCommand {
|
||||
you.setRole(Role.NORMAL);
|
||||
targetFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(targetFaction, true));
|
||||
msg("<i>You have removed moderator status from %s<i>.", you.describeTo(fme, true));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Give
|
||||
you.setRole(Role.MODERATOR);
|
||||
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));
|
||||
|
@ -29,8 +29,8 @@ public class CmdMoneyBalance extends FCommand {
|
||||
faction = this.argAsFaction(0);
|
||||
}
|
||||
|
||||
if (faction == null) return;
|
||||
if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) return;
|
||||
if (faction == null) { return; }
|
||||
if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) { return; }
|
||||
|
||||
Econ.sendBalanceInfo(fme, faction);
|
||||
}
|
||||
|
@ -31,11 +31,12 @@ public class CmdMoneyDeposit extends FCommand {
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions)
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,13 +31,14 @@ public class CmdMoneyTransferFf extends FCommand {
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsFaction(1);
|
||||
if (from == null) return;
|
||||
if (from == null) { return; }
|
||||
EconomyParticipator to = this.argAsFaction(2);
|
||||
if (to == null) return;
|
||||
if (to == null) { return; }
|
||||
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions)
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,14 @@ public class CmdMoneyTransferFp extends FCommand {
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsFaction(1);
|
||||
if (from == null) return;
|
||||
if (from == null) { return; }
|
||||
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
||||
if (to == null) return;
|
||||
if (to == null) { return; }
|
||||
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions)
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,14 @@ public class CmdMoneyTransferPf extends FCommand {
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
||||
if (from == null) return;
|
||||
if (from == null) { return; }
|
||||
EconomyParticipator to = this.argAsFaction(2);
|
||||
if (to == null) return;
|
||||
if (to == null) { return; }
|
||||
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions)
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,10 +29,11 @@ public class CmdMoneyWithdraw extends FCommand {
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions)
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ public class CmdOpen extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostOpen, "to open or close the faction", "for opening or closing the faction"))
|
||||
if (!payForCommand(Conf.econCostOpen, "to open or close the faction", "for opening or closing the faction")) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class CmdOwner extends FCommand {
|
||||
}
|
||||
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
||||
if (target == null) return;
|
||||
if (target == null) { return; }
|
||||
|
||||
String playerName = target.getName();
|
||||
|
||||
@ -86,8 +86,9 @@ public class CmdOwner extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land"))
|
||||
if (!payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setPlayerAsOwner(target, flocation);
|
||||
|
||||
|
@ -26,13 +26,14 @@ public class CmdPeaceful extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
|
||||
String change;
|
||||
if (faction.isPeaceful()) {
|
||||
change = "removed peaceful status from";
|
||||
faction.setPeaceful(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
change = "granted peaceful status to";
|
||||
faction.setPeaceful(true);
|
||||
}
|
||||
@ -41,7 +42,8 @@ public class CmdPeaceful extends FCommand {
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||
if (fplayer.getFaction() == faction) {
|
||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " your faction.");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " the faction \"" + faction.getTag(fplayer) + "<i>\".");
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,14 @@ public class CmdPermanent extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
|
||||
String change;
|
||||
if (faction.isPermanent()) {
|
||||
change = "removed permanent status from";
|
||||
faction.setPermanent(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
change = "added permanent status to";
|
||||
faction.setPermanent(true);
|
||||
}
|
||||
@ -44,7 +45,8 @@ public class CmdPermanent extends FCommand {
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||
if (fplayer.getFaction() == faction) {
|
||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " your faction.");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " the faction \"" + faction.getTag(fplayer) + "\".");
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class CmdPermanentPower extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction targetFaction = this.argAsFaction(0);
|
||||
if (targetFaction == null) return;
|
||||
if (targetFaction == null) { return; }
|
||||
|
||||
Integer targetPower = this.argAsInt(1);
|
||||
|
||||
|
@ -26,12 +26,14 @@ public class CmdPower extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
||||
if (target == null) return;
|
||||
if (target == null) { return; }
|
||||
|
||||
if (target != fme && !Permission.POWER_ANY.has(sender, true)) return;
|
||||
if (target != fme && !Permission.POWER_ANY.has(sender, true)) { return; }
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) return;
|
||||
if (!payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) {
|
||||
return;
|
||||
}
|
||||
|
||||
double powerBoost = target.getPowerBoost();
|
||||
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
||||
|
@ -29,7 +29,8 @@ public class CmdPowerBoost extends FCommand {
|
||||
boolean doPlayer = true;
|
||||
if (type.equals("f") || type.equals("faction")) {
|
||||
doPlayer = false;
|
||||
} else if (!type.equals("p") && !type.equals("player")) {
|
||||
}
|
||||
else if (!type.equals("p") && !type.equals("player")) {
|
||||
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
|
||||
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5");
|
||||
return;
|
||||
@ -45,18 +46,20 @@ public class CmdPowerBoost extends FCommand {
|
||||
|
||||
if (doPlayer) {
|
||||
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
|
||||
if (targetPlayer == null) return;
|
||||
if (targetPlayer == null) { return; }
|
||||
targetPlayer.setPowerBoost(targetPower);
|
||||
target = "Player \"" + targetPlayer.getName() + "\"";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Faction targetFaction = this.argAsFaction(1);
|
||||
if (targetFaction == null) return;
|
||||
if (targetFaction == null) { return; }
|
||||
targetFaction.setPowerBoost(targetPower);
|
||||
target = "Faction \"" + targetFaction.getTag() + "\"";
|
||||
}
|
||||
|
||||
msg("<i>" + target + " now has a power bonus/penalty of " + targetPower + " to min and max power levels.");
|
||||
if (!senderIsConsole)
|
||||
if (!senderIsConsole) {
|
||||
P.p.log(fme.getName() + " has set the power bonus/penalty for " + target + " to " + targetPower + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,22 +31,27 @@ public class CmdReload extends FCommand {
|
||||
if (file.startsWith("c")) {
|
||||
Conf.load();
|
||||
fileName = "conf.json";
|
||||
} else if (file.startsWith("b")) {
|
||||
}
|
||||
else if (file.startsWith("b")) {
|
||||
Board.load();
|
||||
fileName = "board.json";
|
||||
} else if (file.startsWith("f")) {
|
||||
}
|
||||
else if (file.startsWith("f")) {
|
||||
Factions.i.loadFromDisc();
|
||||
fileName = "factions.json";
|
||||
} else if (file.startsWith("p")) {
|
||||
}
|
||||
else if (file.startsWith("p")) {
|
||||
FPlayers.i.loadFromDisc();
|
||||
fileName = "players.json";
|
||||
} else if (file.startsWith("a")) {
|
||||
}
|
||||
else if (file.startsWith("a")) {
|
||||
fileName = "all";
|
||||
Conf.load();
|
||||
FPlayers.i.loadFromDisc();
|
||||
Factions.i.loadFromDisc();
|
||||
Board.load();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
||||
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
|
||||
return;
|
||||
|
@ -31,8 +31,7 @@ public class CmdSafeunclaimall extends FCommand {
|
||||
Board.unclaimAll(Factions.i.getSafeZone().getId());
|
||||
msg("<i>You unclaimed ALL safe zone land.");
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
P.p.log(fme.getName() + " unclaimed all safe zones.");
|
||||
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all safe zones."); }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,13 +31,14 @@ public class CmdSethome extends FCommand {
|
||||
}
|
||||
|
||||
Faction faction = this.argAsFaction(0, myFaction);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
|
||||
// Can the player set the home for this faction?
|
||||
if (faction == myFaction) {
|
||||
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) return;
|
||||
} else {
|
||||
if (!Permission.SETHOME_ANY.has(sender, true)) return;
|
||||
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) { return; }
|
||||
}
|
||||
else {
|
||||
if (!Permission.SETHOME_ANY.has(sender, true)) { return; }
|
||||
}
|
||||
|
||||
// Can the player set the faction home HERE?
|
||||
@ -54,7 +55,7 @@ public class CmdSethome extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostSethome, "to set the faction home", "for setting the faction home")) return;
|
||||
if (!payForCommand(Conf.econCostSethome, "to set the faction home", "for setting the faction home")) { return; }
|
||||
|
||||
faction.setHome(me.getLocation());
|
||||
|
||||
|
@ -34,11 +34,13 @@ public class CmdShow extends FCommand {
|
||||
Faction faction = myFaction;
|
||||
if (this.argIsSet(0)) {
|
||||
faction = this.argAsFaction(0);
|
||||
if (faction == null) return;
|
||||
if (faction == null) { return; }
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return;
|
||||
if (!payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
||||
@ -87,22 +89,19 @@ public class CmdShow extends FCommand {
|
||||
String allyList = p.txt.parse("<a>Allies: ");
|
||||
String enemyList = p.txt.parse("<a>Enemies: ");
|
||||
for (Faction otherFaction : Factions.i.get()) {
|
||||
if (otherFaction == faction) continue;
|
||||
if (otherFaction == faction) { continue; }
|
||||
|
||||
Relation rel = otherFaction.getRelationTo(faction);
|
||||
if (!rel.isAlly() && !rel.isEnemy())
|
||||
if (!rel.isAlly() && !rel.isEnemy()) {
|
||||
continue; // if not ally or enemy, drop out now so we're not wasting time on it; good performance boost
|
||||
}
|
||||
|
||||
listpart = otherFaction.getTag(fme) + p.txt.parse("<i>") + ", ";
|
||||
if (rel.isAlly())
|
||||
allyList += listpart;
|
||||
else if (rel.isEnemy())
|
||||
enemyList += listpart;
|
||||
if (rel.isAlly()) { allyList += listpart; }
|
||||
else if (rel.isEnemy()) { enemyList += listpart; }
|
||||
}
|
||||
if (allyList.endsWith(", "))
|
||||
allyList = allyList.substring(0, allyList.length() - 2);
|
||||
if (enemyList.endsWith(", "))
|
||||
enemyList = enemyList.substring(0, enemyList.length() - 2);
|
||||
if (allyList.endsWith(", ")) { allyList = allyList.substring(0, allyList.length() - 2); }
|
||||
if (enemyList.endsWith(", ")) { enemyList = enemyList.substring(0, enemyList.length() - 2); }
|
||||
|
||||
sendMessage(allyList);
|
||||
sendMessage(enemyList);
|
||||
@ -114,7 +113,8 @@ public class CmdShow extends FCommand {
|
||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||
if (follower.isOnlineAndVisibleTo(me)) {
|
||||
onlineList += listpart;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
offlineList += listpart;
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,8 @@ public class CmdShow extends FCommand {
|
||||
if
|
||||
(follower.isOnlineAndVisibleTo(me)) {
|
||||
onlineList += listpart;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
offlineList += listpart;
|
||||
}
|
||||
}
|
||||
@ -131,7 +132,8 @@ public class CmdShow extends FCommand {
|
||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||
if (follower.isOnlineAndVisibleTo(me)) {
|
||||
onlineList += listpart;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
offlineList += listpart;
|
||||
}
|
||||
}
|
||||
|
@ -45,15 +45,15 @@ public class CmdTag extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!canAffordCommand(Conf.econCostTag, "to change the faction tag")) return;
|
||||
if (!canAffordCommand(Conf.econCostTag, "to change the faction tag")) { return; }
|
||||
|
||||
// trigger the faction rename event (cancellable)
|
||||
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
||||
if (renameEvent.isCancelled()) return;
|
||||
if (renameEvent.isCancelled()) { return; }
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) return;
|
||||
if (!payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) { return; }
|
||||
|
||||
String oldtag = myFaction.getTag();
|
||||
myFaction.setTag(tag);
|
||||
|
@ -24,15 +24,15 @@ public class CmdTitle extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) return;
|
||||
if (you == null) { return; }
|
||||
|
||||
args.remove(0);
|
||||
String title = TextUtil.implode(args, " ");
|
||||
|
||||
if (!canIAdministerYou(fme, you)) return;
|
||||
if (!canIAdministerYou(fme, you)) { return; }
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostTitle, "to change a players title", "for changing a players title")) return;
|
||||
if (!payForCommand(Conf.econCostTitle, "to change a players title", "for changing a players title")) { return; }
|
||||
|
||||
you.setTitle(title);
|
||||
|
||||
|
@ -34,20 +34,25 @@ public class CmdUnclaim extends FCommand {
|
||||
Board.removeAt(flocation);
|
||||
msg("<i>Safe zone was unclaimed.");
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
msg("<b>This is a safe zone. You lack permissions to unclaim.");
|
||||
}
|
||||
return;
|
||||
} else if (otherFaction.isWarZone()) {
|
||||
}
|
||||
else if (otherFaction.isWarZone()) {
|
||||
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
||||
Board.removeAt(flocation);
|
||||
msg("<i>War zone was unclaimed.");
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
msg("<b>This is a war zone. You lack permissions to unclaim.");
|
||||
}
|
||||
return;
|
||||
@ -59,8 +64,9 @@ public class CmdUnclaim extends FCommand {
|
||||
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
|
||||
msg("<i>You unclaimed this land.");
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -81,23 +87,27 @@ public class CmdUnclaim extends FCommand {
|
||||
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
if (unclaimEvent.isCancelled()) return;
|
||||
if (unclaimEvent.isCancelled()) { return; }
|
||||
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) return;
|
||||
} else {
|
||||
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) return;
|
||||
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) { return; }
|
||||
}
|
||||
}
|
||||
|
||||
Board.removeAt(flocation);
|
||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,11 +30,14 @@ public class CmdUnclaimall extends FCommand {
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||
if (!Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land"))
|
||||
if (!Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
|
||||
return;
|
||||
} else {
|
||||
if (!Econ.modifyMoney(fme, refund, "to unclaim all faction land", "for unclaiming all faction land"))
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!Econ.modifyMoney(fme, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,8 +48,9 @@ public class CmdUnclaimall extends FCommand {
|
||||
Board.unclaimAll(myFaction.getId());
|
||||
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed everything for the faction: " + myFaction.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,8 +31,7 @@ public class CmdWarunclaimall extends FCommand {
|
||||
Board.unclaimAll(Factions.i.getWarZone().getId());
|
||||
msg("<i>You unclaimed ALL war zone land.");
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
P.p.log(fme.getName() + " unclaimed all war zones.");
|
||||
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all war zones."); }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,8 @@ public abstract class FCommand extends MCommand<P> {
|
||||
if (sender instanceof Player) {
|
||||
this.fme = FPlayers.i.get((Player) sender);
|
||||
this.myFaction = this.fme.getFaction();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.fme = null;
|
||||
this.myFaction = null;
|
||||
}
|
||||
@ -72,11 +73,11 @@ public abstract class FCommand extends MCommand<P> {
|
||||
@Override
|
||||
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
||||
boolean superValid = super.validSenderType(sender, informSenderIfNot);
|
||||
if (!superValid) return false;
|
||||
if (!superValid) { return false; }
|
||||
|
||||
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) return true;
|
||||
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) { return true; }
|
||||
|
||||
if (!(sender instanceof Player)) return false;
|
||||
if (!(sender instanceof Player)) { return false; }
|
||||
|
||||
FPlayer fplayer = FPlayers.i.get((Player) sender);
|
||||
|
||||
@ -103,7 +104,7 @@ public abstract class FCommand extends MCommand<P> {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean assertHasFaction() {
|
||||
if (me == null) return true;
|
||||
if (me == null) { return true; }
|
||||
|
||||
if (!fme.hasFaction()) {
|
||||
sendMessage("You are not member of any faction.");
|
||||
@ -113,7 +114,7 @@ public abstract class FCommand extends MCommand<P> {
|
||||
}
|
||||
|
||||
public boolean assertMinRole(Role role) {
|
||||
if (me == null) return true;
|
||||
if (me == null) { return true; }
|
||||
|
||||
if (fme.getRole().value < role.value) {
|
||||
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + ".");
|
||||
@ -240,13 +241,16 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
if (you.getRole().equals(Role.ADMIN)) {
|
||||
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
|
||||
} else if (i.getRole().equals(Role.MODERATOR)) {
|
||||
}
|
||||
else if (i.getRole().equals(Role.MODERATOR)) {
|
||||
if (i == you) {
|
||||
return true; //Moderators can control themselves
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
|
||||
}
|
||||
|
||||
@ -255,21 +259,21 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
||||
public boolean payForCommand(double cost, String toDoThis, String forDoingThis) {
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { return true; }
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
||||
else
|
||||
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
|
||||
}
|
||||
else { return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); }
|
||||
}
|
||||
|
||||
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
||||
public boolean canAffordCommand(double cost, String toDoThis) {
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { return true; }
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
||||
else
|
||||
return Econ.hasAtLeast(fme, cost, toDoThis);
|
||||
}
|
||||
else { return Econ.hasAtLeast(fme, cost, toDoThis); }
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public abstract class FRelationCommand extends FCommand {
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction them = this.argAsFaction(0);
|
||||
if (them == null) return;
|
||||
if (them == null) { return; }
|
||||
|
||||
if (!them.isNormal()) {
|
||||
msg("<b>Nope! You can't.");
|
||||
@ -46,8 +46,9 @@ public abstract class FRelationCommand extends FCommand {
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish"))
|
||||
if (!payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// try to set the new relation
|
||||
Relation oldRelation = myFaction.getRelationTo(them, true);
|
||||
|
@ -19,7 +19,7 @@ public class Econ {
|
||||
private static Economy econ = null;
|
||||
|
||||
public static void setup() {
|
||||
if (isSetup()) return;
|
||||
if (isSetup()) { return; }
|
||||
|
||||
String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" ";
|
||||
|
||||
@ -37,8 +37,9 @@ public class Econ {
|
||||
|
||||
P.p.log("Economy integration through Vault plugin successful.");
|
||||
|
||||
if (!Conf.econEnabled)
|
||||
if (!Conf.econEnabled) {
|
||||
P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||
}
|
||||
|
||||
P.p.cmdBase.cmdHelp.updateHelp();
|
||||
|
||||
@ -55,11 +56,11 @@ public class Econ {
|
||||
|
||||
|
||||
public static void modifyUniverseMoney(double delta) {
|
||||
if (!shouldBeUsed()) return;
|
||||
if (!shouldBeUsed()) { return; }
|
||||
|
||||
if (Conf.econUniverseAccount == null) return;
|
||||
if (Conf.econUniverseAccount.length() == 0) return;
|
||||
if (!econ.hasAccount(Conf.econUniverseAccount)) return;
|
||||
if (Conf.econUniverseAccount == null) { return; }
|
||||
if (Conf.econUniverseAccount.length() == 0) { return; }
|
||||
if (!econ.hasAccount(Conf.econUniverseAccount)) { return; }
|
||||
|
||||
modifyBalance(Conf.econUniverseAccount, delta);
|
||||
}
|
||||
@ -77,25 +78,26 @@ public class Econ {
|
||||
Faction fYou = RelationUtil.getFaction(you);
|
||||
|
||||
// This is a system invoker. Accept it.
|
||||
if (fI == null) return true;
|
||||
if (fI == null) { return true; }
|
||||
|
||||
// Bypassing players can do any kind of transaction
|
||||
if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) return true;
|
||||
if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) { return true; }
|
||||
|
||||
// Players with the any withdraw can do.
|
||||
if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) return true;
|
||||
if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) { return true; }
|
||||
|
||||
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
|
||||
if (i == you) return true;
|
||||
if (i == you) { return true; }
|
||||
|
||||
// A faction can always transfer away the money of it's members and its own money...
|
||||
// This will however probably never happen as a faction does not have free will.
|
||||
// Ohh by the way... Yes it could. For daily rent to the faction.
|
||||
if (i == fI && fI == fYou) return true;
|
||||
if (i == fI && fI == fYou) { return true; }
|
||||
|
||||
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
|
||||
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value))
|
||||
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise you may not! ;,,;
|
||||
i.msg("<h>%s<i> lacks permission to control <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
||||
@ -107,7 +109,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) {
|
||||
if (!shouldBeUsed()) return false;
|
||||
if (!shouldBeUsed()) { return false; }
|
||||
|
||||
// The amount must be positive.
|
||||
// If the amount is negative we must flip and multiply amount with -1.
|
||||
@ -119,13 +121,14 @@ public class Econ {
|
||||
}
|
||||
|
||||
// Check the rights
|
||||
if (!canIControllYou(invoker, from)) return false;
|
||||
if (!canIControllYou(invoker, from)) { return false; }
|
||||
|
||||
// Is there enough money for the transaction to happen?
|
||||
if (!econ.has(from.getAccountId(), amount)) {
|
||||
// There was not enough money to pay
|
||||
if (invoker != null && notify)
|
||||
if (invoker != null && notify) {
|
||||
invoker.msg("<h>%s<b> can't afford to transfer <h>%s<b> to %s<b>.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -136,17 +139,19 @@ public class Econ {
|
||||
if (erw.transactionSuccess()) {
|
||||
EconomyResponse erd = econ.depositPlayer(to.getAccountId(), amount);
|
||||
if (erd.transactionSuccess()) {
|
||||
if (notify) sendTransferInfo(invoker, from, to, amount);
|
||||
if (notify) { sendTransferInfo(invoker, from, to, amount); }
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// transaction failed, refund account
|
||||
econ.depositPlayer(from.getAccountId(), amount);
|
||||
}
|
||||
}
|
||||
|
||||
// if we get here something with the transaction failed
|
||||
if (notify)
|
||||
if (notify) {
|
||||
invoker.msg("Unable to transfer %s<b> to <h>%s<b> from <h>%s<b>.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -156,9 +161,11 @@ public class Econ {
|
||||
|
||||
if (ep == null) {
|
||||
// Add nothing
|
||||
} else if (ep instanceof FPlayer) {
|
||||
}
|
||||
else if (ep instanceof FPlayer) {
|
||||
fplayers.add((FPlayer) ep);
|
||||
} else if (ep instanceof Faction) {
|
||||
}
|
||||
else if (ep instanceof Faction) {
|
||||
fplayers.addAll(((Faction) ep).getFPlayers());
|
||||
}
|
||||
|
||||
@ -175,15 +182,18 @@ public class Econ {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> was transfered from <h>%s<i> to <h>%s<i>.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||
}
|
||||
} else if (invoker == from) {
|
||||
}
|
||||
else if (invoker == from) {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> <h>gave %s<i> to <h>%s<i>.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient));
|
||||
}
|
||||
} else if (invoker == to) {
|
||||
}
|
||||
else if (invoker == to) {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> <h>took %s<i> from <h>%s<i>.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> transfered <h>%s<i> from <h>%s<i> to <h>%s<i>.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||
}
|
||||
@ -191,18 +201,19 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) {
|
||||
if (!shouldBeUsed()) return true;
|
||||
if (!shouldBeUsed()) { return true; }
|
||||
|
||||
if (!econ.has(ep.getAccountId(), delta)) {
|
||||
if (toDoThis != null && !toDoThis.isEmpty())
|
||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) {
|
||||
if (!shouldBeUsed()) return false;
|
||||
if (!shouldBeUsed()) { return false; }
|
||||
|
||||
String acc = ep.getAccountId();
|
||||
String You = ep.describeTo(ep, true);
|
||||
@ -219,29 +230,36 @@ public class Econ {
|
||||
EconomyResponse er = econ.depositPlayer(acc, delta);
|
||||
if (er.transactionSuccess()) {
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// transfer to account failed
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> would have gained <h>%s<i> %s, but the deposit failed.", You, moneyString(delta), forDoingThis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// The player should loose money
|
||||
// The player might not have enough.
|
||||
|
||||
if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) {
|
||||
// There is enough money to pay
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(-delta), forDoingThis);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// There was not enough money to pay
|
||||
if (toDoThis != null && !toDoThis.isEmpty())
|
||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -253,7 +271,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static void oldMoneyDoTransfer() {
|
||||
if (!shouldBeUsed()) return;
|
||||
if (!shouldBeUsed()) { return; }
|
||||
|
||||
for (Faction faction : Factions.i.get()) {
|
||||
if (faction.money > 0) {
|
||||
@ -271,8 +289,8 @@ public class Econ {
|
||||
|
||||
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
|
||||
return Conf.econCostClaimWilderness
|
||||
+ (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand)
|
||||
- (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0);
|
||||
+ (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand)
|
||||
- (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0);
|
||||
}
|
||||
|
||||
// calculate refund amount for unclaiming land
|
||||
@ -309,17 +327,13 @@ public class Econ {
|
||||
|
||||
public static boolean setBalance(String account, double amount) {
|
||||
double current = econ.getBalance(account);
|
||||
if (current > amount)
|
||||
return econ.withdrawPlayer(account, current - amount).transactionSuccess();
|
||||
else
|
||||
return econ.depositPlayer(account, amount - current).transactionSuccess();
|
||||
if (current > amount) { return econ.withdrawPlayer(account, current - amount).transactionSuccess(); }
|
||||
else { return econ.depositPlayer(account, amount - current).transactionSuccess(); }
|
||||
}
|
||||
|
||||
public static boolean modifyBalance(String account, double amount) {
|
||||
if (amount < 0)
|
||||
return econ.withdrawPlayer(account, -amount).transactionSuccess();
|
||||
else
|
||||
return econ.depositPlayer(account, amount).transactionSuccess();
|
||||
if (amount < 0) { return econ.withdrawPlayer(account, -amount).transactionSuccess(); }
|
||||
else { return econ.depositPlayer(account, amount).transactionSuccess(); }
|
||||
}
|
||||
|
||||
public static boolean deposit(String account, double amount) {
|
||||
|
@ -23,7 +23,7 @@ public class Essentials {
|
||||
|
||||
// return false if feature is disabled or Essentials isn't available
|
||||
public static boolean handleTeleport(Player player, Location loc) {
|
||||
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) return false;
|
||||
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) { return false; }
|
||||
|
||||
Teleport teleport = (Teleport) essentials.getUser(player).getTeleport();
|
||||
Trade trade = new Trade(Conf.econCostHome, essentials);
|
||||
|
@ -36,7 +36,8 @@ public class Worldguard {
|
||||
enabled = false;
|
||||
wg = null;
|
||||
P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
wg = (WorldGuardPlugin) wgplug;
|
||||
enabled = true;
|
||||
P.p.log("Successfully hooked to WorldGuard.");
|
||||
@ -79,8 +80,7 @@ public class Worldguard {
|
||||
World world = loc.getWorld();
|
||||
Vector pt = toVector(loc);
|
||||
|
||||
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0)
|
||||
return wg.canBuild(player, loc);
|
||||
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) { return wg.canBuild(player, loc); }
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -117,7 +117,8 @@ public class Worldguard {
|
||||
overlaps = region.getIntersectingRegions(allregionslist);
|
||||
if (overlaps == null || overlaps.isEmpty()) {
|
||||
foundregions = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
foundregions = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -23,21 +23,22 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (!event.canBuild()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
if (!event.canBuild()) { return; }
|
||||
|
||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false))
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
event.setCancelled(true);
|
||||
@ -46,7 +47,7 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
event.setCancelled(true);
|
||||
@ -55,8 +56,8 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (!Conf.pistonProtectionThroughDenyBuild) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
if (!Conf.pistonProtectionThroughDenyBuild) { return; }
|
||||
|
||||
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
||||
|
||||
@ -102,75 +103,69 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
Faction otherFaction = Board.getFactionAt(new FLocation(target));
|
||||
|
||||
if (pistonFaction == otherFaction)
|
||||
return true;
|
||||
if (pistonFaction == otherFaction) { return true; }
|
||||
|
||||
if (otherFaction.isNone()) {
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()))
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isSafeZone()) {
|
||||
if (!Conf.safeZoneDenyBuild)
|
||||
return true;
|
||||
}
|
||||
else if (otherFaction.isSafeZone()) {
|
||||
if (!Conf.safeZoneDenyBuild) { return true; }
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isWarZone()) {
|
||||
if (!Conf.warZoneDenyBuild)
|
||||
return true;
|
||||
}
|
||||
else if (otherFaction.isWarZone()) {
|
||||
if (!Conf.warZoneDenyBuild) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
||||
|
||||
if (rel.confDenyBuild(otherFaction.hasPlayersOnline()))
|
||||
return false;
|
||||
if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||
String name = player.getName();
|
||||
if (Conf.playersWhoBypassAllProtection.contains(name)) return true;
|
||||
if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; }
|
||||
|
||||
FPlayer me = FPlayers.i.get(player.getUniqueId().toString());
|
||||
if (me.isAdminBypassing()) return true;
|
||||
if (me.isAdminBypassing()) { return true; }
|
||||
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction otherFaction = Board.getFactionAt(loc);
|
||||
|
||||
if (otherFaction.isNone()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||
return true;
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
||||
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
|
||||
return true; // This is not faction territory. Use whatever you like here.
|
||||
}
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't " + action + " in the wilderness.");
|
||||
if (!justCheck) { me.msg("<b>You can't " + action + " in the wilderness."); }
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isSafeZone()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||
return true;
|
||||
}
|
||||
else if (otherFaction.isSafeZone()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
||||
|
||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
||||
return true;
|
||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; }
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't " + action + " in a safe zone.");
|
||||
if (!justCheck) { me.msg("<b>You can't " + action + " in a safe zone."); }
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isWarZone()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||
return true;
|
||||
}
|
||||
else if (otherFaction.isWarZone()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
||||
|
||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
||||
return true;
|
||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) { return true; }
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't " + action + " in a war zone.");
|
||||
if (!justCheck) { me.msg("<b>You can't " + action + " in a war zone."); }
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -185,14 +180,16 @@ public class FactionsBlockListener implements Listener {
|
||||
if (pain) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
|
||||
if (!deny)
|
||||
if (!deny) {
|
||||
me.msg("<b>It is painful to try to " + action + " in the territory of " + otherFaction.getTag(myFaction));
|
||||
}
|
||||
}
|
||||
|
||||
// cancel building/destroying in other territory?
|
||||
if (deny) {
|
||||
if (!justCheck)
|
||||
if (!justCheck) {
|
||||
me.msg("<b>You can't " + action + " in the territory of " + otherFaction.getTag(myFaction));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -202,12 +199,14 @@ public class FactionsBlockListener implements Listener {
|
||||
if (!pain && Conf.ownedAreaPainBuild && !justCheck) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
|
||||
if (!Conf.ownedAreaDenyBuild)
|
||||
if (!Conf.ownedAreaDenyBuild) {
|
||||
me.msg("<b>It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
|
||||
}
|
||||
}
|
||||
if (Conf.ownedAreaDenyBuild) {
|
||||
if (!justCheck)
|
||||
if (!justCheck) {
|
||||
me.msg("<b>You can't " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class FactionsChatListener implements Listener {
|
||||
// this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerEarlyChat(PlayerChatEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
Player talkingPlayer = event.getPlayer();
|
||||
String msg = event.getMessage();
|
||||
@ -34,8 +34,9 @@ public class FactionsChatListener implements Listener {
|
||||
|
||||
// slashless factions commands need to be handled here if the user isn't in public chat mode
|
||||
if (chat != ChatMode.PUBLIC && p.handleCommand(talkingPlayer, msg, false, true)) {
|
||||
if (Conf.logPlayerCommands)
|
||||
if (Conf.logPlayerCommands) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[PLAYER_COMMAND] " + talkingPlayer.getName() + ": " + msg);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -51,13 +52,15 @@ public class FactionsChatListener implements Listener {
|
||||
|
||||
//Send to any players who are spying chat
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
||||
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction) {
|
||||
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (chat == ChatMode.ALLIANCE) {
|
||||
}
|
||||
else if (chat == ChatMode.ALLIANCE) {
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg);
|
||||
@ -67,12 +70,10 @@ public class FactionsChatListener implements Listener {
|
||||
|
||||
//Send to all our allies
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||
if (myFaction.getRelationTo(fplayer) == Relation.ALLY)
|
||||
fplayer.sendMessage(message);
|
||||
if (myFaction.getRelationTo(fplayer) == Relation.ALLY) { fplayer.sendMessage(message); }
|
||||
|
||||
//Send to any players who are spying chat
|
||||
else if (fplayer.isSpyingChat())
|
||||
fplayer.sendMessage("[ACspy]: " + message);
|
||||
//Send to any players who are spying chat
|
||||
else if (fplayer.isSpyingChat()) { fplayer.sendMessage("[ACspy]: " + message); }
|
||||
}
|
||||
|
||||
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message));
|
||||
@ -85,11 +86,11 @@ public class FactionsChatListener implements Listener {
|
||||
// this is for handling insertion of the player's faction tag, set at highest priority to give other plugins a chance to modify chat first
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
// Are we to insert the Faction tag into the format?
|
||||
// If we are not to insert it - we are done.
|
||||
if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) return;
|
||||
if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) { return; }
|
||||
|
||||
Player talkingPlayer = event.getPlayer();
|
||||
String msg = event.getMessage();
|
||||
@ -107,17 +108,19 @@ public class FactionsChatListener implements Listener {
|
||||
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, "");
|
||||
Conf.chatTagPadAfter = false;
|
||||
Conf.chatTagPadBefore = false;
|
||||
} else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) {
|
||||
}
|
||||
else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) {
|
||||
// we're using the "insert after string" method
|
||||
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length();
|
||||
} else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) {
|
||||
}
|
||||
else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) {
|
||||
// we're using the "insert before string" method
|
||||
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// we'll fall back to using the index place method
|
||||
InsertIndex = Conf.chatTagInsertIndex;
|
||||
if (InsertIndex > eventFormat.length())
|
||||
return;
|
||||
if (InsertIndex > eventFormat.length()) { return; }
|
||||
}
|
||||
|
||||
String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : "");
|
||||
@ -148,7 +151,8 @@ public class FactionsChatListener implements Listener {
|
||||
// Write to the log... We will write the non colored message.
|
||||
String nonColoredMsg = ChatColor.stripColor(String.format(nonColoredMsgFormat, talkingPlayer.getDisplayName(), msg));
|
||||
Bukkit.getLogger().log(Level.INFO, nonColoredMsg);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// No relation color.
|
||||
event.setFormat(nonColoredMsgFormat);
|
||||
}
|
||||
|
@ -54,16 +54,20 @@ public class FactionsEntityListener implements Listener {
|
||||
if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
|
||||
powerLossEvent.setMessage("<b>The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\n<i>Your power is now <h>%d / %d");
|
||||
}
|
||||
} else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) {
|
||||
}
|
||||
else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) {
|
||||
powerLossEvent.setMessage("<i>You didn't lose any power since you were in the wilderness.");
|
||||
powerLossEvent.setCancelled(true);
|
||||
} else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
|
||||
}
|
||||
else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
|
||||
powerLossEvent.setMessage("<i>You didn't lose any power due to the world you died in.");
|
||||
powerLossEvent.setCancelled(true);
|
||||
} else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) {
|
||||
}
|
||||
else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) {
|
||||
powerLossEvent.setMessage("<i>You didn't lose any power since you are in a peaceful faction.");
|
||||
powerLossEvent.setCancelled(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
powerLossEvent.setMessage("<i>Your power is now <h>%d / %d");
|
||||
}
|
||||
|
||||
@ -87,14 +91,15 @@ public class FactionsEntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
||||
if (!this.canDamagerHurtDamagee(sub, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) {
|
||||
}
|
||||
else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) {
|
||||
// Players can not take any damage in a Safe Zone
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -102,7 +107,7 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
Location loc = event.getLocation();
|
||||
Entity boomer = event.getEntity();
|
||||
@ -133,40 +138,43 @@ public class FactionsEntityListener implements Listener {
|
||||
) {
|
||||
// creeper which needs prevention
|
||||
event.setCancelled(true);
|
||||
} else if
|
||||
(
|
||||
}
|
||||
else if
|
||||
(
|
||||
// it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
|
||||
(boomer instanceof Fireball || boomer instanceof WitherSkull || boomer instanceof Wither)
|
||||
&&
|
||||
(
|
||||
(faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
||||
||
|
||||
(faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline))
|
||||
||
|
||||
(faction.isWarZone() && Conf.warZoneBlockFireballs)
|
||||
||
|
||||
faction.isSafeZone()
|
||||
)
|
||||
) {
|
||||
(boomer instanceof Fireball || boomer instanceof WitherSkull || boomer instanceof Wither)
|
||||
&&
|
||||
(
|
||||
(faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
||||
||
|
||||
(faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline))
|
||||
||
|
||||
(faction.isWarZone() && Conf.warZoneBlockFireballs)
|
||||
||
|
||||
faction.isSafeZone()
|
||||
)
|
||||
) {
|
||||
// ghast fireball which needs prevention
|
||||
event.setCancelled(true);
|
||||
} else if
|
||||
(
|
||||
(boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart)
|
||||
&&
|
||||
(
|
||||
(faction.isNone() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
||||
||
|
||||
(faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline))
|
||||
||
|
||||
(faction.isWarZone() && Conf.warZoneBlockTNT)
|
||||
||
|
||||
(faction.isSafeZone() && Conf.safeZoneBlockTNT)
|
||||
)
|
||||
) {
|
||||
}
|
||||
else if
|
||||
(
|
||||
(boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart)
|
||||
&&
|
||||
(
|
||||
(faction.isNone() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
||||
||
|
||||
(faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline))
|
||||
||
|
||||
(faction.isWarZone() && Conf.warZoneBlockTNT)
|
||||
||
|
||||
(faction.isSafeZone() && Conf.safeZoneBlockTNT)
|
||||
)
|
||||
) {
|
||||
// TNT which needs prevention
|
||||
event.setCancelled(true);
|
||||
} else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
|
||||
}
|
||||
else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
|
||||
// TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but...
|
||||
// this change below provides workaround for waterwalling providing perfect protection,
|
||||
// and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots
|
||||
@ -183,8 +191,9 @@ public class FactionsEntityListener implements Listener {
|
||||
for (Block target : targets) {
|
||||
int id = target.getTypeId();
|
||||
// ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet
|
||||
if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130)
|
||||
if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) {
|
||||
target.breakNaturally();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -193,23 +202,22 @@ public class FactionsEntityListener implements Listener {
|
||||
// mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0);
|
||||
if (!this.canDamagerHurtDamagee(sub, false))
|
||||
event.setCancelled(true);
|
||||
if (!this.canDamagerHurtDamagee(sub, false)) { event.setCancelled(true); }
|
||||
sub = null;
|
||||
}
|
||||
|
||||
private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<PotionEffectType>(Arrays.asList(
|
||||
PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER,
|
||||
PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS,
|
||||
PotionEffectType.WITHER
|
||||
PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER,
|
||||
PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS,
|
||||
PotionEffectType.WITHER
|
||||
));
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPotionSplashEvent(PotionSplashEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
// see if the potion has a harmful effect
|
||||
boolean badjuju = false;
|
||||
@ -219,7 +227,7 @@ public class FactionsEntityListener implements Listener {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!badjuju) return;
|
||||
if (!badjuju) { return; }
|
||||
|
||||
ProjectileSource thrower = event.getPotion().getShooter();
|
||||
if (!(thrower instanceof Entity)) {
|
||||
@ -231,8 +239,9 @@ public class FactionsEntityListener implements Listener {
|
||||
while (iter.hasNext()) {
|
||||
LivingEntity target = iter.next();
|
||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
||||
if (!this.canDamagerHurtDamagee(sub, true))
|
||||
if (!this.canDamagerHurtDamagee(sub, true)) {
|
||||
event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works
|
||||
}
|
||||
sub = null;
|
||||
}
|
||||
}
|
||||
@ -256,13 +265,11 @@ public class FactionsEntityListener implements Listener {
|
||||
Entity damagee = sub.getEntity();
|
||||
double damage = sub.getDamage();
|
||||
|
||||
if (!(damagee instanceof Player))
|
||||
return true;
|
||||
if (!(damagee instanceof Player)) { return true; }
|
||||
|
||||
FPlayer defender = FPlayers.i.get((Player) damagee);
|
||||
|
||||
if (defender == null || defender.getPlayer() == null)
|
||||
return true;
|
||||
if (defender == null || defender.getPlayer() == null) { return true; }
|
||||
|
||||
Location defenderLoc = defender.getPlayer().getLocation();
|
||||
Faction defLocFaction = Board.getFactionAt(new FLocation(defenderLoc));
|
||||
@ -273,7 +280,7 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (damager == damagee) // ender pearl usage and other self-inflicted damage
|
||||
return true;
|
||||
{ return true; }
|
||||
|
||||
// Players can not take attack damage in a SafeZone, or possibly peaceful territory
|
||||
if (defLocFaction.noPvPInTerritory()) {
|
||||
@ -287,19 +294,18 @@ public class FactionsEntityListener implements Listener {
|
||||
return !defLocFaction.noMonstersInTerritory();
|
||||
}
|
||||
|
||||
if (!(damager instanceof Player))
|
||||
return true;
|
||||
if (!(damager instanceof Player)) { return true; }
|
||||
|
||||
FPlayer attacker = FPlayers.i.get((Player) damager);
|
||||
|
||||
if (attacker == null || attacker.getPlayer() == null)
|
||||
return true;
|
||||
if (attacker == null || attacker.getPlayer() == null) { return true; }
|
||||
|
||||
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
|
||||
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) { return true; }
|
||||
|
||||
if (attacker.hasLoginPvpDisabled()) {
|
||||
if (notify)
|
||||
if (notify) {
|
||||
attacker.msg("<i>You can't hurt other players for " + Conf.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -307,38 +313,40 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
|
||||
if (locFaction.noPvPInTerritory()) {
|
||||
if (notify)
|
||||
if (notify) {
|
||||
attacker.msg("<i>You can't hurt other players while you are in " + (locFaction.isSafeZone() ? "a SafeZone." : "peaceful territory."));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire)
|
||||
return true;
|
||||
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) { return true; }
|
||||
|
||||
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName()))
|
||||
return true;
|
||||
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) { return true; }
|
||||
|
||||
Faction defendFaction = defender.getFaction();
|
||||
Faction attackFaction = attacker.getFaction();
|
||||
|
||||
if (attackFaction.isNone() && Conf.disablePVPForFactionlessPlayers) {
|
||||
if (notify) attacker.msg("<i>You can't hurt other players until you join a faction.");
|
||||
if (notify) { attacker.msg("<i>You can't hurt other players until you join a faction."); }
|
||||
return false;
|
||||
} else if (defendFaction.isNone()) {
|
||||
}
|
||||
else if (defendFaction.isNone()) {
|
||||
if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) {
|
||||
// Allow PVP vs. Factionless in attacker's faction territory
|
||||
return true;
|
||||
} else if (Conf.disablePVPForFactionlessPlayers) {
|
||||
if (notify) attacker.msg("<i>You can't hurt players who are not currently in a faction.");
|
||||
}
|
||||
else if (Conf.disablePVPForFactionlessPlayers) {
|
||||
if (notify) { attacker.msg("<i>You can't hurt players who are not currently in a faction."); }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (defendFaction.isPeaceful()) {
|
||||
if (notify) attacker.msg("<i>You can't hurt players who are in a peaceful faction.");
|
||||
if (notify) { attacker.msg("<i>You can't hurt players who are in a peaceful faction."); }
|
||||
return false;
|
||||
} else if (attackFaction.isPeaceful()) {
|
||||
if (notify) attacker.msg("<i>You can't hurt players while you are in a peaceful faction.");
|
||||
}
|
||||
else if (attackFaction.isPeaceful()) {
|
||||
if (notify) { attacker.msg("<i>You can't hurt players while you are in a peaceful faction."); }
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -346,17 +354,16 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
// You can not hurt neutral factions
|
||||
if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) {
|
||||
if (notify) attacker.msg("<i>You can't hurt neutral factions. Declare them as an enemy.");
|
||||
if (notify) { attacker.msg("<i>You can't hurt neutral factions. Declare them as an enemy."); }
|
||||
return false;
|
||||
}
|
||||
|
||||
// Players without faction may be hurt anywhere
|
||||
if (!defender.hasFaction())
|
||||
return true;
|
||||
if (!defender.hasFaction()) { return true; }
|
||||
|
||||
// You can never hurt faction members or allies
|
||||
if (relation.isMember() || relation.isAlly()) {
|
||||
if (notify) attacker.msg("<i>You can't hurt %s<i>.", defender.describeTo(attacker));
|
||||
if (notify) { attacker.msg("<i>You can't hurt %s<i>.", defender.describeTo(attacker)); }
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -399,7 +406,7 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
// if there is a target
|
||||
Entity target = event.getTarget();
|
||||
@ -420,7 +427,7 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPaintingBreak(HangingBreakEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
if (event.getCause() == RemoveCause.EXPLOSION) {
|
||||
Location loc = event.getEntity().getLocation();
|
||||
Faction faction = Board.getFactionAt(new FLocation(loc));
|
||||
@ -444,8 +451,8 @@ public class FactionsEntityListener implements Listener {
|
||||
faction.isNormal()
|
||||
&&
|
||||
(online
|
||||
? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT)
|
||||
: (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline)
|
||||
? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT)
|
||||
: (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline)
|
||||
)
|
||||
)
|
||||
||
|
||||
@ -477,7 +484,7 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPaintingPlace(HangingPlaceEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) {
|
||||
event.setCancelled(true);
|
||||
@ -486,19 +493,19 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
// for now, only interested in Enderman and Wither boss tomfoolery
|
||||
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) return;
|
||||
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) { return; }
|
||||
|
||||
Location loc = event.getBlock().getLocation();
|
||||
|
||||
if (entity instanceof Enderman) {
|
||||
if (stopEndermanBlockManipulation(loc))
|
||||
event.setCancelled(true);
|
||||
} else if (entity instanceof Wither) {
|
||||
if (stopEndermanBlockManipulation(loc)) { event.setCancelled(true); }
|
||||
}
|
||||
else if (entity instanceof Wither) {
|
||||
Faction faction = Board.getFactionAt(new FLocation(loc));
|
||||
// it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
|
||||
if
|
||||
@ -510,8 +517,7 @@ public class FactionsEntityListener implements Listener {
|
||||
(faction.isWarZone() && Conf.warZoneBlockFireballs)
|
||||
||
|
||||
faction.isSafeZone()
|
||||
)
|
||||
event.setCancelled(true);
|
||||
) { event.setCancelled(true); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -540,11 +546,14 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
if (claimFaction.isNone()) {
|
||||
return Conf.wildernessDenyEndermanBlocks;
|
||||
} else if (claimFaction.isNormal()) {
|
||||
}
|
||||
else if (claimFaction.isNormal()) {
|
||||
return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline;
|
||||
} else if (claimFaction.isSafeZone()) {
|
||||
}
|
||||
else if (claimFaction.isSafeZone()) {
|
||||
return Conf.safeZoneDenyEndermanBlocks;
|
||||
} else if (claimFaction.isWarZone()) {
|
||||
}
|
||||
else if (claimFaction.isWarZone()) {
|
||||
return Conf.warZoneDenyEndermanBlocks;
|
||||
}
|
||||
|
||||
|
@ -14,21 +14,20 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
public class FactionsExploitListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void obsidianGenerator(BlockFromToEvent event) {
|
||||
if (event.isCancelled() == true || !Conf.handleExploitObsidianGenerators) return;
|
||||
if (event.isCancelled() == true || !Conf.handleExploitObsidianGenerators) { return; }
|
||||
|
||||
// thanks to ObGenBlocker and WorldGuard for this method
|
||||
Block block = event.getToBlock();
|
||||
int source = event.getBlock().getTypeId();
|
||||
int target = block.getTypeId();
|
||||
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11))
|
||||
block.setTypeId(0);
|
||||
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { block.setTypeId(0); }
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void enderPearlTeleport(PlayerTeleportEvent event) {
|
||||
if (event.isCancelled() == true || !Conf.handleExploitEnderPearlClipping) return;
|
||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) return;
|
||||
if (event.isCancelled() == true || !Conf.handleExploitEnderPearlClipping) { return; }
|
||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { return; }
|
||||
|
||||
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
||||
Location target = event.getTo();
|
||||
|
@ -57,13 +57,12 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
// quick check to make sure player is moving between chunks; good performance boost
|
||||
if(event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4
|
||||
&& event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4
|
||||
&& event.getFrom().getWorld() == event.getTo().getWorld())
|
||||
return;
|
||||
if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4
|
||||
&& event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4
|
||||
&& event.getFrom().getWorld() == event.getTo().getWorld()) { return; }
|
||||
|
||||
Player player = event.getPlayer();
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
@ -92,41 +91,45 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
if (me.isMapAutoUpdating()) {
|
||||
me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw()));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Faction myFaction = me.getFaction();
|
||||
String ownersTo = myFaction.getOwnerListString(to);
|
||||
|
||||
if (changedFaction) {
|
||||
me.sendFactionHereMessage();
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder &&myFaction == factionTo && !ownersTo.isEmpty()) {
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) {
|
||||
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
||||
}
|
||||
} else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && factionFrom == factionTo &&myFaction == factionTo) {
|
||||
}
|
||||
else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && factionFrom == factionTo && myFaction == factionTo) {
|
||||
String ownersFrom = myFaction.getOwnerListString(from);
|
||||
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) {
|
||||
if (!ownersTo.isEmpty())
|
||||
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
||||
else if (!Conf.publicLandMessage.isEmpty())
|
||||
me.sendMessage(Conf.publicLandMessage);
|
||||
if (!ownersTo.isEmpty()) { me.sendMessage(Conf.ownedLandMessage + ownersTo); }
|
||||
else if (!Conf.publicLandMessage.isEmpty()) { me.sendMessage(Conf.publicLandMessage); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (me.getAutoClaimFor() != null) {
|
||||
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
||||
} else if (me.isAutoSafeClaimEnabled()) {
|
||||
}
|
||||
else if (me.isAutoSafeClaimEnabled()) {
|
||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||
me.setIsAutoSafeClaimEnabled(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!Board.getFactionAt(to).isSafeZone()) {
|
||||
Board.setFactionAt(Factions.i.getSafeZone(), to);
|
||||
me.msg("<i>This land is now a safe zone.");
|
||||
}
|
||||
}
|
||||
} else if (me.isAutoWarClaimEnabled()) {
|
||||
}
|
||||
else if (me.isAutoWarClaimEnabled()) {
|
||||
if (!Permission.MANAGE_WAR_ZONE.has(player)) {
|
||||
me.setIsAutoWarClaimEnabled(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!Board.getFactionAt(to).isWarZone()) {
|
||||
Board.setFactionAt(Factions.i.getWarZone(), to);
|
||||
me.msg("<i>This land is now a war zone.");
|
||||
@ -137,14 +140,16 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
// only need to check right-clicks and physical as of MC 1.4+; good performance boost
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) return;
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { return; }
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (block == null) return; // clicked in air, apparently
|
||||
if (block == null) {
|
||||
return; // clicked in air, apparently
|
||||
}
|
||||
|
||||
if (!canPlayerUseBlock(player, block, false)) {
|
||||
event.setCancelled(true);
|
||||
@ -165,7 +170,9 @@ public class FactionsPlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; // only interested on right-clicks for below
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
return; // only interested on right-clicks for below
|
||||
}
|
||||
|
||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
|
||||
event.setCancelled(true);
|
||||
@ -184,10 +191,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
// returns the current attempt count
|
||||
public int increment() {
|
||||
long Now = System.currentTimeMillis();
|
||||
if (Now > lastAttempt + 2000)
|
||||
attempts = 1;
|
||||
else
|
||||
attempts++;
|
||||
if (Now > lastAttempt + 2000) { attempts = 1; }
|
||||
else { attempts++; }
|
||||
lastAttempt = Now;
|
||||
return attempts;
|
||||
}
|
||||
@ -196,44 +201,47 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) {
|
||||
String name = player.getName();
|
||||
if (Conf.playersWhoBypassAllProtection.contains(name)) return true;
|
||||
if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; }
|
||||
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
if (me.isAdminBypassing()) return true;
|
||||
if (me.isAdminBypassing()) { return true; }
|
||||
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction otherFaction = Board.getFactionAt(loc);
|
||||
|
||||
if (otherFaction.hasPlayersOnline()) {
|
||||
if (!Conf.territoryDenyUseageMaterials.contains(material))
|
||||
if (!Conf.territoryDenyUseageMaterials.contains(material)) {
|
||||
return true; // Item isn't one we're preventing for online factions.
|
||||
} else {
|
||||
if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material))
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) {
|
||||
return true; // Item isn't one we're preventing for offline factions.
|
||||
}
|
||||
}
|
||||
|
||||
if (otherFaction.isNone()) {
|
||||
if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||
if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
|
||||
return true; // This is not faction territory. Use whatever you like here.
|
||||
}
|
||||
|
||||
if (!justCheck)
|
||||
if (!justCheck) {
|
||||
me.msg("<b>You can't use <h>%s<b> in the wilderness.", TextUtil.getMaterialName(material));
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isSafeZone()) {
|
||||
if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player))
|
||||
return true;
|
||||
}
|
||||
else if (otherFaction.isSafeZone()) {
|
||||
if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; }
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't use <h>%s<b> in a safe zone.", TextUtil.getMaterialName(material));
|
||||
if (!justCheck) { me.msg("<b>You can't use <h>%s<b> in a safe zone.", TextUtil.getMaterialName(material)); }
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isWarZone()) {
|
||||
if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player))
|
||||
return true;
|
||||
}
|
||||
else if (otherFaction.isWarZone()) {
|
||||
if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) { return true; }
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't use <h>%s<b> in a war zone.", TextUtil.getMaterialName(material));
|
||||
if (!justCheck) { me.msg("<b>You can't use <h>%s<b> in a war zone.", TextUtil.getMaterialName(material)); }
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -243,16 +251,18 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
// Cancel if we are not in our own territory
|
||||
if (rel.confDenyUseage()) {
|
||||
if (!justCheck)
|
||||
if (!justCheck) {
|
||||
me.msg("<b>You can't use <h>%s<b> in the territory of <h>%s<b>.", TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Also cancel if player doesn't have ownership rights for this claim
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedAreaDenyUseage && !otherFaction.playerHasOwnershipRights(me, loc)) {
|
||||
if (!justCheck)
|
||||
if (!justCheck) {
|
||||
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -261,26 +271,24 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
|
||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true;
|
||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) { return true; }
|
||||
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
if (me.isAdminBypassing()) return true;
|
||||
if (me.isAdminBypassing()) { return true; }
|
||||
|
||||
Material material = block.getType();
|
||||
FLocation loc = new FLocation(block);
|
||||
Faction otherFaction = Board.getFactionAt(loc);
|
||||
|
||||
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
||||
if (!otherFaction.isNormal())
|
||||
return true;
|
||||
if (!otherFaction.isNormal()) { return true; }
|
||||
|
||||
// We only care about some material types.
|
||||
if (otherFaction.hasPlayersOnline()) {
|
||||
if (!Conf.territoryProtectedMaterials.contains(material))
|
||||
return true;
|
||||
} else {
|
||||
if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material))
|
||||
return true;
|
||||
if (!Conf.territoryProtectedMaterials.contains(material)) { return true; }
|
||||
}
|
||||
else {
|
||||
if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) { return true; }
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
@ -288,16 +296,18 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
// You may use any block unless it is another faction's territory...
|
||||
if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials)) {
|
||||
if (!justCheck)
|
||||
if (!justCheck) {
|
||||
me.msg("<b>You can't %s <h>%s<b> in the territory of <h>%s<b>.", (material == Material.SOIL ? "trample" : "use"), TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Also cancel if player doesn't have ownership rights for this claim
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc)) {
|
||||
if (!justCheck)
|
||||
if (!justCheck) {
|
||||
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -334,7 +344,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
// but these separate bucket events below always fire without fail
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
Block block = event.getBlockClicked();
|
||||
Player player = event.getPlayer();
|
||||
@ -347,7 +357,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
Block block = event.getBlockClicked();
|
||||
Player player = event.getPlayer();
|
||||
@ -359,16 +369,16 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
public static boolean preventCommand(String fullCmd, Player player) {
|
||||
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty()))
|
||||
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fullCmd = fullCmd.toLowerCase();
|
||||
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
|
||||
String shortCmd; // command without the slash at the beginning
|
||||
if (fullCmd.startsWith("/"))
|
||||
shortCmd = fullCmd.substring(1);
|
||||
if (fullCmd.startsWith("/")) { shortCmd = fullCmd.substring(1); }
|
||||
else {
|
||||
shortCmd = fullCmd;
|
||||
fullCmd = "/" + fullCmd;
|
||||
@ -422,15 +432,14 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
cmdCheck = cmdCheck.toLowerCase();
|
||||
if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck))
|
||||
return true;
|
||||
if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) { return; }
|
||||
|
||||
FPlayer badGuy = FPlayers.i.get(event.getPlayer());
|
||||
if (badGuy == null) {
|
||||
@ -439,8 +448,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
// if player was banned (not just kicked), get rid of their stored info
|
||||
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
|
||||
if (badGuy.getRole() == Role.ADMIN)
|
||||
badGuy.getFaction().promoteNewLeader();
|
||||
if (badGuy.getRole() == Role.ADMIN) { badGuy.getFaction().promoteNewLeader(); }
|
||||
|
||||
badGuy.leave(false);
|
||||
badGuy.detach();
|
||||
|
@ -27,8 +27,8 @@ public enum ChatMode {
|
||||
}
|
||||
|
||||
public ChatMode getNext() {
|
||||
if (this == PUBLIC) return ALLIANCE;
|
||||
if (this == ALLIANCE) return FACTION;
|
||||
if (this == PUBLIC) { return ALLIANCE; }
|
||||
if (this == ALLIANCE) { return FACTION; }
|
||||
return PUBLIC;
|
||||
}
|
||||
}
|
||||
|
@ -48,78 +48,55 @@ public enum Relation {
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
if (this == MEMBER)
|
||||
return Conf.colorMember;
|
||||
else if (this == ALLY)
|
||||
return Conf.colorAlly;
|
||||
else if (this == NEUTRAL)
|
||||
return Conf.colorNeutral;
|
||||
else
|
||||
return Conf.colorEnemy;
|
||||
if (this == MEMBER) { return Conf.colorMember; }
|
||||
else if (this == ALLY) { return Conf.colorAlly; }
|
||||
else if (this == NEUTRAL) { return Conf.colorNeutral; }
|
||||
else { return Conf.colorEnemy; }
|
||||
}
|
||||
|
||||
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
||||
public boolean confDenyBuild(boolean online) {
|
||||
if (isMember())
|
||||
return false;
|
||||
if (isMember()) { return false; }
|
||||
|
||||
if (online) {
|
||||
if (isEnemy())
|
||||
return Conf.territoryEnemyDenyBuild;
|
||||
else if (isAlly())
|
||||
return Conf.territoryAllyDenyBuild;
|
||||
else
|
||||
return Conf.territoryDenyBuild;
|
||||
} else {
|
||||
if (isEnemy())
|
||||
return Conf.territoryEnemyDenyBuildWhenOffline;
|
||||
else if (isAlly())
|
||||
return Conf.territoryAllyDenyBuildWhenOffline;
|
||||
else
|
||||
return Conf.territoryDenyBuildWhenOffline;
|
||||
if (isEnemy()) { return Conf.territoryEnemyDenyBuild; }
|
||||
else if (isAlly()) { return Conf.territoryAllyDenyBuild; }
|
||||
else { return Conf.territoryDenyBuild; }
|
||||
}
|
||||
else {
|
||||
if (isEnemy()) { return Conf.territoryEnemyDenyBuildWhenOffline; }
|
||||
else if (isAlly()) { return Conf.territoryAllyDenyBuildWhenOffline; }
|
||||
else { return Conf.territoryDenyBuildWhenOffline; }
|
||||
}
|
||||
}
|
||||
|
||||
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
||||
public boolean confPainBuild(boolean online) {
|
||||
if (isMember())
|
||||
return false;
|
||||
if (isMember()) { return false; }
|
||||
|
||||
if (online) {
|
||||
if (isEnemy())
|
||||
return Conf.territoryEnemyPainBuild;
|
||||
else if (isAlly())
|
||||
return Conf.territoryAllyPainBuild;
|
||||
else
|
||||
return Conf.territoryPainBuild;
|
||||
} else {
|
||||
if (isEnemy())
|
||||
return Conf.territoryEnemyPainBuildWhenOffline;
|
||||
else if (isAlly())
|
||||
return Conf.territoryAllyPainBuildWhenOffline;
|
||||
else
|
||||
return Conf.territoryPainBuildWhenOffline;
|
||||
if (isEnemy()) { return Conf.territoryEnemyPainBuild; }
|
||||
else if (isAlly()) { return Conf.territoryAllyPainBuild; }
|
||||
else { return Conf.territoryPainBuild; }
|
||||
}
|
||||
else {
|
||||
if (isEnemy()) { return Conf.territoryEnemyPainBuildWhenOffline; }
|
||||
else if (isAlly()) { return Conf.territoryAllyPainBuildWhenOffline; }
|
||||
else { return Conf.territoryPainBuildWhenOffline; }
|
||||
}
|
||||
}
|
||||
|
||||
// return appropriate Conf setting for DenyUseage based on this relation
|
||||
public boolean confDenyUseage() {
|
||||
if (isMember())
|
||||
return false;
|
||||
else if (isEnemy())
|
||||
return Conf.territoryEnemyDenyUseage;
|
||||
else if (isAlly())
|
||||
return Conf.territoryAllyDenyUseage;
|
||||
else
|
||||
return Conf.territoryDenyUseage;
|
||||
if (isMember()) { return false; }
|
||||
else if (isEnemy()) { return Conf.territoryEnemyDenyUseage; }
|
||||
else if (isAlly()) { return Conf.territoryAllyDenyUseage; }
|
||||
else { return Conf.territoryDenyUseage; }
|
||||
}
|
||||
|
||||
public double getRelationCost() {
|
||||
if (isEnemy())
|
||||
return Conf.econCostEnemy;
|
||||
else if (isAlly())
|
||||
return Conf.econCostAlly;
|
||||
else
|
||||
return Conf.econCostNeutral;
|
||||
if (isEnemy()) { return Conf.econCostEnemy; }
|
||||
else if (isAlly()) { return Conf.econCostAlly; }
|
||||
else { return Conf.econCostNeutral; }
|
||||
}
|
||||
}
|
||||
|
@ -33,29 +33,18 @@ public class AsciiCompass {
|
||||
|
||||
public static AsciiCompass.Point getCompassPointForDirection(double inDegrees) {
|
||||
double degrees = (inDegrees - 180) % 360;
|
||||
if (degrees < 0)
|
||||
degrees += 360;
|
||||
if (degrees < 0) { degrees += 360; }
|
||||
|
||||
if (0 <= degrees && degrees < 22.5)
|
||||
return AsciiCompass.Point.N;
|
||||
else if (22.5 <= degrees && degrees < 67.5)
|
||||
return AsciiCompass.Point.NE;
|
||||
else if (67.5 <= degrees && degrees < 112.5)
|
||||
return AsciiCompass.Point.E;
|
||||
else if (112.5 <= degrees && degrees < 157.5)
|
||||
return AsciiCompass.Point.SE;
|
||||
else if (157.5 <= degrees && degrees < 202.5)
|
||||
return AsciiCompass.Point.S;
|
||||
else if (202.5 <= degrees && degrees < 247.5)
|
||||
return AsciiCompass.Point.SW;
|
||||
else if (247.5 <= degrees && degrees < 292.5)
|
||||
return AsciiCompass.Point.W;
|
||||
else if (292.5 <= degrees && degrees < 337.5)
|
||||
return AsciiCompass.Point.NW;
|
||||
else if (337.5 <= degrees && degrees < 360.0)
|
||||
return AsciiCompass.Point.N;
|
||||
else
|
||||
return null;
|
||||
if (0 <= degrees && degrees < 22.5) { return AsciiCompass.Point.N; }
|
||||
else if (22.5 <= degrees && degrees < 67.5) { return AsciiCompass.Point.NE; }
|
||||
else if (67.5 <= degrees && degrees < 112.5) { return AsciiCompass.Point.E; }
|
||||
else if (112.5 <= degrees && degrees < 157.5) { return AsciiCompass.Point.SE; }
|
||||
else if (157.5 <= degrees && degrees < 202.5) { return AsciiCompass.Point.S; }
|
||||
else if (202.5 <= degrees && degrees < 247.5) { return AsciiCompass.Point.SW; }
|
||||
else if (247.5 <= degrees && degrees < 292.5) { return AsciiCompass.Point.W; }
|
||||
else if (292.5 <= degrees && degrees < 337.5) { return AsciiCompass.Point.NW; }
|
||||
else if (337.5 <= degrees && degrees < 360.0) { return AsciiCompass.Point.N; }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) {
|
||||
|
@ -27,7 +27,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!readyToGo) return;
|
||||
if (!readyToGo) { return; }
|
||||
// this is set so it only does one iteration at a time, no matter how frequently the timer fires
|
||||
readyToGo = false;
|
||||
// and this is tracked to keep one iteration from dragging on too long and possibly choking the system if there are a very large number of players to go through
|
||||
@ -44,14 +44,14 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
|
||||
|
||||
FPlayer fplayer = iterator.next();
|
||||
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) {
|
||||
if (Conf.logFactionLeave || Conf.logFactionKick)
|
||||
if (Conf.logFactionLeave || Conf.logFactionKick) {
|
||||
P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity.");
|
||||
}
|
||||
|
||||
// if player is faction admin, sort out the faction since he's going away
|
||||
if (fplayer.getRole() == Role.ADMIN) {
|
||||
Faction faction = fplayer.getFaction();
|
||||
if (faction != null)
|
||||
fplayer.getFaction().promoteNewLeader();
|
||||
if (faction != null) { fplayer.getFaction().promoteNewLeader(); }
|
||||
}
|
||||
|
||||
fplayer.leave(false);
|
||||
|
@ -12,14 +12,12 @@ public class AutoLeaveTask implements Runnable {
|
||||
}
|
||||
|
||||
public synchronized void run() {
|
||||
if (task != null && !task.isFinished())
|
||||
return;
|
||||
if (task != null && !task.isFinished()) { return; }
|
||||
|
||||
task = new AutoLeaveProcessTask();
|
||||
task.runTaskTimer(P.p, 1, 1);
|
||||
|
||||
// maybe setting has been changed? if so, restart this task at new rate
|
||||
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes)
|
||||
P.p.startAutoLeaveTask(true);
|
||||
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) { P.p.startAutoLeaveTask(true); }
|
||||
}
|
||||
}
|
||||
|
@ -57,11 +57,11 @@ public class LazyLocation {
|
||||
// This initializes the Location
|
||||
private void initLocation() {
|
||||
// if location is already initialized, simply return
|
||||
if (location != null) return;
|
||||
if (location != null) { return; }
|
||||
|
||||
// get World; hopefully it's initialized at this point
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) return;
|
||||
if (world == null) { return; }
|
||||
|
||||
// store the Location for future calls, and pass it on
|
||||
location = new Location(world, x, y, z, yaw, pitch);
|
||||
|
@ -301,7 +301,8 @@ public final class Metrics {
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
@ -339,7 +340,8 @@ public final class Metrics {
|
||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||
if (response == null) {
|
||||
response = "null";
|
||||
} else if (response.startsWith("7")) {
|
||||
}
|
||||
else if (response.startsWith("7")) {
|
||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||
}
|
||||
|
||||
@ -419,7 +421,8 @@ public final class Metrics {
|
||||
|
||||
if (isValueNumeric) {
|
||||
json.append(value);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
json.append(escapeJSON(value));
|
||||
}
|
||||
}
|
||||
@ -460,7 +463,8 @@ public final class Metrics {
|
||||
if (chr < ' ') {
|
||||
String t = "000" + Integer.toHexString(chr);
|
||||
builder.append("\\u").append(t.substring(t.length() - 4));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
builder.append(chr);
|
||||
}
|
||||
break;
|
||||
|
@ -39,10 +39,10 @@ public class MiscUtil {
|
||||
|
||||
/// TODO create tag whitelist!!
|
||||
public static HashSet<String> substanceChars = new HashSet<String>(Arrays.asList(new String[]{
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
||||
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
|
||||
"s", "t", "u", "v", "w", "x", "y", "z"
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
||||
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
|
||||
"s", "t", "u", "v", "w", "x", "y", "z"
|
||||
}));
|
||||
|
||||
public static String getComparisonString(String str) {
|
||||
|
@ -13,7 +13,9 @@ public class RelationUtil {
|
||||
String ret = "";
|
||||
|
||||
Faction thatFaction = getFaction(that);
|
||||
if (thatFaction == null) return "ERROR"; // ERROR
|
||||
if (thatFaction == null) {
|
||||
return "ERROR"; // ERROR
|
||||
}
|
||||
|
||||
Faction myFaction = getFaction(me);
|
||||
// if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag
|
||||
@ -21,16 +23,20 @@ public class RelationUtil {
|
||||
if (that instanceof Faction) {
|
||||
if (me instanceof FPlayer && myFaction == thatFaction) {
|
||||
ret = "your faction";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ret = thatFaction.getTag();
|
||||
}
|
||||
} else if (that instanceof FPlayer) {
|
||||
}
|
||||
else if (that instanceof FPlayer) {
|
||||
FPlayer fplayerthat = (FPlayer) that;
|
||||
if (that == me) {
|
||||
ret = "you";
|
||||
} else if (thatFaction == myFaction) {
|
||||
}
|
||||
else if (thatFaction == myFaction) {
|
||||
ret = fplayerthat.getNameAndTitle();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ret = fplayerthat.getNameAndTag();
|
||||
}
|
||||
}
|
||||
@ -52,10 +58,14 @@ public class RelationUtil {
|
||||
|
||||
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) {
|
||||
Faction fthat = getFaction(that);
|
||||
if (fthat == null) return Relation.NEUTRAL; // ERROR
|
||||
if (fthat == null) {
|
||||
return Relation.NEUTRAL; // ERROR
|
||||
}
|
||||
|
||||
Faction fme = getFaction(me);
|
||||
if (fme == null) return Relation.NEUTRAL; // ERROR
|
||||
if (fme == null) {
|
||||
return Relation.NEUTRAL; // ERROR
|
||||
}
|
||||
|
||||
if (!fthat.isNormal() || !fme.isNormal()) {
|
||||
return Relation.NEUTRAL;
|
||||
|
@ -98,19 +98,18 @@ public abstract class SpiralTask implements Runnable {
|
||||
*/
|
||||
|
||||
public final void setTaskID(int ID) {
|
||||
if (ID == -1)
|
||||
this.stop();
|
||||
if (ID == -1) { this.stop(); }
|
||||
taskID = ID;
|
||||
}
|
||||
|
||||
public final void run() {
|
||||
if (!this.valid() || !readyToGo) return;
|
||||
if (!this.valid() || !readyToGo) { return; }
|
||||
|
||||
// this is set so it only does one iteration at a time, no matter how frequently the timer fires
|
||||
readyToGo = false;
|
||||
|
||||
// make sure we're still inside the specified radius
|
||||
if (!this.insideRadius()) return;
|
||||
if (!this.insideRadius()) { return; }
|
||||
|
||||
// track this to keep one iteration from dragging on too long and possibly choking the system
|
||||
long loopStartTime = now();
|
||||
@ -124,8 +123,7 @@ public abstract class SpiralTask implements Runnable {
|
||||
}
|
||||
|
||||
// move on to next chunk in spiral
|
||||
if (!this.moveToNext())
|
||||
return;
|
||||
if (!this.moveToNext()) { return; }
|
||||
}
|
||||
|
||||
// ready for the next iteration to run
|
||||
@ -134,15 +132,16 @@ public abstract class SpiralTask implements Runnable {
|
||||
|
||||
// step through chunks in spiral pattern from center; returns false if we're done, otherwise returns true
|
||||
public final boolean moveToNext() {
|
||||
if (!this.valid()) return false;
|
||||
if (!this.valid()) { return false; }
|
||||
|
||||
// make sure we don't need to turn down the next leg of the spiral
|
||||
if (current < length) {
|
||||
current++;
|
||||
|
||||
// if we're outside the radius, we're done
|
||||
if (!this.insideRadius()) return false;
|
||||
} else { // one leg/side of the spiral down...
|
||||
if (!this.insideRadius()) { return false; }
|
||||
}
|
||||
else { // one leg/side of the spiral down...
|
||||
current = 0;
|
||||
isZLeg ^= true;
|
||||
// every second leg (between X and Z legs, negative or positive), length increases
|
||||
@ -153,18 +152,15 @@ public abstract class SpiralTask implements Runnable {
|
||||
}
|
||||
|
||||
// move one chunk further in the appropriate direction
|
||||
if (isZLeg)
|
||||
z += (isNeg) ? -1 : 1;
|
||||
else
|
||||
x += (isNeg) ? -1 : 1;
|
||||
if (isZLeg) { z += (isNeg) ? -1 : 1; }
|
||||
else { x += (isNeg) ? -1 : 1; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public final boolean insideRadius() {
|
||||
boolean inside = current < limit;
|
||||
if (!inside)
|
||||
this.finish();
|
||||
if (!inside) { this.finish(); }
|
||||
return inside;
|
||||
}
|
||||
|
||||
@ -176,7 +172,7 @@ public abstract class SpiralTask implements Runnable {
|
||||
|
||||
// we're done, whether finished or cancelled
|
||||
public final void stop() {
|
||||
if (!this.valid()) return;
|
||||
if (!this.valid()) { return; }
|
||||
|
||||
readyToGo = false;
|
||||
Bukkit.getServer().getScheduler().cancelTask(taskID);
|
||||
|
@ -11,8 +11,9 @@ public class FCommandHandler implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (P.p.handleCommand(sender, cmd.getName() + args)) {
|
||||
if (P.p.logPlayerCommands())
|
||||
if (P.p.logPlayerCommands()) {
|
||||
Bukkit.getLogger().info("[PLAYER_COMMAND] " + sender.getName() + ": " + cmd.getName() + args);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -91,7 +91,8 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
if (sender instanceof Player) {
|
||||
this.me = (Player) sender;
|
||||
this.senderIsConsole = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.me = null;
|
||||
this.senderIsConsole = true;
|
||||
}
|
||||
@ -110,9 +111,9 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
}
|
||||
}
|
||||
|
||||
if (!validCall(this.sender, this.args)) return;
|
||||
if (!validCall(this.sender, this.args)) { return; }
|
||||
|
||||
if (!this.isEnabled()) return;
|
||||
if (!this.isEnabled()) { return; }
|
||||
|
||||
perform();
|
||||
}
|
||||
@ -164,7 +165,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
}
|
||||
|
||||
public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) {
|
||||
if (this.permission == null) return true;
|
||||
if (this.permission == null) { return true; }
|
||||
return p.perm.has(sender, this.permission, informSenderIfNot);
|
||||
}
|
||||
|
||||
@ -219,7 +220,8 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
String val = optionalArg.getValue();
|
||||
if (val == null) {
|
||||
val = "";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
val = "=" + val;
|
||||
}
|
||||
args.add("[" + optionalArg.getKey() + val + "]");
|
||||
@ -290,7 +292,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
|
||||
// INT ======================
|
||||
public Integer strAsInt(String str, Integer def) {
|
||||
if (str == null) return def;
|
||||
if (str == null) { return def; }
|
||||
try {
|
||||
Integer ret = Integer.parseInt(str);
|
||||
return ret;
|
||||
@ -309,7 +311,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
|
||||
// Double ======================
|
||||
public Double strAsDouble(String str, Double def) {
|
||||
if (str == null) return def;
|
||||
if (str == null) { return def; }
|
||||
try {
|
||||
Double ret = Double.parseDouble(str);
|
||||
return ret;
|
||||
@ -338,7 +340,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
|
||||
public Boolean argAsBool(int idx, boolean def) {
|
||||
String str = this.argAsString(idx);
|
||||
if (str == null) return def;
|
||||
if (str == null) { return def; }
|
||||
|
||||
return strAsBool(str);
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
// reference command will be used to prevent "unknown command" console messages
|
||||
try {
|
||||
Map<String, Map<String, Object>> refCmd = this.getDescription().getCommands();
|
||||
if (refCmd != null && !refCmd.isEmpty())
|
||||
this.refCommand = (String) (refCmd.keySet().toArray()[0]);
|
||||
if (refCmd != null && !refCmd.isEmpty()) { this.refCommand = (String) (refCmd.keySet().toArray()[0]); }
|
||||
} catch (ClassCastException ex) {
|
||||
}
|
||||
|
||||
@ -186,8 +185,7 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
saveTask = null;
|
||||
}
|
||||
// only save data if plugin actually loaded successfully
|
||||
if (loadSuccessful)
|
||||
EM.saveAllToDisc();
|
||||
if (loadSuccessful) { EM.saveAllToDisc(); }
|
||||
log("Disabled");
|
||||
}
|
||||
|
||||
@ -204,10 +202,10 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
|
||||
public GsonBuilder getGsonBuilder() {
|
||||
return new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.serializeNulls()
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE);
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.serializeNulls()
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -237,7 +235,7 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
}.getType();
|
||||
|
||||
Map<String, String> tagsFromFile = this.persist.load(type, "tags");
|
||||
if (tagsFromFile != null) this.rawTags.putAll(tagsFromFile);
|
||||
if (tagsFromFile != null) { this.rawTags.putAll(tagsFromFile); }
|
||||
this.persist.save(this.rawTags, "tags");
|
||||
|
||||
for (Entry<String, String> rawTag : this.rawTags.entrySet()) {
|
||||
@ -266,17 +264,17 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
for (final MCommand<?> command : this.getBaseCommands()) {
|
||||
if (noSlash && !command.allowNoSlashAccess) continue;
|
||||
if (noSlash && !command.allowNoSlashAccess) { continue; }
|
||||
|
||||
for (String alias : command.aliases) {
|
||||
// disallow double-space after alias, so specific commands can be prevented (preventing "f home" won't prevent "f home")
|
||||
if (commandString.startsWith(alias + " ")) return false;
|
||||
if (commandString.startsWith(alias + " ")) { return false; }
|
||||
|
||||
if (commandString.startsWith(alias + " ") || commandString.equals(alias)) {
|
||||
final List<String> args = new ArrayList<String>(Arrays.asList(commandString.split("\\s+")));
|
||||
args.remove(0);
|
||||
|
||||
if (testOnly) return true;
|
||||
if (testOnly) { return true; }
|
||||
|
||||
if (async) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@ -285,8 +283,8 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
command.execute(sender, args);
|
||||
}
|
||||
});
|
||||
} else
|
||||
command.execute(sender, args);
|
||||
}
|
||||
else { command.execute(sender, args); }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ public class MPluginSecretPlayerListener implements Listener {
|
||||
//@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (p.handleCommand(event.getPlayer(), event.getMessage())) {
|
||||
if (p.logPlayerCommands())
|
||||
if (p.logPlayerCommands()) {
|
||||
Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -35,8 +36,9 @@ public class MPluginSecretPlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (p.handleCommand(event.getPlayer(), event.getMessage(), false, true)) {
|
||||
if (p.logPlayerCommands())
|
||||
if (p.logPlayerCommands()) {
|
||||
Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class MPluginSecretServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onServerCommand(ServerCommandEvent event) {
|
||||
if (event.getCommand().length() == 0) return;
|
||||
if (event.getCommand().length() == 0) { return; }
|
||||
|
||||
if (p.handleCommand(event.getSender(), event.getCommand())) {
|
||||
event.setCommand(p.refCommand);
|
||||
|
@ -99,24 +99,24 @@ public abstract class EntityCollection<E extends Entity> {
|
||||
}
|
||||
|
||||
public E get(String id) {
|
||||
if (this.creative) return this.getCreative(id);
|
||||
if (this.creative) { return this.getCreative(id); }
|
||||
return id2entity.get(id);
|
||||
}
|
||||
|
||||
public E getCreative(String id) {
|
||||
E e = id2entity.get(id);
|
||||
if (e != null) return e;
|
||||
if (e != null) { return e; }
|
||||
return this.create(id);
|
||||
}
|
||||
|
||||
public boolean exists(String id) {
|
||||
if (id == null) return false;
|
||||
if (id == null) { return false; }
|
||||
return id2entity.get(id) != null;
|
||||
}
|
||||
|
||||
public E getBestIdMatch(String pattern) {
|
||||
String id = TextUtil.getBestStartWithCI(this.id2entity.keySet(), pattern);
|
||||
if (id == null) return null;
|
||||
if (id == null) { return null; }
|
||||
return this.id2entity.get(id);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public abstract class EntityCollection<E extends Entity> {
|
||||
}
|
||||
|
||||
public synchronized E create(String id) {
|
||||
if (!this.isIdFree(id)) return null;
|
||||
if (!this.isIdFree(id)) { return null; }
|
||||
|
||||
E e = null;
|
||||
try {
|
||||
@ -150,7 +150,7 @@ public abstract class EntityCollection<E extends Entity> {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void attach(E entity) {
|
||||
if (entity.getId() != null) return;
|
||||
if (entity.getId() != null) { return; }
|
||||
entity.setId(this.getNextId());
|
||||
this.entities.add(entity);
|
||||
this.id2entity.put(entity.getId(), entity);
|
||||
@ -165,7 +165,7 @@ public abstract class EntityCollection<E extends Entity> {
|
||||
|
||||
public void detach(String id) {
|
||||
E entity = this.id2entity.get(id);
|
||||
if (entity == null) return;
|
||||
if (entity == null) { return; }
|
||||
this.detach(entity);
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ public abstract class EntityCollection<E extends Entity> {
|
||||
private boolean saveIsRunning = false;
|
||||
|
||||
public boolean saveToDisc() {
|
||||
if (saveIsRunning) return true;
|
||||
if (saveIsRunning) { return true; }
|
||||
saveIsRunning = true;
|
||||
|
||||
Map<String, E> entitiesThatShouldBeSaved = new HashMap<String, E>();
|
||||
@ -205,7 +205,7 @@ public abstract class EntityCollection<E extends Entity> {
|
||||
|
||||
public boolean loadFromDisc() {
|
||||
Map<String, E> id2entity = this.loadCore();
|
||||
if (id2entity == null) return false;
|
||||
if (id2entity == null) { return false; }
|
||||
this.entities.clear();
|
||||
this.entities.addAll(id2entity.values());
|
||||
this.id2entity.clear();
|
||||
@ -289,7 +289,8 @@ public abstract class EntityCollection<E extends Entity> {
|
||||
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
|
||||
}
|
||||
return (Map<String, E>) data;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Map<String, Faction> data = this.gson.fromJson(content, type);
|
||||
|
||||
// Do we have any names that need updating in claims or invites?
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||
public class PlayerEntity extends Entity {
|
||||
public Player getPlayer() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (player.getUniqueId().toString().equals(this.getId())) return player;
|
||||
if (player.getUniqueId().toString().equals(this.getId())) { return player; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -33,7 +33,7 @@ public class PlayerEntity extends Entity {
|
||||
|
||||
public void sendMessage(String msg) {
|
||||
Player player = this.getPlayer();
|
||||
if (player == null) return;
|
||||
if (player == null) { return; }
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class SaveTask implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (!p.getAutoSave() || running) return;
|
||||
if (!p.getAutoSave() || running) { return; }
|
||||
running = true;
|
||||
p.preAutoSave();
|
||||
EM.saveAllToDisc();
|
||||
|
@ -47,7 +47,7 @@ public class PermUtil {
|
||||
* This method tests if me has a certain permission and returns true if me has. Otherwise false
|
||||
*/
|
||||
public boolean has(CommandSender me, String perm) {
|
||||
if (me == null) return false;
|
||||
if (me == null) { return false; }
|
||||
|
||||
if (!(me instanceof Player)) {
|
||||
return me.hasPermission(perm);
|
||||
@ -59,19 +59,20 @@ public class PermUtil {
|
||||
public boolean has(CommandSender me, String perm, boolean informSenderIfNot) {
|
||||
if (has(me, perm)) {
|
||||
return true;
|
||||
} else if (informSenderIfNot && me != null) {
|
||||
}
|
||||
else if (informSenderIfNot && me != null) {
|
||||
me.sendMessage(this.getForbiddenMessage(perm));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public <T> T pickFirstVal(CommandSender me, Map<String, T> perm2val) {
|
||||
if (perm2val == null) return null;
|
||||
if (perm2val == null) { return null; }
|
||||
T ret = null;
|
||||
|
||||
for (Entry<String, T> entry : perm2val.entrySet()) {
|
||||
ret = entry.getValue();
|
||||
if (has(me, entry.getKey())) break;
|
||||
if (has(me, entry.getKey())) { break; }
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -77,7 +77,7 @@ public class Persist {
|
||||
|
||||
// backup bad file, so user can attempt to recover their changes from it
|
||||
File backup = new File(file.getPath() + "_bad");
|
||||
if (backup.exists()) backup.delete();
|
||||
if (backup.exists()) { backup.delete(); }
|
||||
p.log(Level.WARNING, "Backing up copy of bad file to: " + backup);
|
||||
file.renameTo(backup);
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class SmokeUtil {
|
||||
|
||||
// Single ========
|
||||
public static void spawnSingle(Location location, int direction) {
|
||||
if (location == null) return;
|
||||
if (location == null) { return; }
|
||||
location.getWorld().playEffect(location.clone(), Effect.SMOKE, direction);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public enum TL {
|
||||
/**
|
||||
* Lang enum constructor.
|
||||
*
|
||||
* @param path The string path.
|
||||
* @param path The string path.
|
||||
* @param start The default string.
|
||||
*/
|
||||
TL(String path, String start) {
|
||||
|
@ -44,7 +44,8 @@ public class TextUtil {
|
||||
String repl = tags.get(tag);
|
||||
if (repl == null) {
|
||||
matcher.appendReplacement(ret, "<" + tag + ">");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
matcher.appendReplacement(ret, repl);
|
||||
}
|
||||
}
|
||||
@ -72,34 +73,34 @@ public class TextUtil {
|
||||
|
||||
public static String parseColorAcc(String string) {
|
||||
return string.replace("`e", "")
|
||||
.replace("`r", ChatColor.RED.toString()).replace("`R", ChatColor.DARK_RED.toString())
|
||||
.replace("`y", ChatColor.YELLOW.toString()).replace("`Y", ChatColor.GOLD.toString())
|
||||
.replace("`g", ChatColor.GREEN.toString()).replace("`G", ChatColor.DARK_GREEN.toString())
|
||||
.replace("`a", ChatColor.AQUA.toString()).replace("`A", ChatColor.DARK_AQUA.toString())
|
||||
.replace("`b", ChatColor.BLUE.toString()).replace("`B", ChatColor.DARK_BLUE.toString())
|
||||
.replace("`p", ChatColor.LIGHT_PURPLE.toString()).replace("`P", ChatColor.DARK_PURPLE.toString())
|
||||
.replace("`k", ChatColor.BLACK.toString()).replace("`s", ChatColor.GRAY.toString())
|
||||
.replace("`S", ChatColor.DARK_GRAY.toString()).replace("`w", ChatColor.WHITE.toString());
|
||||
.replace("`r", ChatColor.RED.toString()).replace("`R", ChatColor.DARK_RED.toString())
|
||||
.replace("`y", ChatColor.YELLOW.toString()).replace("`Y", ChatColor.GOLD.toString())
|
||||
.replace("`g", ChatColor.GREEN.toString()).replace("`G", ChatColor.DARK_GREEN.toString())
|
||||
.replace("`a", ChatColor.AQUA.toString()).replace("`A", ChatColor.DARK_AQUA.toString())
|
||||
.replace("`b", ChatColor.BLUE.toString()).replace("`B", ChatColor.DARK_BLUE.toString())
|
||||
.replace("`p", ChatColor.LIGHT_PURPLE.toString()).replace("`P", ChatColor.DARK_PURPLE.toString())
|
||||
.replace("`k", ChatColor.BLACK.toString()).replace("`s", ChatColor.GRAY.toString())
|
||||
.replace("`S", ChatColor.DARK_GRAY.toString()).replace("`w", ChatColor.WHITE.toString());
|
||||
}
|
||||
|
||||
public static String parseColorTags(String string) {
|
||||
return string.replace("<empty>", "")
|
||||
.replace("<black>", "\u00A70")
|
||||
.replace("<navy>", "\u00A71")
|
||||
.replace("<green>", "\u00A72")
|
||||
.replace("<teal>", "\u00A73")
|
||||
.replace("<red>", "\u00A74")
|
||||
.replace("<purple>", "\u00A75")
|
||||
.replace("<gold>", "\u00A76")
|
||||
.replace("<silver>", "\u00A77")
|
||||
.replace("<gray>", "\u00A78")
|
||||
.replace("<blue>", "\u00A79")
|
||||
.replace("<lime>", "\u00A7a")
|
||||
.replace("<aqua>", "\u00A7b")
|
||||
.replace("<rose>", "\u00A7c")
|
||||
.replace("<pink>", "\u00A7d")
|
||||
.replace("<yellow>", "\u00A7e")
|
||||
.replace("<white>", "\u00A7f");
|
||||
.replace("<black>", "\u00A70")
|
||||
.replace("<navy>", "\u00A71")
|
||||
.replace("<green>", "\u00A72")
|
||||
.replace("<teal>", "\u00A73")
|
||||
.replace("<red>", "\u00A74")
|
||||
.replace("<purple>", "\u00A75")
|
||||
.replace("<gold>", "\u00A76")
|
||||
.replace("<silver>", "\u00A77")
|
||||
.replace("<gray>", "\u00A78")
|
||||
.replace("<blue>", "\u00A79")
|
||||
.replace("<lime>", "\u00A7a")
|
||||
.replace("<aqua>", "\u00A7b")
|
||||
.replace("<rose>", "\u00A7c")
|
||||
.replace("<pink>", "\u00A7d")
|
||||
.replace("<yellow>", "\u00A7e")
|
||||
.replace("<white>", "\u00A7f");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -122,8 +123,8 @@ public class TextUtil {
|
||||
}
|
||||
|
||||
public static String repeat(String s, int times) {
|
||||
if (times <= 0) return "";
|
||||
else return s + repeat(s, times - 1);
|
||||
if (times <= 0) { return ""; }
|
||||
else { return s + repeat(s, times - 1); }
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -152,10 +153,10 @@ public class TextUtil {
|
||||
int eatLeft = (centerlen / 2) - titleizeBalance;
|
||||
int eatRight = (centerlen - eatLeft) + titleizeBalance;
|
||||
|
||||
if (eatLeft < pivot)
|
||||
if (eatLeft < pivot) {
|
||||
return parseTags("<a>") + titleizeLine.substring(0, pivot - eatLeft) + center + titleizeLine.substring(pivot + eatRight);
|
||||
else
|
||||
return parseTags("<a>") + center;
|
||||
}
|
||||
else { return parseTags("<a>") + center; }
|
||||
}
|
||||
|
||||
public ArrayList<String> getPage(List<String> lines, int pageHumanBased, String title) {
|
||||
@ -169,7 +170,8 @@ public class TextUtil {
|
||||
if (pagecount == 0) {
|
||||
ret.add(this.parseTags("<i>Sorry. No Pages available."));
|
||||
return ret;
|
||||
} else if (pageZeroBased < 0 || pageHumanBased > pagecount) {
|
||||
}
|
||||
else if (pageZeroBased < 0 || pageHumanBased > pagecount) {
|
||||
ret.add(this.parseTags("<i>Invalid page. Must be between 1 and " + pagecount));
|
||||
return ret;
|
||||
}
|
||||
@ -192,8 +194,8 @@ public class TextUtil {
|
||||
start = start.toLowerCase();
|
||||
int minlength = start.length();
|
||||
for (String candidate : candidates) {
|
||||
if (candidate.length() < minlength) continue;
|
||||
if (!candidate.toLowerCase().startsWith(start)) continue;
|
||||
if (candidate.length() < minlength) { continue; }
|
||||
if (!candidate.toLowerCase().startsWith(start)) { continue; }
|
||||
|
||||
// The closer to zero the better
|
||||
int lendiff = candidate.length() - minlength;
|
||||
|
Loading…
Reference in New Issue
Block a user