Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/moba
This commit is contained in:
commit
17ba7ffe8a
@ -43,7 +43,7 @@ public enum AchievementCategory
|
||||
StatDisplay.fromGame("Wins", GameDisplay.SkywarsTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkywarsTeams, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.SkywarsTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkywarsTeams, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.SkywarsTeams, "GemsEarned") },
|
||||
Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()),
|
||||
Material.FEATHER, 0, GameCategory.SURVIVAL, "Earth Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()),
|
||||
|
||||
UHC("Ultra Hardcore", null,
|
||||
new StatDisplay[] {
|
||||
|
@ -14,7 +14,7 @@ public class ServerInfoMetadata extends AnticheatMetadata
|
||||
private static final String KEY_SERVER_NAME = "server-name";
|
||||
private static final String KEY_SERVER_REGION = "server-region";
|
||||
private static final String KEY_SERVER_GROUP = "server-group";
|
||||
private static final String KEY_SERVER_TPS = "";
|
||||
private static final String KEY_SERVER_TPS = "server-tps";
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
|
@ -250,6 +250,19 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
}
|
||||
argHandle.add(arg);
|
||||
}
|
||||
|
||||
else if (arg.equalsIgnoreCase("wither"))
|
||||
{
|
||||
for (Entity ent : entSet)
|
||||
{
|
||||
if (ent instanceof Skeleton)
|
||||
{
|
||||
((Skeleton) ent).setSkeletonType(SkeletonType.WITHER);
|
||||
}
|
||||
}
|
||||
|
||||
argHandle.add(arg);
|
||||
}
|
||||
}
|
||||
for (String arg : argHandle)
|
||||
argSet.remove(arg);
|
||||
|
@ -15,13 +15,13 @@ import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType;
|
||||
|
||||
public class Leaderboard
|
||||
{
|
||||
private String _display;
|
||||
private Pair<String, String> _statDisplay;
|
||||
private String[] _statNames;
|
||||
private int[] _statIds;
|
||||
private int _size, _start;
|
||||
private LeaderboardSQLType _type;
|
||||
private Location _loc;
|
||||
private final String _display;
|
||||
private final Pair<String, String> _statDisplay;
|
||||
private final String[] _statNames;
|
||||
private final int[] _statIds;
|
||||
private final int _size, _start;
|
||||
private final LeaderboardSQLType _type;
|
||||
private final Location _loc;
|
||||
private Hologram _holo;
|
||||
|
||||
public Leaderboard(String display, Pair<String, String> statDisplayNames, String[] statNames, LeaderboardSQLType type, Location displayLoc, int size)
|
||||
@ -37,6 +37,7 @@ public class Leaderboard
|
||||
_statIds = new int[_statNames.length];
|
||||
_type = type;
|
||||
_size = size;
|
||||
_start = start;
|
||||
_loc = displayLoc;
|
||||
|
||||
update(new LinkedHashMap<>());
|
||||
@ -52,12 +53,15 @@ public class Leaderboard
|
||||
return _start;
|
||||
}
|
||||
|
||||
/**
|
||||
* The returned array is not safe for mutation
|
||||
*/
|
||||
public String[] getStatNames()
|
||||
{
|
||||
return _statNames;
|
||||
}
|
||||
|
||||
public int[] getStatIds()
|
||||
public synchronized int[] getStatIds()
|
||||
{
|
||||
return _statIds;
|
||||
}
|
||||
@ -89,6 +93,14 @@ public class Leaderboard
|
||||
_holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, display.toArray(new String[display.size()])).start();
|
||||
}
|
||||
|
||||
public synchronized void setStatId(int index, int id)
|
||||
{
|
||||
if (_statIds.length > index && index >= 0)
|
||||
{
|
||||
_statIds[index] = id;
|
||||
}
|
||||
}
|
||||
|
||||
public void deconstruct()
|
||||
{
|
||||
if (_holo != null)
|
||||
|
@ -120,7 +120,7 @@ public class LeaderboardManager extends MiniPlugin
|
||||
final int index = i;
|
||||
Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id ->
|
||||
{
|
||||
board.getStatIds()[index] = id.intValue();
|
||||
board.setStatId(index, id.intValue());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -90,73 +90,79 @@ public class LeaderboardRepository extends RepositoryBase
|
||||
|
||||
public void insertStats(int accountId, Map<Integer, Long> stats)
|
||||
{
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT);
|
||||
PreparedStatement insertStat = c.prepareStatement(INSERT_STAT);
|
||||
)
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
for (Integer statId : stats.keySet())
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT);
|
||||
PreparedStatement insertStat = c.prepareStatement(INSERT_STAT);
|
||||
)
|
||||
{
|
||||
updateStat.setLong(1, stats.get(statId));
|
||||
updateStat.setInt(2, accountId);
|
||||
updateStat.setInt(3, statId);
|
||||
updateStat.addBatch();
|
||||
}
|
||||
int[] rowsAffected = updateStat.executeBatch();
|
||||
int i = 0;
|
||||
for (Integer statId : stats.keySet())
|
||||
{
|
||||
if (rowsAffected[i] < 1)
|
||||
for (Integer statId : stats.keySet())
|
||||
{
|
||||
insertStat.setInt(1, accountId);
|
||||
insertStat.setInt(2, statId);
|
||||
insertStat.setLong(3, stats.get(statId));
|
||||
insertStat.addBatch();
|
||||
updateStat.setLong(1, stats.get(statId));
|
||||
updateStat.setInt(2, accountId);
|
||||
updateStat.setInt(3, statId);
|
||||
updateStat.addBatch();
|
||||
}
|
||||
i++;
|
||||
int[] rowsAffected = updateStat.executeBatch();
|
||||
int i = 0;
|
||||
for (Integer statId : stats.keySet())
|
||||
{
|
||||
if (rowsAffected[i] < 1)
|
||||
{
|
||||
insertStat.setInt(1, accountId);
|
||||
insertStat.setInt(2, statId);
|
||||
insertStat.setLong(3, stats.get(statId));
|
||||
insertStat.addBatch();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
insertStat.executeBatch();
|
||||
}
|
||||
insertStat.executeBatch();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadLeaderboard(Leaderboard board, Consumer<Map<String, Integer>> leaderboard)
|
||||
{
|
||||
Map<String, Integer> names = new LinkedHashMap<>();
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
Statement s = c.createStatement();
|
||||
)
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize()));
|
||||
for (int i = 0; i < board.getStatIds().length; i++)
|
||||
Map<String, Integer> names = new LinkedHashMap<>();
|
||||
try (
|
||||
Connection c = getConnection();
|
||||
Statement s = c.createStatement();
|
||||
)
|
||||
{
|
||||
try (ResultSet rs = s.getResultSet())
|
||||
s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize()));
|
||||
for (int i = 0; i < board.getStatIds().length; i++)
|
||||
{
|
||||
while (rs.next())
|
||||
try (ResultSet rs = s.getResultSet())
|
||||
{
|
||||
names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum);
|
||||
}
|
||||
|
||||
if (!s.getMoreResults())
|
||||
{
|
||||
break;
|
||||
while (rs.next())
|
||||
{
|
||||
names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum);
|
||||
}
|
||||
|
||||
if (!s.getMoreResults())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
UtilServer.runSync(() -> leaderboard.accept(names));
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
UtilServer.runSync(() -> leaderboard.accept(names));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -42,6 +42,12 @@ public class LagMeter extends MiniPlugin
|
||||
_start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new VersionsCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
|
@ -0,0 +1,74 @@
|
||||
package mineplex.core.monitor;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
/**
|
||||
* Statistics on versions
|
||||
* @author Dan
|
||||
*/
|
||||
public class VersionsCommand extends CommandBase<LagMeter>
|
||||
{
|
||||
public VersionsCommand(LagMeter plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "versions", "getver");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
Map<Integer, Integer> versions = new HashMap<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
int version = ((CraftPlayer) player).getHandle().getProtocol();
|
||||
int players = versions.getOrDefault(version, 0);
|
||||
versions.put(version, players + 1);
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Version", "Distribution on " + C.cGold
|
||||
+ UtilServer.getServerName()));
|
||||
|
||||
List<Map.Entry<Integer, Integer>> sorted = versions
|
||||
.entrySet().stream()
|
||||
.sorted(Comparator.comparing(Map.Entry::getValue, (i1, i2) -> -i1.compareTo(i2)))
|
||||
.collect(Collectors.toList());
|
||||
for (Map.Entry<Integer, Integer> entry : sorted)
|
||||
{
|
||||
UtilPlayer.message(caller,
|
||||
F.main("Version", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen
|
||||
+ entry.getValue() + C.cGray + " players"));
|
||||
}
|
||||
} else if (args.length == 1)
|
||||
{
|
||||
List<Player> players = UtilPlayer.matchOnline(caller, args[0], true);
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
Player player = players.get(0);
|
||||
UtilPlayer.message(caller,
|
||||
F.main("Version", C.cYellow + player.getName() + C.cGray + " is on protocol "
|
||||
+ C.cGreen + ((CraftPlayer) player).getHandle().getProtocol()));
|
||||
}
|
||||
} else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Version", "Invalid argument list."));
|
||||
}
|
||||
}
|
||||
}
|
@ -132,7 +132,7 @@ public class Portal extends MiniPlugin
|
||||
{
|
||||
if (server.getGroup().equalsIgnoreCase("Clans") && server.getMotd().equalsIgnoreCase("Restarting soon"))
|
||||
{
|
||||
UtilPlayer.message(player, F.main(getName(), C.cGold + "serverName" + C.cRed + " is restarting!"));
|
||||
UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is restarting!"));
|
||||
return;
|
||||
}
|
||||
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA))
|
||||
|
@ -8,7 +8,7 @@ package mineplex.core.quests;
|
||||
public enum TriggerType
|
||||
{
|
||||
|
||||
KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete");
|
||||
KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"), HIT("Hit"), FIRST_BLOOD("First Blood");
|
||||
|
||||
private String _name;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.quests.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -7,6 +9,7 @@ import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
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;
|
||||
|
||||
@ -37,19 +40,44 @@ public class GetQuestCommand extends CommandBase<QuestManager>
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = caller;
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (UtilPlayer.searchExact(args[1]) != null)
|
||||
player = UtilPlayer.searchExact(args[1]);
|
||||
{
|
||||
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]));
|
||||
|
||||
Plugin.addNewQuest(player, quest);
|
||||
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName()));
|
||||
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 (caller != player)
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ public class SeniorModeratorTrack extends ItemizedTrack
|
||||
|
||||
public SeniorModeratorTrack()
|
||||
{
|
||||
super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "I my team is the best team", "Team loyalty at its finest", true);
|
||||
super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "My Team's the Best Team", "Team loyalty at its finest", true);
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
"I think my team is the best team",
|
||||
"My Team's the Best Team",
|
||||
null,
|
||||
this::owns,
|
||||
new TrackFormat(ChatColor.GOLD, ChatColor.GOLD)
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.arcadeevents.CoreGameStartEvent;
|
||||
import mineplex.core.arcadeevents.CoreGameStopEvent;
|
||||
@ -43,6 +44,8 @@ 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;
|
||||
@ -436,7 +439,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
new ChestOpenQuestTracker(this),
|
||||
new KillEntityQuestTracker(this),
|
||||
new PlayGameQuestTracker(this),
|
||||
new ParticipateQuestTracker(this));
|
||||
new ParticipateQuestTracker(this),
|
||||
new HitQuestTracker(this),
|
||||
new FirstBloodQuestTracker(this));
|
||||
|
||||
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
|
||||
|
||||
@ -1774,6 +1779,16 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakEvent event)
|
||||
@ -2053,7 +2068,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
public void onQuestBuy(QuestInteractEvent event)
|
||||
{
|
||||
if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End)
|
||||
event.setCancelled("You cant interact with " + QuestManager.QUEST_NAME + "s while you are ingame!");
|
||||
event.setCancelled("You can't interact with " + QuestManager.QUEST_NAME + "s while you are ingame!");
|
||||
}
|
||||
|
||||
public NautHashMap<String, Entity> getDeadBodies()
|
||||
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@ -34,6 +33,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.block.BlockData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -52,6 +52,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -61,6 +62,7 @@ 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;
|
||||
@ -143,6 +145,8 @@ public class DragonEscape extends SoloGame
|
||||
BlankLine,
|
||||
new ChatStatData("kit", "Kit", true)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new DragonEscapeWinQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
@ -486,7 +490,10 @@ public class DragonEscape extends SoloGame
|
||||
AddGems(_winner, 10, "Course Complete", false, false);
|
||||
|
||||
if (places.size() >= 1)
|
||||
{
|
||||
AddGems(places.get(0), 20, "1st Place", false, false);
|
||||
getQuestTracker(DragonEscapeWinQuestTracker.class).increment(places.get(0));
|
||||
}
|
||||
|
||||
if (places.size() >= 2)
|
||||
AddGems(places.get(1), 15, "2nd Place", false, false);
|
||||
|
@ -0,0 +1,30 @@
|
||||
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)
|
||||
{
|
||||
incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit", "Parkour");
|
||||
}
|
||||
|
||||
}
|
@ -71,6 +71,7 @@ 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;
|
||||
@ -125,6 +126,8 @@ public class Paintball extends TeamGame
|
||||
DamageTaken,
|
||||
DamageDealt
|
||||
);
|
||||
|
||||
registerQuestTrackers(new ReviveQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
|
@ -0,0 +1,32 @@
|
||||
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");
|
||||
}
|
||||
}
|
@ -58,6 +58,7 @@ 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;
|
||||
@ -171,6 +172,7 @@ public class TurfForts extends TeamGame
|
||||
new ChatStatData("BlocksBroken", "Blocks Broken", true)
|
||||
);
|
||||
|
||||
registerQuestTrackers(new BlockBreakQuestTracker(this));
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
|
@ -0,0 +1,33 @@
|
||||
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");
|
||||
}
|
||||
}
|
@ -38,6 +38,9 @@ public class ChestOpenQuestTracker extends QuestTracker<Game>
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if (!getGame().IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
|
@ -1,18 +1,24 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import java.awt.dnd.DragSourceDropEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
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;
|
||||
|
||||
@ -29,7 +35,9 @@ import nautilus.game.arcade.game.Game;
|
||||
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)
|
||||
{
|
||||
@ -45,6 +53,71 @@ public class CollectQuestTracker extends QuestTracker<Game>
|
||||
_usedChests.clear();
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
|
@ -0,0 +1,31 @@
|
||||
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");
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package nautilus.game.arcade.quest;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
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.getEntity() instanceof Player))
|
||||
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;
|
||||
|
||||
System.out.println("Test2");
|
||||
|
||||
incrementQuests(event.GetDamagerPlayer(true), 1, "Player", "Axe", getGame().GetKit(event.GetDamagerPlayer(true)).GetName() + "Kit");
|
||||
}
|
||||
}
|
@ -42,6 +42,9 @@ public class QuestTracker<T extends Game> implements Listener
|
||||
|
||||
public void incrementQuests(Player player, int value, String... items)
|
||||
{
|
||||
if (getGame().getArcadeManager().GetGameHostManager().isPrivateServer())
|
||||
return;
|
||||
|
||||
if (canProgressQuests())
|
||||
{
|
||||
for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests())
|
||||
|
@ -6,6 +6,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.redis.RedisRepository;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class QuitNPCRepository extends RedisRepository
|
||||
{
|
||||
@ -18,16 +19,34 @@ public class QuitNPCRepository extends RedisRepository
|
||||
|
||||
public CompletableFuture<String> loadNpcServer(UUID uuid)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() -> getResource(false).get(getKey(REDIS_KEY_PREFIX + uuid.toString())));
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
try (Jedis jedis = getResource(false))
|
||||
{
|
||||
return jedis.get(getKey(REDIS_KEY_PREFIX + uuid.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteNpc(UUID uuid)
|
||||
{
|
||||
UtilServer.runAsync(() -> getResource(true).del(getKey(REDIS_KEY_PREFIX + uuid.toString())));
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
try (Jedis jedis = getResource(true))
|
||||
{
|
||||
jedis.del(getKey(REDIS_KEY_PREFIX + uuid.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void insertNpc(UUID uuid, String serverName)
|
||||
{
|
||||
UtilServer.runAsync(() -> getResource(true).setex(REDIS_KEY_PREFIX + uuid.toString(), 60, serverName));
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
try (Jedis jedis = getResource(true))
|
||||
{
|
||||
jedis.setex(getKey(REDIS_KEY_PREFIX + uuid.toString()), 60, serverName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -672,6 +672,10 @@ public class LootModule extends MiniPlugin
|
||||
{
|
||||
for (LootItemReward reward : _itemRewards)
|
||||
{
|
||||
if (reward.getPlayer() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (reward.getPlayer().equals(event.getEntity()))
|
||||
{
|
||||
reward.death(event);
|
||||
|
Loading…
Reference in New Issue
Block a user