Reformat.

This commit is contained in:
drtshock 2015-05-12 23:17:22 -05:00
parent 5f6e83872d
commit f37e38b011
19 changed files with 58 additions and 48 deletions

View File

@ -84,7 +84,7 @@ public class CmdAdmin extends FCommand {
} }
} }
public TL getUsageTranslation(){ public TL getUsageTranslation() {
return TL.COMMAND_ADMIN_DESCRIPTION; return TL.COMMAND_ADMIN_DESCRIPTION;
} }

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -42,7 +42,7 @@ public class CmdPeaceful extends FCommand {
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String blame=(fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change); fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change);
} else { } else {

View File

@ -46,7 +46,7 @@ public class CmdPermanent extends FCommand {
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String blame=(fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change); fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change);
} else { } else {

View File

@ -43,7 +43,7 @@ public class CmdPermanentPower extends FCommand {
// Inform all other players // Inform all other players
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) { for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) {
if(fplayer == fme) { if (fplayer == fme) {
continue; continue;
} }
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));

View File

@ -61,7 +61,7 @@ public class CmdPowerBoost extends FCommand {
target = TL.COMMAND_POWERBOOST_FACTION.format(targetFaction.getTag()); target = TL.COMMAND_POWERBOOST_FACTION.format(targetFaction.getTag());
} }
int roundedPower = (int)Math.round(targetPower); int roundedPower = (int) Math.round(targetPower);
msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower); msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower);
if (!senderIsConsole) { if (!senderIsConsole) {
P.p.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower); P.p.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower);

View File

@ -39,7 +39,7 @@ public class CmdSB extends FCommand {
public void perform() { public void perform() {
boolean toggle = toggle(me.getPlayer().getUniqueId()); boolean toggle = toggle(me.getPlayer().getUniqueId());
FScoreboard board = FScoreboard.get(fme); FScoreboard board = FScoreboard.get(fme);
if(board == null) { if (board == null) {
me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString()); me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString());
} else { } else {
me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggle))); me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggle)));

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;

View File

@ -119,7 +119,9 @@ public class FactionsEntityListener implements Listener {
} }
public void cancelFStuckTeleport(Player player) { public void cancelFStuckTeleport(Player player) {
if (player == null) return; if (player == null) {
return;
}
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (P.p.getStuckMap().containsKey(uuid)) { if (P.p.getStuckMap().containsKey(uuid)) {
FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_STUCK_CANCELLED); FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_STUCK_CANCELLED);

View File

@ -1,8 +1,7 @@
package com.massivecraft.factions.util; package com.massivecraft.factions.util;
import org.bukkit.ChatColor;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,11 +29,19 @@ public class AsciiCompass {
return String.valueOf(this.asciiChar); return String.valueOf(this.asciiChar);
} }
public String getTranslation(){ public String getTranslation() {
if(this==N) return TL.COMPASS_SHORT_NORTH.toString(); if (this == N) {
if(this==E) return TL.COMPASS_SHORT_EAST.toString(); return TL.COMPASS_SHORT_NORTH.toString();
if(this==S) return TL.COMPASS_SHORT_SOUTH.toString(); }
if(this==W) return TL.COMPASS_SHORT_WEST.toString(); if (this == E) {
return TL.COMPASS_SHORT_EAST.toString();
}
if (this == S) {
return TL.COMPASS_SHORT_SOUTH.toString();
}
if (this == W) {
return TL.COMPASS_SHORT_WEST.toString();
}
return toString(); return toString();
} }

View File

@ -61,7 +61,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
fplayer.leave(false); fplayer.leave(false);
iterator.remove(); // go ahead and remove this list's link to the FPlayer object iterator.remove(); // go ahead and remove this list's link to the FPlayer object
if(Conf.autoLeaveDeleteFPlayerData) { if (Conf.autoLeaveDeleteFPlayerData) {
fplayer.remove(); fplayer.remove();
} }
} }

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;

View File

