Improve NPC visuals
This commit is contained in:
parent
b6a1a3a054
commit
0c6fcba21f
@ -2,6 +2,8 @@ package mineplex.core.quests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.hologram.Hologram;
|
||||
|
||||
/**
|
||||
* QuestClientData
|
||||
*
|
||||
@ -11,6 +13,8 @@ public class QuestClientData
|
||||
{
|
||||
private ArrayList<Quest> _quests = new ArrayList<>();
|
||||
|
||||
private Hologram _hologram;
|
||||
|
||||
public void addQuest(Quest quest)
|
||||
{
|
||||
_quests.add(quest);
|
||||
@ -77,4 +81,14 @@ public class QuestClientData
|
||||
{
|
||||
return _quests;
|
||||
}
|
||||
|
||||
public Hologram getHologram()
|
||||
{
|
||||
return _hologram;
|
||||
}
|
||||
|
||||
public void setHologram(Hologram hologram)
|
||||
{
|
||||
_hologram = hologram;
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ import java.util.function.Consumer;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -24,9 +24,12 @@ import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.google.GoogleSheetsManager;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
@ -40,6 +43,8 @@ import mineplex.core.quests.command.OpenGuiCommand;
|
||||
import mineplex.core.quests.repository.QuestRepository;
|
||||
import mineplex.core.quests.shop.QuestShop;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.quest.client.RedisQuestSupplier;
|
||||
import mineplex.quest.common.QuestSupplier;
|
||||
import mineplex.serverdata.redis.messaging.PubSubJedisClient;
|
||||
@ -70,8 +75,8 @@ public class QuestManager extends MiniClientPlugin<QuestClientData>
|
||||
|
||||
private Npc _questNPC;
|
||||
private boolean _enableNPC;
|
||||
|
||||
private Hologram _hologram;
|
||||
private HologramManager _hologramManager;
|
||||
private boolean _visualTick;
|
||||
|
||||
public QuestManager(HologramManager hologramManager, InventoryManager inventoryManager, DonationManager donationManager)
|
||||
{
|
||||
@ -83,27 +88,94 @@ public class QuestManager extends MiniClientPlugin<QuestClientData>
|
||||
_availableQuests = new ArrayList<>();
|
||||
_donationManager = donationManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_hologramManager = hologramManager;
|
||||
|
||||
setupQuests();
|
||||
|
||||
_questNPC = require(NpcManager.class).getNpcByName("Knight of GWEN");
|
||||
_questNPC = require(NpcManager.class).getNpcByName("Mineplex Missions");
|
||||
if (_questNPC == null)
|
||||
{
|
||||
_enableNPC = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Location loc = _questNPC.getEntity().getLocation();
|
||||
_hologram = new Hologram(hologramManager, loc.clone().add(0, 2.8, 0), ChatColor.AQUA + QUEST_NAME + "s");
|
||||
_hologram.start();
|
||||
Slime slime = (Slime) _questNPC.getEntity();
|
||||
slime.setSize(3);
|
||||
_enableNPC = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
@EventHandler
|
||||
public void updateCreeper(UpdateEvent event)
|
||||
{
|
||||
_hologram.stop();
|
||||
if (event.getType() != UpdateType.FASTER || !_enableNPC)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
String prefix = _visualTick ? C.cAqua : C.cDAqua;
|
||||
updateSlimeVisual(player, prefix);
|
||||
}
|
||||
|
||||
_visualTick = !_visualTick;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void updateSlimeVisual(Player player , String rewardPrefix)
|
||||
{
|
||||
if (!_enableNPC)
|
||||
return;
|
||||
|
||||
int availableQuests = 5;
|
||||
|
||||
for (int questid : getCurrentQuests())
|
||||
{
|
||||
if (Get(player).getQuestFromAll(questid) == null)
|
||||
continue;
|
||||
|
||||
Quest quest = Get(player).getQuestFromAll(questid);
|
||||
|
||||
if (quest.isActive())
|
||||
availableQuests--;
|
||||
|
||||
if (!UtilTime.elapsed(quest.getLastCompleted(), 1000*60*60*24))
|
||||
availableQuests--;
|
||||
}
|
||||
|
||||
Hologram hologram;
|
||||
|
||||
QuestClientData client = Get(player);
|
||||
|
||||
if (client.getHologram() == null)
|
||||
{
|
||||
double yAdd = 2.3;
|
||||
if(!UtilPlayer.is1_9(player))
|
||||
{
|
||||
yAdd = 2.45;
|
||||
}
|
||||
hologram = new Hologram(_hologramManager, _questNPC.getLocation().clone().add(0, yAdd, 0), "");
|
||||
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
|
||||
hologram.addPlayer(player);
|
||||
client.setHologram(hologram);
|
||||
hologram.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
hologram = client.getHologram();
|
||||
}
|
||||
|
||||
if (availableQuests > 0)
|
||||
{
|
||||
// Hologram
|
||||
String text = rewardPrefix + availableQuests + " Mission" + (availableQuests > 1 ? "s" : "") + " Available";
|
||||
hologram.setText(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
String text = C.cGray + "No Missions Available";
|
||||
hologram.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -323,6 +395,12 @@ public class QuestManager extends MiniClientPlugin<QuestClientData>
|
||||
return new QuestClientData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData(String name, int accountId)
|
||||
{
|
||||
Get(name).getHologram().stop();
|
||||
}
|
||||
|
||||
public ArrayList<Quest> getAvailableQuests()
|
||||
{
|
||||
return _availableQuests;
|
||||
|
@ -16,7 +16,7 @@ public class OpenGuiCommand extends CommandBase<QuestManager>
|
||||
{
|
||||
public OpenGuiCommand(QuestManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "MineplexMissions");
|
||||
super(plugin, Rank.ALL, "Missions");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user