Get Missions working
This commit is contained in:
parent
4da27da27b
commit
f898526012
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.mission.trackers.BlockBreakTracker;
|
||||
import mineplex.core.reward.Reward;
|
||||
|
||||
public class Mission<T>
|
||||
@ -14,18 +13,18 @@ public class Mission<T>
|
||||
private final String _name;
|
||||
private final MissionLength _length;
|
||||
private final int _requiredProgress;
|
||||
private final String _statName;
|
||||
private final MissionTrackerType _trackerType;
|
||||
private final T _data;
|
||||
private final List<Reward> _rewards;
|
||||
private final String _description;
|
||||
|
||||
private Mission(int id, String name, MissionLength length, int requiredProgress, String statName, T data, List<Reward> rewards, String description)
|
||||
private Mission(int id, String name, MissionLength length, int requiredProgress, MissionTrackerType trackerType, T data, List<Reward> rewards, String description)
|
||||
{
|
||||
_id = id;
|
||||
_name = name;
|
||||
_length = length;
|
||||
_requiredProgress = requiredProgress;
|
||||
_statName = statName;
|
||||
_trackerType = trackerType;
|
||||
_data = data;
|
||||
_rewards = rewards;
|
||||
_description = String.format(description, requiredProgress);
|
||||
@ -46,9 +45,9 @@ public class Mission<T>
|
||||
return _length;
|
||||
}
|
||||
|
||||
public String getStatName()
|
||||
public MissionTrackerType getTrackerType()
|
||||
{
|
||||
return _statName;
|
||||
return _trackerType;
|
||||
}
|
||||
|
||||
public int getRequiredProgress()
|
||||
@ -76,12 +75,12 @@ public class Mission<T>
|
||||
return progress >= getRequiredProgress();
|
||||
}
|
||||
|
||||
public static <T> QuestBuilder<T> newBuilder(MissionManager manager, int id)
|
||||
public static <T> MissionBuilder<T> newBuilder(MissionManager manager, int id)
|
||||
{
|
||||
return new QuestBuilder<>(manager, id);
|
||||
return new MissionBuilder<>(manager, id);
|
||||
}
|
||||
|
||||
public static final class QuestBuilder<T>
|
||||
public static final class MissionBuilder<T>
|
||||
{
|
||||
|
||||
private final MissionManager _manager;
|
||||
@ -90,55 +89,55 @@ public class Mission<T>
|
||||
private String _name;
|
||||
private MissionLength _length;
|
||||
private int _requiredProgress;
|
||||
private MissionTracker _tracker;
|
||||
private MissionTrackerType _tracker;
|
||||
private T _data;
|
||||
private final List<Reward> _rewards;
|
||||
private String _description;
|
||||
|
||||
private QuestBuilder(MissionManager manager, int id)
|
||||
private MissionBuilder(MissionManager manager, int id)
|
||||
{
|
||||
_manager = manager;
|
||||
_id = id;
|
||||
_rewards = new ArrayList<>(2);
|
||||
}
|
||||
|
||||
public QuestBuilder<T> name(String name)
|
||||
public MissionBuilder<T> name(String name)
|
||||
{
|
||||
_name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuestBuilder<T> length(MissionLength length)
|
||||
public MissionBuilder<T> length(MissionLength length)
|
||||
{
|
||||
_length = length;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuestBuilder<T> requiredProgress(int requiredProgress)
|
||||
public MissionBuilder<T> requiredProgress(int requiredProgress)
|
||||
{
|
||||
_requiredProgress = requiredProgress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuestBuilder<T> trackBlockBreak()
|
||||
public MissionBuilder<T> tracker(MissionTrackerType tracker)
|
||||
{
|
||||
_tracker = _manager.getTracker(BlockBreakTracker.class);
|
||||
_tracker = tracker;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuestBuilder<T> trackData(T data)
|
||||
public MissionBuilder<T> trackerData(T data)
|
||||
{
|
||||
_data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuestBuilder<T> rewards(Reward... rewards)
|
||||
public MissionBuilder<T> rewards(Reward... rewards)
|
||||
{
|
||||
_rewards.addAll(Arrays.asList(rewards));
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuestBuilder<T> description(String description)
|
||||
public MissionBuilder<T> description(String description)
|
||||
{
|
||||
_description = description;
|
||||
return this;
|
||||
@ -171,7 +170,7 @@ public class Mission<T>
|
||||
throw new IllegalStateException("The description cannot be null or empty! Mission [" + _id + "]");
|
||||
}
|
||||
|
||||
_manager.addQuest(new Mission<>(_id, _name, _length, _requiredProgress, _tracker.getStatName(), _data, _rewards, _description));
|
||||
_manager.addQuest(new Mission<>(_id, _name, _length, _requiredProgress, _tracker, _data, _rewards, _description));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,28 +41,9 @@ public class MissionClient
|
||||
return _progress.containsKey(mission) && mission.validateData(data);
|
||||
}
|
||||
|
||||
public <T> int incrementProgress(Mission<T> mission, int amount, boolean unsaved)
|
||||
public <T> void incrementProgress(Mission<T> mission, int amount)
|
||||
{
|
||||
int previousAmount = getProgress(mission) + incrementMap(_unsavedProgress, mission, amount);
|
||||
|
||||
if (unsaved && isAtPercentage(previousAmount, amount, mission.getRequiredProgress(), 1))
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
if (isAtPercentage(previousAmount, amount, mission.getRequiredProgress(), 0.75))
|
||||
{
|
||||
return 75;
|
||||
}
|
||||
else if (isAtPercentage(previousAmount, amount, mission.getRequiredProgress(), 0.5))
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
else if (isAtPercentage(previousAmount, amount, mission.getRequiredProgress(), 0.25))
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
|
||||
return 0;
|
||||
incrementMap(_unsavedProgress, mission, amount);
|
||||
}
|
||||
|
||||
private int incrementMap(Map<Mission, Integer> map, Mission mission, int amount)
|
||||
@ -72,13 +53,6 @@ public class MissionClient
|
||||
return newAmount;
|
||||
}
|
||||
|
||||
private boolean isAtPercentage(int previous, int amount, int max, double percent)
|
||||
{
|
||||
double previousPercent = (double) previous / max, nowPercent = (double) (previous + amount) / max;
|
||||
|
||||
return previousPercent < percent && nowPercent >= percent;
|
||||
}
|
||||
|
||||
public Map<Mission, Integer> saveProgress()
|
||||
{
|
||||
Map<Mission, Integer> unsaved = new HashMap<>(_unsavedProgress);
|
||||
|
@ -48,25 +48,26 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
private static final String NPC_METADATA = "MISSION_NPC";
|
||||
|
||||
private final DonationManager _donationManager;
|
||||
private final NewNPCManager _npcManager;
|
||||
|
||||
private final List<Mission> _missions;
|
||||
private final Set<MissionTracker> _missionTrackers;
|
||||
private final MissionRepository _repository;
|
||||
private final MissionShop _shop;
|
||||
|
||||
private boolean _requireManualSaving;
|
||||
|
||||
private MissionManager()
|
||||
{
|
||||
super("Mission");
|
||||
|
||||
_donationManager = require(DonationManager.class);
|
||||
_npcManager = require(NewNPCManager.class);
|
||||
|
||||
_missions = new ArrayList<>();
|
||||
_missionTrackers = new HashSet<>();
|
||||
_repository = new MissionRepository();
|
||||
_shop = new MissionShop(this);
|
||||
|
||||
MissionPopulator.populateMissions(this);
|
||||
populateTrackers();
|
||||
|
||||
generatePermissions();
|
||||
@ -87,7 +88,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
|
||||
private void populateTrackers()
|
||||
{
|
||||
addTracker();
|
||||
registerTrackers();
|
||||
}
|
||||
|
||||
void addQuest(Mission mission)
|
||||
@ -95,7 +96,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
_missions.add(mission);
|
||||
}
|
||||
|
||||
private void addTracker(MissionTracker... trackers)
|
||||
public void registerTrackers(MissionTracker... trackers)
|
||||
{
|
||||
for (MissionTracker tracker : trackers)
|
||||
{
|
||||
@ -104,9 +105,10 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
}
|
||||
}
|
||||
|
||||
public void setRequireManualSaving(boolean requireManualSaving)
|
||||
public void clearTrackers()
|
||||
{
|
||||
_requireManualSaving = requireManualSaving;
|
||||
_missionTrackers.forEach(UtilServer::Unregister);
|
||||
_missionTrackers.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -207,7 +209,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> void incrementProgress(Player player, int amount, String statName, T data)
|
||||
public <T> void incrementProgress(Player player, int amount, MissionTrackerType trackerType, T data)
|
||||
{
|
||||
MissionClient client = Get(player);
|
||||
|
||||
@ -218,13 +220,8 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
return;
|
||||
}
|
||||
|
||||
int percentage = client.incrementProgress(mission, amount, _requireManualSaving);
|
||||
|
||||
if (percentage > 0)
|
||||
{
|
||||
player.sendMessage(F.main(getName(), F.name(mission.getName()) + " mission is " + F.count(percentage + "%") + " complete."));
|
||||
}
|
||||
}, statName);
|
||||
client.incrementProgress(mission, amount);
|
||||
}, trackerType);
|
||||
}
|
||||
|
||||
// TODO this may not be good enough. might have to bulk query or change implementation?
|
||||
@ -233,11 +230,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
{
|
||||
selectNewMissions(player);
|
||||
|
||||
if (!_requireManualSaving)
|
||||
{
|
||||
saveProgress(player);
|
||||
}
|
||||
saveProgress(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,10 +296,10 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
}));
|
||||
}
|
||||
|
||||
private void applyForMissions(Consumer<Mission> function, String statName)
|
||||
private void applyForMissions(Consumer<Mission> function, MissionTrackerType trackerType)
|
||||
{
|
||||
_missions.stream()
|
||||
.filter(mission -> mission.getStatName().equals(statName))
|
||||
.filter(mission -> mission.getTrackerType().equals(trackerType))
|
||||
.forEach(function);
|
||||
}
|
||||
|
||||
@ -318,15 +311,15 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public void createNPC(NewNPCManager manager, Location location)
|
||||
public void createNPC(Location location)
|
||||
{
|
||||
NPC npc = SimpleNPC.of(location, Slime.class, NPC_METADATA);
|
||||
NPC npc = SimpleNPC.of(location, Slime.class, NPC_METADATA, 3);
|
||||
|
||||
manager.addNPC(npc);
|
||||
_npcManager.addNPC(npc);
|
||||
|
||||
LivingEntity entity = npc.getEntity();
|
||||
|
||||
entity.setCustomName(C.mElem + C.Bold + "Señor Missions");
|
||||
entity.setCustomName(C.cGreenB + "Señor Missions");
|
||||
entity.setCustomNameVisible(true);
|
||||
}
|
||||
|
||||
|
@ -2,21 +2,42 @@ package mineplex.core.mission;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.reward.rewards.ExperienceReward;
|
||||
import mineplex.core.reward.rewards.GemReward;
|
||||
import mineplex.core.reward.rewards.TreasureShardReward;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
public class MissionPopulator
|
||||
{
|
||||
|
||||
public static void populateMissions(MissionManager manager)
|
||||
{
|
||||
Mission.<Material>newBuilder(manager, 1)
|
||||
.name("Wood Collector")
|
||||
.description("Cut %s Logs")
|
||||
.name("Winner")
|
||||
.description("Win %s games")
|
||||
.length(MissionLength.DAY)
|
||||
.requiredProgress(10)
|
||||
.trackBlockBreak()
|
||||
.trackData(Material.LOG)
|
||||
.rewards()
|
||||
.requiredProgress(1)
|
||||
.tracker(MissionTrackerType.GAME_WIN)
|
||||
.rewards(new GemReward(2000))
|
||||
.build();
|
||||
|
||||
Mission.<Material>newBuilder(manager, 2)
|
||||
.name("Killer")
|
||||
.description("Kill %s players")
|
||||
.length(MissionLength.DAY)
|
||||
.requiredProgress(1)
|
||||
.tracker(MissionTrackerType.GAME_KILL)
|
||||
.rewards(new ExperienceReward(100))
|
||||
.build();
|
||||
|
||||
Mission.<Material>newBuilder(manager, 3)
|
||||
.name("Killer II")
|
||||
.description("Kill %s players")
|
||||
.length(MissionLength.WEEK)
|
||||
.requiredProgress(2)
|
||||
.tracker(MissionTrackerType.GAME_KILL)
|
||||
.rewards(new TreasureShardReward(500))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,21 +7,16 @@ public class MissionTracker<T> implements Listener
|
||||
{
|
||||
|
||||
protected final MissionManager _manager;
|
||||
private final String _statName;
|
||||
private final MissionTrackerType _trackerType;
|
||||
|
||||
public MissionTracker(MissionManager manager, String statName)
|
||||
public MissionTracker(MissionManager manager, MissionTrackerType trackerType)
|
||||
{
|
||||
_manager = manager;
|
||||
_statName = statName;
|
||||
_trackerType = trackerType;
|
||||
}
|
||||
|
||||
protected void incrementProgress(Player player, int amount, T data)
|
||||
{
|
||||
_manager.incrementProgress(player, amount, _statName, data);
|
||||
}
|
||||
|
||||
public String getStatName()
|
||||
{
|
||||
return _statName;
|
||||
_manager.incrementProgress(player, amount, _trackerType, data);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package mineplex.core.mission;
|
||||
|
||||
public enum MissionTrackerType
|
||||
{
|
||||
|
||||
GAME_WIN,
|
||||
GAME_KILL
|
||||
|
||||
}
|
@ -8,14 +8,13 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.mission.Mission;
|
||||
import mineplex.core.mission.MissionClient;
|
||||
import mineplex.core.mission.MissionLength;
|
||||
import mineplex.core.mission.MissionManager;
|
||||
import mineplex.core.reward.rewards.QuantifiableReward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.rewards.QuantifiableReward;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class MissionMainPage extends ShopPageBase<MissionManager, MissionShop>
|
||||
@ -77,7 +76,7 @@ public class MissionMainPage extends ShopPageBase<MissionManager, MissionShop>
|
||||
if (!client.isComplete(mission))
|
||||
{
|
||||
builder.setGlow(true);
|
||||
builder.addLore(F.property("Progress", C.mCount + progress + C.Reset + "/" + C.mCount + mission.getRequiredProgress()));
|
||||
builder.addLore(C.cAqua + "Progress" + C.Reset + ": " + C.mCount + progress + C.Reset + "/" + C.mCount + mission.getRequiredProgress());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.newnpc;
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.EntityHorse;
|
||||
import net.minecraft.server.v1_8_R3.EntitySkeleton;
|
||||
import net.minecraft.server.v1_8_R3.EntitySlime;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
@ -37,6 +38,10 @@ public class SimpleNPC implements NPC
|
||||
{
|
||||
((EntityHorse) entity).setType(variant);
|
||||
}
|
||||
else if (entity instanceof EntitySlime)
|
||||
{
|
||||
((EntitySlime) entity).setSize(variant);
|
||||
}
|
||||
|
||||
return new SimpleNPC(metadata, (LivingEntity) entity.getBukkitEntity());
|
||||
}
|
||||
|
@ -1,225 +0,0 @@
|
||||
package mineplex.core.quests;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import mineplex.core.game.GameCategory;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
|
||||
/**
|
||||
* Quest
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class Quest
|
||||
{
|
||||
private int _questID;
|
||||
|
||||
private String _questName;
|
||||
private String _questTask;
|
||||
|
||||
private int _questCost;
|
||||
private String _questReward;
|
||||
|
||||
private QuestRarity _rarity;
|
||||
|
||||
private String _type;
|
||||
|
||||
private GameDisplay _game;
|
||||
private GameCategory _gameCategory;
|
||||
private boolean _generalGame;
|
||||
private boolean _overworld;
|
||||
|
||||
private TriggerType _trigger;
|
||||
private String[] _item;
|
||||
private int _statToComplete;
|
||||
|
||||
private long _lastCompleted;
|
||||
|
||||
private int _current;
|
||||
|
||||
private int _timesCompleted;
|
||||
|
||||
public Quest(int questID, String name, String task, int cost, String reward, QuestRarity rarity, String type, TriggerType trigger, String[] item, int statToComplete)
|
||||
{
|
||||
_questID = questID;
|
||||
_questName = name;
|
||||
_questTask = task;
|
||||
_questCost = cost;
|
||||
_questReward = reward;
|
||||
_rarity = rarity;
|
||||
_trigger = trigger;
|
||||
_item = item;
|
||||
_statToComplete = statToComplete;
|
||||
_type = type;
|
||||
|
||||
if (GameDisplay.matchName(type) != null)
|
||||
_game = GameDisplay.matchName(type);
|
||||
|
||||
try
|
||||
{
|
||||
_gameCategory = GameCategory.valueOf(type);
|
||||
}
|
||||
catch (IllegalArgumentException e) {}
|
||||
|
||||
_generalGame = _type.equalsIgnoreCase("General");
|
||||
|
||||
if (!_generalGame)
|
||||
_overworld = (_game == null && _gameCategory == null);
|
||||
}
|
||||
|
||||
public int getID()
|
||||
{
|
||||
return _questID;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _questName;
|
||||
}
|
||||
|
||||
public String getTask()
|
||||
{
|
||||
return _questTask;
|
||||
}
|
||||
|
||||
public int getCost()
|
||||
{
|
||||
return _questCost;
|
||||
}
|
||||
|
||||
public String getReward()
|
||||
{
|
||||
return _questReward;
|
||||
}
|
||||
|
||||
public QuestRarity getRarity()
|
||||
{
|
||||
return _rarity;
|
||||
}
|
||||
|
||||
public GameDisplay getGame()
|
||||
{
|
||||
return _game;
|
||||
}
|
||||
|
||||
public GameCategory getGameCategory()
|
||||
{
|
||||
return _gameCategory;
|
||||
}
|
||||
|
||||
public boolean isInOverworld()
|
||||
{
|
||||
return _overworld;
|
||||
}
|
||||
|
||||
public TriggerType getTrigger()
|
||||
{
|
||||
return _trigger;
|
||||
}
|
||||
|
||||
public String[] getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
public int getStatToComplete()
|
||||
{
|
||||
return _statToComplete;
|
||||
}
|
||||
|
||||
public int getProgress()
|
||||
{
|
||||
return _current;
|
||||
}
|
||||
|
||||
public void setProgress(int progress)
|
||||
{
|
||||
_current = progress;
|
||||
}
|
||||
|
||||
public synchronized void increment(int value)
|
||||
{
|
||||
_current += value;
|
||||
}
|
||||
|
||||
public synchronized void increment()
|
||||
{
|
||||
_current++;
|
||||
}
|
||||
|
||||
public synchronized void decrement(int value)
|
||||
{
|
||||
_current -= value;
|
||||
}
|
||||
|
||||
public synchronized void decrement()
|
||||
{
|
||||
_current--;
|
||||
}
|
||||
|
||||
public boolean isCompleted()
|
||||
{
|
||||
return _current >= _statToComplete;
|
||||
}
|
||||
|
||||
public void setLastCompleted(long time)
|
||||
{
|
||||
_lastCompleted = time;
|
||||
}
|
||||
|
||||
public long getLastCompleted()
|
||||
{
|
||||
return _lastCompleted;
|
||||
}
|
||||
|
||||
public String getRewardName()
|
||||
{
|
||||
return _questReward.split(":")[0];
|
||||
}
|
||||
|
||||
public int getRewardAmount()
|
||||
{
|
||||
return Integer.parseInt(_questReward.split(":")[1]);
|
||||
}
|
||||
|
||||
public void setTimesCompleted(int amount)
|
||||
{
|
||||
_timesCompleted = amount;
|
||||
}
|
||||
|
||||
public int getTimesCompleted()
|
||||
{
|
||||
return _timesCompleted;
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return _current != -1;
|
||||
}
|
||||
|
||||
public String[] getQuestInfo()
|
||||
{
|
||||
String[] info = new String[]{
|
||||
ChatColor.LIGHT_PURPLE + getTask(), "", ChatColor.GRAY + "Reward: " + ChatColor.AQUA + getRewardAmount() + " " + getRewardName(),
|
||||
"",
|
||||
ChatColor.GRAY + "Progress: "
|
||||
+ (_current == -1 ? ChatColor.RED + "Not in your " + QuestManager.QUEST_NAME + " Inventory" :
|
||||
(isCompleted() ? ChatColor.GREEN + "Completed!" :
|
||||
ChatColor.YELLOW + "" + getProgress() + ChatColor.GRAY + "/" + ChatColor.YELLOW + getStatToComplete())),
|
||||
"",
|
||||
getRarity().getColor() + "" + ChatColor.BOLD + getRarity().toString(),
|
||||
};
|
||||
return info;
|
||||
}
|
||||
|
||||
public boolean isGeneral()
|
||||
{
|
||||
return _generalGame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Quest clone()
|
||||
{
|
||||
return new Quest(_questID, _questName, _questTask, _questCost, _questReward, _rarity, _type, _trigger, _item, _statToComplete);
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package mineplex.core.quests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.hologram.Hologram;
|
||||
|
||||
/**
|
||||
* QuestClientData
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestClientData
|
||||
{
|
||||
private ArrayList<Quest> _quests = new ArrayList<>();
|
||||
|
||||
private Hologram _hologram;
|
||||
|
||||
public void addQuest(Quest quest)
|
||||
{
|
||||
_quests.add(quest);
|
||||
}
|
||||
|
||||
public ArrayList<Quest> getQuests()
|
||||
{
|
||||
ArrayList<Quest> quests = new ArrayList<>();
|
||||
for (Quest quest : _quests)
|
||||
{
|
||||
if (quest.getProgress() != -1)
|
||||
quests.add(quest);
|
||||
}
|
||||
return quests;
|
||||
}
|
||||
|
||||
public boolean hasQuest(Quest quest)
|
||||
{
|
||||
for (Quest other : getQuests())
|
||||
{
|
||||
if (other.getID() == quest.getID())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Quest getQuest(int id)
|
||||
{
|
||||
for (Quest quest : getQuests())
|
||||
{
|
||||
if (quest.getID() == id)
|
||||
return quest;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Quest getQuestFromAll(int id)
|
||||
{
|
||||
for (Quest quest : _quests)
|
||||
{
|
||||
if (quest.getID() == id)
|
||||
return quest;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasQuestFromAll(Quest quest)
|
||||
{
|
||||
for (Quest other : _quests)
|
||||
{
|
||||
if (other.getID() == quest.getID())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeQuest(int id)
|
||||
{
|
||||
Quest toRemove = getQuest(id);
|
||||
toRemove.setProgress(-1);
|
||||
}
|
||||
|
||||
public ArrayList<Quest> getAllQuests()
|
||||
{
|
||||
return _quests;
|
||||
}
|
||||
|
||||
public Hologram getHologram()
|
||||
{
|
||||
return _hologram;
|
||||
}
|
||||
|
||||
public void setHologram(Hologram hologram)
|
||||
{
|
||||
_hologram = hologram;
|
||||
}
|
||||
}
|
@ -1,450 +0,0 @@
|
||||
package mineplex.core.quests;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
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;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
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;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.npc.Npc;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.quests.command.GetQuestCommand;
|
||||
import mineplex.core.quests.command.IncrementQuestCommand;
|
||||
import mineplex.core.quests.command.OpenGuiCommand;
|
||||
import mineplex.core.quests.repository.QuestData;
|
||||
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;
|
||||
import mineplex.serverdata.redis.messaging.PubSubRouter;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
/**
|
||||
* QuestManager
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestManager extends MiniDbClientPlugin<QuestClientData>
|
||||
{
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
GET_QUEST_COMMAND,
|
||||
INCREMENT_QUEST_COMMAND,
|
||||
QUEST_GUI_COMMAND,
|
||||
}
|
||||
|
||||
public static final String QUEST_NAME = "Mineplex Mission";
|
||||
|
||||
private static final String GOOGLE_SHEET = "QUESTS_SHEET";
|
||||
private static final String GOOGLE_TABLE = "Quests";
|
||||
|
||||
private QuestRepository _repository;
|
||||
private GoogleSheetsManager _sheetsManager;
|
||||
private DonationManager _donationManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
|
||||
public List<Quest> _availableQuests;
|
||||
|
||||
private QuestSupplier _questSupplier = new RedisQuestSupplier(getPlugin(), new PubSubRouter(new PubSubJedisClient(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection())));
|
||||
|
||||
private Npc _questNPC;
|
||||
private boolean _enableNPC;
|
||||
private HologramManager _hologramManager;
|
||||
private boolean _visualTick;
|
||||
|
||||
public QuestManager(HologramManager hologramManager, Location npc, InventoryManager inventoryManager, DonationManager donationManager)
|
||||
{
|
||||
super("Quest Manager", hologramManager.getPlugin(), donationManager.getClientManager());
|
||||
|
||||
_repository = new QuestRepository();
|
||||
_sheetsManager = require(GoogleSheetsManager.class);
|
||||
_donationManager = donationManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_hologramManager = hologramManager;
|
||||
|
||||
setupQuests();
|
||||
|
||||
_questNPC = require(NpcManager.class).getNpcByName("Mineplex Missions");
|
||||
if (_questNPC == null)
|
||||
{
|
||||
_enableNPC = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Slime slime = (Slime) _questNPC.getEntity();
|
||||
slime.setSize(3);
|
||||
if (npc != null)
|
||||
{
|
||||
_questNPC.setLocation(npc);
|
||||
}
|
||||
_enableNPC = true;
|
||||
}
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
|
||||
PermissionGroup.ADMIN.setPermission(Perm.GET_QUEST_COMMAND, true, true);
|
||||
PermissionGroup.QA.setPermission(Perm.GET_QUEST_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.INCREMENT_QUEST_COMMAND, true, true);
|
||||
PermissionGroup.PLAYER.setPermission(Perm.QUEST_GUI_COMMAND, true, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCreeper(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER || !_enableNPC)
|
||||
return;
|
||||
|
||||
Slime slime = (Slime)_questNPC.getEntity();
|
||||
slime.setSize(3);
|
||||
|
||||
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
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new OpenGuiCommand(this));
|
||||
addCommand(new GetQuestCommand(this));
|
||||
addCommand(new IncrementQuestCommand(this));
|
||||
}
|
||||
|
||||
private void setupQuests()
|
||||
{
|
||||
List<Quest> quests = new ArrayList<>();
|
||||
Map<String, List<List<String>>> sheet = _sheetsManager.getSheetData(GOOGLE_SHEET);
|
||||
List<List<String>> table = new ArrayList<>();
|
||||
for (String key : sheet.keySet())
|
||||
{
|
||||
if (key.equalsIgnoreCase(GOOGLE_TABLE))
|
||||
{
|
||||
table = sheet.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
int size = table.size();
|
||||
|
||||
for (int i = 1; i < size; i++)
|
||||
{
|
||||
String id = table.get(i).get(0);
|
||||
String name = table.get(i).get(1);
|
||||
String task = table.get(i).get(2);
|
||||
String type = table.get(i).get(3);
|
||||
String cost = table.get(i).get(4);
|
||||
String reward = table.get(i).get(5);
|
||||
String trigger = table.get(i).get(6);
|
||||
String statcompletion = table.get(i).get(7);
|
||||
String item = table.get(i).get(8);
|
||||
String rarity = table.get(i).get(9);
|
||||
|
||||
quests.add(new Quest(Integer.parseInt(id), name, task,
|
||||
Integer.parseInt(cost),
|
||||
reward,
|
||||
QuestRarity.getByName(rarity),
|
||||
type,
|
||||
TriggerType.getByName(trigger),
|
||||
item.split(","),
|
||||
Integer.parseInt(statcompletion)));
|
||||
}
|
||||
|
||||
_availableQuests = Collections.unmodifiableList(quests);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void openGui(PlayerInteractAtEntityEvent event)
|
||||
{
|
||||
if (!_enableNPC)
|
||||
return;
|
||||
|
||||
Entity entity = event.getRightClicked();
|
||||
if (entity.equals(_questNPC.getEntity()))
|
||||
{
|
||||
new QuestShop(this, getClientManager(), _donationManager).attemptShopOpen(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void openGui(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!_enableNPC)
|
||||
return;
|
||||
|
||||
if (event.getDamager() instanceof Player)
|
||||
{
|
||||
Player player = (Player) event.getDamager();
|
||||
if (event.getEntity().equals(_questNPC.getEntity()))
|
||||
{
|
||||
new QuestShop(this, getClientManager(), _donationManager).attemptShopOpen(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Quest getQuestByID(int id)
|
||||
{
|
||||
for (Quest quest : getAvailableQuests())
|
||||
{
|
||||
if (quest.getID() == id)
|
||||
{
|
||||
return quest;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addNewQuest(Player player, Quest quest)
|
||||
{
|
||||
QuestClientData data = Get(player);
|
||||
for (Quest other : data.getAllQuests())
|
||||
{
|
||||
if (other.getID() == quest.getID())
|
||||
{
|
||||
other.setProgress(0);
|
||||
_repository.addQuest(getClientManager().Get(player).getAccountId(), other.getID());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Quest clone = quest.clone();
|
||||
clone.setProgress(0);
|
||||
Get(player).addQuest(clone);
|
||||
_repository.addNew(getClientManager().Get(player).getAccountId(), quest.getID());
|
||||
}
|
||||
|
||||
public void resetQuest(Player player, Quest quest, boolean completed)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
quest.setTimesCompleted(quest.getTimesCompleted() + 1);
|
||||
quest.setLastCompleted(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
Get(player).removeQuest(quest.getID());
|
||||
_repository.resetQuest(getClientManager().Get(player).getAccountId(), quest.getID(), completed);
|
||||
}
|
||||
|
||||
public void incrementQuest(Player player, Quest quest, int value)
|
||||
{
|
||||
quest.increment(value);
|
||||
if (quest.isCompleted())
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QUEST_NAME, "You have completed the " + QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName()));
|
||||
}
|
||||
_repository.incrementQuest(getClientManager().Get(player).getAccountId(), quest.getID(), value);
|
||||
}
|
||||
|
||||
public Set<Integer> getCurrentQuests()
|
||||
{
|
||||
Set<Integer> set = new HashSet<>();
|
||||
for (mineplex.quest.common.Quest quest : _questSupplier.get())
|
||||
{
|
||||
set.add(quest.getUniqueId());
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public void rewardQuest(Player player, Quest quest, Consumer<Boolean> callback)
|
||||
{
|
||||
if (quest.getReward().contains(":"))
|
||||
{
|
||||
ChatColor color = ChatColor.YELLOW;
|
||||
if (quest.getRewardName().equalsIgnoreCase("Shards"))
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing " + QUEST_NAME + ": " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback);
|
||||
color = ChatColor.AQUA;
|
||||
}
|
||||
else if (quest.getRewardName().equalsIgnoreCase("Gems"))
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing " + QUEST_NAME + ": " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback);
|
||||
color = ChatColor.GREEN;
|
||||
}
|
||||
else if (quest.getRewardName().equalsIgnoreCase("XP"))
|
||||
{
|
||||
require(StatsManager.class).incrementStat(player, "Global.ExpEarned", quest.getRewardAmount());
|
||||
callback.accept(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_inventoryManager.addItemToInventory(player, quest.getRewardName(), quest.getRewardAmount());
|
||||
callback.accept(true);
|
||||
}
|
||||
UtilPlayer.message(player, F.main(QUEST_NAME, "You have recieved " + color + quest.getRewardAmount() + " " + quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + quest.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public DonationManager getDonations()
|
||||
{
|
||||
return _donationManager;
|
||||
}
|
||||
|
||||
public InventoryManager getInventoryManager()
|
||||
{
|
||||
return _inventoryManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QuestClientData addPlayer(UUID uuid)
|
||||
{
|
||||
return new QuestClientData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData(String name, UUID uuid, int accountId)
|
||||
{
|
||||
Hologram hologram = Get(uuid).getHologram();
|
||||
|
||||
if (hologram != null)
|
||||
{
|
||||
hologram.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Quest> getAvailableQuests()
|
||||
{
|
||||
return _availableQuests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT questId, progress, questCompletion, lastCompleted FROM accountQuest WHERE accountId=" + accountId + ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
final Set<QuestData> retrieved = new HashSet<>();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
final int id = resultSet.getInt("questId");
|
||||
final int progress = resultSet.getInt("progress");
|
||||
final int timesCompleted = resultSet.getInt("questCompletion");
|
||||
final long lastCompleted = resultSet.getLong("lastCompleted");
|
||||
|
||||
retrieved.add(new QuestData(id, progress, timesCompleted, lastCompleted));
|
||||
}
|
||||
|
||||
final QuestClientData questData = Get(uuid);
|
||||
|
||||
if (!retrieved.isEmpty())
|
||||
{
|
||||
runSync(() ->
|
||||
{
|
||||
retrieved.forEach(data ->
|
||||
{
|
||||
Optional<Quest> match = getAvailableQuests().stream().filter(quest -> quest.getID() == data.QuestId).findAny();
|
||||
|
||||
if (match.isPresent())
|
||||
{
|
||||
Quest clone = match.get().clone();
|
||||
clone.setProgress(data.QuestProgress);
|
||||
clone.setLastCompleted(data.LastCompleted);
|
||||
clone.setTimesCompleted(data.TimesCompleted);
|
||||
|
||||
questData.addQuest(clone);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package mineplex.core.quests;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* QuestRarity
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public enum QuestRarity
|
||||
{
|
||||
COMMON("Common", ChatColor.YELLOW), RARE("Rare", ChatColor.LIGHT_PURPLE), LEGENDARY("Legendary", ChatColor.GREEN);
|
||||
|
||||
private String _name;
|
||||
private ChatColor _color;
|
||||
|
||||
private QuestRarity(String name, ChatColor color)
|
||||
{
|
||||
_name = name;
|
||||
_color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public static QuestRarity getByName(String name)
|
||||
{
|
||||
for (QuestRarity rarity : values())
|
||||
{
|
||||
if (rarity.toString().equalsIgnoreCase(name))
|
||||
return rarity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package mineplex.core.quests;
|
||||
|
||||
/**
|
||||
* TriggerType
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public enum TriggerType
|
||||
{
|
||||
|
||||
KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"), HIT("Hit"), FIRST_BLOOD("First Blood");
|
||||
|
||||
private String _name;
|
||||
|
||||
private TriggerType(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public static TriggerType getByName(String name)
|
||||
{
|
||||
for (TriggerType type : values())
|
||||
{
|
||||
if (type.toString().equalsIgnoreCase(name))
|
||||
return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package mineplex.core.quests.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.quests.Quest;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
|
||||
/**
|
||||
* GetQuestCommand
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class GetQuestCommand extends CommandBase<QuestManager>
|
||||
{
|
||||
public GetQuestCommand(QuestManager plugin)
|
||||
{
|
||||
super(plugin, QuestManager.Perm.GET_QUEST_COMMAND, "GetMineplexMission");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You have to submit valid arguments"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Plugin.getQuestByID(Integer.parseInt(args[0])) == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, QuestManager.QUEST_NAME + " not found"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> players = new ArrayList<>();
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (UtilPlayer.searchExact(args[1]) != null)
|
||||
{
|
||||
players.add(UtilPlayer.searchExact(args[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("all"))
|
||||
{
|
||||
players.addAll(UtilServer.getPlayersCollection());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
players.add(caller);
|
||||
}
|
||||
|
||||
Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0]));
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
Plugin.addNewQuest(player, quest);
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName()));
|
||||
|
||||
if (!args[1].equalsIgnoreCase("all"))
|
||||
{
|
||||
if (caller != players.get(0))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone"));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package mineplex.core.quests.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.quests.Quest;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
|
||||
/**
|
||||
* CompleteQuestCommand
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class IncrementQuestCommand extends CommandBase<QuestManager>
|
||||
{
|
||||
public IncrementQuestCommand(QuestManager plugin)
|
||||
{
|
||||
super(plugin, QuestManager.Perm.INCREMENT_QUEST_COMMAND, "IncrementMineplexMission");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You have to submit valid arguments"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = caller;
|
||||
if (args.length == 3)
|
||||
{
|
||||
if (UtilPlayer.searchExact(args[2]) != null)
|
||||
player = UtilPlayer.searchExact(args[2]);
|
||||
}
|
||||
|
||||
if (Plugin.Get(player).getQuest(Integer.parseInt(args[0])) == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, QuestManager.QUEST_NAME + " not found"));
|
||||
return;
|
||||
}
|
||||
|
||||
int increment = 0;
|
||||
try
|
||||
{
|
||||
increment = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You have to submit a valid number"));
|
||||
return;
|
||||
}
|
||||
|
||||
Quest quest = Plugin.Get(player).getQuest(Integer.parseInt(args[0]));
|
||||
|
||||
Plugin.incrementQuest(player, quest, increment);
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Incremented " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " by " + increment));
|
||||
|
||||
if (caller != player)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You incremented the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " for " + ChatColor.YELLOW + player.getName() + ChatColor.GRAY + " by " + increment));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package mineplex.core.quests.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.quests.shop.QuestShop;
|
||||
|
||||
/**
|
||||
* OpenGuiCommand
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class OpenGuiCommand extends CommandBase<QuestManager>
|
||||
{
|
||||
public OpenGuiCommand(QuestManager plugin)
|
||||
{
|
||||
super(plugin, QuestManager.Perm.QUEST_GUI_COMMAND, "Missions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
new QuestShop(Plugin, Plugin.getClientManager(), Plugin.getDonations()).attemptShopOpen(caller);
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package mineplex.core.quests.event;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.core.quests.Quest;
|
||||
|
||||
/**
|
||||
* QuestBuyEvent
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestInteractEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private boolean _cancelled = false;
|
||||
|
||||
private Quest _quest;
|
||||
|
||||
private String _cancelReason;
|
||||
|
||||
public QuestInteractEvent(Quest quest)
|
||||
{
|
||||
_quest = quest;
|
||||
}
|
||||
|
||||
public Quest getQuest()
|
||||
{
|
||||
return _quest;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(String reason)
|
||||
{
|
||||
_cancelled = true;
|
||||
_cancelReason = reason;
|
||||
}
|
||||
|
||||
public String getCancelMessage()
|
||||
{
|
||||
return _cancelReason;
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package mineplex.core.quests.repository;
|
||||
|
||||
public class QuestData
|
||||
{
|
||||
public final int QuestId;
|
||||
public final int QuestProgress;
|
||||
public final int TimesCompleted;
|
||||
public final long LastCompleted;
|
||||
|
||||
public QuestData(int questId, int questProgress, int timesCompleted, long lastCompleted)
|
||||
{
|
||||
QuestId = questId;
|
||||
QuestProgress = questProgress;
|
||||
TimesCompleted = timesCompleted;
|
||||
LastCompleted = lastCompleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof QuestData && ((QuestData) obj).QuestId == QuestId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return QuestId;
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package mineplex.core.quests.repository;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnLong;
|
||||
|
||||
/**
|
||||
* QuestRepository
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestRepository extends RepositoryBase
|
||||
{
|
||||
private static final String INSERT_NEW_QUEST = "INSERT INTO accountQuest (accountId, questId, progress, questCompletion, lastCompleted) VALUES (?, ?, ?, ?, ?);";
|
||||
private static final String INCREMENT_QUEST = "UPDATE accountQuest SET progress=progress+? WHERE accountId=? AND questId=?;";
|
||||
private static final String RESET_QUEST = "UPDATE accountQuest SET progress=-1 WHERE accountId=? AND questId=?;";
|
||||
private static final String START_QUEST = "UPDATE accountQuest SET progress=0 WHERE accountId=? AND questId=?;";
|
||||
private static final String COMPLETE_QUEST = "UPDATE accountQuest SET progress=-1, questCompletion=questCompletion+1, lastCompleted=? WHERE accountId=? AND questId=?;";
|
||||
|
||||
public String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS accountQuest (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, questId INT NOT NULL, progress INT, questCompletion INT, lastCompleted BIGINT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts (id), UNIQUE INDEX questIndex (accountId, questId), INDEX progressIndex (progress), INDEX completionIndex (questCompletion));";
|
||||
|
||||
public QuestRepository()
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
|
||||
//createTable();
|
||||
}
|
||||
|
||||
public void createTable()
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
executeUpdate(CREATE_TABLE);
|
||||
});
|
||||
}
|
||||
|
||||
public void resetQuest(int accountId, int questId, boolean completed)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", accountId), new ColumnInt("questId", questId));
|
||||
}
|
||||
else
|
||||
{
|
||||
executeUpdate(RESET_QUEST, new ColumnInt("accountId", accountId), new ColumnInt("questId", questId));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addQuest(int accountId, int questId)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
executeUpdate(START_QUEST, new ColumnInt("accountId", accountId), new ColumnInt("questId", questId));
|
||||
});
|
||||
}
|
||||
|
||||
public void addNew(int accountId, int questId)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
executeInsert(INSERT_NEW_QUEST, null,
|
||||
new ColumnInt("accountId", accountId),
|
||||
new ColumnInt("questId", questId),
|
||||
new ColumnInt("progress", 0),
|
||||
new ColumnInt("questCompletion", 0),
|
||||
new ColumnLong("lastCompleted", (long) 0));
|
||||
});
|
||||
}
|
||||
|
||||
public void incrementQuest(int accountId, int questId, int value)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", accountId), new ColumnInt("questId", questId));
|
||||
});
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package mineplex.core.quests.shop;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
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.quests.Quest;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.quests.event.QuestInteractEvent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
/**
|
||||
* BuyQuestButton
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class BuyQuestButton implements IButton
|
||||
{
|
||||
private final static int MAX_QUESTS = 5;
|
||||
|
||||
private QuestManager _questManager;
|
||||
|
||||
private QuestPage _page;
|
||||
|
||||
private Quest _quest;
|
||||
|
||||
public BuyQuestButton(QuestManager questManager, QuestPage page, Quest quest)
|
||||
{
|
||||
_questManager = questManager;
|
||||
_quest = quest;
|
||||
_page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (!Recharge.Instance.use(player, "Buy Mineplex Mission", 1000, false, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_questManager.Get(player).hasQuest(_quest))
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You already own that " + QuestManager.QUEST_NAME + "!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_questManager.Get(player).getQuests().size() >= MAX_QUESTS)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You can't own more than " + MAX_QUESTS + " active " + QuestManager.QUEST_NAME + " at once!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_questManager.Get(player).hasQuestFromAll(_quest))
|
||||
{
|
||||
if (!UtilTime.elapsed(_questManager.Get(player).getQuestFromAll(_quest.getID()).getLastCompleted(), 1000*60*60*24))
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You already completed that " + QuestManager.QUEST_NAME + " today!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest));
|
||||
if (event.isCancelled())
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, event.getCancelMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
SalesPackageBase salesPackage = new QuestSale(ChatColor.YELLOW + "" + ChatColor.BOLD + _quest.getName(), Material.PAPER, _quest.getCost());
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () ->
|
||||
{
|
||||
_questManager.addNewQuest(player, _quest);
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You have bought: " + ChatColor.YELLOW + _quest.getName()));
|
||||
player.closeInventory();
|
||||
new QuestShop(_questManager, _questManager.getClientManager(), _questManager.getDonations()).attemptShopOpen(player);
|
||||
|
||||
}), salesPackage.buildIcon()));
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
package mineplex.core.quests.shop;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.quests.Quest;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
/**
|
||||
* QuestPage
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestPage extends ShopPageBase<QuestManager, QuestShop>
|
||||
{
|
||||
private QuestShop _questShop;
|
||||
private QuestManager _manager;
|
||||
|
||||
public QuestPage(QuestManager plugin, QuestShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, QuestManager.QUEST_NAME + " Page", player, 27);
|
||||
|
||||
_questShop = shop;
|
||||
_manager = plugin;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int i = 0;
|
||||
setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Available " + QuestManager.QUEST_NAME + "s"));
|
||||
{
|
||||
int currentSlot = 4;
|
||||
int diff = 0;
|
||||
boolean forward = true;
|
||||
for (int questID : getQuestShop().getQuestManager().getCurrentQuests())
|
||||
{
|
||||
if (forward)
|
||||
{
|
||||
currentSlot += diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSlot -= diff;
|
||||
}
|
||||
diff++;
|
||||
forward = !forward;
|
||||
|
||||
Quest playerQuest = _shop.getQuestManager().Get(_player).getQuestFromAll(questID);
|
||||
if (playerQuest != null)
|
||||
{
|
||||
if (!UtilTime.elapsed(playerQuest.getLastCompleted(), 1000*60*60*24))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (playerQuest.isActive())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Quest quest = _shop.getQuestManager().getQuestByID(questID);
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName());
|
||||
|
||||
List<String> lore = UtilText.splitLine(ChatColor.LIGHT_PURPLE + quest.getTask(), LineFormat.LORE);
|
||||
lore.addAll(Arrays.asList(
|
||||
"",
|
||||
ChatColor.GRAY + "Cost: " + ChatColor.GREEN + quest.getCost() + " Gems",
|
||||
ChatColor.GRAY + "Reward: " + ChatColor.AQUA + quest.getRewardAmount() + " " + quest.getRewardName(),
|
||||
"",
|
||||
quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(),
|
||||
"",
|
||||
ChatColor.GREEN + "Click to buy " + QuestManager.QUEST_NAME + "!"
|
||||
));
|
||||
meta.setLore(lore);
|
||||
|
||||
item.setItemMeta(meta);
|
||||
|
||||
addButton(i + currentSlot, item, new BuyQuestButton(_manager, this, quest));
|
||||
}
|
||||
}
|
||||
i = 9;
|
||||
while (i < (9*2))
|
||||
{
|
||||
setItem(i, ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData()));
|
||||
i++;
|
||||
}
|
||||
i = 9*2;
|
||||
addButton(i, ItemStackFactory.Instance.CreateStack(Material.EMPTY_MAP, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + QuestManager.QUEST_NAME + " Stats"), new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
player.closeInventory();
|
||||
new QuestStatShop(_manager, _manager.getClientManager(), _manager.getDonations()).attemptShopOpen(player);
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
int currentSlot = 4;
|
||||
int diff = 0;
|
||||
boolean forward = true;
|
||||
for (Quest quest : _shop.getQuestManager().Get(_player).getQuests())
|
||||
{
|
||||
if (forward)
|
||||
{
|
||||
currentSlot += diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSlot -= diff;
|
||||
}
|
||||
diff++;
|
||||
forward = !forward;
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName());
|
||||
|
||||
meta.setLore(Arrays.asList(ArrayUtils.addAll(quest.getQuestInfo(),
|
||||
"",
|
||||
(quest.isCompleted() ? ChatColor.GREEN + "Left Click to Complete" : ChatColor.RED + "Shift Right-Click to cancel")
|
||||
)));
|
||||
|
||||
item.setItemMeta(meta);
|
||||
item.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
|
||||
|
||||
addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_donationManager, _manager, quest));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public QuestShop getQuestShop()
|
||||
{
|
||||
return _questShop;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package mineplex.core.quests.shop;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
|
||||
/**
|
||||
* QuestSale
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestSale extends SalesPackageBase
|
||||
{
|
||||
|
||||
public QuestSale(String name, Material mat, int cost)
|
||||
{
|
||||
super(name, mat, (byte) 0, new String[] {}, cost);
|
||||
|
||||
KnownPackage = false;
|
||||
OneTimePurchaseOnly = false;
|
||||
// CurrencyCostMap.clear();
|
||||
CurrencyCostMap.put(GlobalCurrency.GEM, cost);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package mineplex.core.quests.shop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
/**
|
||||
* QuestShop
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestShop extends ShopBase<QuestManager>
|
||||
{
|
||||
public QuestShop(QuestManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, QuestManager.QUEST_NAME + " Shop");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<QuestManager, ? extends ShopBase<QuestManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return new QuestPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||
}
|
||||
|
||||
public QuestManager getQuestManager()
|
||||
{
|
||||
return getPlugin();
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package mineplex.core.quests.shop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
/**
|
||||
* QuestStatShop
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestStatShop extends ShopBase<QuestManager>
|
||||
{
|
||||
|
||||
public QuestStatShop(QuestManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, QuestManager.QUEST_NAME + " Stats");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<QuestManager, ? extends ShopBase<QuestManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return new QuestStatsPage(getPlugin(), this, getClientManager(), getDonationManager(), player, 0);
|
||||
}
|
||||
|
||||
public QuestManager getQuestManager()
|
||||
{
|
||||
return getPlugin();
|
||||
}
|
||||
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
package mineplex.core.quests.shop;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.quests.Quest;
|
||||
import mineplex.core.quests.QuestClientData;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
/**
|
||||
* QuestStatsPage
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestStatsPage extends ShopPageBase<QuestManager, QuestStatShop>
|
||||
{
|
||||
private QuestStatShop _questShop;
|
||||
private QuestManager _manager;
|
||||
private int _siteIndex;
|
||||
|
||||
public QuestStatsPage(QuestManager plugin, QuestStatShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, int site)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, QuestManager.QUEST_NAME + " Stats", player, 6*9);
|
||||
|
||||
_siteIndex = site;
|
||||
|
||||
_questShop = shop;
|
||||
_manager = plugin;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
removeButton(5*9);
|
||||
removeButton((6*9) - 1);
|
||||
|
||||
int questID = (_siteIndex * 5 * 9);
|
||||
for (int i = 0; i < 9*5; i++)
|
||||
{
|
||||
Quest quest = _manager.getQuestByID(questID);
|
||||
|
||||
if (quest == null)
|
||||
{
|
||||
setItem(i, null);
|
||||
questID++;
|
||||
continue;
|
||||
}
|
||||
|
||||
QuestClientData data = _manager.Get(getPlayer());
|
||||
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.WOOL, DyeColor.GRAY.getWoolData(), 1, ChatColor.YELLOW + quest.getName());
|
||||
|
||||
if (data.hasQuestFromAll(quest))
|
||||
{
|
||||
Quest used = data.getQuestFromAll(questID);
|
||||
|
||||
item = ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, ChatColor.YELLOW + used.getName());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(Arrays.asList(ArrayUtils.addAll(used.getQuestInfo(),
|
||||
"",
|
||||
ChatColor.GRAY + "Times Completed: " + ChatColor.YELLOW + used.getTimesCompleted()
|
||||
)));
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
setItem(i, item);
|
||||
|
||||
questID++;
|
||||
}
|
||||
|
||||
if (_siteIndex > 0)
|
||||
{
|
||||
addButton(5*9, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Previous Page"), new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_siteIndex--;
|
||||
buildPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (((_siteIndex + 1) * 5 * 9) <= _manager.getAvailableQuests().size())
|
||||
{
|
||||
addButton((6*9) - 1, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Next Page"), new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_siteIndex++;
|
||||
buildPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addButton(5*9 + 4, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Back to " + QuestManager.QUEST_NAME + "s"), new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
player.closeInventory();
|
||||
new QuestShop(_manager, getClientManager(), getDonationManager()).attemptShopOpen(player);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public QuestStatShop getQuestStatsShop()
|
||||
{
|
||||
return _questShop;
|
||||
}
|
||||
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package mineplex.core.quests.shop;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.quests.Quest;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.quests.event.QuestInteractEvent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
/**
|
||||
* RedeemDeclineQuest
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class RedeemDeclineQuestButton implements IButton
|
||||
{
|
||||
private QuestManager _questManager;
|
||||
private DonationManager _donations;
|
||||
|
||||
private Quest _quest;
|
||||
|
||||
public RedeemDeclineQuestButton(DonationManager donations, QuestManager questManager, Quest quest)
|
||||
{
|
||||
_questManager = questManager;
|
||||
_donations = donations;
|
||||
_quest = quest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (!Recharge.Instance.use(player, "Decline Mineplex Mission", 1000, false, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_questManager.Get(player).hasQuest(_quest))
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You don't own that " + QuestManager.QUEST_NAME + "!"));
|
||||
return;
|
||||
}
|
||||
|
||||
QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest));
|
||||
if (event.isCancelled())
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, event.getCancelMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickType == ClickType.SHIFT_RIGHT)
|
||||
{
|
||||
if (_quest.isCompleted())
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You can't cancel a completed " + QuestManager.QUEST_NAME + "!"));
|
||||
return;
|
||||
}
|
||||
_questManager.resetQuest(player, _quest, false);
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You have cancelled that " + QuestManager.QUEST_NAME + "!"));
|
||||
}
|
||||
|
||||
if (clickType == ClickType.LEFT)
|
||||
{
|
||||
if (!_quest.isCompleted())
|
||||
{
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You haven't completed that " + QuestManager.QUEST_NAME + " yet!"));
|
||||
return;
|
||||
}
|
||||
|
||||
_questManager.rewardQuest(player, _quest, new Consumer<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Boolean succes)
|
||||
{
|
||||
if (succes)
|
||||
{
|
||||
_questManager.resetQuest(player, _quest, true);
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
new QuestShop(_questManager, _questManager.getClientManager(), _donations).attemptShopOpen(player);
|
||||
}
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.achievement.Achievement;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
@ -19,15 +18,18 @@ public class ExperienceReward extends Reward implements QuantifiableReward
|
||||
private static final StatsManager STATS_MANAGER = Managers.require(StatsManager.class);
|
||||
private static final ItemStack ITEM_STACK = new ItemStack(Material.EXP_BOTTLE);
|
||||
|
||||
private Random _random;
|
||||
private int _minExperience;
|
||||
private int _maxExperience;
|
||||
private final int _minExperience;
|
||||
private final int _maxExperience;
|
||||
|
||||
public ExperienceReward(int experience)
|
||||
{
|
||||
this(experience, experience, 0, RewardRarity.RARE);
|
||||
}
|
||||
|
||||
public ExperienceReward(int minExperience, int maxExperience, int shardValue, RewardRarity rarity)
|
||||
{
|
||||
super(rarity, shardValue);
|
||||
|
||||
_random = new Random();
|
||||
_minExperience = minExperience;
|
||||
_maxExperience = maxExperience;
|
||||
}
|
||||
@ -35,7 +37,16 @@ public class ExperienceReward extends Reward implements QuantifiableReward
|
||||
@Override
|
||||
protected RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
int experience = _random.nextInt(_maxExperience - _minExperience) + _minExperience;
|
||||
int experience;
|
||||
|
||||
if (_minExperience == _maxExperience)
|
||||
{
|
||||
experience = _minExperience;
|
||||
}
|
||||
else
|
||||
{
|
||||
experience = UtilMath.rRange(_minExperience, _maxExperience);
|
||||
}
|
||||
|
||||
STATS_MANAGER.incrementStat(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], experience);
|
||||
|
||||
|
@ -16,6 +16,11 @@ public class GemReward extends Reward implements QuantifiableReward
|
||||
private final int _minGemCount;
|
||||
private final int _maxGemCount;
|
||||
|
||||
public GemReward(int gems)
|
||||
{
|
||||
this(gems, gems, 0, RewardRarity.LEGENDARY);
|
||||
}
|
||||
|
||||
public GemReward(int minGemCount, int maxGemCount, int shardValue, RewardRarity rarity)
|
||||
{
|
||||
super(rarity, shardValue);
|
||||
|
@ -31,6 +31,11 @@ public class TreasureShardReward extends Reward implements QuantifiableReward
|
||||
_shardsMax = _shardsMin;
|
||||
}
|
||||
|
||||
public TreasureShardReward(int shards)
|
||||
{
|
||||
this(shards, shards, RewardRarity.UNCOMMON);
|
||||
}
|
||||
|
||||
public TreasureShardReward(int min, int max, RewardRarity rarity)
|
||||
{
|
||||
super(rarity, 0);
|
||||
|
@ -67,6 +67,7 @@ import mineplex.core.interactions.NewInteractionsManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.menu.MenuManager;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
import mineplex.core.mission.MissionManager;
|
||||
import mineplex.core.noteblock.MusicManager;
|
||||
import mineplex.core.notifier.NotificationManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
@ -80,7 +81,6 @@ import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.Preference;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.scoreboard.TabListSorter;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
@ -107,7 +107,6 @@ import mineplex.hub.player.CreativeManager;
|
||||
import mineplex.hub.player.HubPlayerManager;
|
||||
import mineplex.hub.plugin.HubPlugin;
|
||||
import mineplex.hub.scoreboard.HubScoreboard;
|
||||
import mineplex.hub.treasurehunt.TreasureHuntManager;
|
||||
import mineplex.hub.world.HubPortalManager;
|
||||
import mineplex.hub.world.HubWorldManager;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
@ -224,7 +223,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
|
||||
//new EasterEggHunt(_plugin, _clientManager);
|
||||
|
||||
new QuestManager(hologramManager, null, inventoryManager, _donationManager);
|
||||
require(MissionManager.class);
|
||||
|
||||
//new TemporaryGemHuntersServerSender(_portal);
|
||||
|
||||
|
@ -26,6 +26,7 @@ import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -88,7 +89,9 @@ import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.menu.MenuManager;
|
||||
import mineplex.core.mission.MissionManager;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.party.PartyManager;
|
||||
@ -103,7 +106,6 @@ import mineplex.core.preferences.UserPreferences;
|
||||
import mineplex.core.progression.KitProgressionManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager;
|
||||
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
@ -249,7 +251,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private ScoreboardManager _scoreboardManager;
|
||||
private NextBestGameManager _nextBestGameManager;
|
||||
private TrackManager _trackManager;
|
||||
private QuestManager _questManager;
|
||||
private final MissionManager _missionsManager;
|
||||
private GoogleSheetsManager _sheetsManager;
|
||||
private IncognitoManager _incognitoManager;
|
||||
private WinStreakManager _winStreakManager;
|
||||
@ -356,7 +358,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
//new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager);
|
||||
require(PlayerDisguiseManager.class);
|
||||
new GameBoosterManager(plugin, boosterManager, hologramManager, npcManager, serverConfig.BoosterGroup);
|
||||
require(GameBoosterManager.class);
|
||||
|
||||
// Game Addons
|
||||
new SoupAddon(plugin, this);
|
||||
@ -370,8 +372,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_conditionManager, _projectileManager, _disguiseManager, _blockRestore, _fire, new Movement(plugin), teleport,
|
||||
_energy);
|
||||
|
||||
_classManager = new ClassManager(plugin, clientManager, donationManager, _cosmeticManager.getGadgetManager(), _skillFactory, _itemFactory
|
||||
);
|
||||
_classManager = new ClassManager(plugin, clientManager, donationManager, _cosmeticManager.getGadgetManager(), _skillFactory, _itemFactory);
|
||||
|
||||
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, _itemFactory, _achievementManager, clientManager);
|
||||
|
||||
@ -383,7 +384,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
_kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager);
|
||||
_serverUptimeManager = new ServerUptimeManager(this);
|
||||
_questManager = new QuestManager(hologramManager, _gameLobbyManager.getMissions(), _inventoryManager, _donationManager);
|
||||
_missionsManager = require(MissionManager.class);
|
||||
_missionsManager.createNPC(_gameLobbyManager.getMissions());
|
||||
|
||||
if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-"))
|
||||
{
|
||||
@ -1378,13 +1380,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void MobSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
if (_game == null)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void SkillTrigger(SkillTriggerEvent event)
|
||||
{
|
||||
@ -2026,9 +2021,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
return _titles;
|
||||
}
|
||||
|
||||
public QuestManager getQuestManager()
|
||||
public MissionManager getMissionsManager()
|
||||
{
|
||||
return _questManager;
|
||||
return _missionsManager;
|
||||
}
|
||||
|
||||
public GoogleSheetsManager getSheetsManager()
|
||||
|
@ -1,5 +1,16 @@
|
||||
package nautilus.game.arcade.booster;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.boosters.event.BoosterActivateEvent;
|
||||
@ -10,75 +21,50 @@ import mineplex.core.common.util.UtilSkull;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.npc.Npc;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.newnpc.NPC;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.SimpleNPC;
|
||||
import mineplex.core.newnpc.event.NPCInteractEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.database.tables.records.NpcsRecord;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
*/
|
||||
public class BoosterPodium extends MiniPlugin
|
||||
{
|
||||
private GameBoosterManager _gameBoosterManager;
|
||||
private HologramManager _hologramManager;
|
||||
private NpcManager _npcManager;
|
||||
private Location _podiumLocation;
|
||||
|
||||
private final GameBoosterManager _gameBoosterManager;
|
||||
private final HologramManager _hologramManager;
|
||||
private final NewNPCManager _npcManager;
|
||||
private final Location _podiumLocation;
|
||||
|
||||
private Booster _activeBooster;
|
||||
private Npc _npc;
|
||||
private boolean _npcAlive;
|
||||
private NPC _npc;
|
||||
private Location _npcLocation;
|
||||
private ArmorStand _activeArmorStand;
|
||||
private Hologram _hologram;
|
||||
|
||||
public BoosterPodium(JavaPlugin plugin, GameBoosterManager gameBoosterManager, HologramManager hologramManager, NpcManager npcManager, Location podiumLocation)
|
||||
BoosterPodium(GameBoosterManager gameBoosterManager, HologramManager hologramManager, Location podiumLocation)
|
||||
{
|
||||
super("Booster Podium - " + podiumLocation.toString(), plugin);
|
||||
super("Booster Podium");
|
||||
|
||||
_gameBoosterManager = gameBoosterManager;
|
||||
_hologramManager = hologramManager;
|
||||
_npcManager = npcManager;
|
||||
_npcManager = require(NewNPCManager.class);
|
||||
_podiumLocation = podiumLocation;
|
||||
_npcLocation = podiumLocation.clone();
|
||||
|
||||
NpcsRecord npcsRecord = new NpcsRecord();
|
||||
npcsRecord.setServer(_npcManager.getServerName());
|
||||
npcsRecord.setName(C.cGreen + "Game Amplifiers");
|
||||
npcsRecord.setWorld(_npcLocation.getWorld().getName());
|
||||
npcsRecord.setX(_npcLocation.getX());
|
||||
npcsRecord.setY(_npcLocation.getY());
|
||||
npcsRecord.setZ(_npcLocation.getZ());
|
||||
npcsRecord.setYaw((double) podiumLocation.getYaw());
|
||||
npcsRecord.setRadius(0D);
|
||||
npcsRecord.setEntityType(EntityType.VILLAGER.name());
|
||||
npcsRecord.setAdult(true);
|
||||
_npcAlive = false;
|
||||
_npc = new Npc(npcManager, npcsRecord);
|
||||
|
||||
updateNpcs();
|
||||
}
|
||||
|
||||
public void updateNpcs()
|
||||
private void updateNpcs()
|
||||
{
|
||||
Booster activeBooster = _gameBoosterManager.getActiveBooster();
|
||||
|
||||
if (activeBooster != null)
|
||||
{
|
||||
if (_npcAlive)
|
||||
if (_npc != null)
|
||||
{
|
||||
_npcManager.removeFakeNpc(_npc);
|
||||
_npcAlive = false;
|
||||
_npcManager.deleteNPC(_npc);
|
||||
_npc = null;
|
||||
}
|
||||
|
||||
if (_activeArmorStand != null)
|
||||
@ -88,14 +74,13 @@ public class BoosterPodium extends MiniPlugin
|
||||
|
||||
if (_hologram == null)
|
||||
{
|
||||
_hologram = new Hologram(_hologramManager, _npcLocation.clone().add(0, 2.5, 0), true, getHologramText(activeBooster));
|
||||
_hologram.start();
|
||||
_hologram = new Hologram(_hologramManager, _npcLocation.clone().add(0, 2.5, 0), true, getHologramText(activeBooster))
|
||||
.start();
|
||||
}
|
||||
|
||||
ArmorStand armorStand = _podiumLocation.getWorld().spawn(_npcLocation, ArmorStand.class);
|
||||
armorStand.setVisible(true);
|
||||
armorStand.setCustomNameVisible(false);
|
||||
armorStand.setCustomName("");
|
||||
armorStand.setGravity(true);
|
||||
armorStand.setArms(true);
|
||||
armorStand.setBasePlate(true);
|
||||
@ -123,16 +108,20 @@ public class BoosterPodium extends MiniPlugin
|
||||
_hologram = null;
|
||||
}
|
||||
|
||||
if (!_npcAlive)
|
||||
if (_npc == null)
|
||||
{
|
||||
_npcManager.spawnNpc(_npc);
|
||||
_npcManager.addFakeNpc(_npc);
|
||||
_npcAlive = true;
|
||||
_npc = SimpleNPC.of(_npcLocation, Villager.class, "GAME_BOOSTER");
|
||||
_npcManager.addNPC(_npc);
|
||||
|
||||
LivingEntity entity = _npc.getEntity();
|
||||
|
||||
entity.setCustomName(C.cGreen + "Game Amplifiers");
|
||||
entity.setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNpcName()
|
||||
private void updateNpcName()
|
||||
{
|
||||
if (_activeBooster != null && _hologram != null)
|
||||
{
|
||||
@ -140,33 +129,31 @@ public class BoosterPodium extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private String getNameString(Booster booster)
|
||||
{
|
||||
return C.cGreen + "Amplified by " + C.cWhite + booster.getPlayerName() + C.cGreen + " - " + C.cWhite + booster.getTimeRemainingString();
|
||||
}
|
||||
|
||||
private String[] getHologramText(Booster booster)
|
||||
{
|
||||
return new String[] {
|
||||
C.cGreen + "Amplified by " + C.cWhite + booster.getPlayerName(),
|
||||
C.cWhite + booster.getTimeRemainingString() + " Remaining",
|
||||
C.cAqua + "Click to Thank. You get " + BoosterThankManager.TIP_FOR_TIPPER + " Treasure Shards"
|
||||
};
|
||||
return new String[]
|
||||
{
|
||||
C.cGreen + "Amplified by " + C.cWhite + booster.getPlayerName(),
|
||||
C.cWhite + booster.getTimeRemainingString() + " Remaining",
|
||||
C.cAqua + "Click to Thank. You get " + BoosterThankManager.TIP_FOR_TIPPER + " Treasure Shards"
|
||||
};
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
if (_activeArmorStand != null && !_activeArmorStand.isValid())
|
||||
{
|
||||
updateNpcs();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateNpcName();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (_activeArmorStand != null && !_activeArmorStand.isValid())
|
||||
{
|
||||
updateNpcs();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateNpcName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,6 +169,15 @@ public class BoosterPodium extends MiniPlugin
|
||||
updateNpcs();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void npcInteract(NPCInteractEvent event)
|
||||
{
|
||||
if (event.getNpc().equals(_npc))
|
||||
{
|
||||
_gameBoosterManager.getManager().getBoosterManager().openShop(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void one(PlayerInteractAtEntityEvent event)
|
||||
{
|
||||
|
@ -3,8 +3,13 @@ package nautilus.game.arcade.booster;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.boosters.event.BoosterActivateEvent;
|
||||
@ -18,38 +23,34 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.managers.lobby.LobbyManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
*/
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class GameBoosterManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private static final List<String> TESTING_GROUPS = Collections.singletonList("testing");
|
||||
|
||||
private String _boosterGroup;
|
||||
private final ArcadeManager _manager;
|
||||
private final BoosterManager _boosterManager;
|
||||
private final String _boosterGroup;
|
||||
|
||||
private BoosterManager _boosterManager;
|
||||
|
||||
public GameBoosterManager(JavaPlugin plugin, BoosterManager boosterManager, HologramManager hologramManager, NpcManager npcManager, String boosterGroup)
|
||||
private GameBoosterManager()
|
||||
{
|
||||
super("Arcade Boosters", plugin);
|
||||
super("Arcade Boosters");
|
||||
|
||||
_boosterGroup = boosterGroup;
|
||||
_boosterManager = boosterManager;
|
||||
_manager = require(ArcadeManager.class);
|
||||
|
||||
LobbyManager lobbyManager = Managers.get(ArcadeManager.class).GetLobby();
|
||||
if (boosterGroup != null && boosterGroup.length() > 0 && lobbyManager.getAmpStand() != null)
|
||||
_boosterGroup = _manager.GetServerConfig().BoosterGroup;
|
||||
_boosterManager = _manager.getBoosterManager();
|
||||
|
||||
LobbyManager lobbyManager = _manager.GetLobby();
|
||||
|
||||
if (_boosterGroup != null && _boosterGroup.length() > 0 && lobbyManager.getAmpStand() != null)
|
||||
{
|
||||
new BoosterPodium(plugin, this, hologramManager, npcManager, lobbyManager.getAmpStand());
|
||||
new BoosterPodium(this, _manager.getHologramManager(), lobbyManager.getAmpStand());
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,13 +69,15 @@ public class GameBoosterManager extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
_boosterManager.getBoosterThankManager().addTip(player, active, result -> {
|
||||
_boosterManager.getBoosterThankManager().addTip(player, active, result ->
|
||||
{
|
||||
if (result == TipAddResult.SUCCESS)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Thank", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got "
|
||||
+ F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER)) + " in return!");
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.getFriendlyMessage() != null)
|
||||
{
|
||||
@ -113,4 +116,9 @@ public class GameBoosterManager extends MiniPlugin
|
||||
message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
|
||||
public ArcadeManager getManager()
|
||||
{
|
||||
return _manager;
|
||||
}
|
||||
}
|
||||
|
@ -73,10 +73,9 @@ import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.lifetimes.Lifetimed;
|
||||
import mineplex.core.lifetimes.ListenerComponent;
|
||||
import mineplex.core.lifetimes.PhasedLifetime;
|
||||
import mineplex.core.mission.MissionTracker;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.preferences.Preference;
|
||||
import mineplex.core.quests.QuestManager;
|
||||
import mineplex.core.quests.event.QuestInteractEvent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -105,16 +104,8 @@ import nautilus.game.arcade.kit.LinearUpgradeKit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
import nautilus.game.arcade.managers.lobby.LobbyManager;
|
||||
import nautilus.game.arcade.quest.ChestOpenQuestTracker;
|
||||
import nautilus.game.arcade.quest.CollectQuestTracker;
|
||||
import nautilus.game.arcade.quest.FirstBloodQuestTracker;
|
||||
import nautilus.game.arcade.quest.HitQuestTracker;
|
||||
import nautilus.game.arcade.quest.KillEntityQuestTracker;
|
||||
import nautilus.game.arcade.quest.KillQuestTracker;
|
||||
import nautilus.game.arcade.quest.ParticipateQuestTracker;
|
||||
import nautilus.game.arcade.quest.PlayGameQuestTracker;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
import nautilus.game.arcade.quest.WinQuestTracker;
|
||||
import nautilus.game.arcade.missions.KillMissionTracker;
|
||||
import nautilus.game.arcade.missions.WinMissionTracker;
|
||||
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||
import nautilus.game.arcade.stats.AssistsStatTracker;
|
||||
import nautilus.game.arcade.stats.DamageDealtStatTracker;
|
||||
@ -399,7 +390,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
private NautHashMap<String, Long> _deadBodiesExpire = new NautHashMap<String, Long>();
|
||||
|
||||
private final Set<StatTracker<? extends Game>> _statTrackers = new HashSet<>();
|
||||
private final Set<QuestTracker<? extends Game>> _questTrackers = new HashSet<>();
|
||||
|
||||
public final WinEffectManager WinEffectManager = new WinEffectManager();
|
||||
public boolean WinEffectEnabled = true;
|
||||
@ -420,8 +410,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
|
||||
_lifetime.register(this);
|
||||
// Player List
|
||||
UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.getName(), "Visit " + C.cGreen + "www.mineplex.com"
|
||||
+ ChatColor.RESET + " for News, Forums and Shop");
|
||||
UtilTabTitle.broadcastHeaderAndFooter(C.cGoldB + gameType.getName(), "Visit " + C.cGreen + "www.mineplex.com" + C.Reset + " for News, Forums and Shop");
|
||||
|
||||
// Game
|
||||
_gameType = gameType;
|
||||
@ -435,21 +424,23 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
WorldData = new WorldData(this);
|
||||
|
||||
// Stat Trackers
|
||||
registerStatTrackers(new KillsStatTracker(this), new DeathsStatTracker(this), new AssistsStatTracker(this),
|
||||
new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
|
||||
this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
|
||||
|
||||
// Quest Trackers
|
||||
registerQuestTrackers(
|
||||
new WinQuestTracker(this),
|
||||
new KillQuestTracker(this),
|
||||
new CollectQuestTracker(this),
|
||||
new ChestOpenQuestTracker(this),
|
||||
new KillEntityQuestTracker(this),
|
||||
new PlayGameQuestTracker(this),
|
||||
new ParticipateQuestTracker(this),
|
||||
new HitQuestTracker(this),
|
||||
new FirstBloodQuestTracker(this));
|
||||
registerStatTrackers(
|
||||
new KillsStatTracker(this),
|
||||
new DeathsStatTracker(this),
|
||||
new AssistsStatTracker(this),
|
||||
new ExperienceStatTracker(this),
|
||||
new WinStatTracker(this),
|
||||
new LoseStatTracker(this),
|
||||
new DamageDealtStatTracker(this),
|
||||
new DamageTakenStatTracker(this),
|
||||
new GamesPlayedStatTracker(this)
|
||||
);
|
||||
|
||||
// Mission Tracks
|
||||
registerMissions(
|
||||
new WinMissionTracker(this),
|
||||
new KillMissionTracker(this)
|
||||
);
|
||||
|
||||
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
|
||||
|
||||
@ -1694,29 +1685,10 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
{
|
||||
return _statTrackers;
|
||||
}
|
||||
|
||||
public void registerQuestTrackers(QuestTracker<? extends Game>... questTrackers)
|
||||
|
||||
public void registerMissions(MissionTracker... trackers)
|
||||
{
|
||||
for (QuestTracker<? extends Game> tracker : questTrackers)
|
||||
{
|
||||
if (_questTrackers.add(tracker))
|
||||
Bukkit.getPluginManager().registerEvents(tracker, Manager.getPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<QuestTracker<? extends Game>> getQuestTrackers()
|
||||
{
|
||||
return _questTrackers;
|
||||
}
|
||||
|
||||
public <T extends QuestTracker<? extends Game>> T getQuestTracker(Class<T> clazz)
|
||||
{
|
||||
for (QuestTracker<? extends Game> tracker : _questTrackers)
|
||||
{
|
||||
if (tracker.getClass().equals(clazz))
|
||||
return clazz.cast(tracker);
|
||||
}
|
||||
return null;
|
||||
getArcadeManager().getMissionsManager().registerTrackers(trackers);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -2013,13 +1985,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
((CraftEntity) event.getEntity()).getHandle().dead = false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuestBuy(QuestInteractEvent event)
|
||||
{
|
||||
if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End)
|
||||
event.setCancelled("You can't interact with " + QuestManager.QUEST_NAME + "s while you are ingame!");
|
||||
}
|
||||
|
||||
public NautHashMap<String, Entity> getDeadBodies()
|
||||
{
|
||||
@ -2144,7 +2109,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
Managers.get(AntiHack.class).setStrict(false);
|
||||
getLifetime().end();
|
||||
getStatTrackers().forEach(HandlerList::unregisterAll);
|
||||
getQuestTrackers().forEach(HandlerList::unregisterAll);
|
||||
getArcadeManager().getMissionsManager().clearTrackers();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
@ -16,7 +17,6 @@ import nautilus.game.arcade.game.games.champions.kits.KitBrute;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitKnight;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitMage;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitRanger;
|
||||
import nautilus.game.arcade.game.games.champions.quests.FlagQuestTracker;
|
||||
import nautilus.game.arcade.game.games.common.CaptureTheFlag;
|
||||
import nautilus.game.arcade.game.modules.ChampionsModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -79,8 +79,6 @@ public class ChampionsCTF extends CaptureTheFlag
|
||||
new ClutchStatTracker(this, "Clutch"),
|
||||
new SpecialWinStatTracker(this, "SpecialWin")
|
||||
);
|
||||
|
||||
registerQuestTrackers(new FlagQuestTracker(this));
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
|
@ -1,9 +1,10 @@
|
||||
package nautilus.game.arcade.game.games.champions;
|
||||
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
@ -12,7 +13,6 @@ import nautilus.game.arcade.game.games.champions.kits.KitBrute;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitKnight;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitMage;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitRanger;
|
||||
import nautilus.game.arcade.game.games.champions.quests.CaptureQuestTracker;
|
||||
import nautilus.game.arcade.game.games.common.Domination;
|
||||
import nautilus.game.arcade.game.modules.ChampionsModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -68,8 +68,6 @@ public class ChampionsDominate extends Domination
|
||||
new TheLongestShotStatTracker(this),
|
||||
new SeismicSlamStatTracker(this)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new CaptureQuestTracker(this));
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
|
@ -1,32 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.champions.quests;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.games.champions.ChampionsDominate;
|
||||
import nautilus.game.arcade.game.games.champions.events.CaptureEvent;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* PointQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class CaptureQuestTracker extends QuestTracker<ChampionsDominate>
|
||||
{
|
||||
|
||||
public CaptureQuestTracker(ChampionsDominate game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void capture(CaptureEvent event)
|
||||
{
|
||||
for (Player player : event.getPlayers())
|
||||
incrementQuests(player, 1, "Point Capture");
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.champions.quests;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.games.common.CaptureTheFlag;
|
||||
import nautilus.game.arcade.game.games.common.ctf_data.PlayerCaptureFlagEvent;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* FlagQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class FlagQuestTracker extends QuestTracker<CaptureTheFlag>
|
||||
{
|
||||
|
||||
public FlagQuestTracker(CaptureTheFlag game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void captureFlag(PlayerCaptureFlagEvent event)
|
||||
{
|
||||
incrementQuests(event.GetPlayer(), 1, "Flag Capture");
|
||||
}
|
||||
|
||||
}
|
@ -66,7 +66,6 @@ import nautilus.game.arcade.game.games.dragonescape.kits.KitDigger;
|
||||
import nautilus.game.arcade.game.games.dragonescape.kits.KitDisruptor;
|
||||
import nautilus.game.arcade.game.games.dragonescape.kits.KitLeaper;
|
||||
import nautilus.game.arcade.game.games.dragonescape.kits.KitWarper;
|
||||
import nautilus.game.arcade.game.games.dragonescape.quests.DragonEscapeWinQuestTracker;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
@ -147,8 +146,6 @@ public class DragonEscape extends SoloGame
|
||||
new ChatStatData("kit", "Kit", true)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new DragonEscapeWinQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
.setGiveCompassToSpecs(true)
|
||||
@ -497,7 +494,6 @@ public class DragonEscape extends SoloGame
|
||||
if (places.size() >= 1)
|
||||
{
|
||||
AddGems(places.get(0), 20, "1st Place", false, false);
|
||||
getQuestTracker(DragonEscapeWinQuestTracker.class).increment(places.get(0));
|
||||
}
|
||||
|
||||
if (places.size() >= 2)
|
||||
|
@ -1,35 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.dragonescape.quests;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.Arcade;
|
||||
import nautilus.game.arcade.game.games.dragonescape.DragonEscape;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* DragonEscapeWinQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class DragonEscapeWinQuestTracker extends QuestTracker<DragonEscape>
|
||||
{
|
||||
|
||||
public DragonEscapeWinQuestTracker(DragonEscape game)
|
||||
{
|
||||
super(game, TriggerType.COMPLETE);
|
||||
}
|
||||
|
||||
public void increment(Player player)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit", "Parkour");
|
||||
}
|
||||
|
||||
}
|
@ -52,7 +52,6 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.GameScore;
|
||||
import nautilus.game.arcade.game.games.draw.kits.KitArtist;
|
||||
import nautilus.game.arcade.game.games.draw.quests.GuessQuestTracker;
|
||||
import nautilus.game.arcade.game.games.draw.tools.Tool;
|
||||
import nautilus.game.arcade.game.games.draw.tools.ToolCircle;
|
||||
import nautilus.game.arcade.game.games.draw.tools.ToolLine;
|
||||
@ -256,8 +255,6 @@ public class Draw extends SoloGame
|
||||
new DrawGuessStatTracker(this)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new GuessQuestTracker(this));
|
||||
|
||||
registerChatStats(
|
||||
new ChatStatData("TotalGuess", "Total Guesses", true),
|
||||
new ChatStatData("PureLuck", "Lucky Guesses", true)
|
||||
|
@ -1,36 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.draw.quests;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.draw.Draw;
|
||||
import nautilus.game.arcade.game.games.draw.DrawGuessCorrectlyEvent;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* GuesQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class GuessQuestTracker extends QuestTracker<Draw>
|
||||
{
|
||||
|
||||
public GuessQuestTracker(Draw game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onDrawGuessCorrectly(DrawGuessCorrectlyEvent event)
|
||||
{
|
||||
if (getGame().GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
if (System.currentTimeMillis() - event.getDrawRound().Time < 8000)
|
||||
incrementQuests(event.getPlayer(), 1, "Guesses");
|
||||
}
|
||||
|
||||
}
|
@ -114,7 +114,6 @@ import nautilus.game.arcade.game.games.hideseek.kits.KitHiderSwapper;
|
||||
import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerLeaper;
|
||||
import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerRadar;
|
||||
import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerTNT;
|
||||
import nautilus.game.arcade.game.games.hideseek.quests.DisguiseQuestTracker;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.game.team.selectors.RatioSelector;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -355,8 +354,6 @@ public class HideSeek extends TeamGame
|
||||
new BadHiderStatTracker(this)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new DisguiseQuestTracker(this));
|
||||
|
||||
//Need ideas for this one
|
||||
registerChatStats();
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.hideseek.quests;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.hideseek.HideSeek;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* DisguiseQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class DisguiseQuestTracker extends QuestTracker<HideSeek>
|
||||
{
|
||||
|
||||
public DisguiseQuestTracker(HideSeek game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onChangeForm(HideSeek.PlayerChangeFormEvent event)
|
||||
{
|
||||
if (getGame().GetState() != Game.GameState.Live)
|
||||
return;
|
||||
|
||||
incrementQuests(event.getPlayer(), 1, "Disguise");
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@ -58,6 +60,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -71,7 +74,6 @@ import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitRifle;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitShotgun;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitSniper;
|
||||
import nautilus.game.arcade.game.games.paintball.quests.ReviveQuestTracker;
|
||||
import nautilus.game.arcade.game.games.paintball.trackers.KillingSpreeTracker;
|
||||
import nautilus.game.arcade.game.games.paintball.trackers.LastStandStatTracker;
|
||||
import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker;
|
||||
@ -80,7 +82,6 @@ import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.stats.WinFastStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
|
||||
|
||||
public class Paintball extends TeamGame
|
||||
{
|
||||
@ -128,8 +129,6 @@ public class Paintball extends TeamGame
|
||||
DamageTaken,
|
||||
DamageDealt
|
||||
);
|
||||
|
||||
registerQuestTrackers(new ReviveQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
|
@ -1,32 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.paintball.quests;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.paintball.events.ReviveEvent;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* ReviveQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class ReviveQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public ReviveQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(ReviveEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
incrementQuests(event.getPlayer(), 1, "Revive", getGame().GetKit(event.getPlayer()).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -81,7 +81,6 @@ import nautilus.game.arcade.game.games.skyfall.kits.KitDeadeye;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitJouster;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitSpeeder;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitStunner;
|
||||
import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker;
|
||||
import nautilus.game.arcade.game.games.skyfall.stats.AeronaughtStatTracker;
|
||||
import nautilus.game.arcade.game.games.skyfall.stats.RingStatTracker;
|
||||
import nautilus.game.arcade.game.modules.VersionModule;
|
||||
@ -189,9 +188,7 @@ public abstract class Skyfall extends Game
|
||||
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),
|
||||
new RingStatTracker(this),
|
||||
new AeronaughtStatTracker(this));
|
||||
|
||||
registerQuestTrackers(new RingQuestTracker(this));
|
||||
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
Assists,
|
||||
|
@ -1,37 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.skyfall.quests;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.games.skyfall.PlayerBoostRingEvent;
|
||||
import nautilus.game.arcade.game.games.skyfall.Skyfall;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* BoosterRingQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class RingQuestTracker extends QuestTracker<Skyfall>
|
||||
{
|
||||
|
||||
public RingQuestTracker(Skyfall game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void boosterRing(PlayerBoostRingEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (!getGame().IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
incrementQuests(event.getPlayer(), 1, "Booster Rings", getGame().GetKit(event.getPlayer()).GetName() + "Kit");
|
||||
}
|
||||
|
||||
}
|
@ -90,7 +90,6 @@ import nautilus.game.arcade.game.games.speedbuilders.data.MobData;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.data.RecreationData;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.kits.DefaultKit;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.quests.PerfectBuildQuestTracker;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker;
|
||||
@ -203,8 +202,6 @@ public class SpeedBuilders extends SoloGame
|
||||
new BlockPlaceStatTracker(this, new Material[]{})
|
||||
);
|
||||
|
||||
registerQuestTrackers(new PerfectBuildQuestTracker(this));
|
||||
|
||||
registerChatStats(
|
||||
new ChatStatData("BlocksPlaced", "Blocks Placed", true),
|
||||
new ChatStatData("BlocksBroken", "Blocks Broken", true)
|
||||
|
@ -1,29 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.speedbuilders.quests;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
|
||||
import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* PerfectBuildQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class PerfectBuildQuestTracker extends QuestTracker<SpeedBuilders>
|
||||
{
|
||||
|
||||
public PerfectBuildQuestTracker(SpeedBuilders game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPerfectBuild(PerfectBuildEvent event)
|
||||
{
|
||||
incrementQuests(event.getPlayer(), 1, "Perfect Build");
|
||||
}
|
||||
}
|
@ -60,7 +60,6 @@ import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.turfforts.kits.KitInfiltrator;
|
||||
import nautilus.game.arcade.game.games.turfforts.kits.KitMarksman;
|
||||
import nautilus.game.arcade.game.games.turfforts.kits.KitShredder;
|
||||
import nautilus.game.arcade.game.games.turfforts.quests.BlockBreakQuestTracker;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
@ -174,8 +173,6 @@ public class TurfForts extends TeamGame
|
||||
new ChatStatData("BlocksBroken", "Blocks Broken", true)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new BlockBreakQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
.setGiveCompassToSpecs(true)
|
||||
|
@ -1,33 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.turfforts.quests;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.turfforts.TurfForts;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* BlockBreakQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class BlockBreakQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public BlockBreakQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(TurfForts.ShredBlockEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
incrementQuests((Player) event.getArrow().getShooter(), 1, "Block Break", getGame().GetKit((Player) event.getArrow().getShooter()).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -105,15 +105,14 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.modules.AbsorptionFix;
|
||||
import nautilus.game.arcade.game.games.uhc.components.UHCBorder;
|
||||
import nautilus.game.arcade.game.games.uhc.components.UHCFreezer;
|
||||
import nautilus.game.arcade.game.games.uhc.components.UHCSpeedMode;
|
||||
import nautilus.game.arcade.game.games.uhc.quests.TameQuestTracker;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.CollectFoodStat;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.HalfHeartHealStat;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.HoeCraftingStat;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.LuckyMinerStat;
|
||||
import nautilus.game.arcade.game.modules.AbsorptionFix;
|
||||
import nautilus.game.arcade.game.modules.OreVeinEditorModule;
|
||||
import nautilus.game.arcade.game.modules.PlayerHeadModule;
|
||||
import nautilus.game.arcade.game.modules.RejoinModule;
|
||||
@ -312,8 +311,6 @@ public abstract class UHC extends Game
|
||||
|
||||
registerStatTrackers(new CollectFoodStat(this), new HoeCraftingStat(this), new LuckyMinerStat(this), new HalfHeartHealStat(this));
|
||||
|
||||
registerQuestTrackers(new TameQuestTracker(this));
|
||||
|
||||
registerDebugCommand("startpvp", Perm.DEBUG_STARTPVP_COMMAND, PermissionGroup.ADMIN, (caller, args) ->
|
||||
{
|
||||
if (!IsLive())
|
||||
|
@ -1,38 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.uhc.quests;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.quest.QuestTracker;
|
||||
|
||||
/**
|
||||
* TameQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class TameQuestTracker extends QuestTracker<UHC>
|
||||
{
|
||||
|
||||
public TameQuestTracker(UHC game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void tameEvent(EntityTameEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.getEntityType() != EntityType.HORSE)
|
||||
return;
|
||||
|
||||
incrementQuests((Player) event.getOwner(), 1, "Tamed Horse");
|
||||
}
|
||||
|
||||
}
|
@ -97,14 +97,8 @@ public class GameStatManager implements Listener
|
||||
if (event.GetState() == GameState.End)
|
||||
{
|
||||
for (StatTracker tracker : event.GetGame().getStatTrackers())
|
||||
HandlerList.unregisterAll(tracker);
|
||||
|
||||
if (event.GetGame().CanAddStats)
|
||||
{
|
||||
//Manager.saveBasicStats(event.GetGame());
|
||||
|
||||
//if (Manager.IsTournamentServer())
|
||||
// Manager.saveLeaderboardStats(event.GetGame());
|
||||
HandlerList.unregisterAll(tracker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import mineplex.core.common.util.UtilLambda;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
|
||||
import mineplex.core.gadget.gadgets.item.ItemTrampoline;
|
||||
import mineplex.core.game.kit.GameKit;
|
||||
@ -69,7 +68,6 @@ public abstract class LobbyManager implements Listener
|
||||
private final Map<Block, Material> _teamBlocks;
|
||||
private final Map<Block, Material> _kitBlocks;
|
||||
|
||||
private String _serverName;
|
||||
private int _advertiseStage = 0;
|
||||
private long _fireworkStart;
|
||||
private Color _fireworkColor;
|
||||
@ -82,7 +80,7 @@ public abstract class LobbyManager implements Listener
|
||||
private Location _missions;
|
||||
private Location _spawn;
|
||||
private Location _ampStand;
|
||||
private boolean _generatePodiums = false;
|
||||
private boolean _generatePodiums;
|
||||
|
||||
public LobbyManager(ArcadeManager manager, Location missions, Location carl, Location spawn, Location ampStand)
|
||||
{
|
||||
@ -98,6 +96,7 @@ public abstract class LobbyManager implements Listener
|
||||
setTeamText(new Location(WORLD, 40, 80, 0));
|
||||
setAdvText(new Location(WORLD, 0, 100, -60));
|
||||
|
||||
_missions = missions;
|
||||
_carl = carl;
|
||||
_spawn = spawn;
|
||||
_ampStand = ampStand;
|
||||
@ -106,8 +105,6 @@ public abstract class LobbyManager implements Listener
|
||||
_teamBlocks = Maps.newHashMap();
|
||||
_kitBlocks = Maps.newHashMap();
|
||||
|
||||
_serverName = _manager.getPlugin().getConfig().getString("serverstatus.name");
|
||||
_serverName = _serverName.substring(0, Math.min(16, _serverName.length()));
|
||||
_serverGroup = _manager.GetServerConfig().ServerGroup;
|
||||
|
||||
_generatePodiums = new File("world/GENPODIUMS.dat").exists() || manager.GetHost() != null;
|
||||
@ -239,7 +236,7 @@ public abstract class LobbyManager implements Listener
|
||||
else if (event.getType() == UpdateType.FASTEST)
|
||||
{
|
||||
UpdateFirework();
|
||||
PlayerSelector.selectPlayers(UtilLambda.and(PlayerSelector.inWorld(Bukkit.getWorld("world")), UtilLambda.not(PlayerSelector.within(getSpawn(), 100))))
|
||||
PlayerSelector.selectPlayers(UtilLambda.and(PlayerSelector.inWorld(WORLD), UtilLambda.not(PlayerSelector.within(getSpawn(), 100))))
|
||||
.forEach(player -> player.teleport(getSpawn()));
|
||||
}
|
||||
else if (event.getType() == UpdateType.SLOW)
|
||||
@ -269,7 +266,7 @@ public abstract class LobbyManager implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entity ent : UtilWorld.getWorld("world").getEntities())
|
||||
for (Entity ent : WORLD.getEntities())
|
||||
{
|
||||
if (ent instanceof Creature || ent instanceof Slime)
|
||||
{
|
||||
|
@ -37,16 +37,23 @@ public class LegacyGameLobbyManager extends LobbyManager
|
||||
|
||||
public LegacyGameLobbyManager(ArcadeManager manager)
|
||||
{
|
||||
super(manager, null, null, null, new Location(UtilWorld.getWorld("world"), 0, 102.5, -15));
|
||||
|
||||
setSpawn(new Location(WORLD, 0, 104, 0, 0, 0));
|
||||
super(
|
||||
manager,
|
||||
// Missions
|
||||
new Location(WORLD, -3.5, 102, 3.5, -145, 0),
|
||||
null,
|
||||
// Spawn
|
||||
new Location(WORLD, 0, 104, 0),
|
||||
// Amp Stand
|
||||
new Location(WORLD, 0, 102.5, -15)
|
||||
);
|
||||
|
||||
setGameText(new Location(WORLD, 0, 130, 50));
|
||||
setKitText(new Location(WORLD, -40, 120, 0));
|
||||
setTeamText(new Location(WORLD, 40, 120, 0));
|
||||
setAdvText(new Location(WORLD, 0, 140, -60));
|
||||
|
||||
setPodium(new Location(UtilWorld.getWorld("world"), 0, 101.5, -15), Material.EMERALD_BLOCK.getId(), (byte) 0);
|
||||
setPodium(new Location(WORLD, 0, 101.5, -15), Material.EMERALD_BLOCK.getId(), (byte) 0);
|
||||
|
||||
_kitDisplay = new Location(WORLD, -17, 101, 0);
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
package nautilus.game.arcade.missions;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.mission.MissionTracker;
|
||||
import mineplex.core.mission.MissionTrackerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
public class GameMissionTracker<T, U extends Game> extends MissionTracker<T>
|
||||
{
|
||||
|
||||
protected final U _game;
|
||||
|
||||
GameMissionTracker(MissionTrackerType trackerType, U game)
|
||||
{
|
||||
super(game.getArcadeManager().getMissionsManager(), trackerType);
|
||||
|
||||
_game = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void incrementProgress(Player player, int amount, T data)
|
||||
{
|
||||
if (!_game.CanAddStats || !_game.getArcadeManager().IsRewardStats())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
super.incrementProgress(player, amount, data);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package nautilus.game.arcade.missions;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.mission.MissionTrackerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
public class KillMissionTracker extends GameMissionTracker<GameDisplay, Game>
|
||||
{
|
||||
|
||||
public KillMissionTracker(Game game)
|
||||
{
|
||||
super(MissionTrackerType.GAME_KILL, game);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void playerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Player killer = event.getEntity().getKiller();
|
||||
|
||||
if (killer != null)
|
||||
{
|
||||
incrementProgress(killer, 1, _game.GetType().getDisplay());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package nautilus.game.arcade.missions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.mission.MissionTrackerType;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
public class WinMissionTracker extends GameMissionTracker<GameDisplay, Game>
|
||||
{
|
||||
|
||||
public WinMissionTracker(Game game)
|
||||
{
|
||||
super(MissionTrackerType.GAME_WIN, game);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void gameEnd(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> winners = event.GetGame().getWinners();
|
||||
|
||||
if (winners == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
winners.forEach(player -> incrementProgress(player, 1, _game.GetType().getDisplay()));
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* ChestOpenQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class ChestOpenQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
private HashMap<Player, ArrayList<Location>> _usedChests = new HashMap<>();
|
||||
|
||||
public ChestOpenQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void chestRegister(PlayerInteractEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if (!getGame().IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
if (!_usedChests.containsKey(event.getPlayer()))
|
||||
_usedChests.put(event.getPlayer(), new ArrayList<>());
|
||||
|
||||
ArrayList<Location> locs = _usedChests.get(event.getPlayer());
|
||||
|
||||
if (locs.contains(event.getClickedBlock().getLocation()))
|
||||
return;
|
||||
|
||||
locs.add(event.getClickedBlock().getLocation());
|
||||
|
||||
incrementQuests((Player) event.getPlayer(), 1, "Chest");
|
||||
}
|
||||
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.events.ChestRefillEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* CollectQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class CollectQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
private ArrayList<ItemStack> _itemsAvailable = new ArrayList<>();
|
||||
private ArrayList<ItemStack> _badItems = new ArrayList<>();
|
||||
private ArrayList<Location> _usedChests = new ArrayList<>();
|
||||
private ArrayList<Location> _usedBlocks = new ArrayList<>();
|
||||
|
||||
public CollectQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.COLLECT);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void chestRefill(ChestRefillEvent event)
|
||||
{
|
||||
_usedChests.removeAll(event.getChests());
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void blockRegister(BlockPlaceEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.getBlockPlaced().getType() == Material.IRON_ORE
|
||||
|| event.getBlockPlaced().getType() == Material.GOLD_ORE)
|
||||
{
|
||||
_usedBlocks.add(event.getBlock().getLocation());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void itemRegister(PlayerDropItemEvent event)
|
||||
{
|
||||
_badItems.add(event.getItemDrop().getItemStack());
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void itemRegister(BlockBreakEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (!_usedBlocks.contains(event.getBlock().getLocation()))
|
||||
return;
|
||||
|
||||
for (ItemStack item : event.getBlock().getDrops())
|
||||
{
|
||||
_badItems.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void itemPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
ItemStack item = event.getItem().getItemStack();
|
||||
|
||||
if (_badItems.contains(item))
|
||||
{
|
||||
_badItems.remove(item);
|
||||
return;
|
||||
}
|
||||
String itemName = item.getType().toString();
|
||||
|
||||
if (item.hasItemMeta())
|
||||
itemName = item.getItemMeta().getDisplayName();
|
||||
|
||||
incrementQuests(event.getPlayer(), item.getAmount(), ChatColor.stripColor(itemName));
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void chestRegister(PlayerInteractEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
if (_usedChests.contains(event.getClickedBlock().getLocation()))
|
||||
return;
|
||||
|
||||
Chest chest = (Chest) event.getClickedBlock().getState();
|
||||
|
||||
if (chest instanceof DoubleChest)
|
||||
{
|
||||
DoubleChest doubleChest = (DoubleChest) chest;
|
||||
for (ItemStack item : doubleChest.getLeftSide().getInventory())
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
_itemsAvailable.add(item);
|
||||
}
|
||||
for (ItemStack item : doubleChest.getRightSide().getInventory())
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
_itemsAvailable.add(item);
|
||||
}
|
||||
}
|
||||
else if (chest instanceof Chest)
|
||||
{
|
||||
for (ItemStack item : chest.getInventory())
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
_itemsAvailable.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
_usedChests.add(event.getClickedBlock().getLocation());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void collectItem(InventoryClickEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.getClickedInventory() instanceof PlayerInventory)
|
||||
return;
|
||||
|
||||
if (!_itemsAvailable.contains(event.getCurrentItem()))
|
||||
return;
|
||||
|
||||
_itemsAvailable.remove(event.getCurrentItem());
|
||||
|
||||
String item = event.getCurrentItem().getType().toString();
|
||||
|
||||
if (event.getCurrentItem().hasItemMeta())
|
||||
item = event.getCurrentItem().getItemMeta().getDisplayName();
|
||||
|
||||
incrementQuests((Player) event.getWhoClicked(), event.getCurrentItem().getAmount(), ChatColor.stripColor(item));
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.events.FirstBloodEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* FirstBloodQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class FirstBloodQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public FirstBloodQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.FIRST_BLOOD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(FirstBloodEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
incrementQuests(event.getPlayer(), 1, getGame().GetKit(event.getPlayer()).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* HitQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class HitQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public HitQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.HIT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Item))
|
||||
return;
|
||||
|
||||
|
||||
Item itemEntity = (Item) event.getEntity();
|
||||
String item = itemEntity.getItemStack().getType().toString();
|
||||
|
||||
incrementQuests((Player) event.getDamager(), 1, "Player", item, getGame().GetKit((Player) event.getDamager()).GetName() + "Kit");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileHit(CustomDamageEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.GetReason() == null)
|
||||
return;
|
||||
|
||||
if (!event.GetReason().contains("Axe Thrower"))
|
||||
return;
|
||||
|
||||
incrementQuests(event.GetDamagerPlayer(true), 1, "Player", "Axe", getGame().GetKit(event.GetDamagerPlayer(true)).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* KillEntityQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class KillEntityQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public KillEntityQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.KILL);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void killEntity(EntityDeathEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
LivingEntity lEntity = event.getEntity();
|
||||
|
||||
if (!(lEntity.getKiller() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = lEntity.getKiller();
|
||||
|
||||
if (lEntity instanceof Player)
|
||||
return;
|
||||
|
||||
String name = lEntity.getType().getName();
|
||||
|
||||
if (lEntity.isCustomNameVisible())
|
||||
name = lEntity.getCustomName();
|
||||
|
||||
incrementQuests((Player) player, 1, ChatColor.stripColor(name), getGame().GetKit(player).GetName() + "Kit");
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.quests.TriggerType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* WInQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class KillQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public KillQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.KILL);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKill(CombatDeathEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.GetLog().GetKiller() == null)
|
||||
return;
|
||||
|
||||
if (!event.GetLog().GetKiller().IsPlayer())
|
||||
return;
|
||||
|
||||
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
incrementQuests(player, 1, "Player", getGame().GetKit(player).GetName() + "Kit");
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.Arcade;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
/**
|
||||
* ParticipateQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class ParticipateQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public ParticipateQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.COMPLETE);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void completeGame(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End)
|
||||
return;
|
||||
|
||||
for (Player player : getGame().GetPlayers(true))
|
||||
incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit");
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.Arcade;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
/**
|
||||
* PlayGameQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class PlayGameQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public PlayGameQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.PLAY);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void gameStart(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
for (Player player : getGame().GetPlayers(true))
|
||||
incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit");
|
||||
}
|
||||
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.quests.Quest;
|
||||
import mineplex.core.quests.QuestClientData;
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
/**
|
||||
* QuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class QuestTracker<T extends Game> implements Listener
|
||||
{
|
||||
private T _game;
|
||||
private TriggerType _trigger;
|
||||
|
||||
public QuestTracker(T game, TriggerType type)
|
||||
{
|
||||
_game = game;
|
||||
_trigger = type;
|
||||
}
|
||||
|
||||
public T getGame()
|
||||
{
|
||||
return _game;
|
||||
}
|
||||
|
||||
public boolean canProgressQuests()
|
||||
{
|
||||
return getGame().CanAddStats;
|
||||
}
|
||||
|
||||
public void incrementQuests(Player player, int value)
|
||||
{
|
||||
incrementQuests(player, value, "");
|
||||
}
|
||||
|
||||
public void incrementQuests(Player player, int value, String... items)
|
||||
{
|
||||
if (getGame().getArcadeManager().GetGameHostManager().isPrivateServer())
|
||||
return;
|
||||
|
||||
if (canProgressQuests())
|
||||
{
|
||||
for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests())
|
||||
{
|
||||
if (!quest.isGeneral())
|
||||
{
|
||||
if (getGame().GetType().getDisplay() != quest.getGame() && getGame().GetType().getDisplay().getGameCategory() != quest.getGameCategory())
|
||||
continue;
|
||||
}
|
||||
|
||||
if (quest.getTrigger() != _trigger)
|
||||
continue;
|
||||
|
||||
if (!quest.getItem()[0].equalsIgnoreCase(""))
|
||||
{
|
||||
boolean cont = true;
|
||||
for (String questItem : quest.getItem())
|
||||
{
|
||||
for (String str : items)
|
||||
{
|
||||
if (str == null || str.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String first = str.replaceAll(" ", "");
|
||||
String compare = questItem.replaceAll(" ", "");
|
||||
|
||||
if (first.equalsIgnoreCase(compare))
|
||||
{
|
||||
cont = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
cont = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cont)
|
||||
continue;
|
||||
}
|
||||
|
||||
QuestClientData data = _game.getArcadeManager().getQuestManager().Get(player);
|
||||
if (!data.hasQuest(quest))
|
||||
continue;
|
||||
|
||||
Quest toProgress = data.getQuest(quest.getID());
|
||||
|
||||
_game.getArcadeManager().getQuestManager().incrementQuest(player, toProgress, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TriggerType getTrigger()
|
||||
{
|
||||
return _trigger;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.quests.TriggerType;
|
||||
|
||||
import nautilus.game.arcade.Arcade;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
/**
|
||||
* WinQuestTracker
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class WinQuestTracker extends QuestTracker<Game>
|
||||
{
|
||||
|
||||
public WinQuestTracker(Game game)
|
||||
{
|
||||
super(game, TriggerType.WIN);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWin(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End)
|
||||
return;
|
||||
|
||||
List<Player> winners = getGame().getWinners();
|
||||
|
||||
if (winners == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : winners)
|
||||
{
|
||||
Kit kit = getGame().GetKit(player);
|
||||
if (kit != null)
|
||||
{
|
||||
incrementQuests(player, 1,
|
||||
((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(),
|
||||
kit.GetName() + "Kit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user