@ -7,7 +7,6 @@ import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
public class RelationUtil { public class RelationUtil {

View File

@ -7,14 +7,13 @@ import com.massivecraft.factions.zcore.util.TL;
public class WarmUpUtil { public class WarmUpUtil {
/** /**
* * @param player The player to notify.
* @param player The player to notify.
* @param translationKey The translation key used for notifying. * @param translationKey The translation key used for notifying.
* @param action The action, inserted into the notification message. * @param action The action, inserted into the notification message.
* @param runnable The task to run after the delay. If the delay is 0, the task is instantly ran. * @param runnable The task to run after the delay. If the delay is 0, the task is instantly ran.
* @param delay The time used, in seconds, for the delay. * @param delay The time used, in seconds, for the delay.
* * <p/>
* note: for translations: %s = action, %d = delay * note: for translations: %s = action, %d = delay
*/ */
public static void process(FPlayer player, TL translationKey, String action, Runnable runnable, long delay) { public static void process(FPlayer player, TL translationKey, String action, Runnable runnable, long delay) {
if (delay > 0) { if (delay > 0) {

View File

@ -708,10 +708,10 @@ public abstract class MemoryFPlayer implements FPlayer {
} else if (factionBuffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, factionBuffer)) { } else if (factionBuffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, factionBuffer)) {
error = P.p.txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(factionBuffer)); error = P.p.txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(factionBuffer));
} else if (flocation.isOutsideWorldBorder(worldBuffer)) { } else if (flocation.isOutsideWorldBorder(worldBuffer)) {
if(worldBuffer > 0) { if (worldBuffer > 0) {
error = P.p.txt.parse(TL.CLAIM_OUTSIDEBORDERBUFFER.format(worldBuffer)); error = P.p.txt.parse(TL.CLAIM_OUTSIDEBORDERBUFFER.format(worldBuffer));
} else { } else {
error = P.p.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString()); error = P.p.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
} }
} else if (currentFaction.isNormal()) { } else if (currentFaction.isNormal()) {
if (myFaction.isPeaceful()) { if (myFaction.isPeaceful()) {

View File

@ -210,7 +210,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
public long getFoundedDate() { public long getFoundedDate() {
if(this.foundedDate == 0) { if (this.foundedDate == 0) {
setFoundedDate(System.currentTimeMillis()); setFoundedDate(System.currentTimeMillis());
} }
return this.foundedDate; return this.foundedDate;

View File

@ -12,9 +12,8 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
* Link between config and in-game messages<br> * Link between config and in-game messages<br> Changes based on faction / player<br> Interfaces the config lists with
* Changes based on faction / player<br> * {} variables to plugin
* Interfaces the config lists with {} variables to plugin
*/ */
public enum TagReplacer { public enum TagReplacer {
@ -123,6 +122,7 @@ public enum TagReplacer {
* *
* @param fac Target faction * @param fac Target faction
* @param fp Target player (can be null) * @param fp Target player (can be null)
*
* @return the value for this enum! * @return the value for this enum!
*/ */
protected String getValue(Faction fac, FPlayer fp) { protected String getValue(Faction fac, FPlayer fp) {
@ -211,6 +211,7 @@ public enum TagReplacer {
* Returns a list of all the variables we can use for this type<br> * Returns a list of all the variables we can use for this type<br>
* *
* @param type the type we want * @param type the type we want
*
* @return a list of all the variables with this type * @return a list of all the variables with this type
*/ */
protected static List<TagReplacer> getByType(TagType type) { protected static List<TagReplacer> getByType(TagType type) {
@ -230,6 +231,7 @@ public enum TagReplacer {
/** /**
* @param original raw line with variables * @param original raw line with variables
* @param value what to replace var in raw line with * @param value what to replace var in raw line with
*
* @return the string with the new value * @return the string with the new value
*/ */
public String replace(String original, String value) { public String replace(String original, String value) {
@ -238,6 +240,7 @@ public enum TagReplacer {
/** /**
* @param toSearch raw line with variables * @param toSearch raw line with variables
*
* @return if the raw line contains this enums variable * @return if the raw line contains this enums variable
*/ */
public boolean contains(String toSearch) { public boolean contains(String toSearch) {

View File

@ -5,7 +5,6 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import mkremins.fanciful.FancyMessage; import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -24,6 +23,7 @@ public class TagUtil {
* *
* @param faction for faction * @param faction for faction
* @param line raw line from config with variables to replace for * @param line raw line from config with variables to replace for
*
* @return clean line * @return clean line
*/ */
public static String parsePlain(Faction faction, String line) { public static String parsePlain(Faction faction, String line) {
@ -40,13 +40,14 @@ public class TagUtil {
* *
* @param fplayer for player * @param fplayer for player
* @param line raw line from config with variables to replace for * @param line raw line from config with variables to replace for
*
* @return clean line * @return clean line
*/ */
public static String parsePlain(FPlayer fplayer, String line) { public static String parsePlain(FPlayer fplayer, String line) {
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.PLAYER)) { for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.PLAYER)) {
if (tagReplacer.contains(line)) { if (tagReplacer.contains(line)) {
String rep = tagReplacer.getValue(fplayer.getFaction(), fplayer); String rep = tagReplacer.getValue(fplayer.getFaction(), fplayer);
if(rep == null) { if (rep == null) {
rep = ""; // this should work, but it's not a good way to handle whatever is going wrong rep = ""; // this should work, but it's not a good way to handle whatever is going wrong
} }
line = tagReplacer.replace(line, rep); line = tagReplacer.replace(line, rep);
@ -60,7 +61,8 @@ public class TagUtil {
* *
* @param faction for faction * @param faction for faction
* @param fplayer from player * @param fplayer from player
* @param line raw line from config with variables to replace for * @param line raw line from config with variables to replace for
*
* @return clean line * @return clean line
*/ */
public static String parsePlain(Faction faction, FPlayer fplayer, String line) { public static String parsePlain(Faction faction, FPlayer fplayer, String line) {
@ -78,6 +80,7 @@ public class TagUtil {
* @param faction for faction (viewers faction) * @param faction for faction (viewers faction)
* @param fme for player (viewer) * @param fme for player (viewer)
* @param line fancy message prefix * @param line fancy message prefix
*
* @return * @return
*/ */
public static List<FancyMessage> parseFancy(Faction faction, FPlayer fme, String line) { public static List<FancyMessage> parseFancy(Faction faction, FPlayer fme, String line) {
@ -94,6 +97,7 @@ public class TagUtil {
* Checks if a line has fancy variables * Checks if a line has fancy variables
* *
* @param line raw line from config with variables * @param line raw line from config with variables
*
* @return if the line has fancy variables * @return if the line has fancy variables
*/ */
public static boolean hasFancy(String line) { public static boolean hasFancy(String line) {
@ -111,6 +115,7 @@ public class TagUtil {
* @param target Faction to get relate from * @param target Faction to get relate from
* @param fme Player to relate to * @param fme Player to relate to
* @param prefix First part of the fancy message * @param prefix First part of the fancy message
*
* @return list of fancy messages to send * @return list of fancy messages to send
*/ */
protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) { protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) {
@ -193,11 +198,10 @@ public class TagUtil {
} }
/** /**
* Parses tooltip variables from config * Parses tooltip variables from config <br> Supports variables for factions only (type 2)
* <br>
* Supports variables for factions only (type 2)
* *
* @param faction faction to tooltip for * @param faction faction to tooltip for
*
* @return list of tooltips for a fancy message * @return list of tooltips for a fancy message
*/ */
private static List<String> tipFaction(Faction faction) { private static List<String> tipFaction(Faction faction) {
@ -209,11 +213,10 @@ public class TagUtil {
} }
/** /**
* Parses tooltip variables from config * Parses tooltip variables from config <br> Supports variables for players and factions (types 1 and 2)
* <br>
* Supports variables for players and factions (types 1 and 2)
* *
* @param fplayer player to tooltip for * @param fplayer player to tooltip for
*
* @return list of tooltips for a fancy message * @return list of tooltips for a fancy message
*/ */
private static List<String> tipPlayer(FPlayer fplayer) { private static List<String> tipPlayer(FPlayer fplayer) {

View File

@ -68,22 +68,22 @@ public class TextUtil {
ChatColor color = null; ChatColor color = null;
char[] chars = first.toCharArray(); char[] chars = first.toCharArray();
for(int i = 0; i < chars.length; i++){ for (int i = 0; i < chars.length; i++) {
if (chars[i] == '§') { if (chars[i] == '§') {
if(color != null) { if (color != null) {
message.then(text).color(color); message.then(text).color(color);
text = ""; text = "";
color = ChatColor.getByChar(chars[i+1]); color = ChatColor.getByChar(chars[i + 1]);
} else { } else {
color = ChatColor.getByChar(chars[i+1]); color = ChatColor.getByChar(chars[i + 1]);
} }
i++; // skip color char i++; // skip color char
} else { } else {
text += chars[i]; text += chars[i];
} }
} }
if(text.length() > 0) { if (text.length() > 0) {
if(color != null) { if (color != null) {
message.then(text).color(color); message.then(text).color(color);
} else { } else {
message.text(text); message.text(text);