Skip to content

Commit

Permalink
4.4.0: LOCALES!!! Messages are now more consistent, simple and they c…
Browse files Browse the repository at this point in the history
…an be modified
  • Loading branch information
aleksilassila committed Oct 21, 2020
1 parent 62659a3 commit 1429529
Show file tree
Hide file tree
Showing 21 changed files with 267 additions and 201 deletions.
15 changes: 9 additions & 6 deletions src/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
islandsWorldName: world
wildernessWorldName: wilderness

defaultIslandLimit: 2
groupLimits: # Requires vault to work, all limits can be bypassed with islands.bypass.islandLimit
staff: 5
Expand All @@ -20,10 +23,6 @@ generation:
generationDelayInTicks: 0.3 # 2 Will generate 1 row per 2 ticks, 0.5 will generate 2 rows per 1 tick.
maxVariationsPerBiome: 5 # Max locations generated for each biome, lower the value to speed up server startup.

disableMobsOnIslands: true
tpCooldownTime: 10 # /home and /visit cooldown after damage.
illegalIslandNames: # Blocked island names. Useful if you want to reserve name for "official" island
# - spawn
biomeBlacklist: # These biomes do not get picked up by island generator.
- DEEP_OCEAN # Ocean biomes work poorly with islands.
- DEEP_WARM_OCEAN
Expand All @@ -35,6 +34,10 @@ biomeBlacklist: # These biomes do not get picked up by i
- MOUNTAINS
- GRAVELLY_MOUNTAINS
- MODIFIED_GRAVELLY_MOUNTAINS

disableMobsOnIslands: true
tpCooldownTime: 10 # /home and /visit cooldown after damage.
illegalIslandNames: # Blocked island names. Useful if you want to reserve name for "official" island
# - spawn
wildernessCoordinateMultiplier: 4 # Player's x and z coordinates gets multiplied by this value when they jump to wilderness.
islandsWorldName: world
wildernessWorldName: wilderness
locale: en
5 changes: 5 additions & 0 deletions src/me/aleksilassila/islands/Islands.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import me.aleksilassila.islands.generation.ShapesLoader;
import me.aleksilassila.islands.listeners.IslandsListener;
import me.aleksilassila.islands.utils.ConfirmItem;
import me.aleksilassila.islands.utils.Messages;
import me.aleksilassila.islands.utils.Permissions;
import me.aleksilassila.islands.utils.UpdateChecker;
import net.milkbowl.vault.permission.Permission;
Expand Down Expand Up @@ -110,6 +111,8 @@ public void onEnable() {

new IslandsListener(this);

Messages.getInstance(this);

int pluginId = 8974;
new Metrics(this, pluginId);

Expand Down Expand Up @@ -394,4 +397,6 @@ private void initBiomesCache() {
// - /ContainerTrust etc.
// - Fix giant trees cutting off from top.
// - API ??
// - Go through messages
// - Explain game styles?
}
22 changes: 11 additions & 11 deletions src/me/aleksilassila/islands/commands/IslandCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
plugin.confirmations.remove(player.getUniqueId().toString());

if (!player.hasPermission(Permissions.command.visit)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}

Expand All @@ -53,7 +53,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

if (!canTeleport(player) && !player.hasPermission(Permissions.bypass.home)) {
player.sendMessage(Messages.error.COOLDOWN(teleportCooldown(player)));
player.sendMessage(Messages.tl("error.COOLDOWN", teleportCooldown(player)));
return true;
}

Expand All @@ -62,7 +62,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (islandId != null) {
player.teleport(plugin.layout.getIslandSpawn(islandId));
} else {
player.sendMessage(Messages.error.ISLAND_NOT_FOUND);
player.sendMessage(Messages.tl("error.ISLAND_NOT_FOUND"));
}

return true;
Expand All @@ -88,28 +88,28 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

if (args.length == 1 && args[0].equalsIgnoreCase("list") || label.equalsIgnoreCase("homes")) {
if (!player.hasPermission(Permissions.command.listHomes)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}

List<String> ids = plugin.layout.getIslandIds(player.getUniqueId());

player.sendMessage(Messages.success.HOMES_FOUND(ids.size()));
player.sendMessage(Messages.tl("success.HOMES_FOUND", ids.size()));
for (String islandId : ids) {
String name = plugin.getIslandsConfig().getString(islandId + ".name");
String homeNumber = plugin.getIslandsConfig().getString(islandId + ".home");
player.sendMessage(ChatColor.AQUA + " - " + name + " (" + homeNumber + ")");
player.sendMessage(Messages.tl("success.HOME_ITEM", name, homeNumber));
}

return true;
} else {
if (!player.hasPermission(Permissions.command.home)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}

if (!canTeleport(player) && !player.hasPermission(Permissions.bypass.home)) {
player.sendMessage(Messages.error.COOLDOWN(teleportCooldown(player)));
player.sendMessage(Messages.tl("error.COOLDOWN", teleportCooldown(player)));
return true;
}

Expand All @@ -124,7 +124,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

if (player.getWorld().getName().equals("world_nether") && !player.hasPermission(Permissions.bypass.home)) {
player.sendMessage(Messages.info.IN_OVERWORLD);
player.sendMessage(Messages.tl("info.IN_OVERWORLD"));
return true;
}

Expand All @@ -135,7 +135,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
for (int y = playerLocation.getBlockY(); y < player.getWorld().getHighestBlockYAt(playerLocation); y++) {
playerLocation.setY(y);
if (player.getWorld().getBlockAt(playerLocation).getBlockData().getMaterial().equals(Material.STONE)) {
player.sendMessage(Messages.info.ON_SURFACE);
player.sendMessage(Messages.tl("info.ON_SURFACE"));
return true;
}
}
Expand All @@ -154,7 +154,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (location != null) {
player.teleport(location);
} else {
player.sendMessage(Messages.error.HOME_NOT_FOUND);
player.sendMessage(Messages.tl("error.HOME_NOT_FOUND"));
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
Player player = (Player) sender;

if (!player.hasPermission(Permissions.command.island)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}

Expand All @@ -69,26 +69,26 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
Subcommand target = getSubcommand(args[0]);

if (target == null) {
player.sendMessage(Messages.error.SUBCOMMAND_NOT_FOUND);
player.sendMessage(Messages.tl("error.SUBCOMMAND_NOT_FOUND"));
sendHelp(player);
return true;
}

if (target.getPermission() != null && !player.hasPermission(target.getPermission())) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}

try {
target.onCommand(player, Arrays.copyOfRange(args, 1, args.length), confirmed);
return true;
} catch (Exception e) {
player.sendMessage(Messages.error.ERROR);
player.sendMessage(Messages.tl("error.ERROR"));
return true;
}
}

player.sendMessage(Messages.info.VERSION_INFO(plugin.getDescription().getVersion()));
player.sendMessage(Messages.tl("info.VERSION_INFO", plugin.getDescription().getVersion()));

return true;
}
Expand Down
32 changes: 16 additions & 16 deletions src/me/aleksilassila/islands/commands/TrustCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
plugin.confirmations.remove(player.getUniqueId().toString());

