From 61b526e3870c9a1c46598d88a2582a80a136d743 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 10 Apr 2013 10:32:04 +0200 Subject: [PATCH] First pass at using Txt. --- src/com/massivecraft/factions/Board.java | 5 +- src/com/massivecraft/factions/FPlayer.java | 29 +-- src/com/massivecraft/factions/Faction.java | 4 +- .../massivecraft/factions/FactionColl.java | 7 +- .../factions/cmd/CmdAutoHelp.java | 3 +- .../massivecraft/factions/cmd/CmdFlag.java | 7 +- .../massivecraft/factions/cmd/CmdHelp.java | 179 ------------------ .../massivecraft/factions/cmd/CmdLeader.java | 3 +- .../massivecraft/factions/cmd/CmdList.java | 13 +- .../massivecraft/factions/cmd/CmdMoney.java | 3 +- .../factions/cmd/CmdMoneyDeposit.java | 3 +- .../factions/cmd/CmdMoneyTransferFf.java | 3 +- .../factions/cmd/CmdMoneyTransferFp.java | 3 +- .../factions/cmd/CmdMoneyTransferPf.java | 3 +- .../factions/cmd/CmdMoneyWithdraw.java | 3 +- .../massivecraft/factions/cmd/CmdPerm.java | 7 +- .../massivecraft/factions/cmd/CmdShow.java | 17 +- .../massivecraft/factions/cmd/FCmdRoot.java | 3 +- .../massivecraft/factions/cmd/FCommand.java | 15 +- .../massivecraft/factions/zcore/MCommand.java | 9 +- .../massivecraft/factions/zcore/MPlugin.java | 19 +- .../factions/zcore/util/PermUtil.java | 3 +- 22 files changed, 89 insertions(+), 252 deletions(-) delete mode 100644 src/com/massivecraft/factions/cmd/CmdHelp.java diff --git a/src/com/massivecraft/factions/Board.java b/src/com/massivecraft/factions/Board.java index 6514aeb9..5a13d6e7 100644 --- a/src/com/massivecraft/factions/Board.java +++ b/src/com/massivecraft/factions/Board.java @@ -13,6 +13,7 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.block.Block; +import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; import com.massivecraft.factions.integration.LWCFeatures; import com.massivecraft.factions.iface.RelationParticipator; @@ -187,7 +188,7 @@ public class Board { ArrayList ret = new ArrayList(); Faction factionLoc = getFactionAt(flocation); - ret.add(Factions.get().txt.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(observer))); + ret.add(Txt.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(observer))); int halfWidth = ConfServer.mapWidth / 2; int halfHeight = ConfServer.mapHeight / 2; @@ -233,7 +234,7 @@ public class Board } // Get the compass - ArrayList asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Factions.get().txt.parse("")); + ArrayList asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("")); // Add the compass ret.set(1, asciiCompass.get(0)+ret.get(1).substring(3*3)); diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 35e1e17f..8df18b98 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -18,6 +18,7 @@ import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.zcore.persist.PlayerEntity; +import com.massivecraft.mcore.util.Txt; /** @@ -450,7 +451,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator return; } Faction factionHere = Board.getFactionAt(this.getLastStoodAt()); - String msg = Factions.get().txt.parse("")+" ~ "+factionHere.getTag(this); + String msg = Txt.parse("")+" ~ "+factionHere.getTag(this); if (factionHere.getDescription().length() > 0) { msg += " - "+factionHere.getDescription(); @@ -543,11 +544,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator if (ConfServer.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) { // Checks for WorldGuard regions in the chunk attempting to be claimed - error = Factions.get().txt.parse("This land is protected"); + error = Txt.parse("This land is protected"); } else if (ConfServer.worldsNoClaiming.contains(flocation.getWorldName())) { - error = Factions.get().txt.parse("Sorry, this world has land claiming disabled."); + error = Txt.parse("Sorry, this world has land claiming disabled."); } else if (this.hasAdminMode()) { @@ -555,7 +556,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator } else if (forFaction == currentFaction) { - error = Factions.get().txt.parse("%s already own this land.", forFaction.describeTo(this, true)); + error = Txt.parse("%s already own this land.", forFaction.describeTo(this, true)); } else if ( ! FPerm.TERRITORY.has(this, forFaction, true)) { @@ -563,23 +564,23 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator } else if (forFaction.getFPlayers().size() < ConfServer.claimsRequireMinFactionMembers) { - error = Factions.get().txt.parse("Factions must have at least %s members to claim land.", ConfServer.claimsRequireMinFactionMembers); + error = Txt.parse("Factions must have at least %s members to claim land.", ConfServer.claimsRequireMinFactionMembers); } else if (ownedLand >= forFaction.getPowerRounded()) { - error = Factions.get().txt.parse("You can't claim more land! You need more power!"); + error = Txt.parse("You can't claim more land! You need more power!"); } else if (ConfServer.claimedLandsMax != 0 && ownedLand >= ConfServer.claimedLandsMax && ! forFaction.getFlag(FFlag.INFPOWER)) { - error = Factions.get().txt.parse("Limit reached. You can't claim more land!"); + error = Txt.parse("Limit reached. You can't claim more land!"); } else if ( ! ConfServer.claimingFromOthersAllowed && currentFaction.isNormal()) { - error = Factions.get().txt.parse("You may not claim land from others."); + error = Txt.parse("You may not claim land from others."); } else if (currentFaction.getRelationTo(forFaction).isAtLeast(Rel.TRUCE) && ! currentFaction.isNone()) { - error = Factions.get().txt.parse("You can't claim this land due to your relation with the current owner."); + error = Txt.parse("You can't claim this land due to your relation with the current owner."); } else if ( @@ -591,20 +592,20 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator ) { if (ConfServer.claimsCanBeUnconnectedIfOwnedByOtherFaction) - error = Factions.get().txt.parse("You can only claim additional land which is connected to your first claim or controlled by another faction!"); + error = Txt.parse("You can only claim additional land which is connected to your first claim or controlled by another faction!"); else - error = Factions.get().txt.parse("You can only claim additional land which is connected to your first claim!"); + error = Txt.parse("You can only claim additional land which is connected to your first claim!"); } else if (currentFaction.isNormal()) { if ( ! currentFaction.hasLandInflation()) { // TODO more messages WARN current faction most importantly - error = Factions.get().txt.parse("%s owns this land and is strong enough to keep it.", currentFaction.getTag(this)); + error = Txt.parse("%s owns this land and is strong enough to keep it.", currentFaction.getTag(this)); } else if ( ! Board.isBorderLocation(flocation)) { - error = Factions.get().txt.parse("You must start claiming land at the border of the territory."); + error = Txt.parse("You must start claiming land at the border of the territory."); } } @@ -689,6 +690,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator public void msg(String str, Object... args) { - this.sendMessage(Factions.get().txt.parse(str, args)); + this.sendMessage(Txt.parse(str, args)); } } diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 35d66b1f..c6a4eef6 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -12,6 +12,7 @@ import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.util.*; import com.massivecraft.factions.zcore.persist.Entity; +import com.massivecraft.mcore.util.Txt; public class Faction extends Entity implements EconomyParticipator @@ -507,9 +508,10 @@ public class Faction extends Entity implements EconomyParticipator // -------------------------------------------- // // Messages // -------------------------------------------- // + public void msg(String message, Object... args) { - message = Factions.get().txt.parse(message, args); + message = Txt.parse(message, args); for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) { diff --git a/src/com/massivecraft/factions/FactionColl.java b/src/com/massivecraft/factions/FactionColl.java index f0e83cfd..f2761bd0 100644 --- a/src/com/massivecraft/factions/FactionColl.java +++ b/src/com/massivecraft/factions/FactionColl.java @@ -9,6 +9,7 @@ import java.util.logging.Level; import org.bukkit.ChatColor; +import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; import com.massivecraft.factions.integration.Econ; @@ -210,19 +211,19 @@ public class FactionColl extends EntityCollection if(MiscUtil.getComparisonString(str).length() < ConfServer.factionTagLengthMin) { - errors.add(Factions.get().txt.parse("The faction tag can't be shorter than %s chars.", ConfServer.factionTagLengthMin)); + errors.add(Txt.parse("The faction tag can't be shorter than %s chars.", ConfServer.factionTagLengthMin)); } if(str.length() > ConfServer.factionTagLengthMax) { - errors.add(Factions.get().txt.parse("The faction tag can't be longer than %s chars.", ConfServer.factionTagLengthMax)); + errors.add(Txt.parse("The faction tag can't be longer than %s chars.", ConfServer.factionTagLengthMax)); } for (char c : str.toCharArray()) { if ( ! MiscUtil.substanceChars.contains(String.valueOf(c))) { - errors.add(Factions.get().txt.parse("Faction tag must be alphanumeric. \"%s\" is not allowed.", c)); + errors.add(Txt.parse("Faction tag must be alphanumeric. \"%s\" is not allowed.", c)); } } diff --git a/src/com/massivecraft/factions/cmd/CmdAutoHelp.java b/src/com/massivecraft/factions/cmd/CmdAutoHelp.java index ffb694fd..a0f7b1fc 100644 --- a/src/com/massivecraft/factions/cmd/CmdAutoHelp.java +++ b/src/com/massivecraft/factions/cmd/CmdAutoHelp.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import com.massivecraft.factions.Factions; import com.massivecraft.factions.zcore.CommandVisibility; import com.massivecraft.factions.zcore.MCommand; +import com.massivecraft.mcore.util.Txt; public class CmdAutoHelp extends MCommand { @@ -43,6 +44,6 @@ public class CmdAutoHelp extends MCommand } } - sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Help for command \""+pcmd.aliases.get(0)+"\"")); + sendMessage(Txt.getPage(lines, this.argAsInt(0, 1), "Help for command \""+pcmd.aliases.get(0)+"\"")); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFlag.java b/src/com/massivecraft/factions/cmd/CmdFlag.java index ab0471df..01eb37ec 100644 --- a/src/com/massivecraft/factions/cmd/CmdFlag.java +++ b/src/com/massivecraft/factions/cmd/CmdFlag.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Perm; +import com.massivecraft.mcore.util.Txt; public class CmdFlag extends FCommand { @@ -38,7 +39,7 @@ public class CmdFlag extends FCommand if ( ! this.argIsSet(1)) { - msg(p.txt.titleize("Flags for " + faction.describeTo(fme, true))); + msg(Txt.titleize("Flags for " + faction.describeTo(fme, true))); for (FFlag flag : FFlag.values()) { msg(flag.getStateInfo(faction.getFlag(flag), true)); @@ -50,7 +51,7 @@ public class CmdFlag extends FCommand if (flag == null) return; if ( ! this.argIsSet(2)) { - msg(p.txt.titleize("Flag for " + faction.describeTo(fme, true))); + msg(Txt.titleize("Flag for " + faction.describeTo(fme, true))); msg(flag.getStateInfo(faction.getFlag(flag), true)); return; } @@ -62,7 +63,7 @@ public class CmdFlag extends FCommand if ( ! Perm.FLAG_SET.has(sender, true)) return; // Do the change - msg(p.txt.titleize("Flag for " + faction.describeTo(fme, true))); + msg(Txt.titleize("Flag for " + faction.describeTo(fme, true))); faction.setFlag(flag, targetValue); msg(flag.getStateInfo(faction.getFlag(flag), true)); } diff --git a/src/com/massivecraft/factions/cmd/CmdHelp.java b/src/com/massivecraft/factions/cmd/CmdHelp.java deleted file mode 100644 index 0f4d16a3..00000000 --- a/src/com/massivecraft/factions/cmd/CmdHelp.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.massivecraft.factions.cmd; - -import java.util.ArrayList; - -import com.massivecraft.factions.ConfServer; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.Perm; -import com.massivecraft.factions.integration.Econ; - - -public class CmdHelp extends FCommand -{ - - public CmdHelp() - { - super(); - this.aliases.add("help"); - this.aliases.add("h"); - this.aliases.add("?"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("page", "1"); - - this.permission = Perm.HELP.node; - this.disableOnLock = false; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeOfficer = false; - senderMustBeLeader = false; - } - - @Override - public void perform() - { - if (helpPages == null) updateHelp(); - - int page = this.argAsInt(0, 1); - - sendMessage(p.txt.titleize("Factions Help ("+page+"/"+helpPages.size()+")")); - - page -= 1; - - if (page < 0 || page >= helpPages.size()) - { - msg("This page does not exist"); - return; - } - sendMessage(helpPages.get(page)); - } - - //----------------------------------------------// - // Build the help pages - //----------------------------------------------// - - public ArrayList> helpPages; - - public void updateHelp() - { - helpPages = new ArrayList>(); - ArrayList pageLines; - - pageLines = new ArrayList(); - //pageLines.add( p.cmdBase.cmdHelp.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdList.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdShow.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdPower.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdJoin.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdLeave.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdHome.getUseageTemplate(true) ); - pageLines.add( p.txt.parse("Learn how to create a faction on the next page.") ); - helpPages.add(pageLines); - - pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdCreate.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdDescription.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdTag.getUseageTemplate(true) ); - pageLines.add( p.txt.parse("You might want to close it and use invitations:" )); - pageLines.add( p.cmdBase.cmdOpen.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdInvite.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdDeinvite.getUseageTemplate(true) ); - pageLines.add( p.txt.parse("And don't forget to set your home:" )); - pageLines.add( p.cmdBase.cmdSethome.getUseageTemplate(true) ); - helpPages.add(pageLines); - - if (Econ.isSetup() && ConfServer.econEnabled && ConfServer.bankEnabled) - { - pageLines = new ArrayList(); - pageLines.add( p.txt.parse("Your faction has a bank which is used to pay for certain" )); - pageLines.add( p.txt.parse("things, so it will need to have money deposited into it." )); - pageLines.add( p.txt.parse("To learn more, use the money command." )); - pageLines.add( "" ); - pageLines.add( p.cmdBase.cmdMoney.getUseageTemplate(true) ); - pageLines.add( "" ); - pageLines.add( "" ); - pageLines.add( "" ); - helpPages.add(pageLines); - } - - pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdClaim.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdAutoClaim.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdUnclaim.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdUnclaimall.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdKick.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdPromote.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdDemote.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdOfficer.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdLeader.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdTitle.getUseageTemplate(true) ); - pageLines.add( p.txt.parse("Player titles are just for fun. No rules connected to them." )); - helpPages.add(pageLines); - - pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdSeeChunks.getUseageTemplate(true) ); - pageLines.add(p.txt.parse("Claimed land with ownership set is further protected so")); - pageLines.add(p.txt.parse("that only the owner(s), faction admin, and possibly the")); - pageLines.add(p.txt.parse("faction moderators have full access.")); - helpPages.add(pageLines); - - pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdDisband.getUseageTemplate(true) ); - pageLines.add(""); - pageLines.add( p.cmdBase.cmdRelationAlly.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdRelationTruce.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdRelationNeutral.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdRelationEnemy.getUseageTemplate(true) ); - pageLines.add(p.txt.parse("Set the relation you WISH to have with another faction.")); - pageLines.add(p.txt.parse("Your default relation with other factions will be neutral.")); - pageLines.add(p.txt.parse("If BOTH factions choose \"ally\" you will be allies.")); - pageLines.add(p.txt.parse("If ONE faction chooses \"enemy\" you will be enemies.")); - helpPages.add(pageLines); - - pageLines = new ArrayList(); - pageLines.add(p.txt.parse("You can never hurt members or allies.")); - pageLines.add(p.txt.parse("You can not hurt neutrals in their own territory.")); - pageLines.add(p.txt.parse("You can always hurt enemies and players without faction.")); - pageLines.add(""); - pageLines.add(p.txt.parse("Damage from enemies is reduced in your own territory.")); - pageLines.add(p.txt.parse("When you die you lose power. It is restored over time.")); - pageLines.add(p.txt.parse("The power of a faction is the sum of all member power.")); - pageLines.add(p.txt.parse("The power of a faction determines how much land it can hold.")); - pageLines.add(p.txt.parse("You can claim land from factions with too little power.")); - helpPages.add(pageLines); - - pageLines = new ArrayList(); - pageLines.add(p.txt.parse("Only faction members can build and destroy in their own")); - pageLines.add(p.txt.parse("territory. Usage of the following items is also restricted:")); - pageLines.add(p.txt.parse("Door, Chest, Furnace, Dispenser, Diode.")); - pageLines.add(""); - pageLines.add(p.txt.parse("Make sure to put pressure plates in front of doors for your")); - pageLines.add(p.txt.parse("guest visitors. Otherwise they can't get through. You can")); - pageLines.add(p.txt.parse("also use this to create member only areas.")); - pageLines.add(p.txt.parse("As dispensers are protected, you can create traps without")); - pageLines.add(p.txt.parse("worrying about those arrows getting stolen.")); - helpPages.add(pageLines); - - pageLines = new ArrayList(); - pageLines.add("Finally some commands for the server admins:"); - pageLines.add( p.cmdBase.cmdBypass.getUseageTemplate(true) ); - pageLines.add(p.txt.parse("/f claim safezone claim land for the Safe Zone")); - pageLines.add(p.txt.parse("/f claim warzone claim land for the War Zone")); - pageLines.add(p.txt.parse("/f autoclaim [safezone|warzone] take a guess")); - pageLines.add(p.txt.parse("Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + Factions.get().txt.parse("") + " works on safe/war zones as well.")); - helpPages.add(pageLines); - - pageLines = new ArrayList(); - pageLines.add(p.txt.parse("More commands for server admins:")); - pageLines.add( p.cmdBase.cmdPowerBoost.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdSaveAll.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdVersion.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdConfig.getUseageTemplate(true) ); - helpPages.add(pageLines); - } -} - diff --git a/src/com/massivecraft/factions/cmd/CmdLeader.java b/src/com/massivecraft/factions/cmd/CmdLeader.java index b6873109..c2ef7b5f 100644 --- a/src/com/massivecraft/factions/cmd/CmdLeader.java +++ b/src/com/massivecraft/factions/cmd/CmdLeader.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.event.FPlayerJoinEvent; import com.massivecraft.factions.util.RelationUtil; +import com.massivecraft.mcore.util.Txt; public class CmdLeader extends FCommand { @@ -50,7 +51,7 @@ public class CmdLeader extends FCommand // Follow the standard rules if (fme.getRole() != Rel.LEADER || targetFaction != myFaction) { - sender.sendMessage(p.txt.parse("You must be leader of the faction to %s.", this.getHelpShort())); + sender.sendMessage(Txt.parse("You must be leader of the faction to %s.", this.getHelpShort())); return; } diff --git a/src/com/massivecraft/factions/cmd/CmdList.java b/src/com/massivecraft/factions/cmd/CmdList.java index d12a2cda..26b1b561 100644 --- a/src/com/massivecraft/factions/cmd/CmdList.java +++ b/src/com/massivecraft/factions/cmd/CmdList.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.FactionColl; import com.massivecraft.factions.Perm; +import com.massivecraft.mcore.util.Txt; public class CmdList extends FCommand @@ -75,10 +76,10 @@ public class CmdList extends FCommand ArrayList lines = new ArrayList(); /* // this code was really slow on large servers, getting full info for every faction and then only showing 9 of them; rewritten below - lines.add(p.txt.parse("Factionless %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size())); + lines.add(Txt.parse("Factionless %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size())); for (Faction faction : factionList) { - lines.add(p.txt.parse("%s %d/%d online, %d/%d/%d", + lines.add(Txt.parse("%s %d/%d online, %d/%d/%d", faction.getTag(fme), faction.getFPlayersWhereOnline(true).size(), faction.getFPlayers().size(), @@ -88,7 +89,7 @@ public class CmdList extends FCommand ); } - sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Faction List")); + sendMessage(Txt.getPage(lines, this.argAsInt(0, 1), "Faction List")); */ factionList.add(0, FactionColl.i.getNone()); @@ -105,16 +106,16 @@ public class CmdList extends FCommand if (end > factionList.size()) end = factionList.size(); - lines.add(p.txt.titleize("Faction List "+pagenumber+"/"+pagecount)); + lines.add(Txt.titleize("Faction List "+pagenumber+"/"+pagecount)); for (Faction faction : factionList.subList(start, end)) { if (faction.isNone()) { - lines.add(p.txt.parse("Factionless %d online", FactionColl.i.getNone().getFPlayersWhereOnline(true).size())); + lines.add(Txt.parse("Factionless %d online", FactionColl.i.getNone().getFPlayersWhereOnline(true).size())); continue; } - lines.add(p.txt.parse("%s %d/%d online, %d/%d/%d", + lines.add(Txt.parse("%s %d/%d online, %d/%d/%d", faction.getTag(fme), faction.getFPlayersWhereOnline(true).size(), faction.getFPlayers().size(), diff --git a/src/com/massivecraft/factions/cmd/CmdMoney.java b/src/com/massivecraft/factions/cmd/CmdMoney.java index 860ec4ec..588edfec 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoney.java +++ b/src/com/massivecraft/factions/cmd/CmdMoney.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Factions; +import com.massivecraft.mcore.util.Txt; public class CmdMoney extends FCommand { @@ -27,7 +28,7 @@ public class CmdMoney extends FCommand senderMustBeLeader = false; this.setHelpShort("faction money commands"); - this.helpLong.add(p.txt.parseTags("The faction money commands.")); + this.helpLong.add(Txt.parse("The faction money commands.")); this.addSubCommand(this.cmdMoneyBalance); this.addSubCommand(this.cmdMoneyDeposit); diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java b/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java index 79066c64..6f2906ad 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.mcore.util.Txt; import org.bukkit.ChatColor; @@ -39,7 +40,7 @@ public class CmdMoneyDeposit extends FCommand boolean success = Econ.transferMoney(fme, fme, faction, amount); if (success && ConfServer.logMoneyTransactions) - Factions.get().log(ChatColor.stripColor(Factions.get().txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java index 2b90051c..52a55c41 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.mcore.util.Txt; import org.bukkit.ChatColor; @@ -42,6 +43,6 @@ public class CmdMoneyTransferFf extends FCommand boolean success = Econ.transferMoney(fme, from, to, amount); if (success && ConfServer.logMoneyTransactions) - Factions.get().log(ChatColor.stripColor(Factions.get().txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java index dcdfa558..2ee5d9e0 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.mcore.util.Txt; import org.bukkit.ChatColor; @@ -42,6 +43,6 @@ public class CmdMoneyTransferFp extends FCommand boolean success = Econ.transferMoney(fme, from, to, amount); if (success && ConfServer.logMoneyTransactions) - Factions.get().log(ChatColor.stripColor(Factions.get().txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java b/src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java index c42dd773..82372465 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.mcore.util.Txt; import org.bukkit.ChatColor; @@ -42,6 +43,6 @@ public class CmdMoneyTransferPf extends FCommand boolean success = Econ.transferMoney(fme, from, to, amount); if (success && ConfServer.logMoneyTransactions) - Factions.get().log(ChatColor.stripColor(Factions.get().txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java b/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java index a3725776..12d53332 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.mcore.util.Txt; import org.bukkit.ChatColor; @@ -37,6 +38,6 @@ public class CmdMoneyWithdraw extends FCommand boolean success = Econ.transferMoney(fme, faction, fme, amount); if (success && ConfServer.logMoneyTransactions) - Factions.get().log(ChatColor.stripColor(Factions.get().txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdPerm.java b/src/com/massivecraft/factions/cmd/CmdPerm.java index 1563bfed..4263f7bb 100644 --- a/src/com/massivecraft/factions/cmd/CmdPerm.java +++ b/src/com/massivecraft/factions/cmd/CmdPerm.java @@ -4,6 +4,7 @@ import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; +import com.massivecraft.mcore.util.Txt; public class CmdPerm extends FCommand { @@ -41,7 +42,7 @@ public class CmdPerm extends FCommand if ( ! this.argIsSet(1)) { - msg(p.txt.titleize("Perms for " + faction.describeTo(fme, true))); + msg(Txt.titleize("Perms for " + faction.describeTo(fme, true))); msg(FPerm.getStateHeaders()); for (FPerm perm : FPerm.values()) { @@ -54,7 +55,7 @@ public class CmdPerm extends FCommand if (perm == null) return; if ( ! this.argIsSet(2)) { - msg(p.txt.titleize("Perm for " + faction.describeTo(fme, true))); + msg(Txt.titleize("Perm for " + faction.describeTo(fme, true))); msg(FPerm.getStateHeaders()); msg(perm.getStateInfo(faction.getPermittedRelations(perm), true)); return; @@ -78,7 +79,7 @@ public class CmdPerm extends FCommand faction.setRelationPermitted(FPerm.PERMS, Rel.LEADER, true); } - msg(p.txt.titleize("Perm for " + faction.describeTo(fme, true))); + msg(Txt.titleize("Perm for " + faction.describeTo(fme, true))); msg(FPerm.getStateHeaders()); msg(perm.getStateInfo(faction.getPermittedRelations(perm), true)); } diff --git a/src/com/massivecraft/factions/cmd/CmdShow.java b/src/com/massivecraft/factions/cmd/CmdShow.java index 4581db90..3c20fc4e 100644 --- a/src/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/com/massivecraft/factions/cmd/CmdShow.java @@ -13,6 +13,7 @@ import com.massivecraft.factions.Faction; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.zcore.util.TextUtil; +import com.massivecraft.mcore.util.Txt; public class CmdShow extends FCommand { @@ -51,7 +52,7 @@ public class CmdShow extends FCommand Collection normals = faction.getFPlayersWhereRole(Rel.MEMBER); Collection recruits = faction.getFPlayersWhereRole(Rel.RECRUIT); - msg(p.txt.titleize(faction.getTag(fme))); + msg(Txt.titleize(faction.getTag(fme))); msg("Description: %s", faction.getDescription()); // Display important flags @@ -91,22 +92,22 @@ public class CmdShow extends FCommand } } - String sepparator = p.txt.parse("")+", "; + String sepparator = Txt.parse("")+", "; // List the relations to other factions Map> relationTags = faction.getFactionTagsPerRelation(fme, true); if (faction.getFlag(FFlag.PEACEFUL)) { - sendMessage(p.txt.parse("In Truce with: *everyone*")); + sendMessage(Txt.parse("In Truce with: *everyone*")); } else { - sendMessage(p.txt.parse("In Truce with: ") + TextUtil.implode(relationTags.get(Rel.TRUCE), sepparator)); + sendMessage(Txt.parse("In Truce with: ") + TextUtil.implode(relationTags.get(Rel.TRUCE), sepparator)); } - sendMessage(p.txt.parse("Allied to: ") + TextUtil.implode(relationTags.get(Rel.ALLY), sepparator)); - sendMessage(p.txt.parse("Enemies: ") + TextUtil.implode(relationTags.get(Rel.ENEMY), sepparator)); + sendMessage(Txt.parse("Allied to: ") + TextUtil.implode(relationTags.get(Rel.ALLY), sepparator)); + sendMessage(Txt.parse("Enemies: ") + TextUtil.implode(relationTags.get(Rel.ENEMY), sepparator)); // List the members... List memberOnlineNames = new ArrayList(); @@ -159,8 +160,8 @@ public class CmdShow extends FCommand memberOfflineNames.add(follower.getNameAndTitle(fme)); } } - sendMessage(p.txt.parse("Members online: ") + TextUtil.implode(memberOnlineNames, sepparator)); - sendMessage(p.txt.parse("Members offline: ") + TextUtil.implode(memberOfflineNames, sepparator)); + sendMessage(Txt.parse("Members online: ") + TextUtil.implode(memberOnlineNames, sepparator)); + sendMessage(Txt.parse("Members offline: ") + TextUtil.implode(memberOfflineNames, sepparator)); } } diff --git a/src/com/massivecraft/factions/cmd/FCmdRoot.java b/src/com/massivecraft/factions/cmd/FCmdRoot.java index 89886032..dedbf23c 100644 --- a/src/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/com/massivecraft/factions/cmd/FCmdRoot.java @@ -4,6 +4,7 @@ import java.util.Collections; import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Factions; +import com.massivecraft.mcore.util.Txt; public class FCmdRoot extends FCommand { @@ -67,7 +68,7 @@ public class FCmdRoot extends FCommand this.disableOnLock = false; this.setHelpShort("The faction base command"); - this.helpLong.add(p.txt.parseTags("This command contains all faction stuff.")); + this.helpLong.add(Txt.parse("This command contains all faction stuff.")); this.addSubCommand(Factions.get().cmdAutoHelp); this.addSubCommand(this.cmdList); diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/com/massivecraft/factions/cmd/FCommand.java index b4f4fbbb..26da3666 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/com/massivecraft/factions/cmd/FCommand.java @@ -16,6 +16,7 @@ import com.massivecraft.factions.FactionColl; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; import com.massivecraft.factions.zcore.MCommand; +import com.massivecraft.mcore.util.Txt; public abstract class FCommand extends MCommand @@ -101,19 +102,19 @@ public abstract class FCommand extends MCommand if ( ! fplayer.hasFaction()) { - sender.sendMessage(p.txt.parse("You are not member of any faction.")); + sender.sendMessage(Txt.parse("You are not member of any faction.")); return false; } if (this.senderMustBeOfficer && ! fplayer.getRole().isAtLeast(Rel.OFFICER)) { - sender.sendMessage(p.txt.parse("Only faction moderators can %s.", this.getHelpShort())); + sender.sendMessage(Txt.parse("Only faction moderators can %s.", this.getHelpShort())); return false; } if (this.senderMustBeLeader && ! fplayer.getRole().isAtLeast(Rel.LEADER)) { - sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort())); + sender.sendMessage(Txt.parse("Only faction admins can %s.", this.getHelpShort())); return false; } @@ -392,7 +393,7 @@ public abstract class FCommand extends MCommand { if ( ! i.getFaction().equals(you.getFaction())) { - i.sendMessage(p.txt.parse("%s is not in the same faction as you.",you.describeTo(i, true))); + i.sendMessage(Txt.parse("%s is not in the same faction as you.",you.describeTo(i, true))); return false; } @@ -403,7 +404,7 @@ public abstract class FCommand extends MCommand if (you.getRole().equals(Rel.LEADER)) { - i.sendMessage(p.txt.parse("Only the faction admin can do that.")); + i.sendMessage(Txt.parse("Only the faction admin can do that.")); } else if (i.getRole().equals(Rel.OFFICER)) { @@ -413,12 +414,12 @@ public abstract class FCommand extends MCommand } else { - i.sendMessage(p.txt.parse("Moderators can't control each other...")); + i.sendMessage(Txt.parse("Moderators can't control each other...")); } } else { - i.sendMessage(p.txt.parse("You must be a faction moderator to do that.")); + i.sendMessage(Txt.parse("You must be a faction moderator to do that.")); } return false; diff --git a/src/com/massivecraft/factions/zcore/MCommand.java b/src/com/massivecraft/factions/zcore/MCommand.java index 4b4480d5..8ba0dadf 100644 --- a/src/com/massivecraft/factions/zcore/MCommand.java +++ b/src/com/massivecraft/factions/zcore/MCommand.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import com.massivecraft.factions.zcore.MCommand; import com.massivecraft.factions.zcore.MPlugin; import com.massivecraft.factions.zcore.util.TextUtil; +import com.massivecraft.mcore.util.Txt; public abstract class MCommand @@ -221,7 +222,7 @@ public abstract class MCommand public String getUseageTemplate(List> commandChain, boolean addShortHelp) { StringBuilder ret = new StringBuilder(); - ret.append(p.txt.parseTags("")); + ret.append(Txt.parse("")); ret.append('/'); for (MCommand mc : commandChain) @@ -255,13 +256,13 @@ public abstract class MCommand if (args.size() > 0) { - ret.append(p.txt.parseTags("

