Skip to content

Commit

Permalink
Add variable support to all messages where a region is known (mostly …
Browse files Browse the repository at this point in the history
…messages of commands were not using it yet).
  • Loading branch information
NLthijs48 committed Feb 8, 2016
1 parent 0d205b0 commit c445a62
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,49 +75,49 @@ public void execute(CommandSender sender, String[] args) {
if(sender.hasPermission("areashop.addfriendall")) {
if((region.isRentRegion() && !((RentRegion)region).isRented())
|| (region.isBuyRegion() && !((BuyRegion)region).isSold())) {
plugin.message(sender, "addfriend-noOwner");
plugin.message(sender, "addfriend-noOwner", region);
return;
}
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
if(friend.getLastPlayed() == 0 && !plugin.getConfig().getBoolean("addFriendNotExistingPlayers")) {
plugin.message(sender, "addfriend-notVisited", args[1]);
plugin.message(sender, "addfriend-notVisited", args[1], region);
return;
}
if(region.getFriends().contains(friend.getUniqueId())) {
plugin.message(sender, "addfriend-alreadyAdded", friend.getName());
plugin.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
return;
}
if(region.isOwner(friend.getUniqueId())) {
plugin.message(sender, "addfriend-self", friend.getName());
plugin.message(sender, "addfriend-self", friend.getName(), region);
return;
}
region.addFriend(friend.getUniqueId());
region.update();
plugin.message(sender, "addfriend-successOther", friend.getName(), region.getName());
plugin.message(sender, "addfriend-successOther", friend.getName(), region);
} else {
if(sender.hasPermission("areashop.addfriend") && sender instanceof Player) {
if(region.isOwner((Player)sender)) {
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
if(friend.getLastPlayed() == 0 && !plugin.getConfig().getBoolean("addFriendNotExistingPlayers")) {
plugin.message(sender, "addfriend-notVisited", args[1]);
plugin.message(sender, "addfriend-notVisited", args[1], region);
return;
}
if(region.getFriends().contains(friend.getUniqueId())) {
plugin.message(sender, "addfriend-alreadyAdded", friend.getName());
plugin.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
return;
}
if(region.isOwner(friend.getUniqueId())) {
plugin.message(sender, "addfriend-self", friend.getName());
plugin.message(sender, "addfriend-self", friend.getName(), region);
return;
}
region.addFriend(friend.getUniqueId());
region.update();
plugin.message(sender, "addfriend-success", friend.getName(), region.getName());
plugin.message(sender, "addfriend-success", friend.getName(), region);
} else {
plugin.message(sender, "addfriend-noPermissionOther");
plugin.message(sender, "addfriend-noPermissionOther", region);
}
} else {
plugin.message(sender, "addfriend-noPermission");
plugin.message(sender, "addfriend-noPermission", region);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ public void execute(CommandSender sender, String[] args) {
profile = args[2];
Set<String> profiles = plugin.getConfig().getConfigurationSection("signProfiles").getKeys(false);
if(!profiles.contains(profile)) {
plugin.message(sender, "addsign-wrongProfile", Utils.createCommaSeparatedList(profiles));
plugin.message(sender, "addsign-wrongProfile", Utils.createCommaSeparatedList(profiles), region);
return;
}
}
GeneralRegion signRegion = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
if(signRegion != null) {
plugin.message(sender, "addsign-alreadyRegistered", signRegion.getName());
plugin.message(sender, "addsign-alreadyRegistered", signRegion);
return;
}

region.addSign(block.getLocation(), block.getType(), sign.getFacing(), profile);
if(profile == null) {
plugin.message(sender, "addsign-success", region);
} else {
plugin.message(sender, "addsign-successProfile", region, profile);
plugin.message(sender, "addsign-successProfile", profile, region);
}
region.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void execute(CommandSender sender, String[] args) {
plugin.message(player, "cmd-noRegionsFound");
return;
}
// Start removing the region that he has permission for
// Start removing the regions that he has permission for
ArrayList<String> namesSuccess = new ArrayList<>();
ArrayList<String> namesFailed = new ArrayList<>();
for(GeneralRegion region : regions) {
Expand Down Expand Up @@ -100,17 +100,17 @@ public void execute(CommandSender sender, String[] args) {
// Remove the rent if the player has permission
if(sender.hasPermission("areashop.destroyrent") || (isLandlord && sender.hasPermission("areashop.destroyrent.landlord"))) {
plugin.getFileManager().removeRent((RentRegion)region, true);
plugin.message(sender, "destroy-successRent", region.getName());
plugin.message(sender, "destroy-successRent", region);
} else {
plugin.message(sender, "destroy-noPermissionRent");
plugin.message(sender, "destroy-noPermissionRent", region);
}
} else if(region.isBuyRegion()) {
// Remove the buy if the player has permission
if(sender.hasPermission("areashop.destroybuy") || (isLandlord && sender.hasPermission("areashop.destroybuy.landlord"))) {
plugin.getFileManager().removeBuy((BuyRegion)region, true);
plugin.message(sender, "destroy-successBuy", region.getName());
plugin.message(sender, "destroy-successBuy", region);
} else {
plugin.message(sender, "destroy-noPermissionBuy");
plugin.message(sender, "destroy-noPermissionBuy", region);
}
}
Bukkit.getPluginManager().callEvent(new RemovedRegionEvent(region));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,33 @@ public void execute(CommandSender sender, String[] args) {
if(sender.hasPermission("areashop.delfriendall")) {
if((region.isRentRegion() && !((RentRegion)region).isRented())
|| (region.isBuyRegion() && !((BuyRegion)region).isSold())) {
plugin.message(sender, "delfriend-noOwner");
plugin.message(sender, "delfriend-noOwner", region);
return;
}
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
if(!region.getFriends().contains(friend.getUniqueId())) {
plugin.message(sender, "delfriend-notAdded", friend.getName());
plugin.message(sender, "delfriend-notAdded", friend.getName(), region);
return;
}
region.deleteFriend(friend.getUniqueId());
region.update();
plugin.message(sender, "delfriend-successOther", friend.getName(), region.getName());
plugin.message(sender, "delfriend-successOther", friend.getName(), region);
} else {
if(sender.hasPermission("areashop.delfriend") && sender instanceof Player) {
if(region.isOwner((Player)sender)) {
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
if(!region.getFriends().contains(friend.getUniqueId())) {
plugin.message(sender, "delfriend-notAdded", friend.getName());
plugin.message(sender, "delfriend-notAdded", friend.getName(), region);
return;
}
region.deleteFriend(friend.getUniqueId());
region.update();
plugin.message(sender, "delfriend-success", friend.getName(), region.getName());
plugin.message(sender, "delfriend-success", friend.getName(), region);
} else {
plugin.message(sender, "delfriend-noPermissionOther");
plugin.message(sender, "delfriend-noPermissionOther", region);
}
} else {
plugin.message(sender, "delfriend-noPermission");
plugin.message(sender, "delfriend-noPermission", region);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void execute(CommandSender sender, String[] args) {
plugin.message(sender, "delsign-noRegion");
return;
}
plugin.message(sender, "delsign-success", region.getName());
plugin.message(sender, "delsign-success", region);
region.removeSign(block.getLocation());
region.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void execute(CommandSender sender, String[] args) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-successMax", "buy", region.getName(), Utils.formatCurrency(maxPrice), onlyInGroup);
plugin.message(player, "find-successMax", "buy", Utils.formatCurrency(maxPrice), onlyInGroup, region);
} else {
plugin.message(player, "find-success", "buy", region.getName(), Utils.formatCurrency(balance), onlyInGroup);
plugin.message(player, "find-success", "buy", Utils.formatCurrency(balance), onlyInGroup, region);
}
region.teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
} else {
Expand Down Expand Up @@ -123,9 +123,9 @@ public void execute(CommandSender sender, String[] args) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-successMax", "rent", region.getName(), Utils.formatCurrency(maxPrice), onlyInGroup);
plugin.message(player, "find-successMax", "rent", Utils.formatCurrency(maxPrice), onlyInGroup, region);
} else {
plugin.message(player, "find-success", "rent", region.getName(), Utils.formatCurrency(balance), onlyInGroup);
plugin.message(player, "find-success", "rent", Utils.formatCurrency(balance), onlyInGroup, region);
}
region.teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public void execute(CommandSender sender, String[] args) {
}
if(group.addMember(region)) {
region.update();
plugin.message(sender, "groupadd-success", region.getName(), group.getName(), group.getMembers().size());
plugin.message(sender, "groupadd-success", group.getName(), group.getMembers().size(), region);
} else {
plugin.message(sender, "groupadd-failed", region.getName(), group.getName());
plugin.message(sender, "groupadd-failed", group.getName(), region);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void execute(CommandSender sender, String[] args) {
}
if(group.removeMember(region)) {
region.update();
plugin.message(sender, "groupdel-success", region.getName(), group.getName(), group.getMembers().size());
plugin.message(sender, "groupdel-success", group.getName(), group.getMembers().size(), region);
} else {
plugin.message(sender, "groupdel-failed", region.getName(), group.getName());
plugin.message(sender, "groupdel-failed", group.getName(), region);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public void execute(CommandSender sender, String[] args) {
buy.update();
plugin.message(sender, "resell-success", buy);
} else {
plugin.message(sender, "resell-noPermissionOther");
plugin.message(sender, "resell-noPermissionOther", buy);
}
} else {
plugin.message(sender, "resell-noPermission");
plugin.message(sender, "resell-noPermission", buy);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public void execute(CommandSender sender, String[] args) {
for(RegionEvent value : RegionEvent.values()) {
values.add(value.getValue().toLowerCase());
}
plugin.message(sender, "schemevent-wrongEvent", args[2], Utils.createCommaSeparatedList(values));
plugin.message(sender, "schemevent-wrongEvent", args[2], Utils.createCommaSeparatedList(values), region);
return;
}
region.handleSchematicEvent(event);
region.update();
plugin.message(sender, "schemevent-success", args[2], region.getName());
plugin.message(sender, "schemevent-success", args[2], region);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void execute(CommandSender sender, String[] args) {
return;
}
if(!buy.isSold()) {
plugin.message(sender, "sell-notBought");
plugin.message(sender, "sell-notBought", buy);
return;
}
buy.sell(true, sender);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ public void execute(CommandSender sender, String[] args) {
try {
Integer.parseInt(args[1]);
} catch(NumberFormatException e) {
plugin.message(sender, "setduration-wrongAmount", args[1]);
plugin.message(sender, "setduration-wrongAmount", args[1], rent);
return;
}
if(!Utils.checkTimeFormat(args[1]+" "+args[2])) {
plugin.message(sender, "setduration-wrongFormat", args[1]+" "+args[2]);
plugin.message(sender, "setduration-wrongFormat", args[1]+" "+args[2], rent);
return;
}
rent.setDuration(args[1]+" "+args[2]);
rent.update();
plugin.message(sender, "setduration-success", rent.getName(), rent.getDurationString());
plugin.message(sender, "setduration-success", rent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void execute(CommandSender sender, String[] args) {
}
region.setLandlord(player.getUniqueId(), playerName);
region.update();
plugin.message(sender, "setlandlord-success", playerName, region.getName());
plugin.message(sender, "setlandlord-success", playerName, region);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public void execute(CommandSender sender, String[] args) {
}

if(region.isRentRegion() && !sender.hasPermission("areashop.setownerrent")) {
plugin.message(sender, "setowner-noPermissionRent");
plugin.message(sender, "setowner-noPermissionRent", region);
return;
}
if(region.isBuyRegion() && !sender.hasPermission("areashop.setownerbuy")) {
plugin.message(sender, "setowner-noPermissionBuy");
plugin.message(sender, "setowner-noPermissionBuy", region);
return;
}

Expand All @@ -86,7 +86,7 @@ public void execute(CommandSender sender, String[] args) {
uuid = player.getUniqueId();
}
if(uuid == null) {
plugin.message(sender, "setowner-noPlayer", args[1]);
plugin.message(sender, "setowner-noPlayer", args[1], region);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void execute(CommandSender sender, String[] args) {
try {
price = Double.parseDouble(args[1]);
} catch(NumberFormatException e) {
plugin.message(sender, "setprice-wrongPrice", args[1]);
plugin.message(sender, "setprice-wrongPrice", args[1], region);
return;
}
if(region.isRentRegion()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public void execute(CommandSender sender, String[] args) {
}
if(args.length > 3) {
region.setSchematicProfile(args[3]);
plugin.message(sender, "setrestore-successProfile", region.getName(), valueString, args[3]);
plugin.message(sender, "setrestore-successProfile", valueString, args[3], region);
} else {
plugin.message(sender, "setrestore-success", region.getName(), valueString);
plugin.message(sender, "setrestore-success", valueString, region);
}
region.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,27 @@ public void execute(CommandSender sender, String[] args) {
owner = player.getUniqueId().equals(((BuyRegion)region).getBuyer());
}
if(!player.hasPermission("areashop.setteleport")) {
plugin.message(player, "setteleport-noPermission");
plugin.message(player, "setteleport-noPermission", region);
return;
} else if(!owner && !player.hasPermission("areashop.setteleportall")) {
plugin.message(player, "setteleport-noPermissionOther");
plugin.message(player, "setteleport-noPermissionOther", region);
return;
}

ProtectedRegion wgRegion = region.getRegion();
if(args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("reset") || args[2].equalsIgnoreCase("yes") || args[2].equalsIgnoreCase("true"))) {
region.setTeleport(null);
region.update();
plugin.message(player, "setteleport-reset", region.getName());
plugin.message(player, "setteleport-reset", region);
return;
}
if(!player.hasPermission("areashop.setteleportoutsideregion") && (wgRegion == null || !wgRegion.contains(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()))) {
plugin.message(player, "setteleport-notInside", region.getName());
plugin.message(player, "setteleport-notInside", region);
return;
}
region.setTeleport(player.getLocation());
region.update();
plugin.message(player, "setteleport-success", region.getName());
plugin.message(player, "setteleport-success", region);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public void execute(CommandSender sender, String[] args) {
buy.update();
plugin.message(sender, "stopresell-success", buy);
} else {
plugin.message(sender, "stopresell-noPermissionOther");
plugin.message(sender, "stopresell-noPermissionOther", buy);
}
} else {
plugin.message(sender, "stopresell-noPermission");
plugin.message(sender, "stopresell-noPermission", buy);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void execute(CommandSender sender, String[] args) {
return;
}
if(!rent.isRented()) {
plugin.message(sender, "unrent-notRented");
plugin.message(sender, "unrent-notRented", rent);
return;
}
rent.unRent(true, sender);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public void onSignBreak(BlockBreakEvent event) {
// Remove the sign of the rental region if the player has permission
if(event.getPlayer().hasPermission("areashop.delsign")) {
region.removeSign(block.getLocation());
plugin.message(event.getPlayer(), "delsign-success", region.getName());
plugin.message(event.getPlayer(), "delsign-success", region);
} else { // Cancel the breaking of the sign
event.setCancelled(true);
plugin.message(event.getPlayer(), "delsign-noPermission");
plugin.message(event.getPlayer(), "delsign-noPermission", region);
}
}
}
Expand Down
Loading

0 comments on commit c445a62

Please sign in to comment.