if (!player.hasPermission(Permissions.command.untrust)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}


if (!player.getWorld().equals(plugin.islandsWorld)) {
player.sendMessage(Messages.error.WRONG_WORLD);
player.sendMessage(Messages.tl("error.WRONG_WORLD"));
return true;
}

Expand All @@ -53,25 +53,25 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
String islandId = plugin.layout.getIslandId(player.getLocation().getBlockX(), player.getLocation().getBlockZ());

if (ownerUUID == null || islandId == null) {
player.sendMessage(Messages.error.NOT_ON_ISLAND);
player.sendMessage(Messages.tl("error.NOT_ON_ISLAND"));
return true;
}

if (!ownerUUID.equals(player.getUniqueId().toString()) && !player.hasPermission(Permissions.bypass.untrust)) {
player.sendMessage(Messages.error.NOT_OWNED);
player.sendMessage(Messages.tl("error.NOT_OWNED"));
return true;
}

Player targetPlayer = Bukkit.getPlayer(args[0]);

if (targetPlayer == null) {
player.sendMessage(Messages.error.PLAYER_NOT_FOUND);
player.sendMessage(Messages.tl("error.PLAYER_NOT_FOUND"));
return true;
}

plugin.layout.removeTrusted(islandId, targetPlayer.getUniqueId().toString());

player.sendMessage(Messages.success.UNTRUSTED);
player.sendMessage(Messages.tl("success.UNTRUSTED"));

return true;
}
Expand All @@ -91,7 +91,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
plugin.confirmations.remove(player.getUniqueId().toString());

if (!player.hasPermission(Permissions.command.trust)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}

Expand All @@ -104,25 +104,25 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
String islandId = plugin.layout.getIslandId(player.getLocation().getBlockX(), player.getLocation().getBlockZ());

if (ownerUUID == null || islandId == null) {
player.sendMessage(Messages.error.NOT_ON_ISLAND);
player.sendMessage(Messages.tl("error.NOT_ON_ISLAND"));
return true;
}

if (!ownerUUID.equals(player.getUniqueId().toString()) && !player.hasPermission(Permissions.bypass.trust)) {
player.sendMessage(Messages.error.NOT_OWNED);
player.sendMessage(Messages.tl("error.NOT_OWNED"));
return true;
}

Player targetPlayer = Bukkit.getPlayer(args[0]);

if (targetPlayer == null) {
player.sendMessage(Messages.error.PLAYER_NOT_FOUND);
player.sendMessage(Messages.tl("error.PLAYER_NOT_FOUND"));
return true;
}

plugin.layout.addTrusted(islandId, targetPlayer.getUniqueId().toString());

player.sendMessage(Messages.success.TRUSTED);
player.sendMessage(Messages.tl("success.TRUSTED"));

return true;
}
Expand All @@ -142,30 +142,30 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
plugin.confirmations.remove(player.getUniqueId().toString());

if (!player.hasPermission(Permissions.command.listTrusted)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return true;
}

