diff --git a/src/main/java/serverutils/ServerUtilitiesPermissions.java b/src/main/java/serverutils/ServerUtilitiesPermissions.java index d26debad..1ff6ad6a 100644 --- a/src/main/java/serverutils/ServerUtilitiesPermissions.java +++ b/src/main/java/serverutils/ServerUtilitiesPermissions.java @@ -50,6 +50,7 @@ public class ServerUtilitiesPermissions { public static final String HOMES_TELEPORT_OTHER = "serverutilities.other_player.homes.teleport"; // Warps // + public static final String WARPS_CROSS_DIM = "serverutilities.warps.cross_dim"; public static final String WARPS_COOLDOWN = "serverutilities.warps.cooldown"; public static final String WARPS_WARMUP = "serverutilities.warps.warmup"; @@ -229,6 +230,10 @@ public static void registerPermissions() { DefaultPermissionLevel.ALL, "Allow player to see other teams claims on JourneyMap overlay"); PermissionAPI.registerNode(RANK_EDIT, DefaultPermissionLevel.OP, "Allow player to edit ranks via Admin Panel"); + PermissionAPI.registerNode( + WARPS_CROSS_DIM, + DefaultPermissionLevel.ALL, + "Can use /warp to teleport to/from another dimension"); for (Block block : GameData.getBlockRegistry().typeSafeIterable()) { String name = formatId(block); diff --git a/src/main/java/serverutils/command/tp/CmdWarp.java b/src/main/java/serverutils/command/tp/CmdWarp.java index 3cb279ae..8371a052 100644 --- a/src/main/java/serverutils/command/tp/CmdWarp.java +++ b/src/main/java/serverutils/command/tp/CmdWarp.java @@ -13,12 +13,14 @@ import cpw.mods.fml.common.eventhandler.Event; import serverutils.ServerUtilities; +import serverutils.ServerUtilitiesPermissions; import serverutils.data.ServerUtilitiesPlayerData; import serverutils.data.ServerUtilitiesUniverseData; import serverutils.lib.command.CmdBase; import serverutils.lib.command.CommandUtils; import serverutils.lib.math.BlockDimPos; import serverutils.lib.util.StringJoiner; +import serverutils.lib.util.permission.PermissionAPI; import serverutils.lib.util.text_components.Notification; import serverutils.ranks.Rank; import serverutils.ranks.Ranks; @@ -69,6 +71,11 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE ServerUtilitiesPlayerData data = ServerUtilitiesPlayerData.get(CommandUtils.getForgePlayer(player)); data.checkTeleportCooldown(sender, ServerUtilitiesPlayerData.Timer.WARP); + if (player.dimension != p.dim + && !PermissionAPI.hasPermission(player, ServerUtilitiesPermissions.WARPS_CROSS_DIM)) { + throw ServerUtilities.error(sender, "serverutilities.lang.warps.cross_dim"); + } + IChatComponent component = ServerUtilities.lang(sender, "serverutilities.lang.warps.tp", args[0]); Notification notification = Notification.of(TELEPORT, component); Task task = new NotifyTask(-1, player, notification); diff --git a/src/main/java/serverutils/data/BackwardsCompat.java b/src/main/java/serverutils/data/BackwardsCompat.java index c590055c..138e0d70 100644 --- a/src/main/java/serverutils/data/BackwardsCompat.java +++ b/src/main/java/serverutils/data/BackwardsCompat.java @@ -195,6 +195,9 @@ public static void loadRanks(Rank player, Rank admin) { if (permissionsPlayer.get("cross_dim_homes").getAsBoolean()) { player.setPermission(ServerUtilitiesPermissions.HOMES_CROSS_DIM, true); } + if (permissionsPlayer.get("cross_dim_warp").getAsBoolean()) { + player.setPermission(ServerUtilitiesPermissions.WARPS_CROSS_DIM, true); + } JsonObject permissionsAdmin = LATCONFIG.get("permissions_admin").getAsJsonObject(); admin.setPermission(ServerUtilitiesPermissions.HOMES_MAX, permissionsAdmin.get("max_homes").getAsInt()); @@ -207,6 +210,9 @@ public static void loadRanks(Rank player, Rank admin) { if (permissionsAdmin.get("cross_dim_homes").getAsBoolean()) { admin.setPermission(ServerUtilitiesPermissions.HOMES_CROSS_DIM, true); } + if (permissionsAdmin.get("cross_dim_warp").getAsBoolean()) { + admin.setPermission(ServerUtilitiesPermissions.WARPS_CROSS_DIM, true); + } } public static Map toMapWithType(NBTTagCompound tag) { diff --git a/src/main/java/serverutils/ranks/Ranks.java b/src/main/java/serverutils/ranks/Ranks.java index fa746b5e..b0feee55 100644 --- a/src/main/java/serverutils/ranks/Ranks.java +++ b/src/main/java/serverutils/ranks/Ranks.java @@ -118,6 +118,7 @@ public boolean reload() { vRank.setPermission(ServerUtilitiesPermissions.HOMES_WARMUP, "0s"); vRank.setPermission(ServerUtilitiesPermissions.HOMES_COOLDOWN, "1s"); vRank.setPermission(ServerUtilitiesPermissions.HOMES_CROSS_DIM, true); + vRank.setPermission(ServerUtilitiesPermissions.WARPS_CROSS_DIM, true); vRank.setPermission("example.other_permission", true); vRank.setPermission("example.permission_with_value", 15); @@ -133,6 +134,7 @@ public boolean reload() { aRank.setPermission(ServerUtilitiesPermissions.HOMES_WARMUP, "0s"); aRank.setPermission(ServerUtilitiesPermissions.HOMES_COOLDOWN, "0s"); aRank.setPermission(ServerUtilitiesPermissions.HOMES_CROSS_DIM, true); + aRank.setPermission(ServerUtilitiesPermissions.WARPS_CROSS_DIM, true); aRank.setPermission("example.permission_with_value", 100); if (universe.shouldLoadLatmod()) { diff --git a/src/main/resources/assets/serverutilities/lang/en_US.lang b/src/main/resources/assets/serverutilities/lang/en_US.lang index 5ba32e63..bddb1326 100644 --- a/src/main/resources/assets/serverutilities/lang/en_US.lang +++ b/src/main/resources/assets/serverutilities/lang/en_US.lang @@ -468,6 +468,7 @@ serverutilities.lang.warps.cooldown=You can only use warp in %s! serverutilities.lang.warps.tp=Teleported to '%s'! serverutilities.lang.warps.no_dp=You can only go back once! serverutilities.lang.warps.no_pos_found=No position to go back to! +serverutilities.lang.warps.cross_dim=You can't teleport to another dimension! # Homes serverutilities.lang.homes.set=Home '%s' set! diff --git a/src/main/resources/assets/serverutilities/lang/ja_JP.lang b/src/main/resources/assets/serverutilities/lang/ja_JP.lang index 14603ec9..83040fe0 100644 --- a/src/main/resources/assets/serverutilities/lang/ja_JP.lang +++ b/src/main/resources/assets/serverutilities/lang/ja_JP.lang @@ -214,6 +214,7 @@ serverutilities.lang.warps.not_set=「%s」は不明なワープ先です! serverutilities.lang.warps.cooldown=%sでワープ可能になります! serverutilities.lang.warps.tp=「%s」にテレポートしました! serverutilities.lang.warps.no_dp=戻ることができるのは一度だけです! +serverutilities.lang.warps.cross_dim=別のディメンションへはテレポートできません! # Homes serverutilities.lang.homes.set=ホーム「%s」を設定しました! diff --git a/src/main/resources/assets/serverutilities/lang/ru_RU.lang b/src/main/resources/assets/serverutilities/lang/ru_RU.lang index 51cecd07..9ee8cd43 100644 --- a/src/main/resources/assets/serverutilities/lang/ru_RU.lang +++ b/src/main/resources/assets/serverutilities/lang/ru_RU.lang @@ -206,8 +206,10 @@ serverutilities.lang.warps.set=Варп '%s' установлен! serverutilities.lang.warps.del=Варп '%s' удален! serverutilities.lang.warps.not_set=Неизвестный варп: '%s'! serverutilities.lang.warps.cooldown=Вы можете использовать варп только в %s! -вftbutilities.lang.warps.tp=Телепортирован в '%s'! +serverutilities.lang.warps.tp=Телепортирован в '%s'! serverutilities.lang.warps.no_dp=Вы можете вернуться только один раз! +serverutilities.lang.warps.cross_dim=Вы не можете телепортироваться в другое измерение! + # Homes serverutilities.lang.homes.set=Дом '%s' установлен! diff --git a/src/main/resources/assets/serverutilities/lang/zh_CN.lang b/src/main/resources/assets/serverutilities/lang/zh_CN.lang index e3aa7cf0..3b759bf0 100644 --- a/src/main/resources/assets/serverutilities/lang/zh_CN.lang +++ b/src/main/resources/assets/serverutilities/lang/zh_CN.lang @@ -209,6 +209,7 @@ serverutilities.lang.warps.not_set=未知的传送点:“%s”! serverutilities.lang.warps.cooldown=使用传送点传送还需 %s! serverutilities.lang.warps.tp=传送至 “%s”! serverutilities.lang.warps.no_dp=你只能使用一次 /back! +serverutilities.lang.warps.cross_dim=你不能传送至其它维度! # Homes serverutilities.lang.homes.set=家“%s”已设置!