diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java index 1f2835f13..daeb8bae3 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -56,7 +56,7 @@ public class MotdManager implements Listener, Runnable //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; // String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f"; - String motdLine = " §f❄ §2§lWinter Update §f❄ §2§lSnow Fight §f❄"; + String motdLine = " §f❄ §2§lNew Game §f❄ §2§lType Wars §f❄"; //String motdLine = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); diff --git a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java index f4e7aac72..57dc55496 100644 --- a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java +++ b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java @@ -51,13 +51,13 @@ public abstract class DnsMadeEasyApiCallBase try { String timeStamp = getServerTime(); - SecretKeySpec keySpec = new SecretKeySpec("35bb3b97-3815-4b63-b60b-eb1882c07b40".getBytes(), "HmacSHA1"); + SecretKeySpec keySpec = new SecretKeySpec("9041bc01-5cbc-49cf-ae09-a23b98350c62".getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(keySpec); byte[] hashBytes = mac.doFinal((timeStamp + "").getBytes()); Hex.encodeHexString(hashBytes); - request.addHeader("x-dnsme-apiKey", "a9750980-b7df-4a7e-a047-2ade43628f0d"); + request.addHeader("x-dnsme-apiKey", "2039c697-6ca9-412f-abda-0aef659a382a"); request.addHeader("x-dnsme-requestDate", timeStamp + ""); request.addHeader("x-dnsme-hmac", Hex.encodeHexString(hashBytes)); request.addHeader("Content-Type", "application/json"); diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index 067e728d7..e223d6129 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -13,7 +13,7 @@ - + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java index b573392b0..397e6d0c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java @@ -26,6 +26,7 @@ public abstract class MiniClientPlugin extends MiniPlug { synchronized (_clientDataLock) { + saveData(event.GetName(), event.getAccountId()); _clientData.remove(event.GetName()); } } @@ -40,6 +41,8 @@ public abstract class MiniClientPlugin extends MiniPlug return _clientData.get(name); } } + + public void saveData(String name, int accountId) {} public DataType Get(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 26859a6b3..7228b671e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -35,7 +35,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result; -import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -104,14 +103,15 @@ public class CoreClientManager extends MiniPlugin return newClient; } - public void Del(String name) + public void Del(String name, int accountId) { synchronized(_clientLock) { _clientList.remove(name); } - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name)); + // rawr added account id for custom data - william + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name, accountId)); } public CoreClient Get(String name) @@ -365,7 +365,7 @@ public class CoreClientManager extends MiniPlugin if (client == null || client.GetRank() == null) { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconncet."); + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect."); return; } @@ -407,7 +407,7 @@ public class CoreClientManager extends MiniPlugin if (!_duplicateLoginGlitchPreventionList.contains(event.getPlayer().getName())) { - Del(event.getPlayer().getName()); + Del(event.getPlayer().getName(), _clientList.get(event.getPlayer().getName()).getAccountId()); _duplicateLoginGlitchPreventionList.remove(event.getPlayer().getName()); } } @@ -473,7 +473,7 @@ public class CoreClientManager extends MiniPlugin public void run(List matches) { String tempName = null; - + for (String match : matches) { if (match.equalsIgnoreCase(playerName)) @@ -482,12 +482,12 @@ public class CoreClientManager extends MiniPlugin break; } } - + final String matchedName = tempName; - + if (matchedName != null) { - for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) + for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext(); ) { if (!matchIterator.next().equalsIgnoreCase(playerName)) { @@ -495,7 +495,7 @@ public class CoreClientManager extends MiniPlugin } } } - + UtilPlayer.searchOffline(matches, new Callback() { public void run(final String target) @@ -529,7 +529,8 @@ public class CoreClientManager extends MiniPlugin { for (Iterator> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext();) { - Player clientPlayer = clientIterator.next().getValue().GetPlayer(); + CoreClient client = clientIterator.next().getValue(); // rawr, needed this for custom data - william + Player clientPlayer = client.GetPlayer(); if (clientPlayer != null && !clientPlayer.isOnline()) { @@ -537,7 +538,7 @@ public class CoreClientManager extends MiniPlugin if (clientPlayer != null) { - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName())); + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName(), client.getAccountId())); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java index 972b1f612..d0d2d467a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java @@ -8,17 +8,24 @@ public class ClientUnloadEvent extends Event private static final HandlerList handlers = new HandlerList(); private String _name; + private int _accountId; - public ClientUnloadEvent(String name) + public ClientUnloadEvent(String name, int accountId) { _name = name; + _accountId = accountId; } public String GetName() { return _name; } - + + public int getAccountId() + { + return _accountId; + } + public HandlerList getHandlers() { return handlers; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index d8362e33b..d11b9a081 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -46,7 +46,7 @@ public class AccountRepository extends RepositoryBase public AccountRepository(JavaPlugin plugin, String webAddress) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _webAddress = webAddress; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index ee32d3854..d7e71c18e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -23,6 +23,13 @@ public enum Achievement new int[]{200}, AchievementCategory.HOLIDAY), + GLOBAL_PRESENT_HOARDER_2015("2015 Present Hoarder", 4000, + new String[]{"Global.Christmas Presents 2015"}, + new String[]{"Open 200 Christmas Presents,", + "during Christmas 2015!"}, + new int[]{200}, + AchievementCategory.HOLIDAY), + //Bridges BRIDGES_WINS("Bridge Champion", 600, new String[]{"The Bridges.Wins"}, @@ -811,9 +818,43 @@ public enum Achievement new String[]{"Gladiators.SwiftKill"}, new String[]{"Earn 15 first bloods", "in Gladiators"}, new int[]{15}, - AchievementCategory.GLADIATORS) + AchievementCategory.GLADIATORS), - ; + TYPE_WARS_SPEED_DEMON("Speed Demon", 1000, + new String[]{"Type Wars.Demon"}, + new String[]{"Kill 5 Mobs in 8 seconds", "by typing"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_PERFECTIONIST("Perfectionist", 1200, + new String[]{"Type Wars.Perfectionist"}, + new String[]{"Go an entire game", "without mistyping"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_WAIT_FOR_IT("Wait for it", 1200, + new String[]{"Type Wars.Nuke"}, + new String[]{"Kill 30 or more Mobs", "with a Nuke Spell"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_HOARDER("Hoarder", 1000, + new String[]{"Type Wars.Hoarder"}, + new String[]{"Summon 50 Mobs in one game"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_DUMBLEDONT("Dumbledont", 800, + new String[]{"Type Wars.Dumbledont"}, + new String[]{"Win without using any spells"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_WINNS("The True Typewriter", 2000, + new String[]{"Type Wars.Wins"}, + new String[]{"Win 30 Games"}, + new int[]{30}, + AchievementCategory.TYPE_WARS); private String _name; private String[] _desc; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 5fedf3c69..4a12d45cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -2,6 +2,10 @@ package mineplex.core.achievement; import java.util.List; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -10,10 +14,6 @@ import mineplex.core.game.GameDisplay; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - public enum AchievementCategory { GLOBAL("Global", null, @@ -23,7 +23,7 @@ public enum AchievementCategory HOLIDAY("Holiday Achievements", null, new StatDisplay[] {}, - Material.PUMPKIN_PIE, 0, GameCategory.HOLIDAY, "None"), + Material.CAKE, 0, GameCategory.HOLIDAY, "None"), BRIDGES("The Bridges", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -109,7 +109,7 @@ public enum AchievementCategory SUPER_PAINTBALL("Super Paintball", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.ENDER_PEARL, 0, GameCategory.ARCADE, null), + Material.ENDER_PEARL, 0, GameCategory.ARCADE, "Sniper Kit"), TURF_WARS("Turf Wars", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -150,12 +150,15 @@ public enum AchievementCategory MONSTER_MAZE("Monster Maze", null, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM"), - + GLADIATORS("Gladiators", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.IRON_SWORD, 0, GameCategory.ARCADE, null) - - ; + Material.IRON_SWORD, 0, GameCategory.ARCADE, null), + + TYPE_WARS("Type Wars", null, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED}, + Material.NAME_TAG, 0, GameCategory.CLASSICS, null); + private String _name; private String[] _statsToPull; @@ -243,7 +246,7 @@ public enum AchievementCategory if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played"))) continue; - int statNumber = 0; + double statNumber = 0; // This is so we could load stats from other games @@ -256,15 +259,49 @@ public enum AchievementCategory else { for (String statToPull : _statsToPull) + { for (String statName : _statDisplays[i].getStats()) - statNumber += stats.getStat(statToPull + "." + statName); + { + if(_statDisplays[i].isDivideStats()) + { + if(statNumber == 0) + { + statNumber = stats.getStat(statToPull + "." + statName); + continue; + } + double stat = stats.getStat(statToPull + "." + statName); + if(stat == 0) + statNumber = statNumber / 1; + else + statNumber = (double) statNumber / stat; + } + else + statNumber += stats.getStat(statToPull + "." + statName); + } + } } - String statString = C.cWhite + statNumber; + String statString = C.cWhite + Math.round(statNumber); + + // doubles + // Special display for Words per Minute + if (displayName.equalsIgnoreCase("Words Per Minute")) + { + statString = C.cWhite + (double) statNumber; + if(statString.length() > 7) + statString = statString.substring(0, 7); + + lore.add(C.cYellow + displayName + ": " + statString); + continue; + } + + + // ints // Need to display special for time if (displayName.equalsIgnoreCase("Time In Game")) - statString = C.cWhite + UtilTime.convertString(statNumber * 1000L, 0, UtilTime.TimeUnit.FIT); + statString = C.cWhite + UtilTime.convertString(Math.round(statNumber) * 1000L, 0, UtilTime.TimeUnit.FIT); + lore.add(C.cYellow + displayName + ": " + statString); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java index ea7515827..0d6badd6e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java @@ -14,6 +14,7 @@ public class StatDisplay private String[] _stats; private boolean _fullStat; private boolean _justDisplayName; + private boolean _divideStats; public StatDisplay(String stat) { @@ -25,19 +26,26 @@ public class StatDisplay _displayName = stat; _stats = new String[] { stat }; _fullStat = false; + _divideStats = false; _justDisplayName = justDisplayName; } + + public StatDisplay(String displayName, boolean divideStats, String... stats) + { + this(displayName, false, divideStats, stats); + } public StatDisplay(String displayName, String... stats) { - this(displayName, false, stats); + this(displayName, false, false, stats); } - public StatDisplay(String displayName, boolean fullStat, String... stats) + public StatDisplay(String displayName, boolean fullStat, boolean divideStats, String... stats) { _displayName = displayName; _stats = stats; _fullStat = fullStat; + _divideStats = divideStats; } public String getDisplayName() @@ -59,6 +67,11 @@ public class StatDisplay { return _fullStat; } + + public boolean isDivideStats() + { + return _divideStats; + } public static StatDisplay fromGame(String name, GameDisplay gameDisplay, String... stats) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 7056d8b8e..40ec84525 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -49,7 +49,7 @@ public class AchievementMainPage extends ShopPageBase implements I { try { - final int newTickets = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). + final int newTickets = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets(); runSync(new Runnable() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java index 0c4a1c6f5..2ce772e8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java @@ -36,7 +36,7 @@ public class BonusRepository extends RepositoryBase public BonusRepository(JavaPlugin plugin, BonusManager bonusManager, DonationManager donationManager) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _manager = bonusManager; _donationManager = donationManager; } @@ -145,7 +145,7 @@ public class BonusRepository extends RepositoryBase { try { - DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + DSLContext create = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). where(Tables.bonus.accountId.eq(accountId)).execute(); final int newTickets = create.select(Tables.bonus.tickets).from(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne().value1(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java index d1460fb4a..3af3d0d4f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java @@ -24,7 +24,7 @@ public class BotSpamRepository extends RepositoryBase public BotSpamRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } public ArrayList getSpamText() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CorePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CorePlayer.java new file mode 100644 index 000000000..14aaec660 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CorePlayer.java @@ -0,0 +1,21 @@ +package mineplex.core.customdata; + +import org.bukkit.entity.Player; + +/** + * Created by William (WilliamTiger). + * 17/12/15 + */ +public class CorePlayer extends MineplexPlayer +{ + public CorePlayer(Player player, CustomDataManager customDataManager) + { + super(player, customDataManager); + } + + @Override + public String getKeyPrefix() + { + return "core."; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomData.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomData.java new file mode 100644 index 000000000..052965b5c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomData.java @@ -0,0 +1,27 @@ +package mineplex.core.customdata; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class CustomData +{ + private int _id; + private String _key; + + public CustomData(int id, String key) + { + _id = id; + _key = key; + } + + public int getId() + { + return _id; + } + + public String getKey() + { + return _key; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java new file mode 100644 index 000000000..cd0543674 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -0,0 +1,61 @@ +package mineplex.core.customdata; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.customdata.repository.CustomDataRepository; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class CustomDataManager extends MiniDbClientPlugin +{ + private CustomDataRepository _repository; + + public CustomDataManager(JavaPlugin plugin, CoreClientManager clientManager) + { + super("Custom Data Manager", plugin, clientManager); + + _repository = new CustomDataRepository(plugin, clientManager, this); + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + PlayerCustomData data = new PlayerCustomData(_repository); + while (resultSet.next()) + { + data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data")); + } + Set(playerName, data); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT accountId, customDataId, data FROM accountCustomData INNER JOIN customData ON customData.id = accountCustomData.customDataId WHERE accountId = " + accountId + ";"; + } + + @Override + protected PlayerCustomData AddPlayer(String player) + { + return new PlayerCustomData(_repository); + } + + @Override + public void saveData(String name, int accountId) + { + _repository.saveData(name, accountId); + } + + public CorePlayer getCorePlayer(Player player) + { + return new CorePlayer(player, this); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java new file mode 100644 index 000000000..e49f75211 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java @@ -0,0 +1,41 @@ +package mineplex.core.customdata; + +import org.bukkit.entity.Player; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public abstract class MineplexPlayer +{ + private Player _player; + private CustomDataManager _customDataManager; + + public MineplexPlayer(Player player, CustomDataManager customDataManager) + { + _player = player; + _customDataManager = customDataManager; + } + + public Player getPlayer() + { + return _player; + } + + public String getKeyPrefix() + { + return ""; + } + + public void put(String key, int data) + { + key = getKeyPrefix() + key; + _customDataManager.Get(getPlayer()).setData(key, data); + } + + public int get(String key) + { + key = getKeyPrefix() + key; + return _customDataManager.Get(getPlayer()).getData(key); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java new file mode 100644 index 000000000..961d68023 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java @@ -0,0 +1,62 @@ +package mineplex.core.customdata; + +import java.util.HashMap; + +import mineplex.core.customdata.repository.CustomDataRepository; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class PlayerCustomData +{ + private HashMap _data; + private CustomDataRepository _repository; + + public PlayerCustomData(CustomDataRepository repository) + { + _data = new HashMap<>(); + _repository = repository; + } + + public HashMap getDataMap() + { + return _data; + } + + public void setData(CustomData cd, int amount) + { + _data.put(cd, amount); + } + + public void setData(String key, int amount) + { + if (_repository.doesKeyExist(key)) + { + setData(_repository.getKey(key), amount); + return; + } + + _repository.getClientManager().getScheduler().runTaskAsynchronously( + _repository.getClientManager().getPlugin(), + new Runnable() + { + @Override + public void run() + { + _repository.registerKey(key); // Make sure it's in the DB. + + setData(_repository.getKey(key), amount); // Input + } + }); + } + + public int getData(String key) + { + if (_data.containsKey(_repository.getKey(key))) + return _data.get(_repository.getKey(key)); + + return -1; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java new file mode 100644 index 000000000..328aa6e6f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -0,0 +1,138 @@ +package mineplex.core.customdata.repository; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.customdata.CustomData; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.customdata.PlayerCustomData; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.database.column.ColumnVarChar; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class CustomDataRepository extends RepositoryBase +{ + private static final String SELECT_KEYS = "SELECT id, name FROM customData;"; + private static final String INSERT_KEY = "INSERT INTO customData (name) VALUES (?);"; + private static final String UPDATE_DATA = "UPDATE accountCustomData SET data = ? WHERE accountId = ? AND customDataId = ?;"; + private static final String INSERT_DATA = "INSERT INTO accountCustomData (accountId, customDataId, data) VALUES (?, ?, ?);"; + + private ArrayList _dataKeys; + + private CoreClientManager _clientManager; + private CustomDataManager _customDataManager; + + public CustomDataRepository(JavaPlugin plugin, CoreClientManager clientManager, CustomDataManager customDataManager) + { + super(plugin, DBPool.getAccount()); + + _clientManager = clientManager; + _customDataManager = customDataManager; + } + + @Override + protected void initialize() + { + downloadDataKeys(); + } + + @Override + protected void update() {} + + private void downloadDataKeys() + { + _dataKeys = new ArrayList<>(); + + executeQuery(SELECT_KEYS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + _dataKeys.add(new CustomData(resultSet.getInt("id"), resultSet.getString("name"))); + } + } + }); + } + + public void saveData(String name, int accountId) + { + PlayerCustomData data = _customDataManager.Get(name); + + for (CustomData cd : data.getDataMap().keySet()) + { + if (executeUpdate( + UPDATE_DATA, + new ColumnInt("data", data.getDataMap().get(cd)), + new ColumnInt("account", accountId), + new ColumnInt("customData", cd.getId())) < 1) + { + // Not already in the DB + executeUpdate( + INSERT_DATA, + new ColumnInt("account", accountId), + new ColumnInt("customData", cd.getId()), + new ColumnInt("data", data.getDataMap().get(cd)) + ); + } + } + } + + public void registerKey(String key) + { + if (doesKeyExist(key)) + return; + + executeUpdate(INSERT_KEY, new ColumnVarChar("name", 100, key)); + downloadDataKeys(); + } + + public ArrayList getDataKeys() + { + return _dataKeys; + } + + public boolean doesKeyExist(String key) + { + for (CustomData cur : _dataKeys) + if (cur.getKey().equals(key)) + return true; + + return false; + } + + public CustomData getKey(int id) + { + for (CustomData cur : _dataKeys) + if (cur.getId() == id) + return cur; + + return null; + } + + public CustomData getKey(String key) + { + for (CustomData cur : _dataKeys) + if (cur.getKey().equals(key)) + return cur; + + return null; + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java index 8400fa954..06495ff54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java @@ -1,16 +1,26 @@ package mineplex.core.database; import javax.sql.DataSource; + +import java.io.File; +import java.nio.charset.Charset; +import java.nio.file.Files; import java.sql.Connection; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.dbcp2.BasicDataSource; +import mineplex.serverdata.redis.RedisConfig; +import mineplex.serverdata.servers.ConnectionData; +import mineplex.serverdata.servers.ConnectionData.ConnectionType; + public final class DBPool { - public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); - public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); - public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); - public static final DataSource STATS_MINEPLEX = openDataSource("jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh"); + private static DataSource ACCOUNT; + private static DataSource QUEUE; + private static DataSource MINEPLEX; + private static DataSource STATS_MINEPLEX; private static DataSource openDataSource(String url, String username, String password) { @@ -30,8 +40,86 @@ public final class DBPool return source; } - private DBPool() + public static DataSource getAccount() { + if (ACCOUNT == null) + loadDataSources(); + return ACCOUNT; + } + + public static DataSource getQueue() + { + if (QUEUE == null) + loadDataSources(); + + return QUEUE; + } + + public static DataSource getMineplex() + { + if (MINEPLEX == null) + loadDataSources(); + + return MINEPLEX; + } + + public static DataSource getStats() + { + if (STATS_MINEPLEX == null) + loadDataSources(); + + return STATS_MINEPLEX; + } + + private static void loadDataSources() + { + try + { + File configFile = new File("database-config.dat"); + + if (configFile.exists()) + { + List lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset()); + + for (String line : lines) + { + deserializeConnection(line); + } + } + else + { + System.out.println("database-config.dat not found at " + configFile.toPath().toString()); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + System.out.println("---Unable To Parse DBPOOL Configuration File---"); + } + } + + private static void deserializeConnection(String line) + { + String[] args = line.split(" "); + + if (args.length == 4) + { + String dbSource = args[0]; + String dbHost = args[1]; + String userName = args[2]; + String password = args[3]; + + System.out.println(dbSource + " " + dbHost + " " + userName + " " + password); + + if (dbSource.toUpperCase().equalsIgnoreCase("ACCOUNT")) + ACCOUNT = openDataSource("jdbc:mysql://" + dbHost, userName, password); + else if (dbSource.toUpperCase().equalsIgnoreCase("QUEUE")) + QUEUE = openDataSource("jdbc:mysql://" + dbHost, userName, password); + else if (dbSource.toUpperCase().equalsIgnoreCase("MINEPLEX")) + MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password); + else if (dbSource.toUpperCase().equalsIgnoreCase("STATS")) + STATS_MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java index f96d1b04d..55acc83ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java @@ -68,7 +68,7 @@ public abstract class RepositoryBase implements Listener protected DSLContext jooq() { - return DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + return DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 910f03c63..98999dbf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -37,7 +37,7 @@ public class DonationRepository extends RepositoryBase public DonationRepository(JavaPlugin plugin, String webAddress) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _webAddress = webAddress; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java index 54503474f..2304a75c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java @@ -17,7 +17,7 @@ public class EloRepository extends RepositoryBase public EloRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); initialize(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index c7ab1ae90..c09fe1703 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -37,7 +37,7 @@ public class FriendRepository extends RepositoryBase public FriendRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _repository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), Region.currentRegion(), PlayerStatus.class, "playerStatus"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index ebdc89a02..8ae12ae88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -67,12 +67,10 @@ public enum GameDisplay MonsterLeague("Monster League", Material.MINECART, (byte)0, GameCategory.ARCADE, 56), Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), - ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), - BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), - Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), + TypeWars("Type Wars", Material.NAME_TAG, (byte) 0, GameCategory.CLASSICS, 59), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java index c8cac2179..46844bd07 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java @@ -26,7 +26,7 @@ public class GiveawayRepository extends RepositoryBase public GiveawayRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } public boolean canGiveaway(int accountId, String giveawayName, String cooldownName) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index e772427cc..a569b9612 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -4,11 +4,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; @@ -16,8 +19,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; public class Hologram { @@ -313,7 +314,7 @@ public class Hologram */ public Hologram removePlayer(Player player) { - return addPlayer(player.getName()); + return removePlayer(player.getName()); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java index aad60e65c..14e1918c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java @@ -17,7 +17,7 @@ public class IgnoreRepository extends RepositoryBase public IgnoreRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java index a21d6c9ec..018eb41e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java @@ -29,7 +29,7 @@ public class InventoryRepository extends RepositoryBase public InventoryRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index 8ea88cc70..fa7070511 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -11,16 +11,17 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; +import org.bukkit.DyeColor; import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.FireworkEffectMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.SkullMeta; -import org.bukkit.potion.Potion; import mineplex.core.common.util.C; @@ -254,6 +255,10 @@ public class ItemBuilder { ((FireworkEffectMeta) meta).setEffect(FireworkEffect.builder().withColor(_color).build()); } + else if (meta instanceof BannerMeta) + { + ((BannerMeta) meta).setBaseColor(DyeColor.getByColor(_color)); + } meta.addItemFlags(getItemFlags().toArray(new ItemFlag[0])); meta.spigot().setUnbreakable(isUnbreakable()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java index 1679bc36d..5f0659c03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java @@ -36,7 +36,7 @@ public class StatEventsRepository extends RepositoryBase */ public StatEventsRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 11887cd53..59dc27148 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -224,6 +224,11 @@ public class MessageManager extends MiniClientPlugin UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); } + if (to.getName().equals("xXVevzZXx")) + { + UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); + UtilPlayer.message(from, C.cPurple + "Please be patient if she does not reply instantly."); + } /*if(to.getName().equals("ishh")) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 5e971bf50..1235a6301 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -268,7 +268,7 @@ public class NpcManager extends MiniPlugin public Entity addNpc(Player player, EntityType entityType, double radius, boolean adult, String name, String entityMeta) throws SQLException { - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { String helmet = itemStackToYaml(player.getInventory().getHelmet()); String chestplate = itemStackToYaml(player.getInventory().getChestplate()); @@ -386,7 +386,7 @@ public class NpcManager extends MiniPlugin if (npc != null) { - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { npc.getDatabaseRecord().attach(DSL.using(connection).configuration()); npc.getDatabaseRecord().delete(); @@ -493,7 +493,7 @@ public class NpcManager extends MiniPlugin { String serverType = getServerName(); - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { Result result = DSL.using(connection) .selectFrom(Tables.npcs) @@ -519,7 +519,7 @@ public class NpcManager extends MiniPlugin { String serverType = getServerName(); - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { DSL.using(connection) .delete(Tables.npcs) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java index a79065f4c..40c2d2e1c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -22,7 +22,7 @@ public class PetRepository extends RepositoryBase public PetRepository(JavaPlugin plugin, String webAddress) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _webAddress = webAddress; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java index 588d3d549..9628a5c93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java @@ -29,7 +29,7 @@ public class PollRepository extends RepositoryBase public PollRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index bace34ea9..8d4fd8c80 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -29,7 +29,7 @@ public class PreferencesRepository extends RepositoryBase public PreferencesRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java index 901564cea..3120de5ce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java @@ -16,7 +16,7 @@ public class ReportRepository extends RepositoryBase public ReportRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java deleted file mode 100644 index f51ee8b96..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package mineplex.core.resourcepack; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import mineplex.core.resourcepack.redis.RedisUnloadResPack; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -import mineplex.serverdata.commands.ServerCommandManager; - -public class ResPackManager implements CommandCallback -{ - private ResUnloadCheck _packUnloadCheck; - - public ResPackManager(ResUnloadCheck packUnloadCheck) - { - _packUnloadCheck = packUnloadCheck; - - ServerCommandManager.getInstance().registerCommandType("RedisUnloadResPack", RedisUnloadResPack.class, this); - } - - @Override - public void run(ServerCommand command) - { - if (command instanceof RedisUnloadResPack) - { - RedisUnloadResPack redisCommand = (RedisUnloadResPack) command; - - Player player = Bukkit.getPlayerExact(redisCommand.getPlayer()); - - if (player != null) - { - if (_packUnloadCheck.canSendUnload(player)) - { - player.setResourcePack("http://file.mineplex.com/ResReset.zip"); - } - } - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java deleted file mode 100644 index c25175c58..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java +++ /dev/null @@ -1,9 +0,0 @@ -package mineplex.core.resourcepack; - -import org.bukkit.entity.Player; - -public interface ResUnloadCheck -{ - - public boolean canSendUnload(Player player); -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java new file mode 100644 index 000000000..31b41dd06 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java @@ -0,0 +1,238 @@ +package mineplex.core.resourcepack; + +import java.util.Iterator; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.base.Objects; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.portal.Portal; +import mineplex.core.resourcepack.redis.RedisUnloadResPack; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; +import mineplex.serverdata.commands.ServerCommandManager; + +public class ResourcePackManager extends MiniPlugin implements CommandCallback +{ + private String _resourcePackUrl; + private boolean _resourcePackRequired; + private NautHashMap _resourcePackUsers = new NautHashMap(); + private NautHashMap _resourcePackNoResponse = new NautHashMap(); + private Portal _portal; + + public ResourcePackManager(JavaPlugin plugin, Portal portal) + { + super("Resource Pack Manager", plugin); + + _portal = portal; + + ServerCommandManager.getInstance().registerCommandType("RedisUnloadResPack", RedisUnloadResPack.class, this); + } + + @EventHandler + public void ResourcePackJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + if (_resourcePackUrl == null) + { + return; + } + + if (_resourcePackRequired) + { + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + } + + _resourcePackUsers.put(player.getName(), false); + player.setResourcePack(_resourcePackUrl); + } + + @EventHandler + public void onSecond(UpdateEvent event) + { + Iterator> itel = _resourcePackNoResponse.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (!UtilTime.elapsed(entry.getValue(), 20000)) + { + continue; + } + + Player player = Bukkit.getPlayerExact(entry.getKey()); + + if (player == null) + { + itel.remove(); + continue; + } + + // Send it again, enforce it! + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + player.setResourcePack(_resourcePackUrl); + } + } + + @EventHandler + public void onResourcePackStatus(PlayerResourcePackStatusEvent event) + { + if (_resourcePackUrl == null) + { + return; + } + + Player player = event.getPlayer(); + + if (_resourcePackRequired) + { + if (event.getStatus() == Status.ACCEPTED) + { + _resourcePackNoResponse.remove(player.getName()); + } + else if (event.getStatus() == Status.DECLINED) + { + _resourcePackNoResponse.remove(player.getName()); + + UtilPlayer.message(player, " "); + JsonMessage message = new JsonMessage("").color("gold").bold() + .extra("You need to accept the resource pack!\n" + "Click me for instructions on how to fix this!") + + .click(ClickEvent.OPEN_URL, + + "http://mineplex.com/forums/m/11929946/viewthread/21554536-wizards-resource-pack-help"); + + message.sendToPlayer(player); + UtilPlayer.message(player, " "); + + returnHubNoResPack(player); + } + else if (event.getStatus() == Status.FAILED_DOWNLOAD) + { + _resourcePackNoResponse.remove(player.getName()); + + returnHubNoResPack(player, "Failed to download resource pack!"); + + return; + } + } + + if (event.getStatus() == Status.ACCEPTED || event.getStatus() == Status.SUCCESSFULLY_LOADED) + { + _resourcePackUsers.put(player.getName(), true); + } + else + { + _resourcePackUsers.remove(player.getName()); + } + } + + @EventHandler + public void ResourcePackQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + if (!_resourcePackUsers.containsKey(player.getName()) || !_resourcePackUsers.get(player.getName())) + { + return; + } + + new RedisUnloadResPack(player.getName()).publish(); + + _resourcePackUsers.remove(player.getName()); + } + + private void returnHubNoResPack(Player player) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); + _portal.sendPlayerToServer(player, "Lobby"); + } + + private void returnHubNoResPack(Player player, String message) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cGold + C.Bold + message); + UtilPlayer.message(player, " "); + + returnHubNoResPack(player); + } + + public void setResourcePack(String resourcePack, boolean forceResourcePack) + { + if (Objects.equal(resourcePack, _resourcePackUrl) && forceResourcePack == _resourcePackRequired) + { + return; + } + + _resourcePackNoResponse.clear(); + _resourcePackUsers.clear(); + _resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack; + _resourcePackRequired = forceResourcePack; + + if (_resourcePackUrl == null || _resourcePackUrl.isEmpty()) + { + _resourcePackRequired = false; + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.setResourcePack("http://file.mineplex.com/ResReset.zip"); + } + } + else + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_resourcePackRequired) + { + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + } + + _resourcePackUsers.put(player.getName(), false); + player.setResourcePack(_resourcePackUrl); + } + } + } + + @Override + public void run(ServerCommand command) + { + if (command instanceof RedisUnloadResPack) + { + RedisUnloadResPack redisCommand = (RedisUnloadResPack) command; + + Player player = Bukkit.getPlayerExact(redisCommand.getPlayer()); + + if (player == null) + { + return; + } + + if (_resourcePackUsers.containsKey(player.getName())) + { + return; + } + + player.setResourcePack("http://file.mineplex.com/ResReset.zip"); + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java index eb85bae9d..c6f4191a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java @@ -23,7 +23,7 @@ public class SpawnRepository extends RepositoryBase public SpawnRepository(JavaPlugin plugin, String serverName) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _serverName = serverName; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index d32b5fee3..12deca990 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -32,7 +32,7 @@ public class StatsRepository extends RepositoryBase public StatsRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java index 95a427d11..51dfe5726 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java @@ -24,7 +24,7 @@ public class TaskRepository extends RepositoryBase public TaskRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java index 4eb95a46d..b6d29c68b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java @@ -20,7 +20,7 @@ public class TitanGiveawayRepository extends RepositoryBase public TitanGiveawayRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _titanCount = 0; } diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java index ba4cd2729..e96d4a42a 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java @@ -13,7 +13,7 @@ public class TempRepository extends RepositoryBase public TempRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } public void addGemBooster(String name, int amount) diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java index d71d09552..048c1fc99 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java @@ -23,7 +23,7 @@ public class PurchaseRepository extends RepositoryBase public PurchaseRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java index 037593a54..70f9d082b 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java @@ -86,7 +86,7 @@ public class ClanRepository extends RepositoryBase public ClanRepository(JavaPlugin plugin, String serverName, boolean isClansServer) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _serverName = serverName; _serverId = -1; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java index cd45b22bc..2f36fd067 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java @@ -34,7 +34,7 @@ public class FieldRepository extends RepositoryBase public FieldRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } public List getFieldBlocks(String server) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index a1128d60e..307d233a0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -16,6 +16,7 @@ import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotPlugin; import mineplex.core.command.CommandCenter; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; @@ -46,8 +47,7 @@ import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; -import mineplex.core.resourcepack.ResUnloadCheck; -import mineplex.core.resourcepack.ResPackManager; +import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; @@ -136,9 +136,11 @@ public class Hub extends JavaPlugin implements IRelation PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); SkillConditionManager conditionManager = new SkillConditionManager(this); - + + CustomDataManager customDataManager = new CustomDataManager(this, clientManager); + PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, giveawayManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, giveawayManager, customDataManager); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); @@ -149,13 +151,7 @@ public class Hub extends JavaPlugin implements IRelation new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); new PacketsInteractionFix(this, packetHandler); - new ResPackManager(new ResUnloadCheck() - { - public boolean canSendUnload(Player player) - { - return true; - } - }); + new ResourcePackManager(this, portal); new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, giveawayManager); SnapshotManager snapshotManager = new SnapshotManager(); new SnapshotPlugin(this, snapshotManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 52abd753e..738c79422 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -31,6 +31,7 @@ import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; @@ -159,6 +160,7 @@ public class HubManager extends MiniClientPlugin private PacketHandler _packetHandler; private PersonalServerManager _personalServerManager; private PlayerCountManager _playerCountManager; + private CustomDataManager _customDataManager; // private HalloweenSpookinessManager _halloweenManager; // private TrickOrTreatManager _trickOrTreatManager; @@ -181,7 +183,7 @@ public class HubManager extends MiniClientPlugin // private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; private final ArrayList _songs; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager, CustomDataManager customDataManager) { super("Hub Manager", plugin); @@ -250,6 +252,8 @@ public class HubManager extends MiniClientPlugin _playerCountManager = new PlayerCountManager(plugin); + _customDataManager = new CustomDataManager(plugin, clientManager); + _songs = new ArrayList(); try @@ -856,7 +860,12 @@ public class HubManager extends MiniClientPlugin return _visibilityManager; } -// public HalloweenSpookinessManager getHalloweenManager() + public CustomDataManager getCustomDataManager() + { + return _customDataManager; + } + + // public HalloweenSpookinessManager getHalloweenManager() // { // return _halloweenManager; // } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java index 5c09e8423..cf07e0012 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java @@ -41,7 +41,7 @@ public class HubRepository PreparedStatement preparedStatement = null; HashMap newsEntries = new HashMap(); - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_NEWS_ENTRIES); @@ -91,7 +91,7 @@ public class HubRepository int result = 0; PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(SET_NEWS_ENTRY); preparedStatement.setString(1, newsEntry); @@ -127,7 +127,7 @@ public class HubRepository ResultSet resultSet = null; PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_MAX_NEWS_POSITION); resultSet = preparedStatement.executeQuery(); @@ -165,7 +165,7 @@ public class HubRepository int maxPos = retrieveMaxNewsPosition(); PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(ADD_NEWS_ENTRY); preparedStatement.setString(1, newsEntry); @@ -201,7 +201,7 @@ public class HubRepository int maxPos = retrieveMaxNewsPosition(); PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { //preparedStatement = connection.prepareStatement(DELETE_RECALC_NEWS_ENTRY); preparedStatement = connection.prepareStatement(DELETE_NEWS_ENTRY); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java index af43ab9f5..ae09e592f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java @@ -21,7 +21,7 @@ public class MailRepository extends RepositoryBase public MailRepository(JavaPlugin plugin, MailManager manager) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _manager = manager; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java index 0dfdf8640..d0b0d0a91 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java @@ -36,7 +36,7 @@ public class QueueRepository { PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(DELETE_QUEUE_RECORD); @@ -71,7 +71,7 @@ public class QueueRepository { PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(SAVE_STATE_VALUE); preparedStatement.setString(1, matchStatus.State); @@ -108,7 +108,7 @@ public class QueueRepository PreparedStatement preparedStatement = null; PlayerMatchStatus matchStatus = new PlayerMatchStatus(); - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(INSERT_ACCOUNT, Statement.RETURN_GENERATED_KEYS); preparedStatement.setString(1, playerList); @@ -165,7 +165,7 @@ public class QueueRepository PreparedStatement preparedStatement = null; PlayerMatchStatus matchStatus = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_MATCH_STATUS); preparedStatement.setInt(1, id); @@ -220,7 +220,7 @@ public class QueueRepository ResultSet resultSet = null; PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_OTHER_MATCH_STATUS); preparedStatement.setInt(1, matchStatus.AssignedMatch); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 10f889fce..a80aa4503 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -87,6 +87,8 @@ public class ServerManager extends MiniPlugin private NautHashMap _serverInfoMap = new NautHashMap(); private NautHashMap _serverUpdate = new NautHashMap(); private NautHashMap _serverPortalLocations = new NautHashMap(); + + private ClansServerShop _clansShop; // Join Time for Free Players Timer private NautHashMap _joinTime = new NautHashMap(); @@ -121,7 +123,7 @@ public class ServerManager extends MiniPlugin //_domShop = new new QueueShop(_queueManager, clientManager, donationManager, "Dominate"); // TODO: Find more appropriate place to initialize Clans server shop? - new ClansServerShop(this, _clientManager, _donationManager); + _clansShop = new ClansServerShop(this, _clientManager, _donationManager); } @EventHandler(priority = EventPriority.LOW) @@ -786,6 +788,11 @@ public class ServerManager extends MiniPlugin { return _serverNpcShopMap.get("Dominate"); } + + public ServerNpcShop getCtfShop() + { + return _serverNpcShopMap.get("Capture the Flag"); + } public ServerNpcShop getBridgesShop() { @@ -804,9 +811,9 @@ public class ServerManager extends MiniPlugin public ServerNpcShop getBetaShop() { - return _serverNpcShopMap.get("Beta Games"); + return _serverNpcShopMap.get("Beta Monster Maze"); } - + public ServerNpcShop getUHCShop() { return _serverNpcShopMap.get("Ultra Hardcore"); @@ -822,6 +829,11 @@ public class ServerManager extends MiniPlugin return _serverNpcShopMap.get("Mineplex Player Servers"); } + public ServerNpcShop getShop(String name) + { + return _serverNpcShopMap.get(name); + } + private Vector ParseVector(String vectorString) { Vector vector = new Vector(); @@ -882,4 +894,14 @@ public class ServerManager extends MiniPlugin { return _serverNpcShopMap.get("Master Builders"); } + + public ClansServerShop getClansShop() + { + return _clansShop; + } + + public ShopBase getTypeWarsShop() + { + return _serverNpcShopMap.get("Type Wars"); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 6b1411ecd..3a062a401 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -12,15 +13,18 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; +import mineplex.hub.server.ui.button.SelectBETAButton; import mineplex.hub.server.ui.button.SelectBHButton; import mineplex.hub.server.ui.button.SelectBLDButton; import mineplex.hub.server.ui.button.SelectBRButton; +import mineplex.hub.server.ui.button.SelectCLANSButton; import mineplex.hub.server.ui.button.SelectCSButton; +import mineplex.hub.server.ui.button.SelectCTFButton; import mineplex.hub.server.ui.button.SelectDMTButton; import mineplex.hub.server.ui.button.SelectDOMButton; +import mineplex.hub.server.ui.button.SelectFEATButton; import mineplex.hub.server.ui.button.SelectMINButton; import mineplex.hub.server.ui.button.SelectMSButton; import mineplex.hub.server.ui.button.SelectPLAYERButton; @@ -28,6 +32,7 @@ import mineplex.hub.server.ui.button.SelectSGButton; import mineplex.hub.server.ui.button.SelectSKYButton; import mineplex.hub.server.ui.button.SelectSSMButton; import mineplex.hub.server.ui.button.SelectTDMButton; +import mineplex.hub.server.ui.button.SelectTWButton; import mineplex.hub.server.ui.button.SelectUHCButton; import mineplex.hub.server.ui.button.SelectWIZButton; @@ -38,11 +43,12 @@ public class ServerGameMenu extends ShopPageBase private int _ssmIndex; private int _minigameIndex; + private boolean _extraValue; public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) { - super(plugin, quickShop, clientManager, donationManager, name, player, 47); + super(plugin, quickShop, clientManager, donationManager, name, player, 45); createSuperSmashCycle(); createMinigameCycle(); @@ -50,246 +56,247 @@ public class ServerGameMenu extends ShopPageBase buildPage(); } - @SuppressWarnings("deprecation") @Override protected void buildPage() { - setItem(0, new ItemBuilder(Material.IRON_PICKAXE) - .setTitle(C.Reset + C.Bold + C.cYellow + "The Bridges " + C.cGray + "4 Team Survival").addLore(new String[] - { - C.Reset + "", - C.Reset + "4 Teams get 10 minutes to prepare.", - C.Reset + "Then the bridges drop, and all hell", - C.Reset + "breaks loose as you battle to the", - C.Reset + "death with the other teams.", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("BR") + C.Reset + " other players!" - }).setHideInfo(true).build()); - - setItem(2, new ItemBuilder(Material.DIAMOND_SWORD) - .setTitle(C.Reset + C.Bold + C.cYellow + "Survival Games " + C.cGray + "Solo/Team Survival").addLore(new String[] - { - C.Reset + "", - C.Reset + "Search for chests to find loot and ", - C.Reset + "fight others to be the last man standing. ", - C.Reset + "Stay away from the borders!", - C.Reset + "", - C.Reset + "Join " + C.cGreen - + (getPlugin().getGroupTagPlayerCount("HG") + getPlugin().getGroupTagPlayerCount("SG2")) + C.Reset - + " other players!" - }).setHideInfo(true).build()); - - setItem(4, new ItemBuilder(Material.FEATHER) - .setTitle(C.Reset + C.Bold + C.cYellow + "Skywars " + C.cGray + "Solo/Team Survival").addLore(new String[] - { - C.Reset + "", - C.Reset + "16 contenders fight to rule the skies!", - C.Reset + "Spawn on a sky island and build your path!", - C.Reset + "Find weapons to take your enemies down!", - C.Reset + "Up in the skies, death looming if you fall..", - C.Reset + "Win! Fight! Send enemies flying in Skywars!", - C.Reset + "", - C.Reset + "Join " + C.cGreen - + (getPlugin().getGroupTagPlayerCount("SKY") + getPlugin().getGroupTagPlayerCount("SKY2")) + C.Reset - + " other players!", - }).setHideInfo(true).build()); - - setItem(6, new ItemBuilder(Material.GOLDEN_APPLE) - .setTitle(C.Reset + C.Bold + C.cYellow + "UHC " + C.cGray + "Ultra Hardcore Mode").addLore(new String[] - { - C.Reset + "", - C.Reset + "Extremely hard team-based survival ", - C.Reset + "Gather materials and fight your way", - C.Reset + "to become the last team standing!", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("UHC") + C.Reset + " other players!", - }).setHideInfo(true).build()); - - setItem(8, new ItemBuilder(Material.BLAZE_ROD) - .setTitle(C.Reset + C.Bold + C.cYellow + "Wizards " + C.cGray + "Last Man Standing").addLore(new String[] - { - C.Reset + "", - C.Reset + "Wield powerful spells to fight", - C.Reset + "against other players in this", - C.Reset + "exciting free-for-all brawl!", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("WIZ") + C.Reset + " other players!", - }).setHideInfo(true).build()); - - setItem(18, new ItemBuilder(Material.DIAMOND_CHESTPLATE) - .setTitle(C.Reset + C.Bold + C.cYellow + "Castle Siege " + C.cGray + "Team Game").addLore(new String[] - { - C.Reset + "", - C.Reset + "Defenders must protect King Sparklez", - C.Reset + "from the endless waves of Undead", - C.Reset + "until the sun rises!", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("CS") + C.Reset + " other players!", - }).setHideInfo(true).build()); - - setItem(20, new ItemBuilder(Material.GRASS) - .setTitle(C.Reset + C.Bold + C.cYellow + "Block Hunt " + C.cGray + "Cat and Mouse").addLore(new String[] - { - C.Reset + "", - C.Reset + "Hide as blocks/animals, upgrade your ", - C.Reset + "weapon and fight to survive against", - C.Reset + "the Hunters!", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("BH") + C.Reset + " other players!", - }).setHideInfo(true).build()); - - setItem(22, _superSmashCycle.get(_ssmIndex)); - - setItem(24, ItemStackFactory.Instance.CreateStack(Material.TNT.getId(), (byte) 0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Mine-Strike" + C.cGray + "Team Survival", new String[] + addButton(3, new ItemBuilder(Material.NAME_TAG).setTitle(C.cYellowB + "Type Wars " + C.cGray + "Team Deathmatch").addLore(new String[] { - ChatColor.RESET + "", - ChatColor.RESET + "One team must defend two bomb sites from", - ChatColor.RESET + "the other team, who are trying to plant a bomb", - ChatColor.RESET + "and blow them up!", - ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("MS") + ChatColor.RESET + " other players!", - })); - - setItem(26, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Draw My Thing " + C.cGray + "Pictionary!", new String[] - { - ChatColor.RESET + "", - ChatColor.RESET + "Players take turns at drawing a random", - ChatColor.RESET + "word. Whoever guesses it within the time", - ChatColor.RESET + "limit gets some points!", - ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("DMT") + ChatColor.RESET + " other players!", - })); - - setItem(36, ItemStackFactory.Instance.CreateStack(Material.BEACON.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Dominate " + C.cGray + "Team Game", new String[] + (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", + C.Reset + "", + C.Reset + "Attack your enemies with", + C.Reset + "waves of mobs. Defend your giant", + C.Reset + "by typing the name of an enemy mob", + C.Reset + "to kill it.", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("TW") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectTWButton(this)); + + addButton(5, new ItemBuilder(Material.IRON_SWORD).setTitle(C.cYellowB + "Gladiators" + C.cGray + " Bracketted Deathmatch").addLore(new String[] { - ChatColor.RESET + "", - ChatColor.RESET + "Customize one of five exciting champions", - ChatColor.RESET + "and battle with the opposing team for the", - ChatColor.RESET + "control points on the map.", - ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("DOM") + ChatColor.RESET + " other players!", - })); - - setItem(38, ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Team Deathmatch " + C.cGray + "Team Game", new String[] + (_extraValue ? C.cAquaB : C.cWhiteB) + "FEATURED ARCADE GAME", + C.Reset + "", + C.Reset + "A 1v1 tournament.", + C.Reset + "Kill your enemy and then", + C.Reset + "run to the next arena!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("GLD") + C.Reset + " other players!" + }).setHideInfo(true).build(), new SelectFEATButton(this, "Gladiators")); + + addButton(9, new ItemBuilder(Material.IRON_PICKAXE).setTitle(C.cYellowB + "The Bridges " + C.cGray + "4 Team Survival").addLore(new String[] { - ChatColor.RESET + "", - ChatColor.RESET + "Customize one of five exciting champions", - ChatColor.RESET + "and battle with the opposing team to the", - ChatColor.RESET + "last man standing.", - ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("TDM") + ChatColor.RESET + " other players!", - })); - - setItem(40, ItemStackFactory.Instance.CreateStack(Material.WOOD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Master Builders " + C.cGray + "Creative Build", new String[] - { - ChatColor.RESET + "", - ChatColor.RESET + "Players are given a Build Theme and ", - ChatColor.RESET + "must use blocks, monsters and more", - ChatColor.RESET + "to create a masterpiece!", - ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BLD") + ChatColor.RESET + " other players!", - })); - - setItem(24, new ItemBuilder(Material.TNT) - .setTitle(C.Reset + C.Bold + C.cYellow + "Mine-Strike " + C.cGray + "Team Survival").addLore(new String[] - { - C.Reset + "", - C.Reset + "One team must defend two bomb sites from", - C.Reset + "the other team, who are trying to plant a bomb", - C.Reset + "and blow them up!", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("MS") + C.Reset + " other players!", - }).setHideInfo(true).build()); + C.Reset + "", + C.Reset + "4 Teams get 10 minutes to prepare.", + C.Reset + "Then the bridges drop, and all hell", + C.Reset + "breaks loose as you battle to the", + C.Reset + "death with the other teams.", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("BR") + C.Reset + " other players!" + }).setHideInfo(true).build(), new SelectBRButton(this)); - setItem(26, new ItemBuilder(Material.BOOK_AND_QUILL) - .setTitle(C.Reset + C.Bold + C.cYellow + "Draw My Thing " + C.cGray + "Pictionary!").addLore(new String[] - { - C.Reset + "", - C.Reset + "Players take turns at drawing a random", - C.Reset + "word. Whoever guesses it within the time", - C.Reset + "limit gets some points!", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("DMT") + C.Reset + " other players!", - }).setHideInfo(true).build()); + addButton(11, new ItemBuilder(Material.DIAMOND_SWORD).setTitle(C.cYellowB + "Survival Games " + C.cGray + "Solo/Team Survival").addLore(new String[] + { + C.Reset + "", + C.Reset + "Search for chests to find loot and ", + C.Reset + "fight others to be the last man standing. ", + C.Reset + "Stay away from the borders!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + (getPlugin().getGroupTagPlayerCount("HG") + getPlugin().getGroupTagPlayerCount("SG2")) + C.Reset + " other players!" + }).setHideInfo(true).build(), new SelectSGButton(this)); - setItem(36, new ItemBuilder(Material.BEACON).setTitle(C.Reset + C.Bold + C.cYellow + "Dominate " + C.cGray + "Team Game") - .addLore(new String[] - { - C.Reset + "", - C.Reset + "Customize one of five exciting champions", - C.Reset + "and battle with the opposing team for the", - C.Reset + "control points on the map.", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("DOM") + C.Reset + " other players!", - }).setHideInfo(true).build()); + addButton(13, new ItemBuilder(Material.FEATHER).setTitle(C.cYellowB + "Skywars " + C.cGray + "Solo/Team Survival").addLore(new String[] + { + C.Reset + "", + C.Reset + "16 contenders fight to rule the skies!", + C.Reset + "Spawn on a sky island and build your path!", + C.Reset + "Find weapons to take your enemies down!", + C.Reset + "Up in the skies, death looming if you fall..", + C.Reset + "Win! Fight! Send enemies flying in Skywars!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + (getPlugin().getGroupTagPlayerCount("SKY") + getPlugin().getGroupTagPlayerCount("SKY2")) + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectSKYButton(this)); - setItem(38, new ItemBuilder(Material.GOLD_SWORD) - .setTitle(C.Reset + C.Bold + C.cYellow + "Team Deathmatch " + C.cGray + "Team Game").addLore(new String[] - { - C.Reset + "", - C.Reset + "Customize one of five exciting champions", - C.Reset + "and battle with the opposing team to the", - C.Reset + "last man standing.", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("TDM") + C.Reset + " other players!", - }).setHideInfo(true).build()); + addButton(15, new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cYellowB + "UHC " + C.cGray + "Ultra Hardcore Mode").addLore(new String[] + { + C.Reset + "", + C.Reset + "Extremely hard team-based survival ", + C.Reset + "Gather materials and fight your way", + C.Reset + "to become the last team standing!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("UHC") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectUHCButton(this)); - setItem(40, new ItemBuilder(Material.WOOD) - .setTitle(C.Reset + C.Bold + C.cYellow + "Master Builders " + C.cGray + "Creative Build").addLore(new String[] - { - C.Reset + "", - C.Reset + "Players are given a Build Theme and ", - C.Reset + "must use blocks, monsters and more", - C.Reset + "to create a masterpiece!", - C.Reset + "", - C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("BLD") + C.Reset + " other players!", - }).setHideInfo(true).build()); + addButton(17, new ItemBuilder(Material.BLAZE_ROD).setTitle(C.cYellowB + "Wizards " + C.cGray + "Last Man Standing").addLore(new String[] + { + C.Reset + "", + C.Reset + "Wield powerful spells to fight", + C.Reset + "against other players in this", + C.Reset + "exciting free-for-all brawl!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("WIZ") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectWIZButton(this)); - setItem(42, _minigameCycle.get(_minigameIndex)); + addButton(18, new ItemBuilder(Material.BANNER).setColor(Color.RED).setTitle(C.cYellowB + "Capture the Flag " + C.cGray + "Team Game").addLore(new String[] + { + C.Reset + "", + C.Reset + "One team must steal the other", + C.Reset + "team's flag. Capture it", + C.Reset + "three times to win.", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("CTF") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectCTFButton(this)); - setItem(44, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3) - .setTitle(C.Reset + C.Bold + C.cYellow + "Player Servers " + C.cGray + "Player Hosted Games").addLore(new String[] - { - C.Reset + "", - C.Reset + "Join your friends in their own ", - C.Reset + "Mineplex Player Server. You can play", - C.Reset + "the games you want, when you want.", - C.Reset + "", - }).setHideInfo(true).build()); + addButton(20, new ItemBuilder(Material.BEACON).setTitle(C.cYellowB + "Dominate " + C.cGray + "Team Game").addLore(new String[] + { + C.Reset + "", + C.Reset + "Customize one of five exciting champions", + C.Reset + "and battle with the opposing team for the", + C.Reset + "control points on the map.", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("DOM") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectDOMButton(this)); - getButtonMap().put(0, new SelectBRButton(this)); - getButtonMap().put(2, new SelectSGButton(this)); - getButtonMap().put(4, new SelectSKYButton(this)); - getButtonMap().put(6, new SelectUHCButton(this)); - getButtonMap().put(8, new SelectWIZButton(this)); + addButton(22, new ItemBuilder(Material.GOLD_SWORD).setTitle(C.cYellowB + "Team Deathmatch " + C.cGray + "Team Game").addLore(new String[] + { + C.Reset + "", + C.Reset + "Customize one of five exciting champions", + C.Reset + "and battle with the opposing team to the", + C.Reset + "last man standing.", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("TDM") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectTDMButton(this)); - getButtonMap().put(18, new SelectCSButton(this)); - getButtonMap().put(20, new SelectBHButton(this)); - getButtonMap().put(22, new SelectSSMButton(this)); - getButtonMap().put(24, new SelectMSButton(this)); - getButtonMap().put(26, new SelectDMTButton(this)); - getButtonMap().put(36, new SelectDOMButton(this)); - getButtonMap().put(38, new SelectTDMButton(this)); - getButtonMap().put(40, new SelectBLDButton(this)); - getButtonMap().put(42, new SelectMINButton(this)); - getButtonMap().put(44, new SelectPLAYERButton(this)); - // getButtonMap().put(44, new SelectBETAButton(this)); + addButton(24, new ItemBuilder(Material.DIAMOND_CHESTPLATE).setTitle(C.cYellowB + "Castle Siege " + C.cGray + "Team Game").addLore(new String[] + { + C.Reset + "", + C.Reset + "Defenders must protect King Sparklez", + C.Reset + "from the endless waves of Undead", + C.Reset + "until the sun rises!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("CS") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectCSButton(this)); + + addButton(26, new ItemBuilder(Material.GRASS).setTitle(C.cYellowB + "Block Hunt " + C.cGray + "Cat and Mouse").addLore(new String[] + { + C.Reset + "", + C.Reset + "Hide as blocks/animals, upgrade your ", + C.Reset + "weapon and fight to survive against", + C.Reset + "the Hunters!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("BH") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectBHButton(this)); + + addButton(27, new ItemBuilder(Material.TNT).setTitle(C.cYellowB + "MineStrike " + C.cGray + "Team Survival").addLore(new String[] + { + C.Reset + "", + C.Reset + "One team must defend two bomb sites from", + C.Reset + "the other team, who are trying to plant a bomb", + C.Reset + "and blow them up!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("MS") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectMSButton(this)); + + addButton(29, new ItemBuilder(Material.BOOK_AND_QUILL).setTitle(C.cYellowB + "Draw My Thing " + C.cGray + "Pictionary").addLore(new String[] + { + C.Reset + "", + C.Reset + "Players take turns at drawing a random", + C.Reset + "word. Whoever guesses it within the time", + C.Reset + "limit gets some points!", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("DMT") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectDMTButton(this)); + + addButton(31, _superSmashCycle.get(_ssmIndex), new SelectSSMButton(this)); + + addButton(33, _minigameCycle.get(_minigameIndex), new SelectMINButton(this)); + + addButton(35, new ItemBuilder(Material.WOOD).setTitle(C.cYellowB + "Master Builders " + C.cGray + "Creative Build").setLore(new String[] + { + C.Reset + "", + C.Reset + "Players are given a Build Theme and ", + C.Reset + "must use blocks, monsters and more", + C.Reset + "to create a masterpiece!", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BLD") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectBLDButton(this)); + + addButton(37, new ItemBuilder(Material.SNOW_BALL).setTitle(C.cYellowB + "Snow Fight " + C.cGray + "Team Survival").addLore(new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "LIMITED TIME", + C.Reset + "", + C.Reset + "Harness the power of snow", + C.Reset + "to vanquish your enemies in", + C.Reset + "this ULTIMATE snowball fight!", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("SF") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectFEATButton(this, "Snow Fight")); + + addButton(39, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.cYellowB + "Player Servers " + C.cGray + "Player Hosted Games").addLore(new String[] + { + C.Reset + "", + C.Reset + "Join your friends in their own ", + C.Reset + "Mineplex Player Server. You can play", + C.Reset + "the games you want, when you want.", + }).setHideInfo(true).build(), new SelectPLAYERButton(this)); + + addButton(40, new ItemBuilder(Material.IRON_DOOR).setTitle(C.cYellowB + "Mineplex Clans " + C.cGray + "Champions Teams").addLore(new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "ALPHA RELEASE", + C.Reset + "", + C.Reset + "Equip custom skills and builds", + C.Reset + "and join your clan to destroy", + C.Reset + "and raid others!", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("Clans") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectCLANSButton(this)); + + addButton(41, new ItemBuilder(Material.BREWING_STAND_ITEM).setTitle(C.cYellowB + "Monster Maze " + C.cGray + "Snow Sprint").addLore(new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA GAME", + C.Reset + "", + C.Reset + "Run along a maze avoiding", + C.Reset + "evil monsters. Get to the", + C.Reset + "Safe-Pad or be killed!", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BETA") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectBETAButton(this)); + + addButton(43, new ItemBuilder(Material.BOOKSHELF).setTitle(C.cYellowB + "Christmas Chaos " + C.cGray + "Help Save Christmas").addLore(new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "LIMITED TIME", + C.Reset + "", + C.Reset + "Band together with your friends", + C.Reset + "and help Santa save Christmas from", + C.Reset + "a deadly enemy...", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("CC") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectFEATButton(this, "Christmas Chaos")); } - @SuppressWarnings("deprecation") private void createMinigameCycle() { - int playerCount = getPlugin().getGroupTagPlayerCount("MIN") + getPlugin().getGroupTagPlayerCount("DR") - + getPlugin().getGroupTagPlayerCount("DE") + getPlugin().getGroupTagPlayerCount("PB") - + getPlugin().getGroupTagPlayerCount("TF") + getPlugin().getGroupTagPlayerCount("RUN") - + getPlugin().getGroupTagPlayerCount("SN") + getPlugin().getGroupTagPlayerCount("DT") - + getPlugin().getGroupTagPlayerCount("SQ") + getPlugin().getGroupTagPlayerCount("SA") - + getPlugin().getGroupTagPlayerCount("SS") + getPlugin().getGroupTagPlayerCount("OITQ"); + int playerCount = 0 + + getPlugin().getGroupTagPlayerCount("MIN") + + getPlugin().getGroupTagPlayerCount("DR") + + getPlugin().getGroupTagPlayerCount("DE") + + getPlugin().getGroupTagPlayerCount("PB") + + getPlugin().getGroupTagPlayerCount("TF") + + getPlugin().getGroupTagPlayerCount("RUN") + + getPlugin().getGroupTagPlayerCount("SN") + + getPlugin().getGroupTagPlayerCount("DT") + + getPlugin().getGroupTagPlayerCount("SQ") + + getPlugin().getGroupTagPlayerCount("SA") + + getPlugin().getGroupTagPlayerCount("SS") + + getPlugin().getGroupTagPlayerCount("OITQ") + + getPlugin().getGroupTagPlayerCount("BB") + + getPlugin().getGroupTagPlayerCount("MB") + + getPlugin().getGroupTagPlayerCount("EVO") + + getPlugin().getGroupTagPlayerCount("GLD") + + getPlugin().getGroupTagPlayerCount("BL"); _minigameCycle.add(new ItemBuilder(Material.SMOOTH_BRICK) .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + C.Bold + C.cGreen + "Super Spleef", C.Reset + "Runner", @@ -310,7 +317,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + C.Bold + C.cGreen + "Runner", @@ -331,7 +338,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -352,7 +359,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -373,7 +380,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -394,7 +401,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -415,7 +422,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -436,7 +443,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -457,7 +464,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -478,7 +485,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -499,7 +506,7 @@ public class ServerGameMenu extends ShopPageBase .setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(new String[] { C.Reset + "", - C.Reset + "Play all of these fun minigames:", + C.Reset + "Play all of these fun minigames and more!", C.Reset + "", C.Reset + "Super Spleef", C.Reset + "Runner", @@ -520,26 +527,37 @@ public class ServerGameMenu extends ShopPageBase private void createSuperSmashCycle() { String[] desc = new String[] - { - C.Reset + "", - C.Reset + "Pick from a selection of monsters,", - C.Reset + "then battle other players to the ", - C.Reset + "death with your monsters skills!", - C.Reset + "", - C.Reset + "Join " + C.cGreen - + (getPlugin().getGroupTagPlayerCount("SSM") + getPlugin().getGroupTagPlayerCount("SSM2")) + C.Reset - + " other players!", - }; + { + C.Reset + "", + C.Reset + "Pick from a selection of monsters,", + C.Reset + "then battle other players to the ", + C.Reset + "death with your monsters skills!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + (getPlugin().getGroupTagPlayerCount("SSM") + getPlugin().getGroupTagPlayerCount("SSM2")) + C.Reset + " other players!", + }; - _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 4) - .setTitle(C.Reset + C.Bold + C.cYellow + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc) - .setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 0).setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 1).setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 2).setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_LavaSlime").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Golem").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Enderman").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Cow").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Chicken").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Blaze").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Squid").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Spider").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Slime").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Sheep").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setPlayerHead("MHF_Pig").setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); + _superSmashCycle.add(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 4).setTitle(C.cYellowB + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch").addLore(desc).setHideInfo(true).build()); } public void Update() { _ssmIndex++; _minigameIndex++; + _extraValue = !_extraValue; if (_ssmIndex >= _superSmashCycle.size()) _ssmIndex = 0; @@ -565,6 +583,11 @@ public class ServerGameMenu extends ShopPageBase getPlugin().getDominateShop().attemptShopOpen(player); } + public void openCtf(Player player) + { + getPlugin().getCtfShop().attemptShopOpen(player); + } + public void openCS(Player player) { getPlugin().getCastleSiegeShop().attemptShopOpen(player); @@ -614,6 +637,11 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getBetaShop().attemptShopOpen(player); } + + public void openFeatured(Player player, String name) + { + getPlugin().getShop(name).attemptShopOpen(player); + } public void openUHC(Player player) { @@ -629,4 +657,14 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getPlayerGamesShop().attemptShopOpen(player); } + + public void openClans(Player player) + { + getPlugin().getClansShop().attemptShopOpen(player); + } + + public void openTypeWars(Player player) + { + getPlugin().getTypeWarsShop().attemptShopOpen(player); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCLANSButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCLANSButton.java new file mode 100644 index 000000000..49b4a270f --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCLANSButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectCLANSButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectCLANSButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openClans(player); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCTFButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCTFButton.java new file mode 100644 index 000000000..78633dffc --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCTFButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectCTFButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectCTFButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openCtf(player); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectFEATButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectFEATButton.java new file mode 100644 index 000000000..2174481bb --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectFEATButton.java @@ -0,0 +1,25 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectFEATButton implements IButton +{ + private ServerGameMenu _menu; + private String _name; + + public SelectFEATButton(ServerGameMenu menu, String name) + { + _menu = menu; + _name = name; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openFeatured(player, _name); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTWButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTWButton.java new file mode 100644 index 000000000..daecaad39 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTWButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectTWButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectTWButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openTypeWars(player); + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index ef2f17d9b..8f2788e66 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -3,8 +3,6 @@ package mineplex.minecraft.game.core.damage; import java.util.ArrayList; import java.util.HashMap; -import mineplex.core.common.util.C; - import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -15,6 +13,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.core.common.util.C; + public class CustomDamageEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @@ -43,6 +43,7 @@ public class CustomDamageEvent extends Event implements Cancellable private boolean _knockback = true; private boolean _damageeBrute = false; private boolean _damageToLevel = true; + private boolean _arrowShow = true; public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile, Location knockbackOrigin, DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor, String initialSource, @@ -167,6 +168,16 @@ public class CustomDamageEvent extends Event implements Cancellable { return _projectile; } + + public void setShowArrows(boolean show) + { + _arrowShow = show; + } + + public boolean getShowArrows() + { + return _arrowShow; + } public DamageCause GetCause() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index af1525e2a..8d3d35d16 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -378,7 +378,7 @@ public class DamageManager extends MiniPlugin event.GetDamageeEntity().playEffect(EntityEffect.HURT); //Sticky Arrow - if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) + if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow && event.getShowArrows()) ((CraftLivingEntity)event.GetDamageeEntity()).getHandle().o(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().bv() + 1); //Knockback diff --git a/Plugins/Mineplex.PlayerCache/.project b/Plugins/Mineplex.PlayerCache/.project deleted file mode 100644 index 5321c2157..000000000 --- a/Plugins/Mineplex.PlayerCache/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Cache - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Queuer/.gitignore b/Plugins/Mineplex.Queuer/.gitignore index 5e56e040e..167fb2c02 100644 --- a/Plugins/Mineplex.Queuer/.gitignore +++ b/Plugins/Mineplex.Queuer/.gitignore @@ -1 +1,2 @@ /bin +/bin diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 8056b8d2a..cb57dc313 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -406,30 +406,40 @@ public class ServerMonitor if (deadServer.getUptime() <= 10 || ignoreServer(deadServer.getGroup())) continue; - if (_count == 0 || deadServers.contains(deadServer.getName())) + try { - copyServerLog(deadServer); - killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true); - - handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup())); - } - else if (!_delayedKill.contains(deadServer.getName())) - { - startTimingReport(deadServer); - - _timer.schedule(new TimerTask() + if (_count == 0 || deadServers.contains(deadServer.getName())) { - public void run() + if (_count != 0) + copyServerLog(deadServer); + + killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true); + + handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup())); + } + else if (!_delayedKill.contains(deadServer.getName())) + { + startTimingReport(deadServer); + + _timer.schedule(new TimerTask() { - _deadServers.add(deadServer.getName()); - _delayedKill.remove(deadServer.getName()); - - stopTimingReport(deadServer); - log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress()); - } - }, 20 * 1000); - - _delayedKill.add(deadServer.getName()); + public void run() + { + _deadServers.add(deadServer.getName()); + _delayedKill.remove(deadServer.getName()); + + stopTimingReport(deadServer); + log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress()); + } + }, 20 * 1000); + + _delayedKill.add(deadServer.getName()); + } + } + catch (Exception exception) + { + log("[ERROR] : Trying to delete " + deadServer.getName() + ":" + deadServer.getPublicAddress()); + exception.printStackTrace(); } } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 99fd02eb4..1f12a4982 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -105,6 +105,7 @@ public class CustomerSupport extends MiniPlugin int oldChestsReceived = 0; int ancientChestsReceived = 0; int mythicalChestsReceived = 0; + int winterChestsReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -150,12 +151,24 @@ public class CustomerSupport extends MiniPlugin } } + if (transaction.SalesPackageName.startsWith("Winter Chest")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 3) + winterChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + winterChestsReceived += 1; + } + + } } caller.sendMessage(C.cBlue + "Enjin Coin Total Received : " + C.cYellow + enjinCoinsReceived); caller.sendMessage(C.cBlue + "Old Chests Received : " + C.cYellow + oldChestsReceived); caller.sendMessage(C.cBlue + "Ancient Chests Received : " + C.cYellow + ancientChestsReceived); caller.sendMessage(C.cBlue + "Mythical Chests Received : " + C.cYellow + mythicalChestsReceived); + caller.sendMessage(C.cBlue + "Winter Chests Received : " + C.cYellow + winterChestsReceived); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _salesPackageManager.displaySalesPackages(caller, playerName); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java index f0cf867d4..33b63e8a5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java @@ -24,7 +24,7 @@ public class PasswordRepository extends RepositoryBase public PasswordRepository(JavaPlugin plugin, String serverName) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _serverName = serverName; } diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java index 19a3c37b3..4817371cb 100644 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -179,7 +179,7 @@ public class VotifierManager extends MiniPlugin private void awardBonus(final String playerName, final UUID uuid, final Callback onComplete) { - DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + DSLContext create = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); Record1 idRecord = create.select(Tables.accounts.id).from(Tables.accounts).where(Tables.accounts.uuid.eq(uuid.toString())).fetchOne(); if (idRecord != null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index d31f9cca2..3c471d91e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -8,6 +8,10 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; +import mineplex.core.account.CoreClient; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.chatsnap.SnapshotManager; +import mineplex.core.chatsnap.SnapshotPlugin; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotPlugin; import mineplex.core.giveaway.GiveawayManager; @@ -155,12 +159,13 @@ public class Arcade extends JavaPlugin cosmeticManager.disableTeamArmor(); GiveawayManager giveawayManager = new GiveawayManager(this, _clientManager, serverStatusManager); + CustomDataManager customDataManager = new CustomDataManager(this, _clientManager); new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager, petManager, statsManager, giveawayManager); //Arcade Manager PollManager pollManager = new PollManager(this, _clientManager, _donationManager); - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager, customDataManager); new MemoryFix(this); new CustomTagFix(this, packetHandler); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 7e9d4a156..9403f9d7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -6,6 +6,39 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBurnEvent; +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.EntityExplodeEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.util.Vector; + +import com.google.common.base.Objects; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -28,6 +61,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; @@ -39,7 +73,6 @@ import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.movement.Movement; -import mineplex.core.notifier.NotificationManager; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; import mineplex.core.party.PartyManager; @@ -48,9 +81,7 @@ import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; -import mineplex.core.resourcepack.ResPackManager; -import mineplex.core.resourcepack.ResUnloadCheck; -import mineplex.core.resourcepack.redis.RedisUnloadResPack; +import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; @@ -100,45 +131,14 @@ import nautilus.game.arcade.managers.GameManager; import nautilus.game.arcade.managers.GamePlayerManager; import nautilus.game.arcade.managers.GameSpectatorManager; import nautilus.game.arcade.managers.GameStatManager; +import nautilus.game.arcade.managers.GameTestingManager; import nautilus.game.arcade.managers.GameTournamentManager; import nautilus.game.arcade.managers.GameWorldManager; import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; +import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockBurnEvent; -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.EntityExplodeEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerResourcePackStatusEvent; -import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.util.Vector; - -import com.google.common.base.Objects; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -191,15 +191,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation private PartyManager _partyManager; private PreferencesManager _preferencesManager; private GiveawayManager _giveawayManager; + private ResourcePackManager _resourcePackManager; + private CustomDataManager _customDataManager; private TaskManager _taskManager; private PacketHandler _packetHandler; - private String _resourcePackUrl; - private boolean _resourcePackRequired; - private NautHashMap _resourcePackUsers = new NautHashMap(); - private NautHashMap _resourcePackNoResponse = new NautHashMap(); - // Observers private HashSet _specList = new HashSet(); @@ -219,7 +216,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, - CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager, GiveawayManager giveawayManager) + CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, + NpcManager npcManager, GiveawayManager giveawayManager, CustomDataManager customDataManager) { super("Game Manager", plugin); @@ -278,6 +276,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation _petManager = petManager; _eventManager = new EventModule(this, getPlugin()); _giveawayManager = giveawayManager; + _resourcePackManager = new ResourcePackManager(plugin, portal); + + _customDataManager = customDataManager; // Shop _arcadeShop = new ArcadeShop(this, clientManager, donationManager); @@ -302,6 +303,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); new HolidayManager(this, titanGiveaway); + new GameTestingManager(this); // Game Addons new CompassAddon(plugin, this); @@ -340,19 +342,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation }, 80L); } - new ResPackManager(new ResUnloadCheck() - { - public boolean canSendUnload(Player player) - { - if (_resourcePackUsers.containsKey(player.getName())) - { - return false; - } - - return true; - } - }); - loadRequiredRank(); } @@ -365,69 +354,17 @@ public class ArcadeManager extends MiniPlugin implements IRelation addCommand(new DisguiseCommand(this)); addCommand(new RequiredRankCommand(this)); } - - @EventHandler - public void onResourcePackStatus(PlayerResourcePackStatusEvent event) - { - if (_resourcePackUrl == null) - { - return; - } - - Player player = event.getPlayer(); - - if (_resourcePackRequired) - { - if (event.getStatus() == Status.ACCEPTED) - { - _resourcePackNoResponse.remove(player.getName()); - } - else if (event.getStatus() == Status.DECLINED) - { - _resourcePackNoResponse.remove(player.getName()); - - UtilPlayer.message(player, " "); - JsonMessage message = new JsonMessage("") - .color("gold") - .bold() - .extra("You need to accept the resource pack!\n" - + "Click me for instructions on how to fix this!") - - .click(ClickEvent.OPEN_URL, - - "http://mineplex.com/forums/m/11929946/viewthread/21554536-wizards-resource-pack-help"); - - message.sendToPlayer(player); - UtilPlayer.message(player, " "); - - returnHubNoResPack(player); - } - else if (event.getStatus() == Status.FAILED_DOWNLOAD) - { - _resourcePackNoResponse.remove(player.getName()); - - returnHubNoResPack(player, "Failed to download resource pack!"); - - return; - } - } - - if (event.getStatus() == Status.ACCEPTED - || event.getStatus() == Status.SUCCESSFULLY_LOADED) - { - _resourcePackUsers.put(player.getName(), true); - } - else - { - _resourcePackUsers.remove(player.getName()); - } - } public GameServerConfig GetServerConfig() { return _serverConfig; } + public ResourcePackManager getResourcePackManager() + { + return _resourcePackManager; + } + public ArrayList GetGameList() { return GetServerConfig().GameList; @@ -598,6 +535,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _serverStatusManager; } + public CustomDataManager getCustomDataManager() { return _customDataManager; } + public ChatColor GetColor(Player player) { if (_game == null) @@ -1435,112 +1374,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return false; } - @EventHandler - public void onSecond(UpdateEvent event) - { - Iterator> itel = _resourcePackNoResponse.entrySet().iterator(); - - while (itel.hasNext()) - { - Entry entry = itel.next(); - - if (UtilTime.elapsed(entry.getValue(), 20000)) - { - Player player = Bukkit.getPlayerExact(entry.getKey()); - - if (player != null) - { - // Send it again, enforce it! - _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); - player.setResourcePack(_resourcePackUrl); - } - else - { - itel.remove(); - } - } - } - } - - @EventHandler - public void ResourcePackQuit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if (_resourcePackUsers.containsKey(player.getName()) && _resourcePackUsers.get(player.getName())) - { - new RedisUnloadResPack(player.getName()).publish(); - - _resourcePackUsers.remove(player.getName()); - } - } - - private void returnHubNoResPack(Player player) - { - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); - GetPortal().sendPlayerToServer(player, "Lobby"); - } - - private void returnHubNoResPack(Player player, String message) - { - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cGold + C.Bold + message); - UtilPlayer.message(player, " "); - - returnHubNoResPack(player); - } - - @EventHandler - public void ResourcePackJoin(PlayerJoinEvent event) - { - Player player = event.getPlayer(); - - if (_resourcePackUrl != null) - { - if (_resourcePackRequired) - { - _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); - } - - _resourcePackUsers.put(player.getName(), false); - player.setResourcePack(_resourcePackUrl); - } - } - - public void setResourcePack(String resourcePack, boolean forceResourcePack) - { - if (!Objects.equal(resourcePack, _resourcePackUrl) || forceResourcePack != _resourcePackRequired) - { - _resourcePackNoResponse.clear(); - _resourcePackUsers.clear(); - _resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack; - _resourcePackRequired = forceResourcePack; - - if (_resourcePackUrl == null || _resourcePackUrl.isEmpty()) - { - _resourcePackRequired = false; - - for (Player player : Bukkit.getOnlinePlayers()) - { - player.setResourcePack("http://file.mineplex.com/ResReset.zip"); - } - } - else - { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (_resourcePackRequired) - { - _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); - } - - _resourcePackUsers.put(player.getName(), false); - player.setResourcePack(_resourcePackUrl); - } - } - } - } - public void loadRequiredRank() { _requiredRank = null; @@ -1613,4 +1446,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation event.setCancelled(true); } } + + public ArcadePlayer getArcadePlayer(Player player) + { + return new ArcadePlayer(player, getCustomDataManager(), this); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 5ff9e576c..5f647dcd9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -62,6 +62,7 @@ import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames; import nautilus.game.arcade.game.games.tug.Tug; import nautilus.game.arcade.game.games.turfforts.TurfForts; +import nautilus.game.arcade.game.games.typewars.TypeWars; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.games.wizards.Wizards; @@ -104,6 +105,7 @@ public enum GameType Runner(Runner.class, GameDisplay.Runner), SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy), Sheep(SheepGame.class, GameDisplay.Sheep), + TypeWars(TypeWars.class, GameDisplay.TypeWars), Smash(SoloSuperSmash.class, GameDisplay.Smash), SmashDomination(SuperSmashDominate.class, GameDisplay.SmashDomination), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 1d6947f06..6eec52eb7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -383,7 +383,7 @@ public abstract class Game implements Listener new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker( this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this)); - Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); + Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); _useEntityPacketHandler = new IPacketHandler() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java index e66165d86..0ee17ce94 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java @@ -5,14 +5,15 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.baconbrawl.kits.*; +import nautilus.game.arcade.game.games.baconbrawl.kits.KitMamaPig; +import nautilus.game.arcade.game.games.baconbrawl.kits.KitPig; +import nautilus.game.arcade.game.games.baconbrawl.kits.KitSheepPig; import nautilus.game.arcade.kit.Kit; public class BaconBrawl extends SoloGame @@ -34,9 +35,9 @@ public class BaconBrawl extends SoloGame "Last pig in the arena wins!" }); - this.DamageTeamSelf = true; - this.HungerSet = 20; - this.PrepareFreeze = false; + DamageTeamSelf = true; + HungerSet = 20; + PrepareFreeze = false; } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java index 7ab4b7812..c285f9c53 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java @@ -11,7 +11,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.itemstack.ItemStackFactory; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java index db9071a12..1f54d2eec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java @@ -13,7 +13,6 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkBodySlam; -import nautilus.game.arcade.kit.perks.PerkJump; public class KitPig extends Kit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java index 3a63d31ff..5607d41ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.baconbrawl.kits; -import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java new file mode 100644 index 000000000..7c7e71ba0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java @@ -0,0 +1,6 @@ +package nautilus.game.arcade.game.games.bridge; + +public class BattleCryManager +{ + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java index 86765e9a1..3d810c506 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java @@ -26,6 +26,7 @@ public class BridgePart Velocity = velocity; } + @SuppressWarnings("deprecation") public boolean Update() { if (!Entity.isValid()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java index 07e2ab006..8943458b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java @@ -2,17 +2,9 @@ package nautilus.game.arcade.game.games.cards; import java.util.ArrayList; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; - import mineplex.core.common.util.C; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -23,6 +15,13 @@ import nautilus.game.arcade.game.games.GameScore; import nautilus.game.arcade.game.games.cards.kits.KitPlayer; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + public class Cards extends SoloGame { private CardFactory _cardFactory; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index ddb562ae1..a9fcae09a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -22,6 +22,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index 5569229b4..f509b43dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -4,12 +4,55 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.event.Cancellable; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scoreboard.NameTagVisibility; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.hologram.Hologram.HologramTarget; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -21,111 +64,56 @@ import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.paintball.events.PaintballEvent; +import nautilus.game.arcade.game.games.paintball.events.ReviveEvent; 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.trackers.KillingSpreeTracker; +import nautilus.game.arcade.game.games.paintball.trackers.LastStandStatTracker; +import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.KillFastStatTracker; -import nautilus.game.arcade.stats.LastStandStatTracker; -import nautilus.game.arcade.stats.MedicStatTracker; import nautilus.game.arcade.stats.WinFastStatTracker; import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.ThrownPotion; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; public class Paintball extends TeamGame { - public static class ReviveEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final Player _revivedPlayer; - - public ReviveEvent(Player who, Player revivedPlayer) - { - super(who); - - _revivedPlayer = revivedPlayer; - } - - public Player getRevivedPlayer() - { - return _revivedPlayer; - } - } - - private HashMap _doubles = new HashMap(); + private HashMap _doubles = new HashMap(); + @SuppressWarnings("unchecked") public Paintball(ArcadeManager manager) { - super(manager, GameType.Paintball, + super(manager, GameType.Paintball, new Kit[] + { + new KitRifle(manager), + new KitShotgun(manager), + new KitMachineGun(manager), + new KitSniper(manager), + + }, new String[] + { + "Shoot enemies to paint them", + "Revive/heal with Water Bombs", + "Last team alive wins!" + }); - new Kit[] - { - new KitRifle(manager), - new KitShotgun(manager), - new KitMachineGun(manager), - }, + StrictAntiHack = true; - new String[] - { - "Shoot enemies to paint them", - "Revive/heal with Water Bombs", - "Last team alive wins!" - }); - - this.StrictAntiHack = true; + HungerSet = 20; - this.HungerSet = 20; + InventoryClick = false; + + TeamArmorHotbar = true; registerStatTrackers( - new KillFastStatTracker(this, 4, 5, "KillingSpree"), + new KillingSpreeTracker(this), new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"), new MedicStatTracker(this), new WinFastStatTracker(this, 30, "Speedrunner"), new LastStandStatTracker(this) - ); + ); } @EventHandler @@ -140,6 +128,14 @@ public class Paintball extends TeamGame this.GetTeamList().get(1).SetColor(ChatColor.RED); this.GetTeamList().get(1).SetName("Nether"); } + + @EventHandler + public void onNameTag(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare) + for (Team team : Scoreboard.GetScoreboard().getTeams()) + team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); + } @EventHandler(priority = EventPriority.HIGHEST) public void ColorArmor(PlayerPrepareTeleportEvent event) @@ -160,47 +156,63 @@ public class Paintball extends TeamGame if (event.getCause() == TeleportCause.ENDER_PEARL) event.setCancelled(true); } - + + @SuppressWarnings("deprecation") @EventHandler - public void Paint(ProjectileHitEvent event) + public void Paint(final ProjectileHitEvent event) { - // Fixed projectile wool painting in waiting lobby. - if (IsLive() || GetState() == GameState.End) { if (event.getEntity() instanceof ThrownPotion) return; - byte color = 3; - if (event.getEntity() instanceof EnderPearl) - color = 14; + final byte color = (byte) (event.getEntity() instanceof EnderPearl || (event.getEntity() instanceof Arrow && event.getEntity().hasMetadata("color") && ChatColor.values()[event.getEntity().getMetadata("color").get(0).asInt()] == ChatColor.RED) ? 14 : 3); - Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity()); + event.getEntity().setVelocity(event.getEntity().getVelocity().normalize().multiply(1.2)); - for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) - { - if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) - continue; + PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(new int[]{event.getEntity().getEntityId()}); + for (Player player : UtilServer.getPlayers()) + UtilPlayer.sendPacket(player, destroy); - block.setData(color); - } + Manager.runSyncLater(new Runnable() // Stupid thing I have to do to make sure the arrow's location is accounted for. Stupid mojang. - Myst + { + @Override + public void run() + { + Location loc = event.getEntity().getLocation(); + // loc.add(event.getEntity().getVelocity().clone().normalize().multiply(.5)); - if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); - else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + { + if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY && block.getType() != Material.HARD_CLAY) + continue; + if (block.getType() == Material.HARD_CLAY) + block.setType(Material.STAINED_CLAY); + + block.setData(color); + } + + if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); + else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + + event.getEntity().remove(); + } + }, 0); } } @EventHandler - public void PlayerQuit(PlayerQuitEvent event) + public void onQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); if (_doubles.containsKey(player)) { - PlayerCopy copy = _doubles.get(player); + PlayerCopyPaintball copy = _doubles.remove(player); copy.GetEntity().remove(); - _doubles.remove(player); + copy.GetHolo().stop(); + copy.GetSaveMe().stop(); } } @@ -216,7 +228,7 @@ public class Paintball extends TeamGame event.SetCancelled("No Projectile"); } - @EventHandler + @EventHandler(priority = EventPriority.LOW) public void PaintballDamage(CustomDamageEvent event) { if (!IsLive()) @@ -225,7 +237,7 @@ public class Paintball extends TeamGame if (event.GetProjectile() == null) return; - if (!(event.GetProjectile() instanceof Snowball) && !(event.GetProjectile() instanceof EnderPearl)) + if (!(event.GetProjectile() instanceof Snowball) && !(event.GetProjectile() instanceof EnderPearl) && !(event.GetProjectile() instanceof Arrow)) return; //Negate @@ -234,6 +246,8 @@ public class Paintball extends TeamGame event.AddMod("Paintball", "Paintball", 2, true); event.AddKnockback("Paintball", 2); + + event.setShowArrows(false); Player damagee = event.GetDamageePlayer(); if (damagee == null) @@ -262,6 +276,13 @@ public class Paintball extends TeamGame { count = 3; } + if (GetKit(damager) instanceof KitSniper && event.GetProjectile() instanceof Arrow) + { + count = ((KitSniper) GetKit(damager)).getPaintDamage((Arrow) event.GetProjectile()); + + if (count == -1) + count = 1; + } } //Out @@ -271,12 +292,14 @@ public class Paintball extends TeamGame UtilPlayer.message(player, damageeTeam.GetColor() + damagee.getName() + ChatColor.RESET + " was painted by " + damagerTeam.GetColor() + damager.getName() + ChatColor.RESET + "!"); - PlayerOut(damagee); + PlayerOut(damagee, damager); AddGems(damager, 2, "Kills", true, true); AddStat(damager, "Kills", 1, false, false); AddStat(damagee, "Deaths", 1, false, false); + + Bukkit.getPluginManager().callEvent(new PaintballEvent(damagee, damager)); } //Hit Sound @@ -288,14 +311,8 @@ public class Paintball extends TeamGame @EventHandler public void ArmorRemoveCancel(InventoryClickEvent event) { - HumanEntity player = event.getWhoClicked(); - - // Fixed armor being taken off while spectating after being painted. - - if (!IsAlive(player)) - { + if (!IsAlive(event.getWhoClicked())) event.setCancelled(true); - } } public boolean Color(Player player, int amount) @@ -331,8 +348,8 @@ public class Paintball extends TeamGame return nonColored.isEmpty(); } - public void PlayerOut(Player player) - { + public void PlayerOut(Player player, Player killer) + { //State SetPlayerState(player, PlayerState.OUT); player.setHealth(20); @@ -341,15 +358,15 @@ public class Paintball extends TeamGame Manager.GetCondition().Factory().Blind("Hit", player, player, 1.5, 0, false, false, false); Manager.GetCondition().Factory().Cloak("Hit", player, player, 9999, false, false); + _doubles.put(player, new PlayerCopyPaintball(this, player, killer, GetTeam(player).GetColor())); + //Settings player.setAllowFlight(true); player.setFlying(true); ((CraftPlayer)player).getHandle().spectating = true; ((CraftPlayer)player).getHandle().k = false; - + UtilAction.velocity(player, new Vector(0,1.2,0)); - - _doubles.put(player, new PlayerCopy(this, player, GetTeam(player).GetColor())); } // @EventHandler @@ -402,10 +419,10 @@ public class Paintball extends TeamGame if (throwerTeam == null) return; //Revive - Iterator copyIterator = _doubles.values().iterator(); + Iterator copyIterator = _doubles.values().iterator(); while (copyIterator.hasNext()) { - PlayerCopy copy = copyIterator.next(); + PlayerCopyPaintball copy = copyIterator.next(); GameTeam otherTeam = GetTeam(copy.GetPlayer()); if (otherTeam == null || !otherTeam.equals(throwerTeam)) @@ -414,7 +431,8 @@ public class Paintball extends TeamGame if (UtilMath.offset(copy.GetEntity().getLocation().add(0,1,0), event.getEntity().getLocation()) > 3) continue; - PlayerIn(copy.GetPlayer(), copy.GetEntity()); + PlayerIn(copy.GetPlayer(), copy); + copyIterator.remove(); AddGems(thrower, 3, "Revived Ally", true, true); @@ -436,7 +454,7 @@ public class Paintball extends TeamGame } } - public void PlayerIn(final Player player, final LivingEntity copy) + public void PlayerIn(final Player player, final PlayerCopyPaintball copy) { //State SetPlayerState(player, PlayerState.IN); @@ -446,9 +464,9 @@ public class Paintball extends TeamGame if (copy != null) { Location loc = player.getLocation(); - loc.setX(copy.getLocation().getX()); - loc.setY(copy.getLocation().getY()); - loc.setZ(copy.getLocation().getZ()); + loc.setX(copy.GetEntity().getLocation().getX()); + loc.setY(copy.GetEntity().getLocation().getY()); + loc.setZ(copy.GetEntity().getLocation().getZ()); player.teleport(loc); } @@ -480,7 +498,9 @@ public class Paintball extends TeamGame Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, null); //Remove Copy - copy.remove(); + copy.GetEntity().remove(); + copy.GetHolo().stop(); + copy.GetSaveMe().stop(); } }, 4); } @@ -512,4 +532,128 @@ public class Paintball extends TeamGame for (Player player : GetPlayers(true)) player.removePotionEffect(PotionEffectType.WATER_BREATHING); } + + @EventHandler + public void onHeal(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + LaunchPotion(event.getPlayer(), event); + } + + @EventHandler + public void onHeal(PlayerInteractEntityEvent event) + { + LaunchPotion(event.getPlayer(), event); + } + + @EventHandler(ignoreCancelled = false) + public void onHeal(PlayerInteractAtEntityEvent event) + { + LaunchPotion(event.getPlayer(), event); + } + + public void LaunchPotion(Player player, Cancellable event) + { + if (!IsLive()) + return; + + if (!UtilGear.isMat(player.getItemInHand(), Material.POTION)) + return; + + event.setCancelled(true); + + if (!IsAlive(player) || UtilPlayer.isSpectator(player)) + return; + + if (!Recharge.Instance.use(player, "Water Potion", 250, false, false)) + return; + + UtilInv.UseItemInHand(player); + + ThrownPotion potion = player.launchProjectile(ThrownPotion.class); + potion.getEffects().clear(); + potion.getEffects().add(new PotionEffect(PotionEffectType.WATER_BREATHING, 100, 100)); + + Manager.runAsync(new Runnable() + { + @Override + public void run() + { + UtilInv.Update(player); + } + }); + } + + @EventHandler + public void onInteract(PlayerInteractAtEntityEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void updateCloneHolograms(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (PlayerCopyPaintball clone : _doubles.values()) + { + if (clone.GetHolo().getHologramTarget() == HologramTarget.WHITELIST) + { + //Other team blacklist + clone.GetHolo().setHologramTarget(HologramTarget.BLACKLIST); + + for (Player cur : GetPlayers(false)) + { + if (!IsAlive(cur)) + { + if (clone.GetHolo().containsPlayer(cur)) + clone.GetHolo().removePlayer(cur); + } + else + { + if (GetTeam(cur) != GetTeam(clone.GetPlayer())) + { + if (!clone.GetHolo().containsPlayer(cur)) + clone.GetHolo().addPlayer(cur); + } + else if (clone.GetHolo().containsPlayer(cur)) + { + clone.GetHolo().removePlayer(cur); + } + } + } + clone.GetHolo().start(); + } + + clone.setSaveMeFlop(!clone.getSaveMeFlop()); + clone.GetSaveMe().setText((clone.getSaveMeFlop() ? C.cRedB : C.cWhiteB) + "SAVE ME!"); + + for (Player player : GetTeam(clone.GetPlayer()).GetPlayers(false)) + { + if (!IsAlive(player)) // Remove if it's not alive + { + if (clone.GetSaveMe().containsPlayer(player)) + clone.GetSaveMe().removePlayer(player); + } + else + { + boolean hasPotion = UtilInv.contains(player, Material.POTION, (byte) -1, 1); + if (clone.GetSaveMe().containsPlayer(player)) + { + if (!hasPotion) // No potions left + { + clone.GetSaveMe().removePlayer(player); + } + } + else if (hasPotion) + { + clone.GetSaveMe().addPlayer(player); + } + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java new file mode 100644 index 000000000..a42d2592b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java @@ -0,0 +1,119 @@ +package nautilus.game.arcade.game.games.paintball; + +import org.bukkit.ChatColor; +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.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.util.EulerAngle; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.Hologram.HologramTarget; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.game.Game; + +public class PlayerCopyPaintball +{ + private Game Host; + + private Player _owner; + + private ArmorStand _ent; + private Hologram _holo; + private Hologram _saveMe; + + private boolean _saveMeFlop = false; + + public PlayerCopyPaintball(Game host, Player owner, Player paintedBy, ChatColor nameColor) + { + Host = host; + + _owner = owner; + + Location entLoc = owner.getLocation(); + entLoc.setPitch(0F); + + Host.CreatureAllowOverride = true; + _ent = owner.getWorld().spawn(owner.getLocation(), ArmorStand.class); + Host.CreatureAllowOverride = false; + + UtilEnt.ghost(_ent, true, false); + + UtilEnt.Vegetate(_ent); + + _ent.setArms(true); + _ent.setBasePlate(false); + _ent.setVisible(false); + + //Rand pose + int rA = UtilMath.r(20) - 3; + int lA = UtilMath.r(20) - 3; + int rL = UtilMath.r(20) - 3; + int lL = UtilMath.r(20) - 3; + _ent.setRightArmPose(new EulerAngle(Math.toRadians(rA < 0 ? 360 - rA : rA), 0, Math.toRadians(Math.abs(rA)))); + _ent.setRightLegPose(new EulerAngle(Math.toRadians(rL < 0 ? 360 - rL : rL), 0, Math.toRadians(Math.abs(rL)))); + _ent.setLeftArmPose(new EulerAngle(Math.toRadians(lA < 0 ? 360 - lA : lA), 0, Math.toRadians(360 - Math.abs(lA)))); + _ent.setLeftLegPose(new EulerAngle(Math.toRadians(lL < 0 ? 360 - lL : rA), 0, Math.toRadians(360 - Math.abs(lL)))); + + //Armor + _ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents()); + _ent.setItemInHand(owner.getItemInHand()); + + //Player skull + ItemStack skull = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1); + SkullMeta meta = (SkullMeta) skull.getItemMeta(); + meta.setOwner(owner.getName()); + skull.setItemMeta(meta); + _ent.setHelmet(skull); + + //Name + _holo = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.2, 0)); + _holo.setText(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX", C.cWhite + "Painted by " + host.GetTeam(paintedBy).GetColor() + paintedBy.getName()); + _holo.setHologramTarget(HologramTarget.WHITELIST); + _holo.setFollowEntity(_ent); + _holo.start(); + + //Save me + _saveMe = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.8, 0)); + _saveMe.setText(C.cRedB + "SAVE ME!"); + _saveMe.setHologramTarget(HologramTarget.WHITELIST); + _saveMe.setFollowEntity(_ent); + _saveMe.start(); + } + + public LivingEntity GetEntity() + { + return _ent; + } + + public Player GetPlayer() + { + return _owner; + } + + public Hologram GetHolo() + { + return _holo; + } + + public Hologram GetSaveMe() + { + return _saveMe; + } + + public boolean getSaveMeFlop() + { + return _saveMeFlop; + } + + public void setSaveMeFlop(boolean flop) + { + _saveMeFlop = flop; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java new file mode 100644 index 000000000..6de498547 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.paintball.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class PaintballEvent extends PlayerEvent +{ + /** + * Created by: Mysticate + * Timestamp: November 19, 2015 + */ + + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _revivedPlayer; + + public PaintballEvent(Player who, Player revivedPlayer) + { + super(who); + + _revivedPlayer = revivedPlayer; + } + + public Player getKiller() + { + return _revivedPlayer; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java new file mode 100644 index 000000000..1fb253675 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.paintball.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class ReviveEvent extends PlayerEvent +{ + /** + * Created by: Mysticate + * Timestamp: November 19, 2015 + */ + + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _revivedPlayer; + + public ReviveEvent(Player who, Player revivedPlayer) + { + super(who); + + _revivedPlayer = revivedPlayer; + } + + public Player getRevivedPlayer() + { + return _revivedPlayer; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java index 3c6db6cc1..591abb677 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java @@ -1,21 +1,23 @@ package nautilus.game.arcade.game.games.paintball.kits; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballMachineGun; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.PotionMeta; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; - public class KitMachineGun extends Kit { public KitMachineGun(ArcadeManager manager) @@ -39,36 +41,17 @@ public class KitMachineGun extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING, (byte)0, 1, "Paintball Machine Gun")); + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING, (byte)0, 1, F.item("Paintball Machine Gun"))); ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); - - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); + UtilInv.insert(player, potion); - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java index 4bbf4b523..db88ea43c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java @@ -1,21 +1,23 @@ package nautilus.game.arcade.game.games.paintball.kits; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballRifle; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkSpeed; + import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionEffectType; - -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; public class KitRifle extends Kit { @@ -41,37 +43,17 @@ public class KitRifle extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING, (byte)0, 1, "Paintball Rifle")); - - //Potion + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING, (byte)0, 1, F.item("Paintball Rifle"))); + ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); - - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); + UtilInv.insert(player, potion); - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java index a397ccb10..65275c0a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java @@ -1,21 +1,24 @@ package nautilus.game.arcade.game.games.paintball.kits; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballShotgun; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkSpeed; + import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.PotionMeta; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; - public class KitShotgun extends Kit { public KitShotgun(ArcadeManager manager) @@ -40,36 +43,17 @@ public class KitShotgun extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING, (byte)0, 1, "Paintball Shotgun")); + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING, (byte)0, 1, F.item("Paintball Shotgun"))); ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); + UtilInv.insert(player, potion); - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); - - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java new file mode 100644 index 000000000..3baa4479e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java @@ -0,0 +1,81 @@ +package nautilus.game.arcade.game.games.paintball.kits; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; + +import mineplex.core.achievement.Achievement; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballSniper; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitSniper extends Kit +{ + public KitSniper(ArcadeManager manager) + { + super(manager, "Sniper", KitAvailability.Achievement, + + new String[] + { + "Long range sniper rifle", + C.cGold + "Higher damage the longer scoped" + }, + + new Perk[] + { + new PerkPaintballSniper(), + }, + EntityType.ZOMBIE, + new ItemStack(Material.STONE_HOE)); + + setAchievementRequirements(new Achievement[] + { + Achievement.SUPER_PAINTBALL_FLAWLESS_VICTORY, + Achievement.SUPER_PAINTBALL_KILLING_SPREE, + Achievement.SUPER_PAINTBALL_LAST_STAND, + Achievement.SUPER_PAINTBALL_MEDIC, + Achievement.SUPER_PAINTBALL_SPEEDRUNNER, + Achievement.SUPER_PAINTBALL_WINS + }); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_HOE, (byte)0, 1, F.item("Paintball Sniper Rifle"))); + + ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 + PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); + potionMeta.setDisplayName(F.item("Water Bomb")); + potion.setItemMeta(potionMeta); + UtilInv.insert(player, potion); + + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); + } + + public int getPaintDamage(Arrow proj) + { + for (Perk perk : GetPerks()) + { + if (perk instanceof PerkPaintballSniper) + { + return ((PerkPaintballSniper) perk).getPaintDamage(proj); + } + } + return -1; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java index f2097476a..081fef3e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.paintball.kits.perks; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -51,6 +51,9 @@ public class PerkPaintballMachineGun extends Perk @EventHandler public void Shoot(PlayerInteractEvent event) { + if (!Manager.GetGame().IsLive()) + return; + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; @@ -95,7 +98,8 @@ public class PerkPaintballMachineGun extends Perk //Energy if (player.getExp() >= 0.97) return; - player.setExp((float) (player.getExp() + 0.025)); + + player.setExp((float) Math.min(.999, player.getExp() + 0.025)); //Shoot Vector rand = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java index d977b8cfc..944d6ae7a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.paintball.kits.perks; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -39,6 +39,9 @@ public class PerkPaintballRifle extends Perk @EventHandler public void Shoot(PlayerInteractEvent event) { + if (!Manager.GetGame().IsLive()) + return; + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java index 257f58a15..7e6f6646f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.paintball.kits.perks; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -42,6 +42,9 @@ public class PerkPaintballShotgun extends Perk @EventHandler public void Shoot(PlayerInteractEvent event) { + if (!Manager.GetGame().IsLive()) + return; + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java new file mode 100644 index 000000000..f863678e3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -0,0 +1,350 @@ +package nautilus.game.arcade.game.games.paintball.kits.perks; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.metadata.FixedMetadataValue; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.recharge.Recharge; +import mineplex.core.recharge.RechargedEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.kit.Perk; +import net.md_5.bungee.api.ChatColor; +import net.minecraft.server.v1_8_R3.EntityArrow; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; + +public class PerkPaintballSniper extends Perk implements IPacketHandler +{ + /** + * Created by: Mysticate + * Timestamp: October 27, 2015 + */ + + private static class Bullet + { + public Player Shooter; + public int Damage; + public Location LastSeen; + } + + private HashSet _crouching = new HashSet(); + private NautHashMap _fired = new NautHashMap(); + + private double _velocity = 15; + + private boolean _spawning = false; + + public PerkPaintballSniper() + { + super("Sniper Rifle", new String[] + { + C.cYellow + "Crouch" + C.cGray + " to use " + C.cGreen + "Scope", + C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Sniper Rifle", + "Experience Bar represents damage." + }); + } + + @SuppressWarnings("unchecked") + @Override + public void registeredEvents() + { + Manager.getPacketHandler().addPacketHandler(this, PacketPlayOutSpawnEntity.class); + } + + @EventHandler + public void Recharge(RechargedEvent event) + { + if (!event.GetAbility().equals(GetName())) + return; + + event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 2f, 1f); + event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 2f, 1.5f); + } + + @EventHandler + public void Shoot(PlayerInteractEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!UtilGear.isMat(event.getItem(), Material.STONE_HOE)) + return; + + Player player = event.getPlayer(); + + if (!Manager.IsAlive(player)) + return; + + if (UtilPlayer.isSpectator(player)) + return; + + if (!Kit.HasKit(player)) + return; + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, GetName(), 1000, true, true)) + return; + + net.minecraft.server.v1_8_R3.World world = ((CraftWorld) player.getWorld()).getHandle(); + EntityArrow launch = new EntityArrow(world, ((CraftPlayer) player).getHandle(), 0F); + Location location = player.getEyeLocation(); + + launch.projectileSource = player; + launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + + ((Projectile) launch.getBukkitEntity()).setVelocity(player.getEyeLocation().getDirection().clone().multiply(_velocity)); + + _spawning = true; + world.addEntity(launch); + _spawning = false; + + Arrow proj = (Arrow) launch.getBukkitEntity(); + + proj.setMetadata("color", new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetColor().ordinal())); + + Bullet bullet = new Bullet(); + bullet.Shooter = player; + bullet.Damage = getPaintDamage(player); + bullet.LastSeen = proj.getLocation(); + + _fired.put(proj, bullet); + + //Sound + player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 0.8f, 1f); + + player.setSneaking(false); + + //Effects + removeEffects(player); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + //Cleanup check + for (Player player : new HashSet(_crouching)) + { + boolean remove = false; + if (!player.isOnline()) + remove = true; + + if (!Manager.GetGame().IsAlive(player)) + remove = true; + + if (UtilPlayer.isSpectator(player)) + remove = true; + + if (!player.isSneaking()) + remove = true; + + if (!UtilInv.IsItem(player.getItemInHand(), Material.STONE_HOE, (byte) -1)) + remove = true; + + if (!Recharge.Instance.usable(player, GetName())) + remove = true; + + if (remove) + { + if (_crouching.contains(player)) + _crouching.remove(player); + + player.setExp(0F); + player.setSneaking(false); + + // Zoom + removeEffects(player); + } + } + + //Add check + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + continue; + + if (!Kit.HasKit(player)) + continue; + + if (!player.isSneaking()) + continue; + + if (!UtilInv.IsItem(player.getItemInHand(), Material.STONE_HOE, (byte) -1)) + continue; + + if (_crouching.contains(player)) + continue; + + _crouching.add(player); + + // Zoom + addEffects(player); + } + + // Exp check + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + continue; + + if (!Kit.HasKit(player)) + continue; + + if (!_crouching.contains(player)) + continue; + + player.setExp((float) Math.min(.999F, player.getExp() + .03332)); + } + } + + @EventHandler + public void doArrowEffects(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + for (Arrow proj : new ArrayList(_fired.keySet())) + { + Bullet bullet = _fired.get(proj); + + double curRange = 0; + double distance = Math.abs(UtilMath.offset(proj.getLocation(), bullet.LastSeen)); + + while (curRange <= distance) + { + Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); + + //Progress Forwards + curRange += 0.8; + + if (UtilMath.offset(bullet.Shooter.getLocation(), newTarget) < 2) + continue; + + ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; + if (color == ChatColor.BLUE || color == ChatColor.AQUA) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, -1, 1, 1, 1, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + + if (!proj.isValid()) + { + _fired.remove(proj); + continue; + } + + bullet.LastSeen = proj.getLocation(); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void clean(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + for (Player player : _crouching) + { + removeEffects(player); + } + + _crouching.clear(); + + Manager.getPacketHandler().removePacketHandler(this); + } + + private void removeEffects(Player player) + { + // Zoom + if (Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().EndCondition(player, ConditionType.SLOW, GetName()); + +// if (Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) +// Manager.GetCondition().EndCondition(player, ConditionType.JUMP, GetName()); + } + + private void addEffects(Player player) + { + // Zoom + if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, true); + } + + public int getPaintDamage(Arrow proj) + { + if (!_fired.containsKey(proj)) + return 1; + + return _fired.get(proj).Damage; + } + + private int getPaintDamage(Player player) + { + if (!_crouching.contains(player)) + return 1; + + return 1 + (int) Math.floor(player.getExp() * 10 / 3); + } + + @Override + public void handle(PacketInfo packetInfo) + { + if (!_spawning) + return; + + packetInfo.setCancelled(true); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/KillingSpreeTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/KillingSpreeTracker.java new file mode 100644 index 000000000..354d64ea9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/KillingSpreeTracker.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.paintball.trackers; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.paintball.Paintball; +import nautilus.game.arcade.game.games.paintball.events.PaintballEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class KillingSpreeTracker extends StatTracker +{ + private final Map _killCount = new HashMap<>(); + private final Map _lastKillTime = new HashMap<>(); + + public KillingSpreeTracker(Paintball game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(PaintballEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + Long lastTime = _lastKillTime.get(event.getKiller().getUniqueId()); + + long now = System.currentTimeMillis(); + + Integer killCount; + if (lastTime == null || now - lastTime > 5000) + killCount = 0; + else + { + killCount = _killCount.get(event.getKiller().getUniqueId()); + if (killCount == null) + killCount = 0; + } + + killCount++; + + _killCount.put(event.getKiller().getUniqueId(), killCount); + _lastKillTime.put(event.getKiller().getUniqueId(), now); + + _killCount.remove(event.getPlayer().getUniqueId()); + _lastKillTime.remove(event.getPlayer().getUniqueId()); + + if (killCount >= 4) + addStat(event.getKiller(), "KillingSpree", 1, true, false); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java new file mode 100644 index 000000000..523201a16 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.paintball.trackers; + +import java.util.UUID; + +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.NautHashMap; +import nautilus.game.arcade.game.games.paintball.Paintball; +import nautilus.game.arcade.game.games.paintball.events.PaintballEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class LastStandStatTracker extends StatTracker +{ + private final NautHashMap _kills = new NautHashMap(); + + public LastStandStatTracker(Paintball game) + { + super(game); + } + + @EventHandler + public void onPaintball(PaintballEvent event) + { + if (!getGame().IsLive()) + return; + + if (getGame().GetTeam(event.getKiller()).GetPlayers(true).size() == 1) + { + if (!_kills.containsKey(event.getKiller().getUniqueId())) + _kills.put(event.getKiller().getUniqueId(), 0); + + int kills = _kills.get(event.getKiller().getUniqueId()) + 1; + + if (kills >= 3) + addStat(event.getKiller(), "LastStand", 1, true, false); + + _kills.put(event.getKiller().getUniqueId(), kills); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java new file mode 100644 index 000000000..cedccaba6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java @@ -0,0 +1,25 @@ +package nautilus.game.arcade.game.games.paintball.trackers; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import nautilus.game.arcade.game.games.paintball.Paintball; +import nautilus.game.arcade.game.games.paintball.events.ReviveEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class MedicStatTracker extends StatTracker +{ + public MedicStatTracker(Paintball game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(ReviveEvent event) + { + if (!getGame().IsLive()) + return; + + addStat(event.getPlayer(), "Medic", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateNukeSpellEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateNukeSpellEvent.java new file mode 100644 index 000000000..8b27a426e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateNukeSpellEvent.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class ActivateNukeSpellEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private ArrayList _minions; + + public ActivateNukeSpellEvent(Player player, ArrayList minions) + { + _player = player; + _minions = minions; + } + + public Player getPlayer() + { + return _player; + } + + public ArrayList getMinions() + { + return _minions; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateSpellEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateSpellEvent.java new file mode 100644 index 000000000..21148e56d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateSpellEvent.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.typewars; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class ActivateSpellEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private Spell _spell; + + public ActivateSpellEvent(Player player, Spell spell) + { + _player = player; + _spell = spell; + } + + public Player getPlayer() + { + return _player; + } + + public Spell getSpell() + { + return _spell; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java new file mode 100644 index 000000000..b4c4832cf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java @@ -0,0 +1,632 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; +import java.util.Collections; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.disguise.disguises.DisguiseZombie; +import mineplex.core.hologram.Hologram; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.Game.GameState; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.inventory.ItemStack; + +public class Minion +{ + + private static String[] NAMES = new String[]{"Fishing", "Cookie", "Sleeping", "Diamond", "Banana", "Tree", "Egg", "Cat", + "Quadrilateral", "Rollercoaster", "Hallucinating", "Advertisement", "Entertainment", "Administrator", "Intergalactic", "International", "Understanding", "Investigation", + "Veterinarian", "Photographer", "Cheeseburger", "Civilization", "Tranquilizer", "Conversation", "EnderDragon", "Engineering", "Philippines", "Countryside", + "Electricity", "Caterpillar", "Keyboarding", "Agriculture", "Mathematics", "Millimeters", "Centimeters", "Screwdriver", "Achievement", "Necromancer", + "Grasshopper", "Quadrillion", "Horseradish", "Aboveground", "Belowground", "Mississippi", "Computerize", "Hibernation", "Radioactive", "Unfortunate", + "Demonstrate", "Gymnastics", "Toothpaste", "Paraphrase", "Limitless", "Breakfast", "Graveyard", "Philippines", "Countryside", + "Competition", "Management", "Peppermint", "Pyromaniac", "Sandstone", "Vengeance", "Passwords", "Chew", "Philippines", "Countryside", + "Competitive", "Accounting", "Generation", "Mechanized", "Minecraft", "Sprinting", "Beautiful", "Container", "Mayonaise", "Generator", + "Bombardment", "Laboratory", "BlackBerry", "Calculator", "Mushrooms", "Heartbeat", "Authority", "Apartment", "Deception", "Recommend", + "Highlighter", "Incomplete", "Javascript", "Compressor", "Dentistry", "Rectangle", "Exhausted", "Slimeball", "Commander", "Associate", + "Complicated", "Government", "Ceptillion", "Deflection", "Cosmetics", "Trapezoid", "Hamburger", "Raspberry", "Developer", "Accompany", + "Basketball", "Milkshakes", "Antibiotic", "Vocabulary", "Australia", "Dodecagon", "Miniature", "Blueberry", "Historian", "Machinery", + "Volleyball", "Earthquake", "Girlfriend", "Definition", "Christmas", "Cardboard", "Dimension", "Overreact", "Character", + "Television", "Motorcycle", "Despicable", "Contradict", "Chocolate", "Screaming", "Microsoft", "Barbarian", "Backspace", "Knowledge", + "Microphone", "Buccaneers", "Affordable", "Attendance", "Halloween", "Demanding", "Wrestling", "Lightbulb", "Wisconsin", "Secondary", + "Rhinoceros", "Applesauce", "Disconnect", "Protection", "Vacations", "Hopscotch", "Moderator", "Invisible", "Tennessee", "Adjective", + "Chestpiece", "Headphones", "Watermelon", "Reasonless", "Traveling", "Spectator", "Paintball", "Carnivore", "Awareness", "Direction", + "Complicated", "Controller", "Chimpanzee", "Deportment", "Saxophone", "Quadruple", "Champions", "Herbivore", "Unexcused", "Different", + "Antarctica", "Paintbrush", "Newsletter", "Appearance", "Hurricane", "Autopilot", "Architect", "Automatic", "Diplomacy", "Construct", + "Snowflakes", "Typewriter", "Sunglasses", "Occupation", "Piercings", "Principle", "Sharpness", "Performer", "Valentine", "Alternate", + "Strawberry", "Smartwatch", "Horrendous", "Antarctica", "Necklaces", "September", "Trademark", "Miniscule", "Copyright", "Opposable", + "Blackholes", "Minestrike", "California", "Wristwatch", "Evolution", "Microwave", "Dangerous", "Humongous", "Practical", "Imaginary", + "Rocketship", "Deathmatch", "Transplant", "Confusion", "Spaceship", "Eyeshadow", "Afternoon", "Judgement", "Imperfect", "Bonemeal", + "Aquamarine", "Playground", "Inevitable", "Surprised", "Lightning", "Butterfly", "Beekeeper", "Gladiator", "Excessive", "Courages", + "Levitation", "Resistance", "Inflatable", "Newspaper", "Sketching", "Centipede", "Parachute", "Treachery", "Crocodile", "Baseball", + "Vegetables", "Lighthouse", "Relentless", "Dinosaurs", "Teenagers", "Cartwheel", "Barricade", "Blowtorch", "Alligator", "Presents", + "Whispering", "Helicopter", "Mistakable", "Tarantula", "Grassland", "President", "Raincloud", "Incentive", "Balloons", + "Announcing", "Mechanical", "Expectance", "Mountains", "Fingertip", "Millenium", "Structure", "Keyboard", + "Meditation", "Toothbrush", "Tumbleweed", "Sandstone", "Dumplings", "Scientist", "Pineapple", "Boyfriend", "Spotlight", "Computer", + "Clothing", "Elephant", "Reptiles", "Scorpion", "Redstone", "Diamonds", "Porkchop", "Endermen", "Obsidian", "Planting", + "Potatoes", "Vampires", "Bracelet", "Coloring", "Thousand", "Hologram", "Lipstick", "Cruising", "Delivery", "Dreaming", + "Minecart", "Werewolf", "Highways", "Painting", "Infinity", "Ancestor", "Eyeliner", "Complete", "Packages", "Thinking", + "Unicorns", "Pumpkins", "Internet", "Toddlers", "Swimming", "Wreckage", "Siblings", "Branches", "Criminal", "Engineer", + "Military", "Costumes", "Earrings", "Children", "Triangle", "Defender", "Baguette", "Politics", "Handsome", "Reindeer", + "Portland", "Chipotle", "Dolphins", "Pre-teen", "Pentagon", "Homework", "Princess", "Citizens", "Gorgeous", "Necklace", + "Penguins", "Sapphire", "Galaxies", "Campfire", "Heptagon", "February", "Alphabet", "Username", "Panthers", "Mineplex", + "Barbecue", "Amethyst", "Cartoons", "Tropical", "Lollipop", "November", "Scissors", "Medicine", "Warriors", "Pallette", + "Mermaids", "Clarinet", "Basement", "Broccoli", "Shouting", "December", "Eternity", "Behavior", "Chatting", "Dominate", + "Assassin", "Elevator", "Weakness", "Blizzard", "Entrance", "Universe", "Teleport", "Director", "Stuffing", "Eruption", + "Godzilla", "Electron", "Strength", "Powerful", "Dynamite", "Backyard", "Gradient", "Producer", "Festival", "Mattress", + "Empoleon", "Building", "Dinosaur", "Illusion", "Mustache", "Ceremony", "Shipment", "Cosmetic", "Applause", "Research", + "Chimchar", "Aquarium", "Sidewalk", "Calendar", "Treasure", "Airplane", "Envelope", "Kangaroo", "Goldfish", "Starfish", + "Nickname", "Slowness", "Official", "Accident", "Cinnamon", "Collapse", "Geometry", "Barnacle", "Football", "Creative", + "Hypnotic", "Antidote", "Emulator", "Foothold", "Friction", "Tungsten", "Tablets", "Torches", "Fairies", "Windows", + "Conquest", "Province", "Overflow", "Graceful", "Negative", "Doctrine", "Charger", "Carrots", "Spirits", "Robbers", + "Karambit", "Solution", "Sandwich", "Catapult", "Positive", "Firework", "Ukulele", "Dragons", "Cobwebs", "Drawing", + "Internal", "Japanese", "Atronomy", "Villager", "Tranquil", "Compress", "Glasses", "Nursing", "College", "Magenta", + "Trillion", "Standard", "Astrology", "Infringe", "Fortress", "Prisoner", "Daisies", "Soldier", "Courses", "Serpent", + "Carnival", "Parasite", "Porridge", "Variable", "Charcoal", "Decision", "Hazards", "Jupiter", "Buttons", "Camping", + "Concrete", "Carriage", "Pressure", "Practice", "Commerce", "Windmill", "Cheetah", "Mercury", "Octopus", "Canyons", + "Pavement", "Auxilary", "Demolish", "Maintain", "Barbeque", "Parmesan", "Vulture", "America", "Printer", "Seventy", + "Joystick", "Marshall", "Franklin", "Umbrella", "Contract", "Warthog", "Turtles", "Ireland", "Titanic", "Hundred", + "Speaker", "Suitcase", "Michigan", "Darkness", "Separate", "Puzzled", "Ocelots", "Germany", "Vanilla", "Million", + "Figurine", "Mandarin", "Arkansas", "Ethernet", "Eligible", "Shocked", "Creeper", "Chillie", "Tornado", "Billion", + "Boundary", "Anteater", "Colorado", "Everyday", "Fraction", "Figures", "Zombies", "Jamaica", "Seaweed", "Twitter", + "Birthday", "Sunshine", "Virginia", "Surprise", "Compound", "Pillows", "Leather", "Bermuda", "Craters", "Waiting", + "Hogwarts", "Particle", "American", "Together", "Precious", "Erasers", "Chicken", "Bahamas", "Meteors", "Passion", + "Walking", "Decagon", "Spatula", "Science", "Bicycle", "Animate", "Cereal", "Graphic", "Message", "Episode", + "Running", "Talking", "Cooking", "Biology", "Sweater", "Cabinet", "Pokemon", "Kingdom", "Funeral", "Destroy", + "Jogging", "Yelling", "Fashion", "Pajamas", "Lettuce", "Furnace", "Chariot", "Package", "Grinder", "Defrost", + "Breathe", "Ladybug", "Brother", "Reflect", "Cheddar", "Bridges", "Spawner", "Exhibit", "Nuclear", "Avocado", + "Muscles", "Invader", "Grandpa", "Confirm", "Speaker", "Wizards", "Stacker", "Feather", "Channel", "Thunder", + "Marbles", "Contest", "Grandma", "History", "Minigun", "Skywars", "Turtwig", "Morning", "Explode", "Factory", + "Polygon", "Teacher", "Royalty", "Balcony", "Android", "Monster", "Emerald", "Primate", "Village", "Company", + "Degrees", "Glacier", "Cricket", "Partner", "Medieval", "Gravity", "Surgeon", "Volcano", "Forward", "Console", + "Hexagon", "Cyclops", "Kung-fu", "Bonjour", "Painter", "Snowman", "Caramel", "Lullaby", "Sparrow", "Blowgun", + "Octagon", "January", "Century", "Bowling", "Plumber", "Explore", "Healing", "Circuit", "Vampire", "Distort", + "Nonagon", "October", "Lockers", "Justice", "England", "Pancake", "Whisper", "Voltage", "Ceramic", "Avenger", + "Bazooka", "Actress", "Highway", "Fighter", "Notepad", "Knuckle", "YouTube", "Fishing", "Florida", "Capsule", + "Missile", "Haircut", "Apricot", "Deathly", "Cracker", "Western", "Colonel", "Balance", "Georgia", "Boolean", + "Pyramid", "Stomach", "Dracula", "Fractal", "Network", "Eastern", "Creator", "Monitor", "Glowing", "Integer", + "Mailbox", "Phantom", "Harpoon", "Endless", "Ketchup", "English", "Sunrise", "Examine", "Blowing", "Perfect", + "Algebra", "Pattern", "Cottage", "Crystal", "Mustard", "Spanish", "Unlucky", "Tragedy", "Deviate", "Builder", + "Penguin", "Emperor", "Amplify", "Hamster", "Paprika", "Chinese", "Shackle", "Kitchen", "Liberty", "Cupcake", + "Robotic", "Fortune", "Gazelle", "Scratch", "Revenge", "Honesty", "Hideout", "Compass", "Italian", "Demoman", + "Machine", "Gymnast", "Balloon", "Country", "Poision", "Brendan", "Connect", "Fireman", "Mexican", "Neptune", + "Aquatic", "Hostage", "Program", "Witness", "Villain", "Virtual", "Supreme", "Platter", "Ukraine", "Profile", + "Hatchet", "Hangers", "Bayonet", "Gamepad", "Bandage", "Blister", "Archive", "Implode", "Hilbert", "Offline", + "Shelter", "Primary", "Organic", "Healthy", "Makeup", "Blazes", "Brazil", "Horror", "Subway", "Babies", + "Capture", "Various", "Gradual", "Rapture", "Pollen", "String", "Warren", "Moving", "Shorts", "Elders", + "Elegant", "Violate", "Heroic", "Violent", "Leaves", "Soccer", "Europe", "School", "Scarves", "Orange", + "Dentist", "Neglect", "Strong", "Solvent", "Monkey", "Closet", "Africa", "Hotels", "Sharks", "Yellow", + "Combine", "Fulfill", "Barbie", "Engrave", "Rabbit", "Carpet", "Winter", "Zipper", "Whales", "Purple", + "Surface", "Sailing", "Pencil", "Passage", "Kitten", "Saturn", "Spring", "Acorns", "Comets", + "Gelatin", "Klarin", "Phones", "Quality", "Ingots", "Uranus", "Summer", "Pariot", "Comedy", "Poison", + "Similar", "Flutter", "Shield", "Psychic", "Spider", "Mexico", "Autumn", "Cruise", "Sports", "Forest", + "Oxidize", "Disease", "Guitar", "Opossum", "Ghasts", "France", "Ghosts", "Lucius", "Cement", "Desert", + "Purpose", "Symptom", "Sticks", "Measure", "Slimes", "Greece", "Spooky", "Coffee", "Aliens", "Cities", + "Bikini", "Mortal", "Serena", "Future", "Bottle", "Helmet", "Crunch", "Afraid", "Threat", "Static", + "Happy", "Knife", "Scary", "Lapis", "Skirt", "Waves", "Calem", "Clock", "Taste", "Lucas", + "Anger", "Spork", "Maike", "Candy", "Shirt", "Tides", "Ocean", "Crawl", "Smell", "React", + "Dolls", "Roses", "Trips", "Flute", "Pants", "Brick", "Three", "Ethan", "Uncle", "Lunch", + "Legos", "Tulip", "Beach", "Wipes", "Heels", "Straw", "Seven", "Hands", "Queen", "Books", + "Couch", "Grass", "Clans", "Frame", "Nails", "Cream", "Eight", "Belly", "Crown", "Polls", + "Vases", "Tiger", "Wagon", "Sleet", "Rings", "Attic", "Forty", "Chest", "Staff", "Hello", + "Sword", "Panda", "Sleep", "Roads", "Money", "Green", "Fifty", "Brush", "Tools", "Howdy", + "Banjo", "Sloth", "X-ray", "Truck", "Coral", "Speed", "Sixty", "Peace", "Music", "Court", + "Drums", "Snake", "Socks", "Plane", "Reefs", "Hilda", "Brown", "Heart", "Lucia", "Raven", + "Spoon", "Boots", "Pearl", "Train", "Horse", "Woods", "Silly", "Lotta", "Month", "Games", + "Love", "Cats", "Lava", "Ship", "Moon", "Five", "Head", "July", "Mask", "Hola", + "Rosa", "Wolf", "Soda", "Ruby", "News", "Nine", "Hair", "Feel", "Jazz", "Soft", + "Toys", "Duck", "Mars", "Mint", "Ufos", "Grey", "Ears", "Hear", "Hour", "Hard", + "Soap", "Ores", "Cuba", "Snow", "Cops", "Derp", "Eyes", "Oven", "Week", "Clay", + "Wigs", "Gold", "Asia", "Rain", "Lime", "Time", "Star", "King", "Year", "Gold", + "Fork", "Iron", "Elfs", "Suit", "Blue", "Tony", "Salt", "Ants", "Nate", "Mind", + "Weed", "Pigs", "Bricks", "Blue", "Pink", "Hide", "Kris", "File", "Yard", "Comb", + "Wood", "Lyra", "Frog", "Hats", "Heal", "Feet", "Yoga", "Edit", "Mile", "Paws", + "Bird", "Wool", "Fish", "Eels", "Jump", "Arms", "Boom", "View", "Girl", "Tree", + "Lion", "Dirt", "Yarn", "Dawn", "Four", "Neck", "June", "Help", "Mail", "Lamp", + "Sad", "Sun", "Pan", "Yes", "Dad", "Bat", "Wig", "KFC", "War", "Fan", + "Red", "Jam", "Ivy", "Map", "Fur", "Yen", "Hum", "May", "Dog", + "One", "Day", "Sky", "Add", "Orb", "Hip", "Sew", "Act", "Ice", + "Two", "Gum", "Cow", "Moo", "Bee", "Ape", "Zoo", "Pit", "Hat", + "Six", "Gym", "Rat", "Mow", "Pot", "Dot", "Paw", "Hen", "Bed", + "Ten", "Art", "Bag", "Mob", "End", "Egg", "Saw", "Law", "Fog", + "Fly", "Boy", "Rag", "New", "Jet", "Pet", "Tin", "Pen", "Car", + "Old", "Age", "TNT", "Leg", "Axe", "UFO", "Rap", "Wet", "Tie", + "May", "Gas", "Hue", "Wax", "Toy", "Lay", "Pop", "Dry", "Sea", + "See", "Ash", "Mom", "Box", "Key", "Fat", "Spy"}; + + private ArcadeManager _manager; + + private MinionType _type; + private Entity _entity; + private String _name; + private Location _location; + private Location _target; + private GameTeam _team; + private Player _player; + private Player _killer; + private Location _lastNameChanged; + private Hologram _hologram; + private int _money; + private float _walkSpeed; + private boolean _spawned; + private double _tagHight; + private boolean _moving; + + private int _size; + + private int _spawnID; + + private boolean _die; + private boolean _killed; + private int _frame; + private int _lives; + + public Minion(ArcadeManager manager, Location location, Location target, GameTeam team, int spawnID) + { + this(manager, location, target, team, null, true, null, spawnID); + } + + public Minion(ArcadeManager manager, Location location, Location target, GameTeam team, Player player, boolean spawn, MinionType type, int spawnID) + { + _manager = manager; + + _type = type; + _moving = true; + if(_type == null) + _type = randomType(); + + _walkSpeed = _type.getWalkSpeed(); + _tagHight = _type.getTagHight(); + _die = false; + _killed = false; + _frame = 0; + _entity = null; + _team = team; + _player = player; + _killer = null; + _money = _type.getMoney(); + _spawnID = spawnID; + _size = 10; + if(_type == MinionType.WITHER) + _size = 0; + + changeRandomName(_type.getMinName(), _type.getMaxName(), true); + + _location = location; + _target = target; + _spawned = false; + _lives = _type.getSize().getLives(); + if(spawn) + spawnMinion(); + } + + public void spawnMinion() + { + _entity = _location.getWorld().spawn(_location, Zombie.class); + Zombie zombie = (Zombie) _entity; + zombie.setRemoveWhenFarAway(false); + zombie.setMaxHealth(200); + zombie.setHealth(200); + zombie.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + disguiseCreeper(); + path(); + _spawned = true; + } + + private Material[] _items = new Material[]{Material.DIAMOND_AXE, Material.IRON_SWORD, Material.CARROT, Material.STONE_SPADE, Material.GOLD_PICKAXE, Material.AIR}; + + private void disguiseCreeper() + { + if (_hologram != null) + { + _hologram.setText(_team.GetColor() + _name); + } + else + { + if(_manager.GetGame().GetState() == GameState.Live) + { + _hologram = new Hologram(_manager.getHologramManager(), _entity.getLocation().add(0, 2.3, 0), _team.GetColor() + _name); + } + else + { + _hologram = new Hologram(_manager.getHologramManager(), _entity.getLocation().add(0, 2.3, 0), ChatColor.WHITE + _name); + } + _hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); + //_hologram.setFollowEntity(_entity); + + for (Player player : _manager.GetGame().GetPlayers(false)) + { + if (_manager.GetGame().GetTeam(player) == _team && _manager.GetGame().GetState() != GameState.Prepare) + { + continue; + } + + _hologram.addPlayer(player); + } + + _hologram.start(); + } + + try + { + int i = 0; + for(Class clazz : _type.getDisguiseClasses()) + { + Object disguise = null; + Entity ent = null; + if(i == 0) + { + disguise = clazz.getConstructors()[0].newInstance(_entity); + } + else + { + ent = _location.getWorld().spawn(_location, Creeper.class); + disguise = clazz.getConstructors()[0].newInstance(ent); + } + try + { + clazz.getMethod("setHelmet", ItemStack.class).invoke(disguise, new ItemStack(Material.LEATHER_HELMET)); + clazz.getMethod("setHeldItem", ItemStack.class).invoke(disguise, new ItemStack(_items[UtilMath.r(_items.length)])); + } + catch (Exception e) {} + if(disguise instanceof DisguiseZombie && i > 0) + { + DisguiseZombie zombie = (DisguiseZombie) disguise; + zombie.SetBaby(true); + } + if(disguise instanceof DisguiseSlime) + { + DisguiseSlime slime = (DisguiseSlime) disguise; + slime.SetSize(_size); + } + if(disguise instanceof DisguiseWither) + { + DisguiseWither wither = (DisguiseWither) disguise; + wither.setInvulTime(_size); + } + _entity.setPassenger(ent); + _manager.GetDisguise().disguise((DisguiseBase)disguise); + _manager.GetDisguise().updateDisguise((DisguiseBase)disguise); + i++; + } + } + catch (Exception e) {} + _hologram.start(); + } + + private void path() + { + UtilEnt.Vegetate(_entity); + UtilEnt.silence(_entity, true); + UtilEnt.ghost(_entity, true, false); + } + + private MinionType randomType() + { + if(System.currentTimeMillis() - _manager.GetGame().GetStateTime() <= 30000) + { + return MinionSize.EASY.getRandomType(); + } + if(System.currentTimeMillis() - _manager.GetGame().GetStateTime() <= 60000) + { + int rdm = UtilMath.r(2); + if(rdm == 0) + return MinionSize.MEDIUM.getRandomType(); + else + return MinionSize.EASY.getRandomType(); + } + int rdm = UtilMath.r(MinionType.values().length); + int freak = UtilMath.r(1000); + if(freak <= 10) + { + ArrayList minions = new ArrayList<>(); + for(MinionType type : MinionType.values()) + { + if(type.getSize() == MinionSize.FREAK) + minions.add(type); + } + return minions.get(UtilMath.r(minions.size())); + } + for(MinionType type : MinionType.values()) + { + if(type.ordinal() == rdm) + { + if(type.getSize() != MinionSize.FREAK && type.getSize() != MinionSize.BOSS) + { + return type; + } + else + { + return randomType(); + } + } + } + return null; + } + + public boolean hasLives() + { + return _lives > 1; + } + + public void despawn(Player player, boolean killed, boolean clean) + { + _money = _money + 1; + if(_lives > 1) + { + _lives = _lives - 1; + changeRandomName(_name.length()+1, _name.length()+1, false); + if(_type == MinionType.WITHER) + { + _size = _size + 100; + _tagHight = _tagHight - 0.15; + } + else + { + _size = _size -1; + _tagHight = _tagHight - 0.1; + } + return; + } + _killed = killed; + _killer = player; + _die = true; + _hologram.stop(); + try + { + if(_entity.getPassenger() != null) + { + if(!clean) + ((Zombie) _entity.getPassenger()).damage(10000); + else + _entity.getPassenger().remove(); + } + if(!clean) + ((Zombie) _entity).damage(10000); + else + _entity.remove(); + + if(!_entity.isDead()) + _entity.remove(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void despawn(Player player, boolean killed) + { + despawn(player, killed, false); + } + + public void animation() + { + if(!_die) + return; + + if(_killed) + { + if(_frame <= 30) + { + if(_team.GetColor() == ChatColor.RED) + { + double radius = _frame / 20D; + int particleAmount = _frame / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = _entity.getLocation().clone().add(0.5, 0, 0.5).add(xDiff, particleAmount/10, zDiff); + try + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.RED_DUST, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, _player); + } + catch (Exception ex) + { + + } + + } + } + else + { + double radius = _frame / 20D; + int particleAmount = _frame / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = _entity.getLocation().clone().add(0.5, 0, 0.5).add(xDiff, particleAmount/10, zDiff); + try + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, location, -1, 1, 1, 1, 0,ViewDist.NORMAL, _player); + } + catch (Exception ex) + { + + } + + } + + } + } + } + else + { + if(_frame <= 1) + { + UtilFirework.playFirework(_entity.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.GREEN, true, true); + } + } + + if(_frame == 31) + { + _die = false; + } + + _frame++; + } + + public void changeName(String name) + { + _name = name; + Location loc = _entity.getLocation(); + _lastNameChanged = loc; + disguiseCreeper(); + } + + public void changeRandomName(int min, int max, boolean spawned) + { + ArrayList tempList = new ArrayList<>(); + for(String names : NAMES) + tempList.add(names); + + Collections.shuffle(tempList); + for(String str : tempList) + { + if(str.length() >= min && str.length() <= max) + { + if(!spawned) + changeName(str); + else + _name = str; + + return; + } + } + } + + public boolean isNameChangeable() + { + if(_lastNameChanged == null) + return true; + + if(_entity.getLocation().getBlockX() != _lastNameChanged.getBlockX()) + return true; + + if(_entity.getLocation().getBlockZ() != _lastNameChanged.getBlockZ()) + return true; + + return false; + } + + public void setWalkSpeed(float speed) + { + _walkSpeed = speed; + } + + public void increaseWalkSpeed(float speed) + { + float oldSpeed = _walkSpeed; + _walkSpeed = oldSpeed + speed; + if(_walkSpeed <= 0.5) + _walkSpeed = 0.6F; + } + + public Location getTarget() + { + return _target; + } + + public boolean isSpawned() + { + return _spawned; + } + + public Entity getEntity() + { + return _entity; + } + + public MinionType getType() + { + return _type; + } + + public int getMoney() + { + return _money; + } + + public Player getKiller() + { + return _killer; + } + + public Player getPlayer() + { + return _player; + } + + public GameTeam getTeam() + { + return _team; + } + + public String getName() + { + return _name; + } + + public float getWalkSpeed() + { + return _walkSpeed; + } + + public Location getLastNameChanged() + { + return _lastNameChanged; + } + + public Hologram getHologram() + { + return _hologram; + } + + public int getSpawnID() + { + return _spawnID; + } + + public double getTagHight() + { + return _tagHight; + } + + public void setTarget(Location location) + { + _target = location; + } + + public void setMoving(boolean moving) + { + _moving = moving; + } + + public boolean isMoving() + { + return _moving; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionKillEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionKillEvent.java new file mode 100644 index 000000000..2198d4aca --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionKillEvent.java @@ -0,0 +1,66 @@ +package nautilus.game.arcade.game.games.typewars; + +import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class MinionKillEvent extends Event implements Cancellable +{ + + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private Minion _minion; + private KillType _type; + + private boolean _canceled; + + public MinionKillEvent(Player player, Minion minion, KillType type) + { + _player = player; + _minion = minion; + _type = type; + _canceled = false; + } + + public Player getPlayer() + { + return _player; + } + + public Minion getMinion() + { + return _minion; + } + + public KillType getType() + { + return _type; + } + + @Override + public void setCancelled(boolean cancel) + { + _canceled = cancel; + } + + public boolean isCancelled() + { + return _canceled; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionSize.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionSize.java new file mode 100644 index 000000000..af5f91434 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionSize.java @@ -0,0 +1,73 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemStackFactory; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public enum MinionSize +{ + EASY("Easy", 2, ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte) 0, 1, (short) 55, "", new String[]{}), 1, 1), + MEDIUM("Medium", 4, ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte) 0, 1, (short) 61, "", new String[]{}), 1, 2), + HARD("Hard", 6, ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte) 0, 1, (short) 52, "", new String[]{}), 1, 4), + FREAK("Freak", 10000, new ItemStack(Material.MONSTER_EGG), 1, 999999), + BOSS("Boss", 10000, new ItemStack(Material.MONSTER_EGG), 7, 999999999); + + private int _cost; + private ItemStack _displayItem; + private int _lives; + private int _gemReward; + + private String _displayName; + + private MinionSize(String name, int cost, ItemStack displayItem, int lives, int gemReward) + { + _displayName = name; + _cost = cost; + _displayItem = displayItem; + _lives = lives; + _gemReward = gemReward; + } + + public int getCost() + { + return _cost; + } + + public ItemStack getDisplayItem() + { + return _displayItem; + } + + public String getDisplayName() + { + return _displayName; + } + + public int getGemReward() + { + return _gemReward; + } + + public MinionType getRandomType() + { + ArrayList minionList = new ArrayList<>(); + for(MinionType type : MinionType.values()) + { + if(type.getSize() == this) + { + minionList.add(type); + } + } + return minionList.get(UtilMath.r(minionList.size())); + } + + public int getLives() + { + return _lives; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionType.java new file mode 100644 index 000000000..a80d1fc5f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionType.java @@ -0,0 +1,123 @@ +package nautilus.game.arcade.game.games.typewars; + +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.disguise.disguises.DisguiseCow; +import mineplex.core.disguise.disguises.DisguiseCreeper; +import mineplex.core.disguise.disguises.DisguiseEnderman; +import mineplex.core.disguise.disguises.DisguiseHorse; +import mineplex.core.disguise.disguises.DisguiseIronGolem; +import mineplex.core.disguise.disguises.DisguiseMagmaCube; +import mineplex.core.disguise.disguises.DisguisePig; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.disguise.disguises.DisguiseSpider; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.disguise.disguises.DisguiseWolf; +import mineplex.core.disguise.disguises.DisguiseZombie; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +@SuppressWarnings("unchecked") +public enum MinionType +{ + + CHICKEN(10, MinionSize.EASY, EntityType.CHICKEN, 3, 3, (float) (0.7 + (0.1*7)), 1, -0.5D, Material.EGG, DisguiseChicken.class), + PIG(10, MinionSize.EASY, EntityType.PIG, 3, 6, (float) (0.7 + (0.1*7)), 1, -0.5D, Material.PORK, DisguisePig.class), + COW(10, MinionSize.EASY, EntityType.COW, 6, 9, (float) (0.7 + (0.1*7)), 1, -0.5D, Material.COOKED_BEEF, DisguiseCow.class), + + ZOMBIE(10, MinionSize.MEDIUM, EntityType.ZOMBIE, 9, 12, (float) (0.7 + (0.1*2)), 2, 0D, Material.ROTTEN_FLESH, DisguiseZombie.class), + SPIDER(10, MinionSize.MEDIUM, EntityType.SPIDER, 6, 9, (float) (0.7 + (0.1*5)), 2, 0D, Material.SPIDER_EYE, DisguiseSpider.class), + WOLF(10, MinionSize.MEDIUM, EntityType.WOLF, 3, 6, (float) (0.7 + (0.1*8)), 2, -1D, Material.COOKED_BEEF, DisguiseWolf.class), + + IRON_GOLEM(10, MinionSize.HARD, EntityType.IRON_GOLEM, 10, 13,(float) (0.7 + (0.1*3)), 3, 0.5D, Material.IRON_INGOT, DisguiseIronGolem.class), + HORSE(10, MinionSize.HARD, EntityType.HORSE, 6, 9, (float) (0.7 + (0.1*10)), 3, 0D, Material.APPLE, DisguiseHorse.class), + ENDERMAN(10, MinionSize.HARD, EntityType.ENDERMAN, 9, 12, (float) (0.7 + (0.1*4)), 3, 1D, Material.ENDER_STONE, DisguiseEnderman.class), + + WITHER(1, MinionSize.BOSS, EntityType.WITHER, 5, 5, (float) (0.7 + (0.1*2)), 1, 2D, Material.NETHER_STAR, DisguiseWither.class), + SLIME(1, MinionSize.BOSS, EntityType.SLIME, 5, 5, (float) (0.7 + (0.1*2)), 1, 3D, Material.SLIME_BALL, DisguiseSlime.class), + + SPIDER_JOKEY(1, MinionSize.FREAK, EntityType.SPIDER, 10, 13, (float) (0.7 + (0.1*7)), 10, 1D, Material.APPLE, DisguiseSpider.class, DisguiseSkeleton.class), + CHICKEN_JOKEY(1, MinionSize.FREAK, EntityType.CHICKEN, 10, 13, (float) (0.7 + (0.1*7)), 10, 1D, Material.APPLE, DisguiseChicken.class, DisguiseZombie.class); + + private Class[] _disguiseClasses; + + private EntityType _type; + private int _minName; + private int _maxName; + private float _walkSpeed; + private int _money; + + private MinionSize _size; + + private double _tagHight; + private Material _displayItem; + + private int _chance; + + private MinionType(int chance, MinionSize size, EntityType type, int minName, int maxName, float walkSpeed, int money, double tagHight, Material displayItem,Class... disguiseClasses) + { + _disguiseClasses = disguiseClasses; + _type = type; + _minName = minName; + _maxName = maxName; + _walkSpeed = walkSpeed; + _money = money; + _displayItem = displayItem; + _tagHight = tagHight; + _chance = chance; + _size = size; + } + + public EntityType getType() + { + return _type; + } + + public int getMinName() + { + return _minName; + } + + public int getMaxName() + { + return _maxName; + } + + public float getWalkSpeed() + { + return _walkSpeed; + } + + public int getMoney() + { + return _money; + } + + public Material getDisplayItem() + { + return _displayItem; + } + + public Class[] getDisguiseClasses() + { + return _disguiseClasses; + } + + public double getTagHight() + { + return _tagHight; + } + + public int getChance() + { + return _chance; + } + + public MinionSize getSize() + { + return _size; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Spell.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Spell.java new file mode 100644 index 000000000..532de8dd0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Spell.java @@ -0,0 +1,212 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public abstract class Spell +{ + + private ArrayList _playerUses; + + private ArcadeManager _manager; + private TypeWars _typeWars; + private String _name; + private int _cost; + private Material _material; + private Long _recharge; + private boolean _singleUse; + private long _updateDelay; + + private HashMap _lastUsed; + private long _useDelay; + + public Spell(ArcadeManager manager, String name, int cost, Material material, Long recharge, int updateDelay, long useDelay, boolean singleUse) + { + _manager = manager; + _name = name; + _cost = cost; + _material = material; + _recharge = recharge; + _singleUse = singleUse; + _updateDelay = updateDelay; + _playerUses = new ArrayList<>(); + _lastUsed = new HashMap<>(); + _updateDelay = useDelay; + } + + public void prepareExecution(final Player player) + { + if(isSingleUse()) + { + if(_playerUses.contains(player)) + { + UtilTextMiddle.display("", ChatColor.GRAY + "You can't use this spell anymore.", player); + return; + } + } + GameTeam team = getManager().GetGame().GetTeam(player); + if(_lastUsed.containsKey(team)) + { + if(!UtilTime.elapsed(_lastUsed.get(team), _useDelay)) + { + UtilTextMiddle.display("", ChatColor.GRAY + "This Spell cant be used at the moment.", player); + return; + } + } + _lastUsed.put(team, System.currentTimeMillis()); + + _typeWars = (TypeWars) _manager.GetGame(); + if(_typeWars.getMoneyMap().get(player) < getCost()) + { + UtilTextMiddle.display("", ChatColor.GRAY + "You dont have enough Money to use that spell.", player); + return; + } + if(!Recharge.Instance.usable(player, getName(), true)) + return; + + UtilTextMiddle.display(ChatColor.GREEN + "-$" + getCost(), ChatColor.GRAY + "You used " + F.game(getName()), player); + final Spell spell = this; + + new Thread(new Runnable() + { + + @Override + public void run() + { + Location loc = player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 80).get(0).getLocation().add(0.5, 0.5, 0.5); + if(trail() != null) + { + int i = 0; + for (Location location : UtilShapes.getLinesDistancedPoints(player.getEyeLocation().subtract(0, 0.1, 0), loc, 0.6)) + { + if(getManager().GetGame().GetTeam(player).GetColor() == ChatColor.RED) + { + UtilParticle.PlayParticle(trail(), location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + UtilParticle.PlayParticle(trail(), location, -1, 1, 1, 1, 0, ViewDist.NORMAL, UtilServer.getPlayers()); + } + trailAnimation(location, i); + location.getWorld().playSound(location, sound(), 1, 1); + i++; + if(i > 30) + i = 0; + try + { + Thread.sleep(_updateDelay); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + } + if(hit() != null) + UtilParticle.PlayParticle(hit(), loc, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + + if(execute(player, loc)) + { + Recharge.Instance.use(player, getName(), getRecharge(), false, true); + int money = ((TypeWars) _manager.GetGame()).getMoneyMap().get(player); + ((TypeWars) _manager.GetGame()).getMoneyMap().put(player, money - getCost()); + if(!_playerUses.contains(player)) + _playerUses.add(player); + + Bukkit.getPluginManager().callEvent(new ActivateSpellEvent(player, spell)); + return; + } + else + { + UtilPlayer.message(player, F.main("Game", "Error while using spell.")); + return; + } + } + + }).start(); + + } + + public ParticleType trail() + { + return ParticleType.RED_DUST; + } + + public ParticleType hit() + { + return ParticleType.EXPLODE; + } + + public Sound sound() + { + return Sound.CLICK; + } + + public boolean hasUsed(Player player) + { + return _playerUses.contains(player); + } + + public void trailAnimation(Location location, int frame) {} + + public abstract boolean execute(Player player, Location location); + + public ArcadeManager getManager() + { + return _manager; + } + + public TypeWars getTypeWars() + { + return _typeWars; + } + + public String getName() + { + return _name; + } + + public int getCost() + { + return _cost; + } + + public Material getMaterial() + { + return _material; + } + + public Long getRecharge() + { + return _recharge; + } + + public boolean isSingleUse() + { + return _singleUse; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/SummonMinionEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/SummonMinionEvent.java new file mode 100644 index 000000000..49ed46c56 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/SummonMinionEvent.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.typewars; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class SummonMinionEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private Minion _minion; + + public SummonMinionEvent(Player player, Minion minion) + { + _player = player; + _minion = minion; + } + + public Player getPlayer() + { + return _player; + } + + public Minion getMinion() + { + return _minion; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeAttemptEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeAttemptEvent.java new file mode 100644 index 000000000..c03828fdf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeAttemptEvent.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class TypeAttemptEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private String _attempt; + private boolean _success; + + public TypeAttemptEvent(Player player, String attempt, boolean sucess) + { + _player = player; + _attempt = attempt; + _success = sucess; + } + + public Player getPlayer() + { + return _player; + } + + public String getAttempt() + { + return _attempt; + } + + public boolean isSuccessful() + { + return _success; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java new file mode 100644 index 000000000..0f0d7e6c5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -0,0 +1,1368 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.hologram.Hologram; +import mineplex.core.itemstack.ItemStackFactory; +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; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.typewars.kits.KitTypeWarsBase; +import nautilus.game.arcade.game.games.typewars.kits.KitTyper; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.stats.DemonStatsTracker; +import nautilus.game.arcade.game.games.typewars.stats.DumbledontStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.HoarderStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.KillsStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.PerfectionistStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.TimeInGameTracker; +import nautilus.game.arcade.game.games.typewars.stats.WaitForItStatTracker; +import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars; +import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; +import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.stats.TimeInGameStatTracker; +import nautilus.game.arcade.world.WorldData; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + +public class TypeWars extends TeamGame +{ + + private ArrayList _activeMinions; + private ArrayList _deadMinions; + private ArrayList _finishedMinions; + + private HashMap _moneyMap; + + private long _lastSpawnedRed; + private long _timeToSpawnRed; + + private long _lastSpawnedBlue; + private long _timeToSpawnBlue; + + private ArrayList _pendingNukes; + + private HashMap> _lineGrowth; + private HashMap> _lineShorten; + private HashMap> _minionSpawns; + + private HashMap> _giantAttackZones; + private HashMap _giants; + private HashMap _giantLocs; + private HashMap _minionsSpawned; + private HashMap _giantsAttacked; + + private HashSet _playerTitles; + + public TypeWars(ArcadeManager manager) + { + super(manager, GameType.TypeWars, + new Kit[] + { + new KitTyper(manager), + }, + new String[] + { + "Protect your Giant from enemy minions.", + "Type minions names to kill them and get money.", + "Spend money on Spells and Minion Spawns.", + "You get ONE free Giant Smash per game.", + "Kill your enemies Giant before they kill yours!" + }); + + this.DeathOut = false; + this.DamageTeamSelf = false; + this.DamageSelf = false; + this.DamageTeamOther = false; + this.DeathSpectateSecs = 0; + this.HungerSet = 20; + this.WorldBoundaryKill = true; + this.CompassEnabled = false; + this.TeamArmor = true; + this.TeamArmorHotbar = false; + this.WorldTimeSet = 6000; + this.DamageEvP = false; + this.DamagePvE = false; + this.DamagePvP = false; + this.TeamArmorHotbar = true; + this.Damage = false; + this.CreatureAllow = false; + this.PrepareTime = 50000; + this.PrepareFreeze = false; + this.PlaySoundGameStart = false; + this.EnableTutorials = true; + this.PrepareFreeze = true; + this.AllowParticles = false; + + _activeMinions = new ArrayList<>(); + _deadMinions = new ArrayList<>(); + _finishedMinions = new ArrayList<>(); + _minionSpawns = new HashMap<>(); + _moneyMap = new HashMap<>(); + _timeToSpawnRed = 30000; + _timeToSpawnBlue = 30000; + _lineGrowth = new HashMap<>(); + _lineShorten = new HashMap<>(); + _pendingNukes = new ArrayList<>(); + _giantAttackZones = new HashMap<>(); + _giants = new HashMap<>(); + _minionsSpawned = new HashMap<>(); + _giantsAttacked = new HashMap<>(); + _playerTitles = new HashSet<>(); + _giantLocs = new HashMap<>(); + + _animationTicks = 0; + _nukeFrame = 0; + + registerStatTrackers( + new DemonStatsTracker(this), + new DumbledontStatTracker(this), + new HoarderStatTracker(this), + new PerfectionistStatTracker(this), + new WaitForItStatTracker(this), + new KillsStatTracker(this), + new TimeInGameTracker(this) + ); + + manager.GetCreature().SetDisableCustomDrops(true); + manager.GetChat().setThreeSecondDelay(false); + } + + @EventHandler + public void stateChange(GameStateChangeEvent event) + { + for (Player player : GetPlayers(true)) + { + UtilAction.velocity(player, 0.1, 0.1, 0.1, false); + _moneyMap.put(player, 0); + _playerTitles.add(player); + } + + if(event.GetState() == GameState.Prepare) + { + initSpawns(); + prepareGiants(); + } + if(event.GetState() != GameState.Live) + return; + + for(GameTeam team : GetTeamList()) + { + _lineGrowth.put(team, new ArrayList()); + _lineShorten.put(team, new ArrayList()); + _minionsSpawned.put(team, 0); + } + + _timeToSpawnRed = 6000 / GetTeamList().get(0).GetPlayers(true).size(); + _timeToSpawnBlue = 6000 / GetTeamList().get(1).GetPlayers(true).size(); + + _lastSpawnedRed = System.currentTimeMillis(); + _lastSpawnedBlue = System.currentTimeMillis(); + } + + public void prepareGiants() + { + Location blue = WorldData.GetDataLocs("PURPLE").get(0).clone(); + Location red = WorldData.GetDataLocs("LIME").get(0).clone(); + + red.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(red, blue))); + blue.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(blue, red))); + + red.getBlock().setType(Material.STONE); + blue.getBlock().setType(Material.STONE); + + red.add(0, 2, 0); + blue.add(0, 2, 0); + + int i = 0; + for(GameTeam team : GetTeamList()) + { + Location loc = red; + if(i == 1) + loc = blue; + + this.CreatureAllowOverride = true; + Giant giant = loc.getWorld().spawn(loc, Giant.class); + _giantLocs.put(giant, loc.clone()); + this.CreatureAllowOverride = false; + giant.setRemoveWhenFarAway(false); + UtilEnt.Vegetate(giant, true); + UtilEnt.ghost(giant, true, false); + + ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); + LeatherArmorMeta helmetmeta = (LeatherArmorMeta) helmet.getItemMeta(); + helmetmeta.setColor(team.GetColorBase()); + helmet.setItemMeta(helmetmeta); + + ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE); + LeatherArmorMeta chestmeta = (LeatherArmorMeta) chest.getItemMeta(); + chestmeta.setColor(team.GetColorBase()); + chest.setItemMeta(chestmeta); + + ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS); + LeatherArmorMeta leggingsmeta = (LeatherArmorMeta) leggings.getItemMeta(); + leggingsmeta.setColor(team.GetColorBase()); + leggings.setItemMeta(leggingsmeta); + + ItemStack stack = new ItemStack(Material.LEATHER_BOOTS); + LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta(); + meta.setColor(team.GetColorBase()); + stack.setItemMeta(meta); + + giant.getEquipment().setHelmet(helmet); + giant.getEquipment().setChestplate(chest); + giant.getEquipment().setLeggings(leggings); + giant.getEquipment().setBoots(stack); + + giant.setMaxHealth(100); + giant.setHealth(100); + _giants.put(team, giant); + i++; + } + for(GameTeam team : GetTeamList()) + { + for(GameTeam otherTeam : GetTeamList()) + { + if(team != otherTeam) + { + for(Location location : _giantAttackZones.get(team)) + { + Location giantLoc = _giants.get(otherTeam).getLocation(); + location.setYaw(UtilAlg.GetYaw(new Vector(giantLoc.getBlockX() - location.getBlockX(), giantLoc.getBlockY() - location.getBlockY(), giantLoc.getBlockZ() - location.getBlockZ()))); + } + } + } + } + } + + @EventHandler + public void fixGiants(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(GetState() != GameState.Prepare) + return; + + for(Giant giant : _giantLocs.keySet()) + { + giant.teleport(_giantLocs.get(giant)); + } + } + + @EventHandler + public void Players(UpdateEvent event) + { + if(GetState() != GameState.Live && GetState() != GameState.End) + return; + + if(event.getType() != UpdateType.TICK) + return; + + for(Player player : GetPlayers(true)) + { + Recharge.Instance.Reset(player, "Chat Message"); + + player.setAllowFlight(true); + player.setFlying(true); + UtilTextBottom.display(C.cGreen + "You have $" + _moneyMap.get(player), player); + + for(Minion minion : _activeMinions) + { + if(UtilMath.offset(minion.getEntity().getLocation(), player.getLocation()) < 1) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(minion.getEntity().getLocation(), player.getLocation()), 1, true, 1, 1, 1, true); + } + } + } + } + + @EventHandler + public void ForcefieldUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + for (Minion minion : _activeMinions) + { + for (Player other : UtilServer.getPlayers()) + { + if (UtilMath.offset(other, minion.getEntity()) > 3) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + UtilAction.velocity(other, UtilAlg.getTrajectory2d(minion.getEntity(), other), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + for (Giant giant : _giants.values()) + { + for (Player other : UtilServer.getPlayers()) + { + if (UtilMath.offset(other, giant) > 10) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + UtilAction.velocity(other, UtilAlg.getTrajectory2d(giant, other), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + } + + private Location _tutorialLocationRed, _tutorialLocationBlue; + + private void initSpawns() + { + WorldData data = WorldData; + + ((CraftWorld) data.World).getHandle().spigotConfig.animalActivationRange = 200; + ((CraftWorld) data.World).getHandle().spigotConfig.monsterActivationRange = 200; + + ((CraftWorld) data.World).getHandle().spigotConfig.animalTrackingRange = 200; + ((CraftWorld) data.World).getHandle().spigotConfig.monsterTrackingRange = 200; + + _minionSpawns.put(GetTeamList().get(0), (ArrayList)data.GetDataLocs("RED").clone()); + _minionSpawns.put(GetTeamList().get(1), (ArrayList)data.GetDataLocs("LIGHT_BLUE").clone()); + + _giantAttackZones.put(GetTeamList().get(0), (ArrayList) data.GetDataLocs("MAGENTA").clone()); + _giantAttackZones.put(GetTeamList().get(1), (ArrayList) data.GetDataLocs("ORANGE").clone()); + + Location blue = WorldData.GetDataLocs("LIME").get(0); + Location red = WorldData.GetDataLocs("PURPLE").get(0); + + ArrayList tutorialLocations = UtilShapes.getLinesDistancedPoints(red, blue, 1); + _tutorialLocationRed = tutorialLocations.get(20).clone().add(0, 15, 0); + _tutorialLocationBlue = tutorialLocations.get(tutorialLocations.size() - 20).clone().add(0, 15, 0); + } + + @EventHandler + public void tutorialStart(GameTutorialStartEvent event) + { + Location targetRed, targetBlue; + ArrayList locations = UtilShapes.getLinesDistancedPoints(_minionSpawns.get(GetTeamList().get(0)).get(4), _minionSpawns.get(GetTeamList().get(1)).get(4), 1); + + targetRed = locations.get(locations.size() - 3); + targetBlue = locations.get(3); + if(event.getTutorial().getTeam() == GetTeamList().get(1)) + { + event.getTutorial().getPhase(1).setLocation(_tutorialLocationRed); + event.getTutorial().getPhase(1).setTarget(targetRed); + } + else + { + event.getTutorial().getPhase(1).setLocation(_tutorialLocationBlue); + event.getTutorial().getPhase(1).setTarget(targetBlue); + } + } + + @EventHandler + public void tutorialEnd(final GameTutorialEndEvent event) + { + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + for(Player player : event.getTutorial().getPlayers().keySet()) + { + Location location = player.getLocation().clone(); + for(GameTeam team : GetTeamList()) + { + if(team != event.getTutorial().getTeam()) + { + location.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(location, _giants.get(team).getLocation()))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _giants.get(team).getLocation()))); + } + } + player.teleport(location); + } + } + }, 7); + } + + @Override + public void addTutorials() + { + GetTeamList().get(0).setTutorial(new TutorialTypeWars(Manager)); + GetTeamList().get(1).setTutorial(new TutorialTypeWars(Manager)); + } + + @EventHandler + public void tutorialFrames(GameStateChangeEvent event) + { + if(event.GetState() != GameState.Live) + return; + + for(Giant giant : _giants.values()) + { + giant.setHealth(100); + } + + _activeMinions.clear(); + _deadMinions.clear(); + _finishedMinions.clear(); + } + + @EventHandler + public void testCommands(PlayerCommandPreprocessEvent event) + { + if(GetState() != GameState.Live) + return; + + if(event.getMessage().contains("/Money")) + { + + if(!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.DEVELOPER, true)) + return; + + _moneyMap.put(event.getPlayer(), 1000); + UtilPlayer.message(event.getPlayer(), F.main("Money", "You got some Money")); + event.setCancelled(true); + return; + } + + if(event.getMessage().contains("/Boss")) + { + if(!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.DEVELOPER, true)) + return; + + if(!IsPlaying(event.getPlayer())) + return; + + + event.setCancelled(true); + GameTeam teams = GetTeam(event.getPlayer()); + for(GameTeam team : GetTeamList()) + { + if(team == teams) + continue; + + int rdm = UtilMath.r(_minionSpawns.get(teams).size()); + this.CreatureAllowOverride = true; + Minion minion = new Minion(Manager, _minionSpawns.get(teams).get(rdm), _minionSpawns.get(team).get(rdm), teams, event.getPlayer(), true, MinionSize.BOSS.getRandomType(), rdm); + _activeMinions.add(minion); + this.CreatureAllowOverride = false; + UtilPlayer.message(event.getPlayer(), F.main("Boss", "You have spawned a Boss")); + } + } + + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if(event.getItem() == null) + return; + + if(GetState() != GameState.Live) + return; + + for(MinionSize type : MinionSize.values()) + { + if(type.getDisplayItem().getType() == event.getItem().getType() && type.getDisplayItem().getDurability() == event.getItem().getDurability()) + { + if(type.getCost() > _moneyMap.get(event.getPlayer())) + { + UtilTextMiddle.display("", ChatColor.GRAY + "You dont have enough money to spawn this Minion.", event.getPlayer()); + return; + } + GameTeam teams = GetTeam(event.getPlayer()); + for(GameTeam team : GetTeamList()) + { + if(teams != team) + { + if(getMinions(teams).size() >= 60) + { + UtilTextMiddle.display("", ChatColor.GRAY + "Your Team can't have more than 60 Minions", 5, 30, 5, event.getPlayer()); + return; + } + + this.CreatureAllowOverride = true; + _moneyMap.put(event.getPlayer(), _moneyMap.get(event.getPlayer()) - type.getCost()); + UtilTextMiddle.display("", ChatColor.GRAY + "You bought a Minion.", event.getPlayer()); + int rdm = UtilMath.r(_minionSpawns.get(teams).size()); + Minion minion = new Minion(Manager, _minionSpawns.get(teams).get(rdm), _minionSpawns.get(team).get(rdm), teams, event.getPlayer(), true, type.getRandomType(), rdm); + Bukkit.getPluginManager().callEvent(new SummonMinionEvent(event.getPlayer(), minion)); + _activeMinions.add(minion); + this.CreatureAllowOverride = false; + } + } + return; + } + } + } + + @EventHandler + public void mobSpawn(EntitySpawnEvent event) + { + if(event.getEntityType() == EntityType.CREEPER) + { + event.setCancelled(true); + } + } + + @EventHandler(priority=EventPriority.LOWEST) + public void noItems(EntityDeathEvent event) + { + event.getDrops().clear(); + } + + @EventHandler + public void spawnMinions(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(!IsLive()) + return; + + if(UtilTime.elapsed(_lastSpawnedRed, _timeToSpawnRed)) + { + if(getMinions(GetTeamList().get(0)).size() < 60) + { + _lastSpawnedRed = System.currentTimeMillis(); + + this.CreatureAllowOverride = true; + int rdm = UtilMath.r(_minionSpawns.get(GetTeamList().get(0)).size()); + Minion minion = null; + + if(_minionsSpawned.get(GetTeamList().get(0)) >= 100) + { + _minionsSpawned.put(GetTeamList().get(0), 0); + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(0)).get(rdm), _minionSpawns.get(GetTeamList().get(1)).get(rdm), GetTeamList().get(0), null, true, MinionSize.BOSS.getRandomType(), rdm); + UtilTextMiddle.display("", minion.getTeam().GetColor() + "A Boss monster has spawned!"); + } + else + { + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(0)).get(rdm), _minionSpawns.get(GetTeamList().get(1)).get(rdm), GetTeamList().get(0), rdm); + } + _activeMinions.add(minion); + + this.CreatureAllowOverride = false; + + if(_timeToSpawnRed > 5000 / (GetTeamList().get(1).GetPlayers(true).size() > 0 ? GetTeamList().get(1).GetPlayers(true).size() : 1)) + _timeToSpawnRed = _timeToSpawnRed - 75; + + } + } + if(UtilTime.elapsed(_lastSpawnedBlue, _timeToSpawnBlue)) + { + if(getMinions(GetTeamList().get(1)).size() < 60) + { + _lastSpawnedBlue = System.currentTimeMillis(); + + this.CreatureAllowOverride = true; + int rdm = UtilMath.r(_minionSpawns.get(GetTeamList().get(1)).size()); + Minion minion = null; + if(_minionsSpawned.get(GetTeamList().get(1)) >= 100) + { + _minionsSpawned.put(GetTeamList().get(1), 0); + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(1)).get(rdm), _minionSpawns.get(GetTeamList().get(0)).get(rdm), GetTeamList().get(1), null, true, MinionSize.BOSS.getRandomType(), rdm); + UtilTextMiddle.display("", minion.getTeam().GetColor() + "A Boss monster has spawned!"); + } + else + { + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(1)).get(rdm), _minionSpawns.get(GetTeamList().get(0)).get(rdm), GetTeamList().get(1), rdm); + } + _activeMinions.add(minion); + this.CreatureAllowOverride = false; + + if(_timeToSpawnBlue > 5000 / (GetTeamList().get(0).GetPlayers(true).size() > 0 ? GetTeamList().get(0).GetPlayers(true).size() : 1)) + _timeToSpawnBlue = _timeToSpawnRed - 75; + + } + } + } + + @EventHandler + public void updateMinions(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(GetState() != GameState.Live && GetState() != GameState.Prepare) + return; + + Iterator minionIterator = _activeMinions.iterator(); + + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + if(minion.isSpawned()) + { + if(minion.isMoving()) + { + if(!UtilEnt.CreatureMoveFast(minion.getEntity(), minion.getTarget(), minion.getWalkSpeed())) + { + GameTeam enemy = null; + for(GameTeam teams : GetTeamList()) + { + if(teams != minion.getTeam()) + enemy = teams; + } + Location nextTarget = _giantAttackZones.get(enemy).get(minion.getSpawnID()); + if(!nextTarget.equals(minion.getTarget())) + { + minion.setTarget(nextTarget); + } + else + { + if(!_finishedMinions.contains(minion)) + _finishedMinions.add(minion); + } + } + } + } + Hologram hologram = minion.getHologram(); + hologram.setLocation(minion.getEntity().getLocation().add(0, minion.getTagHight() + 2.3, 0)); + } + } + + @EventHandler + public void checkDeadMinions(UpdateEvent event) + { + if(GetState() != GameState.Live && GetState() != GameState.End) + return; + + if(event.getType() != UpdateType.FASTER) + return; + + for(Minion minion : _deadMinions) + { + if(!minion.getEntity().isDead()) + minion.despawn(null, false); + } + } + + @EventHandler + public void giants(UpdateEvent event) + { + if(GetState() != GameState.Live) + return; + + if(event.getType() != UpdateType.SLOW) + return; + + for(GameTeam team : _giants.keySet()) + { + ArrayList minions = new ArrayList<>(); + for(Minion minion : _finishedMinions) + { + if(!minion.getEntity().isDead()) + { + if(minion.getTeam() != team) + minions.add(minion); + } + } + if(minions.isEmpty()) + continue; + + Giant giant = _giants.get(team); + Minion minion = minions.get(UtilMath.r(minions.size())); + Location loc = giant.getLocation().clone(); + loc.setYaw(UtilAlg.GetYaw(new Vector(minion.getEntity().getLocation().getBlockX() - loc.getBlockX(), minion.getEntity().getLocation().getBlockY() - loc.getBlockY(), minion.getEntity().getLocation().getBlockZ() - loc.getBlockZ()))); + giant.teleport(loc); + for(Player player : team.GetPlayers(false)) + { + player.playSound(giant.getLocation(), Sound.ZOMBIE_WOODBREAK, 100, 1); + player.playSound(giant.getLocation(), Sound.ZOMBIE_IDLE, 1, 1); + } + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, minion.getEntity().getLocation(), 0, 0, 0, 1, 1, ViewDist.LONG, UtilServer.getPlayers()); + + minion.despawn(null, true); + if(!minion.hasLives()) + _deadMinions.add(minion); + } + } + + @EventHandler + public void minionAttack(UpdateEvent event) + { + if(GetState() != GameState.Live && GetState() != GameState.Prepare) + return; + + if(event.getType() != UpdateType.SEC) + return; + + for(GameTeam team : _giants.keySet()) + { + int damage = 0; + for(Minion minion : _finishedMinions) + { + if(minion.getTeam() == team) + continue; + + if(minion.getEntity().isDead()) + continue; + + damage++; + } + if(damage == 0) + continue; + + for(GameTeam otherTeam : GetTeamList()) + { + if(team != otherTeam) + { + _giants.get(team).getWorld().playSound(_giants.get(team).getEyeLocation(), Sound.ZOMBIE_HURT, 100, 1); + _giants.get(team).damage(damage); + } + } + if(!_giantsAttacked.containsKey(team) || UtilTime.elapsed(_giantsAttacked.get(team), 10000)) + { + _giantsAttacked.put(team, System.currentTimeMillis()); + for(Player player : GetPlayers(true)) + { + if(GetTeam(player) == team) + { + if(IsLive()) + { + UtilTextMiddle.display("", "Your giant is under Attack!", 0, 30, 9, player); + } + } + } + } + } + } + + @EventHandler + public void minionAnimation(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + minion.animation(); + } + } + + public double getScore(GameTeam team) + { + if(_giants.get(team).isDead()) + { + return 0; + } + return _giants.get(team).getHealth(); + } + + @EventHandler + public void chatCheck(AsyncPlayerChatEvent event) + { + if(!IsLive()) + return; + + if(!GetPlayers(true).contains(event.getPlayer())) + return; + + if(event.getMessage().split(" ").length == 1) + event.setCancelled(true); + } + + @EventHandler + public void chatCheck(PlayerChatEvent event) + { + if(!IsLive()) + return; + + if(!GetPlayers(true).contains(event.getPlayer())) + return; + + try + { + Minion minion = getFarestMininion(event.getPlayer(), event.getMessage()); + + Bukkit.getPluginManager().callEvent(new TypeAttemptEvent(event.getPlayer(), event.getMessage(), minion != null)); + + if(minion == null) + return; + + MinionKillEvent minionEvent = new MinionKillEvent(event.getPlayer(), minion, KillType.TYPED); + Bukkit.getPluginManager().callEvent(minionEvent); + + if(minionEvent.isCancelled()) + return; + + killMinion(minion, event.getPlayer()); + + int spawned = _minionsSpawned.get(GetTeam(event.getPlayer())); + _minionsSpawned.put(GetTeam(event.getPlayer()), spawned + 1); + + if(_playerTitles.contains(event.getPlayer())) + { + _playerTitles.remove(event.getPlayer()); + UtilTextMiddle.clear(event.getPlayer()); + } + UtilTextMiddle.display("", C.cGreen + "+$" + minion.getMoney(), event.getPlayer()); + _moneyMap.put(event.getPlayer(), _moneyMap.get(event.getPlayer()) + minion.getMoney()); + return; + } + catch (Exception ex) {} + } + + public enum KillType + { + TYPED, SPELL; + } + + public void killMinion(Minion minion, Player player) + { + if(!minion.hasLives()) + { + _activeMinions.remove(minion); + _deadMinions.add(minion); + } + minion.despawn(player, true); + } + + private Minion getFarestMininion(Player player, String msg) + { + for(Minion minion : _activeMinions) + { + if(msg != null && !minion.getName().equalsIgnoreCase(msg)) + continue; + + if(GetTeam(player) == minion.getTeam()) + continue; + + boolean found = true; + + for(Minion otherMinion : _activeMinions) + { + if(minion == otherMinion) + continue; + + if(msg != null && !otherMinion.getName().equalsIgnoreCase(msg)) + continue; + + if(GetTeam(player) == otherMinion.getTeam()) + continue; + + if(UtilMath.offset(minion.getEntity().getLocation(), minion.getTarget()) > UtilMath.offset(otherMinion.getEntity().getLocation(), otherMinion.getTarget())) + found = false; + } + + if(found) + return minion; + else + continue; + } + return null; + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList winners = new ArrayList<>(); + + for(GameTeam team : GetTeamList()) + { + for(GameTeam otherTeam : GetTeamList()) + { + if(team == otherTeam) + continue; + + if(getScore(team) <= 0) + { + _giants.get(team).damage(1); + winners.add(otherTeam); + } + } + } + + if(winners.isEmpty()) + return; + + GameTeam winner = winners.get(UtilMath.r(winners.size())); + AnnounceEnd(winner); + + Iterator minionIterator = _activeMinions.iterator(); + + while (minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + minion.despawn(null, false); + minionIterator.remove(); + } + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + { + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + AddGems(player, getPlayerKills(player), getPlayerKills(player) + " Minions killed", false, true); + + for(MinionSize size : MinionSize.values()) + { + if(size == MinionSize.BOSS || size == MinionSize.FREAK) + continue; + + AddGems(player, getSpawnedMinions(player, size) * size.getGemReward(), getSpawnedMinions(player, size) + " " + size.getDisplayName() + " Minions spawned", false, true); + } + } + } + } + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + for(GameTeam team : GetTeamList()) + { + Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); + if(wpm.length() > 4) + wpm = wpm.substring(0, 4); + + Scoreboard.Write(team.GetColor() + "WPM: " + wpm); + Scoreboard.WriteBlank(); + } + + Scoreboard.Draw(); + + //End + Manager.GetCreature().SetDisableCustomDrops(false); + Manager.GetChat().setThreeSecondDelay(true); + SetState(GameState.End); + } + + @EventHandler + public void preventFire(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + minionIterator.next().getEntity().setFireTicks(0); + } + } + + @EventHandler + public void updateHotbarItems(UpdateEvent event) + { + if(!IsLive()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + for(Player player : GetPlayers(true)) + { + int e = 0; + for(Spell spell : ((KitTypeWarsBase) GetKit(player)).getSpells()) + { + if(spell instanceof SpellKillEverything) + { + if(spell.hasUsed(player)) + { + player.getInventory().setItem(e, new ItemStack(Material.AIR)); + continue; + } + } + if(_moneyMap.get(player) >= spell.getCost()) + { + if(spell.getCost() > 0) + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, Math.round(_moneyMap.get(player)/spell.getCost()), C.cGreen + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + else + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, 1, C.cGreen + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + } + else + { + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, 0, C.cRed + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + } + e++; + } + + int i = 4; + for(MinionSize type : MinionSize.values()) + { + if(type == MinionSize.BOSS || type == MinionSize.FREAK) + continue; + + if(_moneyMap.get(player) >= type.getCost()) + { + player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(type.getDisplayItem().getType(), (byte) 0, Math.round(_moneyMap.get(player)/type.getCost()), (short) type.getDisplayItem().getDurability(), C.cGreen + "Spawn " + type.getDisplayName() + " Minion Cost: " + type.getCost(), new String[]{})); + } + else + { + player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(type.getDisplayItem().getType(), (byte) 0, 0, (short) type.getDisplayItem().getDurability(), C.cRed + "Spawn " + type.getDisplayName() + " Minion Cost: " + type.getCost(), new String[]{})); + } + i++; + } + } + } + + private int _animationTicks; + + @EventHandler + public void lines(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(ArrayList locs : _lineGrowth.values()) + { + for(Location loc : locs) + { + double radius = _animationTicks / 20D; + int particleAmount = _animationTicks / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = loc.clone().add(0.5, 0, 0.5).clone().add(xDiff, particleAmount/10, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.RED_DUST, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + for(ArrayList locs : _lineShorten.values()) + { + for(Location loc : locs) + { + double radius = _animationTicks / 20D; + int particleAmount = _animationTicks / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = loc.clone().add(0.5, 0, 0.5).add(xDiff, particleAmount/10, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + _animationTicks++; + if(_animationTicks > 15) + _animationTicks = 0; + + Iterator minionIterator = _activeMinions.iterator(); + + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + for(GameTeam team : _lineGrowth.keySet()) + { + for(Location loc : _lineGrowth.get(team)) + { + if(minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) + continue; + + if(minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) + continue; + + if(!minion.isNameChangeable()) + continue; + + if(team != minion.getTeam()) + continue; + + int oldname = minion.getName().length() + 2; + minion.changeRandomName(oldname, oldname, false); + } + } + for(GameTeam team : _lineShorten.keySet()) + { + for(Location loc : _lineShorten.get(team)) + { + if(minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) + continue; + + if(minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) + continue; + + if(!minion.isNameChangeable()) + continue; + + if(team == minion.getTeam()) + continue; + + int oldname = minion.getName().length() - 2; + minion.changeRandomName(oldname, oldname, false); + } + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + if(!IsLive()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + for(GameTeam team : GetTeamList()) + { + Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); + if(wpm.length() > 4) + wpm = wpm.substring(0, 4); + + Scoreboard.Write(team.GetColor() + "WPM: " + wpm); + Scoreboard.WriteBlank(); + } + + Scoreboard.Draw(); + } + + public ArrayList getMinions(GameTeam team) + { + ArrayList minionList = new ArrayList<>(); + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + if(minion.getTeam() == team) + minionList.add(minion); + } + return minionList; + } + + private int _nukeFrame; + + @EventHandler + public void nuke(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(_pendingNukes.isEmpty()) + return; + + Player player = _pendingNukes.get(0); + GameTeam team = GetTeam(player); + + GameTeam otherTeam = null; + for(GameTeam teams : GetTeamList()) + { + if(teams != team) + { + otherTeam = teams; + } + } + ArrayList testLocs = UtilShapes.getLinesDistancedPoints(_minionSpawns.get(team).get(0), _minionSpawns.get(otherTeam).get(0), 1); + + if(_nukeFrame >= testLocs.size()) + { + _nukeFrame = 0; + _pendingNukes.remove(0); + return; + } + if(_nukeFrame < 25) + { + _giants.get(team).getWorld().playSound(_giants.get(team).getLocation(), Sound.ZOMBIE_IDLE, 1, 1); + } + boolean cansee = true; + int i = 0; + for(Location loc : _minionSpawns.get(team)) + { + cansee = !cansee; + ArrayList locations = UtilShapes.getLinesDistancedPoints(loc, _minionSpawns.get(otherTeam).get(i), 1); + Location location = locations.get(_nukeFrame); + + if(cansee) + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + for(Player players : GetPlayers(false)) + players.playSound(location, Sound.EXPLODE, 1, 1); + } + + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + if(minion.getTeam() == team) + continue; + + if(UtilMath.offset(location, minion.getEntity().getLocation()) > 1) + continue; + + minion.despawn(player, true); + if(!minion.hasLives()) + { + minionIterator.remove(); + _deadMinions.add(minion); + } + } + Iterator finishedMinionIterator = _finishedMinions.iterator(); + while(finishedMinionIterator.hasNext()) + { + Minion minion = finishedMinionIterator.next(); + if(minion.getTeam() == team) + continue; + + if(UtilMath.offset(location, minion.getEntity().getLocation()) > 3) + continue; + + minion.despawn(player, true); + if(!minion.hasLives()) + { + finishedMinionIterator.remove(); + _deadMinions.add(minion); + } + } + i++; + } + _nukeFrame++; + } + + public int getPlayerKills(Player player) + { + int kills = 0; + for(Minion minion : _deadMinions) + { + if(minion.getKiller() != null) + { + if(minion.getKiller().getName().contentEquals(player.getName())) + { + kills++; + } + } + } + return kills; + } + + public int getTeamKills(GameTeam team) + { + int kills = 0; + for(Player player : team.GetPlayers(true)) + { + kills = kills + getPlayerKills(player); + } + return kills; + } + + public int getSpawnedMinions(Player player, MinionSize size) + { + int spawns = 0; + for(Minion minion : _deadMinions) + { + if(minion.getType().getSize() != size) + continue; + + if(minion.getPlayer() == null) + continue; + + if(minion.getPlayer().getName().contentEquals(player.getName())) + spawns++; + } + return spawns; + } + + public HashMap getMoneyMap() + { + return _moneyMap; + } + + public ArrayList getActiveMinions() + { + return _activeMinions; + } + + public ArrayList getDeadMinions() + { + return _deadMinions; + } + + public HashMap> getMinionSpawns() + { + return _minionSpawns; + } + + public HashMap> getLineGrowth() + { + return _lineGrowth; + } + + public HashMap> getLineShorten() + { + return _lineShorten; + } + + public void addNuke(Player player) + { + _pendingNukes.add(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTactician.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTactician.java new file mode 100644 index 000000000..62ed1d88e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTactician.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.game.games.typewars.spells.SpellGrowthLiner; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.spells.SpellMassSlow; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class KitTactician extends KitTypeWarsBase +{ + + public KitTactician(ArcadeManager manager) + { + super(manager, "Alpha. Tactician", KitAvailability.Achievement, + new String[] + { + "The ahlpabet Tactician", + "is known for using deffensive spells" + }, + new Perk[] + { + new Perk("Growth Line", new String[]{"Creates a line that grows your minions names"}){}, + new Perk("Mass Slow", new String[]{"Slows down all enemy Minions"}){}, + new Perk("Nuke Spell", new String[]{"Kill all enemy minions. One use."}){} + }, + EntityType.SKELETON, new ItemStack(Material.PAPER), + new Spell[]{new SpellGrowthLiner(manager), new SpellMassSlow(manager), new SpellKillEverything(manager)}); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTypeWarsBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTypeWarsBase.java new file mode 100644 index 000000000..3e813d0f9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTypeWarsBase.java @@ -0,0 +1,97 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.MinionSize; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +public abstract class KitTypeWarsBase extends Kit +{ + + private Spell[] _spells; + + public KitTypeWarsBase(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand, Spell[] spells) + { + super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); + _spells = spells; + } + + public KitTypeWarsBase(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand, Spell[] spells) + { + super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand); + _spells = spells; + } + + @Override + public void GiveItems(Player player) + { + int e = 0; + for(Spell spell : getSpells()) + { + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, 1, C.cYellow + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + e++; + } + + int i = 4; + for(MinionSize type : MinionSize.values()) + { + if(type != MinionSize.BOSS && type != MinionSize.FREAK) + { + player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(type.getDisplayItem().getType(), (byte) 0, 1, (short) type.getDisplayItem().getDurability(), C.cYellow + "Spawn " + type.getDisplayName() + " Minion Cost: " + type.getCost(), new String[]{})); + i++; + } + } + } + + public Spell[] getSpells() + { + return _spells; + } + + @EventHandler + public void activateSpell(PlayerInteractEvent event) + { + if(!Manager.GetGame().IsLive()) + return; + + if(!Manager.GetGame().IsPlaying(event.getPlayer())) + return; + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + return; + + if(event.getPlayer().getItemInHand() == null) + return; + + if(!Manager.GetGame().GetKit(event.getPlayer()).GetName().equalsIgnoreCase(GetName())) + return; + + executeSpell(event.getPlayer(), event.getPlayer().getItemInHand().getType()); + } + + public boolean executeSpell(Player player, Material mat) + { + for(Spell spell : getSpells()) + { + if(spell.getMaterial() == mat) + { + spell.prepareExecution(player); + return true; + } + } + return false; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTyper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTyper.java new file mode 100644 index 000000000..4eb64ad90 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTyper.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.game.games.typewars.spells.SpellFirebomb; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.spells.SpellSniper; +import nautilus.game.arcade.game.games.typewars.spells.SpellSpeedUp; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class KitTyper extends KitTypeWarsBase +{ + + public KitTyper(ArcadeManager manager) + { + super(manager, "Typer", KitAvailability.Free, + + new String[] + { + "This is the fastest typer ", + "in the land of Mineplex" + }, + new Perk[] + { + new Perk("Fire Bomb", new String[]{"Kills small and medium sized enemies."}){}, + new Perk("Sniper spell", new String[]{"Shoot a minion and kill it"}){}, + new Perk("Zombie Smash", new String[]{"Kill all enemy minions. One use."}){} + }, + EntityType.ZOMBIE, new ItemStack(Material.FEATHER), + new Spell[]{new SpellFirebomb(manager), new SpellSniper(manager), new SpellKillEverything(manager)}); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitWarrior.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitWarrior.java new file mode 100644 index 000000000..de293df7d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitWarrior.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.spells.SpellShrinkLiner; +import nautilus.game.arcade.game.games.typewars.spells.SpellSniper; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class KitWarrior extends KitTypeWarsBase +{ + + public KitWarrior(ArcadeManager manager) + { + super(manager, "Letter Warrior", KitAvailability.Gem, 2000, + new String[] + { + "This Legendary Warrior", + "has many Offensive spells" + }, + new Perk[] + { + new Perk("Shrinking Line", new String[]{"Creates a line that shortens enemy names"}){}, + new Perk("Sniper spell", new String[]{"Shoot a minion and kill it"}){}, + new Perk("Nuke Spell", new String[]{"Kill all enemy minions. One use."}){} + }, + EntityType.SKELETON, new ItemStack(Material.STONE_SWORD), + new Spell[]{new SpellShrinkLiner(manager), new SpellSniper(manager), new SpellKillEverything(manager)}); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellFirebomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellFirebomb.java new file mode 100644 index 000000000..2da5791b2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellFirebomb.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.Iterator; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.MinionSize; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +public class SpellFirebomb extends Spell +{ + + public SpellFirebomb(ArcadeManager manager) + { + super(manager, "Firebomb", 4, Material.BLAZE_POWDER, 2000L, 5, 0, false); + } + + @Override + public boolean execute(Player player, Location location) + { + Iterator minionIterator = getTypeWars().getActiveMinions().iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + if(UtilMath.offset2d(minion.getEntity().getLocation(), location) > 3) + continue; + + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + if(minion.getType().getSize() != MinionSize.EASY) + { + UtilPlayer.message(player, F.main("Game", F.game(minion.getName()) + " is to strong to be killed with that.")); + continue; + } + + minion.despawn(player, true); + if(!minion.hasLives()) + { + minionIterator.remove(); + getTypeWars().getDeadMinions().add(minion); + } + } + return true; + } + + @Override + public ParticleType hit() + { + return ParticleType.HUGE_EXPLOSION; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java new file mode 100644 index 000000000..1ba8efa83 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java @@ -0,0 +1,135 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class SpellGrowthLiner extends Spell +{ + + public SpellGrowthLiner(ArcadeManager manager) + { + super(manager, "Growth Line", 7, Material.STICK, 2000L, 10, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.FLAME; + } + + @Override + public boolean execute(final Player player, Location location) + { + final ArrayList line = getLine(player, location); + for(Location loc : line) + { + getTypeWars().getLineGrowth().get(getManager().GetGame().GetTeam(player)).add(loc); + } + + getManager().runSyncLater(new Runnable() + { + @Override + public void run() + { + for(Location loc : line) + { + getTypeWars().getLineGrowth().get(getManager().GetGame().GetTeam(player)).remove(loc); + } + } + }, 180); + return true; + } + + private ArrayList getLine(Player player, Location location) + { + ArrayList line = new ArrayList<>(); + ArrayList spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); + for(Location loc : spawns) + { + if(loc.getBlockX() == location.getBlockX() || loc.getBlockX() == location.getBlockX() - 1 || loc.getBlockX() == location.getBlockX() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setZ(location.getBlockZ()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(1, 0, 0); + Location pos2 = newLoc.clone().add(-1, 0, 0); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + if(loc.getBlockZ() == location.getBlockZ() || loc.getBlockZ() == location.getBlockZ() - 1 || loc.getBlockZ() == location.getBlockZ() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setX(location.getBlockX()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(0, 0, 1); + Location pos2 = newLoc.clone().add(0, 0, -1); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + } + for(Location loc : spawns) + { + Iterator locIterator = line.iterator(); + while(locIterator.hasNext()) + { + Location locs = locIterator.next(); + if(locs.equals(loc)) + { + locIterator.remove(); + } + if(locs.getBlock().getType() != Material.AIR) + locIterator.remove(); + + } + } + return line; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellKillEverything.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellKillEverything.java new file mode 100644 index 000000000..26bae0d4b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellKillEverything.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.ActivateNukeSpellEvent; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class SpellKillEverything extends Spell +{ + + public SpellKillEverything(ArcadeManager manager) + { + super(manager, "Zombie Smash", 0, Material.TNT, 1000L, 0, 20000, true); + } + + @Override + public ParticleType trail() + { + return null; + } + + @Override + public ParticleType hit() + { + return null; + } + + @Override + public boolean execute(Player player, Location location) + { + + UtilTextMiddle.display("", getManager().GetGame().GetTeam(player).GetColor() + player.getName() + " used a Zombie Smash", 0, 40, 0); + ArrayList minionList = new ArrayList<>(); + Iterator minionIterator = getTypeWars().getActiveMinions().iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + minionList.add(minion); + } + getTypeWars().addNuke(player); + Bukkit.getPluginManager().callEvent(new ActivateNukeSpellEvent(player, minionList)); + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellMassSlow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellMassSlow.java new file mode 100644 index 000000000..26068b303 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellMassSlow.java @@ -0,0 +1,79 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.Spell; + +public class SpellMassSlow extends Spell +{ + + public SpellMassSlow(ArcadeManager manager) + { + super(manager, "Mass Slow spell", 8, Material.ANVIL, 2000L, 0, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.WITCH_MAGIC; + } + + @Override + public boolean execute(Player player, Location location) + { + location.getWorld().playSound(location.clone().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F); + + for(int c = -1; c <= 1; c++) + { + for(int i = -10; i <= 10; i = i + 2) + { + for(double x = 0.2; x <= 2; x = x + 0.2) + { + Location loc = location.clone().add(i + x, 2*(x-1)*(x-1)*(x-1) -2*(x-1), c); + loc.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, loc, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + + Location otherLocation = location.clone().add(c, 2*(x-1)*(x-1)*(x-1) -2*(x-1), i + x); + otherLocation.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, otherLocation, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + } + } + } + + for(Minion minion : getTypeWars().getActiveMinions()) + { + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + minion.increaseWalkSpeed(-0.3F); + } + return true; + } + + /*@Override + public void trailAnimation(Location location, int frame) + { + double radius = 0.6; + int particleAmount = frame / 2; + for (int i = 0; i < particleAmount; i++) + { + double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; + + Location loc = location.clone().add(xDiff, 0, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.ENCHANTMENT_TABLE, loc, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + }*/ + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java new file mode 100644 index 000000000..4bf3471e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java @@ -0,0 +1,134 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class SpellShrinkLiner extends Spell +{ + + public SpellShrinkLiner(ArcadeManager manager) + { + super(manager, "Shrinking Line", 7, Material.BLAZE_ROD, 2000L, 10, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.FLAME; + } + + @Override + public boolean execute(final Player player, Location location) + { + final ArrayList line = getLine(player, location); + for(Location loc : line) + { + getTypeWars().getLineShorten().get(getManager().GetGame().GetTeam(player)).add(loc); + } + + getManager().runSyncLater(new Runnable() + { + @Override + public void run() + { + for(Location loc : line) + { + getTypeWars().getLineShorten().get(getManager().GetGame().GetTeam(player)).remove(loc); + } + } + }, 180); + return true; + } + + private ArrayList getLine(Player player, Location location) + { + ArrayList line = new ArrayList<>(); + ArrayList spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); + for(Location loc : spawns) + { + if(loc.getBlockX() == location.getBlockX() || loc.getBlockX() == location.getBlockX() - 1 || loc.getBlockX() == location.getBlockX() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setZ(location.getBlockZ()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(1, 0, 0); + Location pos2 = newLoc.clone().add(-1, 0, 0); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + if(loc.getBlockZ() == location.getBlockZ() || loc.getBlockZ() == location.getBlockZ() - 1 || loc.getBlockZ() == location.getBlockZ() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setX(location.getBlockX()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(0, 0, 1); + Location pos2 = newLoc.clone().add(0, 0, -1); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + } + for(Location loc : spawns) + { + Iterator locIterator = line.iterator(); + while(locIterator.hasNext()) + { + Location locs = locIterator.next(); + if(locs.equals(loc)) + { + locIterator.remove(); + } + if(locs.getBlock().getType() != Material.AIR) + locIterator.remove(); + + } + } + return line; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSniper.java new file mode 100644 index 000000000..ddc9db8e5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSniper.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.MinionSize; +import nautilus.game.arcade.game.games.typewars.Spell; + +public class SpellSniper extends Spell +{ + + public SpellSniper(ArcadeManager manager) + { + super(manager, "Sniper spell", 4, Material.ARROW, 2000L, 0, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.EXPLODE; + } + + @Override + public boolean execute(Player player, Location location) + { + Iterator minionIterator = getTypeWars().getActiveMinions().iterator(); + + ArrayList locs = UtilShapes.getLinesDistancedPoints(player.getEyeLocation(), location, 0.5); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + for(Location loc : locs) + { + if(UtilMath.offset2d(minion.getEntity().getLocation(), loc) > 1) + continue; + + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + minion.despawn(player, true); + if(!minion.hasLives()) + { + minionIterator.remove(); + getTypeWars().getDeadMinions().add(minion); + } + break; + } + } + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSpeedUp.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSpeedUp.java new file mode 100644 index 000000000..e38733319 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSpeedUp.java @@ -0,0 +1,67 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public class SpellSpeedUp extends Spell +{ + + public SpellSpeedUp(ArcadeManager manager) + { + super(manager, "Speed Boost", 6, Material.FEATHER, 5000L, 0, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.HAPPY_VILLAGER; + } + + @Override + public boolean execute(Player player, Location location) + { + + location.getWorld().playSound(location.clone().add(0.5, 0.5, 0.5), Sound.FIREWORK_BLAST, 10F, 2.0F); + + for(int c = -1; c <= 1; c++) + { + for(int i = -10; i <= 10; i = i + 2) + { + for(double x = 0.2; x <= 2; x = x + 0.2) + { + Location loc = location.clone().add(i + x, 2*(x-1)*(x-1)*(x-1) -2*(x-1), c); + loc.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, loc, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + + Location otherLocation = location.clone().add(c, 2*(x-1)*(x-1)*(x-1) -2*(x-1), i + x); + otherLocation.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, otherLocation, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + } + } + } + + for(Minion minion : getTypeWars().getActiveMinions()) + { + if(UtilMath.offset2d(minion.getEntity().getLocation(), location) > 3) + continue; + + if(getTypeWars().GetTeam(player) != minion.getTeam()) + continue; + + minion.increaseWalkSpeed((float) 0.5); + } + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DemonStatsTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DemonStatsTracker.java new file mode 100644 index 000000000..480443f76 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DemonStatsTracker.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.HashMap; + +import nautilus.game.arcade.game.games.typewars.MinionKillEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class DemonStatsTracker extends StatTracker +{ + + private HashMap _players; + private HashMap _kills; + + public DemonStatsTracker(TypeWars game) + { + super(game); + _players = new HashMap<>(); + _kills = new HashMap<>(); + } + + @EventHandler + public void minonKill(MinionKillEvent event) + { + if(event.getType() != KillType.TYPED) + return; + + if(!_players.containsKey(event.getPlayer())) + { + _players.put(event.getPlayer(), System.currentTimeMillis()); + _kills.put(event.getPlayer(), 1); + return; + } + if(_players.get(event.getPlayer()) + 8000 > System.currentTimeMillis()) + { + int kills = _kills.get(event.getPlayer()); + _kills.put(event.getPlayer(), kills + 1); + } + else + { + _players.put(event.getPlayer(), System.currentTimeMillis()); + _kills.put(event.getPlayer(), 1); + } + if(_kills.get(event.getPlayer()) >= 5) + { + addStat(event.getPlayer(), "Demon", 1, true, false); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DumbledontStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DumbledontStatTracker.java new file mode 100644 index 000000000..2549690a6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DumbledontStatTracker.java @@ -0,0 +1,52 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.ArrayList; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.ActivateSpellEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class DumbledontStatTracker extends StatTracker +{ + + private ArrayList _players; + + public DumbledontStatTracker(TypeWars game) + { + super(game); + _players = new ArrayList<>(); + } + + @EventHandler + public void spell(ActivateSpellEvent event) + { + _players.remove(event.getPlayer()); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if(event.GetState() == GameState.Live) + { + for(Player player : event.GetGame().GetPlayers(true)) + _players.add(player); + } + if(event.GetState() == GameState.End) + { + for(Player player : _players) + { + if(player.isOnline()) + { + if(event.GetGame().GetTeam(player) == event.GetGame().WinnerTeam) + addStat(player, "Dumbledont", 1, true, false); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/HoarderStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/HoarderStatTracker.java new file mode 100644 index 000000000..588520211 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/HoarderStatTracker.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.HashMap; + +import nautilus.game.arcade.game.games.typewars.SummonMinionEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class HoarderStatTracker extends StatTracker +{ + + private HashMap _players; + + public HoarderStatTracker(TypeWars game) + { + super(game); + _players = new HashMap<>(); + } + + @EventHandler + public void summonMinion(SummonMinionEvent event) + { + if(!_players.containsKey(event.getPlayer())) + { + _players.put(event.getPlayer(), 1); + return; + } + int summons = _players.get(event.getPlayer()); + _players.put(event.getPlayer(), summons + 1); + if(_players.get(event.getPlayer()) >= 50) + addStat(event.getPlayer(), "Hoarder", 1, true, false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/KillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/KillsStatTracker.java new file mode 100644 index 000000000..1aa151b31 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/KillsStatTracker.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +public class KillsStatTracker extends StatTracker +{ + + private TypeWars _typeWars; + + public KillsStatTracker(TypeWars game) + { + super(game); + _typeWars = game; + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if(event.GetState() != GameState.End) + return; + + for(Player player : _typeWars.GetPlayers(true)) + { + addStat(player, "MinionKills", _typeWars.getPlayerKills(player), false, false); + } + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/PerfectionistStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/PerfectionistStatTracker.java new file mode 100644 index 000000000..f84200bd0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/PerfectionistStatTracker.java @@ -0,0 +1,82 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.ArrayList; +import java.util.HashMap; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.TypeAttemptEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class PerfectionistStatTracker extends StatTracker +{ + + private HashMap _wordsRecently; + private ArrayList _players; + private HashMap _playerWords; + + public PerfectionistStatTracker(TypeWars game) + { + super(game); + _wordsRecently = new HashMap<>(); + _players = new ArrayList<>(); + _playerWords = new HashMap<>(); + } + + @EventHandler + public void attempt(TypeAttemptEvent event) + { + if(event.isSuccessful()) + { + _wordsRecently.put(event.getAttempt().toUpperCase(), System.currentTimeMillis()); + + if(!_playerWords.containsKey(event.getPlayer())) + _playerWords.put(event.getPlayer(), 1); + + int words = _playerWords.get(event.getPlayer()); + _playerWords.put(event.getPlayer(), words + 1); + } + else + { + if(_wordsRecently.containsKey(event.getAttempt().toUpperCase())) + { + if(_wordsRecently.get(event.getAttempt().toUpperCase()) + 2000 > System.currentTimeMillis()) + { + return; + } + } + _players.remove(event.getPlayer()); + } + } + + @EventHandler + public void gameState(GameStateChangeEvent event) + { + if(event.GetState() == GameState.Live) + { + for(Player player : event.GetGame().GetPlayers(true)) + { + _players.add(player); + } + } + if(event.GetState() == GameState.End) + { + for(Player player : _players) + { + if(player.isOnline()) + { + if(_playerWords.containsKey(player)) + { + if(_playerWords.get(player) >= 5) + addStat(player, "Perfectionist", 1, true, false); + } + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/TimeInGameTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/TimeInGameTracker.java new file mode 100644 index 000000000..b92316dae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/TimeInGameTracker.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class TimeInGameTracker extends StatTracker +{ + + public TimeInGameTracker(Game game) + { + super(game); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if(event.GetState() != GameState.End) + return; + + for(Player player : getGame().GetPlayers(true)) + { + addStat(player, "TimeInGame", (int) (((System.currentTimeMillis() - getGame().getGameLiveTime())/1000)/60), false, false); + } + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/WaitForItStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/WaitForItStatTracker.java new file mode 100644 index 000000000..14ec0a44c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/WaitForItStatTracker.java @@ -0,0 +1,24 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import nautilus.game.arcade.game.games.typewars.ActivateNukeSpellEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.event.EventHandler; + +public class WaitForItStatTracker extends StatTracker +{ + + public WaitForItStatTracker(TypeWars game) + { + super(game); + } + + @EventHandler + public void nuke(ActivateNukeSpellEvent event) + { + if(event.getMinions().size() >= 30) + addStat(event.getPlayer(), "Nuke", 1, true, false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialPhaseTypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialPhaseTypeWars.java new file mode 100644 index 000000000..0c6c64898 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialPhaseTypeWars.java @@ -0,0 +1,62 @@ +package nautilus.game.arcade.game.games.typewars.tutorial; + +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.gametutorial.TutorialPhase; +import nautilus.game.arcade.gametutorial.TutorialText; + +public class TutorialPhaseTypeWars extends TutorialPhase +{ + + public TutorialPhaseTypeWars() + { + super(new TutorialText[] + { + new TutorialText("This is your giant!", 1), + new TutorialText("Protect him from evil minions!", 2), + new TutorialText("Type the name above their head to kill them", 3), + new TutorialText("F_", 7, 4), + new TutorialText("Fi_", 7, 5), + new TutorialText("Fis_", 7, 6), + new TutorialText("Fish_", 7, 7), + new TutorialText("Fishi_", 7, 8), + new TutorialText("Fishin_", 7, 9), + new TutorialText("Fishing_", 30, 10), + new TutorialText("Kill your enemy's giant before they kill yours.", 11) + }); + } + + @Override + public int ID() + { + return 1; + } + + @Override + public void onStart() + { + + } + + @Override + public void onEnd() + { + + } + + @Override + public void onMessageDisplay(TutorialText text) + { + if(text.ID() == 10) + { + for(Minion minion : ((TypeWars) getTutorial().Manager.GetGame()).getActiveMinions()) + { + if(minion.getTeam() == getTutorial().getTeam()) + { + minion.despawn(null, false); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialTypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialTypeWars.java new file mode 100644 index 000000000..6c4cd2600 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialTypeWars.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.typewars.tutorial; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilShapes; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.gametutorial.GameTutorial; +import nautilus.game.arcade.gametutorial.TutorialPhase; + +import org.bukkit.Location; + +public class TutorialTypeWars extends GameTutorial +{ + + private ArcadeManager _manager; + private TypeWars _typeWars; + + public TutorialTypeWars(ArcadeManager manager) + { + super(manager, new TutorialPhase[]{new TutorialPhaseTypeWars()}); + + TutorialNotification = true; + } + + @Override + public void onStart() + { + _manager = Manager; + _typeWars = (TypeWars) Manager.GetGame(); + for(GameTeam team : Manager.GetGame().GetTeamList()) + { + if(team != getTeam()) + { + ArrayList locations = UtilShapes.getLinesDistancedPoints(_typeWars.getMinionSpawns().get(getTeam()).get(4), _typeWars.getMinionSpawns().get(team).get(4), 1); + _manager.GetCreature().SetForce(true); + _manager.GetGame().CreatureAllowOverride = true; + Minion minion = new Minion(_manager, locations.get(locations.size() - 35), _typeWars.getMinionSpawns().get(team).get(4), getTeam(), 4); + minion.changeName("Fishing"); + ((TypeWars) _manager.GetGame()).getActiveMinions().add(minion); + _manager.GetGame().CreatureAllowOverride = false; + _manager.GetCreature().SetForce(false); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/PlayerCopyWither.java similarity index 83% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/PlayerCopyWither.java index 12a842188..d1348569e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/PlayerCopyWither.java @@ -1,24 +1,22 @@ -package nautilus.game.arcade.game.games.paintball; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.disguise.disguises.DisguisePlayer; -import nautilus.game.arcade.game.Game; +package nautilus.game.arcade.game.games.wither; import org.bukkit.ChatColor; -import org.bukkit.EntityEffect; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; -public class PlayerCopy +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.Game; + +public class PlayerCopyWither { private Game Host; private Skeleton _ent; private Player _owner; - public PlayerCopy(Game host, Player owner, ChatColor nameColor) + public PlayerCopyWither(Game host, Player owner, ChatColor nameColor) { Host = host; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index 2ff496c6a..c224dcedf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -1,55 +1,11 @@ package nautilus.game.arcade.game.games.wither; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import mineplex.core.common.block.BlockData; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemBuilder; -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; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.paintball.PlayerCopy; -import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent; -import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher; -import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic; -import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor; -import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.kit.perks.data.IBlockRestorer; -import nautilus.game.arcade.stats.BloodThirstyStatTracker; -import nautilus.game.arcade.stats.KingDamageStatTracker; -import nautilus.game.arcade.stats.KingSlayerStatTracker; -import nautilus.game.arcade.stats.TeamDeathsStatTracker; -import nautilus.game.arcade.stats.TeamKillsStatTracker; -import nautilus.game.arcade.stats.WinAsTeamStatTracker; -import nautilus.game.arcade.stats.WitherAssaultReviveTracker; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.EntityEffect; @@ -74,13 +30,45 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; +import mineplex.core.common.block.BlockData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +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; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent; +import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher; +import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor; +import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic; +import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.NullKit; +import nautilus.game.arcade.kit.perks.data.IBlockRestorer; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; + public class WitherGame extends TeamGame implements IBlockRestorer { private GameTeam _runners; @@ -93,7 +81,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer private long _gameTime = 300000; - private HashMap _doubles = new HashMap(); + private HashMap _doubles = new HashMap(); // private int _livesPerPlayer = 3; // private HashMap _lives = new HashMap(); @@ -456,7 +444,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer { if(!players.isOnline()) { - PlayerCopy pc = _doubles.get(players); + PlayerCopyWither pc = _doubles.get(players); pc.GetEntity().remove(); _doubles.remove(players); } @@ -803,7 +791,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer player.setVelocity(new Vector(0, 1.2, 0)); - _doubles.put(player, new PlayerCopy(this, player, ChatColor.YELLOW)); + _doubles.put(player, new PlayerCopyWither(this, player, ChatColor.YELLOW)); } public void playerIn(final Player player, final LivingEntity copy, Player revivedBy) @@ -888,10 +876,10 @@ public class WitherGame extends TeamGame implements IBlockRestorer return; // Revive a copy - Iterator copyIterator = _doubles.values().iterator(); + Iterator copyIterator = _doubles.values().iterator(); while (copyIterator.hasNext()) { - PlayerCopy copy = copyIterator.next(); + PlayerCopyWither copy = copyIterator.next(); GameTeam otherTeam = GetTeam(copy.GetPlayer()); if (otherTeam == null || !otherTeam.equals(throwerTeam)) @@ -937,7 +925,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer @EventHandler public void skeletonDamage(CustomDamageEvent event) { - for (PlayerCopy copy : _doubles.values()) + for (PlayerCopyWither copy : _doubles.values()) { if (copy.GetEntity().equals(event.GetDamageeEntity())) { @@ -950,7 +938,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer @EventHandler public void skeletonCombust(EntityCombustEvent event) { - for (PlayerCopy copy : _doubles.values()) + for (PlayerCopyWither copy : _doubles.values()) { if (copy.GetEntity().equals(event.getEntity())) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index fc4457377..96ac7ad5a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.gametutorial; import java.util.HashMap; import mineplex.core.common.util.UtilServer; -import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; @@ -36,9 +35,12 @@ public abstract class GameTutorial public boolean RunTasksSync = true; public boolean PlayTutorialSounds = false; public boolean ShowPrepareTimer = false; + public boolean CustomEnding = false; + public boolean TutorialNotification = false; public long TimeBetweenPhase = 0; public long StartAfterTutorial = 5000; + public long CustomEndingTime = 5000; public GameTutorial(ArcadeManager manager, TutorialPhase[] phases) { @@ -47,6 +49,9 @@ public abstract class GameTutorial _players = new HashMap<>(); } + /** + * start the Tutorial (never use this) + */ final public void start() { _hasStarted = true; @@ -54,7 +59,30 @@ public abstract class GameTutorial for(TutorialPhase phase : _phases) phase.setTutorial(this); - //Manager.GetGame().PrepareTime = 60000; + if(TutorialNotification) + { + TutorialPhase phase = getPhase(1); + for(TutorialText text : phase.getText()) + { + int index = text.ID(); + text.setID(index + 1); + } + TutorialText[] newText = new TutorialText[phase.getText().length + 1]; + for(int i = 0; i < newText.length; i++) + { + if(i == 0) + { + newText[i] = new TutorialText("Please notice that this is a Tutorial", 20, 1); + continue; + } + else + { + newText[i] = phase.getText()[i - 1]; + } + } + phase.setText(newText); + } + Manager.GetChat().Silence(60000, false); _started = System.currentTimeMillis(); Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this)); @@ -72,6 +100,9 @@ public abstract class GameTutorial _currentPhase.teleport(); } + /** + * Stting next Phase/ending Tutorial + */ protected void nextPhase(boolean phaseOne) { TutorialPhase from = _currentPhase; @@ -80,25 +111,33 @@ public abstract class GameTutorial if(_currentPhase == null) { - onEnd(); - _hasEnded = true; - endTutorial(); - final GameTutorial tutorial = this; - Manager.runSyncLater(new Runnable() + // has ended + if(!CustomEnding) { - @Override - public void run() + onEnd(); + _hasEnded = true; + endTutorial(); + final GameTutorial tutorial = this; + Manager.runSyncLater(new Runnable() { - Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial)); - } - }, 5); + @Override + public void run() + { + Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial)); + } + }, 5); + } } else { - Manager.GetChat().Silence(70000, false); - onPhaseChange(_currentPhase); - Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase)); - _currentPhase.start(phaseOne); + // setting another Phase, if Tutorial hasn't stopped yet + if(!_hasEnded) + { + Manager.GetChat().Silence(70000, false); + onPhaseChange(_currentPhase); + Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase)); + _currentPhase.start(phaseOne); + } } } @@ -111,19 +150,19 @@ public abstract class GameTutorial { for(final Player player : _players.keySet()) { - //VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); Manager.runSyncLater(new Runnable() { @Override public void run() { - for(Player player : Manager.GetGame().GetPlayers(true)) + // Player visibility/fly mode + for(Player other : Manager.GetGame().GetPlayers(false)) { - for(Player other : Manager.GetGame().GetPlayers(true)) - { - player.showPlayer(other); - } - } + if(player == other) + continue; + + other.showPlayer(player); + } player.setAllowFlight(false); player.setFlying(false); } @@ -135,17 +174,20 @@ public abstract class GameTutorial @Override public void run() { + // Spawn teleporting _team.SpawnTeleport(); } }, 5); } } + // setting the right prepare Time after the Tutorial ends Manager.GetChat().Silence(StartAfterTutorial, false); Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + StartAfterTutorial; } protected TutorialPhase getNextPhase() { + // getting next TutorialPhase for(TutorialPhase phase : _phases) { if(_currentPhase == null && phase.ID() == 1) @@ -164,13 +206,13 @@ public abstract class GameTutorial { for(Player player : UtilServer.getPlayers()) { + // setting Players into fly mode and save their Locations int i = 0; if(Manager.GetGame().GetTeam(player) == _team) { _players.put(player, Manager.GetGame().GetTeam(player).GetSpawns().get(i)); player.setAllowFlight(true); player.setFlying(true); - // VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers()); i++; } } @@ -206,16 +248,42 @@ public abstract class GameTutorial return _team; } - public void onTick(int tick){} - - public void onStart(){} - - public void onPhaseChange(TutorialPhase phase){} - - public void onEnd(){} + /** + * only available if CustomEnding is enabled + * You can end the tutorial with this method + * if you set CutomEnding to true, you have to run this method! + */ + public void end() + { + if(CustomEnding) + { + // Ending + onEnd(); + _hasEnded = true; + Thread thread = _currentPhase.getThread(); + if(thread.isAlive()) + thread.destroy(); + + endTutorial(); + final GameTutorial tutorial = this; + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial)); + } + }, 5); + } + else + { + System.out.println("Only allowed while Custom Ending is enabled"); + } + } public int tick() { + // Fix for Visibility Manager not really working if(!_hasEnded && hasStarted()) { for(Player player : UtilServer.getPlayers()) @@ -249,4 +317,17 @@ public abstract class GameTutorial { return _currentPhase.getPhaseTime(); } + + /* + * some overrideable methods that can be used to synchronize the tutorial events + */ + + public void onTick(int tick){} + + public void onStart(){} + + public void onPhaseChange(TutorialPhase phase){} + + public void onEnd(){} + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index b140b79bc..57c4baad5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -18,6 +18,8 @@ public abstract class TutorialPhase private Location _target; private boolean _hasEnded; + private Thread _thread; + private long _started; private TutorialText _currentText; @@ -27,6 +29,9 @@ public abstract class TutorialPhase _text = text; } + /** + * start the Phase (never use this as well) + */ final public void start(boolean phaseOne) { _hasEnded = false; @@ -39,6 +44,9 @@ public abstract class TutorialPhase displayText(); } + /** + * Teleporting Players and keeping them if SetTutorialPositions == true + */ final public void teleport() { if(!getTutorial().SetTutorialPositions) @@ -51,6 +59,9 @@ public abstract class TutorialPhase } } + /** + * preparing Pitch/Yaw of the location + */ private void prepareLocations() { Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ()); @@ -60,6 +71,9 @@ public abstract class TutorialPhase _location.setYaw(yaw); } + /** + * teleporting players until Phase ends + */ private void updatePlayers() { new Thread(new Runnable() @@ -74,6 +88,7 @@ public abstract class TutorialPhase @Override public void run() { + // teleport Players Sync if(!_hasEnded && !getTutorial().hasEnded()) { for(Player player : _tutorial.getPlayers().keySet()) @@ -87,6 +102,7 @@ public abstract class TutorialPhase }); try { + // sleep for 1 tick Thread.sleep(50); } catch (InterruptedException e) { @@ -97,9 +113,13 @@ public abstract class TutorialPhase }).start(); } + /** + * displays all messages set in the constructor + * will end Phase if no more messages are available or Tutorial has already ended + */ public void displayText() { - new Thread(new Runnable() + _thread = new Thread(new Runnable() { @Override public void run() @@ -109,6 +129,7 @@ public abstract class TutorialPhase TutorialText text = getNextMessage(); if(text == null) { + // ending Phase _tutorial.Manager.runSyncLater(new Runnable() { @Override @@ -123,6 +144,7 @@ public abstract class TutorialPhase } else { + // displaying next message Player[] players = new Player[_tutorial.getPlayers().keySet().size()]; int i = 0; for(Player player : _tutorial.getPlayers().keySet()) @@ -137,7 +159,7 @@ public abstract class TutorialPhase } displayMessage(text); UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); - try + try { Thread.sleep(text.getStayTime() * 50); } catch (InterruptedException e) @@ -148,14 +170,18 @@ public abstract class TutorialPhase } } - }).start(); + }); + _thread.start(); } + /** + * firing abstract method Sync/Async depending on the RunTasksSync Flag + */ private void displayMessage(final TutorialText text) { if(_tutorial.RunTasksSync) { - _tutorial.Manager.runSync(new Runnable() + _tutorial.Manager.runSync(new Runnable() { @Override public void run() @@ -170,6 +196,9 @@ public abstract class TutorialPhase } } + /** + * getting next message + */ protected TutorialText getNextMessage() { for(TutorialText text : _text) @@ -193,6 +222,11 @@ public abstract class TutorialPhase return _text; } + public void setText(TutorialText[] text) + { + _text = text; + } + public Location getLocation() { return _location; @@ -228,6 +262,15 @@ public abstract class TutorialPhase return _started; } + public Thread getThread() + { + return _thread; + } + + /* + * some overrideable methods that can be used to synchronize the tutorial events + */ + public void onStart(){} public void onMessageDisplay(TutorialText text){} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index dba1d39a6..2711b10fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -59,4 +59,9 @@ public class TutorialText _text = text; } + public void setID(int id) + { + _id = id; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java index a5e801770..1b687bb71 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java @@ -4,10 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -57,7 +55,7 @@ public class SpectatorPage extends _buttons = new IButton[54]; _items = new ItemStack[54]; - List teamList = _arcadeManager.GetGame().GetTeamList(); + List teamList = new ArrayList(_arcadeManager.GetGame().GetTeamList()); int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); @@ -153,9 +151,8 @@ public class SpectatorPage extends int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0); - _buttons = Arrays.copyOf(_buttons, _buttons.length - + (rowsNeeded * 9)); - _items = Arrays.copyOf(_items, _items.length + (rowsNeeded * 9) + rowsNeeded); + _buttons = Arrays.copyOf(_buttons, _buttons.length + (rowsNeeded * 9)); + _items = Arrays.copyOf(_items, _items.length + (rowsNeeded * 9)); for (int row = 0; row < rowsNeeded; row++) { @@ -178,6 +175,9 @@ public class SpectatorPage extends if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26) { currentRow += 2; + + _buttons = Arrays.copyOf(_buttons, _buttons.length + 9); + _items = Arrays.copyOf(_items, _items.length + 9); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java index c190beadc..89ff68f52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java @@ -16,6 +16,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemStackFactory; @@ -48,10 +49,7 @@ public class PerkBaconBlast extends Perk implements IThrown if (UtilBlock.usable(event.getClickedBlock())) return; - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + if (!UtilGear.isAxe(event.getItem())) return; Player player = event.getPlayer(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java index f4e0aaf0f..b438a7440 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; -import org.bukkit.GameMode; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java index 4b01f97e5..163695218 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java @@ -11,7 +11,10 @@ import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; @@ -31,10 +34,10 @@ public class PerkPigCloak extends Perk { Player player = event.getPlayer(); - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) return; - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + if (!UtilGear.isAxe(event.getItem())) return; if (!Kit.HasKit(player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index ca7bb2df2..c3fd7777d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -19,34 +19,31 @@ import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.gadgets.morph.MorphWither; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.core.mount.Mount; import mineplex.core.mount.types.MountDragon; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.RestartServerEvent; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.uhc.UHC; -import nautilus.game.arcade.gametutorial.GameTutorial; import nautilus.game.arcade.gametutorial.TutorialPhase; import nautilus.game.arcade.gametutorial.TutorialText; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.FireworkEffect.Type; import org.bukkit.entity.Creature; import org.bukkit.entity.Player; -import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -220,9 +217,12 @@ public class GameManager implements Listener if(!team.getTutorial().hasStarted()) { team.getTutorial().setTeam(team); - team.getTutorial().start(); + team.getTutorial().start(); timeUsage = team.getTutorial().StartAfterTutorial; timeUsage = timeUsage + (team.getTutorial().TimeBetweenPhase * team.getTutorial().getPhases().length); + if(team.getTutorial().CustomEnding) + timeUsage = timeUsage + team.getTutorial().CustomEndingTime; + for(TutorialPhase phase : team.getTutorial().getPhases()) { for(TutorialText text : phase.getText()) @@ -237,9 +237,9 @@ public class GameManager implements Listener if(checkForTimer) { if(team.getTutorial().ShowPrepareTimer) - finished = false; - else finished = true; + else + finished = false; } } } @@ -251,7 +251,7 @@ public class GameManager implements Listener if(!finished) return true; - } + } return false; } @@ -290,6 +290,7 @@ public class GameManager implements Listener if(game.GetState() != GameState.Prepare) return; + if(game.EnableTutorials) { for(GameTeam team : game.GetTeamList()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java new file mode 100644 index 000000000..ce554376b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java @@ -0,0 +1,293 @@ +package nautilus.game.arcade.managers; + +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; + +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; +import nautilus.game.arcade.ArcadeManager; + +public class GameTestingManager implements Listener +{ + /** + * Created by: Mysticate + * Timestamp: November 25, 2015 + */ + + private ArcadeManager _manager; + + private boolean _enabled; + + private boolean _capped = false; + private int _cap = 16; + private String _capMessage = ""; + + private boolean _whitelisted = false; + private Set _whitelistAdded = new HashSet(); + private String _whitelistMessage = ""; + + public GameTestingManager(ArcadeManager manager) + { + _manager = manager; + + _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); + + _enabled = _manager.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + } + + public ArcadeManager getManager() + { + return _manager; + } + + public void setCapped(boolean cap) + { + _capped = cap; + } + + public boolean isCapped() + { + return _capped; + } + + public void setCap(int cap) + { + _cap = cap; + } + + public int getCap() + { + return _cap; + } + + public boolean isWhitelisted(String name) + { + return _whitelistAdded.contains(new String(name).toLowerCase()); + } + + public void setWhitelisted(String name, boolean whitelist) + { + if (isWhitelisted(name)) + { + _whitelistAdded.remove(name.toLowerCase()); + } + else + { + _whitelistAdded.add(new String(name).toLowerCase()); + } + } + + @EventHandler + public void onLogin(PlayerLoginEvent event) + { + if (!_enabled) + return; + + if (_capped) + { + if (UtilServer.getPlayers().length >= _cap) + { + if (!isWhitelisted(event.getPlayer().getName())) + { + event.disallow(Result.KICK_FULL, C.cGray + "That server has a set cap!\n" + + C.cGray + "Current players " + C.cYellow + UtilServer.getPlayers().length + "/" + _cap + "\n" + + C.cGreen + _capMessage); + } + return; + } + } + + if (_whitelisted) + { + if (!isWhitelisted(event.getPlayer().getName())) + { + event.disallow(Result.KICK_FULL, C.cGray + "That server has a testing whitelist!\n" + + C.cGray + "Current players " + C.cYellow + UtilServer.getPlayers().length + "/" + _cap + "\n" + + C.cGreen + _capMessage); + } + return; + } + } + + @EventHandler + public void onCommandTesting(PlayerCommandPreprocessEvent event) + { + if (!_enabled) + return; + + String[] args = event.getMessage().split(" "); + String cmd = args[0]; + + if (!cmd.equalsIgnoreCase("/testing")) + return; + + event.setCancelled(true); + + if (!_manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.JNR_DEV, true)) + return; + + if (args.length == 1) // Help + { + sendGlobalHelp(event.getPlayer()); + return; + } + else if (args[1].equalsIgnoreCase("cap")) + { + if (args.length == 2) + { + sendCapHelp(event.getPlayer()); + return; + } + + if (args.length == 3) // No cap arguments + { + if (args[2].equalsIgnoreCase("toggle")) + { + _capped = !_capped; + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap enabled " + F.tf(_capped) + ".")); + return; + } + + try + { + _cap = Integer.valueOf(args[2]); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap set to " + F.elem("" + _cap) + ".")); + } + catch (Exception ex) + { + sendCapHelp(event.getPlayer()); + } + return; + } + + if (args.length >= 4) + { + if (args[2].equalsIgnoreCase("message")) + { + String message = ""; + for (int i = 3 ; i < args.length ; i++) + message += (args[i] + " "); + + _capMessage = message.trim(); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap message set to " + F.elem(_capMessage) + ".")); + return; + } + + sendCapHelp(event.getPlayer()); + return; + } + + sendCapHelp(event.getPlayer()); + return; + } + else if (args[1].equalsIgnoreCase("whitelist")) + { + if (args.length == 2) + { + sendWhitelistHelp(event.getPlayer()); + return; + } + + if (args.length == 3) // No cap arguments + { + if (args[2].equalsIgnoreCase("toggle")) + { + _whitelisted = !_whitelisted; + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing whitelist enabled " + F.tf(_whitelisted) + ".")); + return; + } + + sendWhitelistHelp(event.getPlayer()); + return; + } + + if (args.length == 4) + { + if (args[2].equalsIgnoreCase("add")) + { + String playerName = args[3]; + + if (isWhitelisted(playerName)) + { + UtilPlayer.message(event.getPlayer(), F.main("Testing", "That player is already whitelisted!")); + } + else + { + setWhitelisted(playerName, true); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "You have whitelisted " + F.name(playerName) + ".")); + } + return; + } + else if (args[2].equalsIgnoreCase("remove")) + { + String playerName = args[3]; + + if (!isWhitelisted(playerName)) + { + UtilPlayer.message(event.getPlayer(), F.main("Testing", "That player is not whitelisted!")); + } + else + { + setWhitelisted(playerName, false); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "You have removed " + F.name(playerName) + " from the whitelist.")); + } + return; + } + } + + if (args.length >= 4) + { + if (args[2].equalsIgnoreCase("message")) + { + String message = ""; + for (int i = 3 ; i < args.length ; i++) + message += (args[i] + " "); + + _whitelistMessage = message.trim(); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing whitelist message set to " + F.elem(_whitelistMessage) + ".")); + return; + } + + sendWhitelistHelp(event.getPlayer()); + return; + } + + sendWhitelistHelp(event.getPlayer()); + return; + } + } + + private void sendGlobalHelp(Player player) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, F.main("Testing", "/testing cap")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist")); + } + + private void sendCapHelp(Player player) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, F.main("Testing", "/testing cap toggle")); + UtilPlayer.message(player, F.main("Testing", "/testing cap ")); + UtilPlayer.message(player, F.main("Testing", "/testing cap message ")); + } + + private void sendWhitelistHelp(Player player) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist toggle")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist add ")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist remove ")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist message ")); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java index 0ace10a33..3585b3586 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java @@ -15,7 +15,7 @@ public class TitanGiveawayRepository extends RepositoryBase public TitanGiveawayRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _titanGiveawayCount = 0; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java index 7b5021ae5..73ebfaf00 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java @@ -1,6 +1,29 @@ package nautilus.game.arcade.player; -public class ArcadePlayer -{ +import org.bukkit.entity.Player; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.customdata.MineplexPlayer; +import nautilus.game.arcade.ArcadeManager; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class ArcadePlayer extends MineplexPlayer +{ + private ArcadeManager _arcadeManager; + + public ArcadePlayer(Player player, CustomDataManager customDataManager, ArcadeManager arcadeManager) + { + super(player, customDataManager); + + _arcadeManager = arcadeManager; + } + + @Override + public String getKeyPrefix() + { + return "arcade." + _arcadeManager.GetGame().GetName().toLowerCase().replaceAll(" ", ".") + "."; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java deleted file mode 100644 index d1df0b6f5..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java +++ /dev/null @@ -1,63 +0,0 @@ -package nautilus.game.arcade.stats; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import mineplex.core.common.util.UtilPlayer; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.TeamGame; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -public class LastStandStatTracker extends StatTracker -{ - private final Map _kills = new HashMap<>(); - - public LastStandStatTracker(TeamGame game) - { - super(game); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onCombatDeath(CombatDeathEvent event) - { - if (getGame().GetState() != Game.GameState.Live) - return; - - if (event.GetLog().GetKiller() == null) - return; - - if (!event.GetLog().GetKiller().IsPlayer()) - return; - - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (killer == null) - return; - - if (event.GetLog().GetPlayer() == null) - return; - - if (!event.GetLog().GetPlayer().IsPlayer()) - return; - - Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); - if (player == null) - return; - - if (getGame().GetTeam(killer).GetPlayers(true).size() == 1) - { - Integer kills = _kills.get(killer.getUniqueId()); - - kills = (kills == null ? 0 : kills) + 1; - - _kills.put(killer.getUniqueId(), kills); - - if (kills >= 3) - addStat(killer, "LastStand", 1, true, false); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java deleted file mode 100644 index 7b3e65e02..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java +++ /dev/null @@ -1,24 +0,0 @@ -package nautilus.game.arcade.stats; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.paintball.Paintball; - -public class MedicStatTracker extends StatTracker -{ - public MedicStatTracker(Game game) - { - super(game); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onCombatDeath(Paintball.ReviveEvent event) - { - if (getGame().GetState() != Game.GameState.Live) - return; - - addStat(event.getPlayer(), "Medic", 1, false, false); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index 74242f538..798c40179 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -544,6 +544,11 @@ public class WorldData { return CustomLocs; } + + public HashMap> GetAllDataLocs() + { + return DataLocs; + } public Location GetRandomXZ() {