String ownerUUID = plugin.layout.getBlockOwnerUUID(player.getLocation().getBlockX(), player.getLocation().getBlockZ());
String islandId = plugin.layout.getIslandId(player.getLocation().getBlockX(), player.getLocation().getBlockZ());

if (ownerUUID == null || islandId == null) {
player.sendMessage(Messages.error.NOT_ON_ISLAND);
player.sendMessage(Messages.tl("error.NOT_ON_ISLAND"));
return true;
}

if (!ownerUUID.equals(player.getUniqueId().toString()) && !player.hasPermission(Permissions.bypass.listTrusted)) {
player.sendMessage(Messages.error.NOT_OWNED);
player.sendMessage(Messages.tl("error.NOT_OWNED"));
return true;
}

List<String> trustedList = plugin.layout.getTrusted(islandId);

player.sendMessage(Messages.info.TRUSTED_INFO(trustedList.size()));
player.sendMessage(Messages.tl("info.TRUSTED_INFO", trustedList.size()));
for (String uuid : trustedList) {
Player trustedPlayer = Bukkit.getPlayer(UUID.fromString(uuid));

if (trustedPlayer != null) player.sendMessage(Messages.info.TRUSTED_PLAYER(trustedPlayer.getDisplayName()));
if (trustedPlayer != null) player.sendMessage(Messages.tl("info.TRUSTED_PLAYER", trustedPlayer.getDisplayName()));
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
String permissionRequired = plugin.getCreatePermission(islandSize);

if (!player.hasPermission(permissionRequired)) {
player.sendMessage(Messages.error.NO_PERMISSION);
player.sendMessage(Messages.tl("error.NO_PERMISSION"));
return;
}

if (islandSize < plugin.getSmallestIslandSize() || islandSize + 4 >= layout.islandSpacing) {
player.sendMessage(Messages.error.INVALID_ISLAND_SIZE);
player.sendMessage(Messages.tl("error.INVALID_ISLAND_SIZE"));
return;
}

Expand Down Expand Up @@ -74,19 +74,19 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
}

if (previousIslands >= islandsLimit && !player.hasPermission(Permissions.bypass.create)) {
player.sendMessage(Messages.error.ISLAND_LIMIT);
player.sendMessage(Messages.tl("error.ISLAND_LIMIT"));
return;
}

Biome targetBiome = utils.getTargetBiome(args[0]);

if (targetBiome == null) {
player.sendMessage(Messages.error.NO_BIOME_FOUND);
player.sendMessage(Messages.tl("error.NO_BIOME_FOUND"));
return;
}

if (!availableLocations.containsKey(targetBiome)) {
player.sendMessage(Messages.error.NO_LOCATIONS_FOR_BIOME);
player.sendMessage(Messages.tl("error.NO_LOCATIONS_FOR_BIOME"));
return;
}

Expand All @@ -95,17 +95,17 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
try {
islandId = plugin.createNewIsland(targetBiome, islandSize, player);
} catch (IllegalArgumentException e) {
player.sendMessage(Messages.error.NO_LOCATIONS_FOR_BIOME);
player.sendMessage(Messages.tl("error.NO_LOCATIONS_FOR_BIOME"));

return;
}

if (islandId == null) {
player.sendMessage(Messages.error.ONGOING_QUEUE_EVENT);
player.sendMessage(Messages.tl("error.ONGOING_QUEUE_EVENT"));
return;
}

player.sendTitle(Messages.success.ISLAND_GEN_TITLE, Messages.success.ISLAND_GEN_SUBTITLE, 10, 20 * 7, 10);
player.sendTitle(Messages.tl("success.ISLAND_GEN_TITLE"), Messages.tl("success.ISLAND_GEN_SUBTITLE"), 10, 20 * 7, 10);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ public DeleteSubcommand(Islands plugin) {
@Override
public void onCommand(Player player, String[] args, boolean confirmed) {
if (!player.getWorld().equals(plugin.islandsWorld)) {
player.sendMessage(Messages.error.WRONG_WORLD);
player.sendMessage(Messages.tl("error.WRONG_WORLD"));
return;
}

String islandId = layout.getIslandId(player.getLocation().getBlockX(), player.getLocation().getBlockZ());

if (islandId == null) {
player.sendMessage(Messages.error.NOT_ON_ISLAND);
player.sendMessage(Messages.tl("error.NOT_ON_ISLAND"));
return;
}

if (!layout.getUUID(islandId).equals(player.getUniqueId().toString())
&& !player.hasPermission(Permissions.bypass.delete)) {
player.sendMessage(Messages.error.UNAUTHORIZED);
player.sendMessage(Messages.tl("error.UNAUTHORIZED"));
return;
}

if (!confirmed) {
player.sendMessage(Messages.info.CONFIRM);
player.sendMessage(Messages.tl("info.CONFIRM"));
return;
}

layout.deleteIsland(islandId);
player.sendMessage(Messages.success.DELETED);
player.sendMessage(Messages.tl("success.DELETED"));
}

@Override
Expand Down
Loading

0 comments on commit 1429529

Please sign in to comment.