From b5ef46007f111d789dd3e17bf8c371705b4ad762 Mon Sep 17 00:00:00 2001 From: Chiss Date: Fri, 31 Oct 2014 18:17:12 +1100 Subject: [PATCH] updated npc info --- .../src/mineplex/core/npc/Npc.java | 23 +++++++++++++--- .../src/mineplex/core/npc/NpcManager.java | 27 ++++++++----------- .../mineplex/hub/modules/ParkourManager.java | 2 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java index d5cd8fa07..fb7b2e41c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java @@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; import org.bukkit.entity.LivingEntity; import net.minecraft.server.v1_7_R4.EntityCreature; +import mineplex.core.common.util.C; import mineplex.database.tables.records.NpcsRecord; public class Npc @@ -32,13 +33,27 @@ public class Npc _info = null; else { - _info = getDatabaseRecord().getInfo().split("\\r?\\n"); + String[] info = getDatabaseRecord().getInfo().split("\\r?\\n"); - for (int i = 0; i < _info.length; i++) + for (int i = 0; i < info.length; i++) { for (ChatColor color : ChatColor.values()) - _info[i] = _info[i].replace("(" + color.name().toLowerCase() + ")", color.toString()); - _info[i] = ChatColor.translateAlternateColorCodes('&', _info[i]); + info[i] = info[i].replace("(" + color.name().toLowerCase() + ")", color.toString()); + info[i] = ChatColor.translateAlternateColorCodes('&', info[i]); + } + + _info = new String[info.length + 2]; + + for (int i=0 ; i<_info.length ; i++) + { + if (i == 0 || i == _info.length-1) + { + _info[i] = C.cGold + C.Strike + "============================================="; + } + else + { + _info[i] = info[i-1]; + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 1aed3b3eb..e818920a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -16,6 +16,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -56,6 +57,7 @@ import mineplex.core.database.DBPool; import mineplex.core.npc.command.NpcCommand; import mineplex.core.npc.event.NpcDamageByEntityEvent; import mineplex.core.npc.event.NpcInteractEntityEvent; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.database.Tables; @@ -103,8 +105,6 @@ public class NpcManager extends MiniPlugin final Map _npcMap = new HashMap<>(); private final Set _npcDeletingPlayers = new HashSet<>(); private Connection _connection; - private final Map _nearNpcMessageTimes = new HashMap<>(); - private final Map _clickNpcMessageTimes = new HashMap<>(); protected Connection getConnection() { @@ -644,12 +644,12 @@ public class NpcManager extends MiniPlugin if (npc.getEntity().getLocation().distanceSquared(player.getLocation()) > npc.getInfoRadiusSquared()) continue; - Long last = _nearNpcMessageTimes.get(player.getUniqueId()); - if (last != null && last + npc.getDatabaseRecord().getInfoDelay() > now) + if (!Recharge.Instance.use(player, npc.getEntity().getCustomName() + " Info", npc.getDatabaseRecord().getInfoDelay(), false, false)) continue; player.sendMessage(npc.getInfo()); - _nearNpcMessageTimes.put(player.getUniqueId(), now); + + player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 2f); } } } @@ -664,14 +664,12 @@ public class NpcManager extends MiniPlugin if (npc.getInfo() == null) return; - long now = System.currentTimeMillis(); - - Long last = _clickNpcMessageTimes.get(event.getPlayer().getUniqueId()); - if (last != null && last + npc.getDatabaseRecord().getInfoDelay() > now) + if (!Recharge.Instance.use(event.getPlayer(), npc.getEntity().getCustomName() + " Info Click", 2000, false, false)) return; event.getPlayer().sendMessage(npc.getInfo()); - _clickNpcMessageTimes.put(event.getPlayer().getUniqueId(), now); + + event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f); } @EventHandler @@ -689,15 +687,12 @@ public class NpcManager extends MiniPlugin if (npc.getInfo() == null) return; - long now = System.currentTimeMillis(); - - Long last = _clickNpcMessageTimes.get(player.getUniqueId()); - if (last != null && last + npc.getDatabaseRecord().getInfoDelay() > now) + if (!Recharge.Instance.use(player, npc.getEntity().getCustomName() + " Info Click", 2000, false, false)) return; player.sendMessage(npc.getInfo()); - - _clickNpcMessageTimes.put(player.getUniqueId(), now); + + player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 2f); } public String getServerName() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index 4dd7128f3..211472a06 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -65,7 +65,7 @@ public class ParkourManager extends MiniPlugin //Modules protected DonationManager _donationManager; protected TaskManager _taskManager; - + public ParkourManager(HubManager manager, DonationManager donation, TaskManager task) { super("Parkour", manager.GetPlugin());