Skip to content

Commit

Permalink
Updates locales. Fixes nether and end warping.
Browse files Browse the repository at this point in the history
Fixes issue with warp level checking wrong environment.

Adds warning when warping to PVP enabled islands.

#21
  • Loading branch information
tastybento committed Mar 4, 2019
1 parent 140e057 commit 79b568f
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 101 deletions.
7 changes: 4 additions & 3 deletions src/main/java/world/bentobox/warps/WarpSignsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;

import world.bentobox.warps.event.WarpRemoveEvent;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
import world.bentobox.warps.event.WarpRemoveEvent;

/**
* Handles warping. Players can add one sign
Expand Down Expand Up @@ -99,8 +100,8 @@ public void onSignWarpCreate(SignChangeEvent e) {
user.sendMessage("general.errors.you-need", "[permission]", addon.getPermPrefix(b.getWorld()) + ".island.addwarp");
return;
}
// Get level is level addon is available
Long level = addon.getLevel(b.getWorld(), user.getUniqueId());
// Get level if level addon is available
Long level = addon.getLevel(Util.getWorld(b.getWorld()), user.getUniqueId());
if (level != null && level < addon.getSettings().getWarpLevelRestriction()) {
user.sendMessage("warps.error.not-enough-level");
user.sendMessage("warps.error.your-level-is",
Expand Down
45 changes: 26 additions & 19 deletions src/main/java/world/bentobox/warps/WarpSignsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;

import world.bentobox.bentobox.lists.Flags;
import world.bentobox.warps.objects.WarpsData;
import world.bentobox.warps.event.WarpInitiateEvent;
import world.bentobox.warps.event.WarpListEvent;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.Database;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.util.Util;
import world.bentobox.warps.event.WarpInitiateEvent;
import world.bentobox.warps.event.WarpListEvent;
import world.bentobox.warps.objects.WarpsData;

/**
* Handles warping. Players can add one sign
Expand All @@ -56,8 +56,7 @@ public class WarpSignsManager {
* @return map of warps
*/
public Map<UUID, Location> getWarpMap(World world) {
worldsWarpList.putIfAbsent(world, new HashMap<>());
return worldsWarpList.get(world);
return worldsWarpList.computeIfAbsent(Util.getWorld(world), k -> new HashMap<>());
}

