From 1af04abd378cca31d154b7b1a171909d0af6e5aa Mon Sep 17 00:00:00 2001 From: Alastair Date: Sun, 11 Jun 2017 19:14:35 +0100 Subject: [PATCH] Fixed text error --- .../sekwah/advancedportals/AdvancedPortalsCommand.java | 2 +- src/com/sekwah/advancedportals/portals/Portal.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index fb979585..2b6500e8 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -555,7 +555,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { "\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal gui remove " + portalName + "\"}}" + ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal show " + portalName + "\"}}" + ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}" - + ",{\"text\":\" \"},{\"text\":\"\u00A7eActivate\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(same as entering the portal)\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/desti warp " + destination + "\"}}]}", player); + + ",{\"text\":\" \"},{\"text\":\"\u00A7eTeleport\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(If there is one)\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/desti warp " + destination + "\"}}]}", player); sender.sendMessage(""); diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index adc15900..947f3c70 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -15,6 +15,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.HashMap; +import java.util.Random; import java.util.Set; import java.util.logging.Level; @@ -378,6 +379,7 @@ public class Portal { // 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op. if (!(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())) { player.sendMessage(PluginMessages.customPrefix + "\u00A7c You do not have permission to use this portal!"); + failSound(player, portal); throwPlayerBack(player); return false; } @@ -386,6 +388,7 @@ public class Portal { int diff = (int) ((System.currentTimeMillis() - cooldown.get(player)) / 1000); if (diff < cooldelay) { player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + (cooldelay - diff) + ChatColor.RED + " seconds until attempting to teleport again."); + failSound(player, portal); throwPlayerBack(player); return false; } @@ -419,6 +422,7 @@ public class Portal { plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp " + "attempt and either the data is corrupt or portal doesn't exist!"); throwPlayerBack(player); + failSound(player, portal); } } @@ -466,6 +470,12 @@ public class Portal { return warped; } + private static void failSound(Player player, AdvancedPortal portal) { + if(!(portal.trigger == Material.PORTAL && player.getGameMode() == GameMode.CREATIVE)){ + player.playSound(player.getLocation(), Sound.BLOCK_PORTAL_TRAVEL, 0.5f, new Random().nextFloat() * 0.4F + 0.8F); + } + } + public static void rename(String oldName, String newName) { // set it so it gets all data from one and puts it into another place