Some reformat
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user