Reformatted Code
This commit is contained in:
@@ -34,24 +34,24 @@ public class Econ {
|
||||
String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" ";
|
||||
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
SavageFactions.plugin.log(integrationFail + "is not installed.");
|
||||
SavageFactions.plugin.log(integrationFail + "is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
SavageFactions.plugin.log(integrationFail + "is not hooked into an economy plugin.");
|
||||
SavageFactions.plugin.log(integrationFail + "is not hooked into an economy plugin.");
|
||||
return;
|
||||
}
|
||||
econ = rsp.getProvider();
|
||||
|
||||
SavageFactions.plugin.log("Economy integration through Vault plugin successful.");
|
||||
SavageFactions.plugin.log("Economy integration through Vault plugin successful.");
|
||||
|
||||
if (!Conf.econEnabled) {
|
||||
SavageFactions.plugin.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||
if (! Conf.econEnabled) {
|
||||
SavageFactions.plugin.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||
}
|
||||
|
||||
SavageFactions.plugin.cmdBase.cmdHelp.updateHelp();
|
||||
SavageFactions.plugin.cmdBase.cmdHelp.updateHelp();
|
||||
}
|
||||
|
||||
public static boolean shouldBeUsed() {
|
||||
@@ -63,7 +63,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static void modifyUniverseMoney(double delta) {
|
||||
if (!shouldBeUsed()) {
|
||||
if (! shouldBeUsed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Econ {
|
||||
if (Conf.econUniverseAccount.length() == 0) {
|
||||
return;
|
||||
}
|
||||
if (!econ.hasAccount(Conf.econUniverseAccount)) {
|
||||
if (! econ.hasAccount(Conf.econUniverseAccount)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about) {
|
||||
if (!shouldBeUsed()) {
|
||||
SavageFactions.plugin.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
|
||||
if (! shouldBeUsed()) {
|
||||
SavageFactions.plugin.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
|
||||
return;
|
||||
}
|
||||
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Econ.moneyString(econ.getBalance(about.getAccountId())));
|
||||
@@ -134,21 +134,21 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) {
|
||||
if (!shouldBeUsed()) {
|
||||
if (! shouldBeUsed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The amount must be positive.
|
||||
// If the amount is negative we must flip and multiply amount with -1.
|
||||
if (amount < 0) {
|
||||
amount *= -1;
|
||||
amount *= - 1;
|
||||
EconomyParticipator temp = from;
|
||||
from = to;
|
||||
to = temp;
|
||||
}
|
||||
|
||||
// Check the rights
|
||||
if (!canIControllYou(invoker, from)) {
|
||||
if (! canIControllYou(invoker, from)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
// Is there enough money for the transaction to happen?
|
||||
if (!econ.has(fromAcc, amount)) {
|
||||
if (! econ.has(fromAcc, amount)) {
|
||||
// There was not enough money to pay
|
||||
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));
|
||||
@@ -247,7 +247,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) {
|
||||
if (!shouldBeUsed()) {
|
||||
if (! shouldBeUsed()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -270,8 +270,8 @@ public class Econ {
|
||||
affordable = true;
|
||||
}
|
||||
|
||||
if (!affordable) {
|
||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||
if (! affordable) {
|
||||
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;
|
||||
@@ -280,7 +280,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) {
|
||||
if (!shouldBeUsed()) {
|
||||
if (! shouldBeUsed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -308,14 +308,14 @@ public class Econ {
|
||||
// The account might not have enough space
|
||||
EconomyResponse er = econ.depositPlayer(acc, delta);
|
||||
if (er.transactionSuccess()) {
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
modifyUniverseMoney(- delta);
|
||||
if (forDoingThis != null && ! forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
||||
}
|
||||
return true;
|
||||
} 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;
|
||||
@@ -324,17 +324,17 @@ public class Econ {
|
||||
// The player should loose money
|
||||
// The player might not have enough.
|
||||
|
||||
if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) {
|
||||
if (econ.has(acc, - delta) && econ.withdrawPlayer(acc, - delta).transactionSuccess()) {
|
||||
// There is enough money to pay
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(-delta), forDoingThis);
|
||||
modifyUniverseMoney(- delta);
|
||||
if (forDoingThis != null && ! forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(- delta), forDoingThis);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// There was not enough money to pay
|
||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
||||
if (toDoThis != null && ! toDoThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(- delta), toDoThis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ public class Econ {
|
||||
|
||||
// calculate the cost for claiming land
|
||||
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) {
|
||||
if (!shouldBeUsed()) {
|
||||
if (! shouldBeUsed()) {
|
||||
return 0d;
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ public class Econ {
|
||||
|
||||
public static boolean modifyBalance(String account, double amount) {
|
||||
if (amount < 0) {
|
||||
return econ.withdrawPlayer(account, -amount).transactionSuccess();
|
||||
return econ.withdrawPlayer(account, - amount).transactionSuccess();
|
||||
} else {
|
||||
return econ.depositPlayer(account, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
if (! Conf.homesTeleportCommandEssentialsIntegration || essentials == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@ public class Worldguard {
|
||||
|
||||
public static void init(Plugin plugin) {
|
||||
Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
|
||||
if (wgplug == null || ! (wgplug instanceof WorldGuardPlugin)) {
|
||||
enabled = false;
|
||||
wg = null;
|
||||
SavageFactions.plugin.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
||||
SavageFactions.plugin.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
||||
} else {
|
||||
wg = (WorldGuardPlugin) wgplug;
|
||||
enabled = true;
|
||||
SavageFactions.plugin.log("Successfully hooked to WorldGuard.");
|
||||
SavageFactions.plugin.log("Successfully hooked to WorldGuard.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Worldguard {
|
||||
// True: PVP is allowed
|
||||
// False: PVP is disallowed
|
||||
public static boolean isPVP(Player player) {
|
||||
if (!enabled) {
|
||||
if (! enabled) {
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return true;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class Worldguard {
|
||||
// True: Player can build in the region.
|
||||
// False: Player can not build in the region.
|
||||
public static boolean playerCanBuild(Player player, Location loc) {
|
||||
if (!enabled) {
|
||||
if (! enabled) {
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return false;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class Worldguard {
|
||||
}
|
||||
|
||||
public static boolean checkForRegionsInChunk(Chunk chunk) {
|
||||
if (!enabled) {
|
||||
if (! enabled) {
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return false;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class Worldguard {
|
||||
|
||||
try {
|
||||
overlaps = region.getIntersectingRegions(allregionslist);
|
||||
foundregions = overlaps != null && !overlaps.isEmpty();
|
||||
foundregions = overlaps != null && ! overlaps.isEmpty();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class EngineDynmap {
|
||||
public DynmapAPI dynmapApi;
|
||||
public MarkerAPI markerApi;
|
||||
public MarkerSet markerset;
|
||||
|
||||
private EngineDynmap() {
|
||||
}
|
||||
|
||||
@@ -103,12 +104,12 @@ public class EngineDynmap {
|
||||
public void init() {
|
||||
Plugin dynmap = Bukkit.getServer().getPluginManager().getPlugin("dynmap");
|
||||
|
||||
if (dynmap == null || !dynmap.isEnabled()) {
|
||||
if (dynmap == null || ! dynmap.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Should we even use dynmap?
|
||||
if (!Conf.dynmapUse) {
|
||||
if (! Conf.dynmapUse) {
|
||||
if (this.markerset != null) {
|
||||
this.markerset.deleteMarkerSet();
|
||||
this.markerset = null;
|
||||
@@ -117,7 +118,7 @@ public class EngineDynmap {
|
||||
}
|
||||
|
||||
// Shedule non thread safe sync at the end!
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -125,12 +126,12 @@ public class EngineDynmap {
|
||||
final Map<String, TempAreaMarker> areas = createAreas();
|
||||
final Map<String, Set<String>> playerSets = createPlayersets();
|
||||
|
||||
if (!updateCore()) {
|
||||
if (! updateCore()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// createLayer() is thread safe but it makes use of fields set in updateCore() so we must have it after.
|
||||
if (!updateLayer(createLayer())) {
|
||||
if (! updateLayer(createLayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -170,7 +171,7 @@ public class EngineDynmap {
|
||||
ret.label = Conf.dynmapLayerName;
|
||||
ret.minimumZoom = Conf.dynmapLayerMinimumZoom;
|
||||
ret.priority = Conf.dynmapLayerPriority;
|
||||
ret.hideByDefault = !Conf.dynmapLayerVisible;
|
||||
ret.hideByDefault = ! Conf.dynmapLayerVisible;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -322,7 +323,7 @@ public class EngineDynmap {
|
||||
Map<String, TempAreaMarker> ret = new HashMap<>();
|
||||
|
||||
// If the faction is visible ...
|
||||
if (!isVisible(faction, world)) {
|
||||
if (! isVisible(faction, world)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -406,10 +407,10 @@ public class EngineDynmap {
|
||||
while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) {
|
||||
switch (direction) {
|
||||
case XPLUS: // Segment in X+ direction
|
||||
if (!ourChunkFlags.getFlag(currentX + 1, currentZ)) { // Right turn?
|
||||
if (! ourChunkFlags.getFlag(currentX + 1, currentZ)) { // Right turn?
|
||||
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line
|
||||
direction = Direction.ZPLUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ - 1)) { // Straight?
|
||||
} else if (! ourChunkFlags.getFlag(currentX + 1, currentZ - 1)) { // Straight?
|
||||
currentX++;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line
|
||||
@@ -419,10 +420,10 @@ public class EngineDynmap {
|
||||
}
|
||||
break;
|
||||
case ZPLUS: // Segment in Z+ direction
|
||||
if (!ourChunkFlags.getFlag(currentX, currentZ + 1)) { // Right turn?
|
||||
if (! ourChunkFlags.getFlag(currentX, currentZ + 1)) { // Right turn?
|
||||
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line
|
||||
direction = Direction.XMINUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ + 1)) { // Straight?
|
||||
} else if (! ourChunkFlags.getFlag(currentX + 1, currentZ + 1)) { // Straight?
|
||||
currentZ++;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line
|
||||
@@ -432,10 +433,10 @@ public class EngineDynmap {
|
||||
}
|
||||
break;
|
||||
case XMINUS: // Segment in X- direction
|
||||
if (!ourChunkFlags.getFlag(currentX - 1, currentZ)) { // Right turn?
|
||||
if (! ourChunkFlags.getFlag(currentX - 1, currentZ)) { // Right turn?
|
||||
linelist.add(new int[]{currentX, currentZ + 1}); // Finish line
|
||||
direction = Direction.ZMINUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX - 1, currentZ + 1)) { // Straight?
|
||||
} else if (! ourChunkFlags.getFlag(currentX - 1, currentZ + 1)) { // Straight?
|
||||
currentX--;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX, currentZ + 1}); // Finish line
|
||||
@@ -445,10 +446,10 @@ public class EngineDynmap {
|
||||
}
|
||||
break;
|
||||
case ZMINUS: // Segment in Z- direction
|
||||
if (!ourChunkFlags.getFlag(currentX, currentZ - 1)) { // Right turn?
|
||||
if (! ourChunkFlags.getFlag(currentX, currentZ - 1)) { // Right turn?
|
||||
linelist.add(new int[]{currentX, currentZ}); // Finish line
|
||||
direction = Direction.XPLUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX - 1, currentZ - 1)) { // Straight?
|
||||
} else if (! ourChunkFlags.getFlag(currentX - 1, currentZ - 1)) { // Straight?
|
||||
currentZ--;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX, currentZ}); // Finish line
|
||||
@@ -570,7 +571,7 @@ public class EngineDynmap {
|
||||
|
||||
// Thread Safe / Asynchronous: Yes
|
||||
public Map<String, Set<String>> createPlayersets() {
|
||||
if (!Conf.dynmapVisibilityByFaction) {
|
||||
if (! Conf.dynmapVisibilityByFaction) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -599,7 +600,7 @@ public class EngineDynmap {
|
||||
|
||||
// Remove
|
||||
for (PlayerSet set : this.markerApi.getPlayerSets()) {
|
||||
if (!set.getSetID().startsWith(FACTIONS_PLAYERSET_)) {
|
||||
if (! set.getSetID().startsWith(FACTIONS_PLAYERSET_)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -669,7 +670,7 @@ public class EngineDynmap {
|
||||
FPlayer playersLeaderObject = faction.getFPlayerAdmin();
|
||||
String playersLeader = getHtmlPlayerName(playersLeaderObject);
|
||||
|
||||
ArrayList<FPlayer> playersAdminsList = faction.getFPlayersWhereRole(Role.LEADER);
|
||||
ArrayList<FPlayer> playersAdminsList = faction.getFPlayersWhereRole(Role.LEADER);
|
||||
String playersAdminsCount = String.valueOf(playersAdminsList.size());
|
||||
String playersAdmins = getHtmlPlayerString(playersAdminsList);
|
||||
|
||||
@@ -713,11 +714,11 @@ public class EngineDynmap {
|
||||
Set<String> visible = Conf.dynmapVisibleFactions;
|
||||
Set<String> hidden = Conf.dynmapHiddenFactions;
|
||||
|
||||
if (!visible.isEmpty() && !visible.contains(factionId) && !visible.contains(factionName) && !visible.contains("world:" + world)) {
|
||||
if (! visible.isEmpty() && ! visible.contains(factionId) && ! visible.contains(factionName) && ! visible.contains("world:" + world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !hidden.contains(factionId) && !hidden.contains(factionName) && !hidden.contains("world:" + world);
|
||||
return ! hidden.contains(factionId) && ! hidden.contains(factionName) && ! hidden.contains("world:" + world);
|
||||
}
|
||||
|
||||
// Thread Safe / Asynchronous: Yes
|
||||
@@ -743,7 +744,7 @@ public class EngineDynmap {
|
||||
ArrayDeque<int[]> stack = new ArrayDeque<>();
|
||||
stack.push(new int[]{x, y});
|
||||
|
||||
while (!stack.isEmpty()) {
|
||||
while (! stack.isEmpty()) {
|
||||
int[] nxt = stack.pop();
|
||||
x = nxt[0];
|
||||
y = nxt[1];
|
||||
|
||||
@@ -82,17 +82,17 @@ public class TempAreaMarker {
|
||||
|
||||
public void update(AreaMarker marker) {
|
||||
// Corner Locations
|
||||
if (!equals(marker, this.x, this.z)) {
|
||||
if (! equals(marker, this.x, this.z)) {
|
||||
marker.setCornerLocations(this.x, this.z);
|
||||
}
|
||||
|
||||
// Label
|
||||
if (!marker.getLabel().equals(this.label)) {
|
||||
if (! marker.getLabel().equals(this.label)) {
|
||||
marker.setLabel(this.label);
|
||||
}
|
||||
|
||||
// Description
|
||||
if (!marker.getDescription().equals(this.description)) {
|
||||
if (! marker.getDescription().equals(this.description)) {
|
||||
marker.setDescription(this.description);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ public class TempMarker {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void update(MarkerAPI markerApi, Marker marker) {
|
||||
if (!this.world.equals(marker.getWorld()) || this.x != marker.getX() || this.y != marker.getY() || this.z != marker.getZ()) {
|
||||
if (! this.world.equals(marker.getWorld()) || this.x != marker.getX() || this.y != marker.getY() || this.z != marker.getZ()) {
|
||||
marker.setLocation(this.world, this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
if (!marker.getLabel().equals(this.label)) {
|
||||
if (! marker.getLabel().equals(this.label)) {
|
||||
marker.setLabel(this.label);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TempMarker {
|
||||
marker.setMarkerIcon(icon);
|
||||
}
|
||||
|
||||
if (!marker.getDescription().equals(this.description)) {
|
||||
if (! marker.getDescription().equals(this.description)) {
|
||||
marker.setDescription(this.description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TempMarkerSet {
|
||||
|
||||
public void update(MarkerSet markerset) {
|
||||
// Name
|
||||
if (!markerset.getMarkerSetLabel().equals(this.label)) {
|
||||
if (! markerset.getMarkerSetLabel().equals(this.label)) {
|
||||
markerset.setMarkerSetLabel(this.label);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user