")); + ret.append(Txt.parse("

")); ret.append(TextUtil.implode(args, " ")); } if (addShortHelp) { - ret.append(p.txt.parseTags(" ")); + ret.append(Txt.parse(" ")); ret.append(this.getHelpShort()); } @@ -284,7 +285,7 @@ public abstract class MCommand public void msg(String str, Object... args) { - sender.sendMessage(p.txt.parse(str, args)); + sender.sendMessage(Txt.parse(str, args)); } public void sendMessage(String msg) diff --git a/src/com/massivecraft/factions/zcore/MPlugin.java b/src/com/massivecraft/factions/zcore/MPlugin.java index 84bda59f..f93ac411 100644 --- a/src/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/com/massivecraft/factions/zcore/MPlugin.java @@ -1,9 +1,6 @@ package com.massivecraft.factions.zcore; import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.util.*; -import java.util.Map.Entry; import java.util.logging.Level; import org.bukkit.Bukkit; @@ -14,17 +11,15 @@ import com.massivecraft.factions.zcore.persist.SaveTask; import com.massivecraft.factions.zcore.util.LibLoader; import com.massivecraft.factions.zcore.util.PermUtil; import com.massivecraft.factions.zcore.util.Persist; -import com.massivecraft.factions.zcore.util.TextUtil; +import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.xlib.gson.Gson; import com.massivecraft.mcore.xlib.gson.GsonBuilder; -import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; public abstract class MPlugin extends JavaPlugin { // Some utils public Persist persist; - public TextUtil txt; public LibLoader lib; public PermUtil perm; @@ -60,8 +55,8 @@ public abstract class MPlugin extends JavaPlugin // if ( ! lib.require("gson.jar", "http://search.maven.org/remotecontent?filepath=com/google/code/gson/gson/2.1/gson-2.1.jar")) return false; this.gson = this.getGsonBuilder().create(); - this.txt = new TextUtil(); - initTXT(); + //this.txt = new TextUtil(); + //initTXT(); // Create and register listeners this.mPluginSecretPlayerListener = new MPluginSecretPlayerListener(this); @@ -119,7 +114,7 @@ public abstract class MPlugin extends JavaPlugin // -------------------------------------------- // // LANG AND TAGS // -------------------------------------------- // - + /* // These are not supposed to be used directly. // They are loaded and used through the TextUtil instance for the plugin. public Map rawTags = new LinkedHashMap(); @@ -151,7 +146,7 @@ public abstract class MPlugin extends JavaPlugin { this.txt.tags.put(rawTag.getKey(), TextUtil.parseColor(rawTag.getValue())); } - } + }*/ // -------------------------------------------- // // HOOKS @@ -176,12 +171,12 @@ public abstract class MPlugin extends JavaPlugin public void log(String str, Object... args) { - log(Level.INFO, this.txt.parse(str, args)); + log(Level.INFO, Txt.parse(str, args)); } public void log(Level level, String str, Object... args) { - log(level, this.txt.parse(str, args)); + log(level, Txt.parse(str, args)); } public void log(Level level, Object msg) diff --git a/src/com/massivecraft/factions/zcore/util/PermUtil.java b/src/com/massivecraft/factions/zcore/util/PermUtil.java index f68d19a9..2a962bc3 100644 --- a/src/com/massivecraft/factions/zcore/util/PermUtil.java +++ b/src/com/massivecraft/factions/zcore/util/PermUtil.java @@ -9,6 +9,7 @@ import org.bukkit.permissions.Permission; import com.massivecraft.factions.zcore.Lang; import com.massivecraft.factions.zcore.MPlugin; +import com.massivecraft.mcore.util.Txt; public class PermUtil { @@ -25,7 +26,7 @@ public class PermUtil { public String getForbiddenMessage(String perm) { - return p.txt.parse(Lang.permForbidden, getPermissionDescription(perm)); + return Txt.parse(Lang.permForbidden, getPermissionDescription(perm)); } /**