updated npc info
This commit is contained in:
parent
bf6e788f36
commit
b5ef46007f
@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import net.minecraft.server.v1_7_R4.EntityCreature;
|
import net.minecraft.server.v1_7_R4.EntityCreature;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.database.tables.records.NpcsRecord;
|
import mineplex.database.tables.records.NpcsRecord;
|
||||||
|
|
||||||
public class Npc
|
public class Npc
|
||||||
@ -32,13 +33,27 @@ public class Npc
|
|||||||
_info = null;
|
_info = null;
|
||||||
else
|
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())
|
for (ChatColor color : ChatColor.values())
|
||||||
_info[i] = _info[i].replace("(" + color.name().toLowerCase() + ")", color.toString());
|
info[i] = info[i].replace("(" + color.name().toLowerCase() + ")", color.toString());
|
||||||
_info[i] = ChatColor.translateAlternateColorCodes('&', _info[i]);
|
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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
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.command.NpcCommand;
|
||||||
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
||||||
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.database.Tables;
|
import mineplex.database.Tables;
|
||||||
@ -103,8 +105,6 @@ public class NpcManager extends MiniPlugin
|
|||||||
final Map<UUID, Npc> _npcMap = new HashMap<>();
|
final Map<UUID, Npc> _npcMap = new HashMap<>();
|
||||||
private final Set<UUID> _npcDeletingPlayers = new HashSet<>();
|
private final Set<UUID> _npcDeletingPlayers = new HashSet<>();
|
||||||
private Connection _connection;
|
private Connection _connection;
|
||||||
private final Map<UUID, Long> _nearNpcMessageTimes = new HashMap<>();
|
|
||||||
private final Map<UUID, Long> _clickNpcMessageTimes = new HashMap<>();
|
|
||||||
|
|
||||||
protected Connection getConnection()
|
protected Connection getConnection()
|
||||||
{
|
{
|
||||||
@ -644,12 +644,12 @@ public class NpcManager extends MiniPlugin
|
|||||||
if (npc.getEntity().getLocation().distanceSquared(player.getLocation()) > npc.getInfoRadiusSquared())
|
if (npc.getEntity().getLocation().distanceSquared(player.getLocation()) > npc.getInfoRadiusSquared())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Long last = _nearNpcMessageTimes.get(player.getUniqueId());
|
if (!Recharge.Instance.use(player, npc.getEntity().getCustomName() + " Info", npc.getDatabaseRecord().getInfoDelay(), false, false))
|
||||||
if (last != null && last + npc.getDatabaseRecord().getInfoDelay() > now)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
player.sendMessage(npc.getInfo());
|
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)
|
if (npc.getInfo() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
if (!Recharge.Instance.use(event.getPlayer(), npc.getEntity().getCustomName() + " Info Click", 2000, false, false))
|
||||||
|
|
||||||
Long last = _clickNpcMessageTimes.get(event.getPlayer().getUniqueId());
|
|
||||||
if (last != null && last + npc.getDatabaseRecord().getInfoDelay() > now)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.getPlayer().sendMessage(npc.getInfo());
|
event.getPlayer().sendMessage(npc.getInfo());
|
||||||
_clickNpcMessageTimes.put(event.getPlayer().getUniqueId(), now);
|
|
||||||
|
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -689,15 +687,12 @@ public class NpcManager extends MiniPlugin
|
|||||||
if (npc.getInfo() == null)
|
if (npc.getInfo() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
if (!Recharge.Instance.use(player, npc.getEntity().getCustomName() + " Info Click", 2000, false, false))
|
||||||
|
|
||||||
Long last = _clickNpcMessageTimes.get(player.getUniqueId());
|
|
||||||
if (last != null && last + npc.getDatabaseRecord().getInfoDelay() > now)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.sendMessage(npc.getInfo());
|
player.sendMessage(npc.getInfo());
|
||||||
|
|
||||||
_clickNpcMessageTimes.put(player.getUniqueId(), now);
|
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerName()
|
public String getServerName()
|
||||||
|
Loading…
Reference in New Issue
Block a user