Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 258ee4f

Browse files
authored
Merge pull request #133 from ProSavage/permsfix
Minor translations for some action messages
2 parents 98dd9a7 + ca75e76 commit 258ee4f

File tree

5 files changed

+49
-20
lines changed

5 files changed

+49
-20
lines changed

src/main/java/com/massivecraft/factions/cmd/FCommand.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,29 @@ public boolean validSenderType(CommandSender sender, boolean informSenderIfNot)
9999

100100
if (!fme.hasFaction()) {
101101
if (informSenderIfNot) {
102-
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
102+
sender.sendMessage(p.txt.parse(TL.ACTIONS_NOFACTION.toString()));
103103
}
104104
return false;
105105
}
106106

107107

108108
if (this.senderMustBeModerator && !fme.getRole().isAtLeast(Role.MODERATOR)) {
109109
if (informSenderIfNot) {
110-
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
110+
sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "moderator").replace("{action}", this.getHelpShort())));
111111
}
112112
return false;
113113
}
114114

115115
if (this.senderMustBeColeader && !fme.getRole().isAtLeast(Role.COLEADER)) {
116116
if (informSenderIfNot) {
117-
sender.sendMessage(p.txt.parse("<b>Only faction coleaders can %s.", this.getHelpShort()));
117+
sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "coleader").replace("{action}", this.getHelpShort())));
118118
}
119119
return false;
120120
}
121121

122122
if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.LEADER)) {
123123
if (informSenderIfNot) {
124-
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
124+
sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "admin").replace("{action}", this.getHelpShort())));
125125
}
126126
return false;
127127
}
@@ -140,7 +140,7 @@ public boolean assertHasFaction() {
140140
}
141141

142142
if (!fme.hasFaction()) {
143-
sendMessage("You are not member of any faction.");
143+
msg(TL.ACTIONS_NOFACTION);
144144
return false;
145145
}
146146
return true;
@@ -152,7 +152,7 @@ public boolean assertMinRole(Role role) {
152152
}
153153

154154
if (fme.getRole().value < role.value) {
155-
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + ".");
155+
msg(TL.ACTIONS_MUSTBE.toString().replace("{role}", role.nicename).replace("{action}", this.getHelpShort()));
156156
return false;
157157
}
158158
return true;
@@ -282,23 +282,23 @@ public boolean canIAdministerYou(FPlayer i, FPlayer you) {
282282
}
283283

284284
if (you.getRole().equals(Role.LEADER)) {
285-
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
285+
i.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "leader").replace("{action}", "do that")));
286286

287287
} else if ((you.getRole().equals(Role.COLEADER))) {
288288
if (i == you) {
289289
return true;
290290
} else {
291-
i.sendMessage(p.txt.parse("<b>Coleaders can't control each other..."));
291+
i.sendMessage(p.txt.parse(TL.ACTIONS_NOSAMEROLE.toString().replace("{role}", i.getRole().nicename)));
292292
}
293293

294294
} else if (i.getRole().equals(Role.MODERATOR)) {
295295
if (i == you) {
296296
return true; //Moderators can control themselves
297297
} else {
298-
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
298+
i.sendMessage(p.txt.parse(TL.ACTIONS_NOSAMEROLE.toString().replace("{role}", i.getRole().nicename)));
299299
}
300300
} else {
301-
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
301+
i.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "moderator").replace("{action}", "do that")));
302302
}
303303

304304
return false;

src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -487,31 +487,31 @@ private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation lo
487487
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
488488
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true;
489489
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
490-
me.msg("<b>You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
490+
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
491491
if (shouldHurt) {
492492
player.damage(Conf.actionDeniedPainAmount);
493-
me.msg("<b>It is painful to try to " + action + " in the territory of " + Board.getInstance().getFactionAt(loc).getTag(myFaction));
493+
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
494494
}
495495
return false;
496496
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
497497
if (shouldHurt) {
498498
player.damage(Conf.actionDeniedPainAmount);
499-
me.msg("<b>It is painful to try to " + action + " in the territory of " + Board.getInstance().getFactionAt(loc).getTag(myFaction));
499+
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
500500
}
501-
me.msg("You cannot " + action + " in the territory of " + myFaction.getTag(me.getFaction()));
501+
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
502502
return false;
503503
} else if (access == Access.ALLOW) return true;
504-
me.msg("You cannot " + action + " in the territory of " + myFaction.getTag(me.getFaction()));
504+
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
505505
return false;
506506
}
507507