/**
Expand Down Expand Up @@ -282,7 +281,7 @@ private void warpPlayer(User user, Location inFront, UUID signOwner, BlockFace d
inFront.getBlockZ() + 0.5D, yaw, 30F);
user.teleport(actualWarp);
if (pvp) {
user.sendRawMessage(user.getTranslation("protection.flags.PVP_OVERWORLD.active"));
user.sendMessage("protection.flags.PVP_OVERWORLD.active");
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F);
} else {
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
Expand Down Expand Up @@ -356,23 +355,31 @@ public void warpPlayer(World world, User user, UUID owner) {
}

if (this.plugin.getIWM().inWorld(user.getWorld()) &&
Flags.PREVENT_TELEPORT_WHEN_FALLING.isSetForWorld(user.getWorld()) &&
user.getPlayer().getFallDistance() > 0) {
Flags.PREVENT_TELEPORT_WHEN_FALLING.isSetForWorld(user.getWorld()) &&
user.getPlayer().getFallDistance() > 0) {
// We're sending the "hint" to the player to tell them they cannot teleport while falling.
user.sendMessage(Flags.PREVENT_TELEPORT_WHEN_FALLING.getHintReference());
return;
}

// Find out if island is locked
// TODO: Fire event

Island island = addon.getPlugin().getIslands().getIsland(world, owner);
boolean pvp = false;
if (island != null) {
//if ((warpSpot.getWorld().equals(IslandWorld.getIslandWorld()) && island.getFlag(SettingsFlag.PVP_OVERWORLD))
// || (warpSpot.getWorld().equals(IslandWorld.getNetherWorld()) && island.getFlag(SettingsFlag.PVP_NETHER))) {
// pvp = true;
//}
// Check for PVP
switch (warpSpot.getWorld().getEnvironment()) {
case NETHER:
pvp = island.isAllowed(Flags.PVP_NETHER);
break;
case NORMAL:
pvp = island.isAllowed(Flags.PVP_OVERWORLD);
break;
case THE_END:
pvp = island.isAllowed(Flags.PVP_END);
break;
default:
break;

}
}
// Find out which direction the warp is facing
Block b = warpSpot.getBlock();
Expand All @@ -397,7 +404,7 @@ public void warpPlayer(World world, User user, UUID owner) {
return;
}
if (!(plugin.getIslands().isSafeLocation(warpSpot))) {
user.sendMessage("warps.error.NotSafe");
user.sendMessage("warps.error.not-safe");
// WALL_SIGN's will always be unsafe if the place in front is obscured.
if (b.getType().equals(Material.SIGN)) {
addon.getLogger().warning(
Expand All @@ -408,13 +415,13 @@ public void warpPlayer(World world, User user, UUID owner) {
} else {
final Location actualWarp = new Location(warpSpot.getWorld(), warpSpot.getBlockX() + 0.5D, warpSpot.getBlockY(),
warpSpot.getBlockZ() + 0.5D);
user.teleport(actualWarp);
if (pvp) {
//user.sendLegacyMessage(user.getTranslation("igs." + SettingsFlag.PVP_OVERWORLD) + " " + user.getTranslation("igs.Allowed"));
user.sendMessage("protection.flags.PVP_OVERWORLD.active");
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F);
} else {
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
}
user.teleport(actualWarp);
return;
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/world/bentobox/warps/commands/WarpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import java.util.Set;
import java.util.UUID;

import world.bentobox.warps.Warp;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.warps.Warp;

/**
* The /is warp <name> command
Expand All @@ -33,18 +33,6 @@ public void setup() {
this.setDescription("warp.help.description");
}

@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
List<String> options = new ArrayList<>();
final Set<UUID> warpList = addon.getWarpSignsManager().listWarps(getWorld());

for (UUID warp : warpList) {
options.add(addon.getPlugin().getPlayers().getName(warp));
}

return Optional.of(options);
}

@Override
public boolean execute(User user, String label, List<String> args) {
if (args.size() == 1) {
Expand All @@ -71,5 +59,17 @@ public boolean execute(User user, String label, List<String> args) {
return false;
}

@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
List<String> options = new ArrayList<>();
final Set<UUID> warpList = addon.getWarpSignsManager().listWarps(getWorld());

for (UUID warp : warpList) {
options.add(addon.getPlugin().getPlayers().getName(warp));
}

return Optional.of(options);
}


}
39 changes: 20 additions & 19 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@
# the one at http://yaml-online-parser.appspot.com #
###########################################################################################

warps:
warp:
help:
description: "warp to the player's warp sign"
parameters: <name>
warps:
deactivate: "&cOld warp sign deactivated!"
success: "&ASuccess!"
sign-removed: "&CWarp sign removed!"
title: "Warp Signs"
player-warped: "&2[name] warped to your warp sign!"
previous: "&6Previous page"
next: "&6Next page"
warpToPlayersSign: "&6Warping to [player]'s sign"
# The [text] is replaced with the welcome line text from config.yml
warpTip: "&6Place a warp sign with [text] on the top"
error:
error:
does-not-exist: "&cOh snap! That warp no longer exists!"
duplicate: "&CDuplicate sign placed"
no-permission: "&CYou do not have permission to do that!"
no-remove: "&CYou cannot remove that sign!"
no-warps-yet: "&CThere are no warps available yet"
not-enough-level: "&CYour island level is not high enough!"
no-permission: "&CYou do not have permission to do that!"
not-on-island: "&CYou must be on your island to do that!"
duplicate: "&CDuplicate sign placed"
no-warps-yet: "&CThere are no warps available yet"
not-safe: "&cThat warp is not safe!"
your-level-is: "&cYou island level is only [level] and must be higher than [required]"
help:
help:
description: "open the warps panel"
warp:
help:
parameters: "<name>"
description: "warp to the player's warp sign"
next: "&6Next page"
player-warped: "&2[name] warped to your warp sign!"
previous: "&6Previous page"
sign-removed: "&CWarp sign removed!"
success: "&ASuccess!"
title: "Warp Signs"
warpTip: "&6Place a warp sign with [text] on the top"
warpToPlayersSign: "&6Warping to [player]'s sign"


38 changes: 19 additions & 19 deletions src/main/resources/locales/fr-FR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
# the one at http://yaml-online-parser.appspot.com #
###########################################################################################

warps:
warp:
help:
description: "te téléporte au Warp d'un autre joueur"
parameters: <pseudo>
warps:
deactivate: "&cAncien panneau de Warp désactivé !"
success: "&aSuccès !"
sign-removed: "&cPanneau de Warp supprimé !"
title: "Panneau Warp"
player-warped: "&2[name] s'est téléporté sur votre île !"
previous: "&6Page précédente"
next: "&6Page suivante"
warpToPlayersSign: "&6Téléportation sur l'île de [player]..."
# The [text] is replaced with the welcome line text from config.yml
warpTip: "&6Placez un panneau et écrivez [text] sur la première ligne."
error:
error:
does-not-exist: "&cCe Warp n'existe plus !"
duplicate: "&cPanneau dupliqué placé."
no-permission: "&cVous n'avez pas la permission pour faire cela !"
no-remove: "&cVous ne pouvez pas supprimer ce panneau !"
no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur."
not-enough-level: "&cVotre niveau d'île n'est pas assez élevé pour faire cela !"
no-permission: "&cVous n'avez pas la permission pour faire cela !"
not-on-island: "&cVous devez être sur votre île pour faire cela !"
duplicate: "&cPanneau dupliqué placé."
no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur."
not-safe: "&cCe Warp n'est pas sûr!"
your-level-is: "&cVotre île est seulement niveau [level] et doit être niveau [required]."
help:
help:
description: "Ouvre le menu des Warps"
warp:
help:
parameters: "<pseudo>"
description: "te téléporte au Warp d'un autre joueur"
next: "&6Page suivante"
player-warped: "&2[name] s'est téléporté sur votre île !"
previous: "&6Page précédente"
sign-removed: "&cPanneau de Warp supprimé !"
success: "&aSuccès !"
title: "Panneau Warp"
warpTip: "&6Placez un panneau et écrivez [text] sur la première ligne."
warpToPlayersSign: "&6Téléportation sur l'île de [player]..."
33 changes: 33 additions & 0 deletions src/main/resources/locales/ja-JP.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
###########################################################################################
# This is a YML file. Be careful when editing. Check your edits in a YAML checker like #
# the one at http://yaml-online-parser.appspot.com #
###########################################################################################

warp:
help:
description: "プレイヤーのワープサインにワープする"
parameters: <名>
warps:
deactivate: "&c前のワープサインが無効になりました!"
error:
does-not-exist: "&cそのワープはもう存在しません!"
duplicate: "&C重複サインを配置"
no-permission: "&C許可がありません!"
no-remove: "&Cワープサインは外せません!"
no-warps-yet: "&C利用可能なワープはまだありません"
not-enough-level: "&C島のレベルは十分に高くありません!"
not-on-island: "&Cあなたの島にいなければなりません!"
not-safe: "&cワープは安全ではありません。!"
your-level-is: "&c島レベルはわずか[level]で、[required]より高くなければなりません"
help:
description: "ワープパネルを開く"
next: "&6次のページ"
player-warped: "&2[name]はあなたのワープサインに反った!"
previous: "&6前のページ"
sign-removed: "&Cワープサインを削除!"
success: "&A完了!"
title: "ワープサイン"
warpTip: "&6最初の行に[text]と一緒にワープサインを置きます"
warpToPlayersSign: "&6[player]のサインに反っている"


40 changes: 22 additions & 18 deletions src/main/resources/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@
# 请在 http://yaml-online-parser.appspot.com 等 YAML 检查器中检查您的编辑. #
###########################################################################################

warp:
help:
description: 传送到该玩家的传送木牌处
parameters: <玩家名称>
warps:
removed: "&C传送木牌已移除"
success: "&A成功!"
sign-removed: "&C传送木牌已移除!"
title: "传送木牌"
previous: "&6上一页"
next: "&6下一页"
warpToPlayersSign: "&6正传送到 [player] 的传送木牌"
warpTip: "&6放置一个第一行是 [text] 的木牌以创建传送木牌"
error:
deactivate: "&c禁用的旧转移标志!"
error:
does-not-exist: "&c转移不再存在!"
duplicate: "&C木牌重复"
no-permission: "&C权限不足!"
no-remove: "&C无权移除传送木牌!"
no-warps-yet: "&C暂无可用传送木牌"
not-enough-level: "&C岛屿等级不够高!"
no-permission: "&C权限不足!"
not-on-island: "&C操作必须在空岛上进行!"
duplicate: "&C木牌重复"
no-warps-yet: "&C暂无可用传送木牌"
not-safe: "&c转移不安全!"
your-level-is: "&c岛屿当前等级 [level], 需要等级 [required]"
help:
description: "打开传送面板"
warp:
help:
parameters: "<玩家名称>"
description: "传送到该玩家的传送木牌处"
help:
description: 打开传送面板
next: "&6下一页"
player-warped: "&2[name]转移到你的标志!"
previous: "&6上一页"
sign-removed: "&C传送木牌已移除!"
success: "&A成功!"
title: 传送木牌
warpTip: "&6放置一个第一行是 [text] 的木牌以创建传送木牌"
warpToPlayersSign: "&6正传送到 [player] 的传送木牌"


0 comments on commit 79b568f

Please sign in to comment.