updated npc info

This commit is contained in:
Chiss 2014-10-31 18:17:12 +11:00
parent bf6e788f36
commit b5ef46007f
3 changed files with 31 additions and 21 deletions

View File

@ -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];
}
}
}

View File

@ -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<UUID, Npc> _npcMap = new HashMap<>();
private final Set<UUID> _npcDeletingPlayers = new HashSet<>();
private Connection _connection;
private final Map<UUID, Long> _nearNpcMessageTimes = new HashMap<>();
private final Map<UUID, Long> _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()

View File

@ -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());