508508
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) {
509509
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
510510
// If pain should be applied
511-
if (pain && Conf.ownedAreaPainBuild) me.msg("<b>It is painful to try to " + action + " in this territory, it is owned by: " + target.getOwnerListString(location));
511+
if (pain && Conf.ownedAreaPainBuild) me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
512512
if (Conf.ownedAreaDenyBuild && pain) return false;
513513
else if (Conf.ownedAreaDenyBuild) {
514-
me.msg("You cannot " + action + " in the territory of " + target.getTag(me.getFaction()));
514+
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));
515515
return false;
516516
}
517517
}

src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static boolean playerCanUseItemHere(Player player, Location location, Mat
8787
// Also cancel if player doesn't have ownership rights for this claim
8888
if (Conf.ownedAreasEnabled && myFaction == otherFaction && !myFaction.playerHasOwnershipRights(me, loc)) {
8989
if (!justCheck) {
90-
me.msg("<b>You can't use that in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
90+
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
9191
}
9292
return false;
9393
}
@@ -772,7 +772,7 @@ public void onPlayerBoneMeal(PlayerInteractEvent event) {
772772
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
773773
Faction myFaction = me.getFaction();
774774

775-
me.msg("<b>You can't use bone meal in the territory of " + otherFaction.getTag(myFaction));
775+
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));
776776
event.setCancelled(true);
777777
}
778778
}
@@ -894,6 +894,10 @@ private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation lo
894894
boolean doPain = pain && Conf.handleExploitInteractionSpam;
895895
if (access != null && access != Access.UNDEFINED) {
896896
// TODO: Update this once new access values are added other than just allow / deny.
897+
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
898+
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true;
899+
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
900+
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
897901
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
898902
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId())))
899903
return true;
@@ -905,6 +909,11 @@ else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.ge
905909
return false;
906910
} else if (!landOwned && access == Access.ALLOW) return true;
907911
else {
912+
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
913+
return false;
914+
}
915+
}
916+
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
908917
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
909918
return false;
910919
}
@@ -919,6 +928,9 @@ else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.ge
919928
private static PermissableAction GetPermissionFromUsableBlock(Block block) {
920929
return GetPermissionFromUsableBlock(block.getType());
921930
}
931+
/// <summary>
932+
/// This will try to resolve a permission action based on the item material, if it's not usable, will return null
933+
/// <summary>
922934
private static PermissableAction GetPermissionFromUsableBlock(Material material) {
923935
// Check for doors that might have diff material name in old version.
924936
if (material.name().contains("DOOR"))

src/main/java/com/massivecraft/factions/zcore/util/TL.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@ public enum TL {
4646
_LOCAL_LANGUAGE("English"),
4747
_LOCAL_REGION("US"),
4848
_LOCAL_STATE("complete"), //And this is the English version. It's not ever going to be not complete.
49-
49+
/**
50+
* Actions translations
51+
*/
52+
ACTIONS_NOPERMISSION("<b>{faction} does not allow you to {action}</b>"),
53+
ACTIONS_NOPERMISSIONPAIN("<b>It is painful to try to {action} in the territory of {faction}</b>"),
54+
ACTIONS_OWNEDTERRITORYDENY("<b>You cant do that in this territory, it is owned by {owners}</b>"),
55+
ACTIONS_OWNEDTERRITORYPAINDENY("<b>It is painful to try to {action} in this territory, it is owned by {owners}"),
56+
ACTIONS_MUSTBE("<b>You </b><h>must be {role}</h><b> to {action}.</b>"),
57+
ACTIONS_NOSAMEROLE("<b>{role} can't control each other...</b>"),
58+
ACTIONS_NOFACTION("You are not member of any faction."),
5059
/**
5160
* Command translations
5261
*/

src/main/resources/lang/en_US.yml

+8
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,14 @@ COMPASS:
476476
EAST: E
477477
SOUTH: S
478478
WEST: W
479+
ACTIONS:
480+
NOPERMISSION: '<b>{faction} does not allow you to {action}</b>'
481+
NOPERMISSIONPAINFUL: '<b>It is painful to try to {action} in the territory of {faction}</b>'
482+
OWNEDTERRITORYDENY: <b>You cant do that in this territory, it is owned by {owners}</b>
483+
OWNEDTERRITORYPAINDENY: <b>It is painful to try to {action} in this territory, it is owned by {owners}</b>
484+
MUSTBE: '<b>You </b><h>must be {role}</h><b> to {action}.</b>'
485+
NOSAMEROLE: <b>{role} can't control each other...</b>
486+
NOFACTION: 'You are not member of any faction.'
479487
CHAT:
480488
FACTION: faction chat
481489
ALLIANCE: alliance chat

0 commit comments

Comments
 (0)