From 5ea8392fd5ab60822a1a66dbed88b355ad4688bb Mon Sep 17 00:00:00 2001 From: korikisulda Date: Fri, 23 Jan 2015 19:25:14 +0000 Subject: [PATCH] Even moar TL --- .../listeners/FactionsEntityListener.java | 32 +++++++++--------- .../listeners/FactionsPlayerListener.java | 28 ++++++++-------- .../massivecraft/factions/zcore/util/TL.java | 33 +++++++++++++++++++ 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index f222ea62..d982ec18 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -4,6 +4,8 @@ import com.massivecraft.factions.*; import com.massivecraft.factions.event.PowerLossEvent; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.util.MiscUtil; +import com.massivecraft.factions.zcore.util.TL; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.TravelAgent; @@ -50,23 +52,23 @@ public class FactionsEntityListener implements Listener { if (faction.isWarZone()) { // war zones always override worldsNoPowerLoss either way, thus this layout if (!Conf.warZonePowerLoss) { - powerLossEvent.setMessage("You didn't lose any power since you were in a war zone."); + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WARZONE.toString()); powerLossEvent.setCancelled(true); } if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { - powerLossEvent.setMessage("The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\nYour power is now %d / %d"); + powerLossEvent.setMessage(TL.PLAYER_POWER_LOSS_WARZONE.toString()); } } else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) { - powerLossEvent.setMessage("You didn't lose any power since you were in the wilderness."); + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WILDERNESS.toString()); powerLossEvent.setCancelled(true); } else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { - powerLossEvent.setMessage("You didn't lose any power due to the world you died in."); + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WORLD.toString()); powerLossEvent.setCancelled(true); } else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) { - powerLossEvent.setMessage("You didn't lose any power since you are in a peaceful faction."); + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_PEACEFUL.toString()); powerLossEvent.setCancelled(true); } else { - powerLossEvent.setMessage("Your power is now %d / %d"); + powerLossEvent.setMessage(TL.PLAYER_POWER_NOW.toString()); } // call Event @@ -304,7 +306,7 @@ public class FactionsEntityListener implements Listener { if (attacker.hasLoginPvpDisabled()) { if (notify) { - attacker.msg("You can't hurt other players for " + Conf.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in."); + attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin); } return false; } @@ -332,7 +334,7 @@ public class FactionsEntityListener implements Listener { if (attackFaction.isNone() && Conf.disablePVPForFactionlessPlayers) { if (notify) { - attacker.msg("You can't hurt other players until you join a faction."); + attacker.msg(TL.PLAYER_PVP_REQUIREFACTION); } return false; } else if (defendFaction.isNone()) { @@ -341,7 +343,7 @@ public class FactionsEntityListener implements Listener { return true; } else if (Conf.disablePVPForFactionlessPlayers) { if (notify) { - attacker.msg("You can't hurt players who are not currently in a faction."); + attacker.msg(TL.PLAYER_PVP_FACTIONLESS); } return false; } @@ -349,12 +351,12 @@ public class FactionsEntityListener implements Listener { if (defendFaction.isPeaceful()) { if (notify) { - attacker.msg("You can't hurt players who are in a peaceful faction."); + attacker.msg(TL.PLAYER_PVP_PEACEFUL); } return false; } else if (attackFaction.isPeaceful()) { if (notify) { - attacker.msg("You can't hurt players while you are in a peaceful faction."); + attacker.msg(TL.PLAYER_PVP_PEACEFUL); } return false; } @@ -364,7 +366,7 @@ public class FactionsEntityListener implements Listener { // You can not hurt neutral factions if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) { if (notify) { - attacker.msg("You can't hurt neutral factions. Declare them as an enemy."); + attacker.msg(TL.PLAYER_PVP_NEUTRAL); } return false; } @@ -377,7 +379,7 @@ public class FactionsEntityListener implements Listener { // You can never hurt faction members or allies if (relation.isMember() || relation.isAlly()) { if (notify) { - attacker.msg("You can't hurt %s.", defender.describeTo(attacker)); + attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker)); } return false; } @@ -387,8 +389,8 @@ public class FactionsEntityListener implements Listener { // You can not hurt neutrals in their own territory. if (ownTerritory && relation.isNeutral()) { if (notify) { - attacker.msg("You can't hurt %s in their own territory unless you declare them as an enemy.", defender.describeTo(attacker)); - defender.msg("%s tried to hurt you.", attacker.describeTo(defender, true)); + attacker.msg(TL.PLAYER_PVP_NEUTRALFAIL, defender.describeTo(attacker)); + defender.msg(TL.PLAYER_PVP_TRIED, attacker.describeTo(defender, true)); } return false; } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index df90eb46..d5b0a130 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -187,7 +187,7 @@ public class FactionsPlayerListener implements Listener { } else { if (!Board.getInstance().getFactionAt(to).isSafeZone()) { Board.getInstance().setFactionAt(Factions.getInstance().getSafeZone(), to); - me.msg("This land is now a safe zone."); + me.msg(TL.PLAYER_SAFEAUTO); } } } else if (me.isAutoWarClaimEnabled()) { @@ -196,7 +196,7 @@ public class FactionsPlayerListener implements Listener { } else { if (!Board.getInstance().getFactionAt(to).isWarZone()) { Board.getInstance().setFactionAt(Factions.getInstance().getWarZone(), to); - me.msg("This land is now a war zone."); + me.msg(TL.PLAYER_WARAUTO); } } } @@ -231,7 +231,7 @@ public class FactionsPlayerListener implements Listener { int count = attempt.increment(); if (count >= 10) { FPlayer me = FPlayers.getInstance().getByPlayer(player); - me.msg("Ouch, that is starting to hurt. You should give it a rest."); + me.msg(TL.PLAYER_OUCH); player.damage(NumberConversions.floor((double) count / 10)); } } @@ -300,7 +300,7 @@ public class FactionsPlayerListener implements Listener { } if (!justCheck) { - me.msg("You can't use %s in the wilderness.", TextUtil.getMaterialName(material)); + me.msg(TL.PLAYER_USE_WILDERNESS, TextUtil.getMaterialName(material)); } return false; @@ -310,7 +310,7 @@ public class FactionsPlayerListener implements Listener { } if (!justCheck) { - me.msg("You can't use %s in a safe zone.", TextUtil.getMaterialName(material)); + me.msg(TL.PLAYER_USE_SAFEZONE, TextUtil.getMaterialName(material)); } return false; @@ -320,7 +320,7 @@ public class FactionsPlayerListener implements Listener { } if (!justCheck) { - me.msg("You can't use %s in a war zone.", TextUtil.getMaterialName(material)); + me.msg(TL.PLAYER_USE_WARZONE, TextUtil.getMaterialName(material)); } return false; @@ -332,7 +332,7 @@ public class FactionsPlayerListener implements Listener { // Cancel if we are not in our own territory if (rel.confDenyUseage()) { if (!justCheck) { - me.msg("You can't use %s in the territory of %s.", TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + me.msg(TL.PLAYER_USE_TERRITORY, TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); } return false; @@ -341,7 +341,7 @@ public class FactionsPlayerListener implements Listener { // Also cancel if player doesn't have ownership rights for this claim if (Conf.ownedAreasEnabled && Conf.ownedAreaDenyUseage && !otherFaction.playerHasOwnershipRights(me, loc)) { if (!justCheck) { - me.msg("You can't use %s in this territory, it is owned by: %s.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc)); + me.msg(TL.PLAYER_USE_OWNED, TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc)); } return false; @@ -400,7 +400,7 @@ 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) || (rel.isTruce() && Conf.territoryTruceProtectMaterials)) { if (!justCheck) { - me.msg("You can't %s %s in the territory of %s.", (material == Material.SOIL ? "trample" : "use"), TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + me.msg(TL.PLAYER_USE_TERRITORY, (material == Material.SOIL ? "trample" : "use"), TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); } return false; @@ -409,7 +409,7 @@ public class FactionsPlayerListener implements Listener { // Also cancel if player doesn't have ownership rights for this claim if (Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc)) { if (!justCheck) { - me.msg("You can't use %s in this territory, it is owned by: %s.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc)); + me.msg(TL.PLAYER_USE_OWNED, TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc)); } return false; @@ -487,7 +487,7 @@ public class FactionsPlayerListener implements Listener { !Conf.permanentFactionMemberDenyCommands.isEmpty() && me.getFaction().isPermanent() && isCommandInList(fullCmd, shortCmd, Conf.permanentFactionMemberDenyCommands.iterator())) { - me.msg("You can't use the command \"" + fullCmd + "\" because you are in a permanent faction."); + me.msg(TL.PLAYER_COMMAND_PERMANENT, fullCmd); return true; } @@ -501,17 +501,17 @@ public class FactionsPlayerListener implements Listener { } if (rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) { - me.msg("You can't use the command \"" + fullCmd + "\" in neutral territory."); + me.msg(TL.PLAYER_COMMAND_NEUTRAL, fullCmd); return true; } if (rel.isEnemy() && !Conf.territoryEnemyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())) { - me.msg("You can't use the command \"" + fullCmd + "\" in enemy territory."); + me.msg(TL.PLAYER_COMMAND_ENEMY, fullCmd); return true; } if(Board.getInstance().getFactionAt(new FLocation(me)).isWarZone() && !Conf.warzoneDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.warzoneDenyCommands.iterator())) { - me.msg("You can't use the command \"" + fullCmd + "\" in warzone."); + me.msg(TL.PLAYER_COMMAND_WARZONE, fullCmd); return true; } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index 5fa8570e..5f086e9f 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -595,6 +595,39 @@ public enum TL { ROLE_MODERATOR("moderator"), ROLE_NORMAL("normal member"), + /** + * In the player and entity listeners + */ + PLAYER_SAFEAUTO("This land is now a safe zone."), + PLAYER_WARAUTO("This land is now a war zone."), + PLAYER_OUCH("Ouch, that is starting to hurt. You should give it a rest."), + PLAYER_USE_WILDERNESS("You can't use %s in the wilderness."), + PLAYER_USE_SAFEZONE("You can't use %s in a safe zone."), + PLAYER_USE_WARZONE("You can't use %s in a war zone."), + PLAYER_USE_TERRITORY("You can't use %s in the territory of %s."), + PLAYER_USE_OWNED("You can't use %s in this territory, it is owned by: %s."), + PLAYER_COMMAND_WARZONE("You can't use the command '%s' in warzone."), + PLAYER_COMMAND_NEUTRAL("You can't use the command '%s' in neutral territory."), + PLAYER_COMMAND_ENEMY("You can't use the command '%s' in enemy territory."), + PLAYER_COMMAND_PERMANENT("You can't use the command '%s' because you are in a permanent faction."), + + PLAYER_POWER_NOLOSS_PEACEFUL("You didn't lose any power since you are in a peaceful faction."), + PLAYER_POWER_NOLOSS_WORLD("You didn't lose any power due to the world you died in."), + PLAYER_POWER_NOLOSS_WILDERNESS("You didn't lose any power since you were in the wilderness."), + PLAYER_POWER_NOLOSS_WARZONE("You didn't lose any power since you were in a war zone."), + PLAYER_POWER_LOSS_WARZONE("The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\nYour power is now %d / %d"), + PLAYER_POWER_NOW("Your power is now %d / %d"), + + PLAYER_PVP_LOGIN("You can't hurt other players for %d seconds after logging in."), + PLAYER_PVP_REQUIREFACTION("You can't hurt other players until you join a faction."), + PLAYER_PVP_FACTIONLESS("You can't hurt players who are not currently in a faction."), + PLAYER_PVP_PEACEFUL("Peaceful players cannot participate in combat."), + PLAYER_PVP_NEUTRAL("You can't hurt neutral factions. Declare them as an enemy."), + PLAYER_PVP_CANTHURT("You can't hurt %s."), + + PLAYER_PVP_NEUTRALFAIL("You can't hurt %s in their own territory unless you declare them as an enemy."), + PLAYER_PVP_TRIED("%s tried to hurt you."), + /** * Strings lying around in other bits of the plugins */