diff --git a/.gitignore b/.gitignore index 626bd858f..c1fc8b034 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,14 @@ zBench zMyst zSotanna zSotanna2 +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdt +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdx +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fnm +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.frq +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.nrm +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.prx +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tii +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tis +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments.gen +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1 +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock diff --git a/Art/Carl.png b/Art/Carl.png new file mode 100644 index 000000000..5d4fe6d36 Binary files /dev/null and b/Art/Carl.png differ diff --git a/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml b/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml index 150c21bc3..370ba8bd7 100644 --- a/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml +++ b/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml @@ -20,6 +20,7 @@ + \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml b/Plugins/.idea/artifacts/Mineplex_Hub_test.xml index d164c4c6a..0527ee7d4 100644 --- a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml +++ b/Plugins/.idea/artifacts/Mineplex_Hub_test.xml @@ -1,5 +1,5 @@ - + $PROJECT_DIR$/../Testing/Hub/plugins diff --git a/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml b/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml new file mode 100644 index 000000000..372114469 --- /dev/null +++ b/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml @@ -0,0 +1,24 @@ + + + $PROJECT_DIR$/out/artifacts/ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index bd35e0f52..37717d4dc 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -4,6 +4,7 @@ diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index 4c3d6b432..3359861d8 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -86,6 +86,9 @@ + + + @@ -152,6 +155,9 @@ + + + @@ -198,6 +204,9 @@ + + + @@ -234,6 +243,9 @@ + + + @@ -440,6 +452,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/Libraries/BungeeCord.jar b/Plugins/Libraries/BungeeCord.jar index a408f8656..45383e430 100644 Binary files a/Plugins/Libraries/BungeeCord.jar and b/Plugins/Libraries/BungeeCord.jar differ 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 fa7f5c43c..75cf934cf 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -1,5 +1,6 @@ package mineplex.bungee.motd; +import java.awt.Color; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -7,9 +8,13 @@ import java.util.Random; import java.util.concurrent.TimeUnit; import mineplex.serverdata.Region; +import mineplex.serverdata.data.BungeeServer; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ConnectionData; import mineplex.serverdata.servers.ServerManager; +import mineplex.serverdata.servers.ConnectionData.ConnectionType; +import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.event.ProxyPingEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; @@ -20,7 +25,9 @@ public class MotdManager implements Listener, Runnable private Plugin _plugin; private DataRepository _repository; - + private DataRepository _secondRepository; + private Region _region; + private Random _random = new Random(); private String _firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r"; private List _motdLines; @@ -28,6 +35,7 @@ public class MotdManager implements Listener, Runnable public MotdManager(Plugin plugin) { _plugin = plugin; + _region = !new File("eu.dat").exists() ? Region.US : Region.EU; _plugin.getProxy().getScheduler().schedule(_plugin, this, 5L, 30L, TimeUnit.SECONDS); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); @@ -38,12 +46,21 @@ public class MotdManager implements Listener, Runnable if (new File("updateMOTD.dat").exists()) { - List lines = new ArrayList(); - lines.add(" §f§l◄ §6§lNEW §f§l▬ §c§lSSM/SG/SW Teams§f§l ▬ §c§lMPS Update §f§l►"); - //lines.add(" §d§lRank Sale §a§l40% Off"); - //lines.add(" §f§l◄§c§lMAINTENANCE§f§l►"); + if (_region == Region.US) + _secondRepository = new RedisDataRepository(new ConnectionData("10.81.1.156", 6379, ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.81.1.156", 6377, ConnectionType.SLAVE, "ServerStatus"), + Region.ALL, GlobalMotd.class, "globalMotd"); + else + _secondRepository = new RedisDataRepository(new ConnectionData("10.33.53.16", 6379, ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.33.53.16", 6377, ConnectionType.SLAVE, "ServerStatus"), + Region.ALL, GlobalMotd.class, "globalMotd"); - updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines); + //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; + //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; + String motdLine = " §b§l◄§f§lNEW GAME§b§l► §f§l◄§b§lEVOLUTION§f§l► §b§l◄§f§lNEW GAME§b§l►"; + //String motdLine = " §f§l◄ §a§lCarl the Creeper§f§l ▬ §c§l75% OFF SALE§f§l ►"; + //String motdLine = " §d§lRank Sale §a§l40% Off"); + //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); + + updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", motdLine); System.out.println("Updated Bungee MOTD"); } } @@ -68,7 +85,7 @@ public class MotdManager implements Listener, Runnable GlobalMotd motd = _repository.getElement("MainMotd"); if (motd != null) - { + { _motdLines = motd.getMotd(); _firstLine = motd.getHeadline(); } @@ -78,9 +95,14 @@ public class MotdManager implements Listener, Runnable * Update the main {@link GlobalMotd} determining the MOTD for Bungee instances. * @param motdLines - the lines to update the MOTD to. */ - public void updateMainMotd(String headline, List motdLines) + public void updateMainMotd(String headline, String motdLine) { + List motdLines = new ArrayList(); + + motdLines.add(motdLine); + _repository.addElement(new GlobalMotd("MainMotd", headline, motdLines)); + _secondRepository.addElement(new GlobalMotd("MainMotd", headline, motdLines)); } public List getMotdLines() diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java index 63bab7330..fcae65a57 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java @@ -1,6 +1,5 @@ package mineplex.bungee.playerStats; -import java.util.HashMap; import java.util.HashSet; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -17,9 +16,8 @@ import net.md_5.bungee.event.EventHandler; public class PlayerStats implements Listener, Runnable { private Plugin _plugin; - private PlayerStatsRepository _repository; + private PlayerStatsRepository _repository; - private PlayerCache _playerCache = new PlayerCache(); private HashSet _retrievingPlayerInfo = new HashSet(); public PlayerStats(Plugin plugin) @@ -52,7 +50,7 @@ public class PlayerStats implements Listener, Runnable boolean addOrUpdatePlayer = false; - playerInfo = _playerCache.getPlayer(uuid); + playerInfo = PlayerCache.getInstance().getPlayer(uuid); if (playerInfo == null) { @@ -80,11 +78,11 @@ public class PlayerStats implements Listener, Runnable } else playerInfo = updatedPlayerInfo; - - _playerCache.addPlayer(playerInfo); } playerInfo.setSessionId(_repository.updatePlayerStats(playerInfo.getId(), ipInfo.id)); + playerInfo.updateLoginTime(); + PlayerCache.getInstance().addPlayer(playerInfo); } finally { @@ -105,13 +103,13 @@ public class PlayerStats implements Listener, Runnable PlayerInfo playerInfo = null; - playerInfo = _playerCache.getPlayer(uuid); + playerInfo = PlayerCache.getInstance().getPlayer(uuid); int timeout = 5; while (playerInfo == null && _retrievingPlayerInfo.contains(uuid) && timeout <= 5) { - playerInfo = _playerCache.getPlayer(uuid); + playerInfo = PlayerCache.getInstance().getPlayer(uuid); if (playerInfo != null) break; @@ -130,6 +128,7 @@ public class PlayerStats implements Listener, Runnable timeout++; } + System.out.println(playerInfo.getName() + ":" + playerInfo.getSessionId()); _repository.updatePlayerSession(playerInfo.getSessionId()); } }); @@ -138,6 +137,6 @@ public class PlayerStats implements Listener, Runnable @Override public void run() { - _playerCache.clean(); + PlayerCache.getInstance().clean(); } } diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java new file mode 100644 index 000000000..8e56dab88 --- /dev/null +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java @@ -0,0 +1,27 @@ +package mineplex.bungee.playerTracker; + +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.PlayerJoinCommand; +import mineplex.serverdata.commands.ServerCommand; + +public class PlayerJoinHandler implements CommandCallback +{ + private PlayerTracker _playerTracker; + + public PlayerJoinHandler(PlayerTracker playerTracker) + { + _playerTracker = playerTracker; + } + + @SuppressWarnings("deprecation") + @Override + public void run(ServerCommand command) + { + if (command instanceof PlayerJoinCommand) + { + PlayerJoinCommand joinCommand = (PlayerJoinCommand)command; + + _playerTracker.kickPlayerIfOnline(joinCommand.getUuid()); + } + } +} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java index 24e40892c..707dc3eb8 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java @@ -1,19 +1,25 @@ package mineplex.bungee.playerTracker; import java.io.File; +import java.util.HashSet; +import java.util.UUID; +import java.util.concurrent.TimeUnit; import mineplex.serverdata.Region; +import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.data.PlayerStatus; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; +import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; +import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; -public class PlayerTracker implements Listener +public class PlayerTracker implements Listener, Runnable { // Default period before status expiry (8 hours) private static final int DEFAULT_STATUS_TIMEOUT = 60 * 60 * 8; @@ -21,6 +27,8 @@ public class PlayerTracker implements Listener // Repository storing player status' across network. private DataRepository _repository; + private HashSet _onlineUUIDs = new HashSet(); + private Plugin _plugin; public PlayerTracker(Plugin plugin) @@ -28,11 +36,14 @@ public class PlayerTracker implements Listener _plugin = plugin; _plugin.getProxy().getPluginManager().registerListener(_plugin, this); + _plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES); Region region = !new File("eu.dat").exists() ? Region.US : Region.EU; _repository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), region, PlayerStatus.class, "playerStatus"); + ServerCommandManager.getInstance().registerCommandType("PlayerJoinCommand", mineplex.serverdata.commands.PlayerJoinCommand.class, new PlayerJoinHandler(this)); + System.out.println("Initialized PlayerTracker."); } @@ -56,8 +67,45 @@ public class PlayerTracker implements Listener { public void run() { - _repository.removeElement(event.getPlayer().getName()); + _repository.removeElement(event.getPlayer().getName().toLowerCase()); } }); + + _onlineUUIDs.remove(event.getPlayer().getUniqueId()); + } + + @EventHandler + public void playerConnect(final PostLoginEvent event) + { + _onlineUUIDs.add(event.getPlayer().getUniqueId().toString()); + } + + @Override + public void run() + { + HashSet onlineUUIDs = new HashSet(); + + for (ProxiedPlayer player : _plugin.getProxy().getPlayers()) + { + onlineUUIDs.add(player.getUniqueId().toString()); + } + + _onlineUUIDs = onlineUUIDs; + } + + public boolean isPlayerOnline(String uuid) + { + return _onlineUUIDs.contains(uuid); + } + + public void kickPlayerIfOnline(String uuid) + { + if (_onlineUUIDs.contains(uuid)) + { + ProxiedPlayer player = _plugin.getProxy().getPlayer(UUID.fromString(uuid)); + + if (player != null) + player.disconnect("You have logged in from another location."); + } } } diff --git a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/ServerMonitor.launch b/Plugins/Mineplex.ChestConverter/.externalToolBuilders/ServerMonitor.launch index 0c6e0f696..d07871b9a 100644 --- a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/ServerMonitor.launch +++ b/Plugins/Mineplex.ChestConverter/.externalToolBuilders/ServerMonitor.launch @@ -10,6 +10,7 @@ + diff --git a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java index 5d7c5d23e..f1fd646d0 100644 --- a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java +++ b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java @@ -1,11 +1,20 @@ package mineplex.chestConverter; import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Map.Entry; import java.util.logging.FileHandler; import java.util.logging.Formatter; import java.util.logging.LogRecord; @@ -18,8 +27,23 @@ public class ChestConverter private static Logger _logger = Logger.getLogger("Converter"); + private static String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Account?allowMultiQueries=true"; + private static String _userName = "MilitaryPolice"; + private static String _password = "CUPr6Wuw2Rus$qap"; + + private static Connection _connection; + public static void main (String args[]) { + try + { + Class.forName("com.mysql.jdbc.Driver"); + } + catch (ClassNotFoundException e1) + { + e1.printStackTrace(); + } + try { FileHandler fileHandler = new FileHandler("converter.log", true); @@ -38,72 +62,138 @@ public class ChestConverter { e1.printStackTrace(); } - - _repository = new ChestConverterRepository(); - int lastId = 18279475; - int count = 50000; - int numOfRowsProcessed = lastId; - HashMap tasks = _repository.getTaskList(); + int limit = 50000; + HashSet accountStats = new HashSet(); - try + while (true) { - while (true) + accountStats.clear(); + + try { - long time = System.currentTimeMillis(); - HashMap> playerMap = new HashMap>(); + Statement statement = null; - - List taskList = _repository.getTasks(lastId, count); - - if (taskList != null && taskList.size() > 0) + try { - for (AccountTask task : taskList) + if (_connection == null || _connection.isClosed()) + _connection = DriverManager.getConnection(_connectionString, _userName, _password); + + statement = _connection.createStatement(); + + statement.execute("SELECT accountId, statId, value FROM Account.accountStats LIMIT " + limit + ";"); + + ResultSet resultSet = statement.getResultSet(); + + while (resultSet.next()) { - if (!playerMap.containsKey(task.UUID)) - playerMap.put(task.UUID, new ArrayList()); + accountStats.add(new AccountStat(resultSet.getInt(1), resultSet.getInt(2), resultSet.getInt(3))); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + if (statement != null) + { + try + { + statement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + + if (accountStats.size() == 0) + { + System.out.println("No accounts."); + return; + } + + PreparedStatement updateStatement = null; + PreparedStatement insertStatement = null; + Statement deleteStatement = null; + + try + { + if (_connection == null || _connection.isClosed()) + _connection = DriverManager.getConnection(_connectionString, _userName, _password); + + _connection.setAutoCommit(true); + updateStatement = _connection.prepareStatement("UPDATE accountStat SET value = value + ? WHERE accountId = ? AND statId = ? AND value < ?;"); + + for (AccountStat stat : accountStats) + { + updateStatement.setLong(1, stat.value); + updateStatement.setInt(2, stat.accountId); + updateStatement.setInt(3, stat.statId); + updateStatement.setLong(4, stat.value); - playerMap.get(task.UUID).add(tasks.get(task.Task)); - - if (task.Id > lastId) - lastId = task.Id; + updateStatement.addBatch(); } - _repository.incrementClients(playerMap); - try + int[] rowsAffected = updateStatement.executeBatch(); + _connection.setAutoCommit(false); + int i = 0; + int count = 0; + + log("Updated rows - " + limit); + + insertStatement = _connection.prepareStatement("INSERT IGNORE accountStat(accountId, statId, value) VALUES (?, ?, ?);"); + + for (AccountStat stat : accountStats) { - numOfRowsProcessed += count; - log("Natural sleep. " + count + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + numOfRowsProcessed); - Thread.sleep(100); - } - catch (InterruptedException e) + if (rowsAffected[i] < 1) + { + insertStatement.setInt(1, stat.accountId); + insertStatement.setInt(2, stat.statId); + insertStatement.setLong(3, stat.value); + + insertStatement.addBatch(); + count++; + } + + i++; + } + + insertStatement.executeBatch(); + log("Inserted rows - " + count); + + deleteStatement = _connection.createStatement(); + deleteStatement.executeUpdate("DELETE FROM accountStats LIMIT " + limit + ";"); + + _connection.commit(); + + log("Deleted rows - " + limit); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + if (statement != null) { - e.printStackTrace(); + try + { + statement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } } } - else if (numOfRowsProcessed > 17000000) - { - System.out.println("Count : " + numOfRowsProcessed); - _logger.info("Count : " + numOfRowsProcessed); - break; - } - else - { - System.out.println("No greater than 17 mil"); - _logger.info("No greater than 17 mil"); - System.out.println("Count : " + numOfRowsProcessed); - _logger.info("Count : " + numOfRowsProcessed); - } } - } - catch (Exception e) - { - _logger.info(e.getMessage()); - } - finally - { - System.out.println("Count : " + numOfRowsProcessed); - _logger.info("Count : " + numOfRowsProcessed); + catch (Exception e) + { + _logger.info(e.getMessage()); + } } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 74e648808..8cab61a15 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilPlayer; public enum Rank { + //Staff LT("LT", ChatColor.DARK_RED), OWNER("Owner", ChatColor.DARK_RED), DEVELOPER("Dev", ChatColor.RED), @@ -21,36 +22,48 @@ public enum Rank MEDIA("Media", ChatColor.BLUE), EVENT("Event", ChatColor.WHITE), - - //Staff ^^ - + + //Media YOUTUBE("YouTube", ChatColor.RED), + YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE), TWITCH("Twitch", ChatColor.DARK_PURPLE), - LEGEND("Legend", ChatColor.GREEN), - HERO("Hero", ChatColor.LIGHT_PURPLE), - ULTRA("Ultra", ChatColor.AQUA), + + //Player + LEGEND("Legend", ChatColor.GREEN, true), + HERO("Hero", ChatColor.LIGHT_PURPLE, true), + ULTRA("Ultra", ChatColor.AQUA, true), ALL("", ChatColor.WHITE); - private ChatColor Color; + private ChatColor _color; + private boolean _donor; + public String Name; Rank(String name, ChatColor color) { - Color = color; + _color = color; Name = name; + _donor = false; } - public boolean Has(Rank rank) + Rank(String name, ChatColor color, boolean donor) { - return Has(null, rank, false); + _color = color; + Name = name; + _donor = donor; } - public boolean Has(Player player, Rank rank, boolean inform) + public boolean has(Rank rank) { - return Has(player, rank, null, inform); + return has(null, rank, false); } - public boolean Has(Player player, Rank rank, Rank[] specific, boolean inform) + public boolean has(Player player, Rank rank, boolean inform) + { + return has(player, rank, null, inform); + } + + public boolean has(Player player, Rank rank, Rank[] specific, boolean inform) { //Specific Rank if (specific != null) @@ -79,7 +92,7 @@ public enum Rank return false; } - public String GetTag(boolean bold, boolean uppercase) + public String getTag(boolean bold, boolean uppercase) { if (Name.equalsIgnoreCase("ALL")) return ""; @@ -88,12 +101,17 @@ public enum Rank if (uppercase) name = Name.toUpperCase(); - if (bold) return Color + C.Bold + name; - else return Color + name; + if (bold) return _color + C.Bold + name; + else return _color + name; } - public ChatColor GetColor() + public ChatColor getColor() { - return Color; + return _color; + } + + public boolean isDonor() + { + return _donor; } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/structs/ItemContainer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/structs/ItemContainer.java new file mode 100644 index 000000000..64871529b --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/structs/ItemContainer.java @@ -0,0 +1,24 @@ +package mineplex.core.common.structs; + +import org.bukkit.Material; + +public class ItemContainer +{ + public Material Type; + public byte Data; + public String Name; + + public ItemContainer(Material type, byte data, String name) + { + Type = type; + Data = data; + Name = name; + } + + public ItemContainer(int id, byte data, String name) + { + Type = Material.getMaterial(id); + Data = data; + Name = name; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index a387ba46a..db1e528f3 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -95,15 +95,15 @@ public class F public static String help(String cmd, String body, Rank rank) { - return rank.GetColor() + cmd + " " + C.mBody + body + " " + rank(rank); + return rank.getColor() + cmd + " " + C.mBody + body + " " + rank(rank); } public static String rank(Rank rank) { if (rank == Rank.ALL) - return rank.GetColor() + "Player"; + return rank.getColor() + "Player"; - return rank.GetTag(false, false); + return rank.getTag(false, false); } public static String value(String variable, String value) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java index b327bf32e..73ae33c86 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java @@ -69,6 +69,11 @@ public class MapUtil { QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo); } + + public static void QuickChangeBlockAt(Location location, Material setTo, byte data) + { + QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo, data); + } public static void QuickChangeBlockAt(Location location, int id, byte data) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 56a9b917e..807dbccb5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -5,10 +5,8 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; - - - import org.bukkit.Location; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -251,6 +249,25 @@ public class UtilAlg return bestLoc; } + public static Location findFurthest(Location mid, ArrayList locs) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double dist = UtilMath.offset(mid, loc); + + if (bestLoc == null || dist > bestDist) + { + bestLoc = loc; + bestDist = dist; + } + } + + return bestLoc; + } + public static boolean isInPyramid(Vector a, Vector b, double angleLimit) { return (Math.abs(GetPitch(a) - GetPitch(b)) < angleLimit) && (Math.abs(GetYaw(a) - GetYaw(b)) < angleLimit); @@ -298,6 +315,42 @@ public class UtilAlg return bestLoc; } + public static Location getLocationAwayFromOtherLocations(ArrayList locs, ArrayList players) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double closest = -1; + + for (Location player : players) + { + //Different Worlds + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player, loc); + + if (closest == -1 || dist < closest) + { + closest = dist; + } + } + + if (closest == -1) + continue; + + if (bestLoc == null || closest > bestDist) + { + bestLoc = loc; + bestDist = closest; + } + } + + return bestLoc; + } + public static Location getLocationNearPlayers(ArrayList locs, ArrayList players, ArrayList dontOverlap) { Location bestLoc = null; @@ -353,4 +406,21 @@ public class UtilAlg return bestLoc; } + + public static Location getNearestCornerLocation(Location near, Block block) + { + ArrayList corners = new ArrayList(); + + corners.add(block.getLocation().clone()); + corners.add(block.getLocation().clone().add(.999, 0, 0)); + corners.add(block.getLocation().clone().add(.999, 0, .999)); + corners.add(block.getLocation().clone().add(0, 0, .999)); + + corners.add(block.getLocation().clone().add(0, .999, 0)); + corners.add(block.getLocation().clone().add(.999, .999, 0)); + corners.add(block.getLocation().clone().add(.999, .999, .999)); + corners.add(block.getLocation().clone().add(0, .999, .999)); + + return UtilAlg.findClosest(near, corners); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index d87d16fa5..1cc2d5416 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -4,26 +4,32 @@ import java.lang.reflect.Field; import java.util.HashMap; import java.util.LinkedList; import java.util.List; + +import net.minecraft.server.v1_7_R4.AxisAlignedBB; import net.minecraft.server.v1_7_R4.EntityBat; import net.minecraft.server.v1_7_R4.EntityCreature; import net.minecraft.server.v1_7_R4.EntityEnderDragon; import net.minecraft.server.v1_7_R4.EntityHuman; import net.minecraft.server.v1_7_R4.EntityInsentient; import net.minecraft.server.v1_7_R4.EntityLiving; +import net.minecraft.server.v1_7_R4.EntityTrackerEntry; import net.minecraft.server.v1_7_R4.Navigation; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityHeadRotation; import net.minecraft.server.v1_7_R4.PathfinderGoal; import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer; import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction; import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_7_R4.PathfinderGoalSelector; +import net.minecraft.server.v1_7_R4.WorldServer; import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; -import org.bukkit.block.BlockFace; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; import org.bukkit.entity.Creature; @@ -32,8 +38,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Giant; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.util.Vector; public class UtilEnt { @@ -491,10 +496,14 @@ public class UtilEnt public static boolean isGrounded(Entity ent) { - if (ent instanceof CraftEntity) - return ((CraftEntity)ent).getHandle().onGround; - - return UtilBlock.solid(ent.getLocation().getBlock().getRelative(BlockFace.DOWN)); + AxisAlignedBB box = ((CraftEntity)ent).getHandle().boundingBox; + Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c); + Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f); + + for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){ + if(UtilBlock.solid(b)) return true; + } + return false; } public static void PlayDamageSound(LivingEntity damagee) @@ -582,6 +591,36 @@ public class UtilEnt return false; } + public static boolean CreatureLook(Entity ent, Entity target) + { + return CreatureLook(ent, target instanceof LivingEntity ? ((LivingEntity) target).getEyeLocation() : target.getLocation()); + } + + public static boolean CreatureLook(Entity ent, Location target) + { + Vector vec = UtilAlg.getTrajectory(ent.getLocation(), target); + + return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); + } + + public static boolean CreatureLook(Entity ent, float pitch, float yaw) + { + if (!(ent instanceof LivingEntity)) + return false; + + EntityLiving ec = ((CraftLivingEntity) ent).getHandle(); + Location loc = ent.getLocation(); + + ec.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), yaw, pitch); + ec.al = true; + + EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.world).tracker.trackedEntities.get(ec.getId()); + + entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, (byte) (ec.yaw * 256.0F / 360.0F))); + + return true; + } + public static void CreatureMove(Entity ent, Location target, float speed) { if (!(ent instanceof Creature)) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java index 7b9a8479f..c07b7b3b4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java @@ -1,5 +1,7 @@ package mineplex.core.common.util; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; + import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; @@ -8,6 +10,7 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework; import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.util.Vector; @@ -68,5 +71,29 @@ public class UtilFirework public static void playFirework(Location loc, Type type, Color color, boolean flicker, boolean trail) { playFirework(loc, FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build()); + } + + public static void packetPlayFirework(Player player, Location loc, Type type, Color color, boolean flicker, boolean trail) + { + Firework firework = (Firework) loc.getWorld().spawn(loc, Firework.class); + FireworkEffect effect = FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build(); + + FireworkMeta data = (FireworkMeta) firework.getFireworkMeta(); + data.clearEffects(); + data.setPower(1); + data.addEffect(effect); + firework.setFireworkMeta(data); + + ((CraftFirework) firework).getHandle().expectedLifespan = 1; + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(firework.getEntityId()); + + for (Player viewing : UtilServer.getPlayers()) + { + if (player == viewing) + continue; + + UtilPlayer.sendPacket(viewing, packet); + } } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index cdd967e05..1c874c58b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -4,22 +4,24 @@ import java.util.AbstractMap; import java.util.LinkedList; import java.util.Map.Entry; +import mineplex.core.common.structs.ItemContainer; + import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class UtilItem { - public static LinkedList> matchItem(Player caller, String items, boolean inform) + public static LinkedList matchItem(Player caller, String items, boolean inform) { - LinkedList> matchList = new LinkedList>(); + LinkedList matchList = new LinkedList(); String failList = ""; //Mass Search for (String cur : items.split(",")) { - Entry match = searchItem(caller, cur, inform); + ItemContainer match = searchItem(caller, cur, inform); if (match != null) matchList.add(match); @@ -40,21 +42,27 @@ public class UtilItem return matchList; } - public static Entry searchItem(Player caller, String args, boolean inform) + public static ItemContainer searchItem(Player caller, String args, boolean inform) { - LinkedList> matchList = new LinkedList>(); + LinkedList matchList = new LinkedList(); for (Material cur : Material.values()) { + String[] arg = args.split(":"); + + //Get Selected Name + String name = null; + if (arg.length > 2) + name = arg[2].replaceAll("_", " "); + //By Name if (cur.toString().equalsIgnoreCase(args)) - return new AbstractMap.SimpleEntry(cur, (byte)0); + return new ItemContainer(cur, (byte)0, name); if (cur.toString().toLowerCase().contains(args.toLowerCase())) - matchList.add(new AbstractMap.SimpleEntry(cur, (byte)0)); + matchList.add(new ItemContainer(cur, (byte)0, name)); - //By ID:Data - String[] arg = args.split(":"); + //By ID:Data:Name //ID int id = 0; @@ -82,8 +90,8 @@ public class UtilItem { continue; } - - return new AbstractMap.SimpleEntry(cur, data); + + return new ItemContainer(cur, data, name); } //No / Non-Unique @@ -102,8 +110,9 @@ public class UtilItem if (matchList.size() > 0) { String matchString = ""; - for (Entry cur : matchList) - matchString += F.elem(cur.getKey().toString()) + ", "; + for (ItemContainer cur : matchList) + matchString += F.elem(cur.Type.toString()) + ", "; + if (matchString.length() > 1) matchString = matchString.substring(0 , matchString.length() - 2); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index c3513308c..72ce23304 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -85,5 +85,11 @@ public class UtilMath return Math.random() * d; } + + public static T randomElement(T[] array) { + if (array.length == 0) + return null; + return array[random.nextInt(array.length)]; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 322a55134..321f16789 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -6,20 +6,23 @@ import java.util.LinkedList; import java.util.List; import java.util.UUID; +import net.minecraft.server.v1_7_R4.EntityPlayer; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PlayerConnection; + import org.bukkit.ChatColor; -import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; import org.bukkit.util.Vector; -import net.minecraft.server.v1_7_R4.Packet; -import net.minecraft.server.v1_7_R4.PlayerConnection; - public class UtilPlayer { private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max) @@ -608,7 +611,19 @@ public class UtilPlayer return ((CraftPlayer) player).getHandle().spectating; return false; } - + + public static InventoryView swapToInventory(Player player, Inventory inv) { + + EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + if (nmsPlayer.activeContainer != nmsPlayer.defaultContainer) + { + // Do this so that other inventories know their time is over. + CraftEventFactory.handleInventoryCloseEvent(nmsPlayer); + nmsPlayer.m(); + } + return player.openInventory(inv); + } + /* public void setListName(Player player, CoreClient client) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java index 14925bf49..9b6044b4e 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java @@ -6,23 +6,23 @@ public class UtilSkull { public static byte getSkullData(Entity entity) { - if (entity instanceof Skeleton) - { - Skeleton sk = ((Skeleton) entity); - if (sk.getSkeletonType() == Skeleton.SkeletonType.WITHER) - return 1; - else return 0; - } - else if (entity instanceof Zombie || entity instanceof Giant) - { + if (entity == null) + return 0; + + return getSkullData(entity.getType()); + } + + public static byte getSkullData(EntityType type) + { + if (type == EntityType.SKELETON) + return 0; + if (type == EntityType.WITHER) + return 1; + if (type == EntityType.ZOMBIE || type == EntityType.GIANT) return 2; - } - else if (entity instanceof Creeper) - { + if (type == EntityType.CREEPER) return 4; - } - else - return 3; + return 3; } public static boolean isPlayerHead(byte data) @@ -31,52 +31,54 @@ public class UtilSkull } public static String getPlayerHeadName(Entity entity) + { + return getPlayerHeadName(entity.getType()); + } + + public static String getPlayerHeadName(EntityType entity) { String name = "MHF_Alex"; // order is important for some of these - if (entity instanceof Blaze) + if (entity == EntityType.BLAZE) name = "MHF_Blaze"; - else if (entity instanceof CaveSpider) + else if (entity == EntityType.CAVE_SPIDER) name = "MHF_CaveSpider"; - else if (entity instanceof Spider) + else if (entity == EntityType.SPIDER) name = "MHF_Spider"; - else if (entity instanceof Chicken) + else if (entity == EntityType.CHICKEN) name = "MHF_Chicken"; - else if (entity instanceof MushroomCow) + else if (entity == EntityType.MUSHROOM_COW) name = "MHF_MushroomCow"; - else if (entity instanceof Cow) + else if (entity == EntityType.COW) name = "MHF_Cow"; - else if (entity instanceof Creeper) + else if (entity == EntityType.CREEPER) name = "MHF_Creeper"; - else if (entity instanceof Enderman) + else if (entity == EntityType.ENDERMAN) name = "MHF_Enderman"; - else if (entity instanceof Ghast) + else if (entity == EntityType.GHAST) name = "MHF_Ghast"; - else if (entity instanceof Golem) + else if (entity == EntityType.IRON_GOLEM) name = "MHF_Golem"; - else if (entity instanceof PigZombie) + else if (entity == EntityType.PIG_ZOMBIE) name = "MHF_PigZombie"; - else if (entity instanceof MagmaCube) + else if (entity == EntityType.MAGMA_CUBE) name = "MHF_LavaSlime"; - else if (entity instanceof Slime) + else if (entity == EntityType.SLIME) name = "MHF_Slime"; - else if (entity instanceof Ocelot) + else if (entity == EntityType.OCELOT) name = "MHF_Ocelot"; - else if (entity instanceof PigZombie) - name = "MHF_PigZombie"; - else if (entity instanceof Pig) + else if (entity == EntityType.PIG) name = "MHF_Pig"; - else if (entity instanceof Sheep) - name = "MHF_Pig"; - else if (entity instanceof Squid) + else if (entity == EntityType.SHEEP) + name = "MHF_Sheep"; + else if (entity == EntityType.SQUID) name = "MHF_Squid"; - else if (entity instanceof HumanEntity) + else if (entity == EntityType.PLAYER) name = "MHF_Steve"; - else if (entity instanceof Villager) + else if (entity == EntityType.VILLAGER) name = "MHF_Villager"; return name; } - } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index 4ae8f94dc..4372b6fba 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -2,6 +2,8 @@ package mineplex.core.common.util; import java.util.Collection; +import org.apache.commons.lang.WordUtils; + public class UtilText { public static String listToString(Collection inputList, boolean comma) { String out = ""; @@ -84,4 +86,13 @@ public class UtilText { return false; } + + public static String[] wrap(String text, int lineLength) + { + return wrap(text, lineLength, true); + } + + public static String[] wrap(String text, int lineLength, boolean wrapLongerWords) { + return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0"); + } } diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index 8171cd881..7dba3b7ca 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -14,5 +14,6 @@ + diff --git a/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.core.prefs index 7341ab168..d17b6724d 100644 --- a/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.core.prefs +++ b/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 diff --git a/Plugins/Mineplex.Core/Mineplex.Core.iml b/Plugins/Mineplex.Core/Mineplex.Core.iml index 1a3abf88d..1714de4b9 100644 --- a/Plugins/Mineplex.Core/Mineplex.Core.iml +++ b/Plugins/Mineplex.Core/Mineplex.Core.iml @@ -20,5 +20,6 @@ + \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java b/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java index 1fd02a703..d6b15a030 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java @@ -22,7 +22,7 @@ public class TablistFix extends MiniPlugin // This is sort of experimental! @EventHandler(priority = EventPriority.MONITOR) public void onJoin(PlayerJoinEvent event) - { + {/* final Player player = event.getPlayer(); runSyncLater(new Runnable() { @@ -49,5 +49,6 @@ public class TablistFix extends MiniPlugin } } }, 20L); + */ } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/AccountCache.java b/Plugins/Mineplex.Core/src/mineplex/core/account/AccountCache.java deleted file mode 100644 index e6ac95b35..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/AccountCache.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.core.account; - -import java.util.UUID; - -import mineplex.serverdata.data.Data; - -public class AccountCache implements Data -{ - private UUID _uuid; - private Integer _id; - - public AccountCache(UUID uuid, int id) - { - _uuid = uuid; - _id = id; - } - - public UUID getUUID() - { - return _uuid; - } - - public int getId() - { - return _id; - } - - @Override - public String getDataId() - { - return _uuid.toString(); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index df6717c6a..156f18867 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -1,12 +1,14 @@ package mineplex.core.account; import mineplex.core.common.Rank; +import mineplex.serverdata.Utility; import org.bukkit.entity.Player; public class CoreClient { private int _accountId = -1; + private long _networkSessionLoginTime; private String _name; private String _disguisedAs; private Player _player; @@ -18,6 +20,7 @@ public class CoreClient { _player = player; _name = player.getName(); + _networkSessionLoginTime = Utility.currentTimeMillis(); } public CoreClient(String name) @@ -58,6 +61,9 @@ public class CoreClient public Rank GetRank() { + if (_rank == null) + _rank = Rank.ALL; + return _rank; } @@ -65,6 +71,11 @@ public class CoreClient { _rank = rank; } + + public long getNetworkSessionLoginTime() + { + return _networkSessionLoginTime; + } public String getDisguisedAs() { @@ -95,4 +106,9 @@ public class CoreClient public void setDisguised(boolean disguised) { this._disguised = disguised; } + + public void setNetworkSessionLoginTime(long loginTime) + { + _networkSessionLoginTime = loginTime; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index f2b2a0016..9fbd04fc0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -2,6 +2,7 @@ package mineplex.core.account; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; import java.util.UUID; @@ -21,10 +22,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.serverdata.Region; -import mineplex.serverdata.data.BungeeServer; -import mineplex.serverdata.redis.RedisDataRepository; -import mineplex.serverdata.servers.ServerManager; +import mineplex.playerCache.PlayerCache; +import mineplex.playerCache.PlayerInfo; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -47,9 +46,9 @@ public class CoreClientManager extends MiniPlugin private AccountRepository _repository; private NautHashMap _clientList; private HashSet _duplicateLoginGlitchPreventionList; - private RedisDataRepository _accountCacheRepository; private NautHashMap _loginProcessors = new NautHashMap(); + private LinkedList _querylessLoginProcessors = new LinkedList(); private Object _clientLock = new Object(); @@ -64,9 +63,6 @@ public class CoreClientManager extends MiniPlugin _repository = new AccountRepository(plugin, webServer); _clientList = new NautHashMap(); _duplicateLoginGlitchPreventionList = new HashSet(); - - _accountCacheRepository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), - Region.ALL, AccountCache.class, "accountCache"); } public AccountRepository getRepository() @@ -110,7 +106,7 @@ public class CoreClientManager extends MiniPlugin { _clientList.remove(name); } - + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name)); } @@ -124,7 +120,14 @@ public class CoreClientManager extends MiniPlugin if(client.getDisguisedAs().equalsIgnoreCase(name)) return client; } - return _clientList.get(name); + CoreClient client = _clientList.get(name); + + if (client == null) + { + client = new CoreClient(name); + } + + return client; } } @@ -138,6 +141,16 @@ public class CoreClientManager extends MiniPlugin return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get()); } + /** + * Get the databse account id for a player. Requires the player is online + * @param player + * @return + */ + public int getAccountId(Player player) + { + return Get(player).getAccountId(); + } + @EventHandler(priority = EventPriority.LOWEST) public void AsyncLogin(AsyncPlayerPreLoginEvent event) { @@ -173,7 +186,7 @@ public class CoreClientManager extends MiniPlugin _clientsProcessing.decrementAndGet(); } - if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR)) + if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(Rank.MODERATOR)) { for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { @@ -207,7 +220,16 @@ public class CoreClientManager extends MiniPlugin UUID uuid = loadUUIDFromDB(playerName); if (uuid == null) - uuid = UUIDFetcher.getUUIDOf(playerName); + { + try + { + uuid = UUIDFetcher.getUUIDOf(playerName); + } + catch (Exception exception) + { + System.out.println("Error fetching uuid from mojang : " + exception.getMessage()); + } + } String response = ""; @@ -224,13 +246,21 @@ public class CoreClientManager extends MiniPlugin CoreClient client = Add(playerName); client.SetRank(Rank.valueOf(token.Rank)); - client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName())); + client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); if (client.getAccountId() > 0) - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); + { + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) + { + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); + } + } } catch (Exception exception) { @@ -264,7 +294,7 @@ public class CoreClientManager extends MiniPlugin { public void run() { - client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName())); + client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); _clientLoginLock.remove(client.GetPlayerName()); } }); @@ -274,7 +304,7 @@ public class CoreClientManager extends MiniPlugin TimingManager.stop(client.GetPlayerName() + " GetClient."); token = gson.fromJson(response, ClientToken.class); - + client.SetRank(Rank.valueOf(token.Rank)); // _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString()); @@ -301,17 +331,15 @@ public class CoreClientManager extends MiniPlugin TimingManager.stop(client.GetPlayerName() + " LoadClient Total."); - System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId()); - if (client.getAccountId() > 0) { - try + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) { - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); - } - catch (Exception e) - { - e.printStackTrace(); + client.setNetworkSessionLoginTime(playerInfo.getLoginTime()); + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); } } @@ -342,7 +370,7 @@ public class CoreClientManager extends MiniPlugin // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { - if (client.GetRank().Has(event.getPlayer(), Rank.ULTRA, false)) + if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -454,7 +482,7 @@ public class CoreClientManager extends MiniPlugin callback.run(matchedName); return; } - + callback.run(matchedName); } }, caller, playerName, true); @@ -485,7 +513,9 @@ public class CoreClientManager extends MiniPlugin clientIterator.remove(); if (clientPlayer != null) + { _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName())); + } } } } @@ -507,6 +537,11 @@ public class CoreClientManager extends MiniPlugin { _loginProcessors.put(processor.getName(), processor); } + + public void addStoredProcedureLoginProcessor(IQuerylessLoginProcessor processor) + { + _querylessLoginProcessors.add(processor); + } public boolean hasRank(Player player, Rank rank) { @@ -514,11 +549,6 @@ public class CoreClientManager extends MiniPlugin if (client == null) return false; - return client.GetRank().Has(rank); - } - - public int getCachedClientAccountId(UUID uuid) - { - return _accountCacheRepository.getElement(uuid.toString()).getId(); + return client.GetRank().has(rank); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java new file mode 100644 index 000000000..7c69bb1c1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java @@ -0,0 +1,6 @@ +package mineplex.core.account; + +public interface IQuerylessLoginProcessor +{ + public void processLogin(String playerName, int accountId); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java index 21f0ee4c9..d0dfbcd93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java @@ -29,7 +29,7 @@ public class UpdateRank extends CommandBase if (Plugin.Get(caller).GetRank() == Rank.JNR_DEV && !testServer) { - F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.GetTag(true, true)) + "s are only permitted to set ranks on test servers!"); + F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.getTag(true, true)) + "s are only permitted to set ranks on test servers!"); return; } @@ -60,9 +60,9 @@ public class UpdateRank extends CommandBase final Rank rank = tempRank; - if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR || rank == Rank.JNR_DEV || rank == Rank.DEVELOPER) + if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.JNR_DEV || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR) { - if (!testServer && rank.Has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT)) + if (!testServer && rank.has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT)) { UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Insufficient privileges!")); return; @@ -122,4 +122,4 @@ public class UpdateRank extends CommandBase } } } -} +} \ No newline at end of file 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 60f756748..cd64cbdfa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -6,6 +6,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.UUID; @@ -14,6 +15,7 @@ import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.IQuerylessLoginProcessor; import mineplex.core.account.repository.token.LoginToken; import mineplex.core.account.repository.token.RankUpdateToken; import mineplex.core.common.Rank; @@ -55,7 +57,7 @@ public class AccountRepository extends RepositoryBase //executeUpdate(CREATE_ACCOUNT_TABLE); } - public int login(NautHashMap loginProcessors, String uuid, String name) + public int login(NautHashMap loginProcessors, LinkedList querylessLoginProcessors, String uuid, String name) { int accountId = -1; try ( @@ -145,6 +147,11 @@ public class AccountRepository extends RepositoryBase loginProcessor.processLoginResultSet(name, accountId, statement.getResultSet()); statement.getMoreResults(); } + + for (IQuerylessLoginProcessor loginProcessor : querylessLoginProcessors) + { + loginProcessor.processLogin(name, accountId); + } } catch (Exception exception) { @@ -186,7 +193,7 @@ public class AccountRepository extends RepositoryBase }, new ColumnVarChar("name", 100, name)); if (uuids.size() > 0) - return uuids.get(uuids.size() - 1); + return uuids.get(0); else return null; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 64d6215aa..ab821003d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -662,11 +662,53 @@ public enum Achievement new int[]{20}, AchievementCategory.BOMB_LOBBERS), - BOMB_LOBBERS_SNIPER("Sniper", 10000, + BOMB_LOBBERS_SNIPER("Sniper", 1000, new String[]{"Bomb Lobbers.Direct Hit"}, new String[]{"Get 50 direct hits"}, new int[]{50}, - AchievementCategory.BOMB_LOBBERS) + AchievementCategory.BOMB_LOBBERS), + + EVOLUTION_WINS("Expert Evolver", 1200, + new String[]{"Evolution.Wins"}, + new String[]{"Win 20 games of Evolution"}, + new int[]{20}, + AchievementCategory.EVOLUTION), + + EVOLUTION_NO_DEATHS("Perfect Game", 2000, + new String[]{"Evolution.NoDeaths"}, + new String[]{"Win a game without dying"}, + new int[]{1}, + AchievementCategory.EVOLUTION), + + EVOLUTION_STEALTH("Stealth Mastah", 1000, + new String[]{"Evolution.Stealth"}, + new String[]{"Win without taking any", "damage while evolving"}, + new int[]{1}, + AchievementCategory.EVOLUTION), + + EVOLUTION_RAMPAGE("Rampage", 800, + new String[]{"Evolution.Rampage"}, + new String[]{"Get 3 kills within 5 seconds", "of each other"}, + new int[]{1}, + AchievementCategory.EVOLUTION), + + EVOLUTION_MELEE("Melee Monster", 1000, + new String[]{"Evolution.MeleeOnly"}, + new String[]{"Win without using any abilities"}, + new int[]{1}, + AchievementCategory.EVOLUTION), + + EVOLUTION_SKILLS("Ability Assassin", 1000, + new String[]{"Evolution.AbilityOnly"}, + new String[]{"Win without any melee attacks"}, + new int[]{1}, + AchievementCategory.EVOLUTION), + + EVOLUTION_EVOLVEKILL("No Evolve 5 U", 800, + new String[]{"Evolution.EvolveKill"}, + new String[]{"Kill 25 people while they", "Are trying to evolve"}, + new int[]{25}, + AchievementCategory.EVOLUTION) ; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 9c9491ad5..5b81e40ea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -2,9 +2,6 @@ package mineplex.core.achievement; import java.util.List; -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; @@ -12,10 +9,14 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; +import org.bukkit.Material; +import org.bukkit.entity.Player; + public enum AchievementCategory { GLOBAL("Global", null, - new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME }, + new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null, + new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote"), null, new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") }, Material.EMERALD, 0, GameCategory.GLOBAL, "None"), BRIDGES("The Bridges", null, @@ -28,7 +29,7 @@ public enum AchievementCategory SKYWARS("Skywars",null, new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, - Material.FEATHER, 5, GameCategory.SURVIVAL, "Destructor Kit"), + Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit"), UHC("Ultra Hardcore", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -122,7 +123,11 @@ public enum AchievementCategory BOMB_LOBBERS("Bomb Lobbers", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit"); + Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit"), + + EVOLUTION("Evolution", null, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, + Material.MONSTER_EGG, 0, GameCategory.ARCADE, "Harvester Kit"); private String _name; private String[] _statsToPull; @@ -202,7 +207,7 @@ public enum AchievementCategory String displayName = _statDisplays[i].getDisplayName(); // Skip showing Losses, Kills, Deaths for other players - 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"))) + 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; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 485f5a124..6c736e5be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -137,15 +137,6 @@ public class AchievementManager extends MiniPlugin _log.remove(event.getPlayer().getName()); } - @EventHandler - public void playerJoin(PlayerJoinEvent event) - { - if (_giveInterfaceItem) - { - giveInterfaceItem(event.getPlayer()); - } - } - public void clearLog(Player player) { _log.remove(player.getName()); @@ -161,22 +152,7 @@ public class AchievementManager extends MiniPlugin _giveInterfaceItem = giveInterfaceItem; } - public void giveInterfaceItem(Player player) - { - if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.SKULL_ITEM)) - { - ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats"); - SkullMeta meta = ((SkullMeta) item.getItemMeta()); - meta.setOwner(player.getName()); - item.setItemMeta(meta); - - player.getInventory().setItem(_interfaceSlot, item); - - UtilInv.Update(player); - } - } - - @EventHandler + /*@EventHandler public void openShop(PlayerInteractEvent event) { if (!_shopEnabled) @@ -188,7 +164,7 @@ public class AchievementManager extends MiniPlugin openShop(event.getPlayer()); } - } + }*/ public boolean hasCategory(Player player, Achievement[] required) { @@ -211,15 +187,15 @@ public class AchievementManager extends MiniPlugin if (sender.getName().equalsIgnoreCase("B2_mp")) return 101; - if (rank.Has(Rank.MODERATOR)) + if (rank.has(Rank.MODERATOR)) level = Math.max(level, 5); - if (rank.Has(Rank.SNR_MODERATOR)) + if (rank.has(Rank.SNR_MODERATOR)) level = Math.max(level, 15); - if (rank.Has(Rank.JNR_DEV)) + if (rank.has(Rank.JNR_DEV)) level = Math.max(level, 25); - if (rank.Has(Rank.ADMIN)) + if (rank.has(Rank.ADMIN)) level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); - if (rank.Has(Rank.OWNER)) + if (rank.has(Rank.OWNER)) level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); if (sender.getName().equalsIgnoreCase("Phinary")) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java index 147b33d59..d7d3fabb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java @@ -17,7 +17,7 @@ public class StatsCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null || args.length == 0) + if (args.length == 0) { Plugin.openShop(caller); } 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 2ab5e498f..68d43a09e 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 @@ -57,11 +57,10 @@ public class AchievementMainPage extends ShopPageBase lore = new ArrayList(); lore.add(" "); - category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 5 : 2, + category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 10 : 2, getPlayer(), _target); lore.add(" "); addAchievements(category, lore, 9); - lore.add(" "); lore.add(ChatColor.RESET + "Click for more details!"); ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), @@ -100,5 +99,8 @@ public class AchievementMainPage extends ShopPageBase 0) + lore.add(" "); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 37ff11c9b..7719eca3f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -259,7 +259,7 @@ public class AntiHack extends MiniPlugin //Inform for (Player admin : UtilServer.getPlayers()) - if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports) + if (_clientManager.Get(admin).GetRank().has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports) { UtilPlayer.message(admin, "#" + total + ": " + C.cRed + C.Bold + player.getName() + " suspected for " + type + "."); } @@ -335,7 +335,7 @@ public class AntiHack extends MiniPlugin boolean handled = false; for (Player staff : UtilServer.getPlayers()) { - if (_clientManager.Get(staff).GetRank().Has(Rank.MODERATOR)) + if (_clientManager.Get(staff).GetRank().has(Rank.MODERATOR)) { UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cYellow + report); UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation. Please investigate."); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java index 6848257d9..8d21d1f13 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java @@ -13,7 +13,7 @@ public class AntiHackRepository { private String _serverName; - private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack_Kick_Log (id INT NOT NULL AUTO_INCREMENT, updated LONG, playerName VARCHAR(256), motd VARCHAR(56), gameType VARCHAR(56), map VARCHAR(256), serverName VARCHAR(256), report VARCHAR(256), ping VARCHAR(25), PRIMARY KEY (id));"; + //private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack_Kick_Log (id INT NOT NULL AUTO_INCREMENT, updated LONG, playerName VARCHAR(256), motd VARCHAR(56), gameType VARCHAR(56), map VARCHAR(256), serverName VARCHAR(256), report VARCHAR(256), ping VARCHAR(25), PRIMARY KEY (id));"; private static String UPDATE_PLAYER_OFFENSES = "INSERT INTO AntiHack_Kick_Log (updated, playerName, motd, gameType, map, serverName, report, ping) VALUES (now(), ?, ?, ?, ?, ?, ?, ?);"; public AntiHackRepository(String serverName) @@ -23,32 +23,6 @@ public class AntiHackRepository public void initialize() { - PreparedStatement preparedStatement = null; - - try (Connection connection = DBPool.STATS_MINEPLEX.getConnection()) - { - // Create table - preparedStatement = connection.prepareStatement(CREATE_TABLE); - preparedStatement.execute(); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } } public void saveOffense(final Player player, final String motd, final String game, final String map, final String report) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java new file mode 100644 index 000000000..bb6d8c9f3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java @@ -0,0 +1,159 @@ +package mineplex.core.bonuses; + +import java.util.List; + +import org.bukkit.ChatColor; + +import mineplex.core.common.util.C; + +public class BonusAmount +{ + private int _gems; + private int _coins; + private int _gold; + private int _bonusGems; + private int _bonusCoins; + private int _bonusGold; + private int _experience; + private int _bonusExperience; + private int _tickets; + + public BonusAmount() + { + + } + + public int getGems() + { + return _gems; + } + + public void setGems(int gems) + { + _gems = gems; + } + + public int getCoins() + { + return _coins; + } + + public void setCoins(int coins) + { + _coins = coins; + } + + public int getGold() + { + return _gold; + } + + public void setGold(int gold) + { + _gold = gold; + } + + public int getBonusGems() + { + return _bonusGems; + } + + public void setBonusGems(int bonusGems) + { + _bonusGems = bonusGems; + } + + public int getBonusCoins() + { + return _bonusCoins; + } + + public void setBonusCoins(int bonusCoins) + { + _bonusCoins = bonusCoins; + } + + public int getBonusGold() + { + return _bonusGold; + } + + public void setBonusGold(int bonusGold) + { + _bonusGold = bonusGold; + } + + public int getTotalGems() + { + return getGems() + getBonusGems(); + } + + public int getTotalCoins() + { + return getCoins() + getBonusCoins(); + } + + public int getTotalGold() + { + return getGold() + getBonusGold(); + } + + public int getExperience() + { + return _experience; + } + + public void setExperience(int experience) + { + _experience = experience; + } + + public int getBonusExperience() + { + return _bonusExperience; + } + + public void setBonusExperience(int bonusExperience) + { + _bonusExperience = bonusExperience; + } + + public int getTotalExperience() + { + return getExperience() + getBonusExperience(); + } + + public int getTickets() + { + return _tickets; + } + + public void setTickets(int tickets) + { + _tickets = tickets; + } + + public boolean isGreaterThanZero() + { + return _bonusCoins > 0 || _coins > 0 || _bonusGems > 0 || _gems > 0 || _gold > 0 || _bonusGold > 0; + } + + public void addLore(List lore) + { + lore.add(C.cYellow + "Rewards"); + addLore(lore, getTickets(), 0, "Carl Spin Ticket" + (getTickets() > 1 ? "s" : "")); + addLore(lore, getCoins(), getBonusCoins(), "Coins"); + addLore(lore, getGems(), getBonusGems(), "Gems"); + addLore(lore, getGold(), getBonusGold(), "Gold"); + addLore(lore, getExperience(), getBonusExperience(), "Experience"); + } + + private void addLore(List lore, int amount, int bonus, String suffix) + { + if (amount > 0) + lore.add(" " + C.cWhite + amount + " " + suffix); + +// if (bonus > 0) +// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java new file mode 100644 index 000000000..346f58b1c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java @@ -0,0 +1,127 @@ +package mineplex.core.bonuses; + +import java.sql.Date; +import java.sql.Timestamp; + +import mineplex.core.hologram.Hologram; +import mineplex.database.tables.records.BonusRecord; + +public class BonusClientData +{ + private Hologram _hologram; + + private int _accountId; + private Timestamp _dailyTime; + private Date _rankTime; + private Date _voteTime; + private int _dailyStreak; + private int _maxDailyStreak; + private int _voteStreak; + private int _maxVoteStreak; + private int _tickets; + + public BonusClientData() + { + _accountId = -1; + } + + public void setAccountId(Integer value) + { + _accountId = value; + } + + public Integer getAccountId() + { + return _accountId; + } + + public void setDailyTime(Timestamp value) + { + _dailyTime = value; + } + + public Timestamp getDailyTime() + { + return _dailyTime; + } + + public void setRankTime(Date value) + { + _rankTime = value; + } + + public Date getRankTime() + { + return _rankTime; + } + + public void setVoteTime(Date value) + { + _voteTime = value; + } + + public Date getVoteTime() + { + return _voteTime; + } + + public void setDailyStreak(Integer value) + { + _dailyStreak = value; + } + + public Integer getDailyStreak() + { + return _dailyStreak; + } + + public void setMaxDailyStreak(Integer value) + { + _maxDailyStreak = value; + } + + public Integer getMaxDailyStreak() + { + return _maxDailyStreak; + } + + public void setVoteStreak(Integer value) + { + _voteStreak = value; + } + + public Integer getVoteStreak() + { + return _voteStreak; + } + + public void setMaxVoteStreak(Integer value) + { + _maxVoteStreak = value; + } + + public Integer getMaxVoteStreak() + { + return _maxVoteStreak; + } + + public void setTickets(Integer value) + { + _tickets = value; + } + + public Integer getTickets() + { + return _tickets; + } + + public Hologram getHologram() + { + return _hologram; + } + + public void setHologram(Hologram hologram) + { + _hologram = hologram; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java new file mode 100644 index 000000000..1276e2f00 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -0,0 +1,1157 @@ +package mineplex.core.bonuses; + +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; +import java.util.TimeZone; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.IQuerylessLoginProcessor; +import mineplex.core.account.event.ClientUnloadEvent; +import mineplex.core.bonuses.redis.VoteHandler; +import mineplex.core.bonuses.redis.VotifierCommand; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.database.DBPool; +import mineplex.core.donation.DonationManager; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.npc.Npc; +import mineplex.core.npc.NpcManager; +import mineplex.core.pet.PetManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.reward.RewardManager; +import mineplex.core.stats.StatsManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.database.Tables; +import mineplex.core.bonuses.animations.AnimationCarl; +import mineplex.core.bonuses.commands.AnimationCommand; +import mineplex.core.bonuses.commands.GuiCommand; +import mineplex.core.bonuses.commands.TicketCommand; +import mineplex.core.bonuses.event.CarlSpinnerEvent; +import mineplex.core.bonuses.gui.BonusGui; +import mineplex.database.tables.records.BonusRecord; +import mineplex.core.bonuses.gui.SpinGui; +import mineplex.core.poll.PollManager; +import mineplex.serverdata.commands.ServerCommandManager; + +import org.jooq.DSLContext; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import net.minecraft.server.v1_7_R4.DataWatcher; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; + +public class BonusManager extends MiniClientPlugin implements ILoginProcessor +{ + + public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC"); + + private static long timeOffSet = 0; + + private ArrayList _pendingExplosions = new ArrayList<>(); + private ArrayList _pendingExplosionsPlayers = new ArrayList<>(); + private HashMap _showCarl = new HashMap<>(); + private long _explode; + private boolean _canVote; + + public static long getSqlTime() + { + return getSqlTime(System.currentTimeMillis()); + } + + public static long getSqlTime(long currentTime) + { + return currentTime + timeOffSet; + } + + public static long getLocalTime() + { + return System.currentTimeMillis(); + } + + public static long getLocalTime(long sqlTime) + { + return sqlTime - timeOffSet; + } + + public void updateOffSet() + { + _repository.getTimeOffset(new Callback() { + + @Override + public void run(Long data) + { + timeOffSet = data; + } + }); + } + + private BonusRepository _repository; + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private PollManager _pollManager; + private NpcManager _npcManager; + private HologramManager _hologramManager; + private RewardManager _rewardManager; + private StatsManager _statsManager; + public boolean _enabled; + private Npc _carlNpc; + private AnimationCarl _animation; + private int _visualTick; + + // Streak + private StreakRecord _dailyStreak; + private StreakRecord _voteStreak; + + private ArrayList _voteList; + + // Donor Queues + private Queue _coinQueue; + private Queue _gemQueue; + + /** + * THIS SHOULD ONLY BE USED FOR VOTIFIER! + */ + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super("Bonus", plugin); + _enabled = false; + + _repository = new BonusRepository(plugin, this, donationManager); + _clientManager = clientManager; + _donationManager = donationManager; + + _voteList = new ArrayList(); + _voteList.add("http://vote1.mineplex.com"); + _voteList.add("http://vote2.mineplex.com"); + _voteList.add("http://vote3.mineplex.com"); + + _coinQueue = new LinkedList(); + _gemQueue = new LinkedList(); + + updateOffSet(); + } + + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager) + { + super("Bonus", plugin); + _repository = new BonusRepository(plugin, this, donationManager); + _clientManager = clientManager; + _donationManager = donationManager; + _npcManager = npcManager; + _hologramManager = hologramManager; + + _rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager, statsManager, + 100, 250, + 500, 1000, + 4000, 6000, + 12000, 32000, + true, true); + + _pollManager = pollManager; + _statsManager = statsManager; + + _voteList = new ArrayList(); + _voteList.add("http://vote1.mineplex.com"); + _voteList.add("http://vote2.mineplex.com"); + _voteList.add("http://vote3.mineplex.com"); + + _canVote = true; + _coinQueue = new LinkedList(); + _gemQueue = new LinkedList(); + + + if (npcManager != null) + { + _carlNpc = _npcManager.getNpcByName("Carl the Creeper"); + if (_carlNpc == null) + { + _enabled = false; + } + else + { + _enabled = true; +// _carlNpc.getEntity().setCustomName(""); +// _carlNpc.getEntity().setCustomNameVisible(false); + _animation = new AnimationCarl(_carlNpc.getEntity()); + _animation.setRunning(false); + } + } + else + { + _enabled = false; + } + + clientManager.addStoredProcedureLoginProcessor(this); + + ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class, + new VoteHandler(this)); + + updateOffSet(); + updateStreakRecord(); + } + + @Override + public void addCommands() + { + addCommand(new GuiCommand(this)); + addCommand(new AnimationCommand(this)); + addCommand(new TicketCommand(this)); + } + + // Just keeping things up-to-date + @EventHandler + public void onSlow(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_16) + return; + updateOffSet(); + } + + @EventHandler + public void updateStreak(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_16) + return; + + updateStreakRecord(); + } + + private void updateStreakRecord() + { + _repository.getDailyStreakRecord(new Callback() + { + @Override + public void run(StreakRecord data) + { + _dailyStreak = data; + } + }); + + _repository.getVoteStreakRecord(new Callback() + { + @Override + public void run(StreakRecord data) + { + _voteStreak = data; + } + }); + } + + public StreakRecord getDailyStreak() + { + return _dailyStreak; + } + + public StreakRecord getVoteStreak() + { + return _voteStreak; + } + + public void handleVote(final Player player, final int gemsReceived) + { + final int accountId = _clientManager.getAccountId(player); + + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.getClientData(accountId, new Callback() + { + @Override + public void run(final BonusClientData data) + { + runSync(new Runnable() + { + @Override + public void run() + { + BonusClientData oldData = Get(player); + if (oldData != null) data.setHologram(oldData.getHologram()); + Set(player, data); + + _statsManager.incrementStat(player, "Global.DailyVote", 1); + addPendingExplosion(player, player.getName()); + UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!")); + UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(gemsReceived + " Gems") + " and " + F.elem("1 Carl Spinner Ticket") + "!")); + } + }); + } + }); + } + }); + + } + + @EventHandler + public void fireCreeper(UpdateEvent event) + { + if(event.getType() != UpdateType.SLOW) + return; + + if(_pendingExplosions.isEmpty()) + return; + + if(!_canVote) + return; + + if (!_enabled) + return; + + _explode = System.currentTimeMillis(); + _animation.setTicks(0); + _canVote = false; + } + + @EventHandler + public void creeperAnimation(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + _animation.itemClean(); + + if(_canVote) + return; + + if (!_enabled) + return; + + Entity creeper = _carlNpc.getEntity(); + + double elapsed = (System.currentTimeMillis() - _explode)/1000d; + + //Not Detonated + if (elapsed < 1) + { + //Sound + creeper.getWorld().playSound(creeper.getLocation(), Sound.CREEPER_HISS, (float)(0.5 + elapsed), (float)(0.5 + elapsed)); + + IncreaseSize(creeper); + return; + } + + if(!_animation.isRunning()) + { + //Effect + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, creeper.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + creeper.getWorld().playSound(creeper.getLocation(), Sound.EXPLODE, 2f, 1f); + _animation.setType(_pendingExplosions.get(0)); + _animation.setPlayer(_pendingExplosionsPlayers.get(0)); + _animation.setRunning(true); + } + + if(!_animation.isDone()) + return; + + DecreaseSize(creeper); + _pendingExplosions.remove(0); + _pendingExplosionsPlayers.remove(0); + _canVote = true; + } + + @EventHandler + public void updateAnimation(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if (!_enabled) + return; + + if(!_animation.isRunning()) + return; + + _animation.run(); + } + + public void DecreaseSize(Entity player) + { + if (!_enabled) + return; + + ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, -1); + } + + public void IncreaseSize(Entity player) + { + if (!_enabled) + return; + + ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, 1); + } + + // DAILY BONUS + + public static final long TIME_BETWEEN_BONUSES = 1000 * 60 * 60 * 20; + public static final long DAILY_STREAK_RESET_TIME = 1000 * 60 * 60 * 12; + public static final long VOTE_STREAK_RESET_TIME = 1000 * 60 * 60 * 24; + + public void attemptDailyBonus(final Player player, final BonusAmount amount, final Callback result) + { + if (timeTillDailyBonus(player) > 0) + result.run(false); + + getRepository().attemptDailyBonus(player, new Callback() + { + @Override + public void run(Boolean r) + { + if (r) + { + incrementDailyStreak(player); + awardBonus(player, amount); + updateCreeperVisual(player, true, C.cAqua); + + _statsManager.incrementStat(player, "Global.DailyReward", 1); + } + + result.run(r); + } + }); + } + + public long timeTillDailyBonus(Player player) + { + return nextDailyBonus(player) - getLocalTime(); + } + + // This calculates the the next daily bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION. + public long nextDailyBonus(Player player) + { + Timestamp timestamp = Get(player).getDailyTime(); + + if (timestamp == null) + return 0; + + long lastBonus = timestamp.getTime(); + + return getLocalTime(lastBonus + TIME_BETWEEN_BONUSES); + } + + // RANK BONUS + public void attemptRankBonus(final Player player, final Callback result) + { + if (timeTillRankBonus(player) > 0) + result.run(false); + getRepository().attemptRankBonus(player, new Callback() + { + @Override + public void run(Boolean aBoolean) + { + if (aBoolean) + { + awardBonus(player, getRankBonusAmount(player)); + updateCreeperVisual(player, true, C.cAqua); + } + + result.run(aBoolean); + } + }); + } + + public void attemptCarlSpin(final Player player) + { + final BonusClientData clientData = Get(player); + + if (Recharge.Instance.use(player, "Carl Spin", 5000, false, false) && clientData.getTickets() > 0) + { + CarlSpinnerEvent event = new CarlSpinnerEvent(player); + Bukkit.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) + { + final int accountId = _clientManager.Get(player).getAccountId(); + + _repository.attemptAddTickets(accountId, clientData, -1, new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + new SpinGui(_plugin, player, _rewardManager, BonusManager.this).openInventory(); + } + else + { + UtilPlayer.message(player, F.main("Carl", "There waa an error processing your request. Try again later")); + } + } + }); + } + } + } + + public long timeTillRankBonus(Player player) + { + return nextRankBonus(player) - getLocalTime(); + } + + + // This calculates the the next rank bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION. + public long nextRankBonus(Player player) + { + Date date = Get(player).getRankTime(); + + if (date == null) + return 0; + + long lastBonus = date.getTime(); + + + return getNextRankBonusTime(getLocalTime(lastBonus)); + } + + public void updateDailyStreak(Player player) + { + BonusClientData client = Get(player); + if (client.getDailyStreak() > 0 && client.getDailyTime() != null) + { + long lastBonus = getLocalTime(client.getDailyTime().getTime()); + long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME); + + if (timeLeft < 0) + { + client.setDailyStreak(0); + } + } + } + + public void updateVoteStreak(BonusRecord client) + { + if (client.getVoteStreak() > 0 && client.getVotetime() != null) + { + long lastBonus = getLocalTime(client.getVotetime().getTime()); + long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); + + if (timeLeft < 0) + { + client.setVoteStreak(0); + } + } + } + + public void incrementDailyStreak(Player player) + { + BonusClientData data = Get(player); + + data.setDailyStreak(data.getDailyStreak() + 1); + + if (data.getDailyStreak() > data.getMaxDailyStreak()) + data.setMaxDailyStreak(data.getDailyStreak()); + } + + public void incrementVoteStreak(BonusRecord client) + { + client.setVoteStreak(client.getVoteStreak() + 1); + + if (client.getVoteStreak() > client.getMaxVoteStreak()) + client.setMaxVoteStreak(client.getVoteStreak()); + } + + public boolean continueStreak(long localLastBonus, long extendTime) + { + long maxTime = localLastBonus + TIME_BETWEEN_BONUSES + extendTime; + return System.currentTimeMillis() < maxTime; + } + + public long getStreakTimeRemaining(long localLastBonus, long extendTime) + { + long maxTime = localLastBonus + TIME_BETWEEN_BONUSES + extendTime; + return maxTime - System.currentTimeMillis(); + } + + public static long getNextRankBonusTime(long time) + { + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeZone(TIMEZONE); + calendar.setTimeInMillis(time); + + calendar.add(Calendar.MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); + + return calendar.getTimeInMillis(); + } + + public int getDailyMultiplier(Player player) + { + BonusClientData client = Get(player); + int streak = client.getDailyStreak(); + + int multiplyer = Math.min(200, 5 * streak); + if (streak >= 40) multiplyer += (1 * (streak - 40)); + return multiplyer; + } + + public int getVoteMultiplyer(int streak) + { + int multiplyer = Math.min(100, 5 * streak); + if (streak >= 20) multiplyer += (1 * (streak - 40)); + return multiplyer; + } + + public BonusAmount getDailyBonusAmount(Player player) + { + double mult = getDailyMultiplier(player) / 100.0; + + BonusAmount amount = new BonusAmount(); + int coins = 100; + int gems = 100; + int experience = 250; + + amount.setCoins(coins); + amount.setGems(gems); + amount.setExperience(experience); + amount.setBonusCoins((int) (mult * coins)); + amount.setBonusGems((int) (mult * gems)); + amount.setBonusExperience((int) (mult * experience)); + + return amount; + } + + public BonusAmount getVoteBonusAmount(Player player) + { + return getVoteBonusAmount(Get(player).getVoteStreak()); + } + + public BonusAmount getVoteBonusAmount(int voteStreak) + { + double mult = getVoteMultiplyer(voteStreak) / 100.0; + + BonusAmount amount = new BonusAmount(); + amount.setTickets(1); + amount.setGems(400); + amount.setBonusGems((int) (mult * 400)); + + return amount; + } + + public BonusAmount getRankBonusAmount(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(); + + BonusAmount data = new BonusAmount(); + + if (rank.has(Rank.MODERATOR)) + { + data.setCoins(35000); + } + if (rank.has(Rank.LEGEND)) + { + data.setCoins(30000); + } + else if (rank.has(Rank.HERO)) + { + data.setCoins(15000); + } + else if (rank.has(Rank.ULTRA)) + { + data.setCoins(7500); + } + + return data; + } + + //VOTE + + public long timeTillVoteBonus(Player player) + { + return nextVoteTime(player) - getLocalTime(); + } + + // This calculates the the next vote bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION. + public long nextVoteTime(Player player) + { + Date date = Get(player).getVoteTime(); + if (date == null) + return 0; + long lastBonus = date.getTime(); + + return getNextVoteTime(getLocalTime(lastBonus)); + + } + + public void awardBonus(final Player player, BonusAmount amount) + { + final BonusClientData bonusClient = Get(player); + CoreClient coreClient = _clientManager.Get(player); + + final int gems = amount.getTotalGems(); + final int gold = amount.getTotalGold(); + final int coins = amount.getTotalCoins(); + final int tickets = amount.getTickets(); + int experience = amount.getTotalExperience(); + + if (gems > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems"))); + _gemQueue.add(new GiveDonorData(player.getName(), coreClient.getAccountId(), player.getUniqueId(), gems)); + } + + if (gold > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold"))); + _donationManager.RewardGold(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + } + else + { + UtilPlayer.message(player, F.main("Carl", "Failed to process Gold")); + } + } + }, "Earned", player.getName(), coreClient.getAccountId(), gold, true); + } + + if (coins > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Coins"))); + _coinQueue.add(new GiveDonorData(player.getName(), coreClient.getAccountId(), player.getUniqueId(), coins)); + } + + if (tickets > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(tickets + " Carl Spin Ticket"))); + final int accountId = _clientManager.Get(player).getAccountId(); + runAsync(new Runnable() + { + @Override + public void run() + { + try + { + final int newTickets = DSL.using(DBPool.ACCOUNT, 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() + { + @Override + public void run() + { + bonusClient.setTickets(newTickets); + } + }); + } + catch (Exception e) + { + System.out.println("Failed to award ticket to player: " + player); + e.printStackTrace(); + } + } + }); + } + + if (experience > 0) + { + _statsManager.incrementStat(player, "Global.ExpEarned", experience); + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience"))); + } + + UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); + + } + + @EventHandler + public void openGui(PlayerInteractEntityEvent event) + { + if (!_enabled) + return; + + Entity entity = event.getRightClicked(); + if (entity.equals(_carlNpc.getEntity())) + { + updateDailyStreak(event.getPlayer()); + new BonusGui(_plugin, event.getPlayer(), this, _rewardManager).openInventory(); + } + } + + @EventHandler + public void openGui(EntityDamageByEntityEvent event) + { + if (!_enabled) + return; + + if (event.getDamager() instanceof Player) + { + Player player = (Player) event.getDamager(); + if (event.getEntity().equals(_carlNpc.getEntity())) + { + updateDailyStreak(player); + new BonusGui(_plugin, player, this, _rewardManager).openInventory(); + } + } + } + + public static long getNextVoteTime(long time) { + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeZone(TIMEZONE); + calendar.setTimeInMillis(time); + + calendar.add(Calendar.DAY_OF_YEAR, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + return calendar.getTimeInMillis(); + } + + public boolean canVote(Player player) + { + long nextVoteTime = nextVoteTime(player); + return System.currentTimeMillis() >= nextVoteTime; + } + + public boolean canDaily(Player player) + { + long nextDailyTime = nextDailyBonus(player); + return System.currentTimeMillis() >= nextDailyTime; + } + + public boolean canRank(Player player) + { + long nextRankTime = nextRankBonus(player); + return System.currentTimeMillis() >= nextRankTime; + } + + @EventHandler + public void join(final PlayerJoinEvent event) + { + runSyncLater(new Runnable() + { + @Override + public void run() + { + if (event.getPlayer().isOnline()) + updateCreeperVisual(event.getPlayer(), true, C.cAqua); + } + }, 10); + } + + public void updateCreeperVisual(Player player, boolean updateDataWatcher, String rewardPrefix) + { + if (!_enabled) + return; + + BonusClientData client = Get(player); + + int availableRewards = 0; + + if (canVote(player)) availableRewards++; + if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; + if (canDaily(player)) availableRewards++; + if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; + + Hologram hologram; + + + if (client.getHologram() == null) + { + double yAdd = UtilPlayer.is1_8(player) ? 2.18 : 2.3; + hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), ""); + hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); + hologram.addPlayer(player); + client.setHologram(hologram); + hologram.start(); + } + else + { + hologram = client.getHologram(); + } + + if (availableRewards > 0) + { + // Hologram +// String name = "Carl the Creeper"; + String text = rewardPrefix + availableRewards + " Reward" + (availableRewards > 1 ? "s" : "") + " to Claim"; + hologram.setText(text); + + if (updateDataWatcher) + { + // Charged + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 0); + watcher.a(1, (short) 300); + watcher.a(17, (byte) 1); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); + packet.a = _carlNpc.getEntity().getEntityId(); + packet.b = watcher.c(); + + UtilPlayer.sendPacket(player, packet); + } + } + else + { + String text = C.cGray + "No Rewards"; + hologram.setText(text); + + if (updateDataWatcher) + { + // Charged + DataWatcher watcher = new DataWatcher(null); + watcher.a(17, (byte) 0); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); + packet.a = _carlNpc.getEntity().getEntityId(); + packet.b = watcher.c(); + + UtilPlayer.sendPacket(player, packet); + } + } + } + + @EventHandler + public void updateCreeper(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER || !_enabled) + return; + + for (Player player : UtilServer.getPlayers()) + { + String prefix = _visualTick % 2 == 0 ? C.cAqua : C.cDAqua; + updateCreeperVisual(player, false, prefix); + } + + _visualTick++; + } + + @Override + protected BonusClientData AddPlayer(String player) + { + return new BonusClientData(); + } + + public BonusRepository getRepository() + { + return _repository; + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public RewardManager getRewardManager() + { + return _rewardManager; + } + + @Override + @EventHandler + public void UnloadPlayer(final ClientUnloadEvent event) + { + final BonusClientData clientData = Get(event.GetName()); + + if (clientData.getHologram() != null) + clientData.getHologram().stop(); + + // Save streaks + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.saveStreak(clientData.getAccountId(), clientData); + } + }); + + // This shouldnt be necessary anymore +// runAsync(new Runnable() +// { +// @Override +// public void run() +// { +// clientData.getRecord().store(); +// } +// }); + + super.UnloadPlayer(event); + } + + public void addPendingExplosion(Player player, Object obj) + { + _pendingExplosions.add(obj); + _pendingExplosionsPlayers.add(player); + } + + public PollManager getPollManager() + { + return _pollManager; + } + + + + @EventHandler + public void Join(final PlayerJoinEvent event) + { + runSyncLater(new Runnable() + { + @Override + public void run() + { + _showCarl.put(event.getPlayer().getName(), true); + } + }, 200); + } + + @EventHandler + public void Quit(PlayerQuitEvent event) + { + _showCarl.remove(event.getPlayer().getName()); + } + + @EventHandler + public void carlUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) + { + if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player)) + { + if(_showCarl.containsKey(player.getName())) + { + if(_plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Lobby")) + UtilPlayer.message(player, C.cDGreen + C.Bold + "Carl the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!"); + } + } + } + } + } + + @EventHandler + public void processQueue(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + // Gems + final GiveDonorData gemData = _gemQueue.poll(); + if (gemData != null && gemData.getAttempts() < 10) + { + _donationManager.RewardGems(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + System.out.println("Successfully processed " + gemData.getGiveAmount() + " gems for " + gemData.getPlayerName()); + } + else + { + gemData.incrementAttempts(); + System.out.println("Failed to process gems for " + gemData.getPlayerName() + " adding to back of queue. Attempts: " + gemData.getAttempts()); + _gemQueue.add(gemData); + } + } + }, "Earned", gemData.getPlayerName(), gemData.getUuid(), gemData.getGiveAmount()); + } + + // Coins + final GiveDonorData coinData = _coinQueue.poll(); + if (coinData != null && coinData.getAttempts() < 10) + { + _donationManager.RewardCoins(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + System.out.println("Successfully processed " + coinData.getGiveAmount() + " coins for " + coinData.getPlayerName()); + } + else + { + coinData.incrementAttempts(); + System.out.println("Failed to process coins for " + coinData.getPlayerName() + " adding to back of queue. Attempts: " + coinData.getAttempts()); + _coinQueue.add(coinData); + } + } + }, "Earned", coinData.getPlayerName(), coinData.getAccountId(), coinData.getGiveAmount()); + } + } + + public String getVoteLink() + { + long sqlTime = getSqlTime(); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(sqlTime); + int date = calendar.get(Calendar.DAY_OF_YEAR); + int index = date % _voteList.size(); + return _voteList.get(index); + } + + /** + * Used for disabling rank rewards during first month of release + * @return + */ + public boolean isPastAugust() + { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeZone(TIMEZONE); + calendar.setTimeInMillis(getSqlTime()); + + if (calendar.get(Calendar.YEAR) == 2015 && calendar.get(Calendar.MONTH) == Calendar.AUGUST) + return false; + + return true; + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + Set(playerName, _repository.loadData(accountId, resultSet)); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT * FROM bonus WHERE accountId = '" + accountId + "';"; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java new file mode 100644 index 000000000..ee21b56a0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java @@ -0,0 +1,446 @@ +package mineplex.core.bonuses; + +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.sql.Types; +import java.util.Map; + +import com.sun.org.apache.xpath.internal.operations.Bool; +import mineplex.core.bonuses.gui.SpinGui; +import mineplex.core.common.Pair; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; +import mineplex.database.Tables; +import mineplex.database.tables.records.BonusRecord; +import org.jooq.Configuration; +import org.jooq.DSLContext; +import org.jooq.Record2; +import org.jooq.SQLDialect; +import org.jooq.TableField; +import org.jooq.impl.DSL; +import org.jooq.impl.DefaultConfiguration; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +public class BonusRepository extends RepositoryBase +{ + private static String CREATE_BONUS_TABLE = "CREATE TABLE IF NOT EXISTS bonus (accountId INT NOT NULL AUTO_INCREMENT, dailytime TIMESTAMP NULL DEFAULT NULL, ranktime DATE NULL DEFAULT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));"; + private BonusManager _manager; + private DonationManager _donationManager; + + public BonusRepository(JavaPlugin plugin, BonusManager bonusManager, DonationManager donationManager) + { + super(plugin, DBPool.ACCOUNT); + _manager = bonusManager; + _donationManager = donationManager; + } + + public BonusRecord loadRecord(String playerName, int accountId) + { + DSLContext create = jooq(); + + BonusRecord record = create.selectFrom(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne(); + + if (record == null) + { + // Need to create new record! + record = create.newRecord(Tables.bonus); + record.setAccountId(accountId); + record.setDailyStreak(0); + record.setMaxDailyStreak(0); + record.setVoteStreak(0); + record.setMaxVoteStreak(0); + record.setTickets(0); + record.store(); // Todo - is this necessary? + } + System.out.println("Loaded record. Daily time: " + record.getDailytime()); + return record; + } + + public BonusClientData loadData(final int accountId, ResultSet resultSet) throws SQLException + { + BonusClientData clientData = new BonusClientData(); + clientData.setAccountId(accountId); + + boolean foundClient = false; + while (resultSet.next()) + { + foundClient = true; + clientData.setDailyTime(resultSet.getTimestamp(2)); + clientData.setRankTime(resultSet.getDate(3)); + clientData.setVoteTime(resultSet.getDate(4)); + clientData.setDailyStreak(resultSet.getInt(5)); + clientData.setMaxDailyStreak(resultSet.getInt(6)); + clientData.setVoteStreak(resultSet.getInt(7)); + clientData.setMaxVoteStreak(resultSet.getInt(8)); + clientData.setTickets(resultSet.getInt(9)); + } + + if (!foundClient) + { + _manager.runAsync(new Runnable() + { + @Override + public void run() + { + executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null); + } + }); + } + + return clientData; + } + + public void getDailyStreakRecord(Callback callback) + { + getStreakRecord(Tables.bonus.maxDailyStreak, callback); + } + + public void getVoteStreakRecord(Callback callback) + { + getStreakRecord(Tables.bonus.maxVoteStreak, callback); + } + + private void getStreakRecord(final TableField field, final Callback callback) + { + Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + final Record2 record = jooq().select(Tables.accounts.name, field) + .from(Tables.bonus.join(Tables.accounts).on(Tables.bonus.accountId.eq(Tables.accounts.id))) + .orderBy(field.desc()).limit(1).fetchOne(); + + Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + if (record.value1() != null && record.value2() != null) + { + callback.run(new StreakRecord(record.value1(), record.value2())); + } + } + }); + } + }); + } + + public void attemptAddTickets(final int accountId, final BonusClientData client, final int tickets, final Callback callback) + { + if (client.getTickets() + tickets < 0) + callback.run(false); + + Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + try + { + DSLContext create = DSL.using(DBPool.ACCOUNT, 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(); + + Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + client.setTickets(newTickets); + callback.run(true); + } + }); + } + catch (Exception e) + { + e.printStackTrace(); + callback.run(false); + } + } + }); + } + + public void attemptDailyBonus(final Player player, final Callback result) + { + final int accountId = _manager.getClientManager().Get(player).getAccountId(); + final int coins = 0; + final int gems = 0; + /* + * if (coins == 0 && gems == 0) { result.accept(false); return; } + */ + final JavaPlugin plug = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() + { + @Override + public void run() + { + try (Connection connection = getConnection(); + CallableStatement callableStatement = connection.prepareCall("{call check_daily(?, ?, ?, ?, ?)}")) + { + callableStatement.setInt(1, accountId); + callableStatement.setInt(2, coins); + callableStatement.setInt(3, gems); + callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN); + callableStatement.registerOutParameter(5, java.sql.Types.TIMESTAMP); + + callableStatement.executeUpdate(); + + final boolean pass = callableStatement.getBoolean(4); + + final Timestamp timeStamp = callableStatement.getTimestamp(5); + + Bukkit.getScheduler().runTask(plug, new Runnable() + { + @Override + public void run() + { + + if (pass) + { + _manager.Get(player).setDailyTime(new Timestamp(BonusManager.getSqlTime())); + result.run(true); + } + else + { + Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 10, false, false); + _manager.Get(player).setDailyTime(timeStamp); + result.run(false); + } + } + }); + } + catch (Exception e) + { + Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false); + e.printStackTrace(); + result.run(false); + } + } + }); + } + + @Deprecated + public void giveTickets(final Player player, final Callback result) + { + final int accountId = _manager.getClientManager().Get(player).getAccountId(); + + Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + final int newTickets = jooq().update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.sub(-1)). + where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets(); + + Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + + + } + }); + + } + }); + } + + public void attemptRankBonus(final Player player, final Callback result) + { + if (!Recharge.Instance.usable(player, "AttemptRankBonus")) { + result.run(false); + return; + } + final int accountId = _manager.getClientManager().Get(player).getAccountId(); + final int coins = _manager.getRankBonusAmount(player).getCoins(); + + if (coins == 0/* && gems == 0 */) { + result.run(false); + return; + } + + final JavaPlugin plug = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() { + + @Override + public void run() + { + + try (Connection connection = getConnection(); + CallableStatement callableStatement = connection.prepareCall("{call check_rank(?, ?, ?, ?, ?)}")) { + callableStatement.setInt(1, accountId); + callableStatement.setInt(2, coins); + callableStatement.setInt(3, 0); + callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN); + callableStatement.registerOutParameter(5, java.sql.Types.DATE); + + callableStatement.executeUpdate(); + + final boolean pass = callableStatement.getBoolean(4); + + final Date date = callableStatement.getDate(5); + + Bukkit.getScheduler().runTask(plug, new Runnable() { + + @Override + public void run() + { + _manager.Get(player).setRankTime(date); + + if (pass) + { + result.run(true); + } + else + { + Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 10, false, false); + result.run(false); + } + } + }); + } catch (Exception e) { + Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false); + e.printStackTrace(); + result.run(false); + } + } + }); + } + + public void attemptVoteBonus(final int accountId, final Callback> result) + { + final int coins = 0; + final int gems = 0; + + final JavaPlugin plug = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() { + + @Override + public void run() + { + + try (Connection connection = getConnection(); + CallableStatement callableStatement = connection.prepareCall("{call check_vote(?, ?, ?, ?, ?)}")) { + callableStatement.setInt(1, accountId); + callableStatement.setInt(2, coins); + callableStatement.setInt(3, gems); + callableStatement.registerOutParameter(4, Types.BOOLEAN); + callableStatement.registerOutParameter(5, Types.DATE); + + callableStatement.executeUpdate(); + + final boolean pass = callableStatement.getBoolean(4); + final Date date = callableStatement.getDate(5); + + Bukkit.getScheduler().runTask(plug, new Runnable() { + + @Override + public void run() + { +// _manager.Get(player).setVoteTime(date); + result.run(Pair.create(pass, date)); + } + }); + } catch (Exception e) { + e.printStackTrace(); + result.run(null); + } + } + }); + } + + public void getTimeOffset(final Callback callback) + { + final long startTime = System.currentTimeMillis(); + final Plugin plugin = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() + { + executeQuery("SELECT CURRENT_TIMESTAMP", new ResultSetCallable() { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + resultSet.next(); + + long theirTimeUnadjusted = resultSet.getTimestamp(1).getTime(); + + long ourCurrentTime = System.currentTimeMillis(); + + long latencyOffset = (ourCurrentTime - startTime) / 2; + + long theirTime = theirTimeUnadjusted - latencyOffset; + + final long offSet = theirTime - ourCurrentTime; + + Bukkit.getScheduler().runTask(plugin, new Runnable() { + @Override + public void run() + { + callback.run(offSet); + } + }); + } + }); + } + }); + } + + public void getClientData(final int accountId, final Callback callback) + { + String query = "SELECT * FROM bonus WHERE accountId = '" + accountId + "';"; + + executeQuery(query, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + BonusClientData clientData = loadData(accountId, resultSet); + callback.run(clientData); + } + }); + } + + public void saveStreak(int accountId, BonusClientData clientData) + { + jooq().update(Tables.bonus).set(Tables.bonus.dailyStreak, clientData.getDailyStreak()) + .set(Tables.bonus.maxDailyStreak, clientData.getMaxDailyStreak()) + .set(Tables.bonus.voteStreak, clientData.getVoteStreak()) + .set(Tables.bonus.maxVoteStreak, clientData.getMaxVoteStreak()) + .where(Tables.bonus.accountId.eq(accountId)).execute(); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE_BONUS_TABLE); + } + + @Override + protected void update() + { + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java new file mode 100644 index 000000000..1aa07d0d5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java @@ -0,0 +1,50 @@ +package mineplex.core.bonuses; + +import java.util.UUID; + +public class GiveDonorData +{ + private String _playerName; + private int _accountId; + private UUID _uuid; + private int _giveAmount; + private int _attempts; + + public GiveDonorData(String playerName, int accountId, UUID uuid, int giveAmount) + { + _playerName = playerName; + _accountId = accountId; + _uuid = uuid; + _giveAmount = giveAmount; + } + + public String getPlayerName() + { + return _playerName; + } + + public int getAccountId() + { + return _accountId; + } + + public UUID getUuid() + { + return _uuid; + } + + public int getGiveAmount() + { + return _giveAmount; + } + + public int getAttempts() + { + return _attempts; + } + + public void incrementAttempts() + { + _attempts++; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/StreakRecord.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/StreakRecord.java new file mode 100644 index 000000000..7757a2c8c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/StreakRecord.java @@ -0,0 +1,23 @@ +package mineplex.core.bonuses; + +public class StreakRecord +{ + private String _playerName; + private int _streak; + + public StreakRecord(String playerName, int streak) + { + _playerName = playerName; + _streak = streak; + } + + public String getPlayerName() + { + return _playerName; + } + + public int getStreak() + { + return _streak; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java new file mode 100644 index 000000000..4cc2ac529 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java @@ -0,0 +1,290 @@ +package mineplex.core.bonuses.animations; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Random; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.treasure.animation.Animation; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class AnimationCarl extends Animation +{ + private boolean _isDone; + private Block _creeper; + private Object _type; + private Player _player; + + private HashSet _items = new HashSet(); + + public AnimationCarl(Entity creeper) + { + _creeper = creeper.getLocation().getBlock(); + } + + @Override + protected void tick() + { + if(_type instanceof String) + { + if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL")) + { + for (int i = 50; i < 60; i++) + { + Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i)); + Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + _items.add(gem); + _items.add(coin); + + Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); + UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false); + UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false); + + } + } + if(((String) _type).contentEquals("RANK")) + { + for (int i = 50; i < 60; i++) + { + Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + _items.add(coin); + + Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d)); + UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false); + + } + } + if(!((String) _type).contentEquals("DAILY")&& !((String) _type).contentEquals("RANK")&& !((String) _type).contentEquals("POLL")) + { + + Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64)); + _items.add(paper); + + Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d)); + UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false); + + for (int i = 50; i < 60; i++) + { + Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i)); + _items.add(gem); + + Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d)); + UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false); + + } + } + finish(); + } + if(_type instanceof Reward) + { + if(getTicks() == 0) + { + RewardData rewardData = ((Reward)_type).getFakeRewardData(_player); + ItemStack itemStack = rewardData.getDisplayItem(); + Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack); + _items.add(item); + + Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ()); + + UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false); + } + + if(((Reward)_type).getRarity() == RewardRarity.RARE) + { + RareAnimation(); + } + else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY) + { + LegendAnimation(); + } + else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL) + { + MythicalAnimation(); + } + else + { + finish(); + } + } + } + + @Override + protected void onFinish() { + _isDone = true; + setTicks(0); + } + + public boolean isDone() + { + return _isDone; + } + + public void setDone(boolean b) + { + _isDone = b; + } + + public void setType(Object type) + { + _type = type; + } + + public void setPlayer(Player player) + { + _player = player; + } + + public void LegendAnimation() + { + if (getTicks() < 1) + { + UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true); + } + + if (getTicks() == 1) + { + _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F); + } + else if (getTicks() < 35) + { + double radius = 2 - (getTicks() / 10D * 2); + int particleAmount = 20 - (getTicks() * 2); + Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5); + 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; + for(double e = 0.1 ; e < 3 ; e += 0.6) + { + Location location = _centerLocation.clone().add(xDiff, e, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + else + { + finish(); + } + } + + public void MythicalAnimation() + { + if (getTicks() < 30) + { + UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true); + } + + if (getTicks() == 1) + { + _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F); + _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F); + } + else if (getTicks() < 40) + { + UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true, + new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1); + + //Particle Spiral Up + double radius = getTicks() / 20D; + int particleAmount = getTicks() / 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 location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + + Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5); + 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; + for(double e = 0.1 ; e < 3 ; e += 0.5) + { + Location location = _centerLocation.clone().add(xDiff, e, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + else + { + finish(); + } + } + + public void RareAnimation() + { + if (getTicks() == 1) + { + for(int i = 0; i < 3; i++) + { + UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false); + } + _creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F); + } + else if (getTicks() >= 60) + { + finish(); + } + + else if (getTicks() < 35) + { + double radius = 2 - (getTicks() / 10D * 2); + int particleAmount = 20 - (getTicks() * 2); + Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5); + 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; + for(double e = 0.1 ; e < 3 ; e += 0.6) + { + Location location = _centerLocation.clone().add(xDiff, e, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + } + + public void itemClean() + { + Iterator itemIterator = _items.iterator(); + + while (itemIterator.hasNext()) + { + Item item = itemIterator.next(); + + if (item.isOnGround() || !item.isValid() || item.getTicksLived() > 60) + { + item.remove(); + itemIterator.remove(); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java new file mode 100644 index 000000000..f3b20f8f8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java @@ -0,0 +1,34 @@ +package mineplex.core.bonuses.commands; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.reward.RewardType; +import mineplex.core.bonuses.BonusManager; + +public class AnimationCommand extends CommandBase{ + + private BonusManager _plugin; + + public AnimationCommand(BonusManager plugin) + { + super(plugin, Rank.DEVELOPER, "animation"); + _plugin = plugin; + } + + @Override + public void Execute(Player caller, String[] args) + { + caller = Bukkit.getPlayer(args[0]); + _plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true)); + + if (args.length >= 2) + { + _plugin.addPendingExplosion(caller, args[1]); + } + + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java new file mode 100644 index 000000000..ccc55a251 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java @@ -0,0 +1,23 @@ +package mineplex.core.bonuses.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.gui.BonusGui; + +public class GuiCommand extends CommandBase{ + + public GuiCommand(BonusManager plugin) + { + super(plugin, Rank.DEVELOPER, "bonus"); + } + + @Override + public void Execute(Player caller, String[] args) + { + new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager()).openInventory(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java new file mode 100644 index 000000000..307a57427 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java @@ -0,0 +1,68 @@ +package mineplex.core.bonuses.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.bonuses.BonusManager; + +import org.bukkit.entity.Player; + +public class TicketCommand extends CommandBase +{ + public TicketCommand(BonusManager plugin) + { + super(plugin, Rank.ADMIN, "ticket"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main("Carl", "Missing Args: " + F.elem("/ticket "))); + return; + } + + final String targetName = args[0]; + final String ticketString = args[1]; + Player target = UtilPlayer.searchExact(targetName); + + + rewardTickets(caller, target, target.getName(), ticketString); + } + + private void rewardTickets(final Player caller, final Player target, final String targetName, String ticketString) + { + try + { + final int tickets = Integer.parseInt(ticketString); + int accountId = Plugin.getClientManager().getAccountId(target); + Plugin.getRepository().attemptAddTickets(accountId, Plugin.Get(target), tickets, new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + ".")); + + if (target != null && !target.equals(caller)) + { + UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + ".")); + } + } + else + { + UtilPlayer.message(caller, F.main("Carl", "Failed to give tickets. Try again later!")); + } + } + }); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main("Carl", "Invalid Ticket Amount")); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/event/CarlSpinnerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/event/CarlSpinnerEvent.java new file mode 100644 index 000000000..a07e1770e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/event/CarlSpinnerEvent.java @@ -0,0 +1,54 @@ +package mineplex.core.bonuses.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Called when a player attempts to purchase a spin through carl + */ +public class CarlSpinnerEvent extends Event implements Cancellable +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private boolean _cancelled; + + public CarlSpinnerEvent(Player player) + { + _player = player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Player getPlayer() + { + return _player; + } + + public void setPlayer(Player player) + { + _player = player; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean b) + { + _cancelled = b; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java new file mode 100644 index 000000000..8306c84d5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -0,0 +1,42 @@ +package mineplex.core.bonuses.gui; + +import mineplex.core.gui.SimpleGui; +import mineplex.core.reward.RewardManager; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.gui.buttons.CarlSpinButton; +import mineplex.core.bonuses.gui.buttons.DailyBonusButton; +import mineplex.core.bonuses.gui.buttons.PollButton; +import mineplex.core.bonuses.gui.buttons.RankBonusButton; +import mineplex.core.bonuses.gui.buttons.VoteButton; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public class BonusGui extends SimpleGui +{ + + private BonusManager manager; + + public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager) + { + super(plugin, player, player.getName() + "'s Bonuses", 5 * 9); + + this.manager = manager; + + setItem(10, new VoteButton(plugin, player, this, manager)); + + setItem(12, new RankBonusButton(getPlugin(), player, this, manager)); + + setItem(14, new DailyBonusButton(getPlugin(), player, this, manager)); + + setItem(16, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager)); + + setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); + } + + @Override + protected void finalize() throws Throwable + { + super.finalize(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java new file mode 100644 index 000000000..779c9e431 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java @@ -0,0 +1,280 @@ +package mineplex.core.bonuses.gui; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gui.DisplayItem; +import mineplex.core.gui.SimpleGui; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardManager; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.gui.buttons.RewardButton; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class SpinGui extends SimpleGui +{ + private static final int HOPPER_SLOT = 4; + private static final int CARL_SLOT = 22; + private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ }; + + private int _tickCount; + private RewardData _rewardData; + private Reward _reward; + private BonusManager _manager; + private int _currentRewardIndex; + private int _ticksThisSwap; + private int _ticksPerSwap; + private int _swapCount; + private Reward[] _rewards; + private boolean _stopped; + private boolean _rewarded; + private ArrayList _ticks; + private int _frame; + private float _pitch; + private int _stopSpinnerAt; + + public SpinGui(Plugin plugin, Player player, RewardManager rewardManager, BonusManager manager) + { + super(plugin, player, "Carl's Spinner", 27); + + _manager = manager; + + ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false); + + setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER))); + //setItem(CARL_SLOT, new DisplayItem(carlItem)); + + + _ticks = new ArrayList<>(); + _frame = 0; + _pitch = 1; + + + + _ticksPerSwap = 1; + + for (int i=0 ; i<40 ; i++) + _ticks.add(1); + + for (int i=0 ; i<20 ; i++) + _ticks.add(2); + + for (int i=0 ; i<10 ; i++) + _ticks.add(4); + + for (int i=0 ; i<4 ; i++) + _ticks.add(6); + + for (int i=0 ; i<3 ; i++) + _ticks.add(8); + + if (Math.random() > 0.5) + { + _ticks.add(12); + } + + _stopSpinnerAt = _ticks.size(); + + //Create Rewards + _rewards = new Reward[_stopSpinnerAt+10]; //Adding 10, so theres items to the right still. + for (int i = 0; i < _stopSpinnerAt+10 ; i++) + { + if (i != _stopSpinnerAt + 4) + { + _rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerFiller, true); + } + else + { + _rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerReal, true); + _reward = _rewards[i]; + } + } + + _rewardData = _reward.giveReward("Carls Spinner", getPlayer()); + } + + private void tick() + { + + if(_stopped) + return; + + _ticksThisSwap++; + + // Swap + if (_ticksThisSwap >= _ticksPerSwap) + { + _ticksThisSwap = 0; + _swapCount++; + + if(_pitch == 1) + _pitch = (float) 1.5; + else if(_pitch == 1.5) + _pitch = 2; + else if(_pitch == 2) + _pitch = 1; + + getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch); + + _currentRewardIndex++; + + updateGui(); + + // Slow + _ticksPerSwap = _ticks.get(_currentRewardIndex - 1); + + if(_currentRewardIndex == _stopSpinnerAt) + _stopped = true; + } + + _tickCount++; + } + + public void updateGui() + { + for (int i = 0; i < 9; i++) + { + int index = _currentRewardIndex + i; + + int slot = 9 + i; + RewardData data = _rewards[index].getFakeRewardData(getPlayer()); + setItem(slot, new RewardButton(data)); + + // Glass Panes + for (int j = 0; j < LINE_NUMS.length; j++) + { + int paneSlot = slot + LINE_NUMS[j]; + if (paneSlot == HOPPER_SLOT) + continue; + + setItem(paneSlot, new DisplayItem(data.getRarity().getItemStack())); + } + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + tick(); + checkIfDone(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void close(InventoryCloseEvent event) + { + if(_rewarded) + return; + + if(event.getPlayer() != getPlayer()) + return; + + _manager.addPendingExplosion(getPlayer(), _reward); + + if (_reward.getRarity() == RewardRarity.RARE) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.LEGENDARY) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.MYTHICAL) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + } + + @EventHandler + public void Glass(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if(!_stopped) + return; + + if(!_rewarded) + return; + + if(_frame == 0) + { + setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack())); + _frame++; + } + else if(_frame < 5) + { + setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + + setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + + setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + _frame++; + } + if(_frame == 6) + { + + } + } + + public void checkIfDone() + { + if(!_stopped) + return; + + if(_rewarded) + return; + + _manager.addPendingExplosion(getPlayer(), _reward); + if (_reward.getRarity() == RewardRarity.RARE) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.LEGENDARY) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.MYTHICAL) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + ItemStack item = getInventory().getItem(13); + getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName())); + _rewarded = true; + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/CarlSpinButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/CarlSpinButton.java new file mode 100644 index 000000000..006135c5d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/CarlSpinButton.java @@ -0,0 +1,85 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.reward.RewardManager; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; + +public class CarlSpinButton implements GuiItem +{ + private Plugin _plugin; + private Player _player; + private BonusManager _bonusManager; + private RewardManager _rewardManager; + + public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, RewardManager rewardManager) + { + _plugin = plugin; + _player = player; + _bonusManager = bonusManager; + _rewardManager = rewardManager; + } + + @Override + public void setup() + { + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + BonusClientData client = _bonusManager.Get(_player); + int tickets = client.getTickets(); + + if (tickets > 0) + { + _bonusManager.attemptCarlSpin(_player); + } + +// new SpinGui(_plugin, _player, _rewardManager).openInventory(); + } + + @Override + public ItemStack getObject() + { + BonusClientData client = _bonusManager.Get(_player); + int tickets = client.getTickets(); + + String name = (tickets > 0 ? C.cGreen : C.cRed) + C.Bold + "Carl's Spinner"; + ArrayList lore = new ArrayList(); + Material material = Material.SKULL_ITEM; + byte data = (byte) 4; + + lore.add(" "); + if (tickets > 0) + { + lore.add(ChatColor.RESET + "Click to Spin"); + } + else + { + lore.add(ChatColor.RESET + "You need a Carl Spin Ticket to Spin"); + } + + lore.add(" "); + lore.add(ChatColor.YELLOW + "Your Tickets: " + C.cWhite + tickets); + + return new ShopItem(material, data, name, lore.toArray(new String[0]), 1, false, false); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java new file mode 100644 index 000000000..0c2ea37d2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java @@ -0,0 +1,211 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.ItemRefresher; +import mineplex.core.gui.pages.LoadingWindow; +import mineplex.core.gui.pages.TimedMessageWindow; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.StreakRecord; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class DailyBonusButton implements GuiItem, Listener +{ + + private ItemStack _item; + + private Player _player; + private Plugin _plugin; + private ItemRefresher _gui; + + private BonusManager _bonusManager; + + public DailyBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager) + { + this._bonusManager = bonusManager; + this._player = player; + this._plugin = plugin; + this._gui = gui; + } + + @Override + public void setup() + { + Bukkit.getPluginManager().registerEvents(this, getPlugin()); + setItem(); + } + + @Override + public void close() + { + HandlerList.unregisterAll(this); + } + + @Override + public void click(ClickType clickType) + { + if (isAvailable()) { + _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); + refreshItem(); + new LoadingWindow(getPlugin(), getPlayer(), 6*9); + _bonusManager.attemptDailyBonus(getPlayer(), _bonusManager.getDailyBonusAmount(_player), new Callback() { + @Override + public void run(Boolean t) + { + if (t) { + + setItem(); + + if (getPlayer().getOpenInventory() != null) { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6*9, 20*3, getGui()).openInventory(); + } else { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!")); + } + _bonusManager.addPendingExplosion(getPlayer(), "DAILY"); + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + } else { + if (getPlayer().getOpenInventory() != null) { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6*9, 20*3, getGui()).openInventory(); + } else { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!")); + } + getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10); + } + getPlayer().closeInventory(); + } + }); + } else + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10); + return; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + return; +// refreshItem(); // Todo Unnecessary? + } + + private void setItem() + { + ArrayList lore = new ArrayList(); + Material material; + String itemName; + byte data = 0; + + if (isAvailable()) + { + material = Material.CHEST; + itemName = C.cGreen + C.Bold + "Daily Reward"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Click to Claim!"); + } + else + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + C.Bold + "Daily Reward"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!"); + } + + lore.add(" "); + + BonusClientData client = _bonusManager.Get(_player); + + BonusAmount bonusAmount = _bonusManager.getDailyBonusAmount(_player); + bonusAmount.addLore(lore); + lore.add(" "); + + lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getDailyStreak()); + lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + _bonusManager.getDailyMultiplier(_player) + "%"); + lore.add(" "); + lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak()); + + if (client.getDailyTime() != null) + { + long lastBonus = _bonusManager.getLocalTime(client.getDailyTime().getTime()); + long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME); + + if (timeLeft > 0) + { + lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT)); + } + } + + StreakRecord streakRecord = _bonusManager.getDailyStreak(); + if (streakRecord != null) + { + lore.add(" "); + lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName()); + lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak()); + } + + + _item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false); + } + + @Override + public ItemStack getObject() + { + return _item; + } + + public void refreshItem() + { + getGui().refreshItem(this); + } + + public long timeLeft() + { + long timeLeft = _bonusManager.nextDailyBonus(getPlayer()) - System.currentTimeMillis(); + return timeLeft; + } + + public boolean isAvailable() + { + return (timeLeft() <= 0); + } + + public Plugin getPlugin() + { + return _plugin; + } + + public Player getPlayer() + { + return _player; + } + + public ItemRefresher getGui() + { + return _gui; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java new file mode 100644 index 000000000..dfb707a05 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java @@ -0,0 +1,219 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; +import java.util.HashMap; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilText; +import mineplex.core.gui.GuiInventory; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.SimpleGui; +import mineplex.core.gui.SimpleGuiItem; +import mineplex.core.gui.botton.BackBotton; +import mineplex.core.gui.pages.TimedMessageWindow; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.poll.Poll; +import mineplex.core.poll.PollManager; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class PollButton extends SimpleGui implements GuiItem { + + protected boolean _create; + + private PollManager _pollManager; + private BonusManager _bonusManager; + private CoreClientManager _clientManager; + private GuiInventory _master; + + private HashMap hard = new HashMap(); + + private Poll _poll; + + public PollButton(Plugin plugin, Player player, PollManager pollManager, CoreClientManager clientManager, GuiInventory master, BonusManager bonusManager) + { + super(plugin, player, "Poll:", 6 * 9); + this._create = true; + this._master = master; + this._clientManager = clientManager; + this._pollManager = pollManager; + hard.put(0, new BackBotton(master)); + _bonusManager = bonusManager; + } + + @Override + public void setup() + { + if (_create) + { + this._poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).GetRank()); + + if (_poll != null) + { + + setItem(13, getQuestionItem(_poll.getQuestion())); + + int[] slots = even(9, _poll.getAnswers().length); + + for (int i = 0; i < slots.length; i++) + { + AnswerItem item = new AnswerItem(_poll, i); + setItem(9 * 3 + slots[i], item); + } + } + } + } + + @Override + public ItemStack getObject() + { + ArrayList lore = new ArrayList<>(); + if (_poll == null) + { + lore.add(""); + lore.add(C.cWhite + "You've voted on all of the polls!"); + return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, ChatColor.RED + C.Bold + "Vote on Poll", lore); + } + else + { + lore.add(""); + lore.add(C.cWhite + _poll.getQuestion()); + lore.add(""); + int i = 1; + for(String str : _poll.getAnswers()) + { + lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str); + i++; + } + lore.add(""); + BonusAmount amount = new BonusAmount(); + amount.setCoins(_poll.getCoinReward()); + amount.setGems(_poll.getCoinReward()); + amount.addLore(lore); +// lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems"); + lore.add(""); + lore.add(C.cGreen + "Click to go to the vote page!"); + return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore); + } + } + + @Override + public void click(ClickType clickType) + { + if (_poll == null) + { + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f); + } + else + { + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + openInventory(); + } + } + + public GuiItem getQuestionItem(String question) + { + + ArrayList lore = new ArrayList<>(); + lore.add(""); + for (String string : wrap(question)) + lore.add(C.cWhite + string); + lore.add(""); + int i = 1; + for(String str : _poll.getAnswers()) + { + lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str); + i++; + } + lore.add(""); + BonusAmount amount = new BonusAmount(); + amount.setCoins(_poll.getCoinReward()); + amount.setGems(_poll.getCoinReward()); + amount.addLore(lore); + + return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + C.cGreen + C.Bold + "Vote on Poll", + lore)); + } + + public static String[] wrap(String text) + { + return UtilText.wrap(text, 40); + } + + public static int[] even(int size, int amount) + { + int[] list = new int[amount]; + + float interval = (size / amount); + float offset = -(interval / 2); + + for (int i = 1; i <= amount; i++) + { + list[i - 1] = (int) (Math.ceil(i * interval) + offset); + } + return list; + } + + public Poll getPoll() + { + return _poll; + } + + public GuiInventory getMaster() + { + return _master; + } + + private class AnswerItem implements GuiItem + { + + private int num; + + private AnswerItem(Poll poll, int num) + { + this.num = num; + } + + @Override + public ItemStack getObject() + { + ArrayList lore = new ArrayList<>(); + lore.add(""); + lore.add(C.cWhite + getPoll().getAnswers()[num]); + return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore); + } + + @Override + public void click(ClickType clickType) + { + _create = true; + + _pollManager.answerPoll(getPlayer(), _poll, num + 1); + + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory(); + _bonusManager.addPendingExplosion(getPlayer(), "POLL"); + getPlayer().closeInventory(); + } + + @Override + public void setup() {} + + @Override + public void close() {} + + } + + @Override + public void close() {} +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java new file mode 100644 index 000000000..5fe0fc0f0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java @@ -0,0 +1,242 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.ItemRefresher; +import mineplex.core.gui.pages.LoadingWindow; +import mineplex.core.gui.pages.TimedMessageWindow; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusManager; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class RankBonusButton implements GuiItem, Listener { + + private boolean hasRank; + + private ItemStack _item; + + private Player _player; + private Plugin _plugin; + private ItemRefresher _gui; + + private BonusManager _bonusManager; + + public RankBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager) + { + this._bonusManager = bonusManager; + this._player = player; + this._plugin = plugin; + this._gui = gui; + } + + @Override + public void setup() + { + if (_bonusManager.getRankBonusAmount(getPlayer()).isGreaterThanZero()) + { + this.hasRank = true; + Bukkit.getPluginManager().registerEvents(this, getPlugin()); + } + else + { + this.hasRank = false; + } + + setItem(); + } + + @Override + public void close() + { + HandlerList.unregisterAll(this); + } + + + @Override + public void click(ClickType clickType) + { + if (isAvailable() && _bonusManager.isPastAugust()) { + _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); + refreshItem(); + new LoadingWindow(getPlugin(), getPlayer(), 6*9); + _bonusManager.attemptRankBonus(getPlayer(), new Callback() + { + @Override + public void run(Boolean t) + { + setItem(); + + if (t) + { + if (getPlayer().getOpenInventory() != null) + { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6 * 9, 20 * 3, getGui()).openInventory(); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!")); + } + _bonusManager.addPendingExplosion(getPlayer(), "RANK"); + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + } + else + { + if (getPlayer().getOpenInventory() != null) + { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6 * 9, 20 * 3, getGui()).openInventory(); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!")); + } + getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10); + } + getPlayer().closeInventory(); + } + }); + } else + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10); + return; + + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + return; +// refreshItem(); // Todo Unnecessary? + } + + @Override + public ItemStack getObject() + { + return _item; + } + + private void setItem() + { + ArrayList lore = new ArrayList(); + Material material; + String itemName; + byte data = 0; + + if (_bonusManager.isPastAugust()) + { + if (!hasRank) + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus"; + lore.add(" "); + lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!"); + lore.add(ChatColor.WHITE + ""); + lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly"); + lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly"); + lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly"); + lore.add(ChatColor.WHITE + ""); + lore.add(ChatColor.WHITE + "Purchase a Rank at;"); + lore.add(ChatColor.WHITE + "www.mineplex.com/shop"); + } + else + { + if (isAvailable()) + { + material = Material.ENDER_CHEST; + itemName = C.cGreen + C.Bold + "Rank Monthly Bonus"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Click to Claim!"); + } + else + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + C.Bold + "Rank Monthly Bonus"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!"); + } + + lore.add(" "); + lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name); + BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player); + bonusAmount.addLore(lore); + } + } + else + { + itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus"; + material = Material.REDSTONE_BLOCK; + lore.add(" "); + lore.add(ChatColor.RESET + "You can claim your Monthly Bonus"); + lore.add(ChatColor.RESET + "here, starting from September!"); + } + + + _item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false); + } + + public void refreshItem() + { + _gui.refreshItem(this); + } + + public long timeLeft() + { + return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis(); + } + + public boolean isAvailable() + { + if (!hasRank) + { + UtilPlayer.message(getPlayer(), "----------------------------------------"); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "Purchase a Rank at the Mineplex Shop:"); + UtilPlayer.message(getPlayer(), C.cGreen + "www.mineplex.com/shop"); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "----------------------------------------"); + + getPlayer().closeInventory(); + return false; + } + return (timeLeft() <= 0); + } + + public Plugin getPlugin() + { + return _plugin; + } + + public Player getPlayer() + { + return _player; + } + + public ItemRefresher getGui() + { + return _gui; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RewardButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RewardButton.java new file mode 100644 index 000000000..73ff6c9cc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RewardButton.java @@ -0,0 +1,46 @@ +package mineplex.core.bonuses.gui.buttons; + +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.gui.GuiItem; +import mineplex.core.reward.RewardData; + +public class RewardButton implements GuiItem +{ + private RewardData _data; + + public RewardButton(RewardData data) + { + _data = data; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + // Do nothing + } + + @Override + public ItemStack getObject() + { + ItemStack stack = _data.getDisplayItem(); + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(_data.getFriendlyName()); + stack.setItemMeta(meta); + return stack; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java new file mode 100644 index 000000000..b2d46d294 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java @@ -0,0 +1,186 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.ItemRefresher; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.StreakRecord; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class VoteButton implements GuiItem, Listener { + + private ItemStack _item; + + private String _url; + + private Player _player; + private Plugin _plugin; + private ItemRefresher _gui; + + private BonusManager _bonusManager; + + public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager) + { + this._bonusManager = bonusManager; + this._player = player; + this._plugin = plugin; + this._gui = gui; + } + + @Override + public void setup() + { + //TODO get url from db + _url = _bonusManager.getVoteLink(); + + setItem(); + Bukkit.getPluginManager().registerEvents(this, getPlugin()); + } + + @Override + public void close() + { + HandlerList.unregisterAll(this); + } + + @Override + public void click(ClickType clickType) + { + if (isAvailable()) + { + getPlayer().closeInventory(); + + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + + UtilPlayer.message(getPlayer(), "----------------------------------------------------"); + UtilPlayer.message(getPlayer(), ""); + + new JsonMessage("Click to Open in Web Browser").click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer()); + new JsonMessage(C.cGreen + _url).click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer()); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "Please be patient, votes may take a few minutes to register."); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "----------------------------------------------------"); + + getPlayer().closeInventory(); + + } + else + { + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10); + } + } + + @Override + public ItemStack getObject() + { + return _item; + } + + private void setItem() + { + ArrayList lore = new ArrayList(); + Material material; + String itemName; + byte data = 0; + + if (isAvailable()) + { + material = Material.JUKEBOX; + itemName = C.cGreen + C.Bold + "Vote for Mineplex"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Click to Vote!"); + } + else + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + C.Bold + "Vote for Mineplex"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Next vote in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!"); + } + + lore.add(" "); + + BonusClientData client = _bonusManager.Get(_player); + + BonusAmount bonusAmount = _bonusManager.getVoteBonusAmount(_player); + bonusAmount.addLore(lore); + lore.add(" "); + + lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak()); + lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplyer(client.getVoteStreak()) + "%"); + if (client.getVoteTime() != null) + { + long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime()); + long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); + + if (timeLeft > 0) + { + lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT)); + } + } + + lore.add(" "); + lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak()); + + StreakRecord streakRecord = _bonusManager.getVoteStreak(); + if (streakRecord != null) + { + lore.add(" "); + lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName()); + lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak()); + } + + _item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false); + } + + public long timeLeft() + { + return _bonusManager.nextVoteTime(getPlayer()) - System.currentTimeMillis(); + } + + public boolean isAvailable() + { + if (_url == null) + return false; + + return (timeLeft() <= 0); + } + + public Plugin getPlugin() + { + return _plugin; + } + + public Player getPlayer() + { + return _player; + } + + public ItemRefresher getGui() + { + return _gui; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java new file mode 100644 index 000000000..54f2a820b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java @@ -0,0 +1,31 @@ +package mineplex.core.bonuses.redis; + +import org.bukkit.entity.Player; + +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.UtilPlayer; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; + +public class VoteHandler implements CommandCallback +{ + private BonusManager _bonusManager; + + public VoteHandler(BonusManager bonusManager) + { + _bonusManager = bonusManager; + } + + @Override + public void run(ServerCommand command) + { + VotifierCommand v = ((VotifierCommand) command); + + Player player = UtilPlayer.searchExact(v.getPlayerName()); + + if (player != null) + { + _bonusManager.handleVote(player, v.getGemsReceived()); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java new file mode 100644 index 000000000..95dbb06a4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java @@ -0,0 +1,28 @@ +package mineplex.core.bonuses.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class VotifierCommand extends ServerCommand +{ + private String _playerName; + private int _gemsReceived; + + public VotifierCommand(String playerName, int gemsReceived, String... targetServer) + { + super(targetServer); + + _playerName = playerName; + _gemsReceived = gemsReceived; + } + + public String getPlayerName() + { + return _playerName; + } + + public int getGemsReceived() + { + return _gemsReceived; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java new file mode 100644 index 000000000..a977b3685 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java @@ -0,0 +1,164 @@ +package mineplex.core.botspam; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.message.PrivateMessageEvent; +import mineplex.core.punish.Category; +import mineplex.core.punish.Punish; +import mineplex.core.botspam.command.BotSpamCommand; +import mineplex.core.botspam.repository.BotSpamRepository; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class BotSpamManager extends MiniPlugin +{ + private Punish _punish; + private CoreClientManager _clientManager; + private BotSpamRepository _repository; + private volatile ArrayList _spam = new ArrayList(); + + public BotSpamManager(JavaPlugin plugin, CoreClientManager clientManager, Punish punish) + { + super("SpamBot Manager", plugin); + + _punish = punish; + _clientManager = clientManager; + _repository = new BotSpamRepository(plugin); + _spam = _repository.getSpamText(); + } + + @EventHandler + public void onPrivateMessage(PrivateMessageEvent event) + { + Player recipient = event.getRecipient(); + // Ignore messages sent to staff members + if (_clientManager.hasRank(recipient, Rank.HELPER)) + return; + + for (SpamText spamText : _spam) + { + if (spamText.isEnabled() && spamText.isSpam(event.getMessage())) + { + punishBot(event.getSender(), spamText); + event.setCancelled(true); + return; + } + } + } + + public void punishBot(Player player, final SpamText botText) + { + _punish.AddPunishment(player.getName(), Category.Other, "Bot Spam #" + botText.getId(), "Chiss", 1, true, -1, true); + + // Update bot text count + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.addPunishment(botText); + } + }); + } + + public void addSpamText(final String caller, final String text, final Runnable callback) + { + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.addSpamText(caller, text); + _spam = _repository.getSpamText(); + + if (callback != null) + runSync(callback); + } + }); + } + + public void enableSpamText(final String caller, final SpamText spamText, final Runnable callback) + { + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.enableSpamText(caller, spamText); + + runSync(new Runnable() + { + @Override + public void run() + { + spamText.setEnabled(true); + spamText.setEnabledBy(caller); + + if (callback != null) + callback.run(); + } + }); + } + }); + } + + public void disableSpamText(final String caller, final SpamText spamText, final Runnable callback) + { + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.disableSpamText(caller, spamText); + + runSync(new Runnable() + { + @Override + public void run() + { + spamText.setEnabled(false); + spamText.setDisabledBy(caller); + + if (callback != null) + callback.run(); + } + }); + } + }); + } + + public List getSpamTexts() + { + return _spam; + } + + @EventHandler + public void updateText(UpdateEvent event) + { + if (event.getType() == UpdateType.MIN_01) + { + runAsync(new Runnable() + { + @Override + public void run() + { + _spam = _repository.getSpamText(); + } + }); + } + } + + @Override + public void addCommands() + { + addCommand(new BotSpamCommand(this)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/SpamText.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/SpamText.java new file mode 100644 index 000000000..a4d466082 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/SpamText.java @@ -0,0 +1,78 @@ +package mineplex.core.botspam; + +public class SpamText +{ + private int _id; + private String _text; + private int _punishments; + private boolean _enabled; + private String _createdBy; + private String _disabledBy; + private String _enabledBy; + + public SpamText(int id, String text, int punishments, boolean enabled, String createdBy, String enabledBy, String disabledBy) + { + _id = id; + _text = text; + _punishments = punishments; + _enabled = enabled; + _createdBy = createdBy; + _enabledBy = enabledBy; + _disabledBy = disabledBy; + } + + public boolean isSpam(String message) + { + return message.toLowerCase().contains(_text.toLowerCase()); + } + + public int getId() + { + return _id; + } + + public String getText() + { + return _text; + } + + public int getPunishments() + { + return _punishments; + } + + public boolean isEnabled() + { + return _enabled; + } + + public void setEnabled(boolean enabled) + { + _enabled = enabled; + } + + public String getCreatedBy() + { + return _createdBy; + } + + public String getEnabledBy() + { + return _enabledBy; + } + + public String getDisabledBy() + { + return _disabledBy; + } + + public void setEnabledBy(String enabledBy) + { + _enabledBy = enabledBy; + } + + public void setDisabledBy(String disabledBy) + { + _disabledBy = disabledBy; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java new file mode 100644 index 000000000..d662dec7d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java @@ -0,0 +1,64 @@ +package mineplex.core.botspam.command; + +import org.bukkit.entity.Player; + +import mineplex.core.botspam.SpamText; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.botspam.BotSpamManager; + +public class BotSpamAddCommand extends CommandBase +{ + public BotSpamAddCommand(BotSpamManager plugin) + { + super(plugin, Rank.DEVELOPER, "add"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args != null && args.length >= 1) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < args.length; i++) + { + if (i > 0) sb.append(" "); + + sb.append(args[i]); + } + + final String text = sb.toString(); + + if (text.length() < 8) + { + UtilPlayer.message(caller, F.main("BotSpam", "Spam text must be at least 8 characters")); + return; + } + + for (SpamText spamText : Plugin.getSpamTexts()) + { + if (text.equalsIgnoreCase(spamText.getText())) + { + UtilPlayer.message(caller, F.main("BotSpam", "That Spam Text already exists. Type " + F.elem("/botspam list") + " to view")); + return; + } + } + + Plugin.addSpamText(caller.getName(), text, new Runnable() + { + @Override + public void run() + { + if (caller.isOnline()) + UtilPlayer.message(caller, F.main("BotSpam", "Added Spam Text: " + F.elem(text))); + } + }); + } + else + { + UtilPlayer.message(caller, F.main("BotSpam", "/botspam add ")); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java new file mode 100644 index 000000000..233939e7b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java @@ -0,0 +1,31 @@ +package mineplex.core.botspam.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.Rank; +import mineplex.core.botspam.BotSpamManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class BotSpamCommand extends MultiCommandBase +{ + public BotSpamCommand(BotSpamManager plugin) + { + super(plugin, Rank.DEVELOPER, "botban", "botspam"); + + AddCommand(new BotSpamAddCommand(Plugin)); + AddCommand(new BotSpamEnableCommand(Plugin)); + AddCommand(new BotSpamDisableCommand(Plugin)); + AddCommand(new BotSpamListCommand(Plugin)); + } + + @Override + protected void Help(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main("BotSpam", "/botspam list")); + UtilPlayer.message(caller, F.main("BotSpam", "/botspam add ")); + UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable ")); + UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable ")); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java new file mode 100644 index 000000000..e59f7c84f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java @@ -0,0 +1,71 @@ +package mineplex.core.botspam.command; + +import org.bukkit.entity.Player; + +import mineplex.core.botspam.SpamText; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.botspam.BotSpamManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class BotSpamDisableCommand extends CommandBase +{ + public BotSpamDisableCommand(BotSpamManager plugin) + { + super(plugin, Rank.DEVELOPER, "disable"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args != null && args.length == 1) + { + final int spamId; + + try + { + spamId = Integer.parseInt(args[0]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable ")); + return; + } + + SpamText text = null; + for (SpamText spamText : Plugin.getSpamTexts()) + { + if (spamText.getId() == spamId) + text = spamText; + } + + if (text == null) + { + UtilPlayer.message(caller, F.main("BotSpam", "Could not find a spam text with the id " + F.elem("" + spamId))); + return; + } + + if (!text.isEnabled()) + { + UtilPlayer.message(caller, F.main("BotSpam", "That spam text is already disabled")); + return; + } + + final SpamText finalText = text; + Plugin.disableSpamText(caller.getName(), text, new Runnable() + { + @Override + public void run() + { + UtilPlayer.message(caller, F.main("BotSpam", "Disabled Spam Text " + F.elem(finalText.getText()))); + } + }); + } + else + { + UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable ")); + } + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java new file mode 100644 index 000000000..ce0242395 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java @@ -0,0 +1,71 @@ +package mineplex.core.botspam.command; + +import org.bukkit.entity.Player; + +import mineplex.core.botspam.SpamText; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.botspam.BotSpamManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class BotSpamEnableCommand extends CommandBase +{ + public BotSpamEnableCommand(BotSpamManager plugin) + { + super(plugin, Rank.DEVELOPER, "enable"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args != null && args.length == 1) + { + final int spamId; + + try + { + spamId = Integer.parseInt(args[0]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable ")); + return; + } + + SpamText text = null; + for (SpamText spamText : Plugin.getSpamTexts()) + { + if (spamText.getId() == spamId) + text = spamText; + } + + if (text == null) + { + UtilPlayer.message(caller, F.main("BotSpam", "Could not find a spam text with the id " + F.elem("" + spamId))); + return; + } + + if (text.isEnabled()) + { + UtilPlayer.message(caller, F.main("BotSpam", "That spam text is already enabled")); + return; + } + + final SpamText finalText = text; + Plugin.enableSpamText(caller.getName(), text, new Runnable() + { + @Override + public void run() + { + UtilPlayer.message(caller, F.main("BotSpam", "Enabled Spam Text " + F.elem(finalText.getText()))); + } + }); + } + else + { + UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable ")); + } + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java new file mode 100644 index 000000000..96e71da64 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java @@ -0,0 +1,46 @@ +package mineplex.core.botspam.command; + +import org.bukkit.entity.Player; + +import mineplex.core.botspam.SpamText; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.botspam.BotSpamManager; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.HoverEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class BotSpamListCommand extends CommandBase +{ + public BotSpamListCommand(BotSpamManager plugin) + { + super(plugin, Rank.DEVELOPER, "list"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main("BotSpam", "Listing Spam Texts. Hover for more details")); + UtilPlayer.message(caller, ""); // Blank Line! + + for (SpamText spamText : Plugin.getSpamTexts()) + { + String modifyMessage = spamText.isEnabled() ? C.cRed + "Click To Disable" : C.cGreen + "Click To Enable"; + String hoverMessage = C.cYellow + "Spam Id: " + C.cWhite + spamText.getId() + "\\n" + C.cYellow + "Ban Count: " + C.cWhite + spamText.getPunishments() + "\\n" + C.cYellow + "Enabled: " + C.cWhite + spamText.isEnabled(); + hoverMessage += "\\n\\n" + C.cYellow + "Created By: " + C.cWhite + spamText.getCreatedBy(); + if (spamText.getEnabledBy() != null) + hoverMessage += "\\n" + C.cYellow + "Enabled By: " + C.cWhite + spamText.getEnabledBy(); + if (spamText.getDisabledBy() != null) + hoverMessage += "\\n" + C.cYellow + "Disabled By: " + C.cWhite + spamText.getDisabledBy(); + hoverMessage += "\\n\\n" + modifyMessage; + + JsonMessage message = new JsonMessage((spamText.isEnabled() ? "" : C.cRed) + spamText.getText()); + message.hover(HoverEvent.SHOW_TEXT, hoverMessage); + message.click(ClickEvent.RUN_COMMAND, "/botspam " + (spamText.isEnabled() ? "disable" : "enable") + " " + spamText.getId()); + message.send(JsonMessage.MessageType.SYSTEM_MESSAGE, caller); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java new file mode 100644 index 000000000..d1460fb4a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java @@ -0,0 +1,88 @@ +package mineplex.core.botspam.repository; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.botspam.SpamText; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.database.column.ColumnVarChar; + +public class BotSpamRepository extends RepositoryBase +{ + private static final String GET_SPAM_TEXT = "SELECT * FROM botSpam"; + private static final String ADD_SPAM_TEXT = "INSERT INTO botSpam (text, createdBy, enabledBy) VALUES (?, ?, ?)"; + private static final String DELETE_SPAM_TEXT = "DELETE FROM botSpam WHERE id = ?"; + private static final String ENABLE_SPAM_TEXT = "UPDATE botSpam SET enabled = 1, enabledBy = ? WHERE id = ?"; + private static final String DISABLE_SPAM_TEXT = "UPDATE botSpam SET enabled = 0 AND disabledBy = ? WHERE id = ?"; + private static final String ADD_PUNISHMENT = "UPDATE botSpam SET punishments = punishments + 1 WHERE id = ?"; + + public BotSpamRepository(JavaPlugin plugin) + { + super(plugin, DBPool.ACCOUNT); + } + + public ArrayList getSpamText() + { + final ArrayList list = new ArrayList(); + + executeQuery(GET_SPAM_TEXT, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + int id = resultSet.getInt(1); + String text = resultSet.getString(2); + int punishments = resultSet.getInt(3); + boolean enabled = resultSet.getBoolean(4); + String createdBy = resultSet.getString(5); + String enabledBy = resultSet.getString(6); + String disabledBy = resultSet.getString(7); + + list.add(new SpamText(id, text, punishments, enabled, createdBy, enabledBy, disabledBy)); + } + } + }); + + return list; + } + + public void addPunishment(SpamText text) + { + executeUpdate(ADD_PUNISHMENT, new ColumnInt("id", text.getId())); + } + + public void disableSpamText(String caller, SpamText text) + { + executeUpdate(DISABLE_SPAM_TEXT, new ColumnVarChar("disabledBy", 100, caller), new ColumnInt("id", text.getId())); + } + + public void enableSpamText(String caller, SpamText text) + { + executeUpdate(ENABLE_SPAM_TEXT, new ColumnVarChar("enabledBy", 100, caller), new ColumnInt("id", text.getId())); + } + + public void addSpamText(String caller, String spamText) + { + executeInsert(ADD_SPAM_TEXT, null, new ColumnVarChar("text", 200, spamText), new ColumnVarChar("createdBy", 100, caller), new ColumnVarChar("enabledBy", 100, caller)); + } + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 9279f5bd7..7847b0408 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -176,7 +176,7 @@ public class Chat extends MiniPlugin if (_silenced == 0) return false; - if (_clientManager.Get(player).GetRank().Has(player, Rank.MODERATOR, false)) + if (_clientManager.Get(player).GetRank().has(player, Rank.MODERATOR, false)) return false; if (_silenced == -1) @@ -210,7 +210,7 @@ public class Chat extends MiniPlugin @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN)) return; + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) return; // Prevent silenced players from using signs if (SilenceCheck(event.getPlayer())) @@ -317,13 +317,13 @@ public class Chat extends MiniPlugin UtilPlayer.message(sender, C.cYellow + "Buy a Rank at " + C.cGreen + "www.mineplex.com/shop" + C.cYellow + " to remove this limit!"); event.setCancelled(true); } - else if (!_clientManager.Get(sender).GetRank().Has(Rank.MODERATOR) && + else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) && !Recharge.Instance.use(sender, "Chat Message", 400, false, false)) { UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast.")); event.setCancelled(true); } - else if (!_clientManager.Get(sender).GetRank().Has(Rank.HELPER) && + else if (!_clientManager.Get(sender).GetRank().has(Rank.HELPER) && msgContainsHack(event.getMessage())) { UtilPlayer.message(sender, F.main("Chat", @@ -337,12 +337,12 @@ public class Chat extends MiniPlugin MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId()); long chatSlowTime = 1000L * _chatSlow; long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent(); - if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().Has(Rank.HELPER)) + if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().has(Rank.HELPER)) { UtilPlayer.message(sender, F.main("Chat", "Chat slow enabled. Please wait " + F.time(UtilTime.convertString(chatSlowTime - timeDiff, 1, UtilTime.TimeUnit.FIT)))); event.setCancelled(true); } - else if (!_clientManager.Get(sender).GetRank().Has(Rank.MODERATOR) && + else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) && UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f)) { UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message.")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java index 8bd788fc8..d15fc0f72 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java @@ -18,7 +18,7 @@ public class ChatSlowCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null && args.length == 1) + if (args.length == 1) { try { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 2b4d8f81b..5290158c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -48,7 +48,7 @@ public class CommandCenter implements Listener public void OnPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { String commandName = event.getMessage().substring(1); - String[] args = null; + String[] args = new String[] {}; if (commandName.contains(" ")) { @@ -62,7 +62,7 @@ public class CommandCenter implements Listener { event.setCancelled(true); - if (ClientManager.Get(event.getPlayer()).GetRank().Has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)) + if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)) { if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false)) { @@ -76,19 +76,6 @@ public class CommandCenter implements Listener } } - @EventHandler - public void onTabComplete(TabCompleteEvent event) - { - ICommand command = Commands.get(event.getCommand().toLowerCase()); - - if (command != null) - { - List suggestions = command.onTabComplete(event.getSender(), event.getCommand(), event.getArgs()); - - if (suggestions != null) - event.setSuggestions(suggestions); - } - } public void AddCommand(ICommand command) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java index 818fe9416..27e725870 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java @@ -40,7 +40,7 @@ public abstract class MultiCommandBase extends Co public void Execute(Player caller, String[] args) { String commandName = null; - String[] newArgs = null; + String[] newArgs = new String[] {}; if (args != null && args.length > 0) { @@ -59,7 +59,7 @@ public abstract class MultiCommandBase extends Co ICommand command = Commands.get(commandName); - if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().Has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true)) + if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true)) { command.SetAliasUsed(commandName); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index d41da36a3..48e7d35f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -19,6 +19,9 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.mount.MountManager; @@ -191,4 +194,15 @@ public class CosmeticManager extends MiniPlugin { return _treasureManager; } + + public void disableTeamArmor() + { + for (Gadget gadget : getGadgetManager().getGadgets(GadgetType.Costume)) + { + if (gadget instanceof OutfitTeam) + { + ((OutfitTeam)gadget).setEnabled(false); + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index f77c4851f..950dc9164 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Creature; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; @@ -20,6 +21,7 @@ import mineplex.core.cosmetic.ui.button.OpenMusic; import mineplex.core.cosmetic.ui.button.OpenParticles; import mineplex.core.cosmetic.ui.button.OpenPets; import mineplex.core.donation.DonationManager; +import mineplex.core.donation.Donor; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; @@ -40,7 +42,14 @@ public class Menu extends ShopPageBase @Override protected void buildPage() - { + { + Donor donor = getDonationManager().Get(getPlayer()); + +// addItem(2, new ShopItem(CurrencyType.Gems.GetDisplayMaterial(), donor.GetGems() + " Gems", new String[] { +// " " +// }, 1, false)); + + addItem(4, new ShopItem(175, getDonationManager().Get(getPlayer().getName()).getCoins() + " Coins", new String[] { " ", @@ -54,9 +63,13 @@ public class Menu extends ShopPageBase ChatColor.RESET + "Receives 15000 Coins per Month", " ", ChatColor.RESET + C.cGreen + "Legend Rank", - ChatColor.RESET + "Recieves 30000 Coins per Month" + ChatColor.RESET + "Receives 30000 Coins per Month" }, 1, false)); +// addItem(6, new ShopItem(Material.GOLD_INGOT, donor.getGold() + " Gold", new String[] { +// " " +// }, 1, false)); + addButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this)); addButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this)); addButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java index d43ccccbf..e98a0699d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java @@ -37,7 +37,7 @@ public class MobCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { HashMap entMap = new HashMap(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java index ca1a57c4b..2d083f5f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java @@ -13,6 +13,9 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.database.column.Column; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.jooq.DSLContext; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; @@ -61,6 +64,11 @@ public abstract class RepositoryBase implements Listener { return _dataSource; } + + protected DSLContext jooq() + { + return DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + } /** * Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool! diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 86a78df78..0e1a9c9d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -442,7 +442,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler return new PacketPlayOutMapChunk(_bedChunk, true, 0, UtilPlayer.is1_8(player) ? 48 : 0); } - private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise) + private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise, boolean is18) { try { @@ -458,7 +458,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity()); - teleportPacket.c += (int) (0.35D * 32); + teleportPacket.c += (int) ((is18 ? 0.07D : 0.25D) * 32); return new Packet[] { @@ -502,7 +502,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler && ((DisguisePlayer) entry.getKey()).getSleepingDirection() != null) { - packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey()))); + packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey(), UtilPlayer.is1_8(player)))); } } } @@ -853,7 +853,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (pDisguise.getSleepingDirection() != null) { - for (Packet packet : getBedPackets(player.getLocation(), pDisguise)) + for (Packet packet : getBedPackets(player.getLocation(), pDisguise, UtilPlayer.is1_8(player))) { handlePacket(packet, packetVerifier); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java index d2b6c6c47..2fff7c2f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java @@ -30,9 +30,9 @@ public abstract class DisguiseInsentient extends DisguiseLiving { if (rank != null) { - if (rank.Has(Rank.ULTRA)) + if (rank.has(Rank.ULTRA)) { - name = rank.GetTag(true, true) + " " + ChatColor.RESET + name; + name = rank.getTag(true, true) + " " + ChatColor.RESET + name; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 71f7ea718..31a02818b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -24,6 +24,7 @@ import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.playerCache.PlayerCache; public class DonationManager extends MiniDbClientPlugin { @@ -279,7 +280,7 @@ public class DonationManager extends MiniDbClientPlugin { public void run() { - RewardCoins(null, caller, player.getName(), ClientManager.getCachedClientAccountId(player.getUniqueId()), total, false); + RewardCoins(null, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java index 7593be55f..8690987bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java @@ -24,7 +24,7 @@ public class GemCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.main("gem", "Missing Args: " + F.elem("/gem "))); + UtilPlayer.message(caller, F.main("Gem", "Missing Args: " + F.elem("/gem "))); return; } @@ -59,7 +59,7 @@ public class GemCommand extends CommandBase } catch (Exception e) { - UtilPlayer.message(caller, F.main("gem", "Invalid gems Amount")); + UtilPlayer.message(caller, F.main("Gem", "Invalid gems Amount")); } } @@ -71,16 +71,16 @@ public class GemCommand extends CommandBase { if (completed) { - UtilPlayer.message(caller, F.main("gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); + UtilPlayer.message(caller, F.main("Gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); if (target != null) { - UtilPlayer.message(target, F.main("gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + ".")); + UtilPlayer.message(target, F.main("Gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + ".")); } } else { - UtilPlayer.message(caller, F.main("gem", "There was an error giving " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); + UtilPlayer.message(caller, F.main("Gem", "There was an error giving " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); } } }, caller.getName(), targetName, uuid, gems); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java index 6fa015312..36095de1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java @@ -23,6 +23,7 @@ public class GoldCommand extends CommandBase if (args == null || args.length == 0) { UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getGold()))); + return; } else if (args.length < 2) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index cafd20ec9..ba5558573 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -251,7 +251,7 @@ public class FriendManager extends MiniDbClientPlugin public void showFriends(Player caller) { - boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER); + boolean isStaff = ClientManager.Get(caller).GetRank().has(Rank.HELPER); boolean gotAFriend = false; List friendStatuses = Get(caller).getFriends(); Collections.sort(friendStatuses, _friendSorter); 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 359220020..c7ab1ae90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -159,7 +159,7 @@ public class FriendRepository extends RepositoryBase Set friendNames = new HashSet(); for(FriendStatus status : friendData.getFriends()) { - friendNames.add(status.Name); + friendNames.add(status.Name.toLowerCase()); } // Load PlayerStatus' for friends @@ -188,7 +188,7 @@ public class FriendRepository extends RepositoryBase */ public String fetchPlayerServer(String playerName) { - PlayerStatus status = _repository.getElement(playerName); + PlayerStatus status = _repository.getElement(playerName.toLowerCase()); return (status == null) ? null : status.getServer(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 3c518f35a..22f60039c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -92,7 +92,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ItemTNT(this)); addGadget(new ItemMelonLauncher(this)); addGadget(new ItemFleshHook(this)); - //addGadget(new ItemPaintballGun(this)); + addGadget(new ItemPaintballGun(this)); addGadget(new ItemBatGun(this)); addGadget(new ItemCoinBomb(this)); addGadget(new ItemPaintbrush(this)); @@ -166,11 +166,11 @@ public class GadgetManager extends MiniPlugin @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR)) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR)) { for (GadgetType gadgetType : _gadgets.keySet()) { - if (gadgetType == GadgetType.Particle && _clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN)) + if (gadgetType == GadgetType.Particle && _clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) { for (Gadget gadget : _gadgets.get(gadgetType)) { @@ -455,12 +455,16 @@ public class GadgetManager extends MiniPlugin @EventHandler public void chissMeow(PlayerToggleSneakEvent event) { - if (event.getPlayer().getName().equals("Chiss")) - { - if (!event.getPlayer().isSneaking()) - { - event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f); - } - } + if (event.getPlayer().isSneaking()) + return; + + if (event.getPlayer().getName().equalsIgnoreCase("Chiss")) + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f); + + if (event.getPlayer().getName().equalsIgnoreCase("defek7")) + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.WOLF_BARK, 1f, 1f); + + if (event.getPlayer().getName().equalsIgnoreCase("sterling_")) + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.PIG_IDLE, 1f, 1f); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java index 34d4ed557..68fba27a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java @@ -18,9 +18,15 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; 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.UtilServer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.gadget.types.ItemGadget; @@ -30,16 +36,17 @@ import mineplex.core.updater.event.UpdateEvent; public class ItemPaintballGun extends ItemGadget { private HashSet _balls = new HashSet(); - - public ItemPaintballGun(GadgetManager manager) + + public ItemPaintballGun(GadgetManager manager) { - super(manager, "Paintball Gun", new String[] - { + super(manager, "Paintball Gun", new String[] + { C.cWhite + "PEW PEW PEW PEW!", - }, - -1, - Material.GOLD_BARDING, (byte)0, - 200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING, (byte)0, new String[] { C.cWhite + "100 Paintballs for you to shoot!" }, 500, 100)); + }, -1, Material.GOLD_BARDING, (byte) 0, 200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING, + (byte) 0, new String[] + { + C.cWhite + "100 Paintballs for you to shoot!" + }, 500, 100)); } @Override @@ -48,77 +55,56 @@ public class ItemPaintballGun extends ItemGadget Projectile proj = player.launchProjectile(EnderPearl.class); proj.setVelocity(proj.getVelocity().multiply(2)); _balls.add(proj); - - //Sound + + // Sound player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 1.2f); } - + @EventHandler public void Paint(ProjectileHitEvent event) { if (!_balls.remove(event.getEntity())) return; - - Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity()); - loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 49); - - byte color = 2; - double r = Math.random(); - if (r > 0.8) color = 4; - else if (r > 0.6) color = 5; - else if (r > 0.4) color = 9; - else if (r > 0.2) color = 14; - for (Block block : UtilBlock.getInRadius(loc, 3d).keySet()) + Location loc = event.getEntity().getLocation(); + + Vector vec = event.getEntity().getVelocity().normalize().multiply(0.05); + + if (vec.length() > 0) { - if (block.getType() == Material.PORTAL) - return; - - if (block.getType() == Material.CACTUS) - return; - - if (block.getType() == Material.SUGAR_CANE_BLOCK) - return; - } - - List blocks = new ArrayList(); - blocks.addAll(UtilBlock.getInRadius(loc, 1.5d).keySet()); - - GadgetBlockEvent gadgetEvent = new GadgetBlockEvent(this, blocks); - Bukkit.getServer().getPluginManager().callEvent(gadgetEvent); - - if (gadgetEvent.isCancelled()) - return; - - for (Block block : gadgetEvent.getBlocks()) - { - if (!UtilBlock.solid(block)) - continue; - - if (block.getType() == Material.CARPET) - Manager.getBlockRestore().Add(block, 171, color, 4000); - else - Manager.getBlockRestore().Add(block, 35, color, 4000); + int i = 0; + + while (UtilBlock.airFoliage(loc.getBlock())) + { + loc.add(vec); + + if (i++ > 50) + break; + } } + + loc.getWorld().playSound(loc, Sound.DIG_STONE, 1.3F, 1.3F); + + UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, 0.2F, 0.2F, 0.2F, 1, 70, ViewDist.LONG, UtilServer.getPlayers()); } - + @EventHandler public void Teleport(PlayerTeleportEvent event) { if (event.getCause() == TeleportCause.ENDER_PEARL) event.setCancelled(true); } - + @EventHandler public void cleanupBalls(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - + for (Iterator ballIterator = _balls.iterator(); ballIterator.hasNext();) { Projectile ball = ballIterator.next(); - + if (ball.isDead() || !ball.isValid()) ballIterator.remove(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java index 80e91b5ad..894c1e4d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java @@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ItemGadget; @@ -35,6 +36,8 @@ public class ItemPaintbrush extends ItemGadget private NautHashMap _brushColor = new NautHashMap(); private NautHashMap _brushPrevious = new NautHashMap(); + private NautHashMap _playerLocation = new NautHashMap(); + public ItemPaintbrush(GadgetManager manager) { super(manager, "Paintbrush", new String[] @@ -83,6 +86,7 @@ public class ItemPaintbrush extends ItemGadget ApplyItem(player, true); _brushColor.put(player.getName(), (byte)15); + _playerLocation.put(player.getName(), player.getLocation()); } @@ -91,6 +95,7 @@ public class ItemPaintbrush extends ItemGadget { _brushColor.remove(player.getName()); _brushPrevious.remove(player.getName()); + _playerLocation.remove(player.getName()); RemoveItem(player); } @@ -115,6 +120,27 @@ public class ItemPaintbrush extends ItemGadget player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f); } + + @EventHandler + public void disableDistance(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (!GetActive().contains(player)) + continue; + + Location loc = _playerLocation.get(player.getName()); + + if (loc == null || UtilMath.offset(player.getLocation(), loc) > 12) + { + Disable(player); + } + } + } + @EventHandler public void paint(UpdateEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java index c93152737..d7b73309d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java @@ -82,7 +82,7 @@ public class MorphBlaze extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO)) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java index 965207894..5cbc89f29 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java @@ -170,7 +170,7 @@ public class MorphCreeper extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO)) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java index 3c184c06b..f132e9e7a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java @@ -83,7 +83,7 @@ public class MorphPig extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.ULTRA)) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.ULTRA)) { Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java index 697f398c4..9090eb81e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java @@ -27,6 +27,8 @@ import mineplex.core.recharge.Recharge; public class OutfitTeam extends OutfitGadget { + private boolean _enabled = true; + private HashMap _colorSetting = new HashMap(); public OutfitTeam(GadgetManager manager, String name, @@ -100,6 +102,9 @@ public class OutfitTeam extends OutfitGadget @EventHandler(priority=EventPriority.LOWEST) public void setColor(PlayerCommandPreprocessEvent event) { + if (!_enabled) + return; + Player player = event.getPlayer(); if (!event.getMessage().toLowerCase().startsWith("/team")) @@ -235,4 +240,9 @@ public class OutfitTeam extends OutfitGadget { return _colorSetting.get(player.getName()); } + + public void setEnabled(boolean var) + { + _enabled = var; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java index cf6e41eba..094c1ff39 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java @@ -46,7 +46,7 @@ public class ParticleLegend extends ParticleGadget @EventHandler public void legendOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.LEGEND)) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java index 458ad6400..21234daa6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.common.structs.ItemContainer; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; @@ -65,7 +66,7 @@ public class Give extends MiniPlugin public void give(Player player, String target, String itemNames, String amount, String enchants) { //Item - LinkedList> itemList = new LinkedList>(); + LinkedList itemList = new LinkedList(); itemList = UtilItem.matchItem(player, itemNames, true); if (itemList.isEmpty()) return; @@ -128,11 +129,15 @@ public class Give extends MiniPlugin if (givenList.length() > 0) givenList = givenList.substring(0, givenList.length()-1); - for (Entry curItem : itemList) + for (ItemContainer curItem : itemList) { for (Player cur : giveList) { - ItemStack stack = ItemStackFactory.Instance.CreateStack(curItem.getKey(), curItem.getValue(), count); + ItemStack stack; + if (curItem.Name == null) + stack = ItemStackFactory.Instance.CreateStack(curItem.Type, curItem.Data, count); + else + stack = ItemStackFactory.Instance.CreateStack(curItem.Type, curItem.Data, count, curItem.Name); //Enchants stack.addUnsafeEnchantments(enchs); @@ -142,18 +147,18 @@ public class Give extends MiniPlugin { //Inform if (!cur.equals(player)) - UtilPlayer.message(cur, F.main("Give", "You received " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " from " + F.elem(player.getName()) + ".")); + UtilPlayer.message(cur, F.main("Give", "You received " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " from " + F.elem(player.getName()) + ".")); } } if (target.equalsIgnoreCase("all")) - UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem("ALL")) + "."); + UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem("ALL")) + "."); else if (giveList.size() > 1) - UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(givenList) + ".")); + UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem(givenList) + ".")); else - UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(giveList.getFirst().getName()) + ".")); + UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem(giveList.getFirst().getName()) + ".")); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/ClickExecutor.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/ClickExecutor.java new file mode 100644 index 000000000..18c9fbf2b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/ClickExecutor.java @@ -0,0 +1,8 @@ +package mineplex.core.gui; + +import org.bukkit.event.inventory.ClickType; + +public interface ClickExecutor +{ + public void click(ClickType clickType); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/Container.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/Container.java new file mode 100644 index 000000000..9ad939f28 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/Container.java @@ -0,0 +1,5 @@ +package mineplex.core.gui; + +public interface Container { + public T getObject(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java new file mode 100644 index 000000000..87e844b1c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java @@ -0,0 +1,40 @@ +package mineplex.core.gui; + +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.gui.GuiItem; + +public class DisplayItem implements GuiItem +{ + private ItemStack _item; + + public DisplayItem(ItemStack item) + { + _item = item; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + + } + + @Override + public ItemStack getObject() + { + return _item; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiInventory.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiInventory.java new file mode 100644 index 000000000..68d347477 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiInventory.java @@ -0,0 +1,9 @@ +package mineplex.core.gui; + +import org.bukkit.inventory.Inventory; + + +public interface GuiInventory { + public void openInventory(); + public Inventory getInventory(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java new file mode 100644 index 000000000..cae592783 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java @@ -0,0 +1,9 @@ +package mineplex.core.gui; + +import org.bukkit.inventory.ItemStack; + +public interface GuiItem extends ClickExecutor, Container +{ + public void setup(); + public void close(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/ItemRefresher.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/ItemRefresher.java new file mode 100644 index 000000000..e736a72bc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/ItemRefresher.java @@ -0,0 +1,6 @@ +package mineplex.core.gui; + +public interface ItemRefresher extends GuiInventory +{ + public void refreshItem(GuiItem item); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java new file mode 100644 index 000000000..0029d1864 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java @@ -0,0 +1,241 @@ +package mineplex.core.gui; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilPlayer; + +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class SimpleGui implements ItemRefresher, Listener +{ +// private Map _buttonMap = new HashMap(); + private GuiItem[] _items; + + private Player _player; + private Plugin _plugin; + private int _size; + private String _title; + private Inventory _inv; + + public SimpleGui(Plugin plugin, Player player) + { + this(plugin, player, null, 0); + } + + public SimpleGui(Plugin plugin, Player player, int size) + { + this(plugin, player, null, size); + } + + public SimpleGui(Plugin plugin, Player player, String title) + { + this(plugin, player, title, 0); + } + + public SimpleGui(Plugin plugin, Player player, String title, int size) + { + + Validate.notNull(plugin, "The plugin cannot be null!"); + Validate.notNull(player, "The player cannot be null!"); + + this._plugin = plugin; + this._player = player; + + if (size == 0) + setSize(9); + else + setSize(size); + + if (title == null) + setTitle(" "); + else + setTitle(title); + + updateArray(); + + _inv = createInventory(); + refreshInventory(); + } + + private void updateArray() + { + _items = new GuiItem[_size]; + } + + public void setItem(int i, GuiItem item) + { + Validate.isTrue(i >= 0 && i < _size, "Tried to add a gui item outside of inventory range"); + + GuiItem oldItem = getItem(i); + if (oldItem != null) oldItem.close(); + + if (item != null) + { + _items[i] = item; + item.setup(); + } + + refreshItem(i); + } + + public GuiItem getItem(int i) + { + return _items[i]; + } + + @Override + public void openInventory() + { + refreshInventory(); + UtilPlayer.swapToInventory(_player, _inv); + Bukkit.getPluginManager().registerEvents(this, _plugin); + } + + public Inventory createInventory() + { + Inventory inv = Bukkit.createInventory(_player, getSize(), getTitle()); + return inv; + } + + public void refreshInventory() + { + for (int i = 0; i < _size; i++) + { + refreshItem(i); + } + } + + @EventHandler + public void inventoryClick(InventoryClickEvent event) + { + if (!event.getWhoClicked().equals(_player) || !event.getInventory().equals(_inv)) + return; + + if (event.getSlot() >= 0 && event.getSlot() < _size) + { + GuiItem item = getItem(event.getSlot()); + if (item == null) + return; + + event.setCancelled(true); + + item.click(event.getClick()); + } + } + + @EventHandler + public void teleport(PlayerTeleportEvent event) + { + if (!event.getPlayer().equals(_player)) + return; + + close(); + } + + @EventHandler + public void inventoryClose(InventoryCloseEvent event) + { + if (!event.getPlayer().equals(_player)) + return; + + close(); + } + + @EventHandler + public void quit(PlayerQuitEvent event) + { + if (!event.getPlayer().equals(_player)) + return; + + close(); + } + + private void close() + { +// _inv = null; // TODO - do we really need to null the inventory? + HandlerList.unregisterAll(this); + + for (int i = 0; i < _size; i++) + { + GuiItem item = getItem(i); + if (item != null) item.close(); + } + } + + @Override + @Deprecated + public void refreshItem(GuiItem item) + { + if (_inv == null) + return; + + for (int i = 0; i < _size; i++) + { + if (item.equals(getItem(i))) + refreshItem(i); + } + } + + public void refreshItem(int slot) + { + GuiItem gi = getItem(slot); + + ItemStack itemStack = null; + if (gi != null) itemStack = gi.getObject(); + + _inv.setItem(slot, itemStack); + } + + public int getSize() + { + return _size; + } + + public String getTitle() + { + return _title; + } + + public Player getPlayer() + { + return _player; + } + + public Plugin getPlugin() + { + return _plugin; + } + + public void setTitle(String title) + { + this._title = title; + } + + @Override + public Inventory getInventory() + { + return _inv; + } + + public void setSize(int size) + { + Validate.isTrue(size % 9 == 0, "The size " + size + " is not divisible by 9"); + this._size = size; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGuiItem.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGuiItem.java new file mode 100644 index 000000000..187aa259f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGuiItem.java @@ -0,0 +1,50 @@ +package mineplex.core.gui; + +import org.bukkit.Material; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class SimpleGuiItem extends ItemStack implements GuiItem { + + public SimpleGuiItem(Material type, int amount, short damage) + { + super(type, amount, damage); + } + + public SimpleGuiItem(Material type, int amount) + { + super(type, amount); + } + + public SimpleGuiItem(Material type) + { + super(type); + } + + public SimpleGuiItem(ItemStack itemStack) + { + super(itemStack); + } + + @Override + public void click(ClickType clickType) + { + } + + @Override + public ItemStack getObject() + { + return this; + } + + @Override + public void setup() + { + } + + @Override + public void close() + { + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/botton/BackBotton.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/botton/BackBotton.java new file mode 100644 index 000000000..4335408eb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/botton/BackBotton.java @@ -0,0 +1,36 @@ +package mineplex.core.gui.botton; + +import mineplex.core.gui.GuiInventory; +import mineplex.core.gui.SimpleGuiItem; +import mineplex.core.itemstack.ItemStackFactory; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class BackBotton extends SimpleGuiItem { + + private GuiInventory _gui; + + public BackBotton(GuiInventory gui) { + this(ItemStackFactory.Instance.CreateStack(Material.BED, (byte) 0, 1, ChatColor.DARK_GRAY + "<-- Go Back"), gui); + } + + public BackBotton(ItemStack itemStack, GuiInventory gui) + { + super(itemStack); + this._gui = gui; + } + + @Override + public void click(ClickType clickType) + { + getGui().openInventory(); + } + + public GuiInventory getGui() + { + return _gui; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java new file mode 100644 index 000000000..b14d00d41 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java @@ -0,0 +1,264 @@ +package mineplex.core.gui.pages; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; + +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +public class LoadingWindow implements Runnable, Listener { + + public static String[] messages = new String[]{"Sending Carrier Pigeons...", "#BlameChiss", "Converting to Morse Code...", "Training monkeys..."}; + public static long defaultWait = 30; + + public ItemStack _background; + public ItemStack _barLoading; + public ItemStack _barBack; + + private Inventory _inv; + private final InventoryView _currentInventory; + + private final int _id; + + private final Plugin _plugin; + private final UUID _playersUUID; + + private String _message; + private String _title; + + private final int _size; + + private final int[] _activeRows; + + private long _ticker = 0; + + public LoadingWindow(Plugin plugin, Player player, int size) { + this(plugin, player, null, size, null, null); + } + + public LoadingWindow(Plugin plugin, Player player, long startTime, int size) { + this(plugin, player, startTime, size, null, null); + } + + public LoadingWindow(Plugin plugin, Player player, long startTime, int size, String message) + { + this(plugin, player, startTime, size, message, message); + } + + @SuppressWarnings("deprecation") + public LoadingWindow(Plugin plugin, Player player, Long startTime, int size, String title, String message) + { + Validate.notNull(plugin, "The plugin can not be null!"); + Validate.notNull(player, "The player can not be null!"); + + _currentInventory = player.getOpenInventory(); + + _size = size; + _activeRows = getActiveRows(size / 9); + + _plugin = plugin; + _playersUUID = player.getUniqueId(); + + + _background = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData(), 1, _message); + _barLoading = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, _message); + _barBack = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.WHITE.getData(), 1, _message); + + + if (title == null && message == null) + { + String randomName = UtilMath.randomElement(messages); + title = randomName; + message = randomName; + } + else if (title == null) + { + title = " "; + } + else if (message == null) + { + message = UtilMath.randomElement(messages); + } + if (startTime == null) + startTime = defaultWait; + + + _title = title; + setMessage(message); + _id = Bukkit.getScheduler().runTaskTimer(plugin, this, startTime, 5).getTaskId(); + } + + public void setMessage(String message) { + _message = message; + ItemMeta im =_background.getItemMeta(); + im.setDisplayName(_message); + _background.setItemMeta(im); + _barBack.setItemMeta(im); + _barLoading.setItemMeta(im); + + setBackGround(); + setLoadingBarItems(); + } + + public void setTitle(String title) { + _title = title; + + Player player = Bukkit.getPlayer(_playersUUID); + if (_inv == null || player == null) + return; + + ItemStack[] con = _inv.getContents(); + + _inv = Bukkit.createInventory(null, _size, _title); + _inv.setContents(con); + UtilPlayer.swapToInventory(player, _inv); + } + + @EventHandler + public void onClick(InventoryClickEvent event) { + if (event.getWhoClicked().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) { + event.setCancelled(true); + } + } + + @EventHandler + public void inventoryClose(InventoryCloseEvent event) { + if (event.getPlayer().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) { + end(); + } + } + + @Override + public void run() + { + Player player = Bukkit.getPlayer(_playersUUID); + + try + { + if (player == null || player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (!player.getOpenInventory().getTopInventory().equals(_inv))) + { + end(); + return; + } + + if (_inv == null) + { + _inv = Bukkit.createInventory(null, _size, _title); + + setBackGround(); + setLoadingBarItems(); + UtilPlayer.swapToInventory(player, _inv); + Bukkit.getPluginManager().registerEvents(this, _plugin); + } + else + setLoadingBarItems(); + } + catch (Exception exception) + { + try + { + System.out.println("player ? " + (player == null)); + System.out.println("player.getOpenInventory() ? " + (player.getOpenInventory() == null)); + System.out.println("player.getOpenInventory().getTopInventory() ? " + (player.getOpenInventory().getTopInventory() == null)); + System.out.println("_inv ? " + (_inv == null)); + exception.printStackTrace(); + } + catch (Exception exception2) + { + exception.printStackTrace(); + } + + end(); + } + finally + { + _ticker++; + } + } + + public void end() { + HandlerList.unregisterAll(this); + Bukkit.getScheduler().cancelTask(_id); + _inv = null; + } + + private void setBackGround() { + if (_inv == null) + return; + + List ignore = new ArrayList(); + + for (int row : _activeRows) { + + int rowStart = row * 9; + int rowEnd = rowStart + 9; + + for (int i = rowStart; i < rowEnd; i++) { + ignore.add(i); + } + } + + for (int i = 0; i < _size; i++) { + if (!ignore.contains(i)) + _inv.setItem(i, _background); + } + } + + private void setLoadingBarItems() { + if (_inv == null) + return; + ItemStack[] loadingBar = getLoadingBar(); + + for (int row : _activeRows) { + int rowStart = row * 9; + for (int i = 0; i < 9; i++) { + _inv.setItem(i + rowStart, loadingBar[i]); + } + } + } + + public ItemStack[] getLoadingBar() + { + ItemStack[] loadingBar = new ItemStack[9]; + + int barStart = (int) (_ticker % 9); + int barEnd = (barStart + 3) % 9; + + boolean endAfter = barEnd > barStart; + + for (int i = 0; i < loadingBar.length; i++) { + if (endAfter ? (i >= barStart && i < barEnd) : (i >= barStart || i < barEnd)) + loadingBar[i] = _barLoading; + else + loadingBar[i] = _barBack; + } + return loadingBar; + } + + private static int[] getActiveRows(int rows) + { + float mid = rows / 2.0f; + if (mid == (int) mid) + return new int[] { (int) mid , (int) mid -1}; + else + return new int[] { (int) Math.floor(mid)}; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/MessageWindow.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/MessageWindow.java new file mode 100644 index 000000000..d51bbcf79 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/MessageWindow.java @@ -0,0 +1,87 @@ +package mineplex.core.gui.pages; + +import java.util.UUID; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gui.GuiInventory; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class MessageWindow implements Listener, GuiInventory { + + private UUID _playersUUID; + private Plugin _plugin; + private Inventory _inv; + + public MessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size) + { + _plugin = plugin; + + this._playersUUID = player.getUniqueId(); + + _inv = Bukkit.createInventory(null, size, title); + + for (int i = 0; i < size; i++) { + _inv.setItem(i, is); + } + } + + @EventHandler(ignoreCancelled = true) + public void onClick(InventoryClickEvent e) + { + if (!e.getWhoClicked().getUniqueId().equals(_playersUUID)) + return; + e.setCancelled(true); + } + + @EventHandler + public void onClose(InventoryCloseEvent e) + { + if (!e.getPlayer().getUniqueId().equals(_playersUUID)) + return; + HandlerList.unregisterAll(this); + close(); + } + + @Override + public void openInventory() + { + Player player = Bukkit.getPlayer(_playersUUID); + + if (player == null || player.getOpenInventory().getTopInventory().equals(_inv)) + return; + + UtilPlayer.swapToInventory(player, _inv); + Bukkit.getPluginManager().registerEvents(this, _plugin); + open(); + } + + @Override + public Inventory getInventory() + { + return _inv; + } + public UUID getPlayersUUID() + { + return _playersUUID; + } + public Plugin getPlugin() + { + return _plugin; + } + public void open() { + + } + public void close() { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/TimedMessageWindow.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/TimedMessageWindow.java new file mode 100644 index 000000000..d84b3bdfa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/TimedMessageWindow.java @@ -0,0 +1,65 @@ +package mineplex.core.gui.pages; + +import mineplex.core.gui.GuiInventory; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class TimedMessageWindow extends MessageWindow implements Runnable { + private GuiInventory _gui; + private int _id; + private long _time; + + public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time) + { + this(plugin, player, is, title, size, time, null); + } + + public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time, GuiInventory gui) + { + super(plugin, player, is, title, size); + + this._gui = gui; + this._time = time; + } + + @Override + @EventHandler + public void onClick(InventoryClickEvent e) + { + super.onClick(e); + if (e.isCancelled() && _gui != null && (e.getWhoClicked() instanceof Player)) { + _gui.openInventory(); + } + } + + @Override + public void open() + { + this._id = Bukkit.getScheduler().runTaskLater(getPlugin(), this, _time).getTaskId(); + } + + @Override + public void close() + { + Bukkit.getScheduler().cancelTask(_id); + } + + @Override + public void run() + { + Player player = Bukkit.getPlayer(getPlayersUUID()); + if (player == null) + return; + + if (_gui != null) { + _gui.openInventory(); + } else + player.closeInventory(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index 7b470f779..fd5311707 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -532,8 +532,6 @@ public class Hologram if (newText.equals(_hologramText)) return this; - _makeSpawnPackets = true; - if (isInUse()) { int[] destroy1_7 = new int[0]; @@ -632,6 +630,7 @@ public class Hologram } _hologramText = newText; + makeSpawnPackets(); return this; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java index e7b8732c1..a4735a7a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -88,7 +88,7 @@ public class IgnoreManager extends MiniDbClientPlugin @EventHandler public void onChat(AsyncPlayerChatEvent event) { - if (ClientManager.Get(event.getPlayer()).GetRank().Has(Rank.HELPER)) + if (ClientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) return; Iterator itel = event.getRecipients().iterator(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 8c87db300..8117ceeed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -21,6 +21,7 @@ import mineplex.core.inventory.data.InventoryRepository; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.playerCache.PlayerCache; public class InventoryManager extends MiniDbClientPlugin { @@ -180,7 +181,7 @@ public class InventoryManager extends MiniDbClientPlugin synchronized (_inventoryLock) { - final boolean success = _repository.incrementClientInventoryItem(ClientManager.getCachedClientAccountId(uuid), _items.get(item).Id, count); + final boolean success = _repository.incrementClientInventoryItem(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _items.get(item).Id, count); if (callback != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index e13338dd1..3a1f090e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -308,9 +308,10 @@ public class ItemBuilder return this; } - public void setData(short newData) + public ItemBuilder setData(short newData) { this._data = newData; + return this; } public ItemBuilder setPotion(Potion potion) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index b81e7fbb1..9df819f31 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -191,7 +191,7 @@ public class MessageManager extends MiniClientPlugin // My attempt at trying to mitigate some of the spam bots - Phinary // Triggers if they are whispering a new player - if (!GetClientManager().Get(from).GetRank().Has(Rank.HELPER) && Get(from).LastTo != null + if (!GetClientManager().Get(from).GetRank().has(Rank.HELPER) && Get(from).LastTo != null && !Get(from).LastTo.equalsIgnoreCase(to.getName())) { long delta = System.currentTimeMillis() - Get(from).LastToTime; @@ -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("ishh")) + { + UtilPlayer.message(from, C.cPurple + "Hi, my name is ishh. If I don't respond to your message, please be patient and try again later!"); + } // Log // Logger().logChat("Private Message", from, to.getName(), message); @@ -247,7 +252,7 @@ public class MessageManager extends MiniClientPlugin { if (!to.equals(staff) && !from.equals(staff)) { - if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER)) + if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) { UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple + " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message); @@ -364,7 +369,7 @@ public class MessageManager extends MiniClientPlugin { if (!to.equals(staff)) { - if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER)) + if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) { UtilPlayer.message(staff, @@ -442,7 +447,7 @@ public class MessageManager extends MiniClientPlugin { if (!target.equals(staff)) { - if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER)) + if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) { UtilPlayer.message(staff, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java index 8534424dc..5735a2dc4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -21,7 +21,7 @@ public class AdminCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } @@ -48,7 +48,7 @@ public class AdminCommand extends CommandBase boolean staff = false; for (Player to : UtilServer.getPlayers()) { - if (Plugin.GetClientManager().Get(to).GetRank().Has(Rank.HELPER)) + if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER)) { if (!to.equals(caller)) UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java index f2336f543..3715bc60f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java @@ -18,7 +18,7 @@ public class AdminMessageCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java index e4c8865fb..c82cdd800 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java @@ -22,7 +22,7 @@ public class AnnounceCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java index fae3d2a36..9c9f12e62 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java @@ -20,7 +20,7 @@ public class GlobalCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java index 89a459c36..cdacc6ef3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java @@ -18,13 +18,13 @@ public class MessageAdminCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } else { - if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true)) + if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true)) return; if (args.length == 0) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java index 405c4bf4d..53db5de4e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java @@ -18,7 +18,7 @@ public class MessageCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java index a1a4f21c3..d201c296f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java @@ -18,13 +18,13 @@ public class ResendAdminCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } else { - if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true)) + if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true)) return; String lastTo = Plugin.Get(caller).LastAdminTo; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java index 4a9c9b6a4..65baece24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java @@ -18,7 +18,7 @@ public class ResendCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index fc898459e..9b7f921a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -9,7 +9,9 @@ import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -25,9 +27,14 @@ public class LagMeter extends MiniPlugin private double _ticksPerSecond; private double _ticksPerSecondAverage; private long _lastAverage; + private long _start; private long _lastTick = 0; + private boolean _timingsRunning; + private boolean _timingsPasted; + private long _timingsStarted; + private HashSet _monitoring = new HashSet(); public LagMeter(JavaPlugin plugin, CoreClientManager clientManager) @@ -37,12 +44,14 @@ public class LagMeter extends MiniPlugin _clientManager = clientManager; _lastRun = System.currentTimeMillis(); _lastAverage = System.currentTimeMillis(); + + _start = System.currentTimeMillis(); } @EventHandler public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR)) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR)) { if (event.getMessage().trim().equalsIgnoreCase("/lag")) { @@ -87,6 +96,24 @@ public class LagMeter extends MiniPlugin _lastRun = now; _count++; + + if (System.currentTimeMillis() - _start > 60000) + { + if (_timingsRunning) + { + if (_ticksPerSecond > 15 || System.currentTimeMillis() - _timingsStarted > 60000) + { + getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings paste"); + _timingsRunning = false; + } + } + else if (_ticksPerSecond < 10) + { + _timingsRunning = true; + _timingsStarted = System.currentTimeMillis(); + getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings on"); + } + } } public double getTicksPerSecond() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 00dcd9fdb..38152a878 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -115,6 +115,12 @@ public class MountManager extends MiniPlugin mount.Disable(player); } + public void DisableAll(Player player) + { + for (Mount mount : _types) + mount.Disable(player); + } + @EventHandler public void quit(PlayerQuitEvent event) { @@ -161,4 +167,6 @@ public class MountManager extends MiniPlugin { return _disguiseManager; } + + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java index bf8d15f97..efb19dcf5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java @@ -110,7 +110,7 @@ public class MountDragon extends DragonMount @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO)) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 342d7b840..d5097e318 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -22,12 +22,12 @@ public class NotificationManager extends MiniPlugin private CoreClientManager _clientManager; private String _summerLine = - C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + - C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + - C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + - C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + - C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + - C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█"; + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█"; public NotificationManager(JavaPlugin plugin, CoreClientManager client) { @@ -45,8 +45,8 @@ public class NotificationManager extends MiniPlugin // if (event.getType() == UpdateType.MIN_08) // hugeSale(); -// if (event.getType() == UpdateType.MIN_16) -// sale(); + if (event.getType() == UpdateType.MIN_16) + sale(); } private void sale() @@ -55,20 +55,20 @@ public class NotificationManager extends MiniPlugin { Rank rank = _clientManager.Get(player).GetRank(); - if (rank.Has(Rank.LEGEND)) + if (rank.has(Rank.LEGEND)) continue; if (rank == Rank.ALL) { - UtilPlayer.message(player, C.cWhite + "Summer Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra RANK" + C.cWhite + " for $15"); + UtilPlayer.message(player, C.cWhite + "50% Off Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra Rank" + C.cWhite + " for $15"); } else if (rank == Rank.ULTRA) { - UtilPlayer.message(player, C.cWhite + "Summer Sale! " + " Upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for $15!"); + UtilPlayer.message(player, C.cWhite + "50% Off Sale! " + " Upgrade to " + C.cPurple + C.Bold + "Hero Rank" + C.cWhite + " for $15!"); } else if (rank == Rank.HERO) { - UtilPlayer.message(player, C.cWhite + "Summer Sale! " + "Upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for $15!"); + UtilPlayer.message(player, C.cWhite + "50% Off Sale! " + "Upgrade to " + C.cGreen + C.Bold + "Legend Rank" + C.cWhite + " for $15!"); } UtilPlayer.message(player, C.cWhite + " Visit " + F.link("www.mineplex.com/shop") + " for 50% Off Ranks!"); @@ -81,7 +81,7 @@ public class NotificationManager extends MiniPlugin { Rank rank = _clientManager.Get(player).GetRank(); - if (rank.Has(Rank.LEGEND)) + if (rank.has(Rank.LEGEND)) continue; UtilPlayer.message(player, _summerLine); @@ -95,17 +95,17 @@ public class NotificationManager extends MiniPlugin if (rank == Rank.ALL) { UtilPlayer.message(player, C.cWhite + " " + player.getName() + ", you can get 75% Off " + C.cAqua + C.Bold + "All Lifetime Ranks" + C.cWhite + "!"); - UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!"); + UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } else if (rank == Rank.ULTRA) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for only $7.50!"); - UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!"); + UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } else if (rank == Rank.HERO) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for only $7.50!"); - UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!"); + UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } UtilPlayer.message(player, " "); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index e58b10020..d92a8690e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -161,6 +161,17 @@ public class NpcManager extends MiniPlugin return _npcMap.get(uuid); } + public Npc getNpcByName(String name) + { + for (Npc npc : _npcs) + { + if (npc.getDatabaseRecord().getName() != null && npc.getDatabaseRecord().getName().contains(name)) + return npc; + } + + return null; + } + public Npc getNpcByEntity(Entity entity) { if (entity == null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java index 08beeb4fe..5de1e1525 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java @@ -19,7 +19,7 @@ public class AddCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java index ff1a59bbf..aae8c26a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java @@ -20,7 +20,7 @@ public class ClearCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java index 4b7ab183b..71dce58c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java @@ -18,7 +18,7 @@ public class DeleteCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java index 03382bf95..51e8a622e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java @@ -18,7 +18,7 @@ public class HomeCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java index f77033b26..465b8ee02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java @@ -20,7 +20,7 @@ public class RefreshCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java index 008aa8f1f..056b75877 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java @@ -50,7 +50,8 @@ public class PacketHandler extends MiniPlugin Method method = ProtocolInjector.class.getDeclaredMethod("addPacket", EnumProtocol.class,boolean.class, int.class, Class.class); method.setAccessible(true); - + + method.invoke(null, EnumProtocol.PLAY, true, 67, PacketPlayOutCamera.class); method.invoke(null, EnumProtocol.PLAY, true, 68, PacketPlayOutWorldBorder.class); // EnumProtocol.PLAY.b().put(68, PacketPlayOutWorldBorder.class); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketPlayOutCamera.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketPlayOutCamera.java new file mode 100644 index 000000000..11dd54051 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketPlayOutCamera.java @@ -0,0 +1,44 @@ +package mineplex.core.packethandler; + +import org.bukkit.entity.Entity; + +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketDataSerializer; +import net.minecraft.server.v1_7_R4.PacketListener; + +public class PacketPlayOutCamera extends Packet +{ + public int a; + + public PacketPlayOutCamera() + { + } + + public PacketPlayOutCamera(int id) + { + a = id; + } + + public PacketPlayOutCamera(Entity paramEntity) + { + this.a = paramEntity.getEntityId(); + } + + public void a(PacketDataSerializer paramPacketDataSerializer) + { + } + + public void b(PacketDataSerializer paramPacketDataSerializer) + { + paramPacketDataSerializer.b(this.a); + } + + public void a(PacketListener paramPacketListenerPlayOut) + { + } + + @Override + public void handle(PacketListener arg0) + { + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java index b5e048f9f..2aa3b2496 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java @@ -82,7 +82,7 @@ public class Party for (Rank rank : Rank.values()) { if (rank != Rank.ALL) - _scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " "); + _scoreboard.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, false) + ChatColor.RESET + " "); else _scoreboard.registerNewTeam(rank.Name).setPrefix(""); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index dbf091299..8fe9045d6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -12,7 +12,7 @@ public class HostServerCommand extends CommandBase { public HostServerCommand(PersonalServerManager plugin) { - super(plugin, Rank.LEGEND, "hostserver"); + super(plugin, Rank.LEGEND, "hostserver", "mps"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 2030044e5..8f8e68dc9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -59,7 +59,6 @@ public class PersonalServerManager extends MiniPlugin { if (_giveInterfaceItem) { - event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem); } } @@ -71,7 +70,7 @@ public class PersonalServerManager extends MiniPlugin if (!Recharge.Instance.use(event.getPlayer(), "Host Server Melon", 30000, false, false)) return; - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.LEGEND)) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { showHostMessage(event.getPlayer()); } @@ -125,7 +124,7 @@ public class PersonalServerManager extends MiniPlugin Rank rank = _clientManager.Get(player).GetRank(); - if (eventServer || rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH) + if (eventServer || rank.has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH) { ram = 2048; cpu = 4; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index b50fc27b4..0983baf8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -228,8 +228,14 @@ public class PetManager extends MiniClientPlugin if (_activePetOwners.containsKey(player.getName())) { final Creature pet = _activePetOwners.get(player.getName()); + + //Wither Silverfish + if (pet.getPassenger() != null) + pet.getPassenger().remove(); + pet.remove(); + if (removeOwner) { _activePetOwners.remove(player.getName()); @@ -401,9 +407,15 @@ public class PetManager extends MiniClientPlugin for (Player player : UtilServer.getPlayers()) RemovePet(player, true); } + + public void DisableAll(Player player) + { + RemovePet(player, true); + } public Collection getPets() { return _activePetOwners.values(); } + } 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 2ed20694b..85973eeb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -26,14 +26,34 @@ public class PetRepository extends RepositoryBase _webAddress = webAddress; } - public void AddPet(PetChangeToken token) + public void AddPet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/AddPet").Execute(token); + + Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + { + public void run() + { + executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName) + , new ColumnInt("petId", token.PetId) + , new ColumnInt("accountId", token.AccountId)); + } + }); } - public void RemovePet(PetChangeToken token) + public void RemovePet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/RemovePet").Execute(token); + + Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + { + public void run() + { + executeUpdate("DELETE FROM accountPets WHERE petId = ? AND accountId = ?;" + , new ColumnInt("petId", token.PetId) + , new ColumnInt("accountId", token.AccountId)); + } + }); } public List GetPetExtras(List petExtraTokens) @@ -41,20 +61,26 @@ public class PetRepository extends RepositoryBase return new JsonWebCall(_webAddress + "Pets/GetPetExtras").Execute(new TypeToken>(){}.getType(), petExtraTokens); } - public void UpdatePet(PetChangeToken token) + public void UpdatePet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token); - - int rowsChanged = executeUpdate("UPDATE accountPets SET petName = ? WHERE petId = ? AND accountId = ?;", new ColumnVarChar("petName", 32, token.PetName) + + Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + { + public void run() + { + int rowsChanged = executeUpdate("UPDATE accountPets SET petName = ? WHERE petId = ? AND accountId = ?;", new ColumnVarChar("petName", 32, token.PetName) + , new ColumnInt("petId", token.PetId) + , new ColumnInt("accountId", token.AccountId)); + + if (rowsChanged < 1) + { + executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName) , new ColumnInt("petId", token.PetId) , new ColumnInt("accountId", token.AccountId)); - - if (rowsChanged < 1) - { - executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName) - , new ColumnInt("petId", token.PetId) - , new ColumnInt("accountId", token.AccountId)); - } + } + } + }); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/DisplayType.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java similarity index 70% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/DisplayType.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java index 3045f5277..958fb9a0c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/DisplayType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import mineplex.core.common.Rank; @@ -13,9 +13,9 @@ public enum DisplayType switch (this) { case RANKED: - return rank.Has(Rank.ULTRA); + return rank.has(Rank.ULTRA); case NOT_RANKED: - return !rank.Has(Rank.ULTRA); + return !rank.has(Rank.ULTRA); default: return true; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PlayerPollData.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java similarity index 97% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PlayerPollData.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java index e0de0ec32..3465fae3b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PlayerPollData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import mineplex.core.common.util.NautHashMap; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java similarity index 95% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java index 1998173ff..715b1f275 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java @@ -1,6 +1,4 @@ -package mineplex.hub.poll; - -import mineplex.core.common.Rank; +package mineplex.core.poll; /** * Created by Shaun on 8/16/2014. diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java similarity index 83% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java index 8820efd46..09f0e4ec3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import java.sql.ResultSet; import java.sql.SQLException; @@ -23,9 +23,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.poll.command.PollCommand; +import mineplex.core.poll.command.PollCommand; public class PollManager extends MiniDbClientPlugin { @@ -64,7 +62,7 @@ public class PollManager extends MiniDbClientPlugin pollData.setPollCooldown(5000); } - @EventHandler + /*@EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) @@ -88,7 +86,7 @@ public class PollManager extends MiniDbClientPlugin pollData.updatePollCooldown(); } } - } + }*/ public Poll getNextPoll(PlayerPollData pollData, Rank playerRank) { @@ -101,6 +99,11 @@ public class PollManager extends MiniDbClientPlugin return null; } + public boolean hasPoll(Player player) + { + return getNextPoll(Get(player), getClientManager().Get(player).GetRank()) != null; + } + public void displayPoll(Player player, Poll poll) { String[] answers = poll.getAnswers(); @@ -146,6 +149,7 @@ public class PollManager extends MiniDbClientPlugin { final String name = player.getName(); final UUID uuid = player.getUniqueId(); + final int accountId = getClientManager().getAccountId(player); // First update answer locally so we know it was answered Get(player).addAnswer(poll.getId(), answer); @@ -166,17 +170,28 @@ public class PollManager extends MiniDbClientPlugin { if (completed) { - // Need to get out of Async code - _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() + _donationManager.RewardCoins(new Callback() { @Override - public void run() + public void run(Boolean completed) { - UtilPlayer.message(player, F.main("Poll", "Thanks for your response!")); - player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0); - UtilPlayer.message(player, F.main("Gem", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!")); + if (completed) + { + // Need to get out of Async code + _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() + { + @Override + public void run() + { + UtilPlayer.message(player, F.main("Carl", "Thanks for your response!")); + player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0); + UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!")); + UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Coins!")); + } + }); + } } - }); + }, "Poll", name, accountId, poll.getCoinReward()); } } }, "Poll", name, uuid, poll.getCoinReward()); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java similarity index 99% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollRepository.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java index e38e980ec..53884c66f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollStats.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java similarity index 97% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollStats.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java index 591302c01..5f3ecdb2a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; /** * Created by Shaun on 8/26/2014. diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/command/PollCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java similarity index 95% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/command/PollCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java index fe5997c79..68380927b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/command/PollCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll.command; +package mineplex.core.poll.command; import java.text.DecimalFormat; import java.util.List; @@ -13,10 +13,10 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.hub.poll.PlayerPollData; -import mineplex.hub.poll.Poll; -import mineplex.hub.poll.PollManager; -import mineplex.hub.poll.PollStats; +import mineplex.core.poll.PlayerPollData; +import mineplex.core.poll.Poll; +import mineplex.core.poll.PollManager; +import mineplex.core.poll.PollStats; /** * Created by Shaun on 8/17/2014. @@ -39,7 +39,7 @@ public class PollCommand extends CommandBase return; } - if (args[0].equalsIgnoreCase("list") && CommandCenter.GetClientManager().Get(caller).GetRank().Has(Rank.MODERATOR)) + if (args[0].equalsIgnoreCase("list") && CommandCenter.GetClientManager().Get(caller).GetRank().has(Rank.MODERATOR)) { if (args.length == 1) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java index 37d5d933c..b4ac74e62 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java @@ -43,7 +43,7 @@ public class ServerCommand extends CommandBase Plugin.doesServerExist(args[0], new Callback() { public void run(final Boolean serverExists) - { + { if (!serverExists) { UtilPlayer.message( @@ -58,32 +58,45 @@ public class ServerCommand extends CommandBase if (servUp.contains("HERO")) { - if (playerRank.Has(Rank.HERO)) + if (playerRank.has(Rank.HERO)) Plugin.sendPlayerToServer(player, args[0]); else deniedAccess = true; } else if (servUp.contains("ULTRA") || servUp.contains("BETA")) { - if (playerRank.Has(Rank.ULTRA)) + if (playerRank.has(Rank.ULTRA)) Plugin.sendPlayerToServer(player, args[0]); else deniedAccess = true; } else if (servUp.contains("STAFF")) { - if (playerRank.Has(Rank.HELPER)) + if (playerRank.has(Rank.HELPER)) Plugin.sendPlayerToServer(player, args[0]); else deniedAccess = true; } else if (servUp.contains("TEST")) { - if (playerRank.Has(Rank.MODERATOR)) + if (playerRank.has(Rank.MODERATOR)) Plugin.sendPlayerToServer(player, args[0]); else deniedAccess = true; } + else if (servUp.contains("CLANS-")) + { + if (playerRank.has(Rank.MODERATOR)) + { + Plugin.sendPlayerToServer(player, args[0]); + } + else + { + UtilPlayer.message(player, + F.main(Plugin.getName(), C.cRed + "You must join clans through the hub! Join " + C.cGold + "ClansHub-1" + + C.cRed + "!")); + } + } else { Plugin.sendPlayerToServer(player, args[0]); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 5523199f3..70ab28680 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -116,7 +116,7 @@ public class Portal extends MiniPlugin { public void run() { - if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.Has(Rank.ULTRA)) + if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA)) { sendPlayer(player, serverName); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index 6a96dcd16..c69ab7bed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -4,6 +4,19 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map.Entry; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.preferences.command.PreferencesCommand; +import mineplex.core.preferences.ui.PreferencesShop; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -11,18 +24,10 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.preferences.command.PreferencesCommand; -import mineplex.core.preferences.ui.PreferencesShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - public class PreferencesManager extends MiniDbClientPlugin { private PreferencesRepository _repository; @@ -53,6 +58,27 @@ public class PreferencesManager extends MiniDbClientPlugin _saveBuffer.put(caller.getUniqueId().toString(), Get(caller)); } + @EventHandler + public void givePlayerItem(PlayerJoinEvent event) + { + if (!GiveItem) + return; + + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM)) + { + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "My Profile"); + SkullMeta meta = ((SkullMeta) item.getItemMeta()); + meta.setOwner(player.getName()); + item.setItemMeta(meta); + + player.getInventory().setItem(8, item); + + UtilInv.Update(player); + } + } + @EventHandler public void storeBuffer(UpdateEvent event) { @@ -76,15 +102,6 @@ public class PreferencesManager extends MiniDbClientPlugin } }); } - - @EventHandler - public void givePlayerItem(PlayerJoinEvent event) - { - if (!GiveItem) - return; - - event.getPlayer().getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, ChatColor.GREEN + "/prefs")); - } @EventHandler(priority = EventPriority.LOWEST) public void playerInteract(PlayerInteractEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java index 31e1bb563..8007a3aef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java @@ -243,7 +243,7 @@ public class PreferencesPage extends ShopPageBase { public PreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager) { - super(plugin, clientManager, donationManager, "User Preferences"); + super(plugin, clientManager, donationManager, "My Preferences"); } @Override protected ShopPageBase> buildPagesFor(Player player) { - return new PreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(), " " + ChatColor.UNDERLINE + "User Preferences", player); + return new PreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(),"My Preferences", player); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java index 132500dc8..03f44665d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java @@ -1,6 +1,7 @@ package mineplex.core.projectile; import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; import java.util.WeakHashMap; @@ -13,6 +14,7 @@ import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.inventory.InventoryPickupItemEvent; @@ -75,10 +77,63 @@ public class ProjectileManager extends MiniPlugin long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult) { - _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, expireTime, hitPlayer, hitBlock, idle, false, sound, soundVolume, soundPitch, null, 0, effectRate, particle, pX, pY, pZ, pS, pC, hitboxMult)); } + + // WITH CAN HIT PLAYERS LIST: + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, float hitboxGrow, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + null, 1f, 1f, null, 0, null, null, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, boolean pickup, float hitboxGrow, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, pickup, + null, 1f, 1f, null, 0, null, null, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, Effect effect, int effectData, UpdateType effectRate , float hitboxGrow, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, effect, effectData, effectRate, null, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, Effect effect, int effectData, UpdateType effectRate, float hitboxGrow, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, effect, effectData, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, pX, pY, pZ, pS, pC, hitboxMult, canHit)); + } @EventHandler public void Update(UpdateEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index 6c94d9e00..3d71c0831 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -1,5 +1,7 @@ package mineplex.core.projectile; +import java.util.List; + import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -55,13 +57,51 @@ public class ProjectileUser private UpdateType _effectRate = UpdateType.TICK; private double _hitboxGrow; + + private List _canHit; + + public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, boolean pickup, + Sound sound, float soundVolume, float soundPitch, + Effect effect, int effectData, UpdateType effectRate, + ParticleType particle, float particleX, float particleY, + float particleZ, float particleS, int particleC, double hitboxMult) + { + Throw = throwInput; + + _thrown = thrown; + _thrower = thrower; + _callback = callback; + + _expireTime = expireTime; + _hitPlayer = hitPlayer; + _hitBlock = hitBlock; + _idle = idle; + _pickup = pickup; + + _sound = sound; + _soundVolume = soundVolume; + _soundPitch = soundPitch; + _particle = particle; + _particleX = particleX; + _particleY = particleY; + _particleZ = particleZ; + _particleS = particleS; + _particleC = particleC; + _effect = effect; + _effectData = effectData; + _effectRate = effectRate; + + _hitboxGrow = hitboxMult; + _canHit = null; + } public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, boolean pickup, Sound sound, float soundVolume, float soundPitch, Effect effect, int effectData, UpdateType effectRate, ParticleType particle, float particleX, float particleY, - float particleZ, float particleS, int particleC, double hitboxMult) + float particleZ, float particleS, int particleC, double hitboxMult, List canHit) { Throw = throwInput; @@ -89,6 +129,7 @@ public class ProjectileUser _effectRate = effectRate; _hitboxGrow = hitboxMult; + _canHit = canHit; } public void Effect(UpdateEvent event) @@ -152,11 +193,22 @@ public class ProjectileUser if (ent.equals(_thrower)) continue; - //Creative or Spec + //Creative or Spec or No Hit if (ent instanceof Player) - if (((Player)ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + { + if (((Player)ent).getGameMode() == GameMode.CREATIVE) continue; + if (UtilPlayer.isSpectator(ent)) + continue; + + if (_canHit != null) + { + if (!_canHit.contains(((Player)ent))) + continue; + } + } + //float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); AxisAlignedBB axisalignedbb1 = ((CraftEntity)ent).getHandle().boundingBox.grow(1F, 1F, 1F); MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index adaceb736..9336697f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -113,24 +113,30 @@ public class Punish extends MiniPlugin UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); UtilPlayer.message(caller, F.help("/punish", " ", Rank.MODERATOR)); } - + public void AddPunishment(final String playerName, final Category category, final String reason, final Player caller, final int severity, boolean ban, long duration) + { + AddPunishment(playerName, category, reason, caller == null ? null : caller.getName(), severity, ban, duration, false); + } + + public void AddPunishment(final String playerName, final Category category, final String reason, final String callerName, final int severity, boolean ban, long duration, final boolean silent) { if (!_punishClients.containsKey(playerName.toLowerCase())) { _punishClients.put(playerName.toLowerCase(), new PunishClient()); } - + + final Player caller = (callerName == null ? null : UtilPlayer.searchExact(callerName)); final PunishmentSentence sentence = !ban ? PunishmentSentence.Mute : PunishmentSentence.Ban; final long finalDuration = duration; - + _repository.Punish(new Callback() { public void run(String result) { PunishmentResponse banResult = PunishmentResponse.valueOf(result); - + if (banResult == PunishmentResponse.AccountDoesNotExist) { if (caller != null) @@ -159,10 +165,9 @@ public class Punish extends MiniPlugin public void run() { String kickReason = C.cRed + C.Bold + "You were banned for " + durationString + " by " + (caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + - "\n" + C.cWhite + reason + - "\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals" - ; - + "\n" + C.cWhite + reason + + "\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals"; + Player target = UtilPlayer.searchOnline(null, playerName, false); if (target != null) target.kickPlayer(kickReason); @@ -170,8 +175,11 @@ public class Punish extends MiniPlugin new mineplex.serverdata.commands.PunishCommand(playerName, true, false, kickReason).publish(); } }); - - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + ".")); + + if (!silent) + { + informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + ".")); + } } else { @@ -181,9 +189,19 @@ public class Punish extends MiniPlugin //Warning if (finalDuration == 0) - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + playerName + ".")); + { + if (!silent) + { + informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + playerName + ".")); + } + } else - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + ".")); + { + if (!silent) + { + informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + ".")); + } + } //Inform Player target = UtilPlayer.searchExact(playerName); @@ -207,14 +225,14 @@ public class Punish extends MiniPlugin } - }, playerName, category.toString(), sentence, reason, duration, caller == null ? "Mineplex Anti-Cheat" : caller.getName(), severity); + }, playerName, category.toString(), sentence, reason, duration, callerName == null ? "Mineplex Anti-Cheat" : callerName, severity); } private void informOfPunish(String punishee, String msg) { for (Player player : UtilServer.getPlayers()) { - if (_clientManager.Get(player).GetRank().Has(Rank.HELPER) || player.getName().equals(punishee)) + if (_clientManager.Get(player).GetRank().has(Rank.HELPER) || player.getName().equals(punishee)) { player.sendMessage(msg); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java index b2a8768aa..26f3a626c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java @@ -137,7 +137,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener examplePrefixNote + "Give Warning if 0 Past Offences and 0 Warnings.", }, 1, false, true), new PunishButton(this, Category.ChatOffense, 1, false, getDuration(Category.ChatOffense, 1, offenseMap))); - if (_plugin.GetClients().Get(_player).GetRank().Has(Rank.MODERATOR)) + if (_plugin.GetClients().Get(_player).GetRank().has(Rank.MODERATOR)) { AddButton(28, new ShopItem(Material.INK_SACK, (byte)11, "Severity 2", new String[] { ChatColor.RESET + "Past Offences: " + ChatColor.YELLOW + offenseMap.get(Category.ChatOffense).get(2), @@ -221,7 +221,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener examplePrefixEx + " Player Radar", }, 1, false, true), new PunishButton(this, Category.Hacking, 1, true, getDuration(Category.Hacking, 1, offenseMap))); - if (_plugin.GetClients().Get(_player).GetRank().Has(Rank.MODERATOR)) + if (_plugin.GetClients().Get(_player).GetRank().has(Rank.MODERATOR)) { AddButton(32, new ShopItem(Material.INK_SACK, (byte)11, "Severity 2",new String[] @@ -274,7 +274,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener }, 1, false, true), new PunishButton(this, Category.Warning, 1, false, 0)); - if (_plugin.GetClients().Get(_player).GetRank().Has(Rank.MODERATOR)) + if (_plugin.GetClients().Get(_player).GetRank().has(Rank.MODERATOR)) { AddButton(34, new ShopItem(Material.REDSTONE_BLOCK, (byte)0, "Permanent Ban", new String[] { ChatColor.RESET + "Ban Duration: " + ChatColor.YELLOW + "Permanent", diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java index 67659dc64..3bd5e8202 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java @@ -27,6 +27,8 @@ public abstract class Reward protected abstract RewardData giveRewardCustom(Player player); + public abstract RewardData getFakeRewardData(Player player); + public abstract boolean canGiveReward(Player player); public RewardRarity getRarity() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java index 77f8b91e3..0a20e5ccf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java @@ -9,11 +9,13 @@ public class RewardData { private final String _friendlyName; private final ItemStack _displayItem; + private final RewardRarity _rarity; - public RewardData(String friendlyName, ItemStack displayItem) + public RewardData(String friendlyName, ItemStack displayItem, RewardRarity rarity) { _friendlyName = friendlyName; _displayItem = displayItem; + _rarity = rarity; } public String getFriendlyName() @@ -26,4 +28,9 @@ public class RewardData return _displayItem; } + public RewardRarity getRarity() + { + return _rarity; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 775ab3cd5..f8be21c1d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -18,27 +18,32 @@ import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; import mineplex.core.reward.rewards.CoinReward; +import mineplex.core.reward.rewards.ExperienceReward; +import mineplex.core.reward.rewards.GemReward; import mineplex.core.reward.rewards.InventoryReward; import mineplex.core.reward.rewards.PetReward; import mineplex.core.reward.rewards.RankReward; import mineplex.core.reward.rewards.UnknownPackageReward; +import mineplex.core.stats.StatsManager; +import mineplex.core.timing.TimingManager; public class RewardManager { private JavaPlugin _plugin; private HashMap> _treasureMap; private Random _random; - + private boolean _carlSpinner; + private CoreClientManager _clientManager; - + private boolean _doubleGadgetValue; - - public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, - int commonValueMin, int commonValueMax, - int uncommonValueMin, int uncommonValueMax, - int rareValueMin, int rareValueMax, - int legendValueMin, int legendValueMax, - boolean doubleGadgetValue) + + public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, + int commonValueMin, int commonValueMax, + int uncommonValueMin, int uncommonValueMax, + int rareValueMin, int rareValueMax, + int legendValueMin, int legendValueMax, + boolean doubleGadgetValue, boolean carlSpinner) { _plugin = donationManager.getPlugin(); _treasureMap = new HashMap>(); @@ -48,23 +53,33 @@ public class RewardManager { _treasureMap.put(rarity, new ArrayList()); } - - _clientManager = clientManager; - - _doubleGadgetValue = doubleGadgetValue; - addCommon(donationManager, inventoryManager, petManager, commonValueMin, commonValueMax); - addUncommon(donationManager, inventoryManager, petManager, uncommonValueMin, uncommonValueMax); - addRare(donationManager, inventoryManager, petManager, rareValueMin, rareValueMax); - addLegendary(donationManager, inventoryManager, petManager, legendValueMin, legendValueMax); + _clientManager = clientManager; + + _doubleGadgetValue = doubleGadgetValue; + _carlSpinner = carlSpinner; + + addCommon(donationManager, inventoryManager, petManager, statsManager, commonValueMin, commonValueMax); + addUncommon(donationManager, inventoryManager, petManager, statsManager, uncommonValueMin, uncommonValueMax); + addRare(donationManager, inventoryManager, petManager, statsManager, rareValueMin, rareValueMax); + addLegendary(donationManager, inventoryManager, petManager, statsManager, legendValueMin, legendValueMax); } - public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.COMMON; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1, rarity)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 25, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 5, rarity)); + } //Increase Value if (_doubleGadgetValue) @@ -72,43 +87,54 @@ public class RewardManager minValue *= 2; maxValue *= 2; } - + // Gadgets addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun", (int)(100*(minValue/500)), (int)(100*(maxValue/500)), new ItemStack(Material.GOLD_BARDING), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.FIREWORK), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.MELON_BLOCK), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook", (int)(40*(minValue/500)), (int)(40*(maxValue/500)), new ItemStack(Material.getMaterial(131)), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl", (int)(30*(minValue/500)), (int)(30*(maxValue/500)), new ItemStack(Material.ENDER_PEARL), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.IRON_BARDING), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "TNT", "TNT", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.TNT), rarity, 10)); + + } - public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.UNCOMMON; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 1200, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1200, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 1200, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON)); + } //Increase Value if (_doubleGadgetValue) @@ -116,32 +142,32 @@ public class RewardManager minValue *= 2; maxValue *= 2; } - + // Gadgets addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun", (int)(100*(minValue/500)), (int)(100*(maxValue/500)), new ItemStack(Material.GOLD_BARDING), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.FIREWORK), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.MELON_BLOCK), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook", (int)(40*(minValue/500)), (int)(40*(maxValue/500)), new ItemStack(Material.getMaterial(131)), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl", (int)(30*(minValue/500)), (int)(30*(maxValue/500)), new ItemStack(Material.ENDER_PEARL), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.IRON_BARDING), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "TNT", "TNT", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.TNT), rarity, 250)); @@ -189,12 +215,22 @@ public class RewardManager new ItemStack(2267), rarity, 25)); } - public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.RARE; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 150, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 150, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 150, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE)); + } + // Mounts addReward(new UnknownPackageReward(donationManager, "Mount Mule", "Mount Mule", @@ -215,7 +251,7 @@ public class RewardManager new ItemStack(Material.FEATHER), rarity, 50)); addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph", new ItemStack(Material.ENDER_PEARL), rarity, 33)); - + // Gadgets addReward(new InventoryReward(inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1, @@ -238,15 +274,23 @@ public class RewardManager new ItemStack(Material.GOLD_LEGGINGS), rarity, 50)); addReward(new UnknownPackageReward(donationManager, "Space Boots", "Space Boots", new ItemStack(Material.GOLD_BOOTS), rarity, 50)); - } - public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.LEGENDARY; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 10, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 10, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 10, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); + } // Mounts addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror", @@ -257,6 +301,8 @@ public class RewardManager new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), rarity, 25)); addReward(new UnknownPackageReward(donationManager, "Block Morph", "Block Morph", new ItemStack(Material.EMERALD_BLOCK), rarity, 20)); + addReward(new UnknownPackageReward(donationManager, "Big Larry Morph", "Big Larry Morph", + new ItemStack(Material.SLIME_BALL), rarity, 10)); // Particles addReward(new UnknownPackageReward(donationManager, "Shadow Walk Particles", "Shadow Walk", @@ -269,12 +315,14 @@ public class RewardManager new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), rarity, 13)); addReward(new UnknownPackageReward(donationManager, "Blood Helix Particles", "Blood Helix", new ItemStack(Material.REDSTONE), rarity, 10)); - addReward(new UnknownPackageReward(donationManager, "Emerald Twirl Particles", "Green Ring", + addReward(new UnknownPackageReward(donationManager, "Green Rings Particles", "Green Ring", new ItemStack(Material.EMERALD), rarity, 8)); addReward(new UnknownPackageReward(donationManager, "Flame Fairy Particles", "Flame Fairy", new ItemStack(Material.APPLE), rarity, 4)); addReward(new UnknownPackageReward(donationManager, "Heart Particles", "I Heart You", new ItemStack(Material.BLAZE_POWDER), rarity, 2)); + + } public void addReward(Reward reward) @@ -306,13 +354,13 @@ public class RewardManager { hasUncommon = true; } - + //Only allow 1 Mythical if (reward.getRarity().ordinal() >= RewardRarity.MYTHICAL.ordinal()) { canGiveMythical = false; } - + rewards[currentReward] = reward; currentReward++; } @@ -339,11 +387,11 @@ public class RewardManager public Reward nextReward(Player player, Reward[] excludedRewards, boolean requiresUncommon, RewardType type, boolean canGiveMythical) { RewardRarity rarity = type.generateRarity(requiresUncommon); - + //Dont give Rank Upgrade if already has Legend if (rarity == RewardRarity.MYTHICAL) { - if (!canGiveMythical || _clientManager.Get(player).GetRank().Has(Rank.LEGEND)) + if (!canGiveMythical || _clientManager.Get(player).GetRank().has(Rank.LEGEND)) { rarity = RewardRarity.LEGENDARY; } @@ -352,7 +400,7 @@ public class RewardManager return new RankReward(_clientManager, 0, rarity); } } - + List treasureList = _treasureMap.get(rarity); int totalWeight = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java index fc186ed03..1f56de46a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java @@ -1,5 +1,9 @@ package mineplex.core.reward; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + import mineplex.core.common.util.C; import static mineplex.core.common.util.C.*; @@ -14,20 +18,31 @@ public enum RewardRarity * (Fireworks, sounds, etc) */ - OTHER("Other", cWhite), - COMMON("Common", cWhite), - UNCOMMON("Uncommon", cAqua), - RARE("Rare", cPurple), - LEGENDARY("Legendary", cGreen), - MYTHICAL("Mythical", cRed); + OTHER("Other", cWhite, Material.STAINED_GLASS_PANE, (byte) 0), + COMMON("Common", cWhite, Material.STAINED_GLASS_PANE, (byte) 0), + GAME("Game", cYellow, Material.STAINED_GLASS_PANE, (byte) 4), + UNCOMMON("Uncommon", cAqua, Material.STAINED_GLASS_PANE, (byte) 3), + RARE("Rare", cPurple, Material.STAINED_GLASS_PANE, (byte) 10), + LEGENDARY("Legendary", cGreen, Material.STAINED_GLASS_PANE, (byte) 5), + MYTHICAL("Mythical", cRed, Material.STAINED_GLASS_PANE, (byte) 14); private String _name; private String _color; + private Material _material; + private byte _data; + private ItemStack _stack; - RewardRarity(String name, String color) + RewardRarity(String name, String color, Material material, byte data) { _name = name; _color = color; + _material = material; + _data = data; + + _stack = new ItemStack(getMaterial(), 1, (short) 0, getData()); + ItemMeta meta = _stack.getItemMeta(); + meta.setDisplayName(_color + _name); + _stack.setItemMeta(meta); } public String getColor() @@ -40,4 +55,19 @@ public enum RewardRarity return _name; } + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public ItemStack getItemStack() + { + return _stack; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index b40559d74..b226448c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -4,15 +4,19 @@ public enum RewardType { //% Chances Mythic Legend Rare Uncommon GameLoot( 0.000001, 0.00001, 0.0001, 3), + OldChest( 0, 0.05, 0.4, 5), AncientChest( 0, 1, 4, 25), - MythicalChest( 0.4, 3, 12, 75); + MythicalChest( 0.4, 3, 12, 75), + SpinnerFiller( 0.1, 1, 4, 20), + SpinnerReal( 0.000001, 0.05, 0.4, 5); + private double _mythicalChance; private double _legendaryChance; private double _rareChance; private double _uncommonChance; - + RewardType(double mythical, double legend, double rare, double uncommon) { _mythicalChance = (mythical / 100d); @@ -24,9 +28,9 @@ public enum RewardType public RewardRarity generateRarity(boolean requiresUncommon) { double rand = Math.random(); - + RewardRarity rarity = RewardRarity.COMMON; - + if (rand <= _mythicalChance) rarity = RewardRarity.MYTHICAL; else if (rand <= _legendaryChance) rarity = RewardRarity.LEGENDARY; else if (rand <= _rareChance) rarity = RewardRarity.RARE; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java index a0023e137..1bf59afb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java @@ -37,7 +37,7 @@ public class CoinReward extends Reward @Override public RewardData giveRewardCustom(Player player) { - int gemsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount; + int coinsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount; _donationManager.RewardCoins(new Callback() { @@ -46,9 +46,15 @@ public class CoinReward extends Reward { } - }, "Treasure Chest", player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), gemsToReward); + }, "Treasure Chest", player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), coinsToReward); - return new RewardData(getRarity().getColor() + gemsToReward + " Coins", new ItemStack(175)); + return new RewardData(getRarity().getColor() + coinsToReward + " Coins", new ItemStack(175), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + "Coins", new ItemStack(175), getRarity()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ExperienceReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ExperienceReward.java new file mode 100644 index 000000000..ad1ad3b5b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ExperienceReward.java @@ -0,0 +1,52 @@ +package mineplex.core.reward.rewards; + +import java.util.Random; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.stats.StatsManager; + +public class ExperienceReward extends Reward +{ + private StatsManager _statsManager; + private Random _random; + private int _minExperience; + private int _maxExperience; + + public ExperienceReward(StatsManager statsManager, int minExperience, int maxExperience, int weight, RewardRarity rarity) + { + super(rarity, weight); + + _statsManager = statsManager; + _random = new Random(); + _minExperience = minExperience; + _maxExperience = maxExperience; + } + + @Override + protected RewardData giveRewardCustom(Player player) + { + int experience = _random.nextInt(_maxExperience - _minExperience) + _minExperience; + + _statsManager.incrementStat(player, "Global.ExpEarned", experience); + + return new RewardData(getRarity().getColor() + experience + " Experience", new ItemStack(Material.EXP_BOTTLE), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + "Experience", new ItemStack(Material.EXP_BOTTLE), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GemReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GemReward.java new file mode 100644 index 000000000..26e695abb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GemReward.java @@ -0,0 +1,75 @@ +package mineplex.core.reward.rewards; + +import java.util.Random; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.Callback; +import mineplex.core.donation.DonationManager; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardManager; +import mineplex.core.reward.RewardRarity; + +public class GemReward extends Reward +{ + private DonationManager _donationManager; + private Random _random; + private int _minGemCount; + private int _maxGemCount; + + public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity) + { + this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM); + } + + public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity, Random random) + { + super(rarity, weight); + _donationManager = donationManager; + _minGemCount = minGemCount; + _maxGemCount = maxGemCount; + + _random = random; + } + + @Override + public RewardData giveRewardCustom(Player player) + { + int GemsToReward = _random.nextInt(_maxGemCount - _minGemCount) + _minGemCount; + + _donationManager.RewardGems(new Callback() + { + @Override + public void run(Boolean data) + { + + } + }, "Treasure Chest", player.getName(), player.getUniqueId(), GemsToReward); + + return new RewardData(getRarity().getColor() + GemsToReward + " Gems", new ItemStack(Material.EMERALD), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + "Gems", new ItemStack(Material.EMERALD), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof GemReward) + return true; + + return false; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java index 83c219e1c..0eb1504e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java @@ -59,7 +59,13 @@ public class InventoryReward extends Reward _inventoryManager.addItemToInventory(player, "Item", _packageName, amountToGive); - return new RewardData(getRarity().getColor() + amountToGive + " " + _name, _itemStack); + return new RewardData(getRarity().getColor() + amountToGive + " " + _name, _itemStack, getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java index 815edb705..ca694776a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -33,18 +33,32 @@ public class RankReward extends Reward else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; if (rank == null) - return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER)); + return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity()); _clientManager.Get(player).SetRank(rank); _clientManager.getRepository().saveRank(null, player.getName(), player.getUniqueId(), rank, true); - return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR)); + return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + Rank rank = null; + if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA; + else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO; + else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; + + if (rank == null) + return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity()); + + return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity()); } @Override public boolean canGiveReward(Player player) { - return !_clientManager.Get(player).GetRank().Has(Rank.LEGEND); + return !_clientManager.Get(player).GetRank().has(Rank.LEGEND); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index 6e041ee9b..af27a817e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -33,7 +33,7 @@ public class UnknownPackageReward extends Reward { _donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, true, 0, true); - return new RewardData(getRarity().getColor() + _name, _itemStack); + return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity()); } @Override @@ -48,6 +48,12 @@ public class UnknownPackageReward extends Reward return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName); } + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity()); + } + protected String getPackageName() { return _packageName; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java index f60381a72..86c226a5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java @@ -39,7 +39,7 @@ public class PlayerScoreboard for (Rank rank : Rank.values()) { if (rank != Rank.ALL) - _scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " "); + _scoreboard.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); else _scoreboard.registerNewTeam(rank.Name).setPrefix(""); } @@ -54,12 +54,12 @@ public class PlayerScoreboard String rankName = _manager.getClients().Get(player).GetRank().Name; String otherRankName = _manager.getClients().Get(otherPlayer).GetRank().Name; - if (!_manager.getClients().Get(player).GetRank().Has(Rank.ULTRA) && _manager.getDonation().Get(player.getName()).OwnsUltraPackage()) + if (!_manager.getClients().Get(player).GetRank().has(Rank.ULTRA) && _manager.getDonation().Get(player.getName()).OwnsUltraPackage()) { rankName = Rank.ULTRA.Name; } - if (!_manager.getClients().Get(otherPlayer).GetRank().Has(Rank.ULTRA) && _manager.getDonation().Get(otherPlayer.getName()).OwnsUltraPackage()) + if (!_manager.getClients().Get(otherPlayer).GetRank().has(Rank.ULTRA) && _manager.getDonation().Get(otherPlayer.getName()).OwnsUltraPackage()) { otherRankName = Rank.ULTRA.Name; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java index 7c7904e7e..694e600f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java @@ -14,7 +14,7 @@ public class ScoreboardElementRank extends ScoreboardElement { ArrayList output = new ArrayList(); - if (manager.getClients().Get(player).GetRank().Has(Rank.ULTRA)) + if (manager.getClients().Get(player).GetRank().has(Rank.ULTRA)) { output.add(manager.getClients().Get(player).GetRank().Name); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java index 02cc887b0..f4f883083 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java @@ -56,7 +56,7 @@ public class ServerConfiguration extends MiniPlugin @EventHandler public void onPlayerLogin(PlayerLoginEvent event) { - if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.HELPER, false)) + if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) event.disallow(Result.KICK_OTHER, "This is a staff only server."); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java index 4f46b6f0f..67f346fd0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java @@ -138,7 +138,7 @@ public abstract class ShopPageBase= 0) { if (event.getInventory().getTitle() == inventory.getInventoryName() && (inventory.getSize() <= event.getSlot() || inventory.getItem(event.getSlot()) != null)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java new file mode 100644 index 000000000..0546c0de6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java @@ -0,0 +1,123 @@ +package mineplex.core.shop.page; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.item.IButton; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public abstract class ShopPageInventory> extends + ShopPageBase +{ + private int _page; + + public ShopPageInventory(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, + String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player, 54); + } + + public PluginType getPlugin() + { + return (PluginType) super.getPlugin(); + } + + public ShopPageInventory(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, + String name, Player player, int slots) + { + super(plugin, shop, clientManager, donationManager, name, player, slots); + } + + protected abstract IButton[] getButtons(); + + protected abstract ItemStack[] getItems(); + + protected abstract void buildItems(); + + @Override + protected final void buildPage() + { + clearPage(); + buildItems(); + + IButton[] buttons = getButtons(); + ItemStack[] items = getItems(); + + int maxLen = Math.max(items.length, buttons.length); + boolean pages = maxLen > getSize(); + + _page = Math.max(0, Math.min(_page, pages ? (int) Math.ceil(maxLen / (double) (getSize() - 9)) - 1 : 0)); + + int start = pages ? _page * (getSize() - 9) : 0; + + for (int slot = 0; slot < (pages ? getSize() - 9 : getSize()); slot++) + { + IButton button = null; + ItemStack item = null; + + if (slot + start < buttons.length) + { + button = buttons[slot + start]; + } + + if (slot + start < items.length) + { + item = items[slot + start]; + } + + if (button != null) + { + super.addButton(slot, item, button); + } + else + { + setItem(slot, item); + } + } + + if (pages) + { + for (int slot = 0; slot < 9; slot++) + { + int realSlot = getSize() - (9 - slot); + + if ((slot == 0 && _page > 0) || (slot == 8 && maxLen > (_page + 1) * (getSize() - 9))) + { + final int nextPage = slot == 0 ? _page - 1 : _page + 1; + + ItemBuilder builder = new ItemBuilder(Material.SIGN); + builder.setTitle(slot == 0 ? "Previous Page" : "Next Page"); + builder.setAmount(nextPage + 1); + + super.addButton(realSlot, builder.build(), new IButton() + { + + @Override + public void onClick(Player player, ClickType clickType) + { + setPage(nextPage); + } + }); + } + else if (slot == 4) + { + ItemStack item = new ItemBuilder(Material.PAPER).setTitle("Page " + (_page + 1)).setAmount(_page + 1).build(); + + setItem(realSlot, item); + } + } + } + } + + public void setPage(int newPage) + { + _page = newPage; + buildPage(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java index b5caa1745..9ceb59d83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java @@ -10,6 +10,8 @@ public class PlayerStats public long addStat(String statName, long value) { + value = Math.max(0L, value); + if (!_statHash.containsKey(statName)) { _statHash.put(statName, 0L); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java deleted file mode 100644 index eb13e4940..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java +++ /dev/null @@ -1,184 +0,0 @@ -package mineplex.core.stats; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.jooq.Configuration; -import org.jooq.DSLContext; -import org.jooq.Delete; -import org.jooq.Insert; -import org.jooq.SQLDialect; -import org.jooq.TransactionalRunnable; -import org.jooq.Update; -import org.jooq.impl.DSL; - -import mineplex.core.account.ILoginProcessor; -import mineplex.core.database.DBPool; -import mineplex.database.Tables; -import org.jooq.types.ULong; - -public class SecondaryStatHandler implements ILoginProcessor -{ - private StatsManager _statsManager; - private StatsRepository _repository; - - public SecondaryStatHandler(StatsManager statsManager, StatsRepository repository) - { - _statsManager = statsManager; - _repository = repository; - } - - @Override - public String getName() - { - return "Secondary Stat Handler"; - } - - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - PlayerStats oldPlayerStats = _statsManager.Get(playerName); - PlayerStats newPlayerStats = _repository.loadClientInformation(resultSet); - - if (newPlayerStats.getStatsNames().size() == 0 && oldPlayerStats.getStatsNames().size() != 0) - { - try - { - DSLContext context = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); - - final List inserts = new ArrayList<>(); - - for (String statName : oldPlayerStats.getStatsNames()) - { - Integer statId = _statsManager.getStatId(statName); - - Insert insert = context - .insertInto(Tables.accountStat) - .set(Tables.accountStat.accountId, accountId) - .set(Tables.accountStat.statId, statId) - .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))); - - inserts.add(insert); - } - - context.transaction(new TransactionalRunnable() - { - @Override - public void run(Configuration config) throws Exception - { - DSL.using(config).batch(inserts).execute(); - } - }); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - else - { - _statsManager.replacePlayerHack(playerName, newPlayerStats); - - if (oldPlayerStats.getStatsNames().size() != 0) - { - try - { - final DSLContext context = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); - final List updates = new ArrayList<>(); - final List inserts = new ArrayList<>(); - boolean foundNegativeStat = false; - boolean foundLessThanStat = false; - - for (String statName : oldPlayerStats.getStatsNames()) - { - Integer statId = _statsManager.getStatId(statName); - - Insert insert = context - .insertInto(Tables.accountStat) - .set(Tables.accountStat.accountId, accountId) - .set(Tables.accountStat.statId, statId) - .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))); - - inserts.add(insert); - - Update update = context - .update(Tables.accountStat) - .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))) - .where(Tables.accountStat.accountId.eq(accountId)) - .and(Tables.accountStat.statId.eq(statId)); - - updates.add(update); - - if (oldPlayerStats.getStat(statName) < 0) - { - foundNegativeStat = true; - } - else if (newPlayerStats.getStat(statName) < oldPlayerStats.getStat(statName)) - { - foundLessThanStat = true; - } - } - - if (foundNegativeStat && foundLessThanStat) - { - context.transaction(new TransactionalRunnable() - { - @Override - public void run(Configuration config) throws Exception - { - int[] updateResult = context.batch(updates).execute(); - - for (int i = 0; i < updateResult.length; i++) - { - if (updateResult[i] > 0) - inserts.set(i, null); - } - - inserts.removeAll(Collections.singleton(null)); - - context.batch(inserts).execute(); - - System.out.println("Updating"); - } - }); - } - -/* - final List deletes = new ArrayList<>(); - - for (String statName : oldPlayerStats.getStatsNames()) - { - Delete delete = context.delete(Tables.accountStats) - .where(Tables.accountStats.accountId.equal(accountId)); - - deletes.add(delete); - } - - context.transaction(new TransactionalRunnable() - { - @Override - public void run(Configuration config) throws Exception - { - DSL.using(config).batch(deletes).execute(); - } - }); - */ - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } - } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT stats.name, value FROM accountStat INNER JOIN stats ON stats.id = accountStat.statId WHERE accountStat.accountId = '" + accountId + "';"; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index ef9fbad63..7c8a2dd9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -1,28 +1,22 @@ package mineplex.core.stats; -import java.lang.reflect.Field; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; -import net.minecraft.server.v1_7_R4.EntityHuman; -import net.minecraft.util.com.mojang.authlib.GameProfile; - -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; import mineplex.core.stats.command.TimeCommand; import mineplex.core.stats.event.StatChangeEvent; +import mineplex.playerCache.PlayerCache; public class StatsManager extends MiniDbClientPlugin { @@ -57,8 +51,33 @@ public class StatsManager extends MiniDbClientPlugin { _stats.put(stat.Name, stat.Id); } + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + PlayerStats playerStats = Get(event.getPlayer()); - clientManager.addStoredProcedureLoginProcessor(new SecondaryStatHandler(this, _repository)); + final int accountId = getClientManager().getAccountId(event.getPlayer()); + + for (String statName : playerStats.getStatsNames()) + { + if (!_stats.containsKey(statName)) + continue; + + final int statId = _stats.get(statName); + + if (playerStats.getStat(statName) == -1) + { + runAsync(new Runnable() + { + public void run() + { + _repository.setStat(accountId, statId, 0); + } + }); + } + } } public void incrementStat(final Player player, final String statName, final long value) @@ -74,7 +93,7 @@ public class StatsManager extends MiniDbClientPlugin // Verify stat is in our local cache, if not add it remotely. if (!_stats.containsKey(statName)) { - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + runAsync(new Runnable() { public void run() { @@ -141,7 +160,7 @@ public class StatsManager extends MiniDbClientPlugin if (player.isOnline()) continue; - int uploadKey = ClientManager.getCachedClientAccountId(player.getUniqueId()); + int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); uploadQueue.put(uploadKey, new NautHashMap()); @@ -221,6 +240,6 @@ public class StatsManager extends MiniDbClientPlugin @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId WHERE accountStats.accountId = '" + accountId + "';"; + return "SELECT stats.name, value FROM accountStat INNER JOIN stats ON stats.id = accountStat.statId WHERE accountStat.accountId = '" + accountId + "';"; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index e1524436d..2b92728ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -26,9 +26,6 @@ import org.jooq.types.ULong; public class StatsRepository extends RepositoryBase { - private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX nameIndex (name));"; - private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));"; - private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; @@ -38,16 +35,10 @@ public class StatsRepository extends RepositoryBase } @Override - protected void initialize() - { - //executeUpdate(CREATE_STAT_TABLE); - //executeUpdate(CREATE_STAT_RELATION_TABLE); - } + protected void initialize() { } @Override - protected void update() - { - } + protected void update() { } public List retrieveStats() { @@ -165,9 +156,36 @@ public class StatsRepository extends RepositoryBase while (resultSet.next()) { - playerStats.addStat(resultSet.getString(1), resultSet.getInt(2)); + try + { + playerStats.addStat(resultSet.getString(1), resultSet.getLong(2)); + } + catch (Exception ex) + { + ex.printStackTrace(); + playerStats.addStat(resultSet.getString(1), -1); + } } return playerStats; } + + public void setStat(int accountId, int statId, long value) + { + try + { + DSLContext context = DSL.using(getConnectionPool(), SQLDialect.MYSQL); + + context + .update(Tables.accountStat) + .set(Tables.accountStat.value, ULong.valueOf(value)) + .where(Tables.accountStat.accountId.eq(accountId)) + .and(Tables.accountStat.statId.eq(statId)) + .execute(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java index 60212f1d0..d7815f41b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java @@ -13,7 +13,7 @@ public class GiveStatCommand extends CommandBase { public GiveStatCommand(StatsManager plugin) { - super(plugin, Rank.OWNER, "givestat"); + super(plugin, Rank.ADMIN, "givestat"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index 520d2417e..a51b92a7f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.Collection; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -163,8 +164,18 @@ public class ServerStatusManager extends MiniPlugin int ram = (int) ((Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / 1048576); int maxRam = (int) (Runtime.getRuntime().maxMemory() / 1048576); + int donorsOnline = 0; + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_clientManager.Get(player).GetRank().isDonor()) + { + donorsOnline++; + } + } + return new MinecraftServer(_name, group, motd, address, port, playerCount, - maxPlayerCount, tps, ram, maxRam, _startUpDate); + maxPlayerCount, tps, ram, maxRam, _startUpDate, donorsOnline); } public String getCurrentServerName() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index 2ecce2580..83f495718 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -14,6 +14,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.task.repository.TaskRepository; +import mineplex.playerCache.PlayerCache; public class TaskManager extends MiniDbClientPlugin { @@ -68,7 +69,7 @@ public class TaskManager extends MiniDbClientPlugin synchronized (_taskLock) { - final boolean success = _repository.addAccountTask(ClientManager.getCachedClientAccountId(uuid), _tasks.get(task)); + final boolean success = _repository.addAccountTask(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _tasks.get(task)); if (callback != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java index 4b198fb39..3f4d5b97d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java @@ -49,7 +49,7 @@ public class BackCommand extends CommandBase int back = 0; for (int i = 0 ; i < amount ; i++) { - if (Plugin.GetTPHistory(player).isEmpty()) + if (Plugin.GetTPHistory(player) == null || Plugin.GetTPHistory(player).isEmpty()) break; loc = Plugin.GetTPHistory(player).removeFirst(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java index 7ca0a1f23..fd3f76684 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java @@ -23,15 +23,15 @@ public class TeleportCommand extends MultiCommandBase protected void Help(Player caller, String[] args) { //Caller to Player - if (args.length == 1 && CommandCenter.GetClientManager().Get(caller).GetRank().Has(caller, Rank.MODERATOR, true)) + if (args.length == 1 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.MODERATOR, true)) Plugin.playerToPlayer(caller, caller.getName(), args[0]); //Player to Player - else if (args.length == 2 && CommandCenter.GetClientManager().Get(caller).GetRank().Has(caller, Rank.ADMIN, true)) + else if (args.length == 2 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true)) Plugin.playerToPlayer(caller, args[0], args[1]); //Caller to Loc - else if (args.length == 3 && CommandCenter.GetClientManager().Get(caller).GetRank().Has(caller, Rank.ADMIN, true)) + else if (args.length == 3 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true)) Plugin.playerToLoc(caller, caller.getName(), args[0], args[1], args[2]); //Player to world @@ -39,7 +39,7 @@ public class TeleportCommand extends MultiCommandBase Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3], args[4]); //Player to Loc - else if (args.length == 4 && CommandCenter.GetClientManager().Get(caller).GetRank().Has(caller, Rank.ADMIN, true)) + else if (args.length == 4 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true)) Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3]); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index 7f4ef7667..7368f718a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -97,6 +97,7 @@ public class TreasureLocation implements Listener return; } + // Treasure is now being opened setHoloChestVisible(false); if (treasureType == TreasureType.ANCIENT) @@ -123,6 +124,7 @@ public class TreasureLocation implements Listener player.teleport(teleportLocation); + _treasureManager.addOpenStat(player, treasureType); } private boolean chargeAccount(Player player, TreasureType treasureType) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 39de66bf0..30d1a2335 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -20,6 +20,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardType; +import mineplex.core.stats.StatsManager; /** * Created by Shaun on 8/27/2014. @@ -30,21 +31,23 @@ public class TreasureManager extends MiniPlugin private InventoryManager _inventoryManager; private BlockRestore _blockRestore; private HologramManager _hologramManager; + private StatsManager _statsManager; private List _treasureLocations; - public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager) + public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager) { super("Treasure", plugin); _inventoryManager = inventoryManager; _blockRestore = blockRestore; _hologramManager = hologramManager; - _rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager, + _statsManager = statsManager; + _rewardManager = new RewardManager(clientManager, donationManager, _inventoryManager, petManager, statsManager, 100, 250, 500, 1000, 4000, 6000, 12000, 32000, - true); + true, false); World world = Bukkit.getWorlds().get(0); @@ -120,6 +123,11 @@ public class TreasureManager extends MiniPlugin } } + public void addOpenStat(Player player, TreasureType treasureType) + { + _statsManager.incrementStat(player, "Global.Treasure." + treasureType.getStatName(), 1); + } + public Reward[] getRewards(Player player, RewardType rewardType) { return _rewardManager.getRewards(player, rewardType); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index 861f47a91..1d6a5a399 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -7,22 +7,24 @@ import mineplex.core.reward.RewardType; public enum TreasureType { - OLD(C.cYellow + "Old Chest", "Old Chest", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD), + OLD(C.cYellow + "Old Chest", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD), - ANCIENT(C.cGold + "Ancient Chest", "Ancient Chest", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT), + ANCIENT(C.cGold + "Ancient Chest", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT), - MYTHICAL(C.cRed + "Mythical Chest", "Mythical Chest", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL); + MYTHICAL(C.cRed + "Mythical Chest", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL); private final String _name; private final RewardType _rewardType; private final Material _material; private final TreasureStyle _treasureStyle; private final String _itemName; + private final String _statName; - TreasureType(String name, String itemName, RewardType rewardType, Material material, TreasureStyle treasureStyle) + TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle) { _name = name; _itemName = itemName; + _statName = statName; _rewardType = rewardType; _material = material; _treasureStyle = treasureStyle; @@ -52,4 +54,9 @@ public enum TreasureType { return _itemName; } + + public String getStatName() + { + return _statName; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java index c3fbe6e62..a6b986660 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java @@ -16,6 +16,8 @@ public abstract class Animation _treasure = treasure; _running = true; } + + public Animation() {} public void run() { @@ -50,5 +52,15 @@ public abstract class Animation { return _treasure; } + + public void setRunning(boolean b) + { + _running = b; + } + + public void setTicks(int ticks) + { + _ticks = ticks; + } } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java index 93914d875..4547730a3 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java @@ -16,7 +16,7 @@ package mineplex.database.tables; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Bonus extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { - private static final long serialVersionUID = -524321170; + private static final long serialVersionUID = -384307684; /** * The reference instance of Account.bonus @@ -54,27 +54,27 @@ public class Bonus extends org.jooq.impl.TableImplAccount.bonus.dailyStreak. */ - public final org.jooq.TableField dailyStreak = createField("dailyStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + public final org.jooq.TableField dailyStreak = createField("dailyStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); /** * The column Account.bonus.maxDailyStreak. */ - public final org.jooq.TableField maxDailyStreak = createField("maxDailyStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + public final org.jooq.TableField maxDailyStreak = createField("maxDailyStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); /** * The column Account.bonus.voteStreak. */ - public final org.jooq.TableField voteStreak = createField("voteStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + public final org.jooq.TableField voteStreak = createField("voteStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); /** * The column Account.bonus.maxVoteStreak. */ - public final org.jooq.TableField maxVoteStreak = createField("maxVoteStreak", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + public final org.jooq.TableField maxVoteStreak = createField("maxVoteStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); /** * The column Account.bonus.tickets. */ - public final org.jooq.TableField tickets = createField("tickets", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + public final org.jooq.TableField tickets = createField("tickets", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); /** * Create a Account.bonus table reference diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 0c37445b6..2a33236df 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -195,7 +195,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor } else { - _commandQueue.add(new QueuedCommand(sender, command, label, args)); + //_commandQueue.add(new QueuedCommand(sender, command, label, args)); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " gems. Queuing for run later."); } } @@ -215,7 +215,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor } else { - _commandQueue.add(new QueuedCommand(sender, command, label, args)); + //_commandQueue.add(new QueuedCommand(sender, command, label, args)); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " coins. Queuing for run later."); } } @@ -244,7 +244,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor else { // Add arg so we don't add back to windows api call - _commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); + //_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later."); } } @@ -267,7 +267,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor else { // Add arg so we don't add back to windows api call - _commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); + //_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later."); } } @@ -275,7 +275,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor } else { - _commandQueue.add(new QueuedCommand(sender, command, label, args)); + //_commandQueue.add(new QueuedCommand(sender, command, label, args)); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later."); } } @@ -297,7 +297,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor else { // Add arg so we don't add back to windows api call - _commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); + //_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Chests. Queuing for run later."); } } @@ -318,7 +318,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor else { // Add arg so we don't add back to windows api call - _commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); + //_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Chests. Queuing for run later."); } } @@ -336,7 +336,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor { public void run() { - if (_clientManager.Get(name).GetRank() == Rank.ALL || !_clientManager.Get(name).GetRank().Has(rank) || _clientManager.Get(name).GetRank() == rank) + if (_clientManager.Get(name).GetRank() == Rank.ALL || !_clientManager.Get(name).GetRank().has(rank) || _clientManager.Get(name).GetRank() == rank) { _clientManager.SaveRank(name, playerUUID, rank, perm); System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month.")); @@ -376,7 +376,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor else { // Add arg so we don't add back to windows api call - _commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); + //_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" })); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + packageName + ". Queuing for run later."); } } @@ -384,7 +384,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor } else { - _commandQueue.add(new QueuedCommand(sender, command, label, args)); + //_commandQueue.add(new QueuedCommand(sender, command, label, args)); System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later."); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 553848414..ac3c3dc40 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin; import net.minecraft.server.v1_7_R4.MinecraftServer; import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; @@ -23,6 +24,7 @@ import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.spawn.Spawn; +import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.FileUpdater; @@ -79,7 +81,7 @@ public class Clans extends JavaPlugin BlockRestore blockRestore = new BlockRestore(this); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); + Chat chat = new Chat(this, _clientManager, preferenceManager, new AchievementManager(new StatsManager(this, _clientManager), _clientManager, _donationManager), serverStatusManager.getCurrentServerName()); new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MemoryFix(this); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java index e7cebc87e..9c55bf6d1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java @@ -19,7 +19,7 @@ public class FieldBlockCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null || args[0].equalsIgnoreCase("help")) + if (args.length == 0 || args[0].equalsIgnoreCase("help")) { Plugin.help(caller); } diff --git a/Plugins/Mineplex.Hub/.classpath b/Plugins/Mineplex.Hub/.classpath index 866da57e1..f8c70de6c 100644 --- a/Plugins/Mineplex.Hub/.classpath +++ b/Plugins/Mineplex.Hub/.classpath @@ -6,11 +6,11 @@ - + diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index b0bc33c67..e196f062c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -31,6 +31,7 @@ import mineplex.core.packethandler.PacketHandler; import mineplex.core.party.PartyManager; import mineplex.core.personalServer.PersonalServerManager; import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -39,7 +40,6 @@ import mineplex.core.recharge.Recharge; import mineplex.core.resourcepack.ResUnloadCheck; import mineplex.core.resourcepack.ResPackManager; import mineplex.core.serverConfig.ServerConfiguration; -import mineplex.core.spawn.Spawn; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; @@ -49,7 +49,6 @@ import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import mineplex.hub.modules.StackerManager; -import mineplex.hub.poll.PollManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -67,26 +66,26 @@ import mineplex.minecraft.game.core.fire.Fire; public class Hub extends JavaPlugin implements IRelation { private String WEB_CONFIG = "webServer"; - - @Override + + @Override public void onEnable() { getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); saveConfig(); - + String webServerAddress = getConfig().getString(WEB_CONFIG); - + //Logger.initialize(this); - + //Velocity Fix new VelocityFix(this); - + //Static Modules CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); - + ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); VisibilityManager.Initialize(this); Give.Initialize(this); @@ -95,7 +94,7 @@ public class Hub extends JavaPlugin implements IRelation DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); new ServerConfiguration(this, clientManager); - + //Other Modules PacketHandler packetHandler = new PacketHandler(this); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); @@ -105,31 +104,32 @@ public class Hub extends JavaPlugin implements IRelation NpcManager npcManager = new NpcManager(this, creature); PetManager petManager = new PetManager(this, clientManager, donationManager, disguiseManager, creature, blockRestore, webServerAddress); PollManager pollManager = new PollManager(this, clientManager, donationManager); - + //Main Modules ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); - + Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); - + IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); - FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); - + FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + StatsManager statsManager = new StatsManager(this, clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager); - + PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); - - HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), packetHandler); + + PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); Chat chat = new Chat(this, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); - new MemoryFix(this); + new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); new TablistFix(this); @@ -141,25 +141,23 @@ public class Hub extends JavaPlugin implements IRelation } }); //new Replay(this, packetHandler); - new PersonalServerManager(this, clientManager); - + AprilFoolsManager.Initialize(this, clientManager, disguiseManager); - + CombatManager combatManager = new CombatManager(this); - + ProjectileManager throwManager = new ProjectileManager(this); SkillConditionManager conditionManager = new SkillConditionManager(this); - + DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); Fire fire = new Fire(this, conditionManager, damage); - Teleport teleport = new Teleport(this); + Teleport teleport = new Teleport(this); Energy energy = new Energy(this); energy.setEnabled(false); - + ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager, webServerAddress); SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, disguiseManager, blockRestore, fire, new Movement(this), teleport, energy, webServerAddress); ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, webServerAddress); - classManager.setEnabled(false); ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory, achievementManager, clientManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 2712568f3..65a827b92 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -3,71 +3,6 @@ package mineplex.hub; import java.util.ArrayList; import java.util.HashMap; -import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.achievement.AchievementManager; -import mineplex.core.aprilfools.AprilFoolsManager; -import mineplex.core.benefit.BenefitManager; -import mineplex.core.blockrestore.BlockRestore; -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.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguiseSlime; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetActivateEvent; -import mineplex.core.gadget.event.GadgetCollideEntityEvent; -import mineplex.core.hologram.HologramManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.message.PrivateMessageEvent; -import mineplex.core.mount.MountManager; -import mineplex.core.mount.event.MountActivateEvent; -import mineplex.core.notifier.NotificationManager; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.party.Party; -import mineplex.core.party.PartyManager; -import mineplex.core.pet.PetManager; -import mineplex.core.portal.Portal; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.projectile.ProjectileManager; -import mineplex.core.stats.StatsManager; -import mineplex.core.task.TaskManager; -import mineplex.core.treasure.TreasureManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.commands.DisguiseCommand; -import mineplex.hub.commands.ForcefieldRadius; -import mineplex.hub.commands.GadgetToggle; -import mineplex.hub.commands.GameModeCommand; -import mineplex.hub.commands.NewsCommand; -import mineplex.hub.modules.ForcefieldManager; -import mineplex.hub.modules.HubVisibilityManager; -import mineplex.hub.modules.JumpManager; -import mineplex.hub.modules.KothManager; -import mineplex.hub.modules.NewsManager; -import mineplex.hub.modules.ParkourManager; -import mineplex.hub.modules.SoccerManager; -import mineplex.hub.modules.TextManager; -import mineplex.hub.modules.WorldManager; -import mineplex.hub.poll.PollManager; -import mineplex.hub.tutorial.TutorialManager; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; -import mineplex.minecraft.game.core.condition.ConditionManager; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -90,6 +25,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -104,54 +40,126 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; +import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.benefit.BenefitManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.botspam.BotSpamManager; +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.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.message.PrivateMessageEvent; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.notifier.NotificationManager; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.personalServer.PersonalServerManager; +import mineplex.core.pet.PetManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.punish.Punish; +import mineplex.core.reward.RewardManager; +import mineplex.core.stats.StatsManager; +import mineplex.core.task.TaskManager; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusManager; +import mineplex.hub.commands.DisguiseCommand; +import mineplex.hub.commands.ForcefieldRadius; +import mineplex.hub.commands.GadgetToggle; +import mineplex.hub.commands.GameModeCommand; +import mineplex.hub.commands.NewsCommand; +import mineplex.hub.modules.ForcefieldManager; +import mineplex.hub.modules.HubVisibilityManager; +import mineplex.hub.modules.JumpManager; +import mineplex.hub.modules.KothManager; +import mineplex.hub.modules.NewsManager; +import mineplex.hub.modules.ParkourManager; +import mineplex.hub.modules.SoccerManager; +import mineplex.hub.modules.TextManager; +import mineplex.hub.modules.WorldManager; +import mineplex.core.poll.PollManager; +import mineplex.hub.profile.gui.GUIProfile; +import mineplex.hub.tutorial.TutorialManager; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + public class HubManager extends MiniClientPlugin { // ☃❅ Snowman! public HubType Type = HubType.Normal; - + private BlockRestore _blockRestore; private CoreClientManager _clientManager; private ConditionManager _conditionManager; private DonationManager _donationManager; private DisguiseManager _disguiseManager; - private PartyManager _partyManager; - private ForcefieldManager _forcefieldManager; - private Portal _portal; - private StatsManager _statsManager; + private PartyManager _partyManager; + private ForcefieldManager _forcefieldManager; + private PollManager _pollManager; + private Portal _portal; + private StatsManager _statsManager; private GadgetManager _gadgetManager; private MountManager _mountManager; - private HubVisibilityManager _visibilityManager; - private TutorialManager _tutorialManager; + private HubVisibilityManager _visibilityManager; + private TutorialManager _tutorialManager; private TextManager _textCreator; - private ParkourManager _parkour; - private PreferencesManager _preferences; + private ParkourManager _parkour; + private PreferencesManager _preferences; private InventoryManager _inventoryManager; private NewsManager _news; private AchievementManager _achievementManager; private TreasureManager _treasureManager; private PetManager _petManager; private PacketHandler _packetHandler; + private PersonalServerManager _personalServerManager; private Location _spawn; private int _scoreboardTick = 0; private HashMap _scoreboards = new HashMap(); - private String _pigStacker = "0 - Nobody"; private String _serverName = ""; - - private ItemStack _ruleBook = null; private boolean _shuttingDown; private HashMap _portalTime = new HashMap(); - + private HashMap> _creativeAdmin = new HashMap>(); //Admin private boolean _gadgetsEnabled = true; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, PacketHandler packetHandler) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, 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) { super("Hub Manager", plugin); @@ -160,7 +168,9 @@ public class HubManager extends MiniClientPlugin _conditionManager = conditionManager; _donationManager = donationManager; _disguiseManager = disguiseManager; - + _pollManager = pollManager; + _personalServerManager = personalServerManager; + _portal = portal; _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); @@ -173,176 +183,49 @@ public class HubManager extends MiniClientPlugin new WorldManager(this); new JumpManager(this); //new TournamentInviter(this); - - + + _news = new NewsManager(this); _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _inventoryManager = new InventoryManager(plugin, clientManager); new BenefitManager(plugin, clientManager, _inventoryManager); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager); - _treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager); + + _treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); new SoccerManager(this, _gadgetManager); new KothManager(this, _gadgetManager); - + _petManager = petManager; _partyManager = partyManager; _preferences = preferences; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); _visibilityManager = new HubVisibilityManager(this); - + _forcefieldManager = new ForcefieldManager(this); addCommand(new ForcefieldRadius(_forcefieldManager)); - + _statsManager = statsManager; _achievementManager = achievementManager; _achievementManager.setGiveInterfaceItem(true); _packetHandler = packetHandler; - + new NotificationManager(getPlugin(), clientManager); + new BotSpamManager(plugin, clientManager, punish); ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; + + new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager); + + // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); - - _ruleBook = ItemStackFactory.Instance.CreateStack(Material.WRITTEN_BOOK, (byte)0, 1, ChatColor.GREEN + "Rule Book", new String[] { }); - BookMeta meta = (BookMeta)_ruleBook.getItemMeta(); + _serverName = getPlugin().getConfig().getString("serverstatus.name"); _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); - - meta.addPage("§m-------------------§r\n" - + "Welcome to §6§lMineplex§r\n" - + "§r§0§l§r§m§0§m-------------------§r§0\n" - + "\n" - + "§2Please §0take a moment to read through this book!\n" - + "\n" - + "\n" - + "Part 1 - Rules\n" - + "\n" - + "Part 2 - FAQ\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l1.§§§r §4No§r spamming.\n" - + "\n" - + "§0This is sending too many messages and/or repeating the same message in a short period of time.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l2.§m§r §4No§0 use of excessive caps.\n" - + "\n" - + "This is sending messages with an excessive amount of capital letters.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l3.§r §4No§0 hacking or use of any unapproved mods.\n" - + "\n" - + "This means we do not tolerate any sort of hacked client or any unapproved mods, such as fly hacks.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l4.§r §4No§0 advertising non-Mineplex related links.\n" - + "\n" - + "This is when a link is sent in chat which directs others to non-Mineplex related content.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l5.§r §4No§0 trolling or use of any exploits.\n" - + "\n" - + "This means that abuse of bugs/glitches is not tolerated. You also may not do things such as teamkilling and/or blocking spawns.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l6.§r §2Be§0 respectful to others, yourself, and the environment around you.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§rPlease report any bugs, exploits, and/or rule breakers on our forums with evidence.\n" - + "§omineplex.com/forums\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lWhat is stacker and how do you play it?\n" - + "\n" - + "§rStacker is a hub game where you can stack & throw players/mobs.\n" - + "\n" - + "§9Right-Click: pick up\n" - + "Left-Click: throw\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lHow do I get §bUltra§l, §5Hero§l, or §aLegend§l?\n" - + "\n" - + "§r§0You are able to purchase these ranks through our shop on our website at:\n" - + "\n" - + "§owww.mineplex.com/shop\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lWhy hasn't my rank been applied yet?\n" - + "\n" - + "§m§rYour rank may take a while to be applied. If it has been over 24 hours please contact:\n" - + "\n" - + "§omineplex.com/support\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lWhat do I do if I was wrongfully punished?\n" - + "\n" - + "§0If you believe you were wrongfully punished, please submit an appeal at:\n" - + "\n" - + "§omineplex.com/appeals\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lHow do I apply for Trainee?\n" - + "\n" - + "§rYou may only apply for Trainee if you have §bUltra§0, §5Hero§0, or §aLegend§0.\n" - + "Apply at:\n" - + "§omineplex.com/application\n"); - - meta.addPage("§m-------------------\n" - + "§r §6§lThank you for \n" - + " reading!§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "Remember to visit our website §2mineplex.com§0 for important news & updates!\n" - + "\n" - + "\n" - + "§c§lH§6§lA§a§lV§9§lE §c§lF§6§lU§a§lN§9§l!\n"); - - // These are needed or 1.8 clients will not show book correctly - meta.setTitle("Rule Book"); - meta.setAuthor("Mineplex"); - - _ruleBook.setItemMeta(meta); } @Override @@ -362,7 +245,7 @@ public class HubManager extends MiniClientPlugin event.setMotd("Restarting soon"); } } - + public boolean BumpDisabled(Entity ent) { if (ent == null) @@ -372,54 +255,54 @@ public class HubManager extends MiniClientPlugin { return !_preferences.Get((Player)ent).HubGames; } - + return true; } - + @EventHandler public void SnowballPickup(BlockDamageEvent event) { if (Type != HubType.Christmas) return; - + if (event.getBlock().getType() != Material.SNOW) return; - + Player player = event.getPlayer(); - + _gadgetManager.RemoveItem(player); - + player.getInventory().setItem(3, new ItemStack(Material.SNOW_BALL, 16)); } - + @EventHandler public void SnowballHit(CustomDamageEvent event) { if (Type != HubType.Christmas) return; - + Projectile proj = event.GetProjectile(); if (proj == null) return; if (!(proj instanceof Snowball)) return; - + event.SetCancelled("Snowball Cancel"); - + if (BumpDisabled(event.GetDamageeEntity())) return; - + if (BumpDisabled(event.GetDamagerEntity(true))) return; - - UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()), + + UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()), 0.4, false, 0, 0.2, 1, false); - + //No Portal SetPortalDelay(event.GetDamageeEntity()); } - + @EventHandler public void redirectStopCommand(PlayerCommandPreprocessEvent event) { @@ -486,7 +369,7 @@ public class HubManager extends MiniClientPlugin // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) { - if (!client.GetRank().Has(Rank.ULTRA)) + if (!client.GetRank().has(Rank.ULTRA)) { Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { @@ -509,12 +392,12 @@ public class HubManager extends MiniClientPlugin // Give developers operator on their servers boolean testServer = _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.OWNER) || (testServer && (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER) || _clientManager.Get(event.getPlayer()).GetRank() == Rank.JNR_DEV))) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.OWNER) || (testServer && (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER) || _clientManager.Get(event.getPlayer()).GetRank() == Rank.JNR_DEV))) event.getPlayer().setOp(true); else event.getPlayer().setOp(false); } - + @EventHandler public void PlayerRespawn(PlayerRespawnEvent event) { @@ -533,32 +416,29 @@ public class HubManager extends MiniClientPlugin //Public Message event.setJoinMessage(null); - + // if (_clientManager.Get(player).GetRank() != Rank.LEGEND) // event.setJoinMessage(null); // else // { // event.setJoinMessage(C.cGreen + C.Bold + "Legend " + playerName + " has joined!"); // } - + //Teleport player.teleport(GetSpawn().add(0, 10, 0)); - + //Survival player.setGameMode(GameMode.SURVIVAL); - + //Clear Inv UtilInv.Clear(player); - + //Allow Double Jump player.setAllowFlight(true); - + //Health player.setHealth(20); - //Rules - player.getInventory().setItem(2, _ruleBook); - //Scoreboard Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); player.setScoreboard(board); @@ -571,7 +451,7 @@ public class HubManager extends MiniClientPlugin for (Rank rank : Rank.values()) { if (rank != Rank.ALL) - board.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " "); + board.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); else board.registerNewTeam(rank.Name).setPrefix(""); } @@ -584,12 +464,12 @@ public class HubManager extends MiniClientPlugin String rankName = _clientManager.Get(player).GetRank().Name; String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name; - if (!_clientManager.Get(player).GetRank().Has(Rank.ULTRA) && _donationManager.Get(player.getName()).OwnsUltraPackage()) + if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && _donationManager.Get(player.getName()).OwnsUltraPackage()) { rankName = Rank.ULTRA.Name; } - if (!_clientManager.Get(otherPlayer).GetRank().Has(Rank.ULTRA) && _donationManager.Get(otherPlayer.getName()).OwnsUltraPackage()) + if (!_clientManager.Get(otherPlayer).GetRank().has(Rank.ULTRA) && _donationManager.Get(otherPlayer.getName()).OwnsUltraPackage()) { otherRankName = Rank.ULTRA.Name; } @@ -617,12 +497,12 @@ public class HubManager extends MiniClientPlugin _portalTime.remove(event.getPlayer().getName()); } - + @EventHandler public void playerPrivateMessage(PrivateMessageEvent event) { //Dont Let PM Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().Has(Rank.HELPER)) + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().has(Rank.HELPER)) { UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); event.setCancelled(true); @@ -634,24 +514,24 @@ public class HubManager extends MiniClientPlugin { if (event.isCancelled()) return; - + //Dont Let Chat Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.HELPER)) + if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) { UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); event.setCancelled(true); return; } - + Player player = event.getPlayer(); String playerName = player.getName(); - + // April Fools if (AprilFoolsManager.Instance.isActive()) playerName = AprilFoolsManager.Instance.getName(player); Rank rank = GetClients().Get(player).GetRank(); - + if(GetClients().Get(player).isDisguised()) rank = GetClients().Get(player).getDisguisedRank(); @@ -659,14 +539,14 @@ public class HubManager extends MiniClientPlugin //Level Prefix String levelStr = _achievementManager.getMineplexLevel(player, rank); - + //Rank Prefix String rankStr = ""; if (rank != Rank.ALL) - rankStr = rank.GetTag(true, true) + " "; + rankStr = rank.getTag(true, true) + " "; - if (ownsUltra && !rank.Has(Rank.ULTRA)) - rankStr = Rank.ULTRA.GetTag(true, true) + " "; + if (ownsUltra && !rank.has(Rank.ULTRA)) + rankStr = Rank.ULTRA.getTag(true, true) + " "; //Party Chat if (event.getMessage().charAt(0) == '@') @@ -694,7 +574,7 @@ public class HubManager extends MiniClientPlugin } return; - } + } else { for (Player other : UtilServer.getPlayers()) @@ -737,6 +617,12 @@ public class HubManager extends MiniClientPlugin event.getEntity().teleport(GetSpawn()); } + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.None); + } + @EventHandler public void FoodHealthUpdate(UpdateEvent event) { @@ -819,14 +705,14 @@ public class HubManager extends MiniClientPlugin obj.setDisplayName(C.cWhite + C.Bold + Get(player).GetScoreboardText()); int line = 15; - + //Stacker obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--); obj.getScore(_serverName).setScore(line--); - + //Space obj.getScore(" ").setScore(line--); - + //Gems obj.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); // Remove Old/Add New @@ -842,19 +728,19 @@ public class HubManager extends MiniClientPlugin // Remove Old player.getScoreboard().resetScores(Get(player.getName()).GetLastCoinCount() + ""); - // Add New + // Add New obj.getScore(GetDonation().Get(player.getName()).getCoins() + "").setScore(line--); Get(player.getName()).SetLastCoinCount(GetDonation().Get(player.getName()).getCoins()); - + //Space obj.getScore(" ").setScore(line--); - - + + //Display Rank obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--); - if (GetClients().Get(player).GetRank().Has(Rank.ULTRA)) + if (GetClients().Get(player).GetRank().has(Rank.ULTRA)) obj.getScore(GetClients().Get(player).GetRank().Name).setScore(line--); else if (GetDonation().Get(player.getName()).OwnsUnknownPackage("SuperSmashMobs ULTRA") || GetDonation().Get(player.getName()).OwnsUnknownPackage("Survival Games ULTRA") || @@ -864,7 +750,7 @@ public class HubManager extends MiniClientPlugin obj.getScore("Single Ultra").setScore(line--); else obj.getScore("No Rank").setScore(line--); - + //Space obj.getScore(" ").setScore(line--); @@ -931,12 +817,12 @@ public class HubManager extends MiniClientPlugin { return _preferences; } - + public Location GetSpawn() { return _spawn.clone(); } - + public PetManager getPetManager() { return _petManager; @@ -956,12 +842,16 @@ public class HubManager extends MiniClientPlugin { return _visibilityManager; } +<<<<<<< HEAD public String getLobbyName() { return _serverName; } +======= + +>>>>>>> 9a3ef895c929b0fa29e72f864553427b87b397f8 @EventHandler(priority = EventPriority.MONITOR) public void gadgetCollide(GadgetCollideEntityEvent event) { @@ -988,7 +878,7 @@ public class HubManager extends MiniClientPlugin return UtilTime.elapsed(_portalTime.get(player.getName()), 5000); } - public boolean CanBump(LivingEntity ent) + public boolean hasPlayerStackingEnabled(LivingEntity ent) { if (!(ent instanceof Player)) return true; @@ -1019,7 +909,7 @@ public class HubManager extends MiniClientPlugin return _gadgetsEnabled; } - + public NewsManager GetNewsManager() { return _news; @@ -1028,7 +918,7 @@ public class HubManager extends MiniClientPlugin @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR) && _preferences.Get(event.getPlayer()).IgnoreVelocity) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.Get(event.getPlayer()).IgnoreVelocity) { event.setCancelled(true); } @@ -1037,24 +927,24 @@ public class HubManager extends MiniClientPlugin public void ToggleGadget(Player caller) { _gadgetsEnabled = !_gadgetsEnabled; - + if (!_gadgetsEnabled) { GetMount().DisableAll(); GetGadget().DisableAll(); } - + for (Player player : UtilServer.getPlayers()) player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled")); } - + @EventHandler public void GadgetActivate(GadgetActivateEvent event) { if (!_gadgetsEnabled) event.setCancelled(true); } - + @EventHandler public void MountActivate(MountActivateEvent event) { @@ -1066,7 +956,7 @@ public class HubManager extends MiniClientPlugin { if (!_creativeAdmin.containsKey(caller.getName())) _creativeAdmin.put(caller.getName(), new ArrayList()); - + if (target.getGameMode() == GameMode.CREATIVE) { _creativeAdmin.get(caller.getName()).add(target.getName()); @@ -1076,29 +966,38 @@ public class HubManager extends MiniClientPlugin _creativeAdmin.get(caller.getName()).remove(target.getName()); } } - + @EventHandler public void clearGameMode(PlayerQuitEvent event) { ArrayList creative = _creativeAdmin.remove(event.getPlayer().getName()); - + if (creative == null) return; - + for (String name : creative) { Player player = UtilPlayer.searchExact(name); if (player == null) continue; - + player.setGameMode(GameMode.SURVIVAL); - + UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false))); } } - + public PacketHandler getPacketHandler() { return _packetHandler; } + + @EventHandler + public void openProfile(PlayerInteractEvent event) + { + if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) + return; + + new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 0402366e7..a7adf15a6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -49,307 +49,307 @@ import com.mysql.jdbc.BalanceStrategy; public class DisguiseCommand extends CommandBase implements Listener { - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - public DisguiseCommand(HubManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] - { - Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + public DisguiseCommand(HubManager plugin) + { + super(plugin, Rank.JNR_DEV, new Rank[] + { + Rank.YOUTUBE, Rank.TWITCH }, "disguise"); plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); new NCPDataManFix(); - } + } - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null) + @Override + public void Execute(final Player caller, final String[] args) { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - try - { - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName); - - for(Player other : UtilServer.getPlayers()) + if(args == null || args.length == 0) { - for(Team team : other.getScoreboard().getTeams()) - { - if(team.hasPlayer(caller)) + if(!Plugin.GetDisguise().isDisguised(caller)) { - team.removePlayer(caller); + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; } - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); - return; - } + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() - { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; + changeName(caller, playerName); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(caller)) + { + team.removePlayer(caller); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } } - for(Player other : UtilServer.getPlayers()) + if(args != null && args.length > 1) { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; } + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + for(Player other : UtilServer.getPlayers()) + { + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0]); + + Plugin.GetGadget().RemoveItem(caller); + + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); + } + + @EventHandler + public void updateDisguises(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; + + for(Player other : UtilServer.getPlayers()) + { + try + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(player)) + { + team.removePlayer(player); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); + } + } + + public void changeName(Player player, String changedName) + { try { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); - GameProfile profile = null; - try - { - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) - { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } + Field name = GameProfile.class.getDeclaredField("name"); + Field declaredProfile = EntityHuman.class.getDeclaredField("i"); + declaredProfile.setAccessible(true); + GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - Rank otherRank = Rank.ALL; - try - { - CoreClient other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - {} - if(otherRank.Has(Rank.TWITCH)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); - return; - } - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0]); - - Plugin.GetGadget().RemoveItem(caller); - - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); - } catch(Exception e) + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); + } catch(Exception ex) { - e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; + ex.printStackTrace(); } - } - }); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - for(Team team : other.getScoreboard().getTeams()) - { - if(team.hasPlayer(player)) - { - team.removePlayer(player); - } - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - - } catch(NullPointerException exp) - {} - } - - if(Plugin.GetDisguise().isDisguised(player)) - continue; - - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); } - } - public void changeName(Player player, String changedName) - { - try + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) { - Field name = GameProfile.class.getDeclaredField("name"); - Field declaredProfile = EntityHuman.class.getDeclaredField("i"); - declaredProfile.setAccessible(true); - GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); - - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(player, playerName); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) - { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetActivateEvent event) - { - if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - Player player = event.getPlayer(); - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) + if(_disguisedPlayers.containsKey(player)) { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } } - } } - } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index 07caf2363..c52990ac1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().Has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV)) + if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH)) { for (Player other : UtilServer.getPlayers()) { @@ -56,7 +56,7 @@ public class ForcefieldManager extends MiniPlugin if (UtilMath.offset(other, player) > range) continue; - if (Manager.GetClients().Get(other).GetRank().Has(Rank.ADMIN) || Manager.GetClients().Get(other).GetRank() == Rank.JNR_DEV) + if (Manager.GetClients().Get(other).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(other).GetRank() == Rank.JNR_DEV) continue; if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java index bacb4156a..373bb1e5d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java @@ -12,6 +12,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; @@ -156,12 +157,12 @@ public class KothManager extends MiniPlugin if (bottom.getVehicle() != null) bottom = bottom.getVehicle(); - UtilAction.velocity(bottom, UtilAlg.getTrajectory(bounce, player.getLocation()), 1, false, 0, 0.4, 1, true); + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(bounce, player.getLocation()), 1.2, false, 0, 0.6, 1, true); if (Recharge.Instance.use(player, "KOTH Eject", 5000, false, false)) { - UtilPlayer.message(player, F.main("Football", "You must be wearing a Team Outfit.")); - UtilPlayer.message(player, F.main("Football", "Type " + F.elem("/team red|yellow|green|blue") + "!")); + UtilPlayer.message(player, F.main("KOTH", "You must be wearing a Team Outfit.")); + UtilPlayer.message(player, F.main("KOTH", "Type " + F.elem("/team red|yellow|green|blue") + "!")); } } } @@ -196,6 +197,8 @@ public class KothManager extends MiniPlugin outfit.add("PvP Sword"); Manager.GetGadget().DisableAll(player, outfit); + Manager.GetMount().DisableAll(player); + Manager.getPetManager().DisableAll(player); } else { @@ -209,7 +212,7 @@ public class KothManager extends MiniPlugin { return _active.contains(player); } - + @EventHandler public void disableGadgets(GadgetActivateEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index 76c1b72d0..2b4b198d3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -408,7 +408,7 @@ public class ParkourManager extends MiniPlugin else { _taskManager.Get(player).TasksCompleted.remove(_taskManager.getTaskId(fData.Name)); - UtilPlayer.message(player, F.main("Parkour", "There as an error giving " + F.elem(C.cGreen + fData.Gems + " gems to you. Please click the NPC again.") + ".")); + UtilPlayer.message(player, F.main("Parkour", "There was an error giving " + F.elem(C.cGreen + fData.Gems + " Gems to you. Please click the NPC again.") + ".")); } } }, "Parkour " + fData.Name, player.getName(), player.getUniqueId(), fData.Gems); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java index d737d65d3..1d55d9f03 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -3,18 +3,26 @@ package mineplex.hub.modules; import java.util.ArrayList; import java.util.HashSet; +import org.bukkit.EntityEffect; import org.bukkit.FireworkEffect.Type; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Sound; +import org.bukkit.entity.Bat; import org.bukkit.entity.Entity; +import org.bukkit.entity.Firework; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; @@ -75,8 +83,9 @@ public class SoccerManager extends MiniPlugin private Vector _ballVel; private long _ballDeadTime = -1; - private String _lastKicker = ""; - private Color _lastKick = null; + private String _lastRedKicker = ""; + private String _lastBlueKicker = ""; + private Color _lastKickColor = null; //Item Rebound protected Vector _vel; @@ -168,7 +177,7 @@ public class SoccerManager extends MiniPlugin if (_ball == null) return; - if (_lastKick == Color.AQUA) + if (_lastKickColor == Color.AQUA) { for (int i = 0 ; i < 3 ; i++) UtilParticle.PlayParticle(ParticleType.RED_DUST, _ball.getLocation().add(0.0, 0.5, 0.0), -1, 1, 1, 1, 0, @@ -205,13 +214,22 @@ public class SoccerManager extends MiniPlugin UtilAction.zeroVelocity(player); - _lastKick = getTeamColor(player); - if (_lastKick == null) - _lastKicker = player.getName(); - else if (_lastKick == Color.RED) - _lastKicker = C.cRed + player.getName(); - else if (_lastKick == Color.AQUA) - _lastKicker = C.cAqua + player.getName(); + _lastKickColor = getTeamColor(player); + if (_lastKickColor == Color.RED) + { + _lastRedKicker = C.cRed + player.getName(); + + if (_lastBlueKicker.length() == 0) + _lastBlueKicker = C.cRed + player.getName(); + } + + else if (_lastKickColor == Color.AQUA) + { + _lastBlueKicker = C.cAqua + player.getName(); + + if (_lastRedKicker.length() == 0) + _lastRedKicker = C.cRed + player.getName(); + } } } } @@ -231,14 +249,15 @@ public class SoccerManager extends MiniPlugin for (Player player : _active) UtilTextMiddle.display("Goal! (" + C.cRed + _redGoals + C.cWhite + " : " + C.cBlue + _blueGoals + C.cWhite + ")", - _lastKicker + C.cWhite + " scored for " + C.cAqua + "Blue Team", 0, 70, 20, player); + _lastBlueKicker + C.cWhite + " scored for " + C.cAqua + "Blue Team", 0, 70, 20, player); _ball.remove(); _ball = null; + + _lastRedKicker = ""; + _lastBlueKicker = ""; } - - return; } @@ -256,10 +275,13 @@ public class SoccerManager extends MiniPlugin for (Player player : _active) UtilTextMiddle.display("Goal! (" + C.cRed + _redGoals + C.cWhite + " : " + C.cBlue + _blueGoals + C.cWhite + ")", - _lastKicker + C.cWhite + " scored for " + C.cRed + "Red Team", 0, 70, 20, player); + _lastRedKicker + C.cWhite + " scored for " + C.cRed + "Red Team", 0, 70, 20, player); _ball.remove(); _ball = null; + + _lastRedKicker = ""; + _lastBlueKicker = ""; } return; @@ -351,6 +373,12 @@ public class SoccerManager extends MiniPlugin if (inPlayerArena(ent)) { + if (ent instanceof Bat || ent instanceof WitherSkull || ent instanceof TNTPrimed || ent instanceof Firework) + { + ent.remove(); + continue; + } + Location bounce = UtilAlg.getMidpoint(_cornerFieldPlayerA, _cornerFieldPlayerB); bounce.setY(Math.min(_cornerFieldPlayerA.getY(), _cornerFieldPlayerB.getY())); @@ -359,7 +387,6 @@ public class SoccerManager extends MiniPlugin bottom = bottom.getVehicle(); UtilAction.velocity(bottom, UtilAlg.getTrajectory(bounce, ent.getLocation()), 1, false, 0, 0.4, 1, true); - } } } @@ -408,19 +435,18 @@ public class SoccerManager extends MiniPlugin if (bottom.getVehicle() != null) bottom = bottom.getVehicle(); - UtilAction.velocity(bottom, UtilAlg.getTrajectory(bounce, player.getLocation()), 1, false, 0, 0.4, 1, true); + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(bounce, player.getLocation()), 1, false, 0, 0.8, 1, true); if (Recharge.Instance.use(player, "Soccer Eject", 5000, false, false)) { - if (_active.size() >= 8) + if (_active.size() < 8) { - UtilPlayer.message(player, F.main("Football", "You must be wearing Red/Blue Team Outfit.")); - UtilPlayer.message(player, F.main("Football", "Type " + F.elem("/team red") + " or " + F.elem("/team blue") + "!")); + UtilPlayer.message(player, F.main("Slimeball", "You must be wearing Red/Blue Team Outfit.")); + UtilPlayer.message(player, F.main("Slimeball", "Type " + F.elem("/team red") + " or " + F.elem("/team blue") + "!")); } else { - UtilPlayer.message(player, F.main("Football", "You must be wearing Red/Blue Team Outfit.")); - UtilPlayer.message(player, F.main("Football", "Type " + F.elem("/team red") + " or " + F.elem("/team blue") + "!")); + UtilPlayer.message(player, F.main("Slimeball", "The game is currently full!")); } } } @@ -436,11 +462,11 @@ public class SoccerManager extends MiniPlugin _active.add(player); if (color == null) - UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Football Mode") + ".")); + UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Slimeball Mode") + ".")); else if (color == Color.RED) - UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cRed + "Red Football Team") + ".")); + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cRed + "Red Slimeball Team") + ".")); else if (color == Color.AQUA) - UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cAqua + "Blue Football Team") + ".")); + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cAqua + "Blue Slimeball Team") + ".")); ArrayList outfit = new ArrayList(); outfit.add("Team Helmet"); @@ -449,11 +475,13 @@ public class SoccerManager extends MiniPlugin outfit.add("Team Boots"); Manager.GetGadget().DisableAll(player, outfit); + Manager.GetMount().DisableAll(player); + Manager.getPetManager().DisableAll(player); } else { _active.remove(player); - UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Football Mode") + ".")); + UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Slimeball Mode") + ".")); } } @@ -461,7 +489,7 @@ public class SoccerManager extends MiniPlugin { return _active.contains(player); } - + @EventHandler public void disableGadgets(GadgetActivateEvent event) { @@ -481,6 +509,9 @@ public class SoccerManager extends MiniPlugin { if (_active.contains(event.getPlayer())) event.setCancelled(true); + + if (_ball != null && event.getRightClicked().equals(_ball)) + event.setCancelled(true); } @EventHandler @@ -488,4 +519,30 @@ public class SoccerManager extends MiniPlugin { _active.remove(event.getPlayer()); } + + @EventHandler(priority = EventPriority.HIGHEST) + public void allowDamage(EntityDamageByEntityEvent event) + { + if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player)) + return; + + Player damager = (Player)event.getDamager(); + Player damagee = (Player)event.getEntity(); + + if (!_active.contains(damager) || !_active.contains(damagee)) + return; + + if (getTeamColor(damager) == null || getTeamColor(damagee) == null) + return; + + if (getTeamColor(damager) == getTeamColor(damagee)) + return; + + if (Recharge.Instance.use(damagee, "Football Damage", 800, false, false)) + { + UtilAction.velocity(damagee, UtilAlg.getTrajectory2d(damager, damagee), 0.6, false, 0, 0.3, 1, true); + + damagee.playEffect(EntityEffect.HURT); + } + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index ed43ae6d2..2f8a774d4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -95,12 +95,6 @@ public class StackerManager extends MiniPlugin implements IThrown return; } - if (!Manager.CanBump(stacker)) - { - UtilPlayer.message(stacker, F.main("Stacker", "You are not playing stacker.")); - return; - } - if (stacker.getVehicle() != null || _tempStackShift.contains(stacker)) { UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack while stacked...")); @@ -123,9 +117,15 @@ public class StackerManager extends MiniPlugin implements IThrown if (stackee instanceof Player) { - if (!Manager.CanBump(((Player)stackee))) + if (!Manager.hasPlayerStackingEnabled(stacker)) { - UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is not playing stacker.")); + UtilPlayer.message(stacker, F.main("Stacker", "You have player stacking disabled.")); + return; + } + + if (!Manager.hasPlayerStackingEnabled(((Player)stackee))) + { + UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " has player stacking disabled.")); return; } @@ -242,7 +242,7 @@ public class StackerManager extends MiniPlugin implements IThrown if (target.getCustomName() != null || (target.getPassenger() != null && target.getPassenger() instanceof LivingEntity && ((LivingEntity)target.getPassenger()).getCustomName() != null)) return; - if (!Manager.CanBump(target)) + if (!Manager.hasPlayerStackingEnabled(target)) return; //Velocity diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index 1506c0311..8729a6e55 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -31,6 +31,7 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; +import org.bukkit.entity.Silverfish; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.Snowman; @@ -44,6 +45,7 @@ import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityTargetEvent; @@ -162,6 +164,12 @@ public class WorldManager extends MiniPlugin { event.setCancelled(true); } + + @EventHandler + public void BlockEntityChange(EntityChangeBlockEvent event) + { + event.setCancelled(true); + } @EventHandler(priority = EventPriority.LOWEST) public void Explosion(EntityExplodeEvent event) @@ -355,4 +363,4 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonMPS.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonMPS.java new file mode 100644 index 000000000..00135e777 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonMPS.java @@ -0,0 +1,60 @@ +package mineplex.hub.profile.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.profile.gui.GUIProfile; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class ButtonMPS implements GuiItem +{ + + private GUIProfile _profile; + private Player _player; + + public ButtonMPS(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getPersonalManager().showHostMessage(_player); + } + + @Override + public ItemStack getObject() + { + return ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, + ChatColor.RESET + C.cYellow + "Mineplex Player Server", + new String[] + { + "", + C.cWhite + "Create a server where you are the Host.", + C.cWhite + "You can choose the game, map and much more!", + "", + C.cWhite + "Type " + C.cGreen + "/mps" + C.cWhite + " to access this anywhere!" + }); + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java new file mode 100644 index 000000000..38652a7c7 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java @@ -0,0 +1,61 @@ +package mineplex.hub.profile.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.profile.gui.GUIProfile; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class ButtonPrefs implements GuiItem +{ + + private GUIProfile _profile; + private Player _player; + + public ButtonPrefs(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getPrefManager().openShop(_player); + } + + @Override + public ItemStack getObject() + { + return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, + ChatColor.RESET + C.cYellow + "Preferences", + new String[] + { + "", + C.cWhite + "Set your preferences to your liking", + C.cWhite + "so you can enjoy the game more!", + + "", + C.cWhite + "Type " + C.cGreen + "/prefs" + C.cWhite + " to access this anywhere!" + }); + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonStats.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonStats.java new file mode 100644 index 000000000..3e36c712d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonStats.java @@ -0,0 +1,65 @@ +package mineplex.hub.profile.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.profile.gui.GUIProfile; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class ButtonStats implements GuiItem +{ + + private GUIProfile _profile; + private Player _player; + + public ButtonStats(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getAchievementManager().openShop(_player); + } + + @Override + public ItemStack getObject() + { + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, + ChatColor.RESET + C.cYellow + "Stats and Achievements", + new String[] + { + "", + C.cWhite + "View your Statistics and Achievements", + C.cWhite + "for all of the games on Mineplex!", + + "", + C.cWhite + "Type " + C.cGreen + "/stats" + C.cWhite + " to access this anywhere!" + }); + SkullMeta meta = ((SkullMeta) item.getItemMeta()); + meta.setOwner(_player.getName()); + item.setItemMeta(meta); + return item; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/gui/GUIProfile.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/gui/GUIProfile.java new file mode 100644 index 000000000..a7dca223b --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/gui/GUIProfile.java @@ -0,0 +1,48 @@ +package mineplex.hub.profile.gui; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import mineplex.core.achievement.AchievementManager; +import mineplex.core.gui.SimpleGui; +import mineplex.core.personalServer.PersonalServerManager; +import mineplex.core.preferences.PreferencesManager; +import mineplex.hub.profile.buttons.ButtonMPS; +import mineplex.hub.profile.buttons.ButtonPrefs; +import mineplex.hub.profile.buttons.ButtonStats; + +public class GUIProfile extends SimpleGui +{ + + private PreferencesManager _preferencesManager; + private AchievementManager _achievementManager; + private PersonalServerManager _personalServerManager; + + public GUIProfile(Plugin plugin, Player player, PreferencesManager preferencesManager, AchievementManager achievementManager, PersonalServerManager personalServerManager) + { + super(plugin, player, "My Profile", 9*3); + _preferencesManager = preferencesManager; + _achievementManager = achievementManager; + _personalServerManager = personalServerManager; + + setItem(11, new ButtonStats(this, player)); + setItem(13, new ButtonPrefs(this, player)); + setItem(15, new ButtonMPS(this, player)); + } + + public PreferencesManager getPrefManager() + { + return _preferencesManager; + } + + public AchievementManager getAchievementManager() + { + return _achievementManager; + } + + public PersonalServerManager getPersonalManager() + { + return _personalServerManager; + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 9cfa24d21..5963ea411 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -1,17 +1,11 @@ package mineplex.hub.server; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Random; import java.util.Set; @@ -189,7 +183,10 @@ public class ServerManager extends MiniPlugin if (serverName != null) { - List serverList = new ArrayList(getServerList(serverName)); + List serverList = new ArrayList(); + + if (hasServerNpc(serverName)) + serverList.addAll(getServerList(serverName)); int slots = 1; @@ -715,6 +712,9 @@ public class ServerManager extends MiniPlugin System.out.println("ServerManager - Error parsing servergroups : " + e.getMessage()); } +// AddServerNpc("Event Servers", "EVENT"); +// AddServerNpc("Mineplex Player Servers", "MPS"); + ServerGroup eventGroup = new ServerGroup("Event", "Event Servers", "EVENT"); ServerGroup mpsGroup = new ServerGroup("MPS", "Mineplex Player Servers", "MPS"); @@ -741,7 +741,7 @@ public class ServerManager extends MiniPlugin if (partyPlayer == null) continue; - if (_clientManager.Get(partyPlayer).GetRank().Has(Rank.ULTRA) || _donationManager.Get(partyPlayer.getName()).OwnsUnknownPackage(serverType + " ULTRA")) + if (_clientManager.Get(partyPlayer).GetRank().has(Rank.ULTRA) || _donationManager.Get(partyPlayer.getName()).OwnsUnknownPackage(serverType + " ULTRA")) continue; slots++; @@ -750,7 +750,7 @@ public class ServerManager extends MiniPlugin } else { - if (!_clientManager.Get(player).GetRank().Has(Rank.ULTRA) && !_donationManager.Get(player.getName()).OwnsUnknownPackage(serverType + " ULTRA")) + if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && !_donationManager.Get(player.getName()).OwnsUnknownPackage(serverType + " ULTRA")) slots++; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java index f084c2ded..e59ae2667 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java @@ -68,7 +68,7 @@ public class LobbyMenu extends ShopPageBase implements if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers) { - if (!getClient().GetRank().Has(Rank.ULTRA)) + if (!getClient().GetRank().has(Rank.ULTRA)) lore.add(openFull); else lore.add(openFullUltra); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/QuickShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/QuickShop.java index 2e0d59b45..08c04b028 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/QuickShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/QuickShop.java @@ -18,7 +18,7 @@ public class QuickShop extends ShopBase @Override protected ShopPageBase> buildPagesFor(Player player) { - return new ServerGameMenu(getPlugin(), this, getClientManager(), getDonationManager(), " " + ChatColor.UNDERLINE + "Quick Game Menu", player); + return new ServerGameMenu(getPlugin(), this, getClientManager(), getDonationManager(), "Game Menu", player); } public void UpdatePages() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index bdd807710..34b527fa9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -1,6 +1,7 @@ package mineplex.hub.server.ui; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -8,25 +9,26 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import mineplex.core.account.CoreClientManager; -import mineplex.core.achievement.AchievementCategory; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.shop.page.ShopPageInventory; import mineplex.hub.server.ServerInfo; import mineplex.hub.server.ServerManager; import mineplex.hub.server.ServerSorter; import mineplex.hub.server.ui.button.JoinServerButton; -public class ServerNpcPage extends ShopPageBase implements IServerPage +public class ServerNpcPage extends ShopPageInventory implements IServerPage { // Shop Item Messages private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Tournament servers!"; @@ -40,6 +42,9 @@ public class ServerNpcPage extends ShopPageBase im private String _serverGroupName; private boolean _onMainPage = true; + private IButton[] _buttons; + private ItemStack[] _items; + public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName) { super(plugin, shop, clientManager, donationManager, name, player, 54); @@ -50,12 +55,14 @@ public class ServerNpcPage extends ShopPageBase im } @Override - protected void buildPage() + protected void buildItems() { + _items = new ItemStack[0]; + _buttons = new IButton[0]; + List serverList = new ArrayList(getPlugin().getServerList(_serverGroupName)); - + int slotsNeeded = 1; - if (serverList.size() > 0) { @@ -74,13 +81,14 @@ public class ServerNpcPage extends ShopPageBase im if (_onMainPage) { - addButton(4, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BLOCK, (byte) 0, 1, C.cGreen + "Click to Join instantly!"), new IButton() { + addButton(4, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BLOCK, (byte) 0, 1, C.cGreen + "Click to join instantly!"), new IButton() { @Override public void onClick(Player player, ClickType clickType) { getPlugin().selectServer(player, _serverGroupName); } }); + buildAvailableServerPage(serverList, slotsNeeded); } else @@ -109,12 +117,12 @@ public class ServerNpcPage extends ShopPageBase im ChatColor.RESET + C.cGreen + "www.mineplex.com/shop" }, seconds, false, false); - addItem(22, item); + addItemStack(22, item); } private ShopItem buildShopItem(ServerInfo serverInfo, int slotsNeeded) { - boolean ownsUltraPackage = getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().Has(Rank.ULTRA); + boolean ownsUltraPackage = getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().has(Rank.ULTRA); Material status = Material.REDSTONE_BLOCK; List lore = new ArrayList(); @@ -201,7 +209,7 @@ public class ServerNpcPage extends ShopPageBase im boolean beta = serverList.size() > 0 && serverList.get(0).Name.contains("BETA"); boolean tournament = serverList.size() > 0 && serverList.get(0).Name.contains("T_"); boolean privateServer = serverList.size() > 0 && serverList.get(0).ServerType.equals("Player"); - boolean ownsUltraPackage = getClient().GetRank().Has(Rank.ULTRA) || (serverList.size() > 0 && getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA")); + boolean ownsUltraPackage = getClient().GetRank().has(Rank.ULTRA) || (serverList.size() > 0 && getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA")); long portalTime = getPlugin().getMillisecondsUntilPortal(getPlayer(), beta); if (portalTime > 0) @@ -220,7 +228,7 @@ public class ServerNpcPage extends ShopPageBase im ChatColor.RESET + "Visit " + C.cGreen + "www.mineplex.com/shop" + C.cWhite + "!" }, 1, false, false); - addItem(22, item); + addItemStack(22, item); return; } @@ -243,9 +251,6 @@ public class ServerNpcPage extends ShopPageBase im } else { - if (slot >= 54) - continue; - addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, serverInfo)); slot++; } @@ -273,7 +278,7 @@ public class ServerNpcPage extends ShopPageBase im greenCount++; if (serverInfo.MOTD.contains("Open in")) - setItem(slot, shopItem); + addItemStack(slot, shopItem); else { addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); @@ -303,11 +308,39 @@ public class ServerNpcPage extends ShopPageBase im { for (int i = greenCount + greenStartSlot; i < greenStartSlot + serversToShow; i++) { - setItem(i, null); + addItemStack(i, null); } } } + public void addItemStack(int slot, ItemStack item) + { + if (_items.length <= slot) + { + if (item == null || item.getType() == Material.AIR) + { + return; + } + + _items = Arrays.copyOf(_items, slot + 1); + _buttons = Arrays.copyOf(_buttons, slot + 1); + } + + _items[slot] = item; + } + + protected void addButton(int slot, ItemStack item, IButton button) + { + if (_items.length <= slot) + { + _items = Arrays.copyOf(_items, slot + 1); + _buttons = Arrays.copyOf(_buttons, slot + 1); + } + + _items[slot] = item; + _buttons[slot] = button; + } + private ShopItem getPrivateItem(ServerInfo serverInfo) { String hostName = serverInfo.Name.substring(0, serverInfo.Name.indexOf('-')); @@ -371,36 +404,47 @@ public class ServerNpcPage extends ShopPageBase im private void buildInProgressServerPage(List serverList, int slotsNeeded) { int slot = 9; + + ArrayList inProgress = new ArrayList(); for (ServerInfo serverInfo : serverList) { - if (isInProgress(serverInfo) && slot < getSize()) + if (isInProgress(serverInfo)) { - ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded); - - addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); - - slot++; + inProgress.add(serverInfo); } } - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + for (ServerInfo serverInfo : inProgress) + { + if (inProgress.size() > 45 && slot > 9 && slot % 45 == 0) + { + addBackBed(slot + 4); + slot += 9; + } + + ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded); + + addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); + + slot++; + } + + addBackBed(4); + } + + private void addBackBed(int slot) + { + addButton(slot, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] + {}, 1, false), new IButton() { @Override public void onClick(Player player, ClickType clickType) { - clear(); _onMainPage = true; + buildPage(); } }); - - while (slot < getSize()) - { - if (getItem(slot) != null) - setItem(slot, null); - - slot++; - } } public void Update() @@ -414,7 +458,7 @@ public class ServerNpcPage extends ShopPageBase im System.out.println("Selecting server :" + serverInfo.Name); int slots = getPlugin().getRequiredSlots(player, serverInfo.ServerType); - if (serverInfo.getAvailableSlots() < slots && !(getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().Has(Rank.ULTRA))) + if (serverInfo.getAvailableSlots() < slots && !(getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().has(Rank.ULTRA))) { playDenySound(player); return; @@ -422,4 +466,16 @@ public class ServerNpcPage extends ShopPageBase im getPlugin().selectServer(player, serverInfo); } + + @Override + protected IButton[] getButtons() + { + return _buttons; + } + + @Override + protected ItemStack[] getItems() + { + return _items; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java index e8c7d1a8c..c91ce9eca 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java @@ -17,8 +17,8 @@ public class PartyTutorial extends Tutorial double y = -manager.GetSpawn().getY(); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 10), - manager.GetSpawn().add(81, y+68.5, 10), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Parties", new String[] { @@ -32,8 +32,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Creating a Party", new String[] { @@ -47,8 +47,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Inviting and Suggesting Players", new String[] { @@ -61,8 +61,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Leaving Parties", new String[] { @@ -73,8 +73,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Kicking Players from Party", new String[] { @@ -87,8 +87,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Joining Games Together", new String[] { @@ -103,8 +103,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Party Chat", new String[] { @@ -118,8 +118,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(0, -2, 0), - manager.GetSpawn().add(0, -2.1, 5), + manager.GetSpawn().add(0, 0, 0), + manager.GetSpawn().add(0, 0.1, 5), "End", new String[] { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java index 5eb6b5ebb..17ddabbad 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java @@ -132,8 +132,8 @@ public class WelcomeTutorial extends Tutorial //END _phases.add(new TutorialPhase( - manager.GetSpawn().add(0, -2, 0), - manager.GetSpawn().add(0, -2.1, 5), + manager.GetSpawn().add(0, 0, 0), + manager.GetSpawn().add(0, 0.1, 5), "End", new String[] { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java index 490f4b8cf..a229e5e07 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java @@ -1,5 +1,6 @@ package mineplex.mapparser.command; +import java.io.File; import java.util.List; import org.bukkit.Bukkit; @@ -77,6 +78,18 @@ public class MapCommand extends BaseCommand message(player, "That map is being backed up now. Try again soon"); return true; } + + //Delete UID + File file = new File(worldName + "/uid.dat"); + if (file.exists()) + { + System.out.println("Deleting uid.dat for " + worldName); + file.delete(); + } + else + { + System.out.println("Could not delete uid.dat for " + worldName); + } World world = getPlugin().GetMapWorld(worldName); if (world == null) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index 6e1815456..c04931c49 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -550,7 +550,7 @@ public class ClientClass if (skillName == null || skill == null || expectedType == null) return false; - if (!skillName.isEmpty() && (skill == null || skill.GetSkillType() != expectedType || (!skill.IsFree() && !_donor.OwnsUnknownPackage("Champions " + skillName) && !_client.GetRank().Has(Rank.ULTRA) && !_donor.OwnsUnknownPackage("Competitive ULTRA")))) + if (!skillName.isEmpty() && (skill == null || skill.GetSkillType() != expectedType || (!skill.IsFree() && !_donor.OwnsUnknownPackage("Champions " + skillName) && !_client.GetRank().has(Rank.ULTRA) && !_donor.OwnsUnknownPackage("Competitive ULTRA")))) return false; } catch (NullPointerException ex) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java index 5a333c782..b4cb1481f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java @@ -48,7 +48,7 @@ public class ClassShopManager extends MiniPlugin public boolean hasAchievements(Player player) { - if (_clientManager.Get(player).GetRank().Has(Rank.HELPER)) + if (_clientManager.Get(player).GetRank().has(Rank.HELPER)) return true; return _achievementManager.hasCategory(player, new Achievement[] diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index becb04fbd..37c726d6c 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -403,7 +403,7 @@ public class SkillPage extends ShopPageBase private boolean isSkillLocked(ISkill skill) { - if (skill.IsFree() || getClientManager().Get(getPlayer().getName()).GetRank().Has(Rank.ULTRA) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + skill.GetName())) + if (skill.IsFree() || getClientManager().Get(getPlayer().getName()).GetRank().has(Rank.ULTRA) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + skill.GetName())) return false; return true; @@ -411,7 +411,7 @@ public class SkillPage extends ShopPageBase private boolean isItemLocked(Item item) { - if (item.isFree() || getClientManager().Get(getPlayer().getName()).GetRank().Has(Rank.ULTRA) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + item.GetName())) + if (item.isFree() || getClientManager().Get(getPlayer().getName()).GetRank().has(Rank.ULTRA) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + item.GetName())) return false; return true; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/Fire.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/Fire.java index 9ace55077..1cc41f938 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/Fire.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/Fire.java @@ -4,19 +4,19 @@ import java.util.HashMap; import java.util.HashSet; import mineplex.core.MiniPlugin; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; -import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.EntityEffect; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -25,12 +25,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffectType; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; public class Fire extends MiniPlugin { @@ -46,9 +42,9 @@ public class Fire extends MiniPlugin _damageManager = damageManager; } - public void Add(Item item, LivingEntity owner, double expireTime, double delayTime, double burnTime, int damage, String skillName) + public void Add(Item item, LivingEntity owner, double expireTime, double delayTime, double burnTime, double d, String skillName) { - _fire.put(item, new FireData(owner, expireTime, delayTime, burnTime, damage, skillName)); + _fire.put(item, new FireData(owner, expireTime, delayTime, burnTime, d, skillName)); item.setPickupDelay(0); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/FireData.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/FireData.java index e70f5627f..a06baaa29 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/FireData.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/fire/FireData.java @@ -8,10 +8,10 @@ public class FireData private long _expireTime; private long _delayTime; private double _burnTime; - private int _damage; + private double _damage; private String _skillName; - public FireData(LivingEntity owner, double expireTime, double delayTime, double burnTime, int damage, String skillName) + public FireData(LivingEntity owner, double expireTime, double delayTime, double burnTime, double damage, String skillName) { _owner = owner; _expireTime = System.currentTimeMillis() + (long)(1000 * expireTime); @@ -31,7 +31,7 @@ public class FireData return _burnTime; } - public int GetDamage() + public double GetDamage() { return _damage; } diff --git a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java index 15cffb719..cf320dbde 100644 --- a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java +++ b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java @@ -8,9 +8,19 @@ import mineplex.serverdata.servers.ServerManager; public class PlayerCache { + private static PlayerCache _instance = null; + private RedisDataRepository _repository; - public PlayerCache() + public static PlayerCache getInstance() + { + if (_instance == null) + _instance = new PlayerCache(); + + return _instance; + } + + private PlayerCache() { _repository = new RedisDataRepository( ServerManager.getMasterConnection(), @@ -22,12 +32,30 @@ public class PlayerCache public void addPlayer(PlayerInfo player) { - _repository.addElement(player, 60 * 60 * 6); // 6 Hours + try + { + _repository.addElement(player, 60 * 60 * 6); // 6 Hours + } + catch (Exception exception) + { + System.out.println("Error adding player info in PlayerCache : " + exception.getMessage()); + exception.printStackTrace(); + } } public PlayerInfo getPlayer(UUID uuid) { - return _repository.getElement(uuid.toString()); + try + { + return _repository.getElement(uuid.toString()); + } + catch (Exception exception) + { + System.out.println("Error retrieving player info in PlayerCache : " + exception.getMessage()); + exception.printStackTrace(); + } + + return null; } public void clean() diff --git a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java index 700839ccb..3ab44b0d5 100644 --- a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java +++ b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java @@ -2,11 +2,13 @@ package mineplex.playerCache; import java.util.UUID; +import mineplex.serverdata.Utility; import mineplex.serverdata.data.Data; public class PlayerInfo implements Data { private int _id; + private int _accountId; private UUID _uuid; private String _name; private boolean _online; @@ -34,6 +36,11 @@ public class PlayerInfo implements Data return _id; } + public int getAccountId() + { + return _accountId; + } + public UUID getUUID() { return _uuid; @@ -83,4 +90,14 @@ public class PlayerInfo implements Data { _version = version; } + + public void setAccountId(int accountId) + { + _accountId = accountId; + } + + public void updateLoginTime() + { + _loginTime = Utility.currentTimeMillis(); + } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java index b71a39583..2a50ea3b9 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java @@ -19,7 +19,9 @@ import com.google.gson.GsonBuilder; */ public class Utility { - + private static boolean _retrievedRedisTime = false; + private static long _millisTimeDifference; + // The Gson instance used to serialize/deserialize objects in JSON form. private static Gson _gson = new GsonBuilder().create(); public static Gson getGson() { return _gson; } @@ -74,29 +76,10 @@ public class Utility */ public static long currentTimeSeconds() { - long currentTime = 0; - JedisPool pool = getPool(false); - Jedis jedis = pool.getResource(); - - try - { - currentTime = Long.parseLong(jedis.time().get(0)); - } - catch (JedisConnectionException exception) - { - exception.printStackTrace(); - pool.returnBrokenResource(jedis); - jedis = null; - } - finally - { - if (pool != null) - { - pool.returnResource(jedis); - } - } - - return currentTime; + if (!_retrievedRedisTime) + setTimeDifference(); + + return (System.currentTimeMillis() + _millisTimeDifference) / 1000; } /** @@ -105,29 +88,10 @@ public class Utility */ public static long currentTimeMillis() { - long currentTime = 0; - JedisPool pool = getPool(false); - Jedis jedis = pool.getResource(); + if (!_retrievedRedisTime) + setTimeDifference(); - try - { - currentTime = Long.parseLong(jedis.time().get(0)); - } - catch (JedisConnectionException exception) - { - exception.printStackTrace(); - pool.returnBrokenResource(jedis); - jedis = null; - } - finally - { - if (pool != null) - { - pool.returnResource(jedis); - } - } - - return currentTime * 1000; + return System.currentTimeMillis() + _millisTimeDifference; } /** @@ -188,4 +152,30 @@ public class Utility return connData.getHost() + ":" + connData.getPort(); } + private static void setTimeDifference() + { + long currentTime = 0; + JedisPool pool = getPool(false); + Jedis jedis = pool.getResource(); + + try + { + currentTime = Long.parseLong(jedis.time().get(0)); + } + catch (JedisConnectionException exception) + { + exception.printStackTrace(); + pool.returnBrokenResource(jedis); + jedis = null; + } + finally + { + if (pool != null) + { + pool.returnResource(jedis); + } + } + + _millisTimeDifference = (currentTime * 1000) - System.currentTimeMillis(); + } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/PlayerJoinCommand.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/PlayerJoinCommand.java new file mode 100644 index 000000000..b41ba4555 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/PlayerJoinCommand.java @@ -0,0 +1,24 @@ +package mineplex.serverdata.commands; + +import java.util.UUID; + +public class PlayerJoinCommand extends ServerCommand +{ + private String _uuid; + + public PlayerJoinCommand(UUID uuid) + { + _uuid = uuid.toString(); + } + + @Override + public void run() + { + // Utilitizes a callback functionality to seperate dependencies + } + + public String getUuid() + { + return _uuid; + } +} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java index 31adb7fe8..3b00da7c2 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java @@ -43,6 +43,9 @@ public class MinecraftServer private int _port; public int getPort() { return _port; } + private int _donorsOnline; + public int getDonorsOnline() { return _donorsOnline; } + private long _startUpDate; /** @@ -59,19 +62,20 @@ public class MinecraftServer * @param maxRam */ public MinecraftServer(String name, String group, String motd, String publicAddress, int port, - int playerCount, int maxPlayerCount, int tps, int ram, int maxRam, long startUpDate) + int playerCount, int maxPlayerCount, int tps, int ram, int maxRam, long startUpDate, int donorsOnline) { - this._name = name; - this._group = group; - this._motd = motd; - this._playerCount = playerCount; - this._maxPlayerCount = maxPlayerCount; - this._tps = tps; - this._ram = ram; - this._maxRam = maxRam; - this._publicAddress = publicAddress; - this._port = port; - this._startUpDate = startUpDate; + _name = name; + _group = group; + _motd = motd; + _playerCount = playerCount; + _maxPlayerCount = maxPlayerCount; + _tps = tps; + _ram = ram; + _maxRam = maxRam; + _publicAddress = publicAddress; + _port = port; + _donorsOnline = donorsOnline; + _startUpDate = startUpDate; } /** diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java index 509006ca0..5cb4d9072 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java @@ -25,9 +25,11 @@ public class PlayerStatus implements Data /** * Unique identifying String ID associated with this {@link PlayerStatus}. + * + * Use the lowercase name so we can have case-insensitive lookup */ public String getDataId() { - return _name; + return _name.toLowerCase(); } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java index fbf5d563b..1c40dab73 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java @@ -20,8 +20,9 @@ import mineplex.serverdata.servers.ConnectionData.ConnectionType; * */ public class ServerManager -{ +{ public static final String SERVER_STATUS_LABEL = "ServerStatus"; // Label differentiating ServerStatus related servers + private static final String DEFAULT_CONFIG = "redis-config.dat"; // Configuration determining connection information private static RedisConfig _config; @@ -74,7 +75,7 @@ public class ServerManager public static ConnectionData getConnection(boolean writeable, String name) { - return getConfig().getConnection(writeable, name); + return getConfig(DEFAULT_CONFIG).getConnection(writeable, name); } /** @@ -89,44 +90,48 @@ public class ServerManager /** * @return the {@link RedisConfig} associated with this manager, providing appropriate connections. */ - public static RedisConfig getConfig() + public static RedisConfig getConfig(String fileName) { if (_config == null) - { - try - { - File configFile = new File("redis-config.dat"); - - if (configFile.exists()) - { - List connections = new ArrayList(); - List lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset()); - - for (String line : lines) - { - ConnectionData connection = deserializeConnection(line); - connections.add(connection); - - } - - _config = new RedisConfig(connections); - } - else - { - log("redis-config.dat not found at " + configFile.toPath().toString()); - _config = new RedisConfig(); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - log("---Unable To Parse Redis Configuration File---"); - } - - } - + _config = loadConfig(fileName); + return _config; } + + public static RedisConfig loadConfig(String fileName) + { + try + { + File configFile = new File(fileName); + + if (configFile.exists()) + { + List connections = new ArrayList(); + List lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset()); + + for (String line : lines) + { + ConnectionData connection = deserializeConnection(line); + connections.add(connection); + + } + + return new RedisConfig(connections); + } + else + { + log(fileName + " not found at " + configFile.toPath().toString()); + return new RedisConfig(); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + log("---Unable To Parse Redis Configuration File---"); + } + + return null; + } /** * @param line - the serialized line representing a valid {@link ConnectionData} object. diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 0cb7fa5b0..ca9557402 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -16,6 +16,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Timer; +import java.util.TimerTask; import java.util.logging.FileHandler; import java.util.logging.Logger; @@ -42,10 +44,12 @@ public class ServerMonitor private static Map _serverGroupMap = null; private static List _dedicatedServers = null; private static HashSet _deadServers = new HashSet(); + private static HashSet _delayedKill = new HashSet(); private static HashSet _laggyServers = new HashSet(); private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); private static Logger _logger = Logger.getLogger("ServerMonitor"); + private static Timer _timer = new Timer(); private static int _totalPlayers = 0; private static Region _region; @@ -124,12 +128,15 @@ public class ServerMonitor for (MinecraftServer minecraftServer : _serverStatuses) { - if (minecraftServer.getMotd().contains("Finished") || (minecraftServer.getGroup().equalsIgnoreCase("UltraHardcore") && minecraftServer.getMotd().contains("Restarting") && minecraftServer.getPlayerCount() == 0)) + if (!ignoreServer(minecraftServer.getGroup())) { - killServer(minecraftServer.getName(), minecraftServer.getPublicAddress(), minecraftServer.getPlayerCount(), "[KILLED] [FINISHED] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress(), true); - - handleUserServerGroup(_serverGroupMap.get(minecraftServer.getGroup())); - continue; + if (minecraftServer.getMotd().contains("Finished") || (minecraftServer.getGroup().equalsIgnoreCase("UltraHardcore") && minecraftServer.getMotd().contains("Restarting") && minecraftServer.getPlayerCount() == 0)) + { + killServer(minecraftServer.getName(), minecraftServer.getPublicAddress(), minecraftServer.getPlayerCount(), "[KILLED] [FINISHED] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress(), true); + + handleUserServerGroup(_serverGroupMap.get(minecraftServer.getGroup())); + continue; + } } for (DedicatedServer server : _dedicatedServers) @@ -202,6 +209,9 @@ public class ServerMonitor for (ServerGroup groupStatus : _serverGroups) { + if (ignoreServer(groupStatus.getName())) + continue; + NautHashMap serverMap = new NautHashMap(); for (Iterator serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();) @@ -226,17 +236,6 @@ public class ServerMonitor exception.printStackTrace(); } } - - /* - if (groupStatus.getHost() == null || groupStatus.getHost().isEmpty()) - { - if (groupStatus.getName().startsWith("0")) - { - int serverCount = groupStatus.getServers().size(); - log(groupStatus.getName() + " : " + groupStatus.getPlayerCount() + " players on " + serverCount + " servers " + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredCpu() / totalCPU)) + "% CPU," + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredRam() / totalRAM)) + "% RAM", false); - } - } - */ } HashSet onlineServers = new HashSet(); @@ -246,7 +245,7 @@ public class ServerMonitor for (MinecraftServer minecraftServer : _serverStatuses) { - if (minecraftServer.getGroup().equalsIgnoreCase("Testing")) + if (ignoreServer(minecraftServer.getGroup())) continue; onlineServers.add(minecraftServer.getName()); @@ -288,7 +287,7 @@ public class ServerMonitor for (ServerGroup serverGroup : _serverGroups) { - if (serverGroup.getName().equals("Testing")) + if (ignoreServer(serverGroup.getName())) continue; try @@ -386,21 +385,35 @@ public class ServerMonitor deadServers.addAll(_deadServers); _deadServers.clear(); - for (MinecraftServer deadServer : _repository.getDeadServers()) + for (final MinecraftServer deadServer : _repository.getDeadServers()) { - if (deadServer.getUptime() <= 10 || deadServer.getGroup().equalsIgnoreCase("Testing")) + if (deadServer.getUptime() <= 10 || ignoreServer(deadServer.getGroup())) continue; if (_count == 0 || deadServers.contains(deadServer.getName())) { + copyServerLog(deadServer); killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true); handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup())); } - else - { - _deadServers.add(deadServer.getName()); - log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress()); + else if (!_delayedKill.contains(deadServer.getName())) + { + startTimingReport(deadServer); + + _timer.schedule(new TimerTask() + { + 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()); } } } @@ -486,7 +499,7 @@ public class ServerMonitor if (joinableServers > maxUHC) serversToKill = maxUHC - joinableServers; } - else if (serverGroup.getName().equalsIgnoreCase("Testing")) + else if (ignoreServer(serverGroup.getName())) { return; } @@ -653,6 +666,105 @@ public class ServerMonitor killServer(serverToKill.getName(), serverToKill.getPublicAddress(), serverToKill.getPlayerCount(), message, true); } + private static void startTimingReport(final MinecraftServer server) + { + if (_debug) + return; + + String cmd = "/home/mineplex/remoteStartTiming.sh"; + + ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() }); + pr.start(new GenericRunnable() + { + public void run(Boolean error) + { + if (error) + log("[TIMING START] Errored " + server.getName() + "(" + server.getPublicAddress() + ")"); + else + log("[TIMING START] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")"); + + } + }); + + try + { + pr.join(100); + } + catch (InterruptedException e1) + { + e1.printStackTrace(); + } + + if (!pr.isDone()) + _processes.add(pr); + } + + private static void stopTimingReport(final MinecraftServer server) + { + if (_debug) + return; + + String cmd = "/home/mineplex/remoteStopTiming.sh"; + + ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() }); + pr.start(new GenericRunnable() + { + public void run(Boolean error) + { + if (error) + log("[TIMING PASTE] Errored " + server.getName() + "(" + server.getPublicAddress() + ")"); + else + log("[TIMING PASTE] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")"); + + } + }); + + try + { + pr.join(100); + } + catch (InterruptedException e1) + { + e1.printStackTrace(); + } + + if (!pr.isDone()) + _processes.add(pr); + } + + private static void copyServerLog(final MinecraftServer server) + { + if (_debug) + return; + + String cmd = "/home/mineplex/easyRemoteCopyLog.sh"; + + ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() }); + pr.start(new GenericRunnable() + { + public void run(Boolean error) + { + if (error) + log("[COPY LOG] Errored " + server.getName() + "(" + server.getPublicAddress() + ")"); + else + log("[COPY LOG] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")"); + + } + }); + + try + { + pr.join(100); + } + catch (InterruptedException e1) + { + e1.printStackTrace(); + } + + if (!pr.isDone()) + _processes.add(pr); + } + private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free) { if (_debug) @@ -691,6 +803,11 @@ public class ServerMonitor _processes.add(pr); } + private static boolean ignoreServer(String serverGroupName) + { + return serverGroupName.equalsIgnoreCase("Testing") || serverGroupName.equalsIgnoreCase("Clans"); + } + private static void log(String message) { log(message, false); diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java index e2f94098c..a85d42848 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java @@ -3,16 +3,19 @@ package mineplex.servermonitor; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; +import java.util.Iterator; import java.util.List; import mineplex.serverdata.Region; +import mineplex.serverdata.data.BungeeServer; +import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.data.DedicatedServer; import mineplex.serverdata.data.ServerGroup; -import mineplex.servermonitor.data.BungeeStatusData; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ServerManager; public class StatusHistoryRepository { @@ -24,8 +27,6 @@ public class StatusHistoryRepository private static String CREATE_DEDICATED_TABLE = "CREATE TABLE IF NOT EXISTS DedicatedServerStats (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), address VARCHAR(25), updated LONG, cpu TINYINT, ram MEDIUMINT, usedCpuPercent DOUBLE(4,2), usedRamPercent DOUBLE(4,2), US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));"; private static String CREATE_BUNGEE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeStats (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(25), updated LONG, players INT, maxPlayers INT, alive BOOLEAN NOT NULL, online BOOLEAN NOT NULL, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));"; private static String CREATE_NETWORKSTATS_TABLE = "CREATE TABLE IF NOT EXISTS NetworkStats (id INT NOT NULL AUTO_INCREMENT, updated LONG, players INT, totalNetworkCpuUsage DOUBLE(4,2), totalNetworkRamUsage DOUBLE(4,2), totalCpu MEDIUMINT, totalRam MEDIUMINT, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));"; - - private static String RETRIEVE_BUNGEE_STATUSES = "SELECT bungeeStatus.address, bungeeStatus.players, bungeeStatus.maxPlayers, bungeeStatus.US, onlineStatus.online, now(), bungeeStatus.updated FROM BungeeServers AS bungeeStatus INNER JOIN bungeeOnlineStatus AS onlineStatus ON onlineStatus.address = bungeeStatus.address"; private static String INSERT_SERVERGROUP_STATS = "INSERT INTO ServerGroupStats (serverGroup, updated, players, maxPlayers, totalNetworkCpuUsage, totalNetworkRamUsage, totalCpu, totalRam, US) VALUES (?, now(), ?, ?, ?, ?, ?, ?, ?);"; private static String INSERT_DEDICATEDSERVER_STATS = "INSERT INTO DedicatedServerStats (serverName, address, updated, cpu, ram, usedCpuPercent, usedRamPercent, US) VALUES (?, ?, now(), ?, ?, ?, ?, ?);"; @@ -33,7 +34,8 @@ public class StatusHistoryRepository private static String INSERT_NETWORK_STATS = "INSERT INTO NetworkStats (updated, players, totalNetworkCpuUsage, totalNetworkRamUsage, totalCpu, totalRam, US) VALUES (now(), ?, ?, ?, ?, ?, ?);"; private static Connection _connection; - private static Connection _bungeeconnection; + + private static DataRepository _repository; public StatusHistoryRepository() { @@ -65,6 +67,9 @@ public class StatusHistoryRepository preparedStatement = _connection.prepareStatement(CREATE_NETWORKSTATS_TABLE); preparedStatement.execute(); preparedStatement.close(); + + _repository = new RedisDataRepository(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL), + Region.ALL, BungeeServer.class, "bungeeServers"); } catch (Exception exception) { @@ -185,58 +190,16 @@ public class StatusHistoryRepository public void saveNetworkStats(double usedCpuPercent, double usedRamPercent, double availableCPU, double availableRAM, Region region) { - /* int totalPlayers = 0; - List bungeeStatuses = new ArrayList(); - PreparedStatement retrieveStatement = null; + List bungeeServers = new ArrayList(_repository.getElements()); - try + for (Iterator bungeeIterator = bungeeServers.iterator(); bungeeIterator.hasNext();) { - if (_bungeeconnection == null || _bungeeconnection.isClosed()) - _bungeeconnection = DriverManager.getConnection(_bungeeConnectionString, _userName, _password); + BungeeServer server = bungeeIterator.next(); - retrieveStatement = _bungeeconnection.prepareStatement(RETRIEVE_BUNGEE_STATUSES); - ResultSet resultSet = retrieveStatement.executeQuery(); - - while (resultSet.next()) - { - BungeeStatusData bungeeData = new BungeeStatusData(); - bungeeData.Address = resultSet.getString(1); - bungeeData.Players = resultSet.getInt(2); - bungeeData.MaxPlayers = resultSet.getInt(3); - bungeeData.US = resultSet.getBoolean(4); - bungeeData.Online = resultSet.getBoolean(5); - - long now = resultSet.getLong(6); - long updated = resultSet.getLong(7); - - bungeeData.Alive = (now - updated) <= 15; - - if (bungeeData.Alive && bungeeData.US == (region == Region.US)) - totalPlayers += bungeeData.Players; - - if (bungeeData.US == (region == Region.US)) - bungeeStatuses.add(bungeeData); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (retrieveStatement != null) - { - try - { - retrieveStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } + if (server.getPublicAddress().equalsIgnoreCase("127.0.0.1") || server.getPublicAddress().equalsIgnoreCase("0.0.0.0")) + bungeeIterator.remove(); } PreparedStatement preparedStatement = null; @@ -248,15 +211,16 @@ public class StatusHistoryRepository preparedStatement = _connection.prepareStatement(INSERT_BUNGEE_STATS); - for (BungeeStatusData bungeeStatusData : bungeeStatuses) + for (BungeeServer bungeeStatusData : bungeeServers) { - preparedStatement.setString(1, bungeeStatusData.Address); - preparedStatement.setInt(2, bungeeStatusData.Players); - preparedStatement.setInt(3, bungeeStatusData.MaxPlayers); - preparedStatement.setBoolean(4, bungeeStatusData.Alive); - preparedStatement.setBoolean(5, bungeeStatusData.Online); - preparedStatement.setBoolean(6, bungeeStatusData.US); - preparedStatement.addBatch(); + totalPlayers += bungeeStatusData.getPlayerCount(); + preparedStatement.setString(1, bungeeStatusData.getPublicAddress()); + preparedStatement.setInt(2, bungeeStatusData.getPlayerCount()); + preparedStatement.setInt(3, bungeeStatusData.getPlayerCount()); + preparedStatement.setBoolean(4, true); + preparedStatement.setBoolean(5, true); + preparedStatement.setBoolean(6, bungeeStatusData.getRegion() == Region.US); + preparedStatement.addBatch(); } preparedStatement.executeBatch(); @@ -315,6 +279,5 @@ public class StatusHistoryRepository } } } - */ } } diff --git a/Plugins/Mineplex.StaffServer/.classpath b/Plugins/Mineplex.StaffServer/.classpath index acc97657a..e03947a20 100644 --- a/Plugins/Mineplex.StaffServer/.classpath +++ b/Plugins/Mineplex.StaffServer/.classpath @@ -11,6 +11,6 @@ - + diff --git a/Plugins/Mineplex.StaffServer/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.StaffServer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/Plugins/Mineplex.StaffServer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index cb9dcedf9..99fd02eb4 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -47,7 +47,7 @@ public class CustomerSupport extends MiniPlugin @EventHandler public void Join(PlayerJoinEvent event) { - if (!_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR)) + if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR)) { event.getPlayer().kickPlayer("Only for staff."); return; diff --git a/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml b/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml new file mode 100644 index 000000000..c5e840788 --- /dev/null +++ b/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Mineplex.Votifier/plugin.yml b/Plugins/Mineplex.Votifier/plugin.yml new file mode 100644 index 000000000..75a40f893 --- /dev/null +++ b/Plugins/Mineplex.Votifier/plugin.yml @@ -0,0 +1,3 @@ +name: MineplexVotifier +main: mineplex.votifier.Votifier +version: 0.1 \ No newline at end of file diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java new file mode 100644 index 000000000..f3fd02c9a --- /dev/null +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java @@ -0,0 +1,34 @@ +package mineplex.votifier; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.command.CommandCenter; +import mineplex.core.donation.DonationManager; + +/** + * Created by shaun on 15-08-05. + */ +public class Votifier extends JavaPlugin +{ + private String WEB_CONFIG = "webServer"; + + @Override + public void onEnable() + { + getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); + getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); + saveConfig(); + + String webServerAddress = getConfig().getString(WEB_CONFIG); + + CommandCenter.Initialize(this); + CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); + DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); + BonusManager bonusManager = new BonusManager(this, clientManager, donationManager); + + + VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager); + } +} diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java new file mode 100644 index 000000000..19a3c37b3 --- /dev/null +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -0,0 +1,283 @@ +package mineplex.votifier; + +import java.sql.Date; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import com.vexsoftware.votifier.model.Vote; +import com.vexsoftware.votifier.model.VotifierEvent; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.Pair; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.database.DBPool; +import mineplex.core.donation.DonationManager; +import mineplex.core.bonuses.redis.VotifierCommand; +import mineplex.database.Tables; +import mineplex.database.tables.records.BonusRecord; +import mineplex.serverdata.Region; +import mineplex.serverdata.Utility; +import mineplex.serverdata.commands.ServerCommand; +import mineplex.serverdata.data.PlayerStatus; +import mineplex.serverdata.redis.RedisConfig; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ServerManager; +import org.jooq.DSLContext; +import org.jooq.Record1; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.exceptions.JedisConnectionException; + +/** + * Created by shaun on 15-08-05. + */ +public class VotifierManager extends MiniPlugin +{ + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private BonusManager _bonusManager; + + private RedisConfig _usConfig; + private RedisConfig _euConfig; + private RedisDataRepository _usPlayerRepo; + private RedisDataRepository _euPlayerRepo; + private JedisPool _usWritePool; + private JedisPool _euWritePool; + + public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager) + { + super("Votifier", plugin); + + _clientManager = clientManager; + _donationManager = donationManager; + _bonusManager = bonusManager; + + _usConfig = ServerManager.loadConfig("us-redis.dat"); + _euConfig = ServerManager.loadConfig("eu-redis.dat"); + + _usPlayerRepo = new RedisDataRepository(_usConfig.getConnection(true, "DefaultConnection"), + _usConfig.getConnection(false, "DefaultConnection"), Region.US, PlayerStatus.class, "playerStatus"); + _euPlayerRepo = new RedisDataRepository(_euConfig.getConnection(true, "DefaultConnection"), + _euConfig.getConnection(false, "DefaultConnection"), Region.EU, PlayerStatus.class, "playerStatus"); + + _usWritePool = Utility.generatePool(_usConfig.getConnection(true, "DefaultConnection")); + _euWritePool = Utility.generatePool(_euConfig.getConnection(true, "DefaultConnection")); + } + + @EventHandler + public void handleVote(VotifierEvent event) + { + final Vote vote = event.getVote(); + final String playerName = vote.getUsername(); + + System.out.println("New Vote: " + playerName); + + runAsync(new Runnable() + { + @Override + public void run() + { + UUID uuid = UUIDFetcher.getUUIDOf(playerName); + if (uuid == null) + { + System.out.println("Failed to load UUID of " + playerName + " from UUIDFetcher. Trying with database"); + uuid = _clientManager.loadUUIDFromDB(playerName); + + if (uuid == null) + { + System.out.println("Failed to load UUID from database. Giving up on " + playerName); + } + } + + String lowerPlayerName = playerName.toLowerCase(); + final PlayerStatus usStatus = _usPlayerRepo.getElement(lowerPlayerName); + final PlayerStatus euStatus = _euPlayerRepo.getElement(lowerPlayerName); + + System.out.println("Loaded " + playerName + " with uuid " + uuid); + System.out.println("Attempting to award bonus"); + final UUID finalUuid = uuid; + awardBonus(playerName, finalUuid, new Callback() + { + @Override + public void run(final Integer gems) + { + runSync(new Runnable() + { + @Override + public void run() + { + if (usStatus != null) + { + System.out.println("Found " + playerName + " on US " + usStatus.getServer()); + notifyServer(playerName, gems, Region.US, usStatus.getServer()); + } + + if (euStatus != null) + { + System.out.println("Found " + playerName + " on EU " + euStatus.getServer()); + notifyServer(playerName, gems, Region.EU, euStatus.getServer()); + } + } + }); + } + }); + } + }); + System.out.println(); + System.out.println(); + +// UUID uuid = _clientManager.loadUUIDFromDB(playerName); +// if (uuid != null) +// { +// System.out.println("Found UUID:" + uuid.toString()); +// if (playerName.equalsIgnoreCase("Phinary")) +// { +// System.out.println("award bonus"); +// awardBonus(uuid); +// } +// } +// else +// { +// System.out.println("Failed to load UUID for player: " + playerName); +// } + +// PlayerStatus usStatus = _usPlayerRepo.getElement(playerName); +// if (usStatus != null) +// { +// System.out.println("Found on US Server: " + usStatus.getServer()); +// writePool = _usWritePool; +// serverName = usStatus.getServer(); +// } +// +// PlayerStatus euStatus = _euPlayerRepo.getElement(playerName); +// if (euStatus != null) +// { +// System.out.println("Found on EU Server: " + euStatus.getServer()); +// writePool = _euWritePool; +// serverName = euStatus.getServer(); +// } + + // Currently we just notify all servers, and the server with the player on it can deal with it +// notifyServer(playerName, true); + } + + private void notifyServer(String playerName, int gems, Region region, String targetServer) + { + JedisPool writePool = region == Region.EU ? _euWritePool : _usWritePool; + + VotifierCommand command = new VotifierCommand(playerName, gems, targetServer); + publishCommand(command, writePool); + } + + private void awardBonus(final String playerName, final UUID uuid, final Callback onComplete) + { + DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + + Record1 idRecord = create.select(Tables.accounts.id).from(Tables.accounts).where(Tables.accounts.uuid.eq(uuid.toString())).fetchOne(); + if (idRecord != null) + { + final int accountId = idRecord.value1(); + final BonusRecord client = _bonusManager.getRepository().loadRecord(playerName, accountId); + + final BonusAmount amount = _bonusManager.getVoteBonusAmount(client.getVoteStreak()); + + _bonusManager.getRepository().attemptVoteBonus(accountId, new Callback>() + { + @Override + public void run(Pair pair) + { + if (pair.getLeft()) + { + // Reward Amount + if (amount.getTickets() > 0) + client.setTickets(client.getTickets() + amount.getTickets()); + + if (amount.getTotalGems() > 0) + { + _donationManager.RewardGems(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + System.out.println("Gave " + amount.getGems() + " gems to " + playerName); + else + System.out.println("Failed to give " + amount.getGems() + " gems to " + playerName); + } + }, "Votifier", playerName, uuid, amount.getTotalGems()); + } + + if (amount.getTotalCoins() > 0) + { + _donationManager.RewardCoins(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + System.out.println("Gave " + amount.getGems() + " coins to " + playerName); + else + System.out.println("Failed to give " + amount.getGems() + " coins to " + playerName); + } + }, "Votifier", playerName, accountId, amount.getTotalCoins()); + } + + // Check if we need to reset vote streak + _bonusManager.updateVoteStreak(client); + client.setVotetime(pair.getRight()); + + // Update Streak + _bonusManager.incrementVoteStreak(client); + + client.store(); + System.out.println("Awarded carl ticket to " + playerName); + onComplete.run(amount.getTotalGems()); + } + else + { + System.out.println(playerName + " attempted to vote, vote bonus returned false!"); + } + } + }); + } + } + + private void publishCommand(final ServerCommand serverCommand, final JedisPool writePool) + { + new Thread(new Runnable() + { + public void run() + { + Jedis jedis = writePool.getResource(); + + try + { + String commandType = serverCommand.getClass().getSimpleName(); + String serializedCommand = Utility.serialize(serverCommand); + jedis.publish("commands.server" + ":" + commandType, serializedCommand); + } + catch (JedisConnectionException exception) + { + exception.printStackTrace(); + writePool.returnBrokenResource(jedis); + jedis = null; + } + finally + { + if (writePool != null) + { + writePool.returnResource(jedis); + } + } + } + }).start(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs b/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs index 13ca019e6..905977b2e 100644 --- a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs +++ b/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 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 3f063b9fb..d38023f34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -4,6 +4,7 @@ import java.io.File; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import org.omg.CORBA._PolicyStub; import net.minecraft.server.v1_7_R4.BiomeBase; import net.minecraft.server.v1_7_R4.MinecraftServer; @@ -24,6 +25,9 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.friend.FriendManager; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.give.Give; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; @@ -37,6 +41,7 @@ import mineplex.core.mount.MountManager; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -53,6 +58,7 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; +import nautilus.game.arcade.game.Game.GameState; public class Arcade extends JavaPlugin { @@ -112,7 +118,8 @@ public class Arcade extends JavaPlugin DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); - _damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, null); + NpcManager npcmanager = new NpcManager(this, creature); + _damageManager = new DamageManager(this, new CombatManager(this), npcmanager, disguiseManager, null); Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); @@ -137,9 +144,12 @@ public class Arcade extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null); cosmeticManager.setInterfaceSlot(7); + cosmeticManager.disableTeamArmor(); + //Arcade Manager - _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 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); 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 cc264d1e6..036793db1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -42,6 +42,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; +import mineplex.core.bonuses.BonusManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.ClickEvent; @@ -62,11 +63,15 @@ import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; import mineplex.core.explosion.Explosion; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; 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.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; @@ -74,6 +79,7 @@ import mineplex.core.packethandler.PacketPlayResourcePackStatus; import mineplex.core.packethandler.PacketPlayResourcePackStatus.EnumResourcePackStatus; import mineplex.core.party.PartyManager; import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -100,11 +106,12 @@ import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; -import nautilus.game.arcade.addons.CompassAddon; import nautilus.game.arcade.addons.SoupAddon; import nautilus.game.arcade.addons.TeamArmorAddon; +import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.command.DisguiseCommand; import nautilus.game.arcade.command.GameCommand; +import nautilus.game.arcade.command.RequiredRankCommand; import nautilus.game.arcade.command.WriteCommand; import nautilus.game.arcade.command.KitUnlockCommand; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -204,12 +211,15 @@ public class ArcadeManager extends MiniPlugin implements IRelation //Youtuber Kits private HashSet _youtube = new HashSet(); + + //Server Property + private Rank _requiredRank; public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, 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) + CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager) { super("Game Manager", plugin); @@ -293,6 +303,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation new NotificationManager(getPlugin(), clientManager); + new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager); + //Champions Modules _energy = new Energy(plugin); @@ -406,6 +418,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation }); getPacketHandler().addPacketHandler(_resourcePacketHandler); + + loadRequiredRank(); } @Override @@ -415,6 +429,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation addCommand(new WriteCommand(this)); addCommand(new KitUnlockCommand(this)); addCommand(new DisguiseCommand(this)); + addCommand(new RequiredRankCommand(this)); } public GameServerConfig GetServerConfig() @@ -777,7 +792,35 @@ public class ArcadeManager extends MiniPlugin implements IRelation { if (Bukkit.getServer().hasWhitelist()) { - if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.MODERATOR, false)) + if(_requiredRank != null) + { + if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), _requiredRank, false)) + { + event.allow(); + event.setResult(PlayerLoginEvent.Result.ALLOWED); + + if (_serverConfig.Tournament && _clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false)) + { + event.getPlayer().setOp(true); + } + } + else + { + for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) + { + if (player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.allow(); + event.setResult(PlayerLoginEvent.Result.ALLOWED); + return; + } + } + + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Required Rank for this server: " + _requiredRank.getColor() + _requiredRank.Name); + return; + } + } + if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -808,13 +851,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { - if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.HELPER, false)) + if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } - else if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.ULTRA, false) + else if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.ULTRA, false) || _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA")) { @@ -849,8 +892,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation { // Give developers operator on their servers boolean testServer = _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); - - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.OWNER) || (testServer && (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER) || _clientManager.Get(event.getPlayer()).GetRank() == Rank.JNR_DEV))) + boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); + + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.OWNER) + || (testServer && (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER) || _clientManager.Get(event.getPlayer()).GetRank() == Rank.JNR_DEV)) + || eventTestServer && _clientManager.Get(event.getPlayer()).GetRank().has(Rank.JNR_DEV)) event.getPlayer().setOp(true); else event.getPlayer().setOp(false); @@ -1479,4 +1525,38 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } } + + public void loadRequiredRank() + { + _requiredRank = null; + + for(File file : new File(".").listFiles()) + { + if(!file.getName().startsWith("RequiredRank")) + continue; + + try + { + _requiredRank = Rank.valueOf(file.getName().split("=")[1]); + System.out.println("set required rank to " + _requiredRank.Name); + } + catch (IllegalArgumentException e) + { + System.out.println("==============================="); + System.out.println("Wrong required rank definition."); + System.out.println("[" + file.getName().split("=")[1] + "] Does not exist!"); + System.out.println("==============================="); + } + } + } + + public Rank getRequiredRank() + { + return _requiredRank; + } + + public void setRequiredRank(Rank rank) + { + _requiredRank = rank; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/CompassAddon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAddon.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/CompassAddon.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAddon.java index 5d121b2ce..488295caf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/CompassAddon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAddon.java @@ -1,21 +1,7 @@ -package nautilus.game.arcade.addons; +package nautilus.game.arcade.addons.compass; import java.util.HashSet; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -34,6 +20,18 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.gui.spectatorMenu.SpectatorShop; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; + public class CompassAddon extends MiniPlugin { public ArcadeManager Manager; @@ -87,6 +85,12 @@ public class CompassAddon extends MiniPlugin if (target == null || dist < bestDist) { + CompassAttemptTargetEvent tE = new CompassAttemptTargetEvent(player, other); + Bukkit.getServer().getPluginManager().callEvent(tE); + + if (tE.isCancelled()) + continue; + target = other; targetTeam = otherTeam; bestDist = dist; @@ -202,7 +206,7 @@ public class CompassAddon extends MiniPlugin { // Teleport to nearest player when you left click compass - if (!Recharge.Instance.use(player, "Spectate", 5000, true, false)) + if (!Recharge.Instance.use(player, "Spectate", 3000, true, false)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAttemptTargetEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAttemptTargetEvent.java new file mode 100644 index 000000000..c6c846b10 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAttemptTargetEvent.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.addons.compass; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class CompassAttemptTargetEvent extends PlayerEvent implements Cancellable +{ + private static HandlerList _handlers = new HandlerList(); + private boolean _cancelled = false; + + private Player _target; + + public CompassAttemptTargetEvent(Player player, Player target) + { + super(player); + + _target = target; + } + + public Player getTarget() + { + return _target; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index 7c32ed36a..b8af19d2b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -45,330 +45,330 @@ import org.bukkit.scoreboard.Team; public class DisguiseCommand extends CommandBase implements Listener { - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - public DisguiseCommand(ArcadeManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] - { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - new NCPDataManFix(); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null) + public DisguiseCommand(ArcadeManager plugin) { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - try - { - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName, true); - - for(Player other : UtilServer.getPlayers()) - { - for(Team team : other.getScoreboard().getTeams()) - { - team.removePlayer(caller); - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } - - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); - return; + super(plugin, Rank.JNR_DEV, new Rank[] + { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + new NCPDataManFix(); } - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + @Override + public void Execute(final Player caller, final String[] args) { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) + if(args == null || args.length == 0) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - for(Player other : UtilServer.getPlayers()) - { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - - try - { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); - GameProfile profile = null; - try - { - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) - { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } - - Rank otherRank = Rank.ALL; - try - { - CoreClient other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - {} - if(otherRank.Has(Rank.TWITCH)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); - return; - } - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0], true); - - Plugin.getCosmeticManager().getGadgetManager().RemoveItem(caller); - - Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); - } catch(Exception e) - { - e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - } - }); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) - { - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - } - if(other.getScoreboard().getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) - { - if(other.getScoreboard() - .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .getPlayers().contains(player)) + if(!Plugin.GetDisguise().isDisguised(caller)) { - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .removePlayer(player); - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).getDisguisedRank().Name - + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; } - } - } catch(NullPointerException exp) - {} - } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); - if(Plugin.GetDisguise().isDisguised(player)) - continue; + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); + changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + team.removePlayer(caller); + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + if(args != null && args.length > 1) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + return; + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + for(Player other : UtilServer.getPlayers()) + { + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0], true); + + Plugin.getCosmeticManager().getGadgetManager().RemoveItem(caller); + + Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); } - } - public void changeName(final Player player, String changedName, boolean skin) - { - try + @EventHandler + public void updateDisguises(UpdateEvent event) { - GameProfile gameProfile = ((CraftPlayer) player).getProfile(); + if(event.getType() != UpdateType.FASTEST) + return; - Field name = GameProfile.class.getDeclaredField("name"); - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; - } catch(Exception ex) - { - ex.printStackTrace(); + for(Player other : UtilServer.getPlayers()) + { + try + { + if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) + { + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + } + if(other.getScoreboard().getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) + { + if(other.getScoreboard() + .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .getPlayers().contains(player)) + { + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .removePlayer(player); + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).getDisguisedRank().Name + + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); + } + } + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); + } } - } - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) + public void changeName(final Player player, String changedName, boolean skin) { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); + try + { + GameProfile gameProfile = ((CraftPlayer) player).getProfile(); - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); + Field name = GameProfile.class.getDeclaredField("name"); + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); - changeName(player, playerName, true); - } catch(Exception ex) - { - ex.printStackTrace(); - } + } catch(Exception ex) + { + ex.printStackTrace(); + } } - } - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetActivateEvent event) - { - if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler - public void onPlayerLeftClick(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(player)) - { - EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - human.world.broadcastEntityEffect(human, (byte) 0); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - Player player = event.getPlayer(); - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) + if(_disguisedPlayers.containsKey(player)) { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName, true); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler + public void onPlayerLeftClick(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(player)) + { + EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + human.world.broadcastEntityEffect(human, (byte) 0); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } } - } } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/RequiredRankCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/RequiredRankCommand.java new file mode 100644 index 000000000..fbb89b22d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/RequiredRankCommand.java @@ -0,0 +1,53 @@ +package nautilus.game.arcade.command; + +import org.bukkit.entity.Player; + +import nautilus.game.arcade.ArcadeManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class RequiredRankCommand extends CommandBase +{ + + private ArcadeManager _manager; + + public RequiredRankCommand(ArcadeManager plugin) + { + super(plugin, Rank.DEVELOPER, new Rank[]{Rank.JNR_DEV}, "Requiredrank"); + _manager = plugin; + } + + @Override + public void Execute(Player caller, String[] args) + { + if(!_manager.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing")) + { + UtilPlayer.message(caller, F.main("Command", "This is not a test server..")); + return; + } + if(args.length == 0) + { + UtilPlayer.message(caller, F.main("Command", "Invalid rank input.")); + return; + } + if(args[0].equalsIgnoreCase("Reset")) + { + _manager.setRequiredRank(null); + UtilPlayer.message(caller, F.main("Command", "You reset the required rank to null.")); + return; + } + try + { + Rank rank = Rank.valueOf(args[0]); + _manager.setRequiredRank(rank); + UtilPlayer.message(caller, F.main("Command", "You set the required rank to: " + rank.getColor() + rank.Name)); + } + catch (IllegalArgumentException e) + { + UtilPlayer.message(caller, F.main("Command", "Invalid rank input.")); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java index d6958a663..78cc48c23 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java @@ -27,7 +27,7 @@ public class SetCommand extends CommandBase if (Plugin.GetGame() == null) return; - if (args == null || args.length == 0) + if (args.length == 0) { caller.sendMessage(F.help("/game set (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN)); return; @@ -89,6 +89,11 @@ public class SetCommand extends CommandBase GameType type = matches.get(0); Plugin.GetGame().setGame(type, caller, true); + if(Plugin.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing")) + { + Plugin.GetGameList().clear(); + Plugin.GetGameList().add(type); + } } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java index 7a7a0dd43..499fe8063 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java @@ -28,7 +28,7 @@ public class StartCommand extends CommandBase } int seconds; - if(args != null && args.length > 0) + if(args.length > 0) seconds = Integer.parseInt(args[0]); else seconds = 10; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java index 386d3867d..672dc9f18 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java @@ -11,7 +11,7 @@ public class WriteCommand extends CommandBase { public WriteCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "write"); + super(plugin, Rank.OWNER, new Rank[] {}, "write"); } @Override 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 075c2afdb..31ee03060 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 @@ -5,30 +5,44 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Map.Entry; import java.util.Set; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftItem; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingPlaceEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Team; +import org.bukkit.scoreboard.TeamNameTagVisibility; import org.bukkit.util.Vector; import mineplex.core.common.util.C; @@ -40,10 +54,15 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTabTitle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -58,7 +77,11 @@ import nautilus.game.arcade.managers.GameLobbyManager; import nautilus.game.arcade.scoreboard.GameScoreboard; import nautilus.game.arcade.stats.*; import nautilus.game.arcade.world.WorldData; -import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.EntityItem; +import net.minecraft.server.v1_7_R4.PacketPlayInUseEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutScoreboardTeam; +import net.minecraft.server.v1_7_R4.ScoreboardTeam; +import net.minecraft.server.v1_7_R4.WorldServer; import net.minecraft.util.com.mojang.authlib.GameProfile; public abstract class Game implements Listener @@ -240,14 +263,21 @@ public abstract class Game implements Listener public boolean GiveClock = true; public boolean AllowParticles = true; - + + public long PrepareTime = 9000; + public boolean PlaySoundGameStart = true; + + //Gems public double GemMultiplier = 1; public boolean GemHunterEnabled = true; public boolean GemBoosterEnabled = true; public boolean GemDoubleEnabled = true; + + public double GemKillDeathRespawn = .5; + public double GemAssistDeathRespawn = .5; - public long PrepareTime = 9000; - public boolean PlaySoundGameStart = true; + public double GemKillDeathOut = 4; + public double GemAssistDeathOut = 1; //Gameplay Data public HashMap PrivateBlockMap = new HashMap(); @@ -271,6 +301,18 @@ public abstract class Game implements Listener public boolean VersionRequire1_8 = false; + public boolean DeadBodies = false; + public boolean DeadBodiesQuit = true; + public boolean DeadBodiesDeath = true; + public int DeadBodiesExpire = -1; + + private IPacketHandler _useEntityPacketHandler; + protected Field NameTagVisibility; + protected Field PacketTeam; + private int _deadBodyCount; + private NautHashMap _deadBodies = new NautHashMap(); + private NautHashMap _deadBodiesExpire = new NautHashMap(); + public ArrayList GemBoosters = new ArrayList(); private final Set> _statTrackers = new HashSet<>(); @@ -346,6 +388,41 @@ public abstract class Game implements Listener Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); + try + { + PacketTeam = Class.forName( + "org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftTeam") + .getDeclaredField("team"); + PacketTeam.setAccessible(true); + + NameTagVisibility = PacketPlayOutScoreboardTeam.class + .getDeclaredField("_nameTagVisibility"); + NameTagVisibility.setAccessible(true); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + _useEntityPacketHandler = new IPacketHandler() + { + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) + { + net.minecraft.server.v1_7_R4.Entity entity = ((PacketPlayInUseEntity) packetInfo + .getPacket()).a(((CraftWorld) packetInfo + .getPlayer().getWorld()).getHandle()); + + if (entity instanceof EntityItem) + { + packetInfo.setCancelled(true); + } + } + } + }; + System.out.println("Loading " + GetName() + "..."); } @@ -649,18 +726,27 @@ public abstract class Game implements Listener public double GetKillsGems(Player killer, Player killed, boolean assist) { - if (!DeathOut) + if (DeathOut) { - return 0.5; - } - - if (!assist) - { - return 4; + if (!assist) + { + return GemKillDeathOut; + } + else + { + return GemAssistDeathOut; + } } else { - return 1; + if (!assist) + { + return GemKillDeathRespawn; + } + else + { + return GemAssistDeathRespawn; + } } } @@ -1449,5 +1535,265 @@ public abstract class Game implements Listener //End SetState(GameState.End); } - + + @EventHandler + public void handleInteractEntityPacket(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live) + { + getArcadeManager().getPacketHandler().addPacketHandler( + _useEntityPacketHandler); + } + else if (event.GetState() == GameState.Dead) + { + getArcadeManager().getPacketHandler().removePacketHandler( + _useEntityPacketHandler); + } + } + + @EventHandler + public void onDeadBodyJoin(PlayerJoinEvent event) + { + for (int i = 0; i < _deadBodyCount; i++) + { + String name = ""; + + for (char c : ("" + i).toCharArray()) + { + name += "§" + c; + } + + try + { + Team team = Scoreboard.GetScoreboard().getTeam(name); + + if (team == null) + { + continue; + } + + PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam( + (ScoreboardTeam) PacketTeam.get(team), 2); + + UtilPlayer.sendPacket(event.getPlayer(), packet); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler + public void onDeadBodyDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + if (!(event.GetEvent().getEntity() instanceof Player)) + return; + + if (!DeadBodiesDeath) + { + return; + } + + spawnDeadBody((Player) event.GetEvent().getEntity()); + } + + @EventHandler(priority = EventPriority.LOW) + public void onDeadBodyQuit(PlayerQuitEvent event) + { + if (!IsLive()) + { + return; + } + + if (!IsAlive(event.getPlayer())) + { + return; + } + + if (!DeadBodiesQuit) + { + return; + } + + spawnDeadBody(event.getPlayer()); + } + + private void spawnDeadBody(Player player) + { + if (!DeadBodies) + { + return; + } + + String name = ""; + + for (char c : ("" + _deadBodyCount++).toCharArray()) + { + name += "§" + c; + } + + try + { + Team team = Scoreboard.GetScoreboard().registerNewTeam(name); + + team.setNameTagVisibility(TeamNameTagVisibility.NEVER); + team.addEntry(name); + + PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam( + (ScoreboardTeam) PacketTeam.get(team), 2); + + for (Player alive : GetPlayers(false)) + { + UtilPlayer.sendPacket(alive, packet); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + GameProfile newProfile = new GameProfile(UUID.randomUUID(), name); + + newProfile.getProperties() + .putAll(((CraftPlayer) player).getHandle().getProfile() + .getProperties()); + + DisguisePlayer disguise = new DisguisePlayer(null, newProfile); + + disguise.setSleeping(getSleepingFace(player.getLocation())); + + getArcadeManager().GetDisguise().addFutureDisguise(disguise); + + Location loc = player.getLocation(); + WorldServer world = ((CraftWorld) loc.getWorld()).getHandle(); + + EntityItem nmsItem = new EntityItem(world, loc.getX(), + loc.getY() + 0.5, loc.getZ(), + CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE) + .setTitle(System.currentTimeMillis() + "").build())); + + nmsItem.motX = 0; + nmsItem.motY = 0; + nmsItem.motZ = 0; + nmsItem.yaw = 0; + + world.addEntity(nmsItem); + + Item entity = new CraftItem(world.getServer(), nmsItem); + + entity.setPickupDelay(Integer.MAX_VALUE); + + _deadBodies.put(player.getName(), entity); + + if (DeadBodiesExpire > 0) + { + _deadBodiesExpire.put(player.getName(), System.currentTimeMillis() + + (DeadBodiesExpire * 1000)); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDeadBodyItemSpawn(ItemSpawnEvent event) + { + if (_deadBodies.containsValue(event.getEntity())) + { + event.setCancelled(false); + + ((CraftEntity) event.getEntity()).getHandle().dead = false; + } + } + + public NautHashMap getDeadBodies() + { + return _deadBodies; + } + + public void cleanDeadBodies() + { + for (Entity entity : _deadBodies.values()) + { + entity.remove(); + } + + _deadBodies.clear(); + _deadBodiesExpire.clear(); + _deadBodyCount = 0; + } + + private BlockFace getSleepingFace(Location loc) + { + Block block = loc.getBlock(); + + while (block.getY() > 0 + && !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)) + && !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) + { + block = block.getRelative(BlockFace.DOWN); + } + + BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3] + .getOppositeFace(); + + // A complicated way to get the face the dead body should be towards. + for (HashSet validBlocks : new HashSet[] + { + UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet + }) + { + + if (validBlocks.contains((byte) block.getRelative(proper) + .getTypeId())) + { + return proper; + } + + for (BlockFace face : new BlockFace[] + { + BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH, + BlockFace.WEST + }) + { + if (validBlocks.contains((byte) block.getRelative(face) + .getTypeId())) + { + return face; + } + } + } + + return proper; + } + + @EventHandler + public void onDeadBodiesExpire(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + Iterator> itel = _deadBodiesExpire.entrySet() + .iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (entry.getValue() < System.currentTimeMillis()) + { + if (_deadBodies.containsKey(entry.getKey())) + { + _deadBodies.remove(entry.getKey()).remove(); + } + + itel.remove(); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index a4adccbd5..cc3956390 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -73,6 +73,7 @@ public class GameTeam //Records order players go out in protected ArrayList _places = new ArrayList(); + private long _teamCreatedTime = System.currentTimeMillis(); // Used just for SpectatorPage so that teams remain ordered public GameTeam(Game host, String name, ChatColor color, ArrayList spawns, boolean tags) { @@ -90,6 +91,11 @@ public class GameTeam this(host, name, color, spawns, false); } + public long getCreatedTime() + { + return _teamCreatedTime; + } + public String GetName() { return _name; @@ -300,6 +306,11 @@ public class GameTeam _displayName = name; } + public String getDisplayName() + { + return _displayName; + } + public byte GetColorData() { if (GetColor() == ChatColor.WHITE) return (byte)0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index e17db6abc..f839c7539 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -177,6 +177,8 @@ public class Bridge extends TeamGame implements OreObsfucation ItemPickup = true; InventoryClick = true; + + AnnounceStay = false; PrivateBlocks = true; BlockBreak = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java index 05d1c8508..31e1a164a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -1,53 +1,83 @@ package nautilus.game.arcade.game.games.event; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; 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.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.give.Give; +import mineplex.core.mount.Mount; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; +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.Game; -import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.event.kits.KitPlayer; +import nautilus.game.arcade.game.games.sheep.kits.KitBrute; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.BlockFace; +import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockRedstoneEvent; +import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import com.sun.xml.internal.ws.resources.UtilMessages; public class EventGame extends Game { @@ -65,6 +95,11 @@ public class EventGame extends Game private boolean _allowAllGadgets = false; private HashSet _gadgetWhitelist = new HashSet(); + + private HashMap _functionSigns; + private ArrayList _powerdedSigns; + + private HashMap _customAreas; public EventGame(ArcadeManager manager) { @@ -105,13 +140,82 @@ public class EventGame extends Game this.InventoryClick = true; this.InventoryOpenBlock = true; this.InventoryOpenChest = true; + //Dont timeout this.GameTimeout = -1; _mps = manager.GetGameHostManager(); + _functionSigns = new HashMap<>(); + _powerdedSigns = new ArrayList<>(); this.CreatureAllow = true; + + _customAreas = new HashMap<>(); + } + + @EventHandler + public void registerSigns(GameStateChangeEvent event) + { + if(event.GetState() != GameState.Live) + return; + + for(Location loc : WorldData.GetDataLocs("RED")) + { + for(int i = -5; i < 5; i++) + { + Location temp = loc.clone().add(0, i, 0); + if(temp.getBlock().getType() == Material.SIGN_POST || temp.getBlock().getType() == Material.WALL_SIGN) + { + if(!_functionSigns.containsKey((Sign) temp.getBlock().getState())) + { + _functionSigns.put((Sign) temp.getBlock().getState(), System.currentTimeMillis()); + } + } + } + } + } + + @EventHandler + public void registerAreas(GameStateChangeEvent event) + { + if(event.GetState() != GameState.Live) + return; + + for(String name : WorldData.GetAllCustomLocs().keySet()) + { + try + { + EventArea area = new EventArea(Integer.parseInt(name.split(" ")[0])); + Location tempA = WorldData.GetAllCustomLocs().get(name).get(0); + Location tempB = WorldData.GetAllCustomLocs().get(name).get(1); + area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ())); + area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ())); + area.DamageAll = name.contains("ALL"); + area.DamagePvP = name.contains("PVP"); + area.DamagePvE = name.contains("PVE"); + area.DamageEvP = name.contains("EVP"); + area.Usable = true; + _customAreas.put(Integer.parseInt(name.split(" ")[0]), area); + } + catch (Exception e) + { + System.out.println("Error while parsing area locs"); + } + } + } + + @EventHandler + public void signPlace(SignChangeEvent event) + { + if(!IsLive()) + return; + + if(!Manager.GetGameHostManager().isAdmin(event.getPlayer(), true)) + return; + + if(event.getLine(0).startsWith("[") && event.getLine(0).endsWith("]")) + _functionSigns.put((Sign) event.getBlock().getState(), System.currentTimeMillis()); } //Before GamePlayerManager puts onto Spec! @@ -464,4 +568,733 @@ public class EventGame extends Game return losers; } + /*@EventHandler + public void signCheck(BlockRedstoneEvent event) + { + if(event.getBlock().getType() != Material.SIGN_POST && event.getBlock().getType() != Material.WALL_SIGN) + return; + + useSign(((Sign) event.getBlock().getState()).getLines()); + }*/ + + @EventHandler + public void signClock(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + for(Sign sign : _functionSigns.keySet()) + { + + Sign cooldown = null; + + for(BlockFace face : BlockFace.values()) + { + if(face == BlockFace.UP) + continue; + + if(sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getType() == Material.WALL_SIGN) + { + cooldown = (Sign) sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getState(); + break; + } + } + + if(cooldown == null) + { + if(!sign.getBlock().isBlockPowered()) + { + _powerdedSigns.remove(sign); + continue; + } + + if(_powerdedSigns.contains(sign)) + continue; + + useSign(sign, ((Sign) sign.getBlock().getState()).getLines()); + + if(sign.getBlock().isBlockPowered()) + { + if(!_powerdedSigns.contains(sign)) + { + _powerdedSigns.add(sign); + } + } + continue; + } + + if(!sign.getBlock().isBlockPowered() && !UtilTime.elapsed(_functionSigns.get(sign), Long.parseLong(cooldown.getLine(0)) * 1000)) + continue; + + if(!sign.getBlock().isBlockPowered()) + { + _powerdedSigns.remove(sign); + } + + if(_powerdedSigns.contains(sign)) + continue; + + _functionSigns.put(sign, System.currentTimeMillis()); + useSign(sign, ((Sign) sign.getBlock().getState()).getLines()); + + if(sign.getBlock().isBlockPowered()) + { + if(!_powerdedSigns.contains(sign)) + { + _powerdedSigns.add(sign); + } + } + } + } + + public void useSign(final Sign sign, String[] args) + { + String command = args[0]; + String playerName = args[1]; + + HashMap> varMap = new HashMap<>(); + + int i = 0; + for(String varArgs : args) + { + ArrayList players = new ArrayList<>(); + if(Bukkit.getPlayer(varArgs) != null) + players.add(Bukkit.getPlayer(varArgs)); + + if(varArgs.contentEquals("@p")) + { + for(Player player : GetPlayers(true)) + { + boolean found; + found = true; + for(Player otherPlayer : GetPlayers(true)) + { + if(player == otherPlayer) + continue; + + if(UtilMath.offset(sign.getLocation(), player.getLocation()) >= UtilMath.offset(sign.getLocation(), otherPlayer.getLocation())) + { + found = false; + break; + } + } + if(found) + { + players.add(player); + break; + } + } + } + if(playerName.contains("@a")) + { + int radius = 0; + if(playerName.contains("r=")) + { + try + { + radius = Integer.parseInt(playerName.split("=")[1]); + } + catch (Exception e) {} + } + for(Player player : GetPlayers(true)) + { + if(UtilMath.offset(sign.getLocation(), player.getLocation()) <= radius || radius <= 0) + players.add(player); + } + } + + varMap.put(i, players); + i++; + } + + if(command.contentEquals("[BC]")) + { + String message = args[1]; + for(int e = 2; e <= 3; e++) + message += " " + args[e]; + + String colored = ChatColor.translateAlternateColorCodes('&', message); + this.Announce(F.main("Event", colored), true); + } + + if(command.contentEquals("[TELEPORT]")) + { + for(Player player : varMap.get(1)) + { + if(Bukkit.getPlayer(args[2]) != null) + { + player.teleport(Bukkit.getPlayer(args[2])); + } + else + { + String[] coords = args[2].split(" "); + int x = Integer.parseInt(coords[0]); + int y = Integer.parseInt(coords[1]); + int z = Integer.parseInt(coords[2]); + player.teleport(new Location(sign.getWorld(), x, y, z)); + } + } + } + + if(command.contentEquals("[MESSAGE]")) + { + String message = args[2]; + message += " " + args[3]; + + String colored = ChatColor.translateAlternateColorCodes('&', message); + + for(Player player : varMap.get(1)) + { + UtilPlayer.message(player, F.main("Event", colored)); + } + } + + if(command.contentEquals("[SETBLOCK]")) + { + Material mat = Material.getMaterial(Integer.parseInt(args[1])); + String[] coords = args[2].split(" "); + int x = Integer.parseInt(coords[0]); + int y = Integer.parseInt(coords[1]); + int z = Integer.parseInt(coords[2]); + sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).setType(mat); + } + + if(command.contentEquals("[TESTFOR]")) + { + boolean redstone = false; + Material mat = Material.getMaterial(Integer.parseInt(args[1])); + if(args[2].contains("r=")) + { + int radius = 0; + try + { + radius = Integer.parseInt(args[2].split("=")[1]); + if(radius >= 30) + radius = 30; + + for(int x = -radius + sign.getLocation().getBlockX(); x < radius + sign.getLocation().getBlockX(); x++) + { + for(int y = -radius + sign.getLocation().getBlockY(); y < radius + sign.getLocation().getBlockY(); y++) + { + for(int z = -radius + sign.getLocation().getBlockZ(); z < radius + sign.getLocation().getBlockZ(); z++) + { + if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat) + { + redstone = true; + } + } + } + } + } + catch (Exception e) {} + } + else + { + String[] coords = args[2].split(" "); + int x = Integer.parseInt(coords[0]); + int y = Integer.parseInt(coords[1]); + int z = Integer.parseInt(coords[2]); + if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat) + { + redstone = true; + } + } + if(redstone) + { + for(final BlockFace face : BlockFace.values()) + { + if(face != BlockFace.UP + && face != BlockFace.NORTH_WEST + && face != BlockFace.NORTH_EAST + && face != BlockFace.SOUTH_EAST + && face != BlockFace.SOUTH_WEST) + { + continue; + } + + if(sign.getBlock().getRelative(face).getType() != Material.AIR) + continue; + + if(sign.getBlock().getRelative(face).isBlockPowered()) + continue; + + sign.getBlock().getRelative(face).setType(Material.REDSTONE_BLOCK); + + Manager.runSyncLater(new Runnable() + { + + @Override + public void run() + { + sign.getBlock().getRelative(face).setType(Material.AIR); + } + + }, 3L); + } + } + } + + if(varMap.get(1).isEmpty()) + return; + + String[] vars = new String[args.length - 1]; + vars[0] = args[0]; + vars[1] = args[2]; + vars[2] = args[3]; + + String tempArgs = ""; + for(String str : vars) + { + for(String string : str.split(" ")) + { + tempArgs += string + " "; + } + } + String[] commandArgs = tempArgs.split(" "); + + if(command.contentEquals("[MOB]")) + { + for(Player player : varMap.get(1)) + Manager.GetEventModule().commandMob(player, commandArgs); + } + if(command.contentEquals("[SCORE]")) + { + for(Player player : varMap.get(1)) + Manager.GetEventModule().commandScoreboard(player, vars); + } + if(command.contentEquals("[GIVE]")) + { + try + { + for(Player player : varMap.get(1)) + { + player.getInventory().addItem(new ItemStack(Material.getMaterial(Integer.parseInt(args[2])), Integer.parseInt(args[3]))); + } + + } catch (Exception e) + { + + } + } + if(command.contentEquals("[DOUBLEJUMP]")) + { + for(Player player : varMap.get(1)) + Manager.GetEventModule().commandDoubleJump(player, vars); + } + if(command.contentEquals("[EFFECT]")) + { + //Manager.GetEventModule().commandEffect(Manager.GetGameHostManager().getHost(), commandArgs, varMap.get(1)); + for(Player player : varMap.get(1)) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(args[2]), Integer.parseInt(args[3].split(" ")[0]), Integer.parseInt(args[3].split(" ")[1]))); + } + + } + if(command.contentEquals("[KIT]")) + { + for(Player player : varMap.get(1)) + Manager.GetEventModule().commandKit(player, commandArgs); + } + } + + @EventHandler + public void signBreak(BlockBreakEvent event) + { + if(event.getBlock().getType() == Material.SIGN_POST || event.getBlock().getType() == Material.WALL_SIGN || event.getBlock().getType() == Material.SIGN) + { + Iterator signIter = _functionSigns.keySet().iterator(); + while(signIter.hasNext()) + { + Sign sign = signIter.next(); + if(sign.getLocation().getBlockX() == event.getBlock().getLocation().getBlockX() + && sign.getLocation().getBlockY() == event.getBlock().getLocation().getBlockY() + && sign.getLocation().getBlockZ() == event.getBlock().getLocation().getBlockZ()) + { + signIter.remove(); + } + } + } + } + + public boolean isInArea(EventArea area, Entity entity) + { + if(entity.getLocation().getX() < area.CornerA.getX() || entity.getLocation().getX() > area.CornerB.getX()) + return false; + + if(entity.getLocation().getY() < area.CornerA.getY() || entity.getLocation().getY() > area.CornerB.getY()) + return false; + + if(entity.getLocation().getZ() < area.CornerA.getZ() || entity.getLocation().getZ() > area.CornerB.getZ()) + return false; + + return true; + } + + @EventHandler + public void activateGadget(GadgetActivateEvent event) + { + for(EventArea area : _customAreas.values()) + { + if(area.CornerA == null || area.CornerB == null) + continue; + + if(area.Usable == false) + continue; + + if(!isInArea(area, event.getPlayer())) + continue; + + if(!area.GadgetsEnabled.contains(event.getGadget())) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void areaPotionEffect(UpdateEvent event) + { + if(event.getType() != UpdateType.SEC) + return; + + for(EventArea area : _customAreas.values()) + { + for(Player player : GetPlayers(true)) + { + if(area.CornerA == null || area.CornerB == null) + continue; + + if(area.Usable == false) + continue; + + if(!isInArea(area, player)) + continue; + + for(PotionEffectType type : area.PotionEffects.keySet()) + { + player.addPotionEffect(new PotionEffect(type, 60, area.PotionEffects.get(type)), true); + } + } + } + } + + @EventHandler(ignoreCancelled=true) + public void areaDamage(CustomDamageEvent event) + { + for(EventArea area : _customAreas.values()) + { + if(area.CornerA == null || area.CornerB == null) + continue; + + if(area.Usable == false) + continue; + + if(Manager.GetEventModule().getDamagePlayers().contains(event.GetDamagerPlayer(true))) + { + if(!Manager.GetGame().DamagePvP) + { + Manager.GetGame().Damage = true; + Manager.GetGame().DamagePvP = true; + Bukkit.getPluginManager().callEvent(event); + Manager.GetGame().DamagePvP = false; + Manager.GetGame().Damage = false; + } + return; + } + + if(!isInArea(area, event.GetDamageeEntity())) + continue; + + if(!area.DamageAll) + { + event.SetCancelled("Event Area"); + continue; + } + if(event.GetCause() == DamageCause.ENTITY_ATTACK && event.GetDamagerPlayer(true) == null) + { + if(!area.DamageEvP) + { + event.SetCancelled("Event Area"); + continue; + } + } + if(!(event.GetDamageeEntity() instanceof Player)) + { + if(!area.DamagePvE) + { + event.SetCancelled("Event Area"); + continue; + } + } + if((event.GetDamageeEntity() instanceof Player) && (event.GetDamagerEntity(true) instanceof Player)) + { + if(!area.DamagePvP) + { + event.SetCancelled("Event Area"); + continue; + } + } + if(!Manager.GetGame().DamagePvP) + { + Manager.GetGame().Damage = true; + Manager.GetGame().DamagePvP = true; + Bukkit.getPluginManager().callEvent(event); + Manager.GetGame().DamagePvP = false; + Manager.GetGame().Damage = false; + } + } + } + + public void listAreaSettings(Player player) + { + for(EventArea area : _customAreas.values()) + { + UtilPlayer.message(player, F.main("Event", "============================")); + UtilPlayer.message(player, F.main("Event", "Settings for area " + area.ID)); + UtilPlayer.message(player, F.oo("Damage All", area.DamageAll) + ", " + + F.oo("Damage PvP", area.DamagePvP) + ", " + + F.oo("Damage PvE", area.DamagePvE) + + ", " + F.oo("Damage EvP", area.DamageEvP)); + + UtilPlayer.message(player, F.main("Event", "Potion Effects for area " + area.ID)); + for(PotionEffectType type : area.PotionEffects.keySet()) + UtilPlayer.message(player, F.oo(type.getName(), true) + " level: " + area.PotionEffects.get(type)); + + UtilPlayer.message(player, F.main("Event", "Gadgets for area " + area.ID)); + for(SalesPackageBase gadget : area.GadgetsEnabled) + UtilPlayer.message(player, F.oo(gadget.GetName(), true)); + } + } + + public void editArea(Player player, String[] args) + { + + if(args[1].equalsIgnoreCase("Info")) + { + listAreaSettings(player); + return; + } + try + { + if(_customAreas.containsKey(Integer.parseInt(args[1]))) + { + if(args[2].equalsIgnoreCase("Del")) + { + _customAreas.remove(Integer.parseInt(args[1])); + UtilPlayer.message(player, F.main("Event", "Region deleted")); + } + if(args[2].equalsIgnoreCase("ALL")) + { + _customAreas.get(Integer.parseInt(args[1])).DamageAll = !_customAreas.get(Integer.parseInt(args[1])).DamageAll; + UtilPlayer.message(player, F.main("Event", "Damage all for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageAll))); + } + if(args[2].equalsIgnoreCase("PVP")) + { + _customAreas.get(Integer.parseInt(args[1])).DamagePvP = !_customAreas.get(Integer.parseInt(args[1])).DamagePvP; + UtilPlayer.message(player, F.main("Event", "Damage PvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvP))); + } + if(args[2].equalsIgnoreCase("PVE")) + { + _customAreas.get(Integer.parseInt(args[1])).DamagePvE = !_customAreas.get(Integer.parseInt(args[1])).DamagePvE; + UtilPlayer.message(player, F.main("Event", "Damage PvE for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvE))); + } + if(args[2].equalsIgnoreCase("EVP")) + { + _customAreas.get(Integer.parseInt(args[1])).DamageEvP = !_customAreas.get(Integer.parseInt(args[1])).DamageEvP; + UtilPlayer.message(player, F.main("Event", "Damage EvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageEvP))); + } + if(args[2].equalsIgnoreCase("Effect")) + { + PotionEffectType type = PotionEffectType.getByName(args[3]); + if(_customAreas.get(Integer.parseInt(args[1])).PotionEffects.containsKey(type)) + { + _customAreas.get(Integer.parseInt(args[1])).PotionEffects.remove(type); + UtilPlayer.message(player, F.main("Event", "Removed potion effect from area")); + return; + } + if (type == null) + { + UtilPlayer.message(player, F.main("Effect", "Invalid Effect Type: " + args[2])); + UtilPlayer.message(player, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect")); + return; + } + int strenght = 0; + try + { + strenght = Integer.parseInt(args[4]); + } + catch (Exception e) {} + _customAreas.get(Integer.parseInt(args[1])).PotionEffects.put(type, strenght); + UtilPlayer.message(player, F.main("Event", "Potion Effect added for Region " + args[1])); + } + if(args[2].equalsIgnoreCase("Gadget")) + { + //Gadgets + for (GadgetType type : GadgetType.values()) + { + for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type)) + { + if (gadget.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3])) + { + if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(gadget)) + { + Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(false)))); + } + else + { + Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(true)))); + _customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(gadget); + } + + return; + } + } + } + + //Mounts + for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) + { + if (mount.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3])) + { + if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(mount)) + { + Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(false)))); + } + else + { + Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(true)))); + _customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(mount); + } + + return; + } + } + } + } + else + { + UtilPlayer.message(player, F.main("Event", "No Area Found")); + } + if(args[2].equalsIgnoreCase("Add")) + { + if(!_customAreas.containsKey(Integer.parseInt(args[1]))) + _customAreas.put(Integer.parseInt(args[1]), new EventArea(Integer.parseInt(args[1]))); + + EventArea area = _customAreas.get(Integer.parseInt(args[1])); + + if(args[3].equalsIgnoreCase("A")) + { + area.CornerA = player.getLocation(); + UtilPlayer.message(player, F.main("Event", "Corner A set!")); + } + if(args[3].equalsIgnoreCase("B")) + { + area.CornerB = player.getLocation(); + UtilPlayer.message(player, F.main("Event", "Corner B set!")); + } + if(area.CornerA != null && area.CornerB != null) + { + Location tempA = area.CornerA.clone(); + Location tempB = area.CornerB.clone(); + area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ())); + area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ())); + area.Usable = true; + UtilPlayer.message(player, F.main("Event", "Region is Usable")); + } + } + } + catch (Exception e) + { + UtilPlayer.message(player, F.main("Event", "Error while executing command")); + } + } + + @EventHandler + public void preventChestDrop(PlayerDropItemEvent event) + { + if(event.getItemDrop() == null) + return; + + if(event.getItemDrop().getItemStack().getType() != Material.CHEST) + return; + + if(!event.getItemDrop().getItemStack().hasItemMeta()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void gemSign(final PlayerInteractEvent event) + { + if(event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if(event.getClickedBlock().getType() != Material.SIGN && event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST) + return; + + Sign sign = (Sign) event.getClickedBlock().getState(); + if(!sign.getLine(0).contentEquals("(GEM)")) + return; + + final Material mat = Material.getMaterial(Integer.parseInt(sign.getLine(1))); + Integer price = Integer.parseInt(sign.getLine(2)); + if(price > 500) + price = 500; + + if(price <= 0) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You got an item for free.")); + event.getPlayer().getInventory().addItem(new ItemStack(mat)); + return; + } + + if(Manager.GetDonation().Get(event.getPlayer()).GetGems() < price) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You dont have enough Gems.")); + return; + } + + final int gems = price; + Manager.GetDonation().RewardGems(new Callback() + { + public void run(Boolean completed) + { + if (completed) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You bought an item for " + gems + " Gems.")); + event.getPlayer().getInventory().addItem(new ItemStack(mat)); + } + } + }, "Gem Sign", event.getPlayer().getName(), event.getPlayer().getUniqueId(), -price); + } + + public class EventArea + { + + public int ID; + + public Location CornerA; + public Location CornerB; + + public boolean DamageAll; + public boolean DamagePvP; + public boolean DamagePvE; + public boolean DamageEvP; + + public boolean Usable; + + public HashMap PotionEffects; + public HashSet GadgetsEnabled; + + public EventArea(Integer id) + { + ID = id; + Usable = false; + PotionEffects = new HashMap<>(); + GadgetsEnabled = new HashSet(); + } + + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 6b77dd967..9dc6de524 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -12,23 +12,33 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilSystem; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.creature.event.CreatureKillEntitiesEvent; +import mineplex.core.event.StackerEvent; +import mineplex.core.gadget.gadgets.MorphBlock; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.give.Give; import mineplex.core.mount.Mount; 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.events.PlayerDeathOutEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Effect; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; import org.bukkit.entity.Ageable; @@ -36,16 +46,19 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.Slime; import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; import org.bukkit.entity.Wolf; import org.bukkit.entity.Zombie; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; @@ -54,17 +67,26 @@ import org.bukkit.potion.PotionEffectType; public class EventModule extends MiniPlugin { - public ArcadeManager Manager; + private ArcadeManager Manager; private NautHashMap _potionEffectsDuration = new NautHashMap<>(); private NautHashMap _potionEffectsMult = new NautHashMap<>(); - private boolean _mobGriefing = true; + private boolean _mobGriefing; + + private HashSet _tempStackShift = new HashSet(); + + private ArrayList _stacker; + private ArrayList _damage; + private boolean _allowStacker; public EventModule(ArcadeManager manager, JavaPlugin plugin) { super("EventModule", plugin); Manager = manager; + _mobGriefing = true; + _stacker = new ArrayList<>(); + _damage = new ArrayList<>(); } @EventHandler @@ -81,10 +103,22 @@ public class EventModule extends MiniPlugin { if (!event.getMessage().toLowerCase().startsWith("/sethost ")) return; - - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true)) - return; + boolean allowed = Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.JNR_DEV, true); + + + if (!allowed) + { + allowed = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1") && + Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.SNR_MODERATOR, true); + } + + if (!allowed) + { + return; + } + + Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1]; event.getPlayer().sendMessage("Set host to: " + event.getMessage().split(" ")[1]); @@ -98,7 +132,7 @@ public class EventModule extends MiniPlugin event.setCancelled(true); } - private void commandHelp(Player player) + public void commandHelp(Player player) { UtilPlayer.message(player, F.main("Event", "Displaying Commands;")); @@ -125,6 +159,12 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e give [e:#,e:#...]", "Give Item")); UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump")); + UtilPlayer.message(player, F.value("/e bc", "Broadcast a message with colorcodes")); + UtilPlayer.message(player, F.value("/e tempgadget", "Activates gadget for all player")); + UtilPlayer.message(player, F.value("/e playerdamage", "Toggles damage fpr player")); + UtilPlayer.message(player, F.value("/e stacker [Player]", "toggles stacker global or for Players")); + UtilPlayer.message(player, F.value("/e kick", "Remove a player from the event")); + UtilPlayer.message(player, F.value("/e area PVP|ALL|PVE|EVP|Gadget|Effect / add", "Create and edit areas")); UtilPlayer.message(player, F.value("/e scoreboard [Text]", "Sets Scoreboard Text")); @@ -139,7 +179,7 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e effect clear", "")); } - private void commandHelpSettings(Player player) + public void commandHelpSettings(Player player) { UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;")); UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage")); @@ -169,7 +209,7 @@ public class EventModule extends MiniPlugin //Command Handler @EventHandler(priority = EventPriority.LOWEST) - private void commandHandler(PlayerCommandPreprocessEvent event) + public void commandHandler(PlayerCommandPreprocessEvent event) { if (!Manager.GetGame().InProgress()) return; @@ -177,7 +217,9 @@ public class EventModule extends MiniPlugin if (!event.getMessage().toLowerCase().startsWith("/e ")) return; - if(!Manager.GetGameHostManager().isEventServer()) + boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); + + if(!Manager.GetGameHostManager().isEventServer() && !eventTestServer) return; event.setCancelled(true); @@ -243,7 +285,7 @@ public class EventModule extends MiniPlugin } else if (args[0].equalsIgnoreCase("effect")) { - commandEffect(event.getPlayer(), args); + commandEffect(event.getPlayer(), args, null); } else if (args[0].equalsIgnoreCase("kit")) { @@ -342,17 +384,77 @@ public class EventModule extends MiniPlugin { commandBlockPlaceInCreative(event.getPlayer(), args); } - else if(args[0].equalsIgnoreCase("blockbreakcreative")) + else if(args[0].equalsIgnoreCase("stacker")) { - commandBlockBreakInCreative(event.getPlayer(), args); + commandStacker(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("playerdamage")) + { + if(args[1] == null) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "Insufficient arguments!")); + return; + } + + if(Bukkit.getPlayer(args[1]) == null) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "This Player is not online!")); + return; + } + + if(_damage.contains(Bukkit.getPlayer(args[1]))) + _damage.remove(Bukkit.getPlayer(args[1])); + else + _damage.add(Bukkit.getPlayer(args[1])); + } + else if(args[0].equalsIgnoreCase("bc")) + { + commandBC(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("area")) + { + if(!(Manager.GetGame() instanceof EventGame)) { + UtilPlayer.message(event.getPlayer(), F.main("Settings", "You can only edit areas in the Event game!")); + return; + } + + ((EventGame) Manager.GetGame()).editArea(event.getPlayer(), args); } else if(args[0].equalsIgnoreCase("mobgriefing")) { commandMobGriefing(event.getPlayer(), args); } + else if(args[0].equalsIgnoreCase("kick")) + { + if(Bukkit.getPlayer(args[1]) == null) + { + UtilPlayer.message(event.getPlayer(), "No matches for: " + C.cYellow + args[1]); + return; + } + //Bukkit.getPlayer(args[1]).kickPlayer("You where kicked from the event, probably you didn't stick to the Event Rules."); + Manager.GetGameHostManager().getBlacklist().add(Bukkit.getPlayer(args[1]).getName()); + UtilPlayer.message(event.getPlayer(), F.main("Event", "You removed " + C.cYellow + Bukkit.getPlayer(args[1]).getName())); + } + else if(args[0].equalsIgnoreCase("tempgadget")) + { + String gadget = args[1]; + for(int e = 2; e < args.length; e++) + gadget+= " " + args[e]; + + try + { + for(Player target : UtilServer.getPlayers()) + Manager.GetDonation().Get(target).AddUnknownSalesPackagesOwned(gadget); + } + catch (Exception e) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "Gadget is not vallid")); + } + UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!")); + } } - private void listSettings(Player player) + public void listSettings(Player player) { UtilPlayer.message(player, F.value("Damage All", F.tf(Manager.GetGame().Damage))); UtilPlayer.message(player, F.value("Damage PvP", F.tf(Manager.GetGame().DamagePvP))); @@ -375,28 +477,55 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("Mob griefing", F.tf(_mobGriefing))); } - private void commandBlockBreakInCreative(Player player, String[] args) + public void commandBlockBreakInCreative(Player player, String[] args) { Manager.GetGame().BlockBreakCreative = !Manager.GetGame().BlockBreakCreative; UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative))); } - private void commandBlockPlaceInCreative(Player player, String[] args) + public void commandStacker(Player player, String[] args) + { + if(args.length == 1) + { + _allowStacker = !_allowStacker; + UtilPlayer.message(player, F.main("Settings", "Stacker all: " + F.tf(_allowStacker))); + } + else + { + for(Player target : UtilPlayer.matchOnline(player, args[1], true)) + { + if(_stacker.contains(target)) + { + _stacker.remove(target); + UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(false))); + UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(false))); + } + else + { + _stacker.add(target); + UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(true))); + UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(true))); + } + } + } + } + + public void commandBlockPlaceInCreative(Player player, String[] args) { Manager.GetGame().BlockPlaceCreative = !Manager.GetGame().BlockPlaceCreative; UtilPlayer.message(player, F.main("Settings", "BlockPlaceCreative: " + F.tf(Manager.GetGame().BlockPlaceCreative))); } - private void commandMobGriefing(Player player, String[] args) + public void commandMobGriefing(Player player, String[] args) { _mobGriefing = !_mobGriefing; UtilPlayer.message(player, F.main("Settings", "Mob Griefing: " + F.tf(_mobGriefing))); } - private void commandBlockPlace(Player player, String[] args, boolean whitelist, String command) + public void commandBlockPlace(Player player, String[] args, boolean whitelist, String command) { try { @@ -457,7 +586,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandBlockBreak(Player player, String[] args, boolean whitelist, String command) + public void commandBlockBreak(Player player, String[] args, boolean whitelist, String command) { try { @@ -518,7 +647,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandHealth(Player player, String[] args) + public void commandHealth(Player player, String[] args) { try { @@ -549,7 +678,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandHunger(Player player, String[] args) + public void commandHunger(Player player, String[] args) { try { @@ -580,7 +709,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandTime(Player player, String[] args) + public void commandTime(Player player, String[] args) { try { @@ -612,7 +741,7 @@ public class EventModule extends MiniPlugin } //Teleport Command (To, Here, All) - private void commandTeleport(Player player, String[] args) + public void commandTeleport(Player player, String[] args) { if (args.length >= 3 && args[1].equalsIgnoreCase("here")) { @@ -654,7 +783,7 @@ public class EventModule extends MiniPlugin } //Gadget Commands (Global & Individual) - private void commandGadget(Player player, String[] args) + public void commandGadget(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!")); @@ -766,7 +895,7 @@ public class EventModule extends MiniPlugin } //Silence - private void commandSilence(Player player, String[] args) + public void commandSilence(Player player, String[] args) { try { @@ -799,7 +928,7 @@ public class EventModule extends MiniPlugin } //Gamemode (Self and Others) - private void commandAdmin(Player player, String[] args) + public void commandAdmin(Player player, String[] args) { Player target = player; @@ -821,7 +950,7 @@ public class EventModule extends MiniPlugin } //Gamemode (Self and Others) - private void commandGamemode(Player player, String[] args) + public void commandGamemode(Player player, String[] args) { Player target = player; @@ -843,7 +972,7 @@ public class EventModule extends MiniPlugin } //Forcefield - private void commandForcefieldRadius(Player player, String[] args) + public void commandForcefieldRadius(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -875,7 +1004,7 @@ public class EventModule extends MiniPlugin } //Give - private void commandGive(Player player, String[] args) + public void commandGive(Player player, String[] args) { String[] newArgs = new String[args.length-1]; @@ -886,7 +1015,7 @@ public class EventModule extends MiniPlugin } //Spec - private void commandSpectators(Player player, String[] args) + public void commandSpectators(Player player, String[] args) { Manager.GetGame().JoinInProgress = !Manager.GetGame().JoinInProgress; @@ -894,7 +1023,7 @@ public class EventModule extends MiniPlugin } //Deathout - private void commandDeathout(Player player, String[] args) + public void commandDeathout(Player player, String[] args) { Manager.GetGame().DeathOut = !Manager.GetGame().DeathOut; @@ -902,7 +1031,7 @@ public class EventModule extends MiniPlugin } //QuitOut - private void commandQuitOut(Player player, String[] args) + public void commandQuitOut(Player player, String[] args) { Manager.GetGame().QuitOut = !Manager.GetGame().QuitOut; @@ -910,7 +1039,7 @@ public class EventModule extends MiniPlugin } //Double Jump - private void commandDoubleJump(Player player, String[] args) + public void commandDoubleJump(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -928,7 +1057,7 @@ public class EventModule extends MiniPlugin } //Scoreboard - private void commandScoreboard(Player player, String[] args) + public void commandScoreboard(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -973,7 +1102,7 @@ public class EventModule extends MiniPlugin lineText += " "; } - ((EventGame) Manager.GetGame()).getSideText()[line] = lineText; + ((EventGame) Manager.GetGame()).getSideText()[line] = ChatColor.translateAlternateColorCodes('&', lineText); UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + ".")); @@ -1002,7 +1131,7 @@ public class EventModule extends MiniPlugin } //Whitelist - private void commandWhitelist(Player player, String[] args) + public void commandWhitelist(Player player, String[] args) { //On and Off if (args.length >= 2) @@ -1042,7 +1171,7 @@ public class EventModule extends MiniPlugin } //Mob - private void commandMob(Player caller, String[] args) + public void commandMob(Player caller, String[] args) { if (args.length == 1) { @@ -1430,7 +1559,7 @@ public class EventModule extends MiniPlugin } } - private void commandMobKill(Player caller, String[] args) + public void commandMobKill(Player caller, String[] args) { if (args.length < 3) { @@ -1476,7 +1605,17 @@ public class EventModule extends MiniPlugin UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed.")); } - private void commandKit(Player caller, String[] args) + public void commandBC(Player caller, String[] args) + { + String message = args[1]; + for(int e = 2; e < args.length; e++) + message += " " + args[e]; + + String colored = ChatColor.translateAlternateColorCodes('&', message); + Manager.GetGame().Announce(F.main("Event", colored), true); + } + + public void commandKit(Player caller, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -1519,7 +1658,7 @@ public class EventModule extends MiniPlugin commandHelp(caller); } - private void commandEffect(Player caller, String[] args) + public void commandEffect(Player caller, String[] args, ArrayList players) { //Clear if (args.length >= 3 && args[2].equalsIgnoreCase("clear")) @@ -1537,9 +1676,19 @@ public class EventModule extends MiniPlugin } else { - targets = UtilPlayer.matchOnline(caller, args[1], true); - if (targets.isEmpty()) - return; + if(players == null) + { + targets = UtilPlayer.matchOnline(caller, args[1], true); + if (targets.isEmpty()) + return; + } + else + { + targets = new LinkedList<>(); + for(Player player : players) + targets.add(player); + + } } for (Player player : targets) @@ -1633,10 +1782,20 @@ public class EventModule extends MiniPlugin _potionEffectsMult.put(type, mult); } else - { - targets = UtilPlayer.matchOnline(caller, args[1], true); - if (targets.isEmpty()) - return; + { + if(players == null) + { + targets = UtilPlayer.matchOnline(caller, args[1], true); + if (targets.isEmpty()) + return; + } + else + { + targets = new LinkedList<>(); + for(Player player : players) + targets.add(player); + + } } //Apply @@ -1667,9 +1826,110 @@ public class EventModule extends MiniPlugin { for(PotionEffectType effect : _potionEffectsDuration.keySet()) { + if(_potionEffectsDuration.get(effect) < 0) + continue; + player.addPotionEffect(new PotionEffect(effect, (int) (((_potionEffectsDuration.get(effect) - System.currentTimeMillis()) / 1000) * 20), _potionEffectsMult.get(effect))); } } } + @EventHandler + public void StackEntity(PlayerInteractEntityEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (event.getRightClicked().getVehicle() != null) + return; + + Player player = event.getPlayer(); + Entity other = event.getRightClicked(); + + if(!_allowStacker && !_stacker.contains(player)) + return; + + if (Manager.isSpectator(event.getPlayer())) + return; + + if (!Manager.GetGame().IsAlive(event.getPlayer())) + return; + + if (Manager.getCosmeticManager().getGadgetManager().getActive(player, GadgetType.Morph) instanceof MorphBlock) + { + UtilPlayer.message(player, F.main("Stacker", "You cannot stack while using the Block Morph.")); + return; + } + + StackerEvent stackerEvent = new StackerEvent(player); + Bukkit.getServer().getPluginManager().callEvent(stackerEvent); + if (stackerEvent.isCancelled()) + return; + + //Effect + event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35); + + //Stack + player.setPassenger(other); + + //Audio + player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); + + //Inform + if ((event.getRightClicked() instanceof Player)) + { + UtilPlayer.message(other, F.main("Event", F.elem(Manager.GetGame().GetTeam(player).GetColor() + player.getName()) + " picked you up.")); + UtilPlayer.message(player, F.main("Event", "You picked up " + F.elem(Manager.GetGame().GetTeam(((Player) other)).GetColor() + ((Player) other).getName()) + ".")); + } + } + + @EventHandler + public void ThrowEntity(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.L)) + return; + + Player thrower = event.getPlayer(); + + if (thrower.getVehicle() != null) + return; + + Entity throwee = thrower.getPassenger(); + if (throwee == null) + return; + + StackerEvent stackerEvent = new StackerEvent(thrower); + Bukkit.getServer().getPluginManager().callEvent(stackerEvent); + if (stackerEvent.isCancelled()) + return; + + thrower.eject(); + + Entity throweeStack = throwee.getPassenger(); + if (throweeStack != null) + { + throwee.eject(); + throweeStack.leaveVehicle(); + + final Entity fThrower = thrower; + final Entity fThroweeStack = throweeStack; + + _tempStackShift.add(throweeStack); + + getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + { + public void run() + { + fThrower.setPassenger(fThroweeStack); + _tempStackShift.remove(fThroweeStack); + } + }, 2); + } + } + + public ArrayList getDamagePlayers() + { + return _damage; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoKit.java new file mode 100644 index 000000000..e6fabd35e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoKit.java @@ -0,0 +1,193 @@ +package nautilus.game.arcade.game.games.evolution; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilSkull; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public abstract class EvoKit extends Kit +{ + /** + * @author Mysticate + */ + + private EntityType _entity; + + protected final double _health; + protected final double _damage; + + public EvoKit(ArcadeManager manager, String name, String[] desc, double health, double damage, Perk[] kitPerks, EntityType type) + { + this(manager, name, desc, health, damage, kitPerks, type, false); + } + + public EvoKit(ArcadeManager manager, String name, String[] desc, double health, double damage, Perk[] kitPerks, EntityType type, boolean visible) + { + super(manager, name, visible ? KitAvailability.Free : KitAvailability.Hide, 0, desc, kitPerks, type, null); + + _entity = type; + + _health = health; + _damage = damage; + } + + public EntityType getEntity() + { + return _entity; + } + + public double getHealth() + { + return _health; + } + + public double getDamage() + { + return _damage; + } + + public String[] buildHologram() + { + ArrayList text = new ArrayList(); + + text.add(C.cAqua + C.Bold + GetName()); + text.add(C.cYellow + "Melee: " + C.cWhite + _damage + " " + C.cYellow + "Health: " + C.cWhite + _health); + + if (GetDesc().length > 0) + { + text.add(C.Line); + + for (String desc : GetDesc()) + text.add(desc); + } + + return text.toArray(new String[0]); + } + + @Override + public void DisplayDesc(Player player) + { + for (int i=0 ; i<3 ; i++) + UtilPlayer.message(player, ""); + + UtilPlayer.message(player, ArcadeFormat.Line); + + UtilPlayer.message(player, "§aKit - §f§l" + GetName()); + + UtilPlayer.message(player, C.Line); + + UtilPlayer.message(player, C.cYellow + " Melee: " + C.cWhite + _damage + " " + C.cYellow + "Health: " + C.cWhite + _health); + + UtilPlayer.message(player, C.Line); + + for (String desc : GetDesc()) + UtilPlayer.message(player, C.cGray + " " + desc); + + UtilPlayer.message(player, ArcadeFormat.Line); + + } + + public void upgradeGive(Player player) + { + String def = C.cWhite + C.Bold + "You evolved into " + ("aeiou".indexOf(GetName().toLowerCase().substring(0, 1)) == -1 ? "a " : "an ") + F.elem(C.cGreen + C.Bold + GetName()); + + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1.0F, 0.1F); + + for (int i=0 ; i<3 ; i++) + UtilPlayer.message(player, ""); + + UtilPlayer.message(player, ArcadeFormat.Line); + UtilPlayer.message(player, def); + + UtilPlayer.message(player, C.Line); + + UtilPlayer.message(player, C.cYellow + " Melee: " + C.cWhite + _damage + " " + C.cYellow + "Health: " + C.cWhite + _health); + + UtilPlayer.message(player, C.Line); + + for (String desc : GetDesc()) + UtilPlayer.message(player, C.cGray + " " + desc); + + UtilPlayer.message(player, ArcadeFormat.Line); + +// UtilTextMiddle.display(null, def, player); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onDamage(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + return; + + Player damager = event.GetDamagerPlayer(false); + if (damager == null) return; + + if (!HasKit(damager)) + return; + + if (!Manager.IsAlive(damager)) + return; + + double mod = _damage - event.GetDamageInitial(); + + event.AddMod(damager.getName(), "Attack", mod, true); + } + + @SuppressWarnings("deprecation") + @Override + public final void GiveItems(final Player player) + { + player.setMaxHealth(_health); + player.setHealth(player.getMaxHealth()); + player.getInventory().setHeldItemSlot(0); + + player.setLevel(0); + player.setExp(0F); + + if (UtilSkull.isPlayerHead(UtilSkull.getSkullData(getEntity()))) + { + + final ItemStack skull = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM.getId(), (byte) 3, 1, C.cGreen + C.Bold + GetName()); + SkullMeta meta = (SkullMeta) skull.getItemMeta(); + meta.setOwner(UtilSkull.getPlayerHeadName(getEntity())); + skull.setItemMeta(meta); + + Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + player.getInventory().setItem(8, skull); + } + }, 4); + } + else + { + player.getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM.getId(), (byte) UtilSkull.getSkullData(getEntity()), 1, C.cGreen + C.Bold + GetName())); + } + + giveItems(player); + } + + protected abstract void giveItems(Player player); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoScore.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoScore.java deleted file mode 100644 index dd4fb9d0e..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoScore.java +++ /dev/null @@ -1,15 +0,0 @@ -package nautilus.game.arcade.game.games.evolution; - -import org.bukkit.entity.Player; - -public class EvoScore -{ - public org.bukkit.entity.Player Player; - public int Kills; - - public EvoScore(Player player, int i) - { - Player = player; - Kills = i; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoToken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoToken.java new file mode 100644 index 000000000..838549dea --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoToken.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.evolution; + +import nautilus.game.arcade.kit.Kit; + +import org.bukkit.entity.Player; + +public class EvoToken implements Comparable +{ + /** + * @author Mysticate + */ + + public final Player Player; + + public final Kit SupplementKit; + + public int Level = 0; + public int LifeKills = 0; + + public EvoToken(Player player, Kit kit) + { + Player = player; + SupplementKit = kit; + } + + @Override + public int compareTo(EvoToken o) + { + if (Level == o.Level) + { + return 0; + } + if (Level > o.Level) + { + return -1; + } + return 1; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 338056822..0d34b7797 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -1,293 +1,818 @@ package nautilus.game.arcade.game.games.evolution; +import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +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.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.CombatManager.AttackReason; +import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.ConditionActive; +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.Game; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.evolution.kits.*; -import nautilus.game.arcade.game.games.evolution.mobs.*; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAttemptingTickEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionPostEvolveEvent; +import nautilus.game.arcade.game.games.evolution.evolve.EvolveManager; +import nautilus.game.arcade.game.games.evolution.kits.KitAbility; +import nautilus.game.arcade.game.games.evolution.kits.KitEvolveSpeed; +import nautilus.game.arcade.game.games.evolution.kits.KitHealth; +import nautilus.game.arcade.game.games.evolution.mobs.KitBlaze; +import nautilus.game.arcade.game.games.evolution.mobs.KitChicken; +import nautilus.game.arcade.game.games.evolution.mobs.KitCreeper; +import nautilus.game.arcade.game.games.evolution.mobs.KitGolem; +import nautilus.game.arcade.game.games.evolution.mobs.KitSlime; +import nautilus.game.arcade.game.games.evolution.mobs.KitSpider; +import nautilus.game.arcade.game.games.evolution.trackers.EvoWinWithoutDyingTracker; +import nautilus.game.arcade.game.games.evolution.trackers.KillsWhileEvolvingTracker; +import nautilus.game.arcade.game.games.evolution.trackers.NoAbilityTracker; +import nautilus.game.arcade.game.games.evolution.trackers.NoDamageWhileEvolvingTracker; +import nautilus.game.arcade.game.games.evolution.trackers.NoMeleeTracker; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.stats.KillFastStatTracker; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.util.Vector; public class Evolution extends SoloGame { - private ArrayList _ranks = new ArrayList(); - private ArrayList _lastScoreboard = new ArrayList(); - - private HashMap _bonusKit = new HashMap(); - - private Objective _scoreObj; + /** + * @author Mysticate + * Reworked from Original Code. + */ + private EvolveManager _evolve; + + private ArrayList _mobKits = new ArrayList(); + private ArrayList _kits = new ArrayList(); + + private NautHashMap _tokens = new NautHashMap(); + + private NautHashMap> _evoPlatforms = new NautHashMap>(); + private ArrayList _spawns = new ArrayList(); + + private ArrayList _evolutionsAvailable = new ArrayList(); + private NautHashMap _chargingExp = new NautHashMap(); + + @SuppressWarnings("unchecked") public Evolution(ArcadeManager manager) { - super(manager, GameType.Evolution, + super(manager, GameType.Evolution, new EvoKit[0], new String[0]); +// +// //Custom kit stuff to make other things easiet + _mobKits.add(new KitGolem(manager)); + _mobKits.add(new KitBlaze(manager)); + _mobKits.add(new KitSpider(manager)); + _mobKits.add(new KitCreeper(manager)); + _mobKits.add(new KitSlime(manager)); +// _mobKits.add(new KitEnderman(manager)); +// _mobKits.add(new KitSnowman(manager)); +// _mobKits.add(new KitWolf(manager)); + _mobKits.add(new KitChicken(manager)); +// _mobKits.add(new KitSkeleton(manager)); + + _kits.add(new KitAbility(Manager)); + _kits.add(new KitEvolveSpeed(Manager)); + _kits.add(new KitHealth(Manager)); + + ArrayList allKits = new ArrayList(); + allKits.addAll(_mobKits); + allKits.addAll(_kits); + + setKits(allKits.toArray(new Kit[0])); - new Kit[] - { - new KitHealth(manager), - new KitAgility(manager), - new KitRecharge(manager), - - new KitGolem(manager), //Iron - new KitBlaze(manager), //Chainmail - new KitSlime(manager), //Chainmail - new KitCreeper(manager), //None - new KitEnderman(manager), //Chainmail - new KitSkeleton(manager), //Leather - new KitSpider(manager), //Chainmail - new KitSnowman(manager), //Leather - new KitWolf(manager), //Leather - new KitChicken(manager), - - }, - - new String[] - { - "You evolve when you get a kill.", + _gameDesc = new String[] + { + "You can evolve every kill.", "Each evolution has unique skills.", - "", - "First to get through 10 evolutions wins!" - }); + "First to get through " + _mobKits.size() + " evolutions wins!" + }; + + DamageTeamSelf = true; + + HungerSet = 20; + + DeathOut = false; + + PrepareFreeze = false; + + GemKillDeathRespawn = 2; + GemAssistDeathRespawn = .5; - this.DamageTeamSelf = true; + CompassEnabled = true; + CompassGiveItem = false; - this.HungerSet = 20; + AutomaticRespawn = false; + DeathSpectateSecs = 4.0; - this.DeathOut = false; + VersionRequire1_8 = true; - this.PrepareFreeze = false; + CreatureAllow = false; + InventoryClick = false; - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Evolutions", "dummy"); - _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); + InventoryOpenBlock = false; + + Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.Attack); + + registerStatTrackers( + new EvoWinWithoutDyingTracker(this), + new NoDamageWhileEvolvingTracker(this), + new KillFastStatTracker(this, 3, 5, "Rampage"), + new NoAbilityTracker(this), + new NoMeleeTracker(this), + new KillsWhileEvolvingTracker(this) + ); } - @EventHandler(priority = EventPriority.MONITOR) - public void RegisterMobKits(GameStateChangeEvent event) + public EvolveManager getEvolve() { - if (event.GetState() != GameState.Live) - return; + return _evolve; } - - //Double Kit - @EventHandler(priority = EventPriority.MONITOR) - public void StoreBonusKits(GameStateChangeEvent event) + + @Override + public void ParseData() { - if (event.GetState() != GameState.Live) - return; - - for (Player player : GetPlayers(true)) + for (Location platform : WorldData.GetDataLocs("RED")) { - _bonusKit.put(player, GetKit(player)); - UpgradeKit(player, true); + platform.getBlock().setType(Material.AIR); + + for (Location viewing : WorldData.GetDataLocs("GREEN")) + { + viewing.getBlock().setType(Material.AIR); + + Iterator iS = WorldData.GetDataLocs("YELLOW").iterator(); + while (iS.hasNext()) + { + Location store = iS.next(); + + store.getBlock().setType(Material.AIR); + + if (UtilMath.offset(store, platform) > 8 || UtilMath.offset(platform, viewing) > 8) + continue; + + iS.remove(); + _evoPlatforms.put(platform, new SimpleEntry(loadAngle(platform, viewing), store)); + } + } + } + + for (GameTeam team : GetTeamList()) + { + _spawns.addAll(team.GetSpawns()); } } + + private Location loadAngle(Location platform, Location viewing) + { + Vector b = UtilAlg.getTrajectory(viewing, platform.clone().subtract(0, 1.1, 0)).normalize(); + + viewing.setPitch(UtilAlg.GetPitch(b)); + viewing.setYaw(UtilAlg.GetYaw(b)); + + return viewing; + } + + //Double kit + @EventHandler(priority = EventPriority.MONITOR) + public void storeTokens(PlayerPrepareTeleportEvent event) + { + _tokens.put(event.GetPlayer().getName(), new EvoToken(event.GetPlayer(), GetKit(event.GetPlayer()) == null ? _kits.get(0) : GetKit(event.GetPlayer()))); + + upgradeKit(event.GetPlayer(), false); + } + +// //Double Kit +// @EventHandler(priority = EventPriority.MONITOR) +// public void storeTokens(GameStateChangeEvent event) +// { +// if (event.GetState() != GameState.Prepare) +// return; +// +// for (Player player : GetPlayers(true)) +// { +// _tokens.put(player.getName(), new EvoToken(player, GetKit(player) == null ? _kits.get(0) : GetKit(player))); +// +// upgradeKit(player, false); +// } +// } + + @EventHandler(priority = EventPriority.MONITOR) + public void showKit(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (!(kit instanceof EvoKit)) + continue; + + ((EvoKit) kit).upgradeGive(player); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void endNoEvolve(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + if (_evoPlatforms.size() <= 0) + { + Announce(C.cWhite + C.Bold + GetName() + " ended, map not set up properly!"); + SetState(GameState.Dead); + return; + } + + _evolve = new EvolveManager(this, _evoPlatforms); + } + + public void upgradeKit(Player player, boolean give) + { + if (!IsAlive(player)) + return; + EvoKit newKit = _mobKits.get(getScore(player)); + + _tokens.get(player.getName()).SupplementKit.ApplyKit(player); + SetKit(player, newKit, false); + + if (give) + { + newKit.upgradeGive(player); + } + } + @Override public boolean HasKit(Player player, Kit kit) { - if (GetKit(player) == null) - return false; - - if (GetKit(player).equals(kit)) + if (super.HasKit(player, kit)) return true; + + if (!_tokens.containsKey(player.getName())) + return false; + + return _tokens.get(player.getName()).SupplementKit.equals(kit); + } + + @EventHandler + public void startEvolve(EvolutionBeginEvent event) + { + Player player = event.getPlayer(); + + Recharge.Instance.Get(player).clear(); + + player.setSprinting(false); + player.setSneaking(false); - //Bonus Kit - if (_bonusKit.containsKey(player)) - if (_bonusKit.get(player).equals(kit)) - return true; + player.setHealth(player.getMaxHealth()); - return false; + player.setFireTicks(0); + player.setFallDistance(0); + + player.eject(); + player.leaveVehicle(); + + ((CraftPlayer) player).getHandle().p(0); + + //Freeze + Manager.GetCondition().Factory().Cloak("Evolving", player, null, 10, false, false); + + ((Player) player).playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 1.25f); } @EventHandler - public void PlayerKillAward(CombatDeathEvent event) + public void stopEvolve(EvolutionEndEvent event) { - Game game = Manager.GetGame(); - if (game == null) return; + if (Manager.GetCondition().GetActiveConditions().containsKey(event.getPlayer())) + { + for (ConditionActive cond : Manager.GetCondition().GetActiveConditions().get(event.getPlayer())) + { + if (cond.GetCondition().GetType() == ConditionType.CLOAK) + continue; + + cond.GetCondition().Expire(); + } + } + + if (increaseScore(event.getPlayer()) >= _mobKits.size()) + { + ScoreboardUpdate(new UpdateEvent(UpdateType.FAST)); - if (!(event.GetEvent().getEntity() instanceof Player)) + event.setCancelled(true); + + End(); + } + else + { + upgradeKit(event.getPlayer(), true); + event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.LEVEL_UP, 1, 0.6F); + } + } + + @EventHandler + public void endEvolve(final EvolutionPostEvolveEvent event) + { + //Make sure they're not invis when they're done evolving + while (Manager.GetCondition().IsCloaked(event.getPlayer())) + { + Manager.GetCondition().GetActiveCondition(event.getPlayer(), ConditionType.CLOAK).Expire(); + } + + if (getScore(event.getPlayer()) >= _mobKits.size()) + { + End(); + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (!IsLive()) + return; + + if (!IsAlive(event.GetDamageeEntity())) + return; + + if (!_chargingExp.containsKey(event.GetDamageePlayer().getName())) + return; + + _chargingExp.put(event.GetDamageePlayer().getName(), (float) Math.max(0, _chargingExp.get(event.GetDamageePlayer().getName()) * .92)); + } + + @EventHandler + public void onDeath(PlayerDeathEvent event) + { + if (!IsLive()) + return; + + if (!IsAlive(event.getEntity())) + return; + + if (_evolutionsAvailable.contains(event.getEntity())) + { + _evolutionsAvailable.remove(event.getEntity()); + } + + if (_chargingExp.containsKey(event.getEntity().getName())) + { + _chargingExp.remove(event.getEntity().getName()); + } + + if (hasEvolvingEffects(event.getEntity())) + { + removeEvolvingEffects(event.getEntity()); + } + + if (_tokens.containsKey(event.getEntity().getName())) + { + _tokens.get(event.getEntity().getName()).LifeKills = 0; + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onKill(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.Simple); + + if (!IsLive()) return; - if (event.GetLog().GetKiller() == null) + CombatComponent damager = event.GetLog().GetKiller(); + if (damager == null) + return; + + if (!damager.IsPlayer()) return; - final Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (killer == null) + Player player = UtilPlayer.searchExact(damager.GetName()); + + if (player == null || !player.isOnline()) return; - if (killer.equals(event.GetEvent().getEntity())) + if (!IsAlive(player)) return; + if (UtilPlayer.isSpectator(player)) + return; + + if (((Player) event.GetEvent().getEntity()) == player) + return; + + if (!_evolutionsAvailable.contains(player)) + { + _evolutionsAvailable.add(player); + + if (_chargingExp.containsKey(player.getName())) + _chargingExp.remove(player.getName()); + } + + if (_tokens.containsKey(player.getName())) + { + EvoToken token = _tokens.get(player.getName()); + token.LifeKills++; + + UtilPlayer.message(player, ""); + UtilPlayer.message(player, F.main("Game", F.elem(token.LifeKills + " Kill" + (token.LifeKills == 1 ? "" : "s")) + C.cWhite + " - " + C.cGreen + Math.max(1.0, 6.0 - (1.5 * (token.LifeKills - 1))) + "s evolve speed" + (token.SupplementKit instanceof KitEvolveSpeed ? C.cGreen + " - 30% (Quick Evolver)" : ""))); + UtilPlayer.message(player, ""); + } + + //Buffs + Manager.GetCondition().Factory().Speed("Kill", player, null, 3, 0, true, false, false); + UtilPlayer.health(player, player.getMaxHealth() / 2); + } + + @Override + public void RespawnPlayer(final Player player) + { + player.eject(); + player.teleport(getSpawn()); + + Manager.Clear(player); + + //Re-Give Kit Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { public void run() - { - UpgradeKit(killer, false); + { + if (_tokens.containsKey(player.getName())) + _tokens.get(player.getName()).SupplementKit.ApplyKit(player); + + GetKit(player).ApplyKit(player); } }, 0); } - - public void UpgradeKit(Player player, boolean first) + + @EventHandler + public void onEgg(PlayerInteractEvent event) { - if (!Recharge.Instance.use(player, "Evolve", 500, false, false)) + if (!IsLive()) return; - //Remove Old Recharges - Recharge.Instance.Reset(player); - Recharge.Instance.useForce(player, "Evolve", 500); + if (!UtilEvent.isAction(event, ActionType.R_BLOCK) && !UtilEvent.isAction(event, ActionType.L_BLOCK)) + return; - Kit kit = GetKit(player); - - for (int i=3 ; i iterator = _evolutionsAvailable.iterator(); + while (iterator.hasNext()) + { + Player player = iterator.next(); + + if (player == null || !player.isOnline()) { - if (!first) - i++; + iterator.remove(); + continue; + } + + if (!IsAlive(player)) + { + iterator.remove(); + continue; + } - if (i= .9999F) + { + + UtilTextMiddle.display("", "", player); + + _chargingExp.remove(player.getName()); + + if (hasEvolvingEffects(player)) + removeEvolvingEffects(player); + + EvoToken token = _tokens.get(player.getName()); + + token.LifeKills = 0; + + EvoKit from = (EvoKit) _mobKits.get(token.Level); + EvoKit to = (EvoKit) _mobKits.get(token.Level + 1 >= _mobKits.size() ? token.Level : token.Level + 1); //Account for the score increase after evolve + + _evolve.addEvolve(Manager.getHologramManager(), player, from, to); + + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1); + return true; + } + + Manager.GetCondition().EndCondition(player, ConditionType.SPEED, "Kill"); + + if (!hasEvolvingEffects(player)) + addEvolvingEffects(player); + + int kills = _tokens.get(player.getName()).LifeKills; + + if (UtilEnt.isGrounded(player) && player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.DRAGON_EGG) + { + EvolutionAttemptingTickEvent tickEvent = new EvolutionAttemptingTickEvent(player, (float) Math.min(.022, .012 + (kills <= 0 ? 0 : (.003 * (kills - 1))))); + Bukkit.getPluginManager().callEvent(tickEvent); + + _chargingExp.put(player.getName(), (float) Math.min(exp + tickEvent.getProgress(), .9999F)); + } + + UtilTextMiddle.display("", UtilTextMiddle.progress(_chargingExp.get(player.getName())).trim(), player); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1, _chargingExp.get(player.getName()) + 1); + + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().clone().add(0, 1, 0), 0.4F, 0.56F, 0.4F, 0, 3, ViewDist.NORMAL, UtilServer.getPlayers()); + return false; + } + + private boolean hasEvolvingEffects(Player player) + { + if (!Manager.GetCondition().GetActiveConditions().containsKey(player)) + return false; + + for (ConditionActive active : Manager.GetCondition().GetActiveConditions().get(player)) + { + if (!active.GetCondition().GetReason().equalsIgnoreCase("Charging")) + continue; + + return true; + } + + return false; + } + + private void removeEvolvingEffects(Player player) + { + if (!Manager.GetCondition().GetActiveConditions().containsKey(player)) + return; + + for (ConditionActive active : Manager.GetCondition().GetActiveConditions().get(player)) + { + if (!active.GetCondition().GetReason().equalsIgnoreCase("Charging")) + continue; + + active.GetCondition().Expire(); + } + } + + private void addEvolvingEffects(Player player) + { + Manager.GetCondition().Factory().Jump("Charging", player, null, 20, 128, false, false, false); + Manager.GetCondition().Factory().Slow("Charging", player, null, 20, 1, false, false, false, false); + } + + @EventHandler + public void onEvolveAttemptingAbility(EvolutionAbilityUseEvent event) + { + if (!IsLive()) + return; + + if (_chargingExp.containsKey(event.getPlayer().getName())) + event.setCancelled(true); } - public int GetScore(Player player) + private int increaseScore(Player player) { if (!IsAlive(player)) return 0; + + if (!_tokens.containsKey(player.getName())) + return 0; + + _tokens.get(player.getName()).Level++; + return getScore(player); + } - //Rank - for (EvoScore score : _ranks) + public int getScore(Player player) + { + if (!IsPlaying(player)) + return 0; + + try { - if (score.Player.equals(player)) + return _tokens.get(player.getName()).Level; + } + catch (NullPointerException ex) + { + return 0; + } + } + + @EventHandler + public void onSlot(PlayerItemHeldEvent event) + { + if (!Manager.GetGame().InProgress()) + return; + + if (!IsAlive(event.getPlayer())) + return; + + if (UtilPlayer.isSpectator(event.getPlayer())) + return; + + if (event.getNewSlot() != 0) + { + event.setCancelled(true); + } + } + + public Location getSpawn() + { + ArrayList allPlayers = new ArrayList(); + + for (Player cur : GetPlayers(true)) + { + if (UtilPlayer.isSpectator(cur)) + continue; + + if (_evolve.isEvolving(cur)) { - return score.Kills; + allPlayers.add(_evolve.getEvolve(cur).getEggLocation()); + } + else + { + allPlayers.add(cur.getLocation()); } } - return 0; + return UtilAlg.getLocationAwayFromOtherLocations(_spawns, allPlayers); } - - private void SortScores() + + @EventHandler + public void onCombust(EntityCombustEvent event) { - for (int i=0 ; i<_ranks.size() ; i++) - { - for (int j=_ranks.size()-1 ; j>0 ; j--) - { - if (_ranks.get(j).Kills > _ranks.get(j-1).Kills) - { - EvoScore temp = _ranks.get(j); - _ranks.set(j, _ranks.get(j-1)); - _ranks.set(j-1, temp); - } - } - } + event.setCancelled(true); } - + private void End() { - SortScores(); + ArrayList tokens = new ArrayList(_tokens.values()); + Collections.sort(tokens); - //Set Places - ArrayList places = new ArrayList(); - for (int i=0 ; i<_ranks.size() ; i++) - places.add(i, _ranks.get(i).Player); + List players = new ArrayList(); + for (int i = 0 ; i < tokens.size() ; i++) + { + players.add(tokens.get(i).Player); + } + //Award Gems - if (_ranks.size() >= 1) - AddGems(_ranks.get(0).Player, 20, "1st Place", false, false); + if (tokens.size() >= 1) + AddGems(players.get(0), 20, "1st Place", false, false); - if (_ranks.size() >= 2) - AddGems(_ranks.get(1).Player, 15, "2nd Place", false, false); + if (tokens.size() >= 2) + AddGems(players.get(1), 15, "2nd Place", false, false); - if (_ranks.size() >= 3) - AddGems(_ranks.get(2).Player, 10, "3rd Place", false, false); + if (tokens.size() >= 3) + AddGems(players.get(2), 10, "3rd Place", false, false); //Participation for (Player player : GetPlayers(false)) if (player.isOnline()) AddGems(player, 10, "Participation", false, false); - + +// _tokens.clear(); + _evoPlatforms.clear(); + _evolutionsAvailable.clear(); + + _evolve.end(); + + AnnounceEnd(players); SetState(GameState.End); - AnnounceEnd(places); } - + @Override - public void EndCheck() + public List getWinners() { + if (GetState() != GameState.End) + return null; + + ArrayList tokens = new ArrayList(_tokens.values()); + Collections.sort(tokens); + if (tokens.size() < 1) + return null; + + return Arrays.asList(tokens.get(0).Player); } - + @Override @EventHandler public void ScoreboardUpdate(UpdateEvent event) { + if (!InProgress()) + return; + if (event.getType() != UpdateType.FAST) return; Scoreboard.Reset(); - + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellow + C.Bold + "First to " + _mobKits.size()); + + Scoreboard.WriteBlank(); + for (Player player : GetPlayers(true)) { - Scoreboard.WriteOrdered("Score", C.cGreen + player.getName(), GetScore(player), true); + Scoreboard.WriteOrdered("Score", C.cGreen + player.getName(), getScore(player), true); } - + Scoreboard.Draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionAbilityUseEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionAbilityUseEvent.java new file mode 100644 index 000000000..377471014 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionAbilityUseEvent.java @@ -0,0 +1,66 @@ +package nautilus.game.arcade.game.games.evolution.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class EvolutionAbilityUseEvent extends PlayerEvent implements Cancellable +{ + /** + * @author Mysticate + */ + + private static HandlerList _handlers = new HandlerList(); + + private boolean _cancelled = false; + + private String _ability; + private long _cooldown; + + public EvolutionAbilityUseEvent(Player who, String ability, long cooldown) + { + super(who); + + _ability = ability; + _cooldown = cooldown; + } + + public String getAbility() + { + return _ability; + } + + public long getCooldown() + { + return _cooldown; + } + + public void setCooldown(long cooldown) + { + _cooldown = cooldown; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionAttemptingTickEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionAttemptingTickEvent.java new file mode 100644 index 000000000..8c249a2b6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionAttemptingTickEvent.java @@ -0,0 +1,44 @@ +package nautilus.game.arcade.game.games.evolution.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class EvolutionAttemptingTickEvent extends PlayerEvent +{ + /** + * @author Mysticate + */ + + private static HandlerList _handlers = new HandlerList(); + + private static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private float _progress; + + public EvolutionAttemptingTickEvent(Player who, float progress) + { + super(who); + + _progress = progress; + } + + public float getProgress() + { + return _progress; + } + + public void setProgress(float progress) + { + _progress = progress; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionBeginEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionBeginEvent.java new file mode 100644 index 000000000..9389e1daf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionBeginEvent.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.evolution.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class EvolutionBeginEvent extends PlayerEvent +{ + /** + * @author Mysticate + */ + + private static HandlerList _handlers = new HandlerList(); + + public EvolutionBeginEvent(Player who) + { + super(who); + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionEndEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionEndEvent.java new file mode 100644 index 000000000..e1cc04125 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionEndEvent.java @@ -0,0 +1,45 @@ +package nautilus.game.arcade.game.games.evolution.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class EvolutionEndEvent extends PlayerEvent implements Cancellable +{ + /** + * @author Mysticate + */ + + private static HandlerList _handlers = new HandlerList(); + + private boolean _cancelled = false; + + public EvolutionEndEvent(Player who) + { + super(who); + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean flag) + { + _cancelled = flag; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionPostEvolveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionPostEvolveEvent.java new file mode 100644 index 000000000..d203e8038 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/events/EvolutionPostEvolveEvent.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.evolution.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class EvolutionPostEvolveEvent extends PlayerEvent +{ + /** + * @author Mysticate + */ + + private static HandlerList _handlers = new HandlerList(); + + public EvolutionPostEvolveEvent(Player who) + { + super(who); + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java new file mode 100644 index 000000000..cd657ace3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java @@ -0,0 +1,422 @@ +package nautilus.game.arcade.game.games.evolution.evolve; + +import java.util.AbstractMap.SimpleEntry; +import java.util.HashMap; +import java.util.Map.Entry; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilFirework; +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.UtilTime; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.Hologram.HologramTarget; +import mineplex.core.hologram.HologramManager; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionPostEvolveEvent; +import net.minecraft.server.v1_7_R4.EntityBlaze; +import net.minecraft.server.v1_7_R4.EntityChicken; +import net.minecraft.server.v1_7_R4.EntityCreeper; +import net.minecraft.server.v1_7_R4.EntityEnderman; +import net.minecraft.server.v1_7_R4.EntityInsentient; +import net.minecraft.server.v1_7_R4.EntityIronGolem; +import net.minecraft.server.v1_7_R4.EntitySkeleton; +import net.minecraft.server.v1_7_R4.EntitySlime; +import net.minecraft.server.v1_7_R4.EntitySnowman; +import net.minecraft.server.v1_7_R4.EntitySpider; +import net.minecraft.server.v1_7_R4.EntityWolf; +import net.minecraft.server.v1_7_R4.EntityZombie; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_7_R4.World; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class EvolveData +{ + /** + * @author Mysticate + */ + + private boolean _ended = false; + + private final long _timestamp = System.currentTimeMillis(); + private long _endTime = System.currentTimeMillis(); + + private final long _preEvolve = 2200; + private final long _postEvolve = 4800; + +// private EvolveManager _manager; + private HologramManager _holoManager; + + private final PlatformToken _token; + + private boolean _active = true; + + private final Player _player; +// private Zombie _zombie; +// private DisguiseArmorStand _disguise; + + private final Location _eggLoc; + private final SimpleEntry _eggLocData; + + private final Hologram _eggHolo; + + private final EvoKit _to; + + private Hologram _holo; + + private final EntityInsentient _eFrom; + private EntityInsentient _eTo; + + @SuppressWarnings("deprecation") + public EvolveData(EvolveManager manager, HologramManager holo, PlatformToken token, Player player, EvoKit from, EvoKit to) + { + +// _manager = manager; + _holoManager = holo; + + _token = token; + + _player = player; + + _eggLoc = player.getLocation(); + _eggLocData = new SimpleEntry(_eggLoc.getBlock().getType(), _eggLoc.getBlock().getData()); + + _eggHolo = new Hologram(holo, _eggLoc.getBlock().getLocation().clone().add(0.5, 1.0, 0.5), C.cYellow + _player.getName()).start(); + + _to = to; + + _eFrom = spawn(from.getEntity(), token.Platform, false); + + Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player)); + + setupViewingToken(_eFrom); +// spawnZombie(); +// setupZombie(); + setupPlayer(); + setupEgg(); + setupHologram(holo, _eFrom, from); + } + + private void setupEgg() + { + MapUtil.QuickChangeBlockAt(_eggLoc, Material.DRAGON_EGG); + } + + private void restoreEgg() + { + MapUtil.QuickChangeBlockAt(_eggLoc, _eggLocData.getKey(), _eggLocData.getValue()); + } + + public Location getEggLocation() + { + return _eggLoc; + } + + private void setupViewingToken(EntityInsentient ent) + { + Location playerEye = _token.Viewing.clone().add(.5, .62, .5); + Location entityHalf = _token.Platform.clone().add(.5, -1, .5).add(0, (ent.boundingBox.e - ent.boundingBox.b) * .75, 0); + + Vector viewing = UtilAlg.getTrajectory(playerEye, entityHalf); + _token.Viewing.setPitch(UtilAlg.GetPitch(viewing)); + } + +// private void spawnZombie() +// { +// _manager.Host.CreatureAllowOverride = true; +// _zombie = (Zombie) _player.getWorld().spawnEntity(_token.Viewing, EntityType.ZOMBIE); +// _manager.Host.CreatureAllowOverride = true; +// UtilEnt.Vegetate(_zombie, true); +// UtilEnt.ghost(_zombie, true, true); +// +// _disguise = new DisguiseArmorStand(_zombie); +// +// _disguise.setInvisible(true); +// _disguise.Global = false; +// +// _manager.Host.Manager.GetDisguise().disguise(_disguise, _player); +// } +// +// private void setupZombie() +// { +// _zombie.teleport(_token.Viewing); +// +// _disguise.setHeadPosition(_token.Viewing.getDirection()); +// +//// _disguise.UpdateDataWatcher(); +// _manager.Host.Manager.GetDisguise().updateDisguise(_disguise); +// +// } + + private void setupPlayer() + { + if (_token.Viewing.getX() != _player.getLocation().getX()) + { + _player.teleport(_token.Viewing); + return; + } + + if (_token.Viewing.getY() != _player.getLocation().getY()) + { + _player.teleport(_token.Viewing); + return; + } + + if (_token.Viewing.getZ() != _player.getLocation().getZ()) + { + _player.teleport(_token.Viewing); + return; + } + + if (_token.Viewing.getPitch() != _player.getLocation().getPitch()) + { + _player.teleport(_token.Viewing); + return; + } + + if (_token.Viewing.getYaw() != _player.getLocation().getYaw()) + { + _player.teleport(_token.Viewing); + return; + } + +// _player.teleport(_token.Store); +// _player.teleport(_token.Viewing); + +// UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_zombie.getEntityId())); + } + + private void setupHologram(HologramManager manager, EntityInsentient entity, EvoKit kit) + { + if (_holo == null) + _holo = new Hologram(manager, _token.Platform); + + double add = entity.boundingBox.e - entity.boundingBox.b + .3; + + _holo.setLocation(_token.Platform.clone().add(0, add, 0)); + + _holo.setText(kit.buildHologram()); + + _holo.setHologramTarget(HologramTarget.WHITELIST); + _holo.addPlayer(_player); + + _holo.start(); + } + + //Boolean completed + public boolean tick() + { + //Failsafe + if (_ended) + { + return true; + } + +// setupZombie(); + teleport(); + + //Hasn't ended yet + if (_active) + { + //If 3 seconds past + if (UtilTime.elapsed(_timestamp, _preEvolve)) + { + _active = false; + _endTime = System.currentTimeMillis(); + + EvolutionEndEvent event = new EvolutionEndEvent(_player); + Bukkit.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return true; + } + + _eTo = spawn(_to.getEntity(), _token.Platform, false); + despawn(_eFrom); + + setupViewingToken(_eTo); +// setupZombie(); + setupPlayer(); + + setupHologram(_holoManager, _eTo, _to); + + UtilFirework.packetPlayFirework(_player, _token.Platform.clone().add(0.0, 1.5, 0.0), Type.BALL, Color.GREEN, false, false); + } + else + { + //Play particles + if (UtilTime.elapsed(_timestamp, 500)) + { + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _token.Platform.clone().add(0.0, 1.0, 0.0), 0.5F, 1.0F, 0.5F, 0, 5, ViewDist.SHORT, _player); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, _eggLoc.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0, 3, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + return false; + } + else + { + if (!UtilTime.elapsed(_endTime, _postEvolve)) + return false; + + end(); + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _eggLoc.clone().add(0.0, 1.0, 0.0), 1.4F, 3.0F, 1.4F, 0, 12, ViewDist.NORMAL, UtilServer.getPlayers()); + knockback(); + + Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugins()[0], new Runnable() + { + @Override + public void run() + { + Bukkit.getServer().getPluginManager().callEvent(new EvolutionPostEvolveEvent(_player)); + } + }, 2); + return true; + } + } + + public void end() + { + _active = false; + + if (_eFrom != null) + despawn(_eFrom); + + if (_eTo != null) + despawn(_eTo); + + _eggHolo.stop(); + restoreEgg(); + + if (_holo != null) + _holo.stop(); + +// UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_player)); +// _zombie.remove(); + + try + { + _player.teleport(_eggLoc.clone()); + } + catch (NullPointerException ex) + {} + + _ended = true; + } + + public void teleport() + { + setupPlayer(); + } + + private void knockback() + { + HashMap radius = UtilPlayer.getInRadius(_eggLoc, 8.0); + + for (Entry entry : radius.entrySet()) + { + if (entry.getKey() == _player) + continue; + + UtilAction.velocity(entry.getKey(), UtilAlg.getTrajectory2d(_eggLoc, entry.getKey().getLocation()), 1.6 - (entry.getValue() / 10), true, 0.8, 0, 10, true); + } + } + + private EntityInsentient spawn(EntityType type, Location loc, boolean invisible) + { + try + { + EntityInsentient entity = getEntity(type).getConstructor(World.class).newInstance(((CraftWorld) loc.getWorld()).getHandle()); + entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(entity); + entity.setCustomNameVisible(false); + + if (entity instanceof EntitySlime) + { + ((EntitySlime) entity).setSize(2); + } + + if (invisible) + { + entity.Invisible = true; + } + + entity.ghost = true; + + UtilPlayer.sendPacket(_player, packet); + return entity; + } + catch (Exception ex) + { + ex.printStackTrace(); + return null; + } + } + + private void despawn(EntityInsentient entity) + { + if (entity == null) + return; + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] + { + entity.getId() + }); + + UtilPlayer.sendPacket(_player, packet); + } + + private Class getEntity(EntityType type) + { + if (type == EntityType.BLAZE) + return EntityBlaze.class; + + if (type == EntityType.CHICKEN) + return EntityChicken.class; + + if (type == EntityType.CREEPER) + return EntityCreeper.class; + + if (type == EntityType.ENDERMAN) + return EntityEnderman.class; + + if (type == EntityType.IRON_GOLEM) + return EntityIronGolem.class; + + if (type == EntityType.SKELETON) + return EntitySkeleton.class; + + if (type == EntityType.SLIME) + return EntitySlime.class; + + if (type == EntityType.SNOWMAN) + return EntitySnowman.class; + + if (type == EntityType.SPIDER) + return EntitySpider.class; + + if (type == EntityType.WOLF) + return EntityWolf.class; + + return EntityZombie.class; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveManager.java new file mode 100644 index 000000000..4f1f48b2e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveManager.java @@ -0,0 +1,236 @@ +package nautilus.game.arcade.game.games.evolution.evolve; + +import java.util.AbstractMap.SimpleEntry; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.hologram.HologramManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.addons.compass.CompassAttemptTargetEvent; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.perks.event.PerkConstructorEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.player.PlayerMoveEvent; + +public class EvolveManager implements Listener +{ + /** + * @author Mysticate + */ + + public final Evolution Host; + + private final NautHashMap> _evolveLocs; + + private NautHashMap _data = new NautHashMap(); + + public EvolveManager(Evolution evolution, NautHashMap> evolveLocs) + { + Host = evolution; + _evolveLocs = evolveLocs; + + Bukkit.getPluginManager().registerEvents(this, Host.Manager.getPlugin()); + } + + private PlatformToken getLocation() + { + ArrayList>> locs = new ArrayList>>(_evolveLocs.entrySet()); + Entry> entry = locs.get(UtilMath.r(locs.size())); + + return new PlatformToken(entry.getKey(), entry.getValue().getKey(), entry.getValue().getValue()); + } + + public boolean isEvolving(Player player) + { + return _data.containsKey(player.getName()); + } + + public void addEvolve(HologramManager holo, Player player, EvoKit from, EvoKit to) + { + if (_data.containsKey(player.getName())) + return; + + _data.put(player.getName(), new EvolveData(this, holo, getLocation(), player, from, to)); + } + + public EvolveData getEvolve(Player player) + { + return _data.get(player.getName()); + } + + @EventHandler + public void tick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Host.IsLive()) + return; + + Iterator> iterator = _data.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + + Player player = UtilPlayer.searchExact(entry.getKey()); + + if (player == null || !player.isOnline()) + { + try + { + entry.getValue().end(); + } + catch (NullPointerException ex) {} + + iterator.remove(); + continue; + } + + if (!Host.IsAlive(player)) + { + try + { + entry.getValue().end(); + } + catch (NullPointerException ex) {} + + iterator.remove(); + continue; + } + + if (entry.getValue().tick()) + { + try + { + entry.getValue().end(); + } + catch (NullPointerException ex) {} + + iterator.remove(); + continue; + } + } + } + + public void end() + { + for (EvolveData data : _data.values()) + { + data.end(); + } + + HandlerList.unregisterAll(this); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onEvolveDamageRecieve(CustomDamageEvent event) + { + if (!Host.IsLive()) + return; + + if (!(event.GetDamageeEntity() instanceof Player)) + return; + + if (isEvolving(event.GetDamageePlayer())) + event.SetCancelled("Player is evolving!"); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onEvolveDamageDeal(CustomDamageEvent event) + { + if (!Host.IsLive()) + return; + + if (!(event.GetDamagerEntity(true) instanceof Player)) + return; + + if (isEvolving(event.GetDamagerPlayer(true))) + event.SetCancelled("Player is evolving!"); + } + + @EventHandler + public void onEvolveAbility(EvolutionAbilityUseEvent event) + { + if (!Host.IsLive()) + return; + + if (isEvolving(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void onEvolveCompass(CompassAttemptTargetEvent event) + { + if (!Host.IsLive()) + return; + + if (isEvolving(event.getTarget())) + event.setCancelled(true); + } + + @EventHandler + public void onEvolveConstruct(PerkConstructorEvent event) + { + if (!Host.IsLive()) + return; + + if (isEvolving(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void onEvolveMove(PlayerMoveEvent event) + { + if (!Host.IsLive()) + return; + + if (isEvolving(event.getPlayer())) + event.setTo(event.getFrom()); + } + + @EventHandler + public void onEggFall(BlockPhysicsEvent event) + { + if (!Host.IsLive()) + return; + + if (event.getChangedType() == Material.DRAGON_EGG || event.getBlock().getType() == Material.DRAGON_EGG) + event.setCancelled(true); + } + + @EventHandler + public void onEggSolidify(EntityChangeBlockEvent event) + { + if (!Host.IsLive()) + return; + + if (!(event.getEntity() instanceof FallingBlock)) + return; + + if (((FallingBlock) event.getEntity()).getMaterial() != Material.DRAGON_EGG) + return; + + event.setCancelled(true); + event.getEntity().remove(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/PlatformToken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/PlatformToken.java new file mode 100644 index 000000000..1525f2dd2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/PlatformToken.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.evolution.evolve; + +import org.bukkit.Location; + +public class PlatformToken +{ + /** + * @author Mysticate + * August 8, 2015 + */ + + public final Location Platform; + public final Location Viewing; /**This was when I was using a spectate packet. Will be used again once I can have teh armorstand : >>>>>>>>*/ + public final Location Store; + + public PlatformToken(Location platform, Location viewing, Location store) + { + Platform = platform.clone(); + Viewing = viewing.clone(); + Store = store.clone(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitAbility.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitAbility.java new file mode 100644 index 000000000..5cff1a8e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitAbility.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.evolution.kits; + +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.kits.perks.PerkCooldownEVO; +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; + +public class KitAbility extends Kit +{ + /** + * @author Mysticate + */ + + public KitAbility(ArcadeManager manager) + { + super(manager, "Darwinist", KitAvailability.Free, new String[] + { + "Your DNA allows you to chop cooldown times!" + }, new Perk[] + { + new PerkCooldownEVO() + }, EntityType.ZOMBIE, ItemStackFactory.Instance.CreateStack(Material.FEATHER)); + } + + @Override + public void GiveItems(Player player) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitAgility.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitAgility.java deleted file mode 100644 index 38e4573bf..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitAgility.java +++ /dev/null @@ -1,38 +0,0 @@ -package nautilus.game.arcade.game.games.evolution.kits; - -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - -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.PerkDoubleJump; -import nautilus.game.arcade.kit.perks.PerkSpeed; - -public class KitAgility extends Kit -{ - public KitAgility(ArcadeManager manager) - { - super(manager, "Agility", KitAvailability.Free, - - new String[] - { - "You are extremely agile and can double jump!" - }, - - new Perk[] - { - new PerkDoubleJump("Double Jump", 0.8, 0.8, false), - new PerkSpeed(0), - }, - EntityType.ZOMBIE, - null); - } - - @Override - public void GiveItems(Player player) - { - - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitEvolveSpeed.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitEvolveSpeed.java new file mode 100644 index 000000000..7eb6d97ba --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitEvolveSpeed.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.evolution.kits; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.kits.perks.PerkEvolveSpeedEVO; +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; + +public class KitEvolveSpeed extends Kit +{ + /** + * @author Mysticate + */ + + public KitEvolveSpeed(ArcadeManager manager) + { + super(manager, "Quick Evolver", KitAvailability.Gem, 4000, new String[] + { + C.cGray + "You always had dreams of growing up..." + }, new Perk[] + { + new PerkEvolveSpeedEVO() + }, EntityType.ZOMBIE, ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS)); + } + + @Override + public void GiveItems(Player player) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java index 39e751c8c..b9d93c102 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java @@ -1,38 +1,79 @@ package nautilus.game.arcade.game.games.evolution.kits; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - +import mineplex.core.achievement.Achievement; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; 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.PerkRegeneration; -import nautilus.game.arcade.kit.perks.PerkVampire; +import nautilus.game.arcade.kit.perks.PerkDummy; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; public class KitHealth extends Kit { + /** + * @author Mysticate + */ + public KitHealth(ArcadeManager manager) { - super(manager, "Vitality", KitAvailability.Free, - - new String[] + super(manager, "Health Harvester", KitAvailability.Achievement, new String[] + { + "Harvest health every day..." + }, new Perk[] { - "You have improved survivability." - }, - - new Perk[] - { - new PerkRegeneration(0), - new PerkVampire(6), - }, - EntityType.ZOMBIE, - null); + new PerkDummy("Health Haravester", new String[] + { + "Recieve " + F.elem("100%") + " health on kill." + }) + }, EntityType.ZOMBIE, ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER)); + + setAchievementRequirements(new Achievement[] + { + Achievement.EVOLUTION_EVOLVEKILL, + Achievement.EVOLUTION_MELEE, + Achievement.EVOLUTION_NO_DEATHS, + Achievement.EVOLUTION_RAMPAGE, + Achievement.EVOLUTION_SKILLS, + Achievement.EVOLUTION_STEALTH, + Achievement.EVOLUTION_WINS + } + ); } @Override - public void GiveItems(Player player) + public void GiveItems(Player player) { } + + @EventHandler(priority = EventPriority.HIGH) + public void onKill(CombatDeathEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + Player killer = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); + if (killer == null || !killer.isOnline()) + return; + + if (!Manager.IsAlive(killer)) + return; + + if (UtilPlayer.isSpectator(killer)) + return; + + if (!HasKit(killer)) + return; + + killer.setHealth(killer.getMaxHealth()); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitRecharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitRecharge.java deleted file mode 100644 index cb45410fa..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitRecharge.java +++ /dev/null @@ -1,37 +0,0 @@ -package nautilus.game.arcade.game.games.evolution.kits; - -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - -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.PerkRecharge; - -public class KitRecharge extends Kit -{ - public KitRecharge(ArcadeManager manager) - { - super(manager, "Stamina", KitAvailability.Free, - - new String[] - { - "You are able to use your abilities more often!" - }, - - new Perk[] - { - new PerkRecharge(0.5), - }, - EntityType.ZOMBIE, - null); - - } - - @Override - public void GiveItems(Player player) - { - - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/perks/PerkCooldownEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/perks/PerkCooldownEVO.java new file mode 100644 index 000000000..213938a55 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/perks/PerkCooldownEVO.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.evolution.kits.perks; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.event.EventHandler; + +public class PerkCooldownEVO extends Perk +{ + /** + * @author Mysticate + */ + + public PerkCooldownEVO() + { + super("Cooldown", new String[] + { + "All ability cooldowns are reduced by " + F.elem("33%") + "." + }); + } + + @EventHandler + public void onAbility(EvolutionAbilityUseEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!Manager.IsAlive(event.getPlayer())) + return; + + if (!Kit.HasKit(event.getPlayer())) + return; + + event.setCooldown((long) (event.getCooldown() * .666)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/perks/PerkEvolveSpeedEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/perks/PerkEvolveSpeedEVO.java new file mode 100644 index 000000000..b9dd45c06 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/perks/PerkEvolveSpeedEVO.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.evolution.kits.perks; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAttemptingTickEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.event.EventHandler; + +public class PerkEvolveSpeedEVO extends Perk +{ + /** + * @author Mysticate + */ + + public PerkEvolveSpeedEVO() + { + super("Speedy", new String[] + { + "You evolve " + F.elem("25%") + " faster." + }); + } + + @EventHandler + public void onAbility(EvolutionAttemptingTickEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!Manager.IsAlive(event.getPlayer())) + return; + + if (!Kit.HasKit(event.getPlayer())) + return; + + event.setProgress((float) (event.getProgress() * 1.25)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitBlaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitBlaze.java index e0c94df7d..4c801b1bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitBlaze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitBlaze.java @@ -1,57 +1,51 @@ package nautilus.game.arcade.game.games.evolution.mobs; +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseBlaze; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.mobs.perks.PerkFlamingSwordEVO; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkNoFallDamage; +import nautilus.game.arcade.kit.perks.PerkWaterDamage; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseBlaze; -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.PerkFlamingSword; - -public class KitBlaze extends Kit +public class KitBlaze extends EvoKit { + /** + * @author Mysticate + */ + public KitBlaze(ArcadeManager manager) { - super(manager, "Blaze", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkFlamingSword() - }, - EntityType.SLIME, - null); - + super(manager, "Blaze", new String[] + { + C.cYellow + "Ability: " + C.cWhite + "Flamethrower", C.Line, + C.cGreen + "No Fall Damage", C.cRed + "Water Damage" + }, 36, 5, new Perk[] + { + new PerkFlamingSwordEVO(), new PerkWaterDamage(1, 0.25), new PerkNoFallDamage() + }, EntityType.BLAZE); } @Override - public void GiveItems(Player player) + protected void giveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD)); - - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Hold Block") + " to use " + F.elem("Inferno")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 4f, 1f); + player.getInventory().setItem(0, new ItemBuilder(Material.BLAZE_ROD).setTitle(C.cYellow + C.Bold + "Right Click" + C.cWhite + " - " + C.cGreen + C.Bold + "Flamethrower").build()); //Disguise DisguiseBlaze disguise = new DisguiseBlaze(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } + + Manager.GetDisguise().undisguise(player); + Manager.GetDisguise().disguise(disguise); + + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 4f, 1f); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java index bafb1cc9d..32587d144 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java @@ -1,74 +1,151 @@ package nautilus.game.arcade.game.games.evolution.mobs; +import mineplex.core.common.util.C; +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.disguise.disguises.DisguiseChicken; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.game.games.evolution.mobs.perks.PerkDoubleJumpEVO; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkConstructor; + +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Egg; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseChicken; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -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.PerkConstructor; -import nautilus.game.arcade.kit.perks.PerkFallDamage; - -public class KitChicken extends Kit +public class KitChicken extends EvoKit { + /** + * @author Mysticate + */ + public KitChicken(ArcadeManager manager) { - super(manager, "Chicken", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkConstructor("Egg Pouch", 0.8, 8, Material.EGG, "Egg", false), - new PerkFallDamage(-2), - }, - EntityType.SLIME, - null); - + super(manager, "Chicken", new String[] + { + C.cYellow + "Ability: " + C.cWhite + "Egg Throw", C.Line, + C.cGreen + "No Fall Damage", C.cGreen + "Double Jump" + }, 16, 3, + new Perk[] + { + new PerkConstructor("Egg Pouch", 2.0, 3, Material.EGG, + "Egg Launcher Ammo", false), new PerkDoubleJumpEVO("Double Jump", 0.6, 0.9, false) + }, EntityType.CHICKEN); } - + @Override - public void GiveItems(Player player) + protected void giveItems(Player player) { - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Right-Click with Eggs") + " to use " + F.elem("Throw Egg")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_IDLE, 4f, 1f); + player.getInventory().setItem(0, new ItemBuilder(Material.FEATHER).setTitle(C.cYellow + C.Bold + "Right Click" + C.cWhite + " - " + C.cGreen + C.Bold + "Egg Launch").build()); //Disguise DisguiseChicken disguise = new DisguiseChicken(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); + + Manager.GetDisguise().undisguise(player); Manager.GetDisguise().disguise(disguise); + + player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_IDLE, 4f, 1f); + } + + @EventHandler + public void onLaunch(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!Manager.GetGame().IsLive()) + return; + + if (!HasKit(event.getPlayer())) + return; + + if (!UtilGear.isMat(event.getItem(), Material.FEATHER)) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(event.getPlayer(), "Egg", 0); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + { + event.setCancelled(true); + return; + } + + if (!UtilInv.contains(event.getPlayer(), Material.EGG, (byte) 0, 1)) + return; + + UtilInv.remove(event.getPlayer(), Material.EGG, (byte) 0, 1); + event.getPlayer().launchProjectile(Egg.class); + } + + @EventHandler + public void onEggLaunch(final PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!Manager.GetGame().IsLive()) + return; + + if (!HasKit(event.getPlayer())) + return; + + if (!UtilGear.isMat(event.getItem(), Material.EGG)) + return; + + event.setCancelled(true); + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + UtilInv.Update(event.getPlayer()); + } + }, 2); } @EventHandler public void EggHit(CustomDamageEvent event) { - if (event.IsCancelled()) + if (!Manager.GetGame().IsLive()) return; - + + if (event.GetDamagerPlayer(true) != null && event.GetDamageePlayer() != null && event.GetDamagerPlayer(true) == event.GetDamageePlayer()) + { + event.SetCancelled("Self damage"); + return; + } + + if (!(event.GetDamagerEntity(true) instanceof Player)) + return; + + Player player = event.GetDamagerPlayer(true); + + if (!Manager.IsAlive(player)) + return; + + if (!HasKit(player)) + return; + if (event.GetProjectile() == null) return; if (!(event.GetProjectile() instanceof Egg)) return; - - event.AddMod("Chicken Kit", "Egg", 1, true); + + event.AddMod("Chicken Kit", "Egg", 2, true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitCreeper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitCreeper.java index 1f24ad9bf..7773a3efe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitCreeper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitCreeper.java @@ -1,59 +1,48 @@ package nautilus.game.arcade.game.games.evolution.mobs; +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseCreeper; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.mobs.perks.PerkSulphurBombEVO; +import nautilus.game.arcade.kit.Perk; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseCreeper; -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.PerkExplode; -import nautilus.game.arcade.kit.perks.PerkFood; - -public class KitCreeper extends Kit +public class KitCreeper extends EvoKit { + /** + * @author Mysticate + */ + public KitCreeper(ArcadeManager manager) { - super(manager, "Creeper", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkFood(1), - new PerkExplode("Detonate", 1, 6000) - }, - EntityType.SLIME, - null); - + super(manager, "Creeper", new String[] + { + C.cYellow + "Ability: " + C.cWhite + "Sulphur Bomb" + }, 28, 4, new Perk[] + { + new PerkSulphurBombEVO() + }, EntityType.CREEPER); } @Override - public void GiveItems(Player player) + protected void giveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT)); - - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Attack") + " to use " + F.elem("Detonate")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, 4f, 1f); + player.getInventory().setItem(0, new ItemBuilder(Material.SULPHUR).setTitle(C.cYellow + C.Bold + "Right Click" + C.cWhite + " - " + C.cGreen + C.Bold + "Sulphur Bomb").build()); //Disguise DisguiseCreeper disguise = new DisguiseCreeper(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); + + Manager.GetDisguise().undisguise(player); Manager.GetDisguise().disguise(disguise); + + player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, 4f, 1f); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java index 2faeb7011..60fb991dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java @@ -1,52 +1,34 @@ package nautilus.game.arcade.game.games.evolution.mobs; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -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.PerkBlink; - -public class KitEnderman extends Kit +public class KitEnderman +//extends EvoKit { - public KitEnderman(ArcadeManager manager) - { - super(manager, "Enderman", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkBlink("Blink", 12, 4000) - }, - EntityType.SLIME, - null); - - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); - - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Right-Click with Axe") + " to use " + F.elem("Blink")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_IDLE, 4f, 1f); - - - } + /** + * @author Mysticate + */ + +// public KitEnderman(ArcadeManager manager) +// { +// super(manager, "Enderman", new String[]{""}, 20, 10, new Perk[]{ +// new PerkBlockTossEVO(), +// new PerkWaterDamage(2, 1) +// }, EntityType.ENDERMAN); +// } +// +// @Override +// protected void giveItems(Player player) +// { +// player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); +// +// player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_IDLE, 4f, 1f); +// +// //Disguise +// DisguiseEnderman disguise = new DisguiseEnderman(player); +// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); +// disguise.setCustomNameVisible(true); +// +// Manager.GetDisguise().undisguise(player); +// Manager.GetDisguise().disguise(disguise); +// } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java index bbf32eb49..2e52e42a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java @@ -1,57 +1,50 @@ package nautilus.game.arcade.game.games.evolution.mobs; +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseIronGolem; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.mobs.perks.PerkSiesmicSlamEVO; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkKnockbackTaken; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseIronGolem; -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.PerkSlam; - -public class KitGolem extends Kit +public class KitGolem extends EvoKit { + /** + * @author Mysticate + */ + public KitGolem(ArcadeManager manager) { - super(manager, "Iron Golem", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkSlam("Ground Pound", 1, 1.2, 10000), - }, - EntityType.SLIME, - null); - + super(manager, "Iron Golem", new String[] + { + C.cYellow + "Abililty: " + C.cWhite + "Seismic Slam", C.Line, + C.cGreen + "50% Knockback" + }, 40, 6, new Perk[] + { + new PerkSiesmicSlamEVO(), new PerkKnockbackTaken(.5) + }, EntityType.IRON_GOLEM); } - + @Override - public void GiveItems(Player player) + protected void giveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE)); - - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Right-Click with Axe") + " to use " + F.elem("Ground Pound")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_DEATH, 4f, 1f); - + player.getInventory().setItem(0, new ItemBuilder(Material.IRON_INGOT).setTitle(C.cYellow + C.Bold + "Right Click" + C.cWhite + " - " + C.cGreen + C.Bold + "Seismic Slam").build()); + //Disguise DisguiseIronGolem disguise = new DisguiseIronGolem(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); + + Manager.GetDisguise().undisguise(player); Manager.GetDisguise().disguise(disguise); + + player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_DEATH, 4f, 1f); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java index dd6a35b17..d4831cbbb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java @@ -1,59 +1,84 @@ package nautilus.game.arcade.game.games.evolution.mobs; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseSkeleton; -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.PerkBarrage; -import nautilus.game.arcade.kit.perks.PerkFletcher; - -public class KitSkeleton extends Kit +public class KitSkeleton +//extends EvoKit { - public KitSkeleton(ArcadeManager manager) - { - super(manager, "Skeletal Archer", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkFletcher(3, 2, false), - new PerkBarrage(5, 250, true, false) - }, - EntityType.SLIME, - null); - - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); - - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Charge Bow") + " to use " + F.elem("Barrage")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.SKELETON_IDLE, 4f, 1f); - - //Disguise - DisguiseSkeleton disguise = new DisguiseSkeleton(player); - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } + /** + * @author Mysticate + */ + +// public KitSkeleton(ArcadeManager manager) +// { +// super(manager, "Skeletal Archer", +// new String[] +// { +// F.elem("Charge Bow") + " to use " + F.elem("Barrage") +// }, +// new String[] +// { +// F.elem("Charge Bow") + C.cWhite + " - " + F.elem("Barrage") +// }, +// new Perk[] +// { +// new PerkConstructor("Fletcher", 3, 2, Material.ARROW, "Fletched Arrow", false), +// new PerkBarrage(5, 250, true, false) +// }, EntityType.SKELETON); +// } +// +// @Override +// public void GiveItems(Player player) +// { +// player.getInventory().setHelmet(new ItemBuilder(Material.CHAINMAIL_HELMET).build()); +// player.getInventory().setChestplate(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE).build()); +// player.getInventory().setLeggings(new ItemBuilder(Material.CHAINMAIL_LEGGINGS).build()); +// player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).build()); +// +// player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); +// +// player.getWorld().playSound(player.getLocation(), Sound.SKELETON_IDLE, 4f, 1f); +// +// //Disguise +// DisguiseSkeleton disguise = new DisguiseSkeleton(player); +// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); +// disguise.setCustomNameVisible(true); +// +// Manager.GetDisguise().undisguise(player); +// Manager.GetDisguise().disguise(disguise); +// +// player.getInventory().setItem(8, new ItemBuilder(Material.COMPASS).setTitle(F.item("Tracking Compass")).build()); +// } +// +// @EventHandler +// public void onBowShoot(final EntityShootBowEvent event) +// { +// if (!(event.getEntity() instanceof Player)) +// return; +// +// if (!Manager.GetGame().IsLive()) +// return; +// +// final Player player = (Player) event.getEntity(); +// +// if (!HasKit(player)) +// return; +// +// EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player); +// Bukkit.getServer().getPluginManager().callEvent(useEvent); +// +// if (useEvent.isCancelled()) +// { +// event.setCancelled(true); +// +// Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() +// { +// @Override +// public void run() +// { +// UtilInv.Update(player); +// } +// }, 10); +// return; +// } +// } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSlime.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSlime.java index 1861030b1..3f0d7102c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSlime.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSlime.java @@ -1,60 +1,51 @@ package nautilus.game.arcade.game.games.evolution.mobs; +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.mobs.perks.PerkBounceEVO; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFallModifier; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseSlime; -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.PerkFallDamage; -import nautilus.game.arcade.kit.perks.PerkLeap; - -public class KitSlime extends Kit +public class KitSlime extends EvoKit { + /** + * @author Mysticate + */ + public KitSlime(ArcadeManager manager) { - super(manager, "Slime", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkLeap("Bounce", 2, 2, 8000), - new PerkFallDamage(-40) - }, - EntityType.SLIME, - null); - + super(manager, "Slime", new String[] + { + C.cYellow + "Ability: " + C.cWhite + "Slime Slam", C.Line, + C.cGreen + "50% Fall Damage" + }, 22, 4, new Perk[] + { + new PerkBounceEVO(), new PerkFallModifier(.5) + }, EntityType.SLIME); } @Override - public void GiveItems(Player player) + protected void giveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + player.getInventory().setItem(0, new ItemBuilder(Material.SLIME_BALL).setTitle(C.cYellow + C.Bold + "Right Click" + C.cWhite + " - " + C.cGreen + C.Bold + "Slime Slam").build()); - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Right-Click with Axe") + " to use " + F.elem("Bounce")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.SLIME_WALK, 4f, 1f); - //Disguise DisguiseSlime disguise = new DisguiseSlime(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); - disguise.SetSize(3); + disguise.SetSize(2); + + Manager.GetDisguise().undisguise(player); Manager.GetDisguise().disguise(disguise); + + player.getWorld().playSound(player.getLocation(), Sound.SLIME_WALK, 4f, 1f); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSnowman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSnowman.java index 305a2875c..fcf33d0aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSnowman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSnowman.java @@ -1,74 +1,110 @@ package nautilus.game.arcade.game.games.evolution.mobs; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.event.EventHandler; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseSnowman; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -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.PerkConstructor; -import nautilus.game.arcade.kit.perks.PerkFallDamage; - -public class KitSnowman extends Kit +public class KitSnowman +//extends EvoKit { - public KitSnowman(ArcadeManager manager) - { - super(manager, "Snowman", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkConstructor("Snowballer", 0.5, 16, Material.SNOW_BALL, "Snowball", false), - new PerkFallDamage(-2), - }, - EntityType.SLIME, - null); - - } - - @Override - public void GiveItems(Player player) - { - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Right-Click with Snowball") + " to use " + F.elem("Throw Snowball")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 4f, 1f); - - //Disguise - DisguiseSnowman disguise = new DisguiseSnowman(player); - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } + /** + * @author Mysticate + */ - @EventHandler - public void SnowballHit(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetProjectile() == null) - return; - - if (!(event.GetProjectile() instanceof Snowball)) - return; - - event.AddMod("Snowman Kit", "Snowball", 3, true); - } +// public KitSnowman(ArcadeManager manager) +// { +// super(manager, "Snowman", +// new String[] +// { +// F.elem("Right-Click with Snowball") + " to use " + F.elem("Throw Snowball") +// }, +// new String[] +// { +// F.elem("Recieve ") + C.cWhite + "1 Snowball / 1 Second", +// }, +// new Perk[] +// { +// new PerkConstructor("Snowballer", 1, 16, Material.SNOW_BALL, "Snowball", false) +// }, EntityType.SNOWMAN); +// } +// +// @Override +// public void GiveItems(Player player) +// { +// player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).build()); +// player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).build()); +// player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).build()); +// player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).build()); +// +// player.getInventory().setItem(0, new ItemBuilder(Material.WOOD_SPADE).build()); +// +// player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 4f, 1f); +// +// //Disguise +// DisguiseSnowman disguise = new DisguiseSnowman(player); +// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); +// disguise.setCustomNameVisible(true); +// +// Manager.GetDisguise().undisguise(player); +// Manager.GetDisguise().disguise(disguise); +// +// player.getInventory().setItem(8, new ItemBuilder(Material.COMPASS).setTitle(F.item("Tracking Compass")).build()); +// } +// +// @EventHandler +// public void onInteract(final PlayerInteractEvent event) +// { +// if (!UtilEvent.isAction(event, ActionType.R)) +// return; +// +// if (!Manager.GetGame().IsLive()) +// return; +// +// if (!HasKit(event.getPlayer())) +// return; +// +// if (!UtilGear.isMat(event.getItem(), Material.SNOW_BALL)) +// return; +// +// EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(event.getPlayer()); +// Bukkit.getServer().getPluginManager().callEvent(useEvent); +// +// if (useEvent.isCancelled()) +// { +// event.setCancelled(true); +// +// Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() +// { +// @Override +// public void run() +// { +// UtilInv.Update(event.getPlayer()); +// } +// }, 10); +// return; +// } +// } +// +// @EventHandler +// public void SnowballHit(CustomDamageEvent event) +// { +// if (!Manager.GetGame().IsLive()) +// return; +// +// if (!(event.GetDamagerEntity(true) instanceof Player)) +// return; +// +// Player player = event.GetDamagerPlayer(true); +// +// if (!Manager.IsAlive(player)) +// return; +// +// if (!HasKit(player)) +// return; +// +// if (event.GetProjectile() == null) +// return; +// +// if (!(event.GetProjectile() instanceof Snowball)) +// return; +// +// event.AddMod("Snowman Kit", "Snowball", 3, true); +// } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSpider.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSpider.java index bed99063c..95c2ec099 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSpider.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSpider.java @@ -1,57 +1,56 @@ package nautilus.game.arcade.game.games.evolution.mobs; +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSpider; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.evolution.EvoKit; +import nautilus.game.arcade.game.games.evolution.mobs.perks.PerkWebEVO; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkConstructor; +import nautilus.game.arcade.kit.perks.PerkNoFallDamage; +import nautilus.game.arcade.kit.perks.PerkSpeed; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseSpider; -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.PerkWeb; - -public class KitSpider extends Kit +public class KitSpider extends EvoKit { + /** + * @author Mysticate + */ + public KitSpider(ArcadeManager manager) { - super(manager, "Spider", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkWeb(2,8) - }, - EntityType.SLIME, - null); + super(manager, "Spider", new String[] + { + C.cYellow + "Ability: " + C.cWhite + "Web Shot", C.Line, + C.cGreen + "Speed 1", C.cGreen + "No Fall Damage" + }, 32, 5, new Perk[] + { + new PerkWebEVO(), + new PerkConstructor("Web Weaver", 3.0, 4, Material.WEB, + "Spiderweb", false), new PerkSpeed(0), + new PerkNoFallDamage() + }, EntityType.SPIDER); } @Override - public void GiveItems(Player player) + protected void giveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE)); + player.getInventory().setItem(0, new ItemBuilder(Material.SPIDER_EYE).setTitle(C.cYellow + C.Bold + "Right Click" + C.cWhite + " - " + C.cGreen + C.Bold + "Web Shot").build()); - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Right-Click with Axe/Web") + " to use " + F.elem("Throw Web")); - UtilPlayer.message(player, C.Line); - player.getWorld().playSound(player.getLocation(), Sound.SPIDER_IDLE, 4f, 1f); //Disguise DisguiseSpider disguise = new DisguiseSpider(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); + + Manager.GetDisguise().undisguise(player); + Manager.GetDisguise().disguise(disguise); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitWolf.java index a496c2b1f..eb763df81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitWolf.java @@ -1,59 +1,51 @@ package nautilus.game.arcade.game.games.evolution.mobs; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseBat; -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.PerkLeap; -import nautilus.game.arcade.kit.perks.PerkSpeed; - -public class KitWolf extends Kit +public class KitWolf +//extends EvoKit { - public KitWolf(ArcadeManager manager) - { - super(manager, "Wolf", KitAvailability.Hide, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkSpeed(2), - new PerkLeap("Pounce", 1.2, 1, 4000) - }, - EntityType.SLIME, - null); - - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE)); - - UtilPlayer.message(player, C.Line); - UtilPlayer.message(player, C.Bold + "You evolved into " + F.elem(C.cGreen + C.Bold + GetName()) + "!"); - UtilPlayer.message(player, F.elem("Right-Click with Axe") + " to use " + F.elem("Pounce")); - UtilPlayer.message(player, C.Line); - - player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 4f, 1f); - - //Disguise - DisguiseBat disguise = new DisguiseBat(player); - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } + /** + * @author Mysticate + */ + +// public KitWolf(ArcadeManager manager) +// { +// super(manager, "Wolf", +// new String[] +// { +// F.elem("Right-Click with Axe") + " to use " + F.elem("Pounce") +// }, +// new String[] +// { +// F.elem("Interact w/ Axe") + C.cWhite + " - " + F.elem("Pounce") +// }, +// new Perk[] +// { +// new PerkSpeed(1), +// new PerkPounceEVO() +// }, EntityType.WOLF); +// } +// +// @Override +// public void GiveItems(Player player) +// { +// player.getInventory().setHelmet(new ItemBuilder(Material.CHAINMAIL_HELMET).build()); +// player.getInventory().setChestplate(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE).build()); +// player.getInventory().setLeggings(new ItemBuilder(Material.CHAINMAIL_LEGGINGS).build()); +// player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).build()); +// +// player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE)); +// +// player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 4f, 1f); +// +// //Disguise +// DisguiseWolf disguise = new DisguiseWolf(player); +// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); +// disguise.setCustomNameVisible(true); +// +// Manager.GetDisguise().undisguise(player); +// Manager.GetDisguise().disguise(disguise); +// +// player.getInventory().setItem(8, new ItemBuilder(Material.COMPASS).setTitle(F.item("Tracking Compass")).build()); +// } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java new file mode 100644 index 000000000..d72652411 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java @@ -0,0 +1,238 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import java.util.HashMap; +import java.util.HashSet; + +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.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.data.BlockTossData; +import nautilus.game.arcade.kit.perks.event.PerkBlockThrowEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +public class PerkBlockTossEVO extends Perk implements IThrown +{ + /** + * @author Mysticate + */ + + private HashMap _hold = new HashMap(); + private HashMap _charge = new HashMap(); + private HashSet _charged = new HashSet(); + private HashMap _falling = new HashMap(); + + public PerkBlockTossEVO() + { + super("Block Toss", new String[] + { + + }); + } + + @SuppressWarnings("deprecation") + @EventHandler + public void Grab(PlayerInteractEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + Player player = event.getPlayer(); + + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + return; + + if (!Manager.IsAlive(player)) + return; + + if (!Kit.HasKit(player)) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player, GetName(), 6000); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.IRON_SWORD, (byte) 0)) + return; + + if (_hold.containsKey(player)) + return; + + Block grab = event.getClickedBlock(); + + if (UtilBlock.usable(grab)) + return; + + if (!UtilBlock.airFoliage(grab.getRelative(BlockFace.UP)) || Manager.GetBlockRestore().Contains(grab.getRelative(BlockFace.UP))) + { + UtilPlayer.message(player, F.main("Game", "You may not pick up that block!")); + return; + } + + if (!Recharge.Instance.use(event.getPlayer(), useEvent.getAbility(), useEvent.getCooldown(), true, true)) + return; + + //Block to Data + int id = grab.getTypeId(); + byte data = grab.getData(); + + //Remove Block + //Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, (byte)0, 10000); + event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, event.getClickedBlock().getType()); + + _hold.put(player, new BlockTossData(id, data)); + + _charge.put(player, System.currentTimeMillis()); + + //Effect + player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, id); + } + + @SuppressWarnings("deprecation") + @EventHandler + public void Throw(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + HashSet throwSet = new HashSet(); + + for (Player cur : _hold.keySet()) + { + //Throw + if (!cur.isBlocking()) + throwSet.add(cur); + + //Charged Tick + if (!_charged.contains(cur)) + if (System.currentTimeMillis() - _charge.get(cur) > 1200) + { + _charged.add(cur); + cur.playEffect(cur.getLocation(), Effect.CLICK1, 0); + } + } + + for (Player cur : throwSet) + { + BlockTossData data = _hold.remove(cur); + + FallingBlock block = cur.getWorld().spawnFallingBlock(cur.getEyeLocation().add(cur.getLocation().getDirection()), data.Type, data.Data); + + _falling.put(block, cur); + + _charged.remove(cur); + + long charge = System.currentTimeMillis() - _charge.remove(cur); + + //Throw + double mult = 1.4; + if (charge < 1200) + mult = mult * ((double)charge/1200d); + + //Action + UtilAction.velocity(block, cur.getLocation().getDirection(), mult, false, 0.2, 0, 1, true); + Manager.GetProjectile().AddThrow(block, cur, this, -1, true, true, true, + null, 0, 0, null, 0, UpdateType.FASTEST, 1f); + + //Event + PerkBlockThrowEvent blockEvent = new PerkBlockThrowEvent(cur); + UtilServer.getServer().getPluginManager().callEvent(blockEvent); + } + } + + @SuppressWarnings("deprecation") + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target == null) + return; + + //Damage Event + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, + DamageCause.PROJECTILE, data.GetThrown().getVelocity().length() * 4, true, true, false, + UtilEnt.getName(data.GetThrower()), GetName()); + + //Block to Item + if (data.GetThrown() instanceof FallingBlock) + { + FallingBlock thrown = (FallingBlock) data.GetThrown(); + + FallingBlock newThrown = data.GetThrown().getWorld().spawnFallingBlock(data.GetThrown().getLocation(), thrown.getMaterial(), (byte)0); + + //Remove Old + _falling.remove(thrown); + thrown.remove(); + + //Add New + if (data.GetThrower() instanceof Player) + _falling.put(newThrown, (Player)data.GetThrower()); + } + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + + } + + + @SuppressWarnings("deprecation") + @EventHandler + public void BlockForm(EntityChangeBlockEvent event) + { + if (!(event.getEntity() instanceof FallingBlock)) + return; + + FallingBlock falling = (FallingBlock)event.getEntity(); + + falling.getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, falling.getBlockId()); + + _falling.remove(falling); + falling.remove(); + + event.setCancelled(true); + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + return; + + event.AddKnockback(GetName(), 2.5); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBounceEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBounceEVO.java new file mode 100644 index 000000000..063a22493 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBounceEVO.java @@ -0,0 +1,188 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +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.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +public class PerkBounceEVO extends Perk +{ + /** + * @author Mysticate + */ + + private NautHashMap _live = new NautHashMap(); + + public PerkBounceEVO() + { + super("Slime Slam", new String[] + { + }); + } + + //Literally just the slime slam code ;D + @EventHandler + public void Leap(PlayerInteractEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.SLIME_BALL, (byte) 0)) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player, GetName(), 7000); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + if (!Recharge.Instance.use(player, useEvent.getAbility(), useEvent.getCooldown(), true, true)) + return; + + UtilAction.velocity(player, player.getLocation().getDirection(), 1.6, false, 0, 0.4, .4, true); + + //Record + _live.put(player, System.currentTimeMillis()); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + player.playSound(player.getLocation(), Sound.SLIME_WALK, 1, 1); + + UtilParticle.PlayParticle(ParticleType.SLIME, player.getLocation(), .5F, .5F, .5F, 0F, 5, ViewDist.NORMAL, UtilServer.getPlayers()); + } + + @EventHandler + public void collide(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + //Collide + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { + _live.remove(player); + continue; + } + + if (!_live.containsKey(player)) + continue; + + for (Player cur : UtilPlayer.getNearby(player.getLocation(), 2.0)) + { + if (!Manager.IsAlive(cur)) + continue; + + if (UtilPlayer.isSpectator(cur)) + { + _live.remove(player); + continue; + } + + if (cur == player) + continue; + + DoSlam(player, cur); + _live.remove(player); + break; + } + } + } + + @EventHandler + public void end(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + //End + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + continue; + + if (!UtilEnt.isGrounded(player)) + continue; + + if (!_live.containsKey(player)) + continue; + + if (!UtilTime.elapsed(_live.get(player), 1000)) + continue; + + _live.remove(player); + } + } + + public void DoSlam(Player damager, LivingEntity damagee) + { + int damage = 8; + + //Damage Event + Manager.GetDamage().NewDamageEvent(damagee, damager, null, + DamageCause.CUSTOM, damage, true, true, false, + damager.getName(), GetName()); + + UtilAction.velocity(damager, new Vector()); + + //Inform + UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(GetName()) + ".")); + UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(GetName()) + ".")); + + damager.playSound(damager.getLocation(), Sound.SLIME_ATTACK, 1, 1); + UtilParticle.PlayParticle(ParticleType.SLIME, damager.getLocation(), .5F, .5F, .5F, 0F, 5, ViewDist.NORMAL, UtilServer.getPlayers()); + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + return; + + event.AddKnockback(GetName(), 2); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkDoubleJumpEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkDoubleJumpEVO.java new file mode 100644 index 000000000..11978b075 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkDoubleJumpEVO.java @@ -0,0 +1,137 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import java.util.HashSet; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerToggleFlightEvent; + +public class PerkDoubleJumpEVO extends Perk +{ + private double _power; + private double _heightMax; + private boolean _control; + private long _recharge; + private boolean _displayForce; + + private HashSet _disabled = new HashSet(); + + public PerkDoubleJumpEVO(String name, double power, double heightLimit, boolean control) + { + super(name, new String[0]); + + _power = power; + _heightMax = heightLimit; + _control = control; + _recharge = 0; + _displayForce = false; + } + + public PerkDoubleJumpEVO(String name, double power, double heightLimit, boolean control, long recharge, boolean displayForce) + { + super(name, new String[0]); + + _power = power; + _heightMax = heightLimit; + _control = control; + _recharge = recharge; + _displayForce = displayForce; + } + + @EventHandler + public void FlightHop(PlayerToggleFlightEvent event) + { + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (Manager.isSpectator(player)) + return; + + if (player.getGameMode() == GameMode.CREATIVE) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player, GetName(), 0); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + event.setCancelled(true); + player.setFlying(false); + + //Disable Flight + player.setAllowFlight(false); + + //Velocity + if (_control) + { + UtilAction.velocity(player, _power, 0.2, _heightMax, true); + } + else + { + UtilAction.velocity(player, player.getLocation().getDirection(), _power, true, _power, 0, _heightMax, true); + } + + //Sound + player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); + + //Recharge + if (_recharge > 0) + { + Recharge.Instance.useForce(player, GetName(), _recharge); + + if (_displayForce) + { + Recharge.Instance.setDisplayForce(player, GetName(), true); + } + } + } + + @EventHandler + public void FlightUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (Manager.isSpectator(player)) + continue; + + if (!Kit.HasKit(player)) + continue; + + if (_recharge > 0 && !Recharge.Instance.usable(player, GetName())) + continue; + + if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) + player.setAllowFlight(true); + } + } + + public void disableForPlayer(Player player) + { + _disabled.add(player); + } + + public void enableForPlayer(Player player) + { + _disabled.remove(player); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkFlamingSwordEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkFlamingSwordEVO.java new file mode 100644 index 000000000..6e226b34e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkFlamingSwordEVO.java @@ -0,0 +1,139 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +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.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +public class PerkFlamingSwordEVO extends Perk +{ + /** + * @author Mysticate + */ + + private NautHashMap _active = new NautHashMap(); + + public PerkFlamingSwordEVO() + { + super("Flamethrower", new String[] + { + C.cYellow + "Block" + C.cGray + " to use " + C.cGreen + "Flamethrower" + }); + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!Manager.GetGame().IsLive()) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.BLAZE_ROD, (byte) 0)) + return; + + if (!Manager.IsAlive(event.getPlayer())) + return; + + if (_active.containsKey(event.getPlayer())) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(event.getPlayer(), GetName(), 5000); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + if (!Recharge.Instance.use(event.getPlayer(), useEvent.getAbility(), useEvent.getCooldown(), true, true)) + return; + + _active.put(event.getPlayer(), System.currentTimeMillis()); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + Iterator> iterator = _active.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + + if (entry.getKey() == null || !entry.getKey().isOnline()) + { + iterator.remove(); + continue; + } + + if (!Manager.IsAlive(entry.getKey())) + { + iterator.remove(); + continue; + } + + if (UtilPlayer.isSpectator(entry.getKey())) + { + iterator.remove(); + continue; + } + + if (UtilTime.elapsed(entry.getValue(), 1000)) + { + iterator.remove(); + continue; + } + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(entry.getKey(), GetName(), 0); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + continue; + + flame(useEvent.getPlayer()); + } + } + + private void flame(Player player) + { + //Fire + Item fire = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER)); + Manager.GetFire().Add(fire, player, 0.7, 0, 0.5, 1, "Inferno"); + + fire.teleport(player.getEyeLocation()); + double x = 0.07 - (UtilMath.r(14)/100d); + double y = 0.07 - (UtilMath.r(14)/100d); + double z = 0.07 - (UtilMath.r(14)/100d); + fire.setVelocity(player.getLocation().getDirection().add(new Vector(x,y,z)).multiply(1.6)); + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 0.1f, 1f); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkPounceEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkPounceEVO.java new file mode 100644 index 000000000..cc4c021ed --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkPounceEVO.java @@ -0,0 +1,162 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +public class PerkPounceEVO extends Perk +{ + /** + * @author Mysticate + */ + + private NautHashMap _live = new NautHashMap(); + + public PerkPounceEVO() + { + super("Pounce", new String[] + { + }); + } + + //Literally just the slime slam code ;D + @EventHandler + public void Leap(PlayerInteractEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.WOOD_AXE, (byte) 0)) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player, GetName(), 6000); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + if (!Recharge.Instance.use(player, useEvent.getAbility(), useEvent.getCooldown(), true, true)) + return; + + UtilAction.velocity(player, player.getLocation().getDirection(), 1.4, false, 0, 0.3, 1.8, false); + + //Record + _live.put(player, System.currentTimeMillis()); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void collide(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + //Collide + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!_live.containsKey(player)) + continue; + + for (Player cur : UtilPlayer.getNearby(player.getLocation(), 2.0)) + { + if (!Manager.IsAlive(cur)) + continue; + + if (cur == player) + continue; + + DoSlam(player, cur); + _live.remove(player); + return; + } + } + } + + @EventHandler + public void end(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + //End + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!UtilEnt.isGrounded(player)) + continue; + + if (!_live.containsKey(player)) + continue; + + if (!UtilTime.elapsed(_live.get(player), 1000)) + continue; + + _live.remove(player); + } + } + + public void DoSlam(Player damager, LivingEntity damagee) + { + int damage = 6; + + //Damage Event + Manager.GetDamage().NewDamageEvent(damagee, damager, null, + DamageCause.CUSTOM, damage, true, true, false, + damager.getName(), GetName()); + + UtilAction.velocity(damager, new Vector()); + + //Inform + UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(GetName()) + ".")); + UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + return; + + event.AddKnockback(GetName(), .5); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSiesmicSlamEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSiesmicSlamEVO.java new file mode 100644 index 000000000..02435d894 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSiesmicSlamEVO.java @@ -0,0 +1,172 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import java.util.HashMap; + +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.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +public class PerkSiesmicSlamEVO extends Perk +{ + /** + * @author Mysticate + */ + + private HashMap _live = new HashMap(); + + public PerkSiesmicSlamEVO() + { + super("Seismic Slam", new String[0]); + } + + @EventHandler + public void deactivateDeath(PlayerDeathEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!Kit.HasKit(event.getEntity())) + return; + + if (_live.containsKey(event.getEntity())) + { + _live.remove(event.getEntity()); + } + } + + @EventHandler + public void Leap(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (!Manager.GetGame().IsLive()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.IRON_INGOT, (byte) 0)) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player, GetName(), 7000); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + if (!Recharge.Instance.use(player, useEvent.getAbility(), useEvent.getCooldown(), true, true)) + return; + + //Action + Vector vec = player.getLocation().getDirection(); + if (vec.getY() < 0) + vec.setY(vec.getY() * -1); + + UtilAction.velocity(player, vec, 1, true, 1, 0, 1, true); + + //Record + _live.put(player, System.currentTimeMillis()); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } + + @SuppressWarnings("deprecation") + @EventHandler + public void Slam(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!_live.containsKey(player)) + continue; + + if (UtilPlayer.isSpectator(player)) + { + _live.remove(player); + continue; + } + + if (!player.isOnGround()) + continue; + + if (!UtilTime.elapsed(_live.get(player), 1000)) + continue; + + _live.remove(player); + + //Action + int damage = 16; + double range = 6; + + HashMap targets = UtilPlayer.getInRadius(player.getLocation(), range); + for (Player cur : targets.keySet()) + { + if (cur == player) + continue; + + if (!Manager.IsAlive((Player) cur)) + continue; + + //Damage Event + Manager.GetDamage().NewDamageEvent(cur, player, null, + DamageCause.CUSTOM, damage * targets.get(cur) + 0.5, true, true, false, + player.getName(), GetName()); + + //Condition + Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); + } + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 2f, 0.2f); + for (Block cur : UtilBlock.getInRadius(player.getLocation(), range).keySet()) + if (UtilBlock.airFoliage(cur.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(cur)) + cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getTypeId()); + } + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + return; + + event.AddKnockback(GetName(), 2.4); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java new file mode 100644 index 000000000..a11c63035 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java @@ -0,0 +1,136 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +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.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +public class PerkSulphurBombEVO extends Perk implements IThrown +{ + /** + * @author Mysticate + */ + + public PerkSulphurBombEVO() + { + super("Sulphur Bomb", new String[] + { + + }); + } + + @EventHandler + public void fire(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.SULPHUR, (byte) 0)) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player, GetName(), 3000); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + if (!Recharge.Instance.use(player, useEvent.getAbility(), useEvent.getCooldown(), true, true)) + return; + + event.setCancelled(true); + + Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0)); + + UtilAction.velocity(ent, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false); + + Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, + null, 1f, 1f, + Effect.SMOKE, 1, UpdateType.SLOW, + 1f); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.CREEPER_DEATH, 2f, 1.5f); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Explode(data); + + if (target == null) + return; + + //Damage Event + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, + DamageCause.PROJECTILE, 5, true, true, false, + UtilEnt.getName(data.GetThrower()), GetName()); + } + + @Override + public void Idle(ProjectileUser data) + { + Explode(data); + } + + @Override + public void Expire(ProjectileUser data) + { + Explode(data); + } + + public void Explode(ProjectileUser data) + { + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.GetThrown().getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + data.GetThrown().getWorld().playSound(data.GetThrown().getLocation(), Sound.EXPLODE, 1f, 1.5f); + data.GetThrown().remove(); + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + return; + + event.AddKnockback(GetName(), 1.5); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java new file mode 100644 index 000000000..7abe68567 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java @@ -0,0 +1,116 @@ +package nautilus.game.arcade.game.games.evolution.mobs.perks; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +public class PerkWebEVO extends Perk implements IThrown +{ + /** + * @author Mysticate + */ + + public PerkWebEVO() + { + super("Web Shot", new String[0]); + } + + @EventHandler + public void Throw(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!Manager.GetGame().IsLive()) + return; + + if (!Manager.IsAlive(event.getPlayer())) + return; + + if (!UtilInv.contains(event.getPlayer(), Material.WEB, (byte) 0, 1)) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.SPIDER_EYE, (byte) 0)) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + EvolutionAbilityUseEvent useEvent = new EvolutionAbilityUseEvent(player, GetName(), 0); + Bukkit.getServer().getPluginManager().callEvent(useEvent); + + if (useEvent.isCancelled()) + return; + + event.setCancelled(true); + + UtilInv.remove(player, Material.WEB, (byte) 0, 1); + UtilInv.Update(player); + + Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.WEB)); + UtilAction.velocity(ent, player.getLocation().getDirection(), 0.8, false, 0, 0.2, 10, false); + Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 1f); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target != null) + { + if (target instanceof Player) + { + if (Manager.GetGame().IsAlive((Player)target)) + { + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, DamageCause.CUSTOM, 8, false, false, false, "Web Shot", "Webbed Net"); + target.playEffect(EntityEffect.HURT); + } + else + { + return; + } + } + } + + Web(data); + } + + @Override + public void Idle(ProjectileUser data) + { + Web(data); + } + + @Override + public void Expire(ProjectileUser data) + { + Web(data); + } + + public void Web(ProjectileUser data) + { + Location loc = data.GetThrown().getLocation(); + data.GetThrown().remove(); + + Manager.GetBlockRestore().Add(loc.getBlock(), 30, (byte)0, 4000); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/EvoWinWithoutDyingTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/EvoWinWithoutDyingTracker.java new file mode 100644 index 000000000..35c33b3e3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/EvoWinWithoutDyingTracker.java @@ -0,0 +1,65 @@ +package nautilus.game.arcade.game.games.evolution.trackers; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class EvoWinWithoutDyingTracker extends StatTracker +{ + private List _out = new ArrayList(); + + public EvoWinWithoutDyingTracker(Evolution evo) + { + super(evo); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.GetLog().GetPlayer() == null) + return; + + if (!event.GetLog().GetPlayer().IsPlayer()) + return; + + Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); + if (player == null || !player.isOnline()) + return; + + _out.add(player.getUniqueId().toString()); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + List winners = getGame().getWinners(); + if (winners == null) + return; + + if (winners.size() < 1) + return; + + Player winner = winners.get(0); + + if (_out.contains(winner.getUniqueId().toString())) + return; + + addStat(winner, "NoDeaths", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/KillsWhileEvolvingTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/KillsWhileEvolvingTracker.java new file mode 100644 index 000000000..52fc68890 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/KillsWhileEvolvingTracker.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.evolution.trackers; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class KillsWhileEvolvingTracker extends StatTracker +{ + /** + * @author Mysticate + */ + + public KillsWhileEvolvingTracker(Evolution game) + { + super(game); + } + + @EventHandler + public void onDamage(CombatDeathEvent event) + { + if (!getGame().IsLive()) + return; + + Player damagee = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); + Player damager = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (damagee == null || damager == null) + return; + + if (!getGame().IsAlive(damagee) || !getGame().IsAlive(damager)) + return; + + if (getGame().isAttemptingEvolve(damagee)) + addStat(damager, "EvolveKill", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoAbilityTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoAbilityTracker.java new file mode 100644 index 000000000..655eb6f79 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoAbilityTracker.java @@ -0,0 +1,64 @@ +package nautilus.game.arcade.game.games.evolution.trackers; + +import java.util.ArrayList; +import java.util.List; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class NoAbilityTracker extends StatTracker +{ + /** + * @author Mysticate + */ + + private List _out = new ArrayList(); + + public NoAbilityTracker(Evolution game) + { + super(game); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onEvolutionAbility(EvolutionAbilityUseEvent event) + { + if (!getGame().IsLive()) + return; + + if (!getGame().IsAlive(event.getPlayer())) + return; + + if (_out.contains(event.getPlayer().getUniqueId().toString())) + return; + + _out.add(event.getPlayer().getUniqueId().toString()); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + List winners = getGame().getWinners(); + if (winners == null) + return; + + if (winners.size() < 1) + return; + + Player winner = winners.get(0); + + if (_out.contains(winner.getUniqueId().toString())) + return; + + addStat(winner, "MeleeOnly", 1, true, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoDamageWhileEvolvingTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoDamageWhileEvolvingTracker.java new file mode 100644 index 000000000..3cfa2efd6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoDamageWhileEvolvingTracker.java @@ -0,0 +1,71 @@ +package nautilus.game.arcade.game.games.evolution.trackers; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class NoDamageWhileEvolvingTracker extends StatTracker +{ + /** + * @author Mysticate + */ + + private List _out = new ArrayList(); + + public NoDamageWhileEvolvingTracker(Evolution game) + { + super(game); + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (!getGame().IsLive()) + return; + + Player player = event.GetDamageePlayer(); + if (player == null) + return; + + if (!getGame().IsAlive(player)) + return; + + if (!getGame().isAttemptingEvolve(player)) + return; + + if (_out.contains(player.getUniqueId().toString())) + return; + + _out.add(player.getUniqueId().toString()); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + List winners = getGame().getWinners(); + if (winners == null) + return; + + if (winners.size() < 1) + return; + + Player winner = winners.get(0); + + if (_out.contains(winner.getUniqueId().toString())) + return; + + addStat(winner, "Stealth", 1, true, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoMeleeTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoMeleeTracker.java new file mode 100644 index 000000000..bc3712ae1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoMeleeTracker.java @@ -0,0 +1,71 @@ +package nautilus.game.arcade.game.games.evolution.trackers; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class NoMeleeTracker extends StatTracker +{ + /** + * @author Mysticate + */ + + private List _out = new ArrayList(); + + public NoMeleeTracker(Evolution game) + { + super(game); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onDamage(CustomDamageEvent event) + { + if (!getGame().IsLive()) + return; + + Player player = event.GetDamagerPlayer(true); + if (player == null) + return; + + if (!getGame().IsAlive(player)) + return; + + if (event.GetReason() != null && new String(event.GetReason()).toLowerCase().contains("attack")) + { + if (_out.contains(player.getUniqueId().toString())) + return; + + _out.add(player.getUniqueId().toString()); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + List winners = getGame().getWinners(); + if (winners == null) + return; + + if (winners.size() < 1) + return; + + Player winner = winners.get(0); + + if (_out.contains(winner.getUniqueId().toString())) + return; + + addStat(winner, "AbilityOnly", 1, true, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index 28bc955d8..bb7fa45b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -837,6 +837,9 @@ public class HideSeek extends TeamGame @EventHandler public void UseBoost(PlayerInteractEvent event) { + if (!IsLive()) + return; + Player player = event.getPlayer(); if (!UtilEvent.isAction(event, ActionType.R)) @@ -901,6 +904,9 @@ public class HideSeek extends TeamGame @EventHandler public void UseMeow(PlayerInteractEvent event) { + if (!IsLive()) + return; + Player player = event.getPlayer(); if (!UtilEvent.isAction(event, ActionType.R)) @@ -927,6 +933,9 @@ public class HideSeek extends TeamGame @EventHandler public void UseFirework(PlayerInteractEvent event) { + if (!IsLive()) + return; + Player player = event.getPlayer(); if (!UtilEvent.isAction(event, ActionType.R)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java index e43c1adb1..5a7f6a0de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java @@ -130,11 +130,6 @@ public class BombLobbers extends TeamGame implements IThrown _kills.put(player, _kills.containsKey(player) ? _kills.get(player) + 1 : 1); } - public void addAssist(Player player) - { - _kills.put(player, _kills.containsKey(player) ? _kills.get(player) + .5 : .5); - } - public double getKills(Player player) { if (_kills.containsKey(player)) @@ -172,10 +167,6 @@ public class BombLobbers extends TeamGame implements IThrown { addKill(killer); } - else - { - addAssist(killer); - } } } } @@ -228,11 +219,23 @@ public class BombLobbers extends TeamGame implements IThrown tnt.setFuseTicks(60); UtilAction.velocity(tnt, player.getLocation().getDirection(), 2.0D, false, 0.0D, 0.1D, 10.0D, false); - Manager.GetProjectile().AddThrow(tnt, player, this, -1L, true, false, true, .2F); - + + ArrayList canHit = new ArrayList(); + for (Player pos : GetPlayers(true)) + { + if (GetTeam(player).HasPlayer(pos)) + continue; + + canHit.add(pos); + } + + Manager.GetProjectile().AddThrow(tnt, player, this, -1L, true, false, true, .2F, canHit); + Manager.getPlugin().getServer().getPluginManager().callEvent(new TNTThrowEvent(player, tnt)); _tnt.put(tnt, new BombToken(player)); + + AddGems(player, 0.5, "TNT Thrown", true, true); } public Player getThrower(TNTPrimed tnt) @@ -562,6 +565,8 @@ public class BombLobbers extends TeamGame implements IThrown UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown().getLocation(), target.getLocation()), .2, false, 0, 0.2, .4, true); Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 10.0, false, false, false, "Throwing TNT", "Throwing TNT Direct Hit"); + + AddGems((Player) data.GetThrower(), 4.0, "Direct Hit", true, true); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index e01db1c83..5359d0fa7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -4,6 +4,33 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +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.SoloGame; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; +import nautilus.game.arcade.game.games.milkcow.kits.KitCow; +import nautilus.game.arcade.game.games.milkcow.kits.KitFarmerJump; +import nautilus.game.arcade.game.games.milkcow.kits.KitSturdyFarmhand; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.NullKit; +import net.minecraft.server.v1_7_R4.EntityCreature; +import net.minecraft.server.v1_7_R4.Navigation; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -25,31 +52,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -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.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.visibility.VisibilityManager; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -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.SoloGame; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.milkcow.kits.*; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import net.minecraft.server.v1_7_R4.EntityCreature; -import net.minecraft.server.v1_7_R4.Navigation; - public class MilkCow extends SoloGame { private GameTeam _farmers; @@ -73,6 +75,7 @@ public class MilkCow extends SoloGame new Kit[] { new KitFarmerJump(manager), + new KitSturdyFarmhand(manager), new NullKit(manager), new KitCow(manager), }, @@ -112,7 +115,7 @@ public class MilkCow extends SoloGame { if (team.GetColor() == ChatColor.RED) { - if (kit.GetName().contains("Farmer")) + if (kit.GetName().contains("Farm")) team.GetRestrictedKits().add(kit); } else @@ -288,13 +291,17 @@ public class MilkCow extends SoloGame SetPlayerTeam(player, _cows, true); //Kit - Kit newKit = GetKits()[2]; + Kit newKit = GetKits()[3]; SetKit(player, newKit, false); newKit.ApplyKit(player); //Refresh VisibilityManager.Instance.refreshPlayerToAll(player); + + //Turn off flight + player.setAllowFlight(false); + player.setFlying(false); if (forced) { @@ -345,7 +352,9 @@ public class MilkCow extends SoloGame @EventHandler public void LoseMilk(PlayerDeathEvent event) { - SetScore(event.getEntity(), Math.max(0, GetScore(event.getEntity()) - 5)); + MilkRemoveEvent e = new MilkRemoveEvent(event.getEntity(), 5, RemoveType.DEATH); + Bukkit.getPluginManager().callEvent(e); + SetScore(event.getEntity(), Math.max(0, GetScore(event.getEntity()) - e.GetMilk())); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java new file mode 100644 index 000000000..5ac777588 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.milkcow; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class MilkRemoveEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private Player _player; + private int _milk; + private RemoveType _cause; + + public MilkRemoveEvent(Player player, int milk, RemoveType cause) + { + _player = player; + _milk = milk; + _cause = cause; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Player GetPlayer() + { + return _player; + } + + public int GetMilk() + { + return _milk; + } + + public RemoveType GetCause() + { + return _cause; + } + + public void SetMilk(int milk) + { + _milk = milk; + } + + public static enum RemoveType + { + FLING, DEATH; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java index d196e224f..68be2fd6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java @@ -33,7 +33,7 @@ public class KitCow extends AbbreviatedKit new PerkKnockbackMultiplier(4), new PerkCharge(), new PerkCowBomb(), - new PerkSeismicCow(), + new PerkSeismicCow("Body Slam"), }, EntityType.COW, null); @@ -67,7 +67,7 @@ public class KitCow extends AbbreviatedKit new String[] { ChatColor.RESET + "Charge with great power, flinging", - ChatColor.RESET + "filthy farmers out of your way!", + ChatColor.RESET + "filthy farmers out of your way, making them drop the milk in their buckets!", })); //Disguise diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java new file mode 100644 index 000000000..feeb802d1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java @@ -0,0 +1,51 @@ +package nautilus.game.arcade.game.games.milkcow.kits; + +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.event.UpdateEvent; +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.PerkIronSkin; +import nautilus.game.arcade.kit.perks.PerkNoSpillMilk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +public class KitSturdyFarmhand extends Kit +{ + public KitSturdyFarmhand(ArcadeManager manager) + { + super(manager, "Sturdy Farmhand", KitAvailability.Gem, 2000, + + new String[] + { + "Been working on the ranch so long, even a charging bull can't faze him!" + }, + + new Perk[] + { + new PerkNoSpillMilk(manager), + new PerkIronSkin(2), + }, + + EntityType.ZOMBIE, + new ItemStack(Material.IRON_SPADE)); + + } + + @EventHandler + public void FireItemResist(UpdateEvent event) + { + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BUCKET)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index eddcab047..c0dbe5c9e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -255,6 +255,8 @@ public class MineStrike extends TeamGame this.StrictAntiHack = true; + AnnounceStay = false; + this.HungerSet = 20; this.ItemDrop = true; @@ -1873,7 +1875,11 @@ public class MineStrike extends TeamGame ChatColor color = ChatColor.GRAY; if (winner != null) { - winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " has won the round!"; + if(winner.GetName().contains("Bombers")) { + winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " have won the round!"; + } else { + winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " has won the round!"; + } addScore(winner); drawScoreboard(); color = winner.GetColor(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index 9793ac98c..731d049e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -79,6 +79,8 @@ public class Quiver extends SoloGame this.PrepareFreeze = false; this.BlockBreakAllow.add(102); this.BlockBreakAllow.add(20); + this.BlockBreakAllow.add(Material.STAINED_GLASS_PANE.getId()); + this.BlockBreakAllow.add(Material.STAINED_GLASS.getId()); this.DeathSpectateSecs = 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index 00eb0798a..6feb9d7d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -146,6 +146,8 @@ public abstract class Skywars extends Game PrepareFreeze = true; + AnnounceStay = false; + HideTeamSheep = true; CompassEnabled = true; @@ -962,8 +964,13 @@ public abstract class Skywars extends Game if (event.GetDamage() >= 1) return; - if(GetTeam(event.GetDamagerPlayer(true)) == GetTeam(event.GetDamageePlayer())) - return; + if(this instanceof TeamSkywars) + { + if(GetTeam(event.GetDamagerPlayer(true)) == GetTeam(event.GetDamageePlayer())) + { + return; + } + } if (event.GetProjectile() instanceof Egg || event.GetProjectile() instanceof Snowball) { @@ -996,6 +1003,10 @@ public abstract class Skywars extends Game { if(event.getEntity() instanceof Player) { + + if(this instanceof SoloSkywars) + return; + if(GetTeam((Player) prj.getShooter()) == GetTeam((Player) event.getEntity())) { event.setCancelled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java index c9d231bd0..17eaf5a5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java @@ -178,14 +178,14 @@ public class Spleef extends SoloGame BlockFade(event.getBlock(), event.getPlayer(), false); //Snowball - if (GetKit(event.getPlayer()) instanceof KitSnowballer) + if (GetKit(event.getPlayer()) instanceof KitSnowballer && event.getBlock().getType() != Material.BEDROCK) if (!UtilInv.contains(event.getPlayer(), Material.SNOW_BALL, (byte)0, 16)) event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL)); } public void BlockFade(Block block, Player player, boolean slowDamage) { - if (block.getTypeId() == 7) + if (block.getType() == Material.BEDROCK || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) return; //Prevent Super Hunger from Bow diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 0e984eb4c..a7699db24 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -13,9 +13,7 @@ import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; import org.bukkit.block.Furnace; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLargeFireball; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Boat; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; @@ -56,7 +54,6 @@ import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; -import org.bukkit.scoreboard.TeamNameTagVisibility; import org.bukkit.util.Vector; import mineplex.core.common.util.C; @@ -74,16 +71,11 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; -import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.*; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketPlayOutWorldBorder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -97,22 +89,18 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.survivalgames.kit.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; -import net.minecraft.server.v1_7_R4.EntityArrow; import net.minecraft.server.v1_7_R4.EntityLargeFireball; -import net.minecraft.server.v1_7_R4.PacketPlayInUseEntity; import net.minecraft.server.v1_7_R4.PacketPlayOutScoreboardTeam; import net.minecraft.server.v1_7_R4.ScoreboardTeam; import net.minecraft.server.v1_7_R4.TileEntity; import net.minecraft.server.v1_7_R4.TileEntityChest; import net.minecraft.server.v1_7_R4.WorldServer; -import net.minecraft.util.com.mojang.authlib.GameProfile; public abstract class SurvivalGames extends Game { @@ -156,8 +144,6 @@ public abstract class SurvivalGames extends Game private Field _nameTagVisibility; private Field _packetTeam; - private IPacketHandler _useEntityPacketHandler; - private int _deadBodyCount; private int _chestRefillTime = 60 * 7; private NautHashMap _openedChests = new NautHashMap(); @@ -210,6 +196,8 @@ public abstract class SurvivalGames extends Game StrictAntiHack = true; + AnnounceStay = false; + HideTeamSheep = true; this.ReplaceTeamsWithKits = true; @@ -237,6 +225,7 @@ public abstract class SurvivalGames extends Game PrepareTime = 15000; VersionRequire1_8 = true; + DeadBodies = true; BlockBreakAllow.add(Material.WEB.getId()); // Web BlockPlaceAllow.add(Material.WEB.getId()); @@ -283,24 +272,6 @@ public abstract class SurvivalGames extends Game ex.printStackTrace(); } - _useEntityPacketHandler = new IPacketHandler() - { - @Override - public void handle(PacketInfo packetInfo) - { - if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) - { - net.minecraft.server.v1_7_R4.Entity entity = ((PacketPlayInUseEntity) packetInfo.getPacket()) - .a(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle()); - - if (entity instanceof EntityArrow) - { - packetInfo.setCancelled(true); - } - } - } - }; - registerStatTrackers(new WinWithoutWearingArmorStatTracker(this), new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"), new FirstSupplyDropOpenStatTracker(this), new SimultaneousSkeletonStatTracker(this, 5)); } @@ -786,126 +757,6 @@ public abstract class SurvivalGames extends Game } } - private BlockFace getFace(Location loc) - { - Block block = loc.getBlock(); - - while (block.getY() > 0 && !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)) - && !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) - { - block = block.getRelative(BlockFace.DOWN); - } - - BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3].getOppositeFace(); - - // A complicated way to get the face the dead body should be towards. - for (HashSet validBlocks : new HashSet[] - { - UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet - }) - { - - if (validBlocks.contains((byte) block.getRelative(proper).getTypeId())) - { - return proper; - } - - for (BlockFace face : new BlockFace[] - { - BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH, BlockFace.WEST - }) - { - if (validBlocks.contains((byte) block.getRelative(face).getTypeId())) - { - return face; - } - } - } - - return proper; - } - - private void deathOrQuit(Player player) - { - String name = ""; - - for (char c : ("" + _deadBodyCount++).toCharArray()) - { - name += "§" + c; - } - - try - { - - Team team = Scoreboard.GetScoreboard().registerNewTeam(name); - - if (!_hiddenNames.get(player).isEmpty()) - { - ScoreboardTeam nmsTeam = (ScoreboardTeam) _packetTeam.get(team); - - PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(nmsTeam, 2); - - Field teamName = PacketPlayOutScoreboardTeam.class.getDeclaredField("a"); - teamName.setAccessible(true); - Field displayName = PacketPlayOutScoreboardTeam.class.getDeclaredField("b"); - displayName.setAccessible(true); - - for (Player alive : GetPlayers(true)) - { - if (_hiddenNames.get(player).contains(alive.getName())) - { - teamName.set(packet, alive.getName()); - displayName.set(packet, alive.getName()); - - UtilPlayer.sendPacket(player, packet); - } - } - } - - _hiddenNames.remove(player); - - team.setNameTagVisibility(TeamNameTagVisibility.NEVER); - team.addEntry(name); - - PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam((ScoreboardTeam) _packetTeam.get(team), 2); - - for (Player alive : GetPlayers(false)) - { - UtilPlayer.sendPacket(alive, packet); - } - - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - GameProfile newProfile = new GameProfile(UUID.randomUUID(), name); - - newProfile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); - - DisguisePlayer disguise = new DisguisePlayer(null, newProfile); - - disguise.setSleeping(getFace(player.getLocation())); - - getArcadeManager().GetDisguise().addFutureDisguise(disguise); - - Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW); - - try - { - EntityArrow entityArrow = ((CraftArrow) entity).getHandle(); - - Field at = EntityArrow.class.getDeclaredField("at"); - at.setAccessible(true); - at.set(entityArrow, Integer.MIN_VALUE); // Despawn time - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - @EventHandler public void DisableDamageLevel(CustomDamageEvent event) { @@ -1026,19 +877,6 @@ public abstract class SurvivalGames extends Game return 12; } - @EventHandler - public void handleEntityPacket(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Live) - { - getArcadeManager().getPacketHandler().addPacketHandler(_useEntityPacketHandler); - } - else if (event.GetState() == GameState.Dead) - { - getArcadeManager().getPacketHandler().removePacketHandler(_useEntityPacketHandler); - } - } - // If an item spawns and no one is there to see it, does it really spawn? No. @EventHandler public void ItemSpawn(ItemSpawnEvent event) @@ -1541,8 +1379,6 @@ public abstract class SurvivalGames extends Game Player player = (Player) event.GetEvent().getEntity(); - deathOrQuit(player); - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL_LARGE).trail(false) .build(); for (int i = 0; i < 3; i++) @@ -1671,8 +1507,7 @@ public abstract class SurvivalGames extends Game return; } - deathOrQuit(event.getPlayer()); - + _hiddenNames.remove(event.getPlayer()); } private void setBorder() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java index e64d87f04..baf59a0bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -42,8 +42,11 @@ public class TeamSurvivalGames extends SurvivalGames new String[] { "Search for chests to find loot", + "Slaughter your opponents", - "Stay away from the Deep Freeze!", + + "Stay away from the borders!", + "Last team alive wins!" }); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 7b4477a05..3e4b5c774 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -31,6 +31,7 @@ import nautilus.game.arcade.stats.BehindEnemyLinesStatTracker; import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker; import net.minecraft.server.v1_7_R4.EntityArrow; +import net.minecraft.server.v1_7_R4.Item; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -43,17 +44,15 @@ import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Arrow; -import org.bukkit.entity.EntityType; +import org.bukkit.entity.Entity; 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.BlockBreakEvent; import org.bukkit.event.block.BlockEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -114,6 +113,7 @@ public class TurfForts extends TeamGame new Kit[] { + new KitMarksman(manager), new KitInfiltrator(manager), new KitShredder(manager), @@ -125,6 +125,7 @@ public class TurfForts extends TeamGame "", "Each kill advances your turf forwards.", "Take over all the turf to win!" + }); this.StrictAntiHack = true; @@ -268,7 +269,7 @@ public class TurfForts extends TeamGame EndCheck(); } } - + @EventHandler public void BowCancel(EntityShootBowEvent event) { @@ -280,13 +281,21 @@ public class TurfForts extends TeamGame ((Player) event.getEntity()).updateInventory(); } } + + @EventHandler + public void BlockBreak(BlockBreakEvent event) + { + if (event.isCancelled()) // this statement might save just a small amount of time + return; + + if(getArcadeManager().isSpectator(event.getPlayer())) event.setCancelled(true); + } - @EventHandler(ignoreCancelled = true) + @EventHandler public void BlockPlace(BlockPlaceEvent event) { - //Remoeved and replaced by ignoreCancelled = true - //if (event.isCancelled()) - // return; + if (event.isCancelled()) + return; GameTeam team = GetTeam(event.getPlayer()); if (team == null) @@ -325,17 +334,6 @@ public class TurfForts extends TeamGame event.setCancelled(true); return; } - - } - - @EventHandler(priority = EventPriority.HIGH) - public void BlockBreak(BlockBreakEvent event) - { - if (!IsAlive(event.getPlayer())) - { - event.setCancelled(true); - return; - } } @EventHandler @@ -343,7 +341,7 @@ public class TurfForts extends TeamGame { if (event.getEntity().getShooter() == null) return; - + if (!(event.getEntity() instanceof Arrow)) return; @@ -359,7 +357,6 @@ public class TurfForts extends TeamGame Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { - public void run() { try @@ -379,22 +376,21 @@ public class TurfForts extends TeamGame int z = fieldZ.getInt(entityArrow); Block block = arrow.getWorld().getBlockAt(x, y, z); - + if (block.getTypeId() == 35) { - if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */) + if (block.getData() == 14 && team.GetColor() != ChatColor.RED) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); } - else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */) + else if (block.getData() == 3 && team.GetColor() != ChatColor.AQUA) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); } - + Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); - - - block.setType(Material.AIR); + + block.breakNaturally(); } arrow.remove(); @@ -669,8 +665,7 @@ public class TurfForts extends TeamGame } } } - - /* + @EventHandler public void ItemRemoval(UpdateEvent event) { @@ -689,37 +684,7 @@ public class TurfForts extends TeamGame ent.remove(); } } - */ - - //Added by TheMineBench. - @EventHandler - public void blockBreak(BlockBreakEvent event) { - - Block block = event.getBlock(); - - GameTeam team = GetTeam(event.getPlayer()); - GameTeam otherTeam = GetOtherTeam(team); - if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); - event.setCancelled(true); - return; - } - - } - - public GameTeam GetOtherTeam(GameTeam team) { - return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); - } - - @EventHandler - public void onItem(ItemSpawnEvent e) { - if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) { - e.setCancelled(true); - } - } - @Override public void EndCheck() { @@ -749,7 +714,7 @@ public class TurfForts extends TeamGame if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - + //End SetState(GameState.End); } @@ -758,4 +723,4 @@ public class TurfForts extends TeamGame { return _enemyTurf.get(player); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index c2b7ecd9f..9175d6350 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -139,6 +139,8 @@ public class UHC extends TeamGame this.HideTeamSheep = true; this.StrictAntiHack = true; + + AnnounceStay = false; this.GameTimeout = 10800000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index f68614c57..9dc6ac437 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -155,6 +155,7 @@ public class Wizards extends SoloGame _wizard = new WizardSpellMenu("Wizard Spell Menu", getArcadeManager().getPlugin(), this); + AnnounceStay = false; BlockBreak = true; BlockPlace = true; ItemPickup = true; @@ -1052,7 +1053,7 @@ public class Wizards extends SoloGame @EventHandler public void onChat(PlayerChatEvent event) { - if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.ADMIN)) + if (Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) { if (event.getMessage().equalsIgnoreCase("spells")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java index c24a31d78..94f2730d9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java @@ -42,7 +42,7 @@ public class MenuPage extends BasePage addButton(4, getOwnerHead(), new PlayerHeadButton(getPlugin(), this)); boolean host = _manager.isHost(getPlayer()); - boolean disableChangeButtons = !getClientManager().Get(getPlayer()).GetRank().Has(Rank.YOUTUBE) && getPlugin().isGameInProgress(); + boolean disableChangeButtons = !getClientManager().Get(getPlayer()).GetRank().has(Rank.YOUTUBE) && getPlugin().isGameInProgress(); { // Change Buttons - If a game is in progress and user isn't Youtube+ rank, they cannot @@ -89,10 +89,10 @@ public class MenuPage extends BasePage if (host) { GiveAdminButton giveAdminButton = new GiveAdminButton(getPlugin(), getShop()); - addButton(4 + 9, new ShopItem(Material.DIAMOND_SWORD, "Give Admin", new String[]{}, 1, false), giveAdminButton); + addButton(4 + 9, new ShopItem(Material.DIAMOND_SWORD, "Give Co-Host", new String[]{}, 1, false), giveAdminButton); RemoveAdminButton removeAdminButton = new RemoveAdminButton(getPlugin(), getShop()); - addButton(4 + 18, new ShopItem(Material.GOLD_SWORD, "Remove Admin", new String[]{}, 1, false), removeAdminButton); + addButton(4 + 18, new ShopItem(Material.GOLD_SWORD, "Remove Co-Host", new String[]{}, 1, false), removeAdminButton); KillButton killButton = new KillButton(getPlugin()); addButton(8 + 18, new ShopItem(Material.TNT, "Kill Private Server", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java index cc9686292..26b0de8c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java @@ -1,13 +1,14 @@ package nautilus.game.arcade.gui.spectatorMenu; import org.bukkit.entity.Player; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.addons.CompassAddon; +import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.gui.spectatorMenu.page.SpectatorPage; /** 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 8e7f24c55..7f75b4533 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,8 +4,10 @@ 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; @@ -18,10 +20,11 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilMath; import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.shop.page.ShopPageInventory; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.addons.CompassAddon; +import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.gui.spectatorMenu.SpectatorShop; import nautilus.game.arcade.gui.spectatorMenu.button.SpectatorButton; @@ -30,35 +33,46 @@ import nautilus.game.arcade.gui.spectatorMenu.button.SpectatorButton; * Created by shaun on 14-09-24. */ -public class SpectatorPage extends ShopPageBase +public class SpectatorPage extends + ShopPageInventory { private ArcadeManager _arcadeManager; + private IButton[] _buttons; + private ItemStack[] _items; - public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, SpectatorShop shop, CoreClientManager clientManager, + public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, + SpectatorShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { - super(plugin, shop, clientManager, donationManager, "Spectator Menu", player); + super(plugin, shop, clientManager, donationManager, "Spectator Menu", + player); + _arcadeManager = arcadeManager; buildPage(); } @Override - protected void buildPage() + protected void buildItems() { - int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); + _buttons = new IButton[54]; + _items = new ItemStack[54]; + List teamList = _arcadeManager.GetGame().GetTeamList(); - if (teamList.size() == 1 && playerCount < 28) - buildSingleTeam(teamList.get(0), playerCount); - else - buildMultipleTeams(teamList, playerCount); + int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); + if (teamList.size() == 1 && playerCount < 28) + { + buildSingleTeam(teamList.get(0), playerCount); + } + else + { + buildMultipleTeams(teamList, playerCount); + } } private void buildSingleTeam(GameTeam team, int playerCount) { - setItem(13, getTeamItem(team, playerCount)); - ArrayList players = team.GetPlayers(true); Collections.sort(players, new Comparator() @@ -72,6 +86,11 @@ public class SpectatorPage extends ShopPageBase }); + _buttons = new IButton[19 + players.size()]; + _items = new ItemStack[_buttons.length]; + + _items[13] = getTeamItem(team, playerCount); + int slot = 19; for (Player other : players) @@ -79,41 +98,70 @@ public class SpectatorPage extends ShopPageBase addPlayerItem(slot, team, other); if ((slot + 2) % 9 == 0) + { + _buttons = Arrays.copyOf(_buttons, _buttons.length + 3); + _items = Arrays.copyOf(_items, _items.length + 3); + slot += 3; + } else + { slot++; + } } } private void buildMultipleTeams(List teamList, int playerCount) { + _buttons = new IButton[0]; + _items = new ItemStack[0]; + int currentRow = 0; + Collections.sort(teamList, new Comparator() + { + + @Override + public int compare(GameTeam o1, GameTeam o2) + { + int returns = o1.getDisplayName().compareToIgnoreCase( + o2.getDisplayName()); + + if (returns == 0) + { + return Long.compare(o1.getCreatedTime(), + o2.getCreatedTime()); + } + + return returns; + } + + }); + for (GameTeam team : teamList) { ArrayList teamPlayers = team.GetPlayers(true); - int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0); Collections.sort(teamPlayers, new Comparator() { - @Override public int compare(Player o1, Player o2) { return o1.getName().compareToIgnoreCase(o2.getName()); } - }); + 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)); + for (int row = 0; row < rowsNeeded; row++) { int woolSlot = (row * 9) + (currentRow * 9); - // TODO Need to handle too many players in a better way - if (woolSlot >= getSize()) - continue; - - setItem(woolSlot, getTeamItem(team, teamPlayers.size())); + _items[woolSlot] = getTeamItem(team, teamPlayers.size()); int playerIndex = row * 8; for (int i = 0; i < 8 && playerIndex < teamPlayers.size(); i++, playerIndex++) @@ -121,36 +169,43 @@ public class SpectatorPage extends ShopPageBase Player other = teamPlayers.get(playerIndex); int slot = woolSlot + 1 + i; - // TODO Need to handle too many players in a better way - if (slot >= getSize()) - continue; - addPlayerItem(slot, team, other); } } - // Add a line in between teams if the player count is low enough and there are less than 4 teams + // Add a line in between teams if the player count is low enough and + // there are less than 4 teams if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26) + { currentRow += 2; + } else + { currentRow += rowsNeeded; + } } } private void addPlayerItem(int slot, GameTeam team, Player other) { ItemStack playerItem = getPlayerItem(team, other); - ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false); - addButton(slot, shopItem, new SpectatorButton(_arcadeManager, getPlayer(), other)); + + ShopItem shopItem = new ShopItem(playerItem, other.getName(), + other.getName(), 1, false, false); + + _items[slot] = shopItem; + _buttons[slot] = new SpectatorButton(_arcadeManager, getPlayer(), other); } private ItemStack getTeamItem(GameTeam team, int playerCount) { - ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, UtilColor.chatColorToWoolData(team.GetColor())); + ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, + UtilColor.chatColorToWoolData(team.GetColor())); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(team.GetFormattedName()); - meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + "Players Alive: " + C.cWhite + playerCount)); + meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + + "Players Alive: " + C.cWhite + playerCount)); item.setItemMeta(meta); return item; @@ -161,13 +216,17 @@ public class SpectatorPage extends ShopPageBase ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3); double distance = UtilMath.offset(getPlayer(), other); - double heightDifference = other.getLocation().getY() - getPlayer().getLocation().getY(); + double heightDifference = other.getLocation().getY() + - getPlayer().getLocation().getY(); ArrayList lore = new ArrayList(); lore.add(" "); - lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite + _arcadeManager.GetGame().GetKit(other).GetName()); - lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite + UtilMath.trim(1, distance)); - lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + UtilMath.trim(1, heightDifference)); + lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite + + _arcadeManager.GetGame().GetKit(other).GetName()); + lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite + + UtilMath.trim(1, distance)); + lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + + UtilMath.trim(1, heightDifference)); lore.add(" "); lore.add(ChatColor.RESET + C.Line + "Click to Spectate"); SkullMeta skullMeta = ((SkullMeta) item.getItemMeta()); @@ -179,4 +238,16 @@ public class SpectatorPage extends ShopPageBase return item; } + @Override + protected IButton[] getButtons() + { + return _buttons; + } + + @Override + protected ItemStack[] getItems() + { + return _items; + } + } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java index 1f4242400..3e4fbdfc3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java @@ -2,23 +2,29 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Cow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import nautilus.game.arcade.kit.Perk; - public class PerkCharge extends Perk { public PerkCharge() @@ -74,6 +80,19 @@ public class PerkCharge extends Perk //Sound player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 0.75f, 1f); + + if (cur instanceof Player) + { + MilkRemoveEvent e = new MilkRemoveEvent((Player)cur, 1, RemoveType.FLING); + Bukkit.getPluginManager().callEvent(e); + ItemStack bucket = e.GetPlayer().getInventory().getItem(0); + if ((bucket.getType() == Material.MILK_BUCKET) && e.GetMilk() >= 0) + { + bucket.setType(Material.BUCKET); + e.GetPlayer().getInventory().setItem(0, bucket); + } + UtilInv.Update(e.GetPlayer()); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java index 7b031d8c1..62b42fdbc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java @@ -2,15 +2,6 @@ package nautilus.game.arcade.kit.perks; import java.util.HashSet; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerDropItemEvent; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; @@ -18,10 +9,20 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.event.PerkConstructorEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; public class PerkConstructor extends Perk { @@ -71,6 +72,12 @@ public class PerkConstructor extends Perk if (UtilInv.contains(cur, _type, (byte)0, _max)) continue; + PerkConstructorEvent cE = new PerkConstructorEvent(cur); + Bukkit.getServer().getPluginManager().callEvent(cE); + + if (cE.isCancelled()) + continue; + //Add byte data = 0; if (_type == Material.WOOL) @@ -83,7 +90,7 @@ public class PerkConstructor extends Perk continue; cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 1)); - return; + continue; } cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(_type, data, 1, F.item(_name))); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java index a00506549..5a97d8a8f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java @@ -1,40 +1,42 @@ package nautilus.game.arcade.kit.perks; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -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.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; 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.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseCreeper; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.SmashPerk; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + public class PerkCreeperExplode extends SmashPerk { private HashMap _active = new HashMap(); @@ -144,7 +146,15 @@ public class PerkCreeperExplode extends SmashPerk player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, (float)(2 + Math.random()*4), (float)(Math.random() + 0.2)); //Blocks - Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(player.getLocation(), 12).keySet(), player.getLocation(), false); + Collection blocks = UtilBlock.getInRadius(player.getLocation(), 12).keySet(); + Iterator iter = blocks.iterator(); + + while (iter.hasNext()) { + Block b = iter.next(); + + if(b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA || b.getType() == Material.BEDROCK) iter.remove();; + } + Manager.GetExplosion().BlockExplosion(blocks, player.getLocation(), false); //Remove Spawns Iterator spawnIterator = Manager.GetGame().GetTeam(player).GetSpawns().iterator(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkExplosionModifier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkExplosionModifier.java new file mode 100644 index 000000000..d34c7cbb2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkExplosionModifier.java @@ -0,0 +1,45 @@ + +package nautilus.game.arcade.kit.perks; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class PerkExplosionModifier extends Perk +{ + private double _explosion; + + public PerkExplosionModifier(double explosion) + { + super("Enforced Armor", new String[]{"You take " + explosion * 100 + "% explosion damage!"}); + + _explosion = explosion; + } + + @EventHandler(priority = EventPriority.HIGH) + public void Knockback(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_EXPLOSION && event.GetCause() != DamageCause.BLOCK_EXPLOSION) + return; + + if (!(event.GetDamageeEntity() instanceof Player)) + return; + + Player player = event.GetDamageePlayer(); + + if (player == null) + return; + + if (!Kit.HasKit(player)) + return; + + if (!Manager.IsAlive(player)) + return; + + event.AddMod("Explosion Modifier", "Reduce damage", (-event.GetDamage()) + event.GetDamageInitial() * _explosion, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFallModifier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFallModifier.java new file mode 100644 index 000000000..bb8decc97 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFallModifier.java @@ -0,0 +1,44 @@ +package nautilus.game.arcade.kit.perks; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class PerkFallModifier extends Perk +{ + private double _fall; + + public PerkFallModifier(double fall) + { + super("Feathered Boots", new String[]{"You take " + fall * 100 + "% fall damage!"}); + + _fall = fall; + } + + @EventHandler(priority = EventPriority.HIGH) + public void Knockback(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.FALL) + return; + + if (!(event.GetDamageeEntity() instanceof Player)) + return; + + Player player = event.GetDamageePlayer(); + + if (player == null) + return; + + if (!Kit.HasKit(player)) + return; + + if (!Manager.IsAlive(player)) + return; + + event.AddMod("Fall Modifier", "Reduce damage", _fall, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackTaken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackTaken.java new file mode 100644 index 000000000..fb5d0321b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackTaken.java @@ -0,0 +1,44 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.Map.Entry; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class PerkKnockbackTaken extends Perk +{ + private double _knockback; + + public PerkKnockbackTaken(double knockback) + { + super("Knockback", new String[]{"You take " + knockback * 100 + "% knockback!"}); + + _knockback = knockback; + } + + @EventHandler(priority = EventPriority.HIGH) + public void Knockback(CustomDamageEvent event) + { + if (!(event.GetDamageeEntity() instanceof Player)) + return; + + Player player = event.GetDamageePlayer(); + + if (player == null) + return; + + if (!Kit.HasKit(player)) + return; + + if (!Manager.IsAlive(player)) + return; + + //Multiply all knockback + for (Entry entry : event.GetKnockback().entrySet()) + entry.setValue(entry.getValue() * _knockback); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java index e91dc9742..23134ec56 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java @@ -14,7 +14,7 @@ public class PerkMammoth extends Perk { super("Mammoth", new String[] { - C.cGray + "Take 50% knockback and deal 150% knockback", + C.cGray + "Take 75% knockback and deal 125% knockback", }); } @@ -30,7 +30,7 @@ public class PerkMammoth extends Perk if (!Kit.HasKit(damager)) return; - event.AddKnockback(GetName(), 1.5d); + event.AddKnockback(GetName(), 1.25d); } @EventHandler(priority = EventPriority.HIGH) @@ -45,6 +45,6 @@ public class PerkMammoth extends Perk if (!Kit.HasKit(damagee)) return; - event.AddKnockback(GetName(), 0.5d); + event.AddKnockback(GetName(), 0.75d); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java index ce4603693..3844440ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java @@ -131,7 +131,7 @@ public class PerkNeedler extends SmashPerk DamageCause.THORNS, 1.1, true, true, false, damager.getName(), GetName()); - if(Manager.GetGame().GetTeam(event.GetDamageePlayer()) != Manager.GetGame().GetTeam(damager)) + if(!Manager.GetGame().GetTeam(event.GetDamageePlayer()).equals(Manager.GetGame().GetTeam(damager))) { Manager.GetCondition().Factory().Poison(GetName(), event.GetDamageeEntity(), damager, 2, 0, false, false, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoFallDamage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoFallDamage.java new file mode 100644 index 000000000..6cb73501a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoFallDamage.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkNoFallDamage extends Perk +{ + public PerkNoFallDamage() + { + super("Feathered Boots", new String[]{"You take no fall damage!"}); + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!(event.GetDamageeEntity() instanceof Player)) + return; + + if (!Kit.HasKit(event.GetDamageePlayer())) + return; + + if (event.GetCause() == DamageCause.FALL) + { + event.SetCancelled("Feathered Boots"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java new file mode 100644 index 000000000..5752294ee --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.kit.perks; + +import mineplex.core.common.util.C; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class PerkNoSpillMilk extends Perk +{ + + public PerkNoSpillMilk(ArcadeManager manager) + { + super("Steady Hands", new String[] + { + C.cGray + "Lose less milk when you die", + C.cGray + "Don't lose your bucket of milk when cows run into you", + }); + } + + @EventHandler + public void onLoseMilk(MilkRemoveEvent event) + { + Player player = event.GetPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (event.GetCause() == RemoveType.DEATH) + { + if (event.GetMilk() > 3) + event.SetMilk(3); + } + + if (event.GetCause() == RemoveType.FLING) + { + event.SetMilk(-1); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java index 31a29a28c..f259ca0a2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java @@ -32,6 +32,14 @@ public class PerkSeismicCow extends Perk { private HashMap _live = new HashMap(); + public PerkSeismicCow(String displayName) + { + super(displayName, new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Shovel to " + C.cGreen + "Seismic Slam" + }); + } + public PerkSeismicCow() { super("Seismic Slam", new String[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVampire.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVampire.java index 69ba0a124..34feae7bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVampire.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVampire.java @@ -17,7 +17,7 @@ public class PerkVampire extends Perk { super("Vampire", new String[] { - C.cGray + "You heal " + recover + "HP when you kill someone", + C.cGray + "You heal " + C.cYellow + recover + " Hearts" + C.cGray + " when you kill someone", }); _recover = recover; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWaterDamage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWaterDamage.java new file mode 100644 index 000000000..2261c9793 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWaterDamage.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkWaterDamage extends Perk +{ + private double _damage; + private long _time; + + public PerkWaterDamage(double damage, double time) + { + super("(Not) Water Bender", new String[] + { + "You are deathly afraid of water.", + "Entering water deals " + C.cYellow + "2 Damage" + C.cGray + " every " + C.cGreen + "1 Second" + }); + + _damage = damage; + _time = (long) (time * 1000); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)){ + if (!Kit.HasKit(player)) + continue; + + if (!Recharge.Instance.use(player, "Not Water Bender Damage", _time, false, false)) + continue; + + if (UtilEnt.inWater(player)) + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.DROWNING, _damage, false, false, true, "Water", "Water Hating Kit"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/event/PerkConstructorEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/event/PerkConstructorEvent.java new file mode 100644 index 000000000..4a077dafa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/event/PerkConstructorEvent.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.kit.perks.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class PerkConstructorEvent extends PlayerEvent implements Cancellable +{ + private static HandlerList _handlers = new HandlerList(); + + private boolean _cancelled = false; + + public PerkConstructorEvent(Player who) + { + super(who); + } + + @Override + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + public HandlerList getHandlers() + { + return getHandlerList(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index 4aed91a8a..4b520c4d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -62,7 +62,7 @@ public class GameChatManager implements Listener CoreClient cc = Manager.GetClients().Get(sender); rank = cc.getDisguisedRank(); - if(!cc.GetRank().Has(Rank.JNR_DEV)) + if(!cc.GetRank().has(Rank.JNR_DEV)) { disguiseTag = ChatColor.BLACK + " "; } @@ -90,17 +90,17 @@ public class GameChatManager implements Listener else if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) { if (Manager.GetGameHostManager().isEventServer()) - rankStr = C.cDGreen + C.Bold + "Event Admin "; + rankStr = C.cDGreen + C.Bold + "Event Co-Host "; else - rankStr = C.cDGreen + C.Bold + "MPS Admin "; + rankStr = C.cDGreen + C.Bold + "MPS Co-Host "; } else { if (rank != Rank.ALL) - rankStr = rank.GetTag(true, true) + " "; + rankStr = rank.getTag(true, true) + " "; - if (ownsUltra && !rank.Has(Rank.ULTRA)) - rankStr = Rank.ULTRA.GetTag(true, true) + " "; + if (ownsUltra && !rank.has(Rank.ULTRA)) + rankStr = Rank.ULTRA.getTag(true, true) + " "; } if (event.getMessage().charAt(0) == '@') @@ -158,7 +158,7 @@ public class GameChatManager implements Listener { Player receiver = recipientIterator.next(); - if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().Has(Rank.MODERATOR)) + if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) continue; GameTeam recTeam = Manager.GetGame().GetTeam(receiver); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 0f25e0656..97ebf6af2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -23,8 +23,8 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerDeathOutEvent; 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.GameTeam.PlayerState; import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent; @@ -33,6 +33,8 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.block.DoubleChest; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -46,8 +48,8 @@ import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryType; @@ -274,7 +276,8 @@ public class GameFlagManager implements Listener if (!game.InProgress()) return; - + + //normal inventories if (!game.InventoryOpenBlock) { if (event.getInventory().getType() == InventoryType.ANVIL || @@ -287,22 +290,37 @@ public class GameFlagManager implements Listener event.getInventory().getType() == InventoryType.HOPPER || event.getInventory().getType() == InventoryType.MERCHANT || event.getInventory().getType() == InventoryType.ENDER_CHEST || - event.getInventory().getType() == InventoryType.WORKBENCH) - { - event.setCancelled(true); - event.getPlayer().closeInventory(); + event.getInventory().getType() == InventoryType.WORKBENCH || + event.getInventory().getType() == InventoryType.CHEST) + { + if (event.getInventory().getType() == InventoryType.CHEST) + { + if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest) + { + event.setCancelled(true); + event.getPlayer().closeInventory(); + } + } + else + { + event.setCancelled(true); + event.getPlayer().closeInventory(); + } + } + } + + //deal with chests + if (!game.InventoryOpenChest) + { + if (event.getInventory().getType() == InventoryType.CHEST) + { + if (event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest) + { + event.setCancelled(true); + event.getPlayer().closeInventory(); + } } } - - -// if (!game.InventoryOpenChest) -// { -// if (event.getInventory().getType() == InventoryType.CHEST) -// { -// event.setCancelled(true); -// event.getPlayer().closeInventory(); -// } -// } } @EventHandler(priority = EventPriority.LOWEST) @@ -923,7 +941,7 @@ public class GameFlagManager implements Listener if (event.isCancelled()) return; - if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER)) + if (Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER)) return; Game game = Manager.GetGame(); @@ -1110,16 +1128,13 @@ public class GameFlagManager implements Listener if (event.getType() != UpdateType.SEC) return; - - if (Manager.GetGame().GetType() == GameType.MineStrike) - return; - + for (Player player : UtilServer.getPlayers()) { if (Manager.IsAlive(player)) continue; - if (Recharge.Instance.use(player, "Dont Quit Message", 30000, false, false)) + if (Recharge.Instance.use(player, "Dont Quit Message", 300000, false, false)) { UtilPlayer.message(player, " "); UtilPlayer.message(player, C.cWhite + C.Bold + "You are out of the game, but " + C.cGold + C.Bold + "DON'T QUIT" + C.cWhite + C.Bold + "!"); @@ -1190,10 +1205,10 @@ public class GameFlagManager implements Listener { if (Manager.GetGame() == null) return; - - if (Manager.GetGame().GetType().getResourcePackUrl() == null) - return; - +// +// if (Manager.GetGame().GetType().getResourcePackUrl() == null) +// return; +// UtilPlayer.message(player, " "); UtilPlayer.message(player, C.cGold + C.Bold + Manager.GetGame().GetType().GetName() + " requires you to be using Minecraft 1.8!"); UtilPlayer.message(player, " "); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 07bb93f7a..eb0edb352 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -9,8 +9,10 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.serverdata.Utility; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -36,8 +38,9 @@ public class GameGemManager implements Listener { ArcadeManager Manager; - boolean DoubleGem = true; - + boolean DoubleGem = false; + boolean TimeReward = true; + public GameGemManager(ArcadeManager manager) { Manager = manager; @@ -184,8 +187,21 @@ public class GameGemManager implements Listener total += (int)(earned * (gemFinder * 0.25)); } } + + //Time Reward + if (TimeReward) + { + long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime(); + + double hoursOnline = timeOnline/3600000d; + + if (hoursOnline > 5) + hoursOnline = 5; + + total += (int)(earned * (hoursOnline * 0.2)); + } - if (DoubleGem && game.GemDoubleEnabled && UtilPlayer.is1_8(player)) + if (DoubleGem && game.GemDoubleEnabled) total += earned; Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), total); @@ -290,8 +306,29 @@ public class GameGemManager implements Listener } } + //Time Reward + if (TimeReward) + { + long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime(); + + double hoursOnline = timeOnline/3600000d; + + if (hoursOnline > 5) + hoursOnline = 5; + + int extraGems = (int)(earnedGems * (hoursOnline * 0.2)); + + if (extraGems > 0) + { + UtilPlayer.message(player, F.elem(C.cGreen + "+" + extraGems + " Gems") + " for " + + F.elem("Online for " + UtilTime.MakeStr(timeOnline) + C.cGreen + " +" + (int)(hoursOnline * 20) + "%")); + + totalGems += extraGems; + } + } + //Double Gem - if (DoubleGem && game.GemDoubleEnabled && UtilPlayer.is1_8(player)) + if (DoubleGem && game.GemDoubleEnabled) { UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 2dfc1c151..3b79045b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -143,7 +143,6 @@ public class GameHostManager implements Listener public ArrayList hasWarning() { ArrayList games = new ArrayList<>(); - games.add(GameType.Evolution); games.add(GameType.MilkCow); games.add(GameType.SearchAndDestroy); games.add(GameType.ZombieSurvival); @@ -169,7 +168,7 @@ public class GameHostManager implements Listener // Admins update for (Player player : UtilServer.getPlayers()) { - if (player.equals(_host) || _adminList.contains(player.getName()) || Manager.GetClients().Get(player).GetRank().Has(Rank.ADMIN)) + if (player.equals(_host) || _adminList.contains(player.getName()) || Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN)) { if (Manager.GetGame() == null || Manager.GetGame().GetState() == GameState.Recruit) giveAdminItem(player); @@ -230,6 +229,10 @@ public class GameHostManager implements Listener _hostRank = Manager.GetClients().Get(_host).GetRank(); System.out.println("Game Host Joined."); + //Limit player count! + if (Manager.GetServerConfig().MaxPlayers > getMaxPlayerCap()) + Manager.GetServerConfig().MaxPlayers = getMaxPlayerCap(); + if (isEventServer()) worldeditPermissionSet(event.getPlayer(), true); } @@ -374,7 +377,7 @@ public class GameHostManager implements Listener if (!isPrivateServer()) return; - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true)) + if (!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.JNR_DEV, true) && !event.getPlayer().isOp()) return; giveAdmin(event.getPlayer()); @@ -478,7 +481,7 @@ public class GameHostManager implements Listener public boolean isAdmin(Player player, boolean includeStaff) { - return player.equals(_host) || _adminList.contains(player.getName()) || (includeStaff && Manager.GetClients().Get(player).GetRank().Has(Rank.ADMIN)); + return player.equals(_host) || _adminList.contains(player.getName()) || (includeStaff && Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN)); } public boolean isHost(Player player) @@ -581,7 +584,7 @@ public class GameHostManager implements Listener if (_hostRank == null) return false; - return _hostRank.Has(rank); + return _hostRank.has(rank); } public ArrayList getAvailableGames(Player player) @@ -642,7 +645,7 @@ public class GameHostManager implements Listener { _adminList.add(player.getName()); _onlineAdmins.add(player); - UtilPlayer.message(player, F.main("Server", "You were given admin privileges.")); + UtilPlayer.message(player, F.main("Server", "You were given Co-Host privileges.")); if (isEventServer()) worldeditPermissionSet(player, true); @@ -660,7 +663,7 @@ public class GameHostManager implements Listener { player.closeInventory(); } - UtilPlayer.message(player, F.main("Server", "Your admin privileges were removed.")); + UtilPlayer.message(player, F.main("Server", "Your Co-Host privileges were removed.")); player.setGameMode(GameMode.SURVIVAL); @@ -713,57 +716,66 @@ public class GameHostManager implements Listener if (!event.getMessage().toLowerCase().startsWith("/e set ") && !event.getMessage().toLowerCase().equals("/e set")) return; + Player caller = event.getPlayer(); String[] args = event.getMessage().split(" "); - //Parse Game - if (args.length >= 3) - { - ArrayList matches = new ArrayList(); - for (GameType type : GameType.values()) - { - if (type.toString().toLowerCase().equals(args[2])) - { - matches.clear(); - matches.add(type); - break; - } - - if (type.toString().toLowerCase().contains(args[2])) - { - matches.add(type); - } - } - - if (matches.size() == 0) - { - event.getPlayer().sendMessage("No results for: " + args[2]); - return; - } - - if (matches.size() > 1) - { - event.getPlayer().sendMessage("Matched multiple games;"); - for (GameType cur : matches) - event.getPlayer().sendMessage(cur.toString()); - return; - } - - GameType type = matches.get(0); - Manager.GetGame().setGame(type, event.getPlayer(), true); - } - else - { - Manager.GetGame().setGame(GameType.Event, event.getPlayer(), true); - } + String game = args[2].toLowerCase(); - - //Map Pref if (args.length >= 4) { - Manager.GetGameCreationManager().MapPref = args[3]; - UtilPlayer.message(event.getPlayer(), C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + args[2]); + String map = ""; + String source = ""; + if(args.length == 5) + { + Manager.GetGameCreationManager().MapSource = args[3]; + Manager.GetGameCreationManager().MapPref = args[4]; + source = args[3]; + map = args[4]; + } + else + { + Manager.GetGameCreationManager().MapSource = args[2]; + Manager.GetGameCreationManager().MapPref = args[3]; + source = args[2]; + map = args[3]; + } + UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + source + ":" + map); } + //Parse Game + ArrayList matches = new ArrayList<>(); + for (GameType type : GameType.values()) + { + if (type.toString().toLowerCase().equals(game)) + { + matches.clear(); + matches.add(type); + break; + } + + if (type.toString().toLowerCase().contains(game)) + { + matches.add(type); + } + } + + if (matches.size() == 0) + { + caller.sendMessage("No results for: " + game); + return; + } + + if (matches.size() > 1) + { + caller.sendMessage("Matched multiple games;"); + for (GameType cur : matches) + caller.sendMessage(cur.toString()); + return; + } + + GameType type = matches.get(0); + Manager.GetGame().setGame(type, event.getPlayer(), true); + event.setCancelled(true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index a13d6f1b9..d144e7ba9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -178,7 +178,7 @@ public class GameLobbyManager implements Listener, IPacketHandler } else { - scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " " + ChatColor.WHITE); + scoreboard.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + ChatColor.WHITE); } if (Manager.GetGame() != null && !Manager.GetGame().GetTeamList().isEmpty()) @@ -197,7 +197,7 @@ public class GameLobbyManager implements Listener, IPacketHandler } else { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " " + team.GetColor()); + scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + team.GetColor()); } } } @@ -1066,7 +1066,7 @@ public class GameLobbyManager implements Listener, IPacketHandler (ent.GetKit().GetAvailability() == KitAvailability.Achievement && Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + ent.GetKit().GetName()) || //Green - Manager.GetClients().Get(player).GetRank().Has(Rank.MAPDEV) || //STAFF + Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) Manager.GetServerConfig().Tournament) //Tournament { @@ -1188,7 +1188,7 @@ public class GameLobbyManager implements Listener, IPacketHandler teamName = ""; String rankName = Manager.GetClients().Get(player).GetRank().Name; - boolean rankIsUltra = !Manager.GetClients().Get(player).GetRank().Has(Rank.ULTRA) && Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); + boolean rankIsUltra = !Manager.GetClients().Get(player).GetRank().has(Rank.ULTRA) && Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); if (rankIsUltra) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java index 08fc48275..ca8a39e3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java @@ -50,12 +50,12 @@ public class GameLootManager implements Listener Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - _rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, + _rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(), 100, 250, 500, 1000, 1500, 2500, 6000, 12000, - false); + false, false); //Chest _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Old Chest", "Old Chest", 1, 1, @@ -139,11 +139,11 @@ public class GameLootManager implements Listener { double chance = Math.min(0.5, 0.1 + (System.currentTimeMillis() - _startTime)/3600000d); - if (Manager.GetClients().Get(player).GetRank().Has(Rank.ULTRA)) + if (Manager.GetClients().Get(player).GetRank().has(Rank.ULTRA)) { - if (Manager.GetClients().Get(player).GetRank().Has(Rank.HERO)) + if (Manager.GetClients().Get(player).GetRank().has(Rank.HERO)) { - if (Manager.GetClients().Get(player).GetRank().Has(Rank.LEGEND)) + if (Manager.GetClients().Get(player).GetRank().has(Rank.LEGEND)) { chance *= 1.6; } 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 cfed7e11b..d3302b599 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 @@ -3,6 +3,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; import java.util.Iterator; +import mineplex.core.bonuses.event.CarlSpinnerEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; @@ -692,4 +693,18 @@ public class GameManager implements Listener { event.GetGame().EndCheck(); } + + @EventHandler + public void carlSpinnerCancel(CarlSpinnerEvent event) + { + Game game = Manager.GetGame(); + if (game == null) return; + + if (game.GetCountdown() > 0 || game.GetState() != GameState.Recruit) + { + UtilPlayer.message(event.getPlayer(), F.main("Carl", "You can't use my spinner at the moment!")); + event.setCancelled(true); + } + + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index d1417d420..1a68d11ff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -2,26 +2,6 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerRespawnEvent; - import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -45,6 +25,25 @@ import nautilus.game.arcade.shop.ArcadeShop; import nautilus.game.arcade.shop.KitPackage; import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerRespawnEvent; + public class GamePlayerManager implements Listener { ArcadeManager Manager; @@ -60,7 +59,7 @@ public class GamePlayerManager implements Listener public void PlayerDeath(CombatDeathEvent event) { //Don't actually die - event.GetEvent().getEntity().setHealth(20); + event.GetEvent().getEntity().setHealth(event.GetEvent().getEntity().getMaxHealth()); //Dont display message if (Manager.GetGame() != null) @@ -336,7 +335,7 @@ public class GamePlayerManager implements Listener donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + kit.GetName()) || //Green - Manager.GetClients().Get(player).GetRank().Has(Rank.MAPDEV) || //STAFF + Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) @@ -380,7 +379,7 @@ public class GamePlayerManager implements Listener Player player = event.getPlayer(); - if (Manager.GetClients().Get(player).GetRank().Has(Rank.MODERATOR)) + if (Manager.GetClients().Get(player).GetRank().has(Rank.MODERATOR)) return; if (event.getMessage().toLowerCase().startsWith("/tp")) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index f855f9ffc..8e7128943 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -122,7 +122,7 @@ public class GameStatManager implements Listener @EventHandler public void statBoostCommand(PlayerCommandPreprocessEvent event) { - if (event.getMessage().startsWith("/statboost ") && Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER)) + if (event.getMessage().startsWith("/statboost ") && Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.OWNER)) { event.setCancelled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java index 4d0ca2244..1d7b53978 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java @@ -78,7 +78,7 @@ public class IdleManager implements Listener if (getArcadeManager().GetGame().GetState() != GameState.Recruit && !getArcadeManager().GetGame().IsAlive(player)) continue; - if (getArcadeManager().GetClients().Get(player).GetRank().Has(Rank.MODERATOR)) + if (getArcadeManager().GetClients().Get(player).GetRank().has(Rank.MODERATOR)) continue; //Start Beeps 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 1bb5955e0..e584708fc 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 @@ -151,7 +151,7 @@ public class WorldData File = Host.GetFiles().get(game).get(map); //Don't allow repeat maps. - if (Host.GetFiles().size() > 1) + if (Host.GetFiles().get(game).size() > 1) { while (File.equals(Host.Manager.GetGameCreationManager().GetLastMap())) { diff --git a/Website/LOC.Core/LOC.Core.csproj b/Website/LOC.Core/LOC.Core.csproj index e10c5ac35..88a44c499 100644 --- a/Website/LOC.Core/LOC.Core.csproj +++ b/Website/LOC.Core/LOC.Core.csproj @@ -50,7 +50,7 @@ - + diff --git a/Website/LOC.Website.Common/LOC.Website.Common.csproj b/Website/LOC.Website.Common/LOC.Website.Common.csproj index 4cd3ebb12..8bdc64668 100644 --- a/Website/LOC.Website.Common/LOC.Website.Common.csproj +++ b/Website/LOC.Website.Common/LOC.Website.Common.csproj @@ -75,6 +75,7 @@ + diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index 3c19dedff..1da074e07 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -277,19 +277,6 @@ token.OriginalBalance = account.Gems; account.Gems += token.Amount; - if (!token.Source.Contains("Earned") && !token.Source.Contains("Tutorial") && !token.Source.Contains("Parkour")) - { - var gemTransaction = new GemTransaction - { - Source = token.Source, - Account = account, - Amount = token.Amount, - Date = (long)TimeUtil.GetCurrentMilliseconds() - }; - - repository.Add(gemTransaction); - } - repository.Edit(account); repository.CommitChanges(); } @@ -323,19 +310,6 @@ token.OriginalBalance = account.Coins; account.Coins += token.Amount; - if (!token.Source.Contains("Earned") && !token.Source.Contains("Tutorial") && !token.Source.Contains("Parkour")) - { - var coinTransaction = new CoinTransaction - { - Source = token.Source, - Account = account, - Amount = token.Amount, - Date = (long)TimeUtil.GetCurrentMilliseconds() - }; - - repository.Add(coinTransaction); - } - repository.Edit(account); repository.CommitChanges(); } @@ -349,6 +323,20 @@ if (account.Coins != token.OriginalBalance + token.Amount) return false; + + if (!token.Source.Contains("Earned") && !token.Source.Contains("Tutorial") && !token.Source.Contains("Parkour")) + { + var coinTransaction = new CoinTransaction + { + Source = token.Source, + Account = account, + Amount = token.Amount, + Date = (long)TimeUtil.GetCurrentMilliseconds() + }; + + repository.Add(coinTransaction); + repository.CommitChanges(); + } } } diff --git a/Website/LOC.Website.Common/Models/IPetAdministrator.cs b/Website/LOC.Website.Common/Models/IPetAdministrator.cs index 40841b2bc..14c41086d 100644 --- a/Website/LOC.Website.Common/Models/IPetAdministrator.cs +++ b/Website/LOC.Website.Common/Models/IPetAdministrator.cs @@ -7,6 +7,7 @@ public interface IPetAdministrator { List GetPets(List petTokens); + List GetBulkPets(int start, int count); List GetPetExtras(List petExtraTokens); void AddPet(PetChangeToken pet); void UpdatePet(PetChangeToken pet); diff --git a/Website/LOC.Website.Common/Models/PetAdministrator.cs b/Website/LOC.Website.Common/Models/PetAdministrator.cs index 15507f4c5..c85e44aaf 100644 --- a/Website/LOC.Website.Common/Models/PetAdministrator.cs +++ b/Website/LOC.Website.Common/Models/PetAdministrator.cs @@ -7,14 +7,18 @@ using Core.Model.Server; using Core.Tokens.Client; using Data; +using System; + using System.Data.SqlClient; public class PetAdministrator : IPetAdministrator { private readonly INautilusRepositoryFactory _repositoryFactory; + private readonly ILogger _logger; - public PetAdministrator(INautilusRepositoryFactory repositoryFactory) + public PetAdministrator(INautilusRepositoryFactory repositoryFactory, ILogger logger) { _repositoryFactory = repositoryFactory; + _logger = logger; } public List GetPets(List petTokens) @@ -145,5 +149,27 @@ repository.CommitChanges(); } } + + #region IPetAdministrator Members + + + public List GetBulkPets(int start, int count) + { + using (var repository = _repositoryFactory.CreateRepository()) + { + try + { + return repository.Context.Database.SqlQuery(@"SELECT OwnedPetId AS PetId, Uuid, PetType, PetName FROM (SELECT OwnedPetId, A.Uuid, PetType, PetName, ROW_NUMBER() OVER (ORDER BY OwnedPetId) as row FROM Nautilus.dbo.OwnedPets INNER JOIN Nautilus.dbo.Accounts AS A ON A.AccountId = Account_AccountId) a WHERE row > " + start + @" AND row <= " + count + @";", string.Empty).ToList(); + } + catch (Exception ex) + { + _logger.Log("ERROR", ex.Message + " : " + ex.InnerException); + } + + return new List(); + } + } + + #endregion } } diff --git a/Website/LOC.Website.Web/Content/themes/techno/about.html b/Website/LOC.Website.Web/Content/themes/techno/about.html deleted file mode 100644 index c27798d6c..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/about.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - -@ViewBag.Title - - - - - - - - - - - - - - - - -
-
-
    -
  • @Html.ActionLink("Home", "Index", "Home")
  • -
  • @Html.ActionLink("About", "About", "Home")
  • -
-
-
- - -
- -
-

About Our Company

- Image 01 -

Ut sed lorem ac ante cursus auctor. Nam ut congue velit. Cras eget fermentum sem. Maecenas nec purus lorem, a sodales lectus. Etiam consequat nulla sit amet volutpat ornare.

-

Donec purus nulla, egestas ac porttitor et, pharetra nec felis. Donec lobortis fringilla blandit. Fusce a purus vel justo pulvinar tempor. Nullam gravida quam et ligula tempus non congue justo egestas. Aliquam erat volutpat. Sed id massa in orci ultrices auctor eu quis dui. Aliquam erat volutpat. Suspendisse potenti. Etiam ullamcorper massa quis elit malesuada eleifend. In ligula arcu, facilisis commodo lacinia in, vehicula eget lacus. Ut sit amet quam est, varius cursus nulla. Validate XHTML & CSS.

-
-

Our People

-
- Image 02 -
UT SED LOREM
-
Webmaster
-
-
-
- Image 04 -
VESTIBULUM MASSA
-
Web Designer
-
-
-
-
- Image 05 -
CRAS AC NISL
-
System Analyst
-
-
-
- Image 07 -
CLASS APTENT
-
Graphic Expert
-
-
-
-
- Image 04 -
PELLENTESQE MASSA
-
Accountant
-
-
-
- Image 06 -
DONEC MOLESTIE ELIT
-
Marketing Director
-
-
-
-
- - - -
-
-
- - - - \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/blog.html b/Website/LOC.Website.Web/Content/themes/techno/blog.html deleted file mode 100644 index fae3ece8b..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/blog.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - -Techno Theme, Blog Page - - - - - - - - - - - - - - - - -
- - - - -
- -
-
- Image 01 -

Free Website Templates

-
by Edward on March 23, 2048 in Freebie, Template | 154 comments
-

Quisque venenatis lacus vitae erat lacinia non rutrum purus suscipit. Suspendisse ligula metus, ullamcorper pretium rutrum ut, laoreet et erat. Aenean at urna sit amet massa pharetra cursus id vestibulum enim. Cras tempor, libero eget auctor consectetur, nulla lacus euismod nulla, ac fermentum sapien a libero.

- More -
-
- -
- Image 02 -

New Web Design Tips

-
by Johny on March 18, 2048 in Programming, HTML/CSS | 187 comments
-

Nulla odio sapien, mollis commodo dictum vitae, mattis eget felis. Etiam malesuada est nec nisl commodo egestas sit amet non mi. Nam a lectus et nisi congue malesuada. Pellentesque velit lacus, venenatis et vehicula ut, consequat ac arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere.

- More -
-
- -
- Image 03 -

3D Animations

-
by Eddy on March 15, 2048 in 3D, Interactive | 190 comments
-

Aenean id sapien vulputate massa tristique pretium. Vestibulum vel metus eget felis auctor aliquam. Ut enim metus, tempus id dignissim vitae, tempor at lectus. Fusce tincidunt vestibulum fringilla. Etiam lobortis nulla id augue placerat blandit. Cras quis quam sapien. Validate XHTML & CSS.

- More -
-
- -
-
- -
-
-
- - - -
-
-
- - - - \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/blog_post.html b/Website/LOC.Website.Web/Content/themes/techno/blog_post.html deleted file mode 100644 index 2ec6f2572..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/blog_post.html +++ /dev/null @@ -1,322 +0,0 @@ - - - - -Techno Theme, Blog Post Page - - - - - - - - - - - - - - - - -
- - - -
- -
-
- -

Web Design Ideas

-
by Eddy on March 15, 2048 in 3D, Interactive | 190 comments
-

Ut sed lorem ac ante cursus auctor. Nam ut congue velit. Cras eget fermentum sem. Maecenas nec purus lorem, a sodales lectus. Etiam consequat nulla sit amet nisl volutpat ornare. Donec purus nulla, egestas ac porttitor et, pharetra nec felis. Donec lobortis fringilla blandit. Fusce a purus vel pulvinar tempor.

-

Validate XHTML & CSS. Morbi venenatis augue sit amet ante facilisis feugiat sed in lectus. Vivamus imperdiet, ante a pretium vehicula, ante enim sodales mi, eu rutrum odio turpis eget arcu. Proin a elit nisl, id aliquam felis. Nunc ultrices iaculis quam, sed commodo erat tempus mollis. Duis ultricies nulla sed dolor egestas id. Donec in orci at augue tristique pretium non sed augue.

-

In eget nisl vel mauris viverra ornare id nec arcu. Sed fermentum ligula sit amet velit iaculis consectetur. Quisque in est dolor, in varius orci. Vivamus pharetra velit et ligula porttitor vel mollis est volutpat. Nunc tristique, est accumsan vulputate malesuada, tellus magna tristique diam, congue posuere est libero in arcu. Fusce eget nisl quam. Pellentesque vehicula nibh quis risus dapibus sit amet elementum nisi cursus. Ut enim mauris, vestibulum eu vehicula in, ornare vitae augue.

-

Vivamus nibh diam, pellentesque sed condimentum sed, ullamcorper eu erat. Mauris porttitor, eros in tempor dignissim, ligula justo iaculis elit, et facilisis tellus felis nec quam.

-

Nunc vitae luctus ligula. Etiam vulputate semper lorem quis gravida. Donec nec aliquam ipsum. Nulla feugiat feugiat erat et consequat. Sed hendrerit molestie ante, sit amet porta leo porta ut. Praesent adipiscing turpis at nisl dapibus vehicula. Phasellus non porttitor mi.

-
- -
- -
-

Comments

- -
-
    - -
  1. -
    - -
    - author 6 -
    - -
    -
    Steven November 21, 2048 11:35 pm
    -

    Praesent id nisi ligula. Integer congue iaculis augue et lacinia. Quisque lobortis nisl at dui vehicula nec facilisis libero dictum.

    - -
    -
    -
    - -
  2. - -
  3. - -
      - -
    1. -
      - -
      - author 6 -
      -
      -
      David November 23, 2048 10:20 pm
      -

      Cras eu turpis vitae tortor placerat lobortis nec ac velit.

      - -
      - -
      -
      - -
    2. - -
    3. - -
        - -
      1. -
        - -
        - author 6 -
        -
        -
        Albert November 25, 2048 11:42 am
        -

        Vestibulum eget ligula et ipsum laoreet aliquam sed ut risus. 

        - -
        - -
        -
        - -
      2. - -
      - -
    4. -
    - -
  4. - -
  5. -
    - -
    - author 6 -
    -
    -
    Johnny November 27, 2048 07:35 am
    -

    Nulla sagittis elit in enim ullamcorper vitae tincidunt metus bibendum.

    - -
    - -
    -
    -
  6. - -
  7. -
    - -
    - author 6 -
    -
    -
    Peter November 29, 2048 10:54 am
    -

    Quisque ut risus nibh. Etiam consequat elit eu nisi porta ac auctor nisl ultrices.

    - -
    - -
    -
    -
  8. - -
-
-
- -
- -
- -
- -
-

Leave your comment

- -
-
- -
- -
-
- -
- -
-
- -
- -
- - -
- -
- -
-
- - - -
-
-
- - - - \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/contact.html b/Website/LOC.Website.Web/Content/themes/techno/contact.html deleted file mode 100644 index 06c85d32a..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/contact.html +++ /dev/null @@ -1,173 +0,0 @@ - - - - -Techno Theme, Contact Page - - - - - - - - - - - - - - - - -
- - - -
-

Contact Information

-
-

Maecenas faucibus, libero nec laoreet, dui turpis porttitor felis, sit amet faucibus turpis sit amet arcu. Validate XHTML & CSS.

-
-
- - -
- -
- - - -
- - -
- - - - -
-
-
-
- -
-

Mailing Address

-
Company Name
- 180-320 Morbi non elit vitae faucibus,
- Vestibulum ante ipsum primis, 12480
- Proin semper tincidunt

- - Phone: 080-050-1180
- Email: info@company.com -
- -
-
-
- - - - \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/css/ddsmoothmenu.css b/Website/LOC.Website.Web/Content/themes/techno/css/ddsmoothmenu.css deleted file mode 100644 index 90b10b647..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/css/ddsmoothmenu.css +++ /dev/null @@ -1,120 +0,0 @@ -.ddsmoothmenu{ - -} - -.ddsmoothmenu ul{ - z-index:100; - margin: 0; - padding: 0; - list-style-type: none; -} - -/*Top level list items*/ -.ddsmoothmenu ul li{ - position: relative; - display: inline; - float: left; -} - -/*Top level menu link items style*/ -.ddsmoothmenu ul li a { - display: block; - height: 50px; - padding: 0 32px 0 30px; - line-height: 50px; - margin: 0 5px 0 9px; - font-size: 14px; - color: #bbb3ac; - text-align: center; - text-decoration: none; - font-weight: 400; - outline: none; - background: url(../images/templatemo_menu_divider.png) no-repeat right center -} - -* html .ddsmoothmenu ul li a{ /*IE6 hack to get sub menu links to behave correctly*/ -display: inline-block; -} - -.ddsmoothmenu ul li a.selected, .ddsmoothmenu ul li a:hover { /*CSS class that's dynamically added to the currently active menu items' LI A element*/ - color: #f2b600; -} - -/*1st sub level menu*/ -.ddsmoothmenu ul li ul{ - position: absolute; - width: 170px; - left: 0; - display: none; /*collapse all sub menus to begin with*/ - visibility: hidden; - background: #222 -} - -/*Sub level menu list items (undo style from Top level List Items)*/ -.ddsmoothmenu ul li ul li{ -display: list-item; -float: none; -} - -/*All subsequent sub menu levels vertical offset after 1st level sub menu */ -.ddsmoothmenu ul li ul li ul{ -top: 0; -} - -/* Sub level menu links style */ -.ddsmoothmenu ul li ul li a{ - font-weight: 500; - width: 140px; /*width of sub menus*/ - height: 28px; - line-height: 28px; - padding: 0 15px; - margin: 0; - font-size: 12px; - text-align: left; - background: none; - color: #bbb3ac; - border-top: 1px solid #333; - border-bottom: 1px solid #000 -} - - -.ddsmoothmenu ul li ul li a.selected, .ddsmoothmenu ul li ul li a:hover { - color: #f2b600; - width: 135px; - padding-left: 20px; - background: none; -} - -/* Holly Hack for IE \*/ -* html .ddsmoothmenu{height: 1%;} /*Holly Hack for IE7 and below*/ - - -/* ######### CSS classes applied to down and right arrow images ######### */ - -.downarrowclass{ -position: absolute; -top: 12px; -right: 7px; -} - -.rightarrowclass{ -position: absolute; -top: 6px; -right: 5px; -} - -/* ######### CSS for shadow added to sub menus ######### */ - -.ddshadow{ -position: absolute; -left: 0; -top: 0; -width: 0; -height: 0; -} - -.toplevelshadow{ /*shadow opacity. Doesn't work in IE*/ -opacity: 0.5; -} - -/* menu */ diff --git a/Website/LOC.Website.Web/Content/themes/techno/css/lightbox.css b/Website/LOC.Website.Web/Content/themes/techno/css/lightbox.css deleted file mode 100644 index 3b5f7aa91..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/css/lightbox.css +++ /dev/null @@ -1,27 +0,0 @@ -#lightbox{ position: absolute; left: 0; width: 100%; z-index: 100; text-align: center; line-height: 0;} -#lightbox img{ width: auto; height: auto;} -#lightbox a img{ border: none; } - -#outerImageContainer{ position: relative; background-color: #fff; width: 250px; height: 250px; margin: 0 auto; } -#imageContainer{ padding: 10px; } - -#loading{ position: absolute; top: 40%; left: 0%; height: 25%; width: 100%; text-align: center; line-height: 0; } -#hoverNav{ position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 10; } -#imageContainer>#hoverNav{ left: 0;} -#hoverNav a{ outline: none;} - -#prevLink, #nextLink{ width: 49%; height: 100%; background-image: url(data:image/gif;base64,AAAA); /* Trick IE into showing hover */ display: block; } -#prevLink { left: 0; float: left;} -#nextLink { right: 0; float: right;} -#prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; } -#nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; } - -#imageDataContainer{ font: 10px Verdana, Helvetica, sans-serif; background-color: #fff; margin: 0 auto; line-height: 1.4em; overflow: auto; width: 100% ; } - -#imageData{ padding:0 10px; color: #666; } -#imageData #imageDetails{ width: 70%; float: left; text-align: left; } -#imageData #caption{ font-weight: bold; } -#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; } -#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; outline: none;} - -#overlay{ position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 500px; background-color: #000; } diff --git a/Website/LOC.Website.Web/Content/themes/techno/css/muffin.css b/Website/LOC.Website.Web/Content/themes/techno/css/muffin.css deleted file mode 100644 index 2da3eb746..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/css/muffin.css +++ /dev/null @@ -1,78 +0,0 @@ -/* - Grey Suits you Sir. Please host the images on your own server. - written by Stuart Colville http://www.muffinresearch.co.uk -*/ - -table,td -{ - border : 1px solid #CCC; - border-collapse : collapse; - font : small/1.5 "Tahoma", "Bitstream Vera Sans", Verdana, Helvetica, sans-serif; -} -table -{ - border :none; - border :1px solid #CCC; -} -thead th, -tbody th -{ - background : #FFF url(../images/th_bck.gif) repeat-x; - color : #666; - padding : 5px 10px; - border-left : 1px solid #CCC; -} -tbody th -{ - background : #fafafb; - border-top : 1px solid #CCC; - text-align : left; - font-weight : normal; -} -tbody tr td -{ - padding : 5px 10px; - color : #666; -} -tbody tr:hover -{ - background : #FFF url(../images/tr_bck.gif) repeat; -} - -tbody tr:hover td -{ - color : #454545; -} -tfoot td, -tfoot th -{ - border-left : none; - border-top : 1px solid #CCC; - padding : 4px; - background : #FFF url(../images/foot_bck.gif) repeat; - color : #666; -} -caption -{ - text-align : left; - font-size : 120%; - padding : 10px 0; - color : #666; -} -table a:link -{ - color : #666; -} -table a:visited -{ - color : #666; -} -table a:hover -{ - color : #003366; - text-decoration : none; -} -table a:active -{ - color : #003366; -} \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/css/nivo-slider.css b/Website/LOC.Website.Web/Content/themes/techno/css/nivo-slider.css deleted file mode 100644 index 57f154c74..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/css/nivo-slider.css +++ /dev/null @@ -1,84 +0,0 @@ -/* - * jQuery Nivo Slider v2.4 - * http://nivo.dev7studios.com - * - * Copyright 2011, Gilbert Pellegrom - * Free to use and abuse under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - * - * March 2010 - */ - - -/* The Nivo Slider styles */ -.nivoSlider { - position:relative; -} -.nivoSlider img { - position:absolute; - top:0px; - left:0px; -} -/* If an image is wrapped in a link */ -.nivoSlider a.nivo-imageLink { - position:absolute; - top:0px; - left:0px; - width:100%; - height:100%; - border:0; - padding:0; - margin:0; - z-index:60; - display:none; -} -/* The slices in the Slider */ -.nivo-slice { - display:block; - position:absolute; - z-index:50; - height:100%; -} -/* Caption styles */ -.nivo-caption { - position:absolute; - left:0px; - bottom:0px; - background:#000; - color:#fff; - opacity:0.8; /* Overridden by captionOpacity setting */ - width:100%; - z-index:89; -} -.nivo-caption p { - padding:5px; - margin:0; -} -.nivo-caption a { - display:inline !important; -} -.nivo-html-caption { - display:none; -} -/* Direction nav styles (e.g. Next & Prev) */ -.nivo-directionNav a { - position:absolute; - top:45%; - z-index:99; - cursor:pointer; -} -.nivo-prevNav { - left:0px; -} -.nivo-nextNav { - right:0px; -} -/* Control nav styles (e.g. 1,2,3...) */ -.nivo-controlNav a { - position:relative; - z-index:99; - cursor:pointer; -} -.nivo-controlNav a.active { - font-weight:bold; -} \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/css/templatemo_style.css b/Website/LOC.Website.Web/Content/themes/techno/css/templatemo_style.css deleted file mode 100644 index 642eebf33..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/css/templatemo_style.css +++ /dev/null @@ -1,705 +0,0 @@ -/* -Credit: http://www.templatemo.com -*/ - -body { - margin: 0; - padding: 0; - color: #5e5b57; - font-family: Tahoma, Geneva, sans-serif; - font-size: 13px; - line-height: 1.4em; - background-color: #242424; - background-repeat: repeat-x; - background-position: top -} - -a, a:link, a:visited { - color: #f2b600; - font-weight: normal; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -a.learnmore { - display: block; - width: 110px; - height: 40px; - text-indent: -10000px; - background: url(../images/templatemo_learnmore.png) no-repeat; -} - -a.more { - display: inline-block; - padding-right: 24px; - font-size: 11px; - font-weight: 700; - background: url(../images/templatemo_more.png) no-repeat scroll 34px 3px; -} - -p { margin: 0 0 10px 0; padding: 0; } -img { border: none; } -blockquote { font-style: italic; margin: 0 0 0 10px;} -cite { font-weight: bold; color:#e17300; } -cite a, cite a:link, cite a:visited { font-size: 12px; text-decoration: none; font-style: normal } -cite span { font-weight: 400; color: #e17300; } - -h1, h2, h3, h4, h5, h6 { color: #f2b600; font-weight: normal; } -h1 { font-size: 48px; margin: 0 0 30px; padding: 5px 0 } -h2 { font-size: 30px; margin: 0 0 25px; padding: 5px 0 } -h3 { font-size: 24px; margin: 0 0 20px; padding: 0; } -h4 { font-size: 18px; margin: 0 0 15px; padding: 0; } -h5 { font-size: 16px; margin: 0 0 10px; padding: 0; } -h6 { font-size: 12px; margin: 0 0 5px; padding: 0; } - -.cleaner { clear: both } -.h10 { height: 10px } -.h20 { height: 20px } -.h30 { height: 30px } -.h40 { height: 40px } -.h50 { height: 50px } - -.float_l { float: left } -.float_r { float: right } - -.image_frame { - display: inline-block; - position: relative; - margin: 3px 0 10px 0; - background: #111111; - padding: 6px; - border: 1px solid #3a3a3a; -} - -.image_fl { - float: left; - margin: 3px 20px 12px 0; -} - -.image_fr { - float: right; - margin: 3px 0 12px 20px; -} - -.templatemo_list { - margin: 10px 0 10px 0; - padding: 0; - list-style: none; -} - -.templatemo_list li { - color:#5e5b57; - margin: 0 0 10px 0; - padding: 0 5px 0 20px; - background: url(../images/templatemo_list.png) no-repeat scroll 0 5px; -} - -.templatemo_list li a { - color: #5e5b57; - font-weight: normal; -} - -.templatemo_list li a:hover { color: #5e5b57 } - -.hgpackagediv -{ - border-radius:6px; - border:2px solid #ffffff; - padding:4px 0px 0px 2px; -} - -.hgpackagebutton -{ - -moz-box-shadow:inset 0px 1px 0px 0px #ffffff; - -webkit-box-shadow:inset 0px 1px 0px 0px #ffffff; - box-shadow:inset 0px 1px 0px 0px #ffffff; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #d1d1d1) ); - background:-moz-linear-gradient( center top, #ededed 5%, #d1d1d1 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#d1d1d1'); - background-color:#ededed; - -moz-border-radius:6px; - -webkit-border-radius:6px; - border-radius:6px; - border:1px solid #ffffff; - display:inline-block; - color:#171717; - font-family:arial; - font-size:15px; - font-weight:bold; - padding:6px 24px; - text-decoration:none; - text-shadow:1px 1px 0px #fcfcfc; - vertical-align: middle; - -} -.hgpackagebutton:hover -{ - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #d1d1d1), color-stop(1, #ededed) ); - background:-moz-linear-gradient( center top, #d1d1d1 5%, #ededed 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d1d1d1', endColorstr='#ededed'); - background-color:#d1d1d1; -} -.hgpackagebutton:active -{ - position:relative; - top:1px; -} - -#home { - background-image: url(../images/templatemo_home_bg.jpg); -} - -#subpage { - background-image: url(../images/templatemo_subpage_bg.jpg); -} - -#templatemo_wrapper { - width: 960px; - margin: 0 auto; - padding: 0 10px; -} -#templatemo_menu { - width: 960px; - height: 50px; -} -#templatemo_header_home { - width: 960px; - height: 150px; - background: url(../images/templatemo_home_header.jpg) no-repeat top -} -#templatemo_header_sp { - width: 960px; - height: 150px; - background: url(../images/templatemo_subpage_header.jpg) no-repeat top -} -#templatemo_middle { - width: 960px; - height: 326px; - padding-top: 15px; - background:url(../images/templatemo_middle.jpg) no-repeat bottom -} -#templatemo_main { - width: 960px; -} -#templatemo_footer_wrapper { - width: 100%; - background: #1b1b1b url(../images/templatemo_footer.jpg) repeat-x top -} -#templatemo_footer { - width: 960px; - padding: 40px 10px; - margin: 0 auto; -} - -#site_title { - margin: 0 auto; - padding: 40px 0; -} - -#site_title h1 { - margin: 0; - padding: 0; -} - -#site_title h1 a { - margin: 0 auto; - display: block; - width: 120; - height: 40px; - text-indent: -10000px; - background: url(../images/logo.png) no-repeat center bottom; -} - -#templatemo_middle_text { - float: right; - width: 500px; - padding: 20px 0; -} - -#templatemo_middle_text h2 { - color: #535353; - font-size: 28px; - font-weight: normal; - line-height: 34px; - margin-bottom: 10px; -} - -#templatemo_middle_text h2 strong { - display: block; - color: #fff; - font-size: 38px; - font-weight: normal; -} - -#templatemo_middle_text p { - color: #333; - margin-bottom: 20px; -} - -#content_top { - width: 100%; - height: 90px; - margin-bottom: 40px; -} - -#templatemo_main h2 a, #templatemo_main h3 a, #templatemo_main h4 a { color: #f2b600 } - -.col_2 { - float: left; - width: 450px; - margin-right: 60px; -} - -.col_3 { - float: left; - width: 280px; - margin-right: 60px; -} - -.col_4 { - float: left; - width: 225px; - margin-right: 20px; -} - -.no_margin_right { margin: 0 } - -#content { - float: left; - width: 620px; -} - -#sidebar { - float: right; - width: 280px; -} - -.testimonial { - padding: 0 0 0 50px; - display: block; - background: url(../images/templatemo_testimonial.png) left top no-repeat; -} - -.post { - clear: both; - padding: 40px 0; - border-bottom: 1px solid #343434; - border-top: 1px solid #000; -} - -.fpost { - padding-top: 0; - border-top: none; -} - -.post h2.home { - color: #ba8c00; - font-size: 18px; - margin-bottom: 0; -} - -.post h2 { - margin-bottom: 0; - line-height: 38px; -} - -.post .meta { - font-size: 10px; - margin-bottom: 20px; -} - -.post .meta a, .post .meta strong { - color: #7b7b7b; - font-weight: 700; -} - -#comment_section { - clear: both; - margin-bottom: 60px; - width: 590px; -} - -.first_level { - margin: 0; padding: 0; -} - -.comments { - list-style: none; -} - -.comments li { - margin-bottom: 10px; - list-style:none; -} - -.comments li .commentbox1 { - border-left: 5px solid #000; - background: #222; -} - -.comments li .commentbox2 { - border-left: 5px solid #333; - background: #292929; -} - -.comments li .comment_box { - clear: both; - width:100%; - padding: 15px; - margin-bottom: 40px; -} - -.comment_box .gravatar { - float: left; - width: 75px; - margin-right: 30px; -} - -.comment_box .gravatar img { - width: 75px; - height: 75px; -} - -.comment_box .comment_text { } - -.comment_box .comment_text p { - margin: 0; -} - -.comment_text .comment_author { - font-size: 14px; - font-weight: bold; - color: #ba8c00; - margin-bottom: 10px; -} - -.comment_text .date { - font-size: 12px; - font-weight: normal; - color: #7b7b7b; - padding-left: 10px; -} - -.comment_text .time { - font-size: 12px; - font-weight: normal; - color: #7b7b7b; - padding-left: 10px; -} - -.comment_text .reply a { - display: block; - clear: both; - float: right; - color: #000; - font-weight: 700; -} - -#comment_form { - clear: both; -} - -#comment_form h3 { - font-size: 20px; - border-bottom: 1px dotted #666; - margin-bottom: 15px; - padding-bottom: 10px; -} - -#comment_form form { -} - -#comment_form textarea { - padding: 5px; - color: #fff; - background: #333; - border: 1px solid #555; - font-size: 12px; - font-family: Tahoma, Geneva, sans-serif; - margin-top: 5px; - height:150px; - width: 400px; -} - -#comment_form .form_row { - width: 100%; - margin-bottom: 15px; -} - -#comment_form form input { - padding: 5px; - color: #fff; - background: #333; - border: 1px solid #555; - font-size: 12px; - font-family: Tahoma, Geneva, sans-serif; - margin-top: 5px; - width: 280px; -} - -#comment_form .submit_btn { - display: block; - width: 70px; - height: 30px; - padding: 5px 8px; - text-align: center; - text-decoration: none; - font-weight: bold; - background: #111; - border: 1px solid #555; - color: #fff; - font-size:12px; -} - -.rp_pp { - margin-bottom: 10px; - padding-bottom: 10px; - border-bottom: 1px dotted #ced4dc; -} - -.rp_pp a { - color: #666; - font-weight: 700; -} - -.rp_pp img { - float: right; -} - -.rp_pp p { - font-size: 10px; -} - -#contact_form { - padding: 0; - width: 460px; - margin-bottom: 40px; -} - -#contact_form form { - margin: 0px; - padding: 0px; -} - -#contact_form form .input_field { - width: 300px; - padding: 5px; - color: #fff; - background: #333; - border: 1px solid #555; - font-size: 12px; - font-family: Tahoma, Geneva, sans-serif; - margin-top: 5px; -} - -#contact_form form label { - display: block; - width: 100px; - margin-right: 12px; - font-size: 13px; -} - -#contact_form form textarea { - width: 448px; - height: 210px; - padding: 5px; - color: #fff; - background: #333; - border: 1px solid #555; - font-size: 12px; - font-family: Tahoma, Geneva, sans-serif; - margin-top: 5px; -} - -#contact_form form .submit_btn { - padding: 5px 14px; - background: #333; - border: 1px solid #555; - color: #fff; - font-size:14px; - margin: 10px 0px; -} - -#templatemo_footer h5 { - font-size: 14px; - font-weight: 700; - margin-bottom: 20px; -} - -.footer_list { - margin: 0; - padding: 0; - list-style: none; -} - -.footer_list li { - margin: 0 0 5px; - padding: 0 0 3px; - border-bottom: 1px dotted #433854; -} - -.footer_list li a { - color: #666; -} - -.twitter_post { - margin: 0; - padding: 0; - list-style: none; -} - -.twitter_post li { - margin: 0 0 10px; - padding: 0 0 7px; - border-bottom: 1px dotted #433854; -} - -.footer_social_button { - clear: both; - margin-top: 20px; -} - -.footer_social_button a { - margin-right: 5px; -} - -#slider-wrapper { - float: left; - width: 360px; - height: 228px; - margin: 0 0 0; - padding: 10px 11px 14px; - background: url(../images/templatemo_slider.png) no-repeat -} - -#slider { - position:relative; - width: 360px; - height: 228px; - background:url(../images/loading.gif) no-repeat 50% 50%; -} - -#slider img { - position:absolute; - top:0px; - left:0px; - display:none; -} - -#slider a { - border:0; - display:block; -} - -.nivo-controlNav { - position:absolute; - left:260px; - bottom:-42px; -} - -.nivo-controlNav a { - display:block; - width:22px; - height:22px; - background:url(../images/bullets.png) no-repeat; - text-indent:-9999px; - border:0; - margin-right:3px; - float:left; -} - -.nivo-controlNav a.active { - background-position:0 -22px; -} - -.nivo-directionNav a { - display:block; - width:30px; - height:30px; - background:url(../images/arrows.png) no-repeat; - text-indent:-9999px; - border:0; -} - -a.nivo-nextNav { - background-position:-30px 0; - right:15px; -} - -a.nivo-prevNav { - left:15px; -} - -.nivo-caption { - text-shadow:none; - font-family: Helvetica, Arial, sans-serif; -} - -.nivo-caption a { - color:#efe9d1; - text-decoration:underline; -} - -.no_margin_right { - margin-right: 0; -} - -.no_pmb { - padding-bottom: 0; - margin-bottom: 0; - border-bottom: 0; -} - -.pagging { - margin: 0 0 20px; - padding: 0; -} - -.pagging ul { - margin: 0; - padding: 0; - list-style: none; -} - -.pagging ul li { - margin: 0; - padding: 0; - display: inline; -} - -.pagging ul li a { - float: left; - display: block; - color: #333; - text-decoration: none; - margin-right: 5px; - padding: 5px 10px; - background-color: #000; - border: 1px solid #2f2f2f; -} - -.pagging ul li a:hover { - background: #f2b600; - border: 1px solid #dfdfdf; - color: #fff; -} - -legend { - color:#efe9d1; - font-size: 16px; -} - -table tr td -{ - color:#000000; - background-color:#8F948C; -} - -table tr.alt td -{ - color:#000000; - background-color:#C5C9C1; -} \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/36_64x64.png b/Website/LOC.Website.Web/Content/themes/techno/images/36_64x64.png deleted file mode 100644 index e42296374..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/36_64x64.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/41_64x64.png b/Website/LOC.Website.Web/Content/themes/techno/images/41_64x64.png deleted file mode 100644 index e1f8ca8a6..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/41_64x64.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/arrows.png b/Website/LOC.Website.Web/Content/themes/techno/images/arrows.png deleted file mode 100644 index 8f562bd81..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/arrows.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/avator.png b/Website/LOC.Website.Web/Content/themes/techno/images/avator.png deleted file mode 100644 index c70655997..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/avator.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/blog/01.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/blog/01.jpg deleted file mode 100644 index af6b814ca..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/blog/01.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/blog/02.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/blog/02.jpg deleted file mode 100644 index bb2deae80..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/blog/02.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/blog/03.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/blog/03.jpg deleted file mode 100644 index c3d77ab99..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/blog/03.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/blog/04.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/blog/04.jpg deleted file mode 100644 index 4d49cae14..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/blog/04.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/close.gif b/Website/LOC.Website.Web/Content/themes/techno/images/close.gif deleted file mode 100644 index ca517b6ab..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/close.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/closelabel.gif b/Website/LOC.Website.Web/Content/themes/techno/images/closelabel.gif deleted file mode 100644 index 87b4f8bd6..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/closelabel.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/facebook.png b/Website/LOC.Website.Web/Content/themes/techno/images/facebook.png deleted file mode 100644 index c46485acc..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/facebook.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/feed.png b/Website/LOC.Website.Web/Content/themes/techno/images/feed.png deleted file mode 100644 index acb923e12..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/feed.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/flickr.png b/Website/LOC.Website.Web/Content/themes/techno/images/flickr.png deleted file mode 100644 index f803e7376..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/flickr.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/foot_bck.gif b/Website/LOC.Website.Web/Content/themes/techno/images/foot_bck.gif deleted file mode 100644 index 99de53ad5..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/foot_bck.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/loading.gif b/Website/LOC.Website.Web/Content/themes/techno/images/loading.gif deleted file mode 100644 index f864d5fd3..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/loading.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/logo.png b/Website/LOC.Website.Web/Content/themes/techno/images/logo.png deleted file mode 100644 index f5932863d..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/logo.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/nextlabel.gif b/Website/LOC.Website.Web/Content/themes/techno/images/nextlabel.gif deleted file mode 100644 index 6c40e51a3..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/nextlabel.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/01.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/01.jpg deleted file mode 100644 index dc458b7a3..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/01.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/02.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/02.jpg deleted file mode 100644 index c5251dbb4..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/02.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/03.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/03.jpg deleted file mode 100644 index 62d50513e..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/03.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/04.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/04.jpg deleted file mode 100644 index de5a2377b..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/portfolio/04.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/prevlabel.gif b/Website/LOC.Website.Web/Content/themes/techno/images/prevlabel.gif deleted file mode 100644 index 51a31c2fd..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/prevlabel.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/slider/01.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/slider/01.jpg deleted file mode 100644 index eec90e360..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/slider/01.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/slider/02.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/slider/02.jpg deleted file mode 100644 index f34dabf3e..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/slider/02.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/slider/03.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/slider/03.jpg deleted file mode 100644 index 134d92419..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/slider/03.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/slider/04.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/slider/04.jpg deleted file mode 100644 index ed22bb0a5..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/slider/04.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/slider/ss.png b/Website/LOC.Website.Web/Content/themes/techno/images/slider/ss.png deleted file mode 100644 index 3560bbe12..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/slider/ss.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/ss1.png b/Website/LOC.Website.Web/Content/themes/techno/images/ss1.png deleted file mode 100644 index 035e7dd03..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/ss1.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/ss2.png b/Website/LOC.Website.Web/Content/themes/techno/images/ss2.png deleted file mode 100644 index 501a61cf0..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/ss2.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/ss3.png b/Website/LOC.Website.Web/Content/themes/techno/images/ss3.png deleted file mode 100644 index e62de9648..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/ss3.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_footer.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_footer.jpg deleted file mode 100644 index 35837bf45..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_footer.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_home_bg.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_home_bg.jpg deleted file mode 100644 index 018328b92..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_home_bg.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_home_header.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_home_header.jpg deleted file mode 100644 index 0aaa45aae..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_home_header.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_01.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_01.png deleted file mode 100644 index 358d14a22..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_01.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_02.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_02.png deleted file mode 100644 index 27bf5cc36..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_02.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_03.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_03.png deleted file mode 100644 index 419798597..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_03.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_04.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_04.png deleted file mode 100644 index 8aeb40edc..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_04.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_05.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_05.png deleted file mode 100644 index e063ab36f..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_05.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_06.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_06.png deleted file mode 100644 index 7626ea858..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_06.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_07.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_07.png deleted file mode 100644 index f80f1944d..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_image_07.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_learnmore.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_learnmore.png deleted file mode 100644 index 6267e8513..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_learnmore.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_list.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_list.png deleted file mode 100644 index a9f76b92b..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_list.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_logo.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_logo.png deleted file mode 100644 index 8f9a65dc9..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_logo.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_menu_divider.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_menu_divider.png deleted file mode 100644 index 9d2b575b2..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_menu_divider.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_middle.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_middle.jpg deleted file mode 100644 index fa5c85ecc..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_middle.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_more.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_more.png deleted file mode 100644 index 1d62035a0..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_more.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_slider.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_slider.png deleted file mode 100644 index ee74a08c5..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_slider.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_subpage_bg.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_subpage_bg.jpg deleted file mode 100644 index 7660e5a32..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_subpage_bg.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_subpage_header.jpg b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_subpage_header.jpg deleted file mode 100644 index a7fc1f7e8..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_subpage_header.jpg and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_testimonial.png b/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_testimonial.png deleted file mode 100644 index 910970f54..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/templatemo_testimonial.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/th_bck.gif b/Website/LOC.Website.Web/Content/themes/techno/images/th_bck.gif deleted file mode 100644 index e172e25ed..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/th_bck.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/tr_bck.gif b/Website/LOC.Website.Web/Content/themes/techno/images/tr_bck.gif deleted file mode 100644 index ff6658ef8..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/tr_bck.gif and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/twitter.png b/Website/LOC.Website.Web/Content/themes/techno/images/twitter.png deleted file mode 100644 index 0a75ea8d7..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/twitter.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/images/youtube.png b/Website/LOC.Website.Web/Content/themes/techno/images/youtube.png deleted file mode 100644 index 1d4dd95bf..000000000 Binary files a/Website/LOC.Website.Web/Content/themes/techno/images/youtube.png and /dev/null differ diff --git a/Website/LOC.Website.Web/Content/themes/techno/js/builder.js b/Website/LOC.Website.Web/Content/themes/techno/js/builder.js deleted file mode 100644 index 830199944..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/js/builder.js +++ /dev/null @@ -1,136 +0,0 @@ -// script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 - -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -var Builder = { - NODEMAP: { - AREA: 'map', - CAPTION: 'table', - COL: 'table', - COLGROUP: 'table', - LEGEND: 'fieldset', - OPTGROUP: 'select', - OPTION: 'select', - PARAM: 'object', - TBODY: 'table', - TD: 'table', - TFOOT: 'table', - TH: 'table', - THEAD: 'table', - TR: 'table' - }, - // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken, - // due to a Firefox bug - node: function(elementName) { - elementName = elementName.toUpperCase(); - - // try innerHTML approach - var parentTag = this.NODEMAP[elementName] || 'div'; - var parentElement = document.createElement(parentTag); - try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 - parentElement.innerHTML = "<" + elementName + ">"; - } catch(e) {} - var element = parentElement.firstChild || null; - - // see if browser added wrapping tags - if(element && (element.tagName.toUpperCase() != elementName)) - element = element.getElementsByTagName(elementName)[0]; - - // fallback to createElement approach - if(!element) element = document.createElement(elementName); - - // abort if nothing could be created - if(!element) return; - - // attributes (or text) - if(arguments[1]) - if(this._isStringOrNumber(arguments[1]) || - (arguments[1] instanceof Array) || - arguments[1].tagName) { - this._children(element, arguments[1]); - } else { - var attrs = this._attributes(arguments[1]); - if(attrs.length) { - try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 - parentElement.innerHTML = "<" +elementName + " " + - attrs + ">"; - } catch(e) {} - element = parentElement.firstChild || null; - // workaround firefox 1.0.X bug - if(!element) { - element = document.createElement(elementName); - for(attr in arguments[1]) - element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; - } - if(element.tagName.toUpperCase() != elementName) - element = parentElement.getElementsByTagName(elementName)[0]; - } - } - - // text, or array of children - if(arguments[2]) - this._children(element, arguments[2]); - - return element; - }, - _text: function(text) { - return document.createTextNode(text); - }, - - ATTR_MAP: { - 'className': 'class', - 'htmlFor': 'for' - }, - - _attributes: function(attributes) { - var attrs = []; - for(attribute in attributes) - attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + - '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'"') + '"'); - return attrs.join(" "); - }, - _children: function(element, children) { - if(children.tagName) { - element.appendChild(children); - return; - } - if(typeof children=='object') { // array can hold nodes and text - children.flatten().each( function(e) { - if(typeof e=='object') - element.appendChild(e) - else - if(Builder._isStringOrNumber(e)) - element.appendChild(Builder._text(e)); - }); - } else - if(Builder._isStringOrNumber(children)) - element.appendChild(Builder._text(children)); - }, - _isStringOrNumber: function(param) { - return(typeof param=='string' || typeof param=='number'); - }, - build: function(html) { - var element = this.node('div'); - $(element).update(html.strip()); - return element.down(); - }, - dump: function(scope) { - if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope - - var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + - "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + - "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ - "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ - "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ - "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); - - tags.each( function(tag){ - scope[tag] = function() { - return Builder.node.apply(Builder, [tag].concat($A(arguments))); - } - }); - } -} diff --git a/Website/LOC.Website.Web/Content/themes/techno/js/effects.js b/Website/LOC.Website.Web/Content/themes/techno/js/effects.js deleted file mode 100644 index b8c0259f5..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/js/effects.js +++ /dev/null @@ -1,1122 +0,0 @@ -// script.aculo.us effects.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 - -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// Contributors: -// Justin Palmer (http://encytemedia.com/) -// Mark Pilgrim (http://diveintomark.org/) -// Martin Bialasinki -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -// converts rgb() and #xxx to #xxxxxx format, -// returns self (or first argument) if not convertable -String.prototype.parseColor = function() { - var color = '#'; - if (this.slice(0,4) == 'rgb(') { - var cols = this.slice(4,this.length-1).split(','); - var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); - } else { - if (this.slice(0,1) == '#') { - if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); - if (this.length==7) color = this.toLowerCase(); - } - } - return (color.length==7 ? color : (arguments[0] || this)); -}; - -/*--------------------------------------------------------------------------*/ - -Element.collectTextNodes = function(element) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); - }).flatten().join(''); -}; - -Element.collectTextNodesIgnoreClass = function(element, className) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? - Element.collectTextNodesIgnoreClass(node, className) : '')); - }).flatten().join(''); -}; - -Element.setContentZoom = function(element, percent) { - element = $(element); - element.setStyle({fontSize: (percent/100) + 'em'}); - if (Prototype.Browser.WebKit) window.scrollBy(0,0); - return element; -}; - -Element.getInlineOpacity = function(element){ - return $(element).style.opacity || ''; -}; - -Element.forceRerendering = function(element) { - try { - element = $(element); - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch(e) { } -}; - -/*--------------------------------------------------------------------------*/ - -var Effect = { - _elementDoesNotExistError: { - name: 'ElementDoesNotExistError', - message: 'The specified DOM element does not exist, but is required for this effect to operate' - }, - Transitions: { - linear: Prototype.K, - sinoidal: function(pos) { - return (-Math.cos(pos*Math.PI)/2) + 0.5; - }, - reverse: function(pos) { - return 1-pos; - }, - flicker: function(pos) { - var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; - return pos > 1 ? 1 : pos; - }, - wobble: function(pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; - }, - pulse: function(pos, pulses) { - pulses = pulses || 5; - return ( - ((pos % (1/pulses)) * pulses).round() == 0 ? - ((pos * pulses * 2) - (pos * pulses * 2).floor()) : - 1 - ((pos * pulses * 2) - (pos * pulses * 2).floor()) - ); - }, - spring: function(pos) { - return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); - }, - none: function(pos) { - return 0; - }, - full: function(pos) { - return 1; - } - }, - DefaultOptions: { - duration: 1.0, // seconds - fps: 100, // 100= assume 66fps max. - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' - }, - tagifyText: function(element) { - var tagifyStyle = 'position:relative'; - if (Prototype.Browser.IE) tagifyStyle += ';zoom:1'; - - element = $(element); - $A(element.childNodes).each( function(child) { - if (child.nodeType==3) { - child.nodeValue.toArray().each( function(character) { - element.insertBefore( - new Element('span', {style: tagifyStyle}).update( - character == ' ' ? String.fromCharCode(160) : character), - child); - }); - Element.remove(child); - } - }); - }, - multiple: function(element, effect) { - var elements; - if (((typeof element == 'object') || - Object.isFunction(element)) && - (element.length)) - elements = element; - else - elements = $(element).childNodes; - - var options = Object.extend({ - speed: 0.1, - delay: 0.0 - }, arguments[2] || { }); - var masterDelay = options.delay; - - $A(elements).each( function(element, index) { - new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); - }); - }, - PAIRS: { - 'slide': ['SlideDown','SlideUp'], - 'blind': ['BlindDown','BlindUp'], - 'appear': ['Appear','Fade'] - }, - toggle: function(element, effect) { - element = $(element); - effect = (effect || 'appear').toLowerCase(); - var options = Object.extend({ - queue: { position:'end', scope:(element.id || 'global'), limit: 1 } - }, arguments[2] || { }); - Effect[element.visible() ? - Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); - } -}; - -Effect.DefaultOptions.transition = Effect.Transitions.sinoidal; - -/* ------------- core effects ------------- */ - -Effect.ScopedQueue = Class.create(Enumerable, { - initialize: function() { - this.effects = []; - this.interval = null; - }, - _each: function(iterator) { - this.effects._each(iterator); - }, - add: function(effect) { - var timestamp = new Date().getTime(); - - var position = Object.isString(effect.options.queue) ? - effect.options.queue : effect.options.queue.position; - - switch(position) { - case 'front': - // move unstarted effects after this effect - this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { - e.startOn += effect.finishOn; - e.finishOn += effect.finishOn; - }); - break; - case 'with-last': - timestamp = this.effects.pluck('startOn').max() || timestamp; - break; - case 'end': - // start effect after last queued effect has finished - timestamp = this.effects.pluck('finishOn').max() || timestamp; - break; - } - - effect.startOn += timestamp; - effect.finishOn += timestamp; - - if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) - this.effects.push(effect); - - if (!this.interval) - this.interval = setInterval(this.loop.bind(this), 15); - }, - remove: function(effect) { - this.effects = this.effects.reject(function(e) { return e==effect }); - if (this.effects.length == 0) { - clearInterval(this.interval); - this.interval = null; - } - }, - loop: function() { - var timePos = new Date().getTime(); - for(var i=0, len=this.effects.length;i= this.startOn) { - if (timePos >= this.finishOn) { - this.render(1.0); - this.cancel(); - this.event('beforeFinish'); - if (this.finish) this.finish(); - this.event('afterFinish'); - return; - } - var pos = (timePos - this.startOn) / this.totalTime, - frame = (pos * this.totalFrames).round(); - if (frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - cancel: function() { - if (!this.options.sync) - Effect.Queues.get(Object.isString(this.options.queue) ? - 'global' : this.options.queue.scope).remove(this); - this.state = 'finished'; - }, - event: function(eventName) { - if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); - if (this.options[eventName]) this.options[eventName](this); - }, - inspect: function() { - var data = $H(); - for(property in this) - if (!Object.isFunction(this[property])) data.set(property, this[property]); - return '#'; - } -}); - -Effect.Parallel = Class.create(Effect.Base, { - initialize: function(effects) { - this.effects = effects || []; - this.start(arguments[1]); - }, - update: function(position) { - this.effects.invoke('render', position); - }, - finish: function(position) { - this.effects.each( function(effect) { - effect.render(1.0); - effect.cancel(); - effect.event('beforeFinish'); - if (effect.finish) effect.finish(position); - effect.event('afterFinish'); - }); - } -}); - -Effect.Tween = Class.create(Effect.Base, { - initialize: function(object, from, to) { - object = Object.isString(object) ? $(object) : object; - var args = $A(arguments), method = args.last(), - options = args.length == 5 ? args[3] : null; - this.method = Object.isFunction(method) ? method.bind(object) : - Object.isFunction(object[method]) ? object[method].bind(object) : - function(value) { object[method] = value }; - this.start(Object.extend({ from: from, to: to }, options || { })); - }, - update: function(position) { - this.method(position); - } -}); - -Effect.Event = Class.create(Effect.Base, { - initialize: function() { - this.start(Object.extend({ duration: 0 }, arguments[0] || { })); - }, - update: Prototype.emptyFunction -}); - -Effect.Opacity = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - // make this work on IE on elements without 'layout' - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - var options = Object.extend({ - from: this.element.getOpacity() || 0.0, - to: 1.0 - }, arguments[1] || { }); - this.start(options); - }, - update: function(position) { - this.element.setOpacity(position); - } -}); - -Effect.Move = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - x: 0, - y: 0, - mode: 'relative' - }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - this.element.makePositioned(); - this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); - this.originalTop = parseFloat(this.element.getStyle('top') || '0'); - if (this.options.mode == 'absolute') { - this.options.x = this.options.x - this.originalLeft; - this.options.y = this.options.y - this.originalTop; - } - }, - update: function(position) { - this.element.setStyle({ - left: (this.options.x * position + this.originalLeft).round() + 'px', - top: (this.options.y * position + this.originalTop).round() + 'px' - }); - } -}); - -// for backwards compatibility -Effect.MoveBy = function(element, toTop, toLeft) { - return new Effect.Move(element, - Object.extend({ x: toLeft, y: toTop }, arguments[3] || { })); -}; - -Effect.Scale = Class.create(Effect.Base, { - initialize: function(element, percent) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - scaleX: true, - scaleY: true, - scaleContent: true, - scaleFromCenter: false, - scaleMode: 'box', // 'box' or 'contents' or { } with provided values - scaleFrom: 100.0, - scaleTo: percent - }, arguments[2] || { }); - this.start(options); - }, - setup: function() { - this.restoreAfterFinish = this.options.restoreAfterFinish || false; - this.elementPositioning = this.element.getStyle('position'); - - this.originalStyle = { }; - ['top','left','width','height','fontSize'].each( function(k) { - this.originalStyle[k] = this.element.style[k]; - }.bind(this)); - - this.originalTop = this.element.offsetTop; - this.originalLeft = this.element.offsetLeft; - - var fontSize = this.element.getStyle('font-size') || '100%'; - ['em','px','%','pt'].each( function(fontSizeType) { - if (fontSize.indexOf(fontSizeType)>0) { - this.fontSize = parseFloat(fontSize); - this.fontSizeType = fontSizeType; - } - }.bind(this)); - - this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; - - this.dims = null; - if (this.options.scaleMode=='box') - this.dims = [this.element.offsetHeight, this.element.offsetWidth]; - if (/^content/.test(this.options.scaleMode)) - this.dims = [this.element.scrollHeight, this.element.scrollWidth]; - if (!this.dims) - this.dims = [this.options.scaleMode.originalHeight, - this.options.scaleMode.originalWidth]; - }, - update: function(position) { - var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); - if (this.options.scaleContent && this.fontSize) - this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType }); - this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); - }, - finish: function(position) { - if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle); - }, - setDimensions: function(height, width) { - var d = { }; - if (this.options.scaleX) d.width = width.round() + 'px'; - if (this.options.scaleY) d.height = height.round() + 'px'; - if (this.options.scaleFromCenter) { - var topd = (height - this.dims[0])/2; - var leftd = (width - this.dims[1])/2; - if (this.elementPositioning == 'absolute') { - if (this.options.scaleY) d.top = this.originalTop-topd + 'px'; - if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; - } else { - if (this.options.scaleY) d.top = -topd + 'px'; - if (this.options.scaleX) d.left = -leftd + 'px'; - } - } - this.element.setStyle(d); - } -}); - -Effect.Highlight = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - // Prevent executing on elements not in the layout flow - if (this.element.getStyle('display')=='none') { this.cancel(); return; } - // Disable background image during the effect - this.oldStyle = { }; - if (!this.options.keepBackgroundImage) { - this.oldStyle.backgroundImage = this.element.getStyle('background-image'); - this.element.setStyle({backgroundImage: 'none'}); - } - if (!this.options.endcolor) - this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); - if (!this.options.restorecolor) - this.options.restorecolor = this.element.getStyle('background-color'); - // init color calculations - this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); - this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); - }, - update: function(position) { - this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){ - return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) }); - }, - finish: function() { - this.element.setStyle(Object.extend(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -Effect.ScrollTo = function(element) { - var options = arguments[1] || { }, - scrollOffsets = document.viewport.getScrollOffsets(), - elementOffsets = $(element).cumulativeOffset(), - max = (window.height || document.body.scrollHeight) - document.viewport.getHeight(); - - if (options.offset) elementOffsets[1] += options.offset; - - return new Effect.Tween(null, - scrollOffsets.top, - elementOffsets[1] > max ? max : elementOffsets[1], - options, - function(p){ scrollTo(scrollOffsets.left, p.round()) } - ); -}; - -/* ------------- combination effects ------------- */ - -Effect.Fade = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - var options = Object.extend({ - from: element.getOpacity() || 1.0, - to: 0.0, - afterFinishInternal: function(effect) { - if (effect.options.to!=0) return; - effect.element.hide().setStyle({opacity: oldOpacity}); - } - }, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Appear = function(element) { - element = $(element); - var options = Object.extend({ - from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0), - to: 1.0, - // force Safari to render floated elements properly - afterFinishInternal: function(effect) { - effect.element.forceRerendering(); - }, - beforeSetup: function(effect) { - effect.element.setOpacity(effect.options.from).show(); - }}, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Puff = function(element) { - element = $(element); - var oldStyle = { - opacity: element.getInlineOpacity(), - position: element.getStyle('position'), - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height - }; - return new Effect.Parallel( - [ new Effect.Scale(element, 200, - { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], - Object.extend({ duration: 1.0, - beforeSetupInternal: function(effect) { - Position.absolutize(effect.effects[0].element) - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().setStyle(oldStyle); } - }, arguments[1] || { }) - ); -}; - -Effect.BlindUp = function(element) { - element = $(element); - element.makeClipping(); - return new Effect.Scale(element, 0, - Object.extend({ scaleContent: false, - scaleX: false, - restoreAfterFinish: true, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }, arguments[1] || { }) - ); -}; - -Effect.BlindDown = function(element) { - element = $(element); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping(); - } - }, arguments[1] || { })); -}; - -Effect.SwitchOff = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - return new Effect.Appear(element, Object.extend({ - duration: 0.4, - from: 0, - transition: Effect.Transitions.flicker, - afterFinishInternal: function(effect) { - new Effect.Scale(effect.element, 1, { - duration: 0.3, scaleFromCenter: true, - scaleX: false, scaleContent: false, restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); - } - }) - } - }, arguments[1] || { })); -}; - -Effect.DropOut = function(element) { - element = $(element); - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left'), - opacity: element.getInlineOpacity() }; - return new Effect.Parallel( - [ new Effect.Move(element, {x: 0, y: 100, sync: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 }) ], - Object.extend( - { duration: 0.5, - beforeSetup: function(effect) { - effect.effects[0].element.makePositioned(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); - } - }, arguments[1] || { })); -}; - -Effect.Shake = function(element) { - element = $(element); - var options = Object.extend({ - distance: 20, - duration: 0.5 - }, arguments[1] || {}); - var distance = parseFloat(options.distance); - var split = parseFloat(options.duration) / 10.0; - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left') }; - return new Effect.Move(element, - { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) { - effect.element.undoPositioned().setStyle(oldStyle); - }}) }}) }}) }}) }}) }}); -}; - -Effect.SlideDown = function(element) { - element = $(element).cleanWhitespace(); - // SlideDown need to have the content of the element wrapped in a container element with fixed height! - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: window.opera ? 0 : 1, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } - }, arguments[1] || { }) - ); -}; - -Effect.SlideUp = function(element) { - element = $(element).cleanWhitespace(); - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, window.opera ? 0 : 1, - Object.extend({ scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); - } - }, arguments[1] || { }) - ); -}; - -// Bug in opera makes the TD containing this element expand for a instance after finish -Effect.Squish = function(element) { - return new Effect.Scale(element, window.opera ? 1 : 0, { - restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }); -}; - -Effect.Grow = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.full - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var initialMoveX, initialMoveY; - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - initialMoveX = initialMoveY = moveX = moveY = 0; - break; - case 'top-right': - initialMoveX = dims.width; - initialMoveY = moveY = 0; - moveX = -dims.width; - break; - case 'bottom-left': - initialMoveX = moveX = 0; - initialMoveY = dims.height; - moveY = -dims.height; - break; - case 'bottom-right': - initialMoveX = dims.width; - initialMoveY = dims.height; - moveX = -dims.width; - moveY = -dims.height; - break; - case 'center': - initialMoveX = dims.width / 2; - initialMoveY = dims.height / 2; - moveX = -dims.width / 2; - moveY = -dims.height / 2; - break; - } - - return new Effect.Move(element, { - x: initialMoveX, - y: initialMoveY, - duration: 0.01, - beforeSetup: function(effect) { - effect.element.hide().makeClipping().makePositioned(); - }, - afterFinishInternal: function(effect) { - new Effect.Parallel( - [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), - new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), - new Effect.Scale(effect.element, 100, { - scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, - sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) - ], Object.extend({ - beforeSetup: function(effect) { - effect.effects[0].element.setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); - } - }, options) - ) - } - }); -}; - -Effect.Shrink = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.none - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - moveX = moveY = 0; - break; - case 'top-right': - moveX = dims.width; - moveY = 0; - break; - case 'bottom-left': - moveX = 0; - moveY = dims.height; - break; - case 'bottom-right': - moveX = dims.width; - moveY = dims.height; - break; - case 'center': - moveX = dims.width / 2; - moveY = dims.height / 2; - break; - } - - return new Effect.Parallel( - [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), - new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), - new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) - ], Object.extend({ - beforeStartInternal: function(effect) { - effect.effects[0].element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } - }, options) - ); -}; - -Effect.Pulsate = function(element) { - element = $(element); - var options = arguments[1] || { }; - var oldOpacity = element.getInlineOpacity(); - var transition = options.transition || Effect.Transitions.sinoidal; - var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) }; - reverser.bind(transition); - return new Effect.Opacity(element, - Object.extend(Object.extend({ duration: 2.0, from: 0, - afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } - }, options), {transition: reverser})); -}; - -Effect.Fold = function(element) { - element = $(element); - var oldStyle = { - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height }; - element.makeClipping(); - return new Effect.Scale(element, 5, Object.extend({ - scaleContent: false, - scaleX: false, - afterFinishInternal: function(effect) { - new Effect.Scale(element, 1, { - scaleContent: false, - scaleY: false, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().setStyle(oldStyle); - } }); - }}, arguments[1] || { })); -}; - -Effect.Morph = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - style: { } - }, arguments[1] || { }); - - if (!Object.isString(options.style)) this.style = $H(options.style); - else { - if (options.style.include(':')) - this.style = options.style.parseStyle(); - else { - this.element.addClassName(options.style); - this.style = $H(this.element.getStyles()); - this.element.removeClassName(options.style); - var css = this.element.getStyles(); - this.style = this.style.reject(function(style) { - return style.value == css[style.key]; - }); - options.afterFinishInternal = function(effect) { - effect.element.addClassName(effect.options.style); - effect.transforms.each(function(transform) { - effect.element.style[transform.style] = ''; - }); - } - } - } - this.start(options); - }, - - setup: function(){ - function parseColor(color){ - if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; - color = color.parseColor(); - return $R(0,2).map(function(i){ - return parseInt( color.slice(i*2+1,i*2+3), 16 ) - }); - } - this.transforms = this.style.map(function(pair){ - var property = pair[0], value = pair[1], unit = null; - - if (value.parseColor('#zzzzzz') != '#zzzzzz') { - value = value.parseColor(); - unit = 'color'; - } else if (property == 'opacity') { - value = parseFloat(value); - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - } else if (Element.CSS_LENGTH.test(value)) { - var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); - value = parseFloat(components[1]); - unit = (components.length == 3) ? components[2] : null; - } - - var originalValue = this.element.getStyle(property); - return { - style: property.camelize(), - originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), - targetValue: unit=='color' ? parseColor(value) : value, - unit: unit - }; - }.bind(this)).reject(function(transform){ - return ( - (transform.originalValue == transform.targetValue) || - ( - transform.unit != 'color' && - (isNaN(transform.originalValue) || isNaN(transform.targetValue)) - ) - ) - }); - }, - update: function(position) { - var style = { }, transform, i = this.transforms.length; - while(i--) - style[(transform = this.transforms[i]).style] = - transform.unit=='color' ? '#'+ - (Math.round(transform.originalValue[0]+ - (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() + - (Math.round(transform.originalValue[1]+ - (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() + - (Math.round(transform.originalValue[2]+ - (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() : - (transform.originalValue + - (transform.targetValue - transform.originalValue) * position).toFixed(3) + - (transform.unit === null ? '' : transform.unit); - this.element.setStyle(style, true); - } -}); - -Effect.Transform = Class.create({ - initialize: function(tracks){ - this.tracks = []; - this.options = arguments[1] || { }; - this.addTracks(tracks); - }, - addTracks: function(tracks){ - tracks.each(function(track){ - track = $H(track); - var data = track.values().first(); - this.tracks.push($H({ - ids: track.keys().first(), - effect: Effect.Morph, - options: { style: data } - })); - }.bind(this)); - return this; - }, - play: function(){ - return new Effect.Parallel( - this.tracks.map(function(track){ - var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options'); - var elements = [$(ids) || $$(ids)].flatten(); - return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) }); - }).flatten(), - this.options - ); - } -}); - -Element.CSS_PROPERTIES = $w( - 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + - 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + - 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + - 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + - 'fontSize fontWeight height left letterSpacing lineHeight ' + - 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ - 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + - 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + - 'right textIndent top width wordSpacing zIndex'); - -Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; - -String.__parseStyleElement = document.createElement('div'); -String.prototype.parseStyle = function(){ - var style, styleRules = $H(); - if (Prototype.Browser.WebKit) - style = new Element('div',{style:this}).style; - else { - String.__parseStyleElement.innerHTML = '
'; - style = String.__parseStyleElement.childNodes[0].style; - } - - Element.CSS_PROPERTIES.each(function(property){ - if (style[property]) styleRules.set(property, style[property]); - }); - - if (Prototype.Browser.IE && this.include('opacity')) - styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]); - - return styleRules; -}; - -if (document.defaultView && document.defaultView.getComputedStyle) { - Element.getStyles = function(element) { - var css = document.defaultView.getComputedStyle($(element), null); - return Element.CSS_PROPERTIES.inject({ }, function(styles, property) { - styles[property] = css[property]; - return styles; - }); - }; -} else { - Element.getStyles = function(element) { - element = $(element); - var css = element.currentStyle, styles; - styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) { - results[property] = css[property]; - return results; - }); - if (!styles.opacity) styles.opacity = element.getOpacity(); - return styles; - }; -}; - -Effect.Methods = { - morph: function(element, style) { - element = $(element); - new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { })); - return element; - }, - visualEffect: function(element, effect, options) { - element = $(element) - var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1); - new Effect[klass](element, options); - return element; - }, - highlight: function(element, options) { - element = $(element); - new Effect.Highlight(element, options); - return element; - } -}; - -$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+ - 'pulsate shake puff squish switchOff dropOut').each( - function(effect) { - Effect.Methods[effect] = function(element, options){ - element = $(element); - Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); - return element; - } - } -); - -$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( - function(f) { Effect.Methods[f] = Element[f]; } -); - -Element.addMethods(Effect.Methods); diff --git a/Website/LOC.Website.Web/Content/themes/techno/js/jquery-1.4.3.min.js b/Website/LOC.Website.Web/Content/themes/techno/js/jquery-1.4.3.min.js deleted file mode 100644 index c941a5f7a..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/js/jquery-1.4.3.min.js +++ /dev/null @@ -1,166 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.3 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Oct 14 23:10:06 2010 -0400 - */ -(function(E,A){function U(){return false}function ba(){return true}function ja(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ga(a){var b,d,e=[],f=[],h,k,l,n,s,v,B,D;k=c.data(this,this.nodeType?"events":"__events__");if(typeof k==="function")k=k.events;if(!(a.liveFired===this||!k||!k.live||a.button&&a.type==="click")){if(a.namespace)D=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var H=k.live.slice(0);for(n=0;nd)break;a.currentTarget=f.elem;a.data=f.handleObj.data; -a.handleObj=f.handleObj;D=f.handleObj.origHandler.apply(f.elem,arguments);if(D===false||a.isPropagationStopped()){d=f.level;if(D===false)b=false}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(Ha,"`").replace(Ia,"&")}function ka(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Ja.test(b))return c.filter(b, -e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function la(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this,e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var k in e[h])c.event.add(this,h,e[h][k],e[h][k].data)}}})}function Ka(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)} -function ma(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?La:Ma,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a,"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function ca(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Na.test(a)?e(a,h):ca(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)? -e(a,""):c.each(b,function(f,h){ca(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(na.concat.apply([],na.slice(0,b)),function(){d[this]=a});return d}function oa(a){if(!da[a]){var b=c("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";da[a]=d}return da[a]}function ea(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var u=E.document,c=function(){function a(){if(!b.isReady){try{u.documentElement.doScroll("left")}catch(i){setTimeout(a, -1);return}b.ready()}}var b=function(i,r){return new b.fn.init(i,r)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,k=/\S/,l=/^\s+/,n=/\s+$/,s=/\W/,v=/\d/,B=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,D=/^[\],:{}\s]*$/,H=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,G=/(?:^|:|,)(?:\s*\[)+/g,M=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,j=/(msie) ([\w.]+)/,o=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false, -q=[],t,x=Object.prototype.toString,C=Object.prototype.hasOwnProperty,P=Array.prototype.push,N=Array.prototype.slice,R=String.prototype.trim,Q=Array.prototype.indexOf,L={};b.fn=b.prototype={init:function(i,r){var y,z,F;if(!i)return this;if(i.nodeType){this.context=this[0]=i;this.length=1;return this}if(i==="body"&&!r&&u.body){this.context=u;this[0]=u.body;this.selector="body";this.length=1;return this}if(typeof i==="string")if((y=h.exec(i))&&(y[1]||!r))if(y[1]){F=r?r.ownerDocument||r:u;if(z=B.exec(i))if(b.isPlainObject(r)){i= -[u.createElement(z[1])];b.fn.attr.call(i,r,true)}else i=[F.createElement(z[1])];else{z=b.buildFragment([y[1]],[F]);i=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this,i)}else{if((z=u.getElementById(y[2]))&&z.parentNode){if(z.id!==y[2])return f.find(i);this.length=1;this[0]=z}this.context=u;this.selector=i;return this}else if(!r&&!s.test(i)){this.selector=i;this.context=u;i=u.getElementsByTagName(i);return b.merge(this,i)}else return!r||r.jquery?(r||f).find(i):b(r).find(i); -else if(b.isFunction(i))return f.ready(i);if(i.selector!==A){this.selector=i.selector;this.context=i.context}return b.makeArray(i,this)},selector:"",jquery:"1.4.3",length:0,size:function(){return this.length},toArray:function(){return N.call(this,0)},get:function(i){return i==null?this.toArray():i<0?this.slice(i)[0]:this[i]},pushStack:function(i,r,y){var z=b();b.isArray(i)?P.apply(z,i):b.merge(z,i);z.prevObject=this;z.context=this.context;if(r==="find")z.selector=this.selector+(this.selector?" ": -"")+y;else if(r)z.selector=this.selector+"."+r+"("+y+")";return z},each:function(i,r){return b.each(this,i,r)},ready:function(i){b.bindReady();if(b.isReady)i.call(u,b);else q&&q.push(i);return this},eq:function(i){return i===-1?this.slice(i):this.slice(i,+i+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(i){return this.pushStack(b.map(this,function(r,y){return i.call(r, -y,r)}))},end:function(){return this.prevObject||b(null)},push:P,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var i=arguments[0]||{},r=1,y=arguments.length,z=false,F,I,K,J,fa;if(typeof i==="boolean"){z=i;i=arguments[1]||{};r=2}if(typeof i!=="object"&&!b.isFunction(i))i={};if(y===r){i=this;--r}for(;r0)){if(q){for(var r=0;i=q[r++];)i.call(u,b);q=null}b.fn.triggerHandler&&b(u).triggerHandler("ready")}}},bindReady:function(){if(!p){p=true;if(u.readyState==="complete")return setTimeout(b.ready, -1);if(u.addEventListener){u.addEventListener("DOMContentLoaded",t,false);E.addEventListener("load",b.ready,false)}else if(u.attachEvent){u.attachEvent("onreadystatechange",t);E.attachEvent("onload",b.ready);var i=false;try{i=E.frameElement==null}catch(r){}u.documentElement.doScroll&&i&&a()}}},isFunction:function(i){return b.type(i)==="function"},isArray:Array.isArray||function(i){return b.type(i)==="array"},isWindow:function(i){return i&&typeof i==="object"&&"setInterval"in i},isNaN:function(i){return i== -null||!v.test(i)||isNaN(i)},type:function(i){return i==null?String(i):L[x.call(i)]||"object"},isPlainObject:function(i){if(!i||b.type(i)!=="object"||i.nodeType||b.isWindow(i))return false;if(i.constructor&&!C.call(i,"constructor")&&!C.call(i.constructor.prototype,"isPrototypeOf"))return false;for(var r in i);return r===A||C.call(i,r)},isEmptyObject:function(i){for(var r in i)return false;return true},error:function(i){throw i;},parseJSON:function(i){if(typeof i!=="string"||!i)return null;i=b.trim(i); -if(D.test(i.replace(H,"@").replace(w,"]").replace(G,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(i):(new Function("return "+i))();else b.error("Invalid JSON: "+i)},noop:function(){},globalEval:function(i){if(i&&k.test(i)){var r=u.getElementsByTagName("head")[0]||u.documentElement,y=u.createElement("script");y.type="text/javascript";if(b.support.scriptEval)y.appendChild(u.createTextNode(i));else y.text=i;r.insertBefore(y,r.firstChild);r.removeChild(y)}},nodeName:function(i,r){return i.nodeName&&i.nodeName.toUpperCase()=== -r.toUpperCase()},each:function(i,r,y){var z,F=0,I=i.length,K=I===A||b.isFunction(i);if(y)if(K)for(z in i){if(r.apply(i[z],y)===false)break}else for(;F";a=u.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var s=u.createElement("div"); -s.style.width=s.style.paddingLeft="1px";u.body.appendChild(s);c.boxModel=c.support.boxModel=s.offsetWidth===2;if("zoom"in s.style){s.style.display="inline";s.style.zoom=1;c.support.inlineBlockNeedsLayout=s.offsetWidth===2;s.style.display="";s.innerHTML="
";c.support.shrinkWrapBlocks=s.offsetWidth!==2}s.innerHTML="
t
";var v=s.getElementsByTagName("td");c.support.reliableHiddenOffsets=v[0].offsetHeight=== -0;v[0].style.display="";v[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&v[0].offsetHeight===0;s.innerHTML="";u.body.removeChild(s).style.display="none"});a=function(s){var v=u.createElement("div");s="on"+s;var B=s in v;if(!B){v.setAttribute(s,"return;");B=typeof v[s]==="function"}return B};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength", -cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var pa={},Oa=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?pa:a;var e=a.nodeType,f=e?a[c.expando]:null,h=c.cache;if(!(e&&!f&&typeof b==="string"&&d===A)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]= -c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==A)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?pa:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando);else if(d)delete f[e];else for(var k in a)delete a[k]}},acceptData:function(a){if(a.nodeName){var b= -c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){if(typeof a==="undefined")return this.length?c.data(this[0]):null;else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===A){var e=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(e===A&&this.length){e=c.data(this[0],a);if(e===A&&this[0].nodeType===1){e=this[0].getAttribute("data-"+a);if(typeof e=== -"string")try{e=e==="true"?true:e==="false"?false:e==="null"?null:!c.isNaN(e)?parseFloat(e):Oa.test(e)?c.parseJSON(e):e}catch(f){}else e=A}}return e===A&&d[1]?this.data(d[0]):e}else return this.each(function(){var h=c(this),k=[d[0],b];h.triggerHandler("setData"+d[1]+"!",k);c.data(this,a,b);h.triggerHandler("changeData"+d[1]+"!",k)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var e=c.data(a,b);if(!d)return e|| -[];if(!e||c.isArray(d))e=c.data(a,b,c.makeArray(d));else e.push(d);return e}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),e=d.shift();if(e==="inprogress")e=d.shift();if(e){b==="fx"&&d.unshift("inprogress");e.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===A)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this, -a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var qa=/[\n\t]/g,ga=/\s+/,Pa=/\r/g,Qa=/^(?:href|src|style)$/,Ra=/^(?:button|input)$/i,Sa=/^(?:button|input|object|select|textarea)$/i,Ta=/^a(?:rea)?$/i,ra=/^(?:radio|checkbox)$/i;c.fn.extend({attr:function(a,b){return c.access(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this, -a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(s){var v=c(this);v.addClass(a.call(this,s,v.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ga),d=0,e=this.length;d-1)return true;return false}, -val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one";if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h=0;else if(c.nodeName(this,"select")){var B=c.makeArray(v);c("option",this).each(function(){this.selected= -c.inArray(c(this).val(),B)>=0});if(!B.length)this.selectedIndex=-1}else this.value=v}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return A;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==A;b=e&&c.props[b]||b;if(a.nodeType===1){var h=Qa.test(b);if((b in a||a[b]!==A)&&e&&!h){if(f){b==="type"&&Ra.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed"); -if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Sa.test(a.nodeName)||Ta.test(a.nodeName)&&a.href?0:A;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return A;a=!c.support.hrefNormalized&&e&& -h?a.getAttribute(b,2):a.getAttribute(b);return a===null?A:a}}});var X=/\.(.*)$/,ha=/^(?:textarea|input|select)$/i,Ha=/\./g,Ia=/ /g,Ua=/[^\w\s.|`]/g,Va=function(a){return a.replace(Ua,"\\$&")},sa={focusin:0,focusout:0};c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var k=a.nodeType?"events":"__events__",l=h[k],n=h.handle;if(typeof l=== -"function"){n=l.handle;l=l.events}else if(!l){a.nodeType||(h[k]=h=function(){});h.events=l={}}if(!n)h.handle=n=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(n.elem,arguments):A};n.elem=a;b=b.split(" ");for(var s=0,v;k=b[s++];){h=f?c.extend({},f):{handler:d,data:e};if(k.indexOf(".")>-1){v=k.split(".");k=v.shift();h.namespace=v.slice(0).sort().join(".")}else{v=[];h.namespace=""}h.type=k;if(!h.guid)h.guid=d.guid;var B=l[k],D=c.event.special[k]||{};if(!B){B=l[k]=[]; -if(!D.setup||D.setup.call(a,e,v,n)===false)if(a.addEventListener)a.addEventListener(k,n,false);else a.attachEvent&&a.attachEvent("on"+k,n)}if(D.add){D.add.call(a,h);if(!h.handler.guid)h.handler.guid=d.guid}B.push(h);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,k=0,l,n,s,v,B,D,H=a.nodeType?"events":"__events__",w=c.data(a),G=w&&w[H];if(w&&G){if(typeof G==="function"){w=G;G=G.events}if(b&&b.type){d=b.handler;b=b.type}if(!b|| -typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in G)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[k++];){v=f;l=f.indexOf(".")<0;n=[];if(!l){n=f.split(".");f=n.shift();s=RegExp("(^|\\.)"+c.map(n.slice(0).sort(),Va).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(B=G[f])if(d){v=c.event.special[f]||{};for(h=e||0;h=0){a.type= -f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return A;a.result=A;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)=== -false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){e=a.target;var k,l=f.replace(X,""),n=c.nodeName(e,"a")&&l==="click",s=c.event.special[l]||{};if((!s._default||s._default.call(d,a)===false)&&!n&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[l]){if(k=e["on"+l])e["on"+l]=null;c.event.triggered=true;e[l]()}}catch(v){}if(k)e["on"+l]=k;c.event.triggered=false}}},handle:function(a){var b,d,e; -d=[];var f,h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var k=d.length;f-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ha.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=va(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===A||f===e))if(e!=null||f){a.type="change";a.liveFired= -A;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",va(a))}},setup:function(){if(this.type=== -"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ha.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ha.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}u.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){sa[b]++===0&&u.addEventListener(a,d,true)},teardown:function(){--sa[b]=== -0&&u.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=A}var k=b==="one"?c.proxy(f,function(n){c(this).unbind(n,k);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var l=this.length;h0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}}); -(function(){function a(g,j,o,m,p,q){p=0;for(var t=m.length;p0){C=x;break}}x=x[g]}m[p]=C}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,k=true;[0,0].sort(function(){k=false;return 0});var l=function(g,j,o,m){o=o||[];var p=j=j||u;if(j.nodeType!==1&&j.nodeType!==9)return[];if(!g||typeof g!=="string")return o;var q=[],t,x,C,P,N=true,R=l.isXML(j),Q=g,L;do{d.exec("");if(t=d.exec(Q)){Q=t[3];q.push(t[1]);if(t[2]){P=t[3]; -break}}}while(t);if(q.length>1&&s.exec(g))if(q.length===2&&n.relative[q[0]])x=M(q[0]+q[1],j);else for(x=n.relative[q[0]]?[j]:l(q.shift(),j);q.length;){g=q.shift();if(n.relative[g])g+=q.shift();x=M(g,x)}else{if(!m&&q.length>1&&j.nodeType===9&&!R&&n.match.ID.test(q[0])&&!n.match.ID.test(q[q.length-1])){t=l.find(q.shift(),j,R);j=t.expr?l.filter(t.expr,t.set)[0]:t.set[0]}if(j){t=m?{expr:q.pop(),set:D(m)}:l.find(q.pop(),q.length===1&&(q[0]==="~"||q[0]==="+")&&j.parentNode?j.parentNode:j,R);x=t.expr?l.filter(t.expr, -t.set):t.set;if(q.length>0)C=D(x);else N=false;for(;q.length;){t=L=q.pop();if(n.relative[L])t=q.pop();else L="";if(t==null)t=j;n.relative[L](C,t,R)}}else C=[]}C||(C=x);C||l.error(L||g);if(f.call(C)==="[object Array]")if(N)if(j&&j.nodeType===1)for(g=0;C[g]!=null;g++){if(C[g]&&(C[g]===true||C[g].nodeType===1&&l.contains(j,C[g])))o.push(x[g])}else for(g=0;C[g]!=null;g++)C[g]&&C[g].nodeType===1&&o.push(x[g]);else o.push.apply(o,C);else D(C,o);if(P){l(P,p,o,m);l.uniqueSort(o)}return o};l.uniqueSort=function(g){if(w){h= -k;g.sort(w);if(h)for(var j=1;j0};l.find=function(g,j,o){var m;if(!g)return[];for(var p=0,q=n.order.length;p":function(g,j){var o=typeof j==="string",m,p=0,q=g.length;if(o&&!/\W/.test(j))for(j=j.toLowerCase();p=0))o||m.push(t);else if(o)j[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var j=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=j[1]+(j[2]||1)-0;g[3]=j[3]-0}g[0]=e++;return g},ATTR:function(g,j,o, -m,p,q){j=g[1].replace(/\\/g,"");if(!q&&n.attrMap[j])g[1]=n.attrMap[j];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,j,o,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=l(g[3],null,null,j);else{g=l.filter(g[3],j,o,true^p);o||m.push.apply(m,g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== -true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,j,o){return!!l(o[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== -g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,j){return j===0},last:function(g,j,o,m){return j===m.length-1},even:function(g,j){return j%2===0},odd:function(g,j){return j%2===1},lt:function(g,j,o){return jo[3]-0},nth:function(g,j,o){return o[3]- -0===j},eq:function(g,j,o){return o[3]-0===j}},filter:{PSEUDO:function(g,j,o,m){var p=j[1],q=n.filters[p];if(q)return q(g,o,j,m);else if(p==="contains")return(g.textContent||g.innerText||l.getText([g])||"").indexOf(j[3])>=0;else if(p==="not"){j=j[3];o=0;for(m=j.length;o=0}},ID:function(g,j){return g.nodeType===1&&g.getAttribute("id")===j},TAG:function(g,j){return j==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== -j},CLASS:function(g,j){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(j)>-1},ATTR:function(g,j){var o=j[1];o=n.attrHandle[o]?n.attrHandle[o](g):g[o]!=null?g[o]:g.getAttribute(o);var m=o+"",p=j[2],q=j[4];return o==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&o!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,j,o,m){var p=n.setFilters[j[2]]; -if(p)return p(g,o,j,m)}}},s=n.match.POS,v=function(g,j){return"\\"+(j-0+1)},B;for(B in n.match){n.match[B]=RegExp(n.match[B].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[B]=RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[B].source.replace(/\\(\d+)/g,v))}var D=function(g,j){g=Array.prototype.slice.call(g,0);if(j){j.push.apply(j,g);return j}return g};try{Array.prototype.slice.call(u.documentElement.childNodes,0)}catch(H){D=function(g,j){var o=j||[],m=0;if(f.call(g)==="[object Array]")Array.prototype.push.apply(o, -g);else if(typeof g.length==="number")for(var p=g.length;m";var o=u.documentElement;o.insertBefore(g,o.firstChild);if(u.getElementById(j)){n.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:A:[]};n.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}o.removeChild(g); -o=g=null})();(function(){var g=u.createElement("div");g.appendChild(u.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(j,o){var m=o.getElementsByTagName(j[1]);if(j[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(j){return j.getAttribute("href",2)};g=null})();u.querySelectorAll&& -function(){var g=l,j=u.createElement("div");j.innerHTML="

";if(!(j.querySelectorAll&&j.querySelectorAll(".TEST").length===0)){l=function(m,p,q,t){p=p||u;if(!t&&!l.isXML(p))if(p.nodeType===9)try{return D(p.querySelectorAll(m),q)}catch(x){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var C=p.id,P=p.id="__sizzle__";try{return D(p.querySelectorAll("#"+P+" "+m),q)}catch(N){}finally{if(C)p.id=C;else p.removeAttribute("id")}}return g(m,p,q,t)};for(var o in g)l[o]=g[o]; -j=null}}();(function(){var g=u.documentElement,j=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,o=false;try{j.call(u.documentElement,":sizzle")}catch(m){o=true}if(j)l.matchesSelector=function(p,q){try{if(o||!n.match.PSEUDO.test(q))return j.call(p,q)}catch(t){}return l(q,null,null,[p]).length>0}})();(function(){var g=u.createElement("div");g.innerHTML="
";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length=== -0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(j,o,m){if(typeof o.getElementsByClassName!=="undefined"&&!m)return o.getElementsByClassName(j[1])};g=null}}})();l.contains=u.documentElement.contains?function(g,j){return g!==j&&(g.contains?g.contains(j):true)}:function(g,j){return!!(g.compareDocumentPosition(j)&16)};l.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var M=function(g, -j){for(var o=[],m="",p,q=j.nodeType?[j]:j;p=n.match.PSEUDO.exec(g);){m+=p[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;p=0;for(var t=q.length;p0)for(var h=d;h0},closest:function(a, -b){var d=[],e,f,h=this[0];if(c.isArray(a)){var k={},l,n=1;if(h&&a.length){e=0;for(f=a.length;e-1:c(h).is(e))d.push({selector:l,elem:h,level:n})}h=h.parentNode;n++}}return d}k=$a.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h|| -!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context):c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}}); -c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling", -d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Wa.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||Ya.test(e))&&Xa.test(a))f=f.reverse();return this.pushStack(f,a,Za.call(arguments).join(","))}}); -c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===A||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var xa=/ jQuery\d+="(?:\d+|null)"/g, -$=/^\s+/,ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,za=/<([\w:]+)/,ab=/\s]+\/)>/g,O={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"], -area:[1,"",""],_default:[0,"",""]};O.optgroup=O.option;O.tbody=O.tfoot=O.colgroup=O.caption=O.thead;O.th=O.td;if(!c.support.htmlSerialize)O._default=[1,"div
","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==A)return this.empty().append((this[0]&&this[0].ownerDocument||u).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this, -d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})}, -unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a= -c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*")); -c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(xa,"").replace(cb,'="$1">').replace($, -"")],e)[0]}else return this.cloneNode(true)});if(a===true){la(this,b);la(this.find("*"),b.find("*"))}return b},html:function(a){if(a===A)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(xa,""):null;else if(typeof a==="string"&&!Aa.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!O[(za.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ya,"<$1>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?l.cloneNode(true):l)}k.length&&c.each(k,Ka)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:u;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===u&&!Aa.test(a[0])&&(c.support.checkClone|| -!Ba.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h= -d.length;f0?this.clone(true):this).get();c(d[f])[b](k);e=e.concat(k)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||u;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||u;for(var f=[],h=0,k;(k=a[h])!=null;h++){if(typeof k==="number")k+="";if(k){if(typeof k==="string"&&!bb.test(k))k=b.createTextNode(k);else if(typeof k==="string"){k=k.replace(ya,"<$1>");var l=(za.exec(k)||["",""])[1].toLowerCase(),n=O[l]||O._default, -s=n[0],v=b.createElement("div");for(v.innerHTML=n[1]+k+n[2];s--;)v=v.lastChild;if(!c.support.tbody){s=ab.test(k);l=l==="table"&&!s?v.firstChild&&v.firstChild.childNodes:n[1]===""&&!s?v.childNodes:[];for(n=l.length-1;n>=0;--n)c.nodeName(l[n],"tbody")&&!l[n].childNodes.length&&l[n].parentNode.removeChild(l[n])}!c.support.leadingWhitespace&&$.test(k)&&v.insertBefore(b.createTextNode($.exec(k)[0]),v.firstChild);k=v.childNodes}if(k.nodeType)f.push(k);else f=c.merge(f,k)}}if(d)for(h=0;f[h];h++)if(e&& -c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script"))));d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,k=0,l;(l=a[k])!=null;k++)if(!(l.nodeName&&c.noData[l.nodeName.toLowerCase()]))if(d=l[c.expando]){if((b=e[d])&&b.events)for(var n in b.events)f[n]? -c.event.remove(l,n):c.removeEvent(l,n,b.handle);if(h)delete l[c.expando];else l.removeAttribute&&l.removeAttribute(c.expando);delete e[d]}}});var Ca=/alpha\([^)]*\)/i,db=/opacity=([^)]*)/,eb=/-([a-z])/ig,fb=/([A-Z])/g,Da=/^-?\d+(?:px)?$/i,gb=/^-?\d/,hb={position:"absolute",visibility:"hidden",display:"block"},La=["Left","Right"],Ma=["Top","Bottom"],W,ib=u.defaultView&&u.defaultView.getComputedStyle,jb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===A)return this; -return c.access(this,a,b,true,function(d,e,f){return f!==A?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true,zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),k=a.style,l=c.cssHooks[h];b=c.cssProps[h]|| -h;if(d!==A){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!l||!("set"in l)||(d=l.set(a,d))!==A)try{k[b]=d}catch(n){}}}else{if(l&&"get"in l&&(f=l.get(a,false,e))!==A)return f;return k[b]}}},css:function(a,b,d){var e,f=c.camelCase(b),h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==A)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]= -e[f]},camelCase:function(a){return a.replace(eb,jb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=ma(d,b,f);else c.swap(d,hb,function(){h=ma(d,b,f)});return h+"px"}},set:function(d,e){if(Da.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return db.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"": -b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f=d.filter||"";d.filter=Ca.test(f)?f.replace(Ca,e):d.filter+" "+e}};if(ib)W=function(a,b,d){var e;d=d.replace(fb,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return A;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};else if(u.documentElement.currentStyle)W=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b], -h=a.style;if(!Da.test(f)&&gb.test(f)){d=h.left;e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f};if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var kb=c.now(),lb=/)<[^<]*)*<\/script>/gi, -mb=/^(?:select|textarea)/i,nb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,ob=/^(?:GET|HEAD|DELETE)$/,Na=/\[\]$/,T=/\=\?(&|$)/,ia=/\?/,pb=/([?&])_=[^&]*/,qb=/^(\w+:)?\/\/([^\/?#]+)/,rb=/%20/g,sb=/#.*$/,Ea=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ea)return Ea.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d= -b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(k,l){if(l==="success"||l==="notmodified")h.html(f?c("
").append(k.responseText.replace(lb,"")).find(f):k.responseText);d&&h.each(d,[k.responseText,l,k])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&& -!this.disabled&&(this.checked||mb.test(this.nodeName)||nb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})}, -getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html", -script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),k=ob.test(h);b.url=b.url.replace(sb,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ia.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data|| -!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+kb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var l=E[d];E[d]=function(m){f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);if(c.isFunction(l))l(m);else{E[d]=A;try{delete E[d]}catch(p){}}v&&v.removeChild(B)}}if(b.dataType==="script"&&b.cache===null)b.cache= -false;if(b.cache===false&&h==="GET"){var n=c.now(),s=b.url.replace(pb,"$1_="+n);b.url=s+(s===b.url?(ia.test(b.url)?"&":"?")+"_="+n:"")}if(b.data&&h==="GET")b.url+=(ia.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");n=(n=qb.exec(b.url))&&(n[1]&&n[1]!==location.protocol||n[2]!==location.host);if(b.dataType==="script"&&h==="GET"&&n){var v=u.getElementsByTagName("head")[0]||u.documentElement,B=u.createElement("script");if(b.scriptCharset)B.charset=b.scriptCharset;B.src= -b.url;if(!d){var D=false;B.onload=B.onreadystatechange=function(){if(!D&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){D=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);B.onload=B.onreadystatechange=null;v&&B.parentNode&&v.removeChild(B)}}}v.insertBefore(B,v.firstChild);return A}var H=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!k||a&&a.contentType)w.setRequestHeader("Content-Type", -b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}n||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(G){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&& -c.triggerGlobal(b,"ajaxSend",[w,b]);var M=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){H||c.handleComplete(b,w,e,f);H=true;if(w)w.onreadystatechange=c.noop}else if(!H&&w&&(w.readyState===4||m==="timeout")){H=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d|| -c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&g.call&&g.call(w);M("abort")}}catch(j){}b.async&&b.timeout>0&&setTimeout(function(){w&&!H&&M("timeout")},b.timeout);try{w.send(k||b.data==null?null:b.data)}catch(o){c.handleError(b,w,null,o);c.handleComplete(b,w,e,f)}b.async||M();return w}},param:function(a,b){var d=[],e=function(h,k){k=c.isFunction(k)?k():k;d[d.length]=encodeURIComponent(h)+ -"="+encodeURIComponent(k)};if(b===A)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)ca(f,a[f],b,e);return d.join("&").replace(rb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess",[b,a])},handleComplete:function(a, -b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),e=a.getResponseHeader("Etag"); -if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}});if(E.ActiveXObject)c.ajaxSettings.xhr= -function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var da={},tb=/^(?:toggle|show|hide)$/,ub=/^([+\-]=)?([\d+.\-]+)(.*)$/,aa,na=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show",3),a,b,d);else{a= -0;for(b=this.length;a=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b, -d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a* -Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(h){return f.step(h)} -this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;var f=this;a=c.fx;e.elem=this.elem;if(e()&&c.timers.push(e)&&!aa)aa=setInterval(a.tick,a.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true; -this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(l,n){f.style["overflow"+n]=h.overflow[l]})}this.options.hide&&c(this.elem).hide();if(this.options.hide|| -this.options.show)for(var k in this.options.curAnim)c.style(this.elem,k,this.options.orig[k]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a= -c.timers,b=0;b-1;e={};var s={};if(n)s=f.position();k=n?s.top:parseInt(k,10)||0;l=n?s.left:parseInt(l,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+k;if(b.left!=null)e.left=b.left-h.left+l;"using"in b?b.using.call(a, -e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Fa.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||u.body;a&&!Fa.test(a.nodeName)&& -c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==A)return this.each(function(){if(h=ea(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=ea(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase(); -c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(h){var k=c(this);k[d](e.call(this,h,k[d]()))});return c.isWindow(f)?f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b]:f.nodeType===9?Math.max(f.documentElement["client"+ -b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]):e===A?parseFloat(c.css(f,d)):this.css(d,typeof e==="string"?e:e+"px")}})})(window); diff --git a/Website/LOC.Website.Web/Content/themes/techno/js/jquery.nivo.slider.js b/Website/LOC.Website.Web/Content/themes/techno/js/jquery.nivo.slider.js deleted file mode 100644 index d3ed1ffa0..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/js/jquery.nivo.slider.js +++ /dev/null @@ -1,553 +0,0 @@ -/* - * jQuery Nivo Slider v2.4 - * http://nivo.dev7studios.com - * - * Copyright 2011, Gilbert Pellegrom - * Free to use and abuse under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - * - * May 2010 - Pick random effect from specified set of effects by toronegro - * May 2010 - controlNavThumbsFromRel option added by nerd-sh - * May 2010 - Do not start nivoRun timer if there is only 1 slide by msielski - * April 2010 - controlNavThumbs option added by Jamie Thompson (http://jamiethompson.co.uk) - * March 2010 - manualAdvance option added by HelloPablo (http://hellopablo.co.uk) - */ - -(function($) { - - var NivoSlider = function(element, options){ - //Defaults are below - var settings = $.extend({}, $.fn.nivoSlider.defaults, options); - - //Useful variables. Play carefully. - var vars = { - currentSlide: 0, - currentImage: '', - totalSlides: 0, - randAnim: '', - running: false, - paused: false, - stop: false - }; - - //Get this slider - var slider = $(element); - slider.data('nivo:vars', vars); - slider.css('position','relative'); - slider.addClass('nivoSlider'); - - //Find our slider children - var kids = slider.children(); - kids.each(function() { - var child = $(this); - var link = ''; - if(!child.is('img')){ - if(child.is('a')){ - child.addClass('nivo-imageLink'); - link = child; - } - child = child.find('img:first'); - } - //Get img width & height - var childWidth = child.width(); - if(childWidth == 0) childWidth = child.attr('width'); - var childHeight = child.height(); - if(childHeight == 0) childHeight = child.attr('height'); - //Resize the slider - if(childWidth > slider.width()){ - slider.width(childWidth); - } - if(childHeight > slider.height()){ - slider.height(childHeight); - } - if(link != ''){ - link.css('display','none'); - } - child.css('display','none'); - vars.totalSlides++; - }); - - //Set startSlide - if(settings.startSlide > 0){ - if(settings.startSlide >= vars.totalSlides) settings.startSlide = vars.totalSlides - 1; - vars.currentSlide = settings.startSlide; - } - - //Get initial image - if($(kids[vars.currentSlide]).is('img')){ - vars.currentImage = $(kids[vars.currentSlide]); - } else { - vars.currentImage = $(kids[vars.currentSlide]).find('img:first'); - } - - //Show initial link - if($(kids[vars.currentSlide]).is('a')){ - $(kids[vars.currentSlide]).css('display','block'); - } - - //Set first background - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - - //Add initial slices - for(var i = 0; i < settings.slices; i++){ - var sliceWidth = Math.round(slider.width()/settings.slices); - if(i == settings.slices-1){ - slider.append( - $('
').css({ left:(sliceWidth*i)+'px', width:(slider.width()-(sliceWidth*i))+'px' }) - ); - } else { - slider.append( - $('
').css({ left:(sliceWidth*i)+'px', width:sliceWidth+'px' }) - ); - } - } - - //Create caption - slider.append( - $('

').css({ display:'none', opacity:settings.captionOpacity }) - ); - //Process initial caption - if(vars.currentImage.attr('title') != ''){ - var title = vars.currentImage.attr('title'); - if(title.substr(0,1) == '#') title = $(title).html(); - $('.nivo-caption p', slider).html(title); - $('.nivo-caption', slider).fadeIn(settings.animSpeed); - } - - //In the words of Super Mario "let's a go!" - var timer = 0; - if(!settings.manualAdvance && kids.length > 1){ - timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); - } - - //Add Direction nav - if(settings.directionNav){ - slider.append(''); - - //Hide Direction nav - if(settings.directionNavHide){ - $('.nivo-directionNav', slider).hide(); - slider.hover(function(){ - $('.nivo-directionNav', slider).show(); - }, function(){ - $('.nivo-directionNav', slider).hide(); - }); - } - - $('a.nivo-prevNav', slider).live('click', function(){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - vars.currentSlide-=2; - nivoRun(slider, kids, settings, 'prev'); - }); - - $('a.nivo-nextNav', slider).live('click', function(){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - nivoRun(slider, kids, settings, 'next'); - }); - } - - //Add Control nav - if(settings.controlNav){ - var nivoControl = $('
'); - slider.append(nivoControl); - for(var i = 0; i < kids.length; i++){ - if(settings.controlNavThumbs){ - var child = kids.eq(i); - if(!child.is('img')){ - child = child.find('img:first'); - } - if (settings.controlNavThumbsFromRel) { - nivoControl.append(''); - } else { - nivoControl.append(''); - } - } else { - nivoControl.append(''+ (i + 1) +''); - } - - } - //Set initial active link - $('.nivo-controlNav a:eq('+ vars.currentSlide +')', slider).addClass('active'); - - $('.nivo-controlNav a', slider).live('click', function(){ - if(vars.running) return false; - if($(this).hasClass('active')) return false; - clearInterval(timer); - timer = ''; - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - vars.currentSlide = $(this).attr('rel') - 1; - nivoRun(slider, kids, settings, 'control'); - }); - } - - //Keyboard Navigation - if(settings.keyboardNav){ - $(window).keypress(function(event){ - //Left - if(event.keyCode == '37'){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - vars.currentSlide-=2; - nivoRun(slider, kids, settings, 'prev'); - } - //Right - if(event.keyCode == '39'){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - nivoRun(slider, kids, settings, 'next'); - } - }); - } - - //For pauseOnHover setting - if(settings.pauseOnHover){ - slider.hover(function(){ - vars.paused = true; - clearInterval(timer); - timer = ''; - }, function(){ - vars.paused = false; - //Restart the timer - if(timer == '' && !settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); - } - }); - } - - //Event when Animation finishes - slider.bind('nivo:animFinished', function(){ - vars.running = false; - //Hide child links - $(kids).each(function(){ - if($(this).is('a')){ - $(this).css('display','none'); - } - }); - //Show current link - if($(kids[vars.currentSlide]).is('a')){ - $(kids[vars.currentSlide]).css('display','block'); - } - //Restart the timer - if(timer == '' && !vars.paused && !settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); - } - //Trigger the afterChange callback - settings.afterChange.call(this); - }); - - // Reset slice width before animations run - var resetSliceWidth = function(slider, settings){ - var slices = $('.nivo-slice', slider); - var i = 0; - slices.each(function(){ - var slice = $(this); - var sliceWidth = Math.round(slider.width()/settings.slices); - if(i == settings.slices-1){ - slice.css('width', (slider.width()-(sliceWidth*i)) + 'px'); - } else { - slice.css('width', sliceWidth + 'px'); - } - i++; - }); - } - - // Private run method - var nivoRun = function(slider, kids, settings, nudge){ - //Get our vars - var vars = slider.data('nivo:vars'); - - //Trigger the lastSlide callback - if(vars && (vars.currentSlide == vars.totalSlides - 1)){ - settings.lastSlide.call(this); - } - - // Stop - if((!vars || vars.stop) && !nudge) return false; - - //Trigger the beforeChange callback - settings.beforeChange.call(this); - - //Set current background before change - if(!nudge){ - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - } else { - if(nudge == 'prev'){ - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - } - if(nudge == 'next'){ - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - } - } - vars.currentSlide++; - //Trigger the slideshowEnd callback - if(vars.currentSlide == vars.totalSlides){ - vars.currentSlide = 0; - settings.slideshowEnd.call(this); - } - if(vars.currentSlide < 0) vars.currentSlide = (vars.totalSlides - 1); - //Set vars.currentImage - if($(kids[vars.currentSlide]).is('img')){ - vars.currentImage = $(kids[vars.currentSlide]); - } else { - vars.currentImage = $(kids[vars.currentSlide]).find('img:first'); - } - - //Set acitve links - if(settings.controlNav){ - $('.nivo-controlNav a', slider).removeClass('active'); - $('.nivo-controlNav a:eq('+ vars.currentSlide +')', slider).addClass('active'); - } - - //Process caption - if(vars.currentImage.attr('title') != ''){ - var title = vars.currentImage.attr('title'); - if(title.substr(0,1) == '#') title = $(title).html(); - - if($('.nivo-caption', slider).css('display') == 'block'){ - $('.nivo-caption p', slider).fadeOut(settings.animSpeed, function(){ - $(this).html(title); - $(this).fadeIn(settings.animSpeed); - }); - } else { - $('.nivo-caption p', slider).html(title); - } - $('.nivo-caption', slider).fadeIn(settings.animSpeed); - } else { - $('.nivo-caption', slider).fadeOut(settings.animSpeed); - } - - //Set new slice backgrounds - var i = 0; - $('.nivo-slice', slider).each(function(){ - var sliceWidth = Math.round(slider.width()/settings.slices); - $(this).css({ height:'0px', opacity:'0', - background: 'url("'+ vars.currentImage.attr('src') +'") no-repeat -'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px 0%' }); - i++; - }); - - if(settings.effect == 'random'){ - var anims = new Array('sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade','slideInRight','slideInLeft'); - vars.randAnim = anims[Math.floor(Math.random()*(anims.length + 1))]; - if(vars.randAnim == undefined) vars.randAnim = 'fade'; - } - - //Run random effect from specified set (eg: effect:'fold,fade') - if(settings.effect.indexOf(',') != -1){ - var anims = settings.effect.split(','); - vars.randAnim = anims[Math.floor(Math.random()*(anims.length))]; - if(vars.randAnim == undefined) vars.randAnim = 'fade'; - } - - //Run effects - vars.running = true; - if(settings.effect == 'sliceDown' || settings.effect == 'sliceDownRight' || vars.randAnim == 'sliceDownRight' || - settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft'){ - var timeBuff = 0; - var i = 0; - resetSliceWidth(slider, settings); - var slices = $('.nivo-slice', slider); - if(settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft') slices = $('.nivo-slice', slider)._reverse(); - slices.each(function(){ - var slice = $(this); - slice.css({ 'top': '0px' }); - if(i == settings.slices-1){ - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); - } - timeBuff += 50; - i++; - }); - } - else if(settings.effect == 'sliceUp' || settings.effect == 'sliceUpRight' || vars.randAnim == 'sliceUpRight' || - settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft'){ - var timeBuff = 0; - var i = 0; - resetSliceWidth(slider, settings); - var slices = $('.nivo-slice', slider); - if(settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft') slices = $('.nivo-slice', slider)._reverse(); - slices.each(function(){ - var slice = $(this); - slice.css({ 'bottom': '0px' }); - if(i == settings.slices-1){ - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); - } - timeBuff += 50; - i++; - }); - } - else if(settings.effect == 'sliceUpDown' || settings.effect == 'sliceUpDownRight' || vars.randAnim == 'sliceUpDown' || - settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft'){ - var timeBuff = 0; - var i = 0; - var v = 0; - resetSliceWidth(slider, settings); - var slices = $('.nivo-slice', slider); - if(settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft') slices = $('.nivo-slice', slider)._reverse(); - slices.each(function(){ - var slice = $(this); - if(i == 0){ - slice.css('top','0px'); - i++; - } else { - slice.css('bottom','0px'); - i = 0; - } - - if(v == settings.slices-1){ - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); - } - timeBuff += 50; - v++; - }); - } - else if(settings.effect == 'fold' || vars.randAnim == 'fold'){ - var timeBuff = 0; - var i = 0; - resetSliceWidth(slider, settings); - $('.nivo-slice', slider).each(function(){ - var slice = $(this); - var origWidth = slice.width(); - slice.css({ top:'0px', height:'100%', width:'0px' }); - if(i == settings.slices-1){ - setTimeout(function(){ - slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); - } - timeBuff += 50; - i++; - }); - } - else if(settings.effect == 'fade' || vars.randAnim == 'fade'){ - var firstSlice = $('.nivo-slice:first', slider); - firstSlice.css({ - 'height': '100%', - 'width': slider.width() + 'px' - }); - - firstSlice.animate({ opacity:'1.0' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); }); - } - else if(settings.effect == 'slideInRight' || vars.randAnim == 'slideInRight'){ - var firstSlice = $('.nivo-slice:first', slider); - firstSlice.css({ - 'height': '100%', - 'width': '0px', - 'opacity': '1' - }); - - firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); }); - } - else if(settings.effect == 'slideInLeft' || vars.randAnim == 'slideInLeft'){ - var firstSlice = $('.nivo-slice:first', slider); - firstSlice.css({ - 'height': '100%', - 'width': '0px', - 'opacity': '1', - 'left': '', - 'right': '0px' - }); - - firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ - // Reset positioning - firstSlice.css({ - 'left': '0px', - 'right': '' - }); - slider.trigger('nivo:animFinished'); - }); - } - } - - // For debugging - var trace = function(msg){ - if (this.console && typeof console.log != "undefined") - console.log(msg); - } - - // Start / Stop - this.stop = function(){ - if(!$(element).data('nivo:vars').stop){ - $(element).data('nivo:vars').stop = true; - trace('Stop Slider'); - } - } - - this.start = function(){ - if($(element).data('nivo:vars').stop){ - $(element).data('nivo:vars').stop = false; - trace('Start Slider'); - } - } - - //Trigger the afterLoad callback - settings.afterLoad.call(this); - }; - - $.fn.nivoSlider = function(options) { - - return this.each(function(){ - var element = $(this); - // Return early if this element already has a plugin instance - if (element.data('nivoslider')) return; - // Pass options to plugin constructor - var nivoslider = new NivoSlider(this, options); - // Store plugin object in this element's data - element.data('nivoslider', nivoslider); - }); - - }; - - //Default settings - $.fn.nivoSlider.defaults = { - effect: 'random', - slices: 15, - animSpeed: 500, - pauseTime: 3000, - startSlide: 0, - directionNav: true, - directionNavHide: true, - controlNav: true, - controlNavThumbs: false, - controlNavThumbsFromRel: false, - controlNavThumbsSearch: '.jpg', - controlNavThumbsReplace: '_thumb.jpg', - keyboardNav: true, - pauseOnHover: true, - manualAdvance: false, - captionOpacity: 0.8, - beforeChange: function(){}, - afterChange: function(){}, - slideshowEnd: function(){}, - lastSlide: function(){}, - afterLoad: function(){} - }; - - $.fn._reverse = [].reverse; - -})(jQuery); \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/js/lightbox.js b/Website/LOC.Website.Web/Content/themes/techno/js/lightbox.js deleted file mode 100644 index 68b4b4ce6..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/js/lightbox.js +++ /dev/null @@ -1,497 +0,0 @@ -// ----------------------------------------------------------------------------------- -// -// Lightbox v2.04 -// by Lokesh Dhakar - http://www.lokeshdhakar.com -// Last Modification: 2/9/08 -// -// For more information, visit: -// http://lokeshdhakar.com/projects/lightbox2/ -// -// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ -// - Free for use in both personal and commercial projects -// - Attribution requires leaving author name, author link, and the license info intact. -// -// Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets. -// Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous. -// -// ----------------------------------------------------------------------------------- -/* - - Table of Contents - ----------------- - Configuration - - Lightbox Class Declaration - - initialize() - - updateImageList() - - start() - - changeImage() - - resizeImageContainer() - - showImage() - - updateDetails() - - updateNav() - - enableKeyboardNav() - - disableKeyboardNav() - - keyboardAction() - - preloadNeighborImages() - - end() - - Function Calls - - document.observe() - -*/ -// ----------------------------------------------------------------------------------- - -// -// Configurationl -// -LightboxOptions = Object.extend({ - fileLoadingImage: 'images/loading.gif', - fileBottomNavCloseImage: 'images/closelabel.gif', - - overlayOpacity: 0.8, // controls transparency of shadow overlay - - animate: true, // toggles resizing animations - resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest) - - borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable - - // When grouping images this is used to write: Image # of #. - // Change it for non-english localization - labelImage: "Image", - labelOf: "of" -}, window.LightboxOptions || {}); - -// ----------------------------------------------------------------------------------- - -var Lightbox = Class.create(); - -Lightbox.prototype = { - imageArray: [], - activeImage: undefined, - - // initialize() - // Constructor runs on completion of the DOM loading. Calls updateImageList and then - // the function inserts html at the bottom of the page which is used to display the shadow - // overlay and the image container. - // - initialize: function() { - - this.updateImageList(); - - this.keyboardAction = this.keyboardAction.bindAsEventListener(this); - - if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10; - if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1; - - this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0; - this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration - - // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. - // If animations are turned off, it will be hidden as to prevent a flicker of a - // white 250 by 250 box. - var size = (LightboxOptions.animate ? 250 : 1) + 'px'; - - - // Code inserts html at the bottom of the page that looks similar to this: - // - //
- // - - - var objBody = $$('body')[0]; - - objBody.appendChild(Builder.node('div',{id:'overlay'})); - - objBody.appendChild(Builder.node('div',{id:'lightbox'}, [ - Builder.node('div',{id:'outerImageContainer'}, - Builder.node('div',{id:'imageContainer'}, [ - Builder.node('img',{id:'lightboxImage'}), - Builder.node('div',{id:'hoverNav'}, [ - Builder.node('a',{id:'prevLink', href: '#' }), - Builder.node('a',{id:'nextLink', href: '#' }) - ]), - Builder.node('div',{id:'loading'}, - Builder.node('a',{id:'loadingLink', href: '#' }, - Builder.node('img', {src: LightboxOptions.fileLoadingImage}) - ) - ) - ]) - ), - Builder.node('div', {id:'imageDataContainer'}, - Builder.node('div',{id:'imageData'}, [ - Builder.node('div',{id:'imageDetails'}, [ - Builder.node('span',{id:'caption'}), - Builder.node('span',{id:'numberDisplay'}) - ]), - Builder.node('div',{id:'bottomNav'}, - Builder.node('a',{id:'bottomNavClose', href: '#' }, - Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage }) - ) - ) - ]) - ) - ])); - - - $('overlay').hide().observe('click', (function() { this.end(); }).bind(this)); - $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this)); - $('outerImageContainer').setStyle({ width: size, height: size }); - $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this)); - $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this)); - $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); - $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); - - var th = this; - (function(){ - var ids = - 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + - 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; - $w(ids).each(function(id){ th[id] = $(id); }); - }).defer(); - }, - - // - // updateImageList() - // Loops through anchor tags looking for 'lightbox' references and applies onclick - // events to appropriate links. You can rerun after dynamically adding images w/ajax. - // - updateImageList: function() { - this.updateImageList = Prototype.emptyFunction; - - document.observe('click', (function(event){ - var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); - if (target) { - event.stop(); - this.start(target); - } - }).bind(this)); - }, - - // - // start() - // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. - // - start: function(imageLink) { - - $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); - - // stretch overlay to fill page and fade in - var arrayPageSize = this.getPageSize(); - $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); - - new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity }); - - this.imageArray = []; - var imageNum = 0; - - if ((imageLink.rel == 'lightbox')){ - // if image is NOT part of a set, add single image to imageArray - this.imageArray.push([imageLink.href, imageLink.title]); - } else { - // if image is part of a set.. - this.imageArray = - $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]'). - collect(function(anchor){ return [anchor.href, anchor.title]; }). - uniq(); - - while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; } - } - - // calculate top and left offset for the lightbox - var arrayPageScroll = document.viewport.getScrollOffsets(); - var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); - var lightboxLeft = arrayPageScroll[0]; - this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show(); - - this.changeImage(imageNum); - }, - - // - // changeImage() - // Hide most elements and preload image in preparation for resizing image container. - // - changeImage: function(imageNum) { - - this.activeImage = imageNum; // update global var - - // hide elements during transition - if (LightboxOptions.animate) this.loading.show(); - this.lightboxImage.hide(); - this.hoverNav.hide(); - this.prevLink.hide(); - this.nextLink.hide(); - // HACK: Opera9 does not currently support scriptaculous opacity and appear fx - this.imageDataContainer.setStyle({opacity: .0001}); - this.numberDisplay.hide(); - - var imgPreloader = new Image(); - - // once image is preloaded, resize image container - - - imgPreloader.onload = (function(){ - this.lightboxImage.src = this.imageArray[this.activeImage][0]; - this.resizeImageContainer(imgPreloader.width, imgPreloader.height); - }).bind(this); - imgPreloader.src = this.imageArray[this.activeImage][0]; - }, - - // - // resizeImageContainer() - // - resizeImageContainer: function(imgWidth, imgHeight) { - - // get current width and height - var widthCurrent = this.outerImageContainer.getWidth(); - var heightCurrent = this.outerImageContainer.getHeight(); - - // get new width and height - var widthNew = (imgWidth + LightboxOptions.borderSize * 2); - var heightNew = (imgHeight + LightboxOptions.borderSize * 2); - - // scalars based on change from old to new - var xScale = (widthNew / widthCurrent) * 100; - var yScale = (heightNew / heightCurrent) * 100; - - // calculate size difference between new and old image, and resize if necessary - var wDiff = widthCurrent - widthNew; - var hDiff = heightCurrent - heightNew; - - if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); - if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration}); - - // if new and old image are same size and no scaling transition is necessary, - // do a quick pause to prevent image flicker. - var timeout = 0; - if ((hDiff == 0) && (wDiff == 0)){ - timeout = 100; - if (Prototype.Browser.IE) timeout = 250; - } - - (function(){ - this.prevLink.setStyle({ height: imgHeight + 'px' }); - this.nextLink.setStyle({ height: imgHeight + 'px' }); - this.imageDataContainer.setStyle({ width: widthNew + 'px' }); - - this.showImage(); - }).bind(this).delay(timeout / 1000); - }, - - // - // showImage() - // Display image and begin preloading neighbors. - // - showImage: function(){ - this.loading.hide(); - new Effect.Appear(this.lightboxImage, { - duration: this.resizeDuration, - queue: 'end', - afterFinish: (function(){ this.updateDetails(); }).bind(this) - }); - this.preloadNeighborImages(); - }, - - // - // updateDetails() - // Display caption, image number, and bottom nav. - // - updateDetails: function() { - - // if caption is not null - if (this.imageArray[this.activeImage][1] != ""){ - this.caption.update(this.imageArray[this.activeImage][1]).show(); - } - - // if image is part of set display 'Image x of x' - if (this.imageArray.length > 1){ - this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); - } - - new Effect.Parallel( - [ - new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), - new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) - ], - { - duration: this.resizeDuration, - afterFinish: (function() { - // update overlay size and update nav - var arrayPageSize = this.getPageSize(); - this.overlay.setStyle({ height: arrayPageSize[1] + 'px' }); - this.updateNav(); - }).bind(this) - } - ); - }, - - // - // updateNav() - // Display appropriate previous and next hover navigation. - // - updateNav: function() { - - this.hoverNav.show(); - - // if not first image in set, display prev image button - if (this.activeImage > 0) this.prevLink.show(); - - // if not last image in set, display next image button - if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show(); - - this.enableKeyboardNav(); - }, - - // - // enableKeyboardNav() - // - enableKeyboardNav: function() { - document.observe('keydown', this.keyboardAction); - }, - - // - // disableKeyboardNav() - // - disableKeyboardNav: function() { - document.stopObserving('keydown', this.keyboardAction); - }, - - // - // keyboardAction() - // - keyboardAction: function(event) { - var keycode = event.keyCode; - - var escapeKey; - if (event.DOM_VK_ESCAPE) { // mozilla - escapeKey = event.DOM_VK_ESCAPE; - } else { // ie - escapeKey = 27; - } - - var key = String.fromCharCode(keycode).toLowerCase(); - - if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox - this.end(); - } else if ((key == 'p') || (keycode == 37)){ // display previous image - if (this.activeImage != 0){ - this.disableKeyboardNav(); - this.changeImage(this.activeImage - 1); - } - } else if ((key == 'n') || (keycode == 39)){ // display next image - if (this.activeImage != (this.imageArray.length - 1)){ - this.disableKeyboardNav(); - this.changeImage(this.activeImage + 1); - } - } - }, - - // - // preloadNeighborImages() - // Preload previous and next images. - // - preloadNeighborImages: function(){ - var preloadNextImage, preloadPrevImage; - if (this.imageArray.length > this.activeImage + 1){ - preloadNextImage = new Image(); - preloadNextImage.src = this.imageArray[this.activeImage + 1][0]; - } - if (this.activeImage > 0){ - preloadPrevImage = new Image(); - preloadPrevImage.src = this.imageArray[this.activeImage - 1][0]; - } - - }, - - // - // end() - // - end: function() { - this.disableKeyboardNav(); - this.lightbox.hide(); - new Effect.Fade(this.overlay, { duration: this.overlayDuration }); - $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); - }, - - // - // getPageSize() - // - getPageSize: function() { - - var xScroll, yScroll; - - if (window.innerHeight && window.scrollMaxY) { - xScroll = window.innerWidth + window.scrollMaxX; - yScroll = window.innerHeight + window.scrollMaxY; - } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac - xScroll = document.body.scrollWidth; - yScroll = document.body.scrollHeight; - } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari - xScroll = document.body.offsetWidth; - yScroll = document.body.offsetHeight; - } - - var windowWidth, windowHeight; - - if (self.innerHeight) { // all except Explorer - if(document.documentElement.clientWidth){ - windowWidth = document.documentElement.clientWidth; - } else { - windowWidth = self.innerWidth; - } - windowHeight = self.innerHeight; - } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode - windowWidth = document.documentElement.clientWidth; - windowHeight = document.documentElement.clientHeight; - } else if (document.body) { // other Explorers - windowWidth = document.body.clientWidth; - windowHeight = document.body.clientHeight; - } - - // for small pages with total height less then height of the viewport - if(yScroll < windowHeight){ - pageHeight = windowHeight; - } else { - pageHeight = yScroll; - } - - // for small pages with total width less then width of the viewport - if(xScroll < windowWidth){ - pageWidth = xScroll; - } else { - pageWidth = windowWidth; - } - - return [pageWidth,pageHeight]; - } -} - -document.observe('dom:loaded', function () { new Lightbox(); }); \ No newline at end of file diff --git a/Website/LOC.Website.Web/Content/themes/techno/js/prototype.js b/Website/LOC.Website.Web/Content/themes/techno/js/prototype.js deleted file mode 100644 index 2c70b8a7e..000000000 --- a/Website/LOC.Website.Web/Content/themes/techno/js/prototype.js +++ /dev/null @@ -1,4221 +0,0 @@ -/* Prototype JavaScript framework, version 1.6.0.2 - * (c) 2005-2008 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://www.prototypejs.org/ - * - *--------------------------------------------------------------------------*/ - -var Prototype = { - Version: '1.6.0.2', - - Browser: { - IE: !!(window.attachEvent && !window.opera), - Opera: !!window.opera, - WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1, - MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) - }, - - BrowserFeatures: { - XPath: !!document.evaluate, - ElementExtensions: !!window.HTMLElement, - SpecificElementExtensions: - document.createElement('div').__proto__ && - document.createElement('div').__proto__ !== - document.createElement('form').__proto__ - }, - - ScriptFragment: ']*>([\\S\\s]*?)<\/script>', - JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, - - emptyFunction: function() { }, - K: function(x) { return x } -}; - -if (Prototype.Browser.MobileSafari) - Prototype.BrowserFeatures.SpecificElementExtensions = false; - - -/* Based on Alex Arnell's inheritance implementation. */ -var Class = { - create: function() { - var parent = null, properties = $A(arguments); - if (Object.isFunction(properties[0])) - parent = properties.shift(); - - function klass() { - this.initialize.apply(this, arguments); - } - - Object.extend(klass, Class.Methods); - klass.superclass = parent; - klass.subclasses = []; - - if (parent) { - var subclass = function() { }; - subclass.prototype = parent.prototype; - klass.prototype = new subclass; - parent.subclasses.push(klass); - } - - for (var i = 0; i < properties.length; i++) - klass.addMethods(properties[i]); - - if (!klass.prototype.initialize) - klass.prototype.initialize = Prototype.emptyFunction; - - klass.prototype.constructor = klass; - - return klass; - } -}; - -Class.Methods = { - addMethods: function(source) { - var ancestor = this.superclass && this.superclass.prototype; - var properties = Object.keys(source); - - if (!Object.keys({ toString: true }).length) - properties.push("toString", "valueOf"); - - for (var i = 0, length = properties.length; i < length; i++) { - var property = properties[i], value = source[property]; - if (ancestor && Object.isFunction(value) && - value.argumentNames().first() == "$super") { - var method = value, value = Object.extend((function(m) { - return function() { return ancestor[m].apply(this, arguments) }; - })(property).wrap(method), { - valueOf: function() { return method }, - toString: function() { return method.toString() } - }); - } - this.prototype[property] = value; - } - - return this; - } -}; - -var Abstract = { }; - -Object.extend = function(destination, source) { - for (var property in source) - destination[property] = source[property]; - return destination; -}; - -Object.extend(Object, { - inspect: function(object) { - try { - if (Object.isUndefined(object)) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : String(object); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - }, - - toJSON: function(object) { - var type = typeof object; - switch (type) { - case 'undefined': - case 'function': - case 'unknown': return; - case 'boolean': return object.toString(); - } - - if (object === null) return 'null'; - if (object.toJSON) return object.toJSON(); - if (Object.isElement(object)) return; - - var results = []; - for (var property in object) { - var value = Object.toJSON(object[property]); - if (!Object.isUndefined(value)) - results.push(property.toJSON() + ': ' + value); - } - - return '{' + results.join(', ') + '}'; - }, - - toQueryString: function(object) { - return $H(object).toQueryString(); - }, - - toHTML: function(object) { - return object && object.toHTML ? object.toHTML() : String.interpret(object); - }, - - keys: function(object) { - var keys = []; - for (var property in object) - keys.push(property); - return keys; - }, - - values: function(object) { - var values = []; - for (var property in object) - values.push(object[property]); - return values; - }, - - clone: function(object) { - return Object.extend({ }, object); - }, - - isElement: function(object) { - return object && object.nodeType == 1; - }, - - isArray: function(object) { - return object != null && typeof object == "object" && - 'splice' in object && 'join' in object; - }, - - isHash: function(object) { - return object instanceof Hash; - }, - - isFunction: function(object) { - return typeof object == "function"; - }, - - isString: function(object) { - return typeof object == "string"; - }, - - isNumber: function(object) { - return typeof object == "number"; - }, - - isUndefined: function(object) { - return typeof object == "undefined"; - } -}); - -Object.extend(Function.prototype, { - argumentNames: function() { - var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip"); - return names.length == 1 && !names[0] ? [] : names; - }, - - bind: function() { - if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } - }, - - bindAsEventListener: function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function(event) { - return __method.apply(object, [event || window.event].concat(args)); - } - }, - - curry: function() { - if (!arguments.length) return this; - var __method = this, args = $A(arguments); - return function() { - return __method.apply(this, args.concat($A(arguments))); - } - }, - - delay: function() { - var __method = this, args = $A(arguments), timeout = args.shift() * 1000; - return window.setTimeout(function() { - return __method.apply(__method, args); - }, timeout); - }, - - wrap: function(wrapper) { - var __method = this; - return function() { - return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); - } - }, - - methodize: function() { - if (this._methodized) return this._methodized; - var __method = this; - return this._methodized = function() { - return __method.apply(null, [this].concat($A(arguments))); - }; - } -}); - -Function.prototype.defer = Function.prototype.delay.curry(0.01); - -Date.prototype.toJSON = function() { - return '"' + this.getUTCFullYear() + '-' + - (this.getUTCMonth() + 1).toPaddedString(2) + '-' + - this.getUTCDate().toPaddedString(2) + 'T' + - this.getUTCHours().toPaddedString(2) + ':' + - this.getUTCMinutes().toPaddedString(2) + ':' + - this.getUTCSeconds().toPaddedString(2) + 'Z"'; -}; - -var Try = { - these: function() { - var returnValue; - - for (var i = 0, length = arguments.length; i < length; i++) { - var lambda = arguments[i]; - try { - returnValue = lambda(); - break; - } catch (e) { } - } - - return returnValue; - } -}; - -RegExp.prototype.match = RegExp.prototype.test; - -RegExp.escape = function(str) { - return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -}; - -/*--------------------------------------------------------------------------*/ - -var PeriodicalExecuter = Class.create({ - initialize: function(callback, frequency) { - this.callback = callback; - this.frequency = frequency; - this.currentlyExecuting = false; - - this.registerCallback(); - }, - - registerCallback: function() { - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - execute: function() { - this.callback(this); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.execute(); - } finally { - this.currentlyExecuting = false; - } - } - } -}); -Object.extend(String, { - interpret: function(value) { - return value == null ? '' : String(value); - }, - specialChar: { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\\': '\\\\' - } -}); - -Object.extend(String.prototype, { - gsub: function(pattern, replacement) { - var result = '', source = this, match; - replacement = arguments.callee.prepareReplacement(replacement); - - while (source.length > 0) { - if (match = source.match(pattern)) { - result += source.slice(0, match.index); - result += String.interpret(replacement(match)); - source = source.slice(match.index + match[0].length); - } else { - result += source, source = ''; - } - } - return result; - }, - - sub: function(pattern, replacement, count) { - replacement = this.gsub.prepareReplacement(replacement); - count = Object.isUndefined(count) ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - }, - - scan: function(pattern, iterator) { - this.gsub(pattern, iterator); - return String(this); - }, - - truncate: function(length, truncation) { - length = length || 30; - truncation = Object.isUndefined(truncation) ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : String(this); - }, - - strip: function() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - }, - - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(function(script) { return eval(script) }); - }, - - escapeHTML: function() { - var self = arguments.callee; - self.text.data = this; - return self.div.innerHTML; - }, - - unescapeHTML: function() { - var div = new Element('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : - div.childNodes[0].nodeValue) : ''; - }, - - toQueryParams: function(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return { }; - - return match[1].split(separator || '&').inject({ }, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var key = decodeURIComponent(pair.shift()); - var value = pair.length > 1 ? pair.join('=') : pair[0]; - if (value != undefined) value = decodeURIComponent(value); - - if (key in hash) { - if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; - hash[key].push(value); - } - else hash[key] = value; - } - return hash; - }); - }, - - toArray: function() { - return this.split(''); - }, - - succ: function() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - }, - - times: function(count) { - return count < 1 ? '' : new Array(count + 1).join(this); - }, - - camelize: function() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; - }, - - capitalize: function() { - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - }, - - underscore: function() { - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); - }, - - dasherize: function() { - return this.gsub(/_/,'-'); - }, - - inspect: function(useDoubleQuotes) { - var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { - var character = String.specialChar[match[0]]; - return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); - }); - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - }, - - toJSON: function() { - return this.inspect(true); - }, - - unfilterJSON: function(filter) { - return this.sub(filter || Prototype.JSONFilter, '#{1}'); - }, - - isJSON: function() { - var str = this; - if (str.blank()) return false; - str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); - return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); - }, - - evalJSON: function(sanitize) { - var json = this.unfilterJSON(); - try { - if (!sanitize || json.isJSON()) return eval('(' + json + ')'); - } catch (e) { } - throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); - }, - - include: function(pattern) { - return this.indexOf(pattern) > -1; - }, - - startsWith: function(pattern) { - return this.indexOf(pattern) === 0; - }, - - endsWith: function(pattern) { - var d = this.length - pattern.length; - return d >= 0 && this.lastIndexOf(pattern) === d; - }, - - empty: function() { - return this == ''; - }, - - blank: function() { - return /^\s*$/.test(this); - }, - - interpolate: function(object, pattern) { - return new Template(this, pattern).evaluate(object); - } -}); - -if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { - escapeHTML: function() { - return this.replace(/&/g,'&').replace(//g,'>'); - }, - unescapeHTML: function() { - return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); - } -}); - -String.prototype.gsub.prepareReplacement = function(replacement) { - if (Object.isFunction(replacement)) return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; -}; - -String.prototype.parseQuery = String.prototype.toQueryParams; - -Object.extend(String.prototype.escapeHTML, { - div: document.createElement('div'), - text: document.createTextNode('') -}); - -with (String.prototype.escapeHTML) div.appendChild(text); - -var Template = Class.create({ - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - if (Object.isFunction(object.toTemplateReplacements)) - object = object.toTemplateReplacements(); - - return this.template.gsub(this.pattern, function(match) { - if (object == null) return ''; - - var before = match[1] || ''; - if (before == '\\') return match[2]; - - var ctx = object, expr = match[3]; - var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; - match = pattern.exec(expr); - if (match == null) return before; - - while (match != null) { - var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; - ctx = ctx[comp]; - if (null == ctx || '' == match[3]) break; - expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); - match = pattern.exec(expr); - } - - return before + String.interpret(ctx); - }); - } -}); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; - -var $break = { }; - -var Enumerable = { - each: function(iterator, context) { - var index = 0; - iterator = iterator.bind(context); - try { - this._each(function(value) { - iterator(value, index++); - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - }, - - eachSlice: function(number, iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var index = -number, slices = [], array = this.toArray(); - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.collect(iterator, context); - }, - - all: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result = true; - this.each(function(value, index) { - result = result && !!iterator(value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result = false; - this.each(function(value, index) { - if (result = !!iterator(value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var results = []; - this.each(function(value, index) { - results.push(iterator(value, index)); - }); - return results; - }, - - detect: function(iterator, context) { - iterator = iterator.bind(context); - var result; - this.each(function(value, index) { - if (iterator(value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator, context) { - iterator = iterator.bind(context); - var results = []; - this.each(function(value, index) { - if (iterator(value, index)) - results.push(value); - }); - return results; - }, - - grep: function(filter, iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var results = []; - - if (Object.isString(filter)) - filter = new RegExp(filter); - - this.each(function(value, index) { - if (filter.match(value)) - results.push(iterator(value, index)); - }); - return results; - }, - - include: function(object) { - if (Object.isFunction(this.indexOf)) - if (this.indexOf(object) != -1) return true; - - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inGroupsOf: function(number, fillWith) { - fillWith = Object.isUndefined(fillWith) ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - }, - - inject: function(memo, iterator, context) { - iterator = iterator.bind(context); - this.each(function(value, index) { - memo = iterator(memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result; - this.each(function(value, index) { - value = iterator(value, index); - if (result == null || value >= result) - result = value; - }); - return result; - }, - - min: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result; - this.each(function(value, index) { - value = iterator(value, index); - if (result == null || value < result) - result = value; - }); - return result; - }, - - partition: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var trues = [], falses = []; - this.each(function(value, index) { - (iterator(value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator, context) { - iterator = iterator.bind(context); - var results = []; - this.each(function(value, index) { - if (!iterator(value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator, context) { - iterator = iterator.bind(context); - return this.map(function(value, index) { - return {value: value, criteria: iterator(value, index)}; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.map(); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (Object.isFunction(args.last())) - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - }, - - size: function() { - return this.toArray().length; - }, - - inspect: function() { - return '#'; - } -}; - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - filter: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray, - every: Enumerable.all, - some: Enumerable.any -}); -function $A(iterable) { - if (!iterable) return []; - if (iterable.toArray) return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; -} - -if (Prototype.Browser.WebKit) { - $A = function(iterable) { - if (!iterable) return []; - if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') && - iterable.toArray) return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; - }; -} - -Array.from = $A; - -Object.extend(Array.prototype, Enumerable); - -if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(Object.isArray(value) ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - reduce: function() { - return this.length > 1 ? this : this[0]; - }, - - uniq: function(sorted) { - return this.inject([], function(array, value, index) { - if (0 == index || (sorted ? array.last() != value : !array.include(value))) - array.push(value); - return array; - }); - }, - - intersect: function(array) { - return this.uniq().findAll(function(item) { - return array.detect(function(value) { return item === value }); - }); - }, - - clone: function() { - return [].concat(this); - }, - - size: function() { - return this.length; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - }, - - toJSON: function() { - var results = []; - this.each(function(object) { - var value = Object.toJSON(object); - if (!Object.isUndefined(value)) results.push(value); - }); - return '[' + results.join(', ') + ']'; - } -}); - -// use native browser JS 1.6 implementation if available -if (Object.isFunction(Array.prototype.forEach)) - Array.prototype._each = Array.prototype.forEach; - -if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) { - i || (i = 0); - var length = this.length; - if (i < 0) i = length + i; - for (; i < length; i++) - if (this[i] === item) return i; - return -1; -}; - -if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) { - i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; - var n = this.slice(0, i).reverse().indexOf(item); - return (n < 0) ? n : i - n - 1; -}; - -Array.prototype.toArray = Array.prototype.clone; - -function $w(string) { - if (!Object.isString(string)) return []; - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -if (Prototype.Browser.Opera){ - Array.prototype.concat = function() { - var array = []; - for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for (var i = 0, length = arguments.length; i < length; i++) { - if (Object.isArray(arguments[i])) { - for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) - array.push(arguments[i][j]); - } else { - array.push(arguments[i]); - } - } - return array; - }; -} -Object.extend(Number.prototype, { - toColorPart: function() { - return this.toPaddedString(2, 16); - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator) { - $R(0, this, true).each(iterator); - return this; - }, - - toPaddedString: function(length, radix) { - var string = this.toString(radix || 10); - return '0'.times(length - string.length) + string; - }, - - toJSON: function() { - return isFinite(this) ? this.toString() : 'null'; - } -}); - -$w('abs round ceil floor').each(function(method){ - Number.prototype[method] = Math[method].methodize(); -}); -function $H(object) { - return new Hash(object); -}; - -var Hash = Class.create(Enumerable, (function() { - - function toQueryPair(key, value) { - if (Object.isUndefined(value)) return key; - return key + '=' + encodeURIComponent(String.interpret(value)); - } - - return { - initialize: function(object) { - this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); - }, - - _each: function(iterator) { - for (var key in this._object) { - var value = this._object[key], pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - }, - - set: function(key, value) { - return this._object[key] = value; - }, - - get: function(key) { - return this._object[key]; - }, - - unset: function(key) { - var value = this._object[key]; - delete this._object[key]; - return value; - }, - - toObject: function() { - return Object.clone(this._object); - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - index: function(value) { - var match = this.detect(function(pair) { - return pair.value === value; - }); - return match && match.key; - }, - - merge: function(object) { - return this.clone().update(object); - }, - - update: function(object) { - return new Hash(object).inject(this, function(result, pair) { - result.set(pair.key, pair.value); - return result; - }); - }, - - toQueryString: function() { - return this.map(function(pair) { - var key = encodeURIComponent(pair.key), values = pair.value; - - if (values && typeof values == 'object') { - if (Object.isArray(values)) - return values.map(toQueryPair.curry(key)).join('&'); - } - return toQueryPair(key, values); - }).join('&'); - }, - - inspect: function() { - return '#'; - }, - - toJSON: function() { - return Object.toJSON(this.toObject()); - }, - - clone: function() { - return new Hash(this); - } - } -})()); - -Hash.prototype.toTemplateReplacements = Hash.prototype.toObject; -Hash.from = $H; -var ObjectRange = Class.create(Enumerable, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -}; - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new XMLHttpRequest()}, - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')} - ) || false; - }, - - activeRequestCount: 0 -}; - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responder) { - if (!this.include(responder)) - this.responders.push(responder); - }, - - unregister: function(responder) { - this.responders = this.responders.without(responder); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (Object.isFunction(responder[callback])) { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) { } - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { Ajax.activeRequestCount++ }, - onComplete: function() { Ajax.activeRequestCount-- } -}); - -Ajax.Base = Class.create({ - initialize: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '', - evalJSON: true, - evalJS: true - }; - Object.extend(this.options, options || { }); - - this.options.method = this.options.method.toLowerCase(); - - if (Object.isString(this.options.parameters)) - this.options.parameters = this.options.parameters.toQueryParams(); - else if (Object.isHash(this.options.parameters)) - this.options.parameters = this.options.parameters.toObject(); - } -}); - -Ajax.Request = Class.create(Ajax.Base, { - _complete: false, - - initialize: function($super, url, options) { - $super(options); - this.transport = Ajax.getTransport(); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = Object.clone(this.options.parameters); - - if (!['get', 'post'].include(this.method)) { - // simulate other verbs over post - params['_method'] = this.method; - this.method = 'post'; - } - - this.parameters = params; - - if (params = Object.toQueryString(params)) { - // when GET, append parameters to URL - if (this.method == 'get') - this.url += (this.url.include('?') ? '&' : '?') + params; - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - params += '&_='; - } - - try { - var response = new Ajax.Response(this); - if (this.options.onCreate) this.options.onCreate(response); - Ajax.Responders.dispatch('onCreate', this, response); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - this.body = this.method == 'post' ? (this.options.postBody || params) : null; - this.transport.send(this.body); - - /* Force Firefox to handle ready state 4 for synchronous requests */ - if (!this.options.asynchronous && this.transport.overrideMimeType) - this.onStateChange(); - - } - catch (e) { - this.dispatchException(e); - } - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState > 1 && !((readyState == 4) && this._complete)) - this.respondToReadyState(this.transport.readyState); - }, - - setRequestHeaders: function() { - var headers = { - 'X-Requested-With': 'XMLHttpRequest', - 'X-Prototype-Version': Prototype.Version, - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }; - - if (this.method == 'post') { - headers['Content-type'] = this.options.contentType + - (this.options.encoding ? '; charset=' + this.options.encoding : ''); - - /* Force "Connection: close" for older Mozilla browsers to work - * around a bug where XMLHttpRequest sends an incorrect - * Content-length header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType && - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) - headers['Connection'] = 'close'; - } - - // user-defined headers - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (Object.isFunction(extras.push)) - for (var i = 0, length = extras.length; i < length; i += 2) - headers[extras[i]] = extras[i+1]; - else - $H(extras).each(function(pair) { headers[pair.key] = pair.value }); - } - - for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); - }, - - success: function() { - var status = this.getStatus(); - return !status || (status >= 200 && status < 300); - }, - - getStatus: function() { - try { - return this.transport.status || 0; - } catch (e) { return 0 } - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + response.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - var contentType = response.getHeader('Content-type'); - if (this.options.evalJS == 'force' - || (this.options.evalJS && this.isSameOrigin() && contentType - && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); - Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - // avoid memory leak in MSIE: clean up - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - isSameOrigin: function() { - var m = this.url.match(/^\s*https?:\/\/[^\/]*/); - return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ - protocol: location.protocol, - domain: document.domain, - port: location.port ? ':' + location.port : '' - })); - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name) || null; - } catch (e) { return null } - }, - - evalResponse: function() { - try { - return eval((this.transport.responseText || '').unfilterJSON()); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Response = Class.create({ - initialize: function(request){ - this.request = request; - var transport = this.transport = request.transport, - readyState = this.readyState = transport.readyState; - - if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { - this.status = this.getStatus(); - this.statusText = this.getStatusText(); - this.responseText = String.interpret(transport.responseText); - this.headerJSON = this._getHeaderJSON(); - } - - if(readyState == 4) { - var xml = transport.responseXML; - this.responseXML = Object.isUndefined(xml) ? null : xml; - this.responseJSON = this._getResponseJSON(); - } - }, - - status: 0, - statusText: '', - - getStatus: Ajax.Request.prototype.getStatus, - - getStatusText: function() { - try { - return this.transport.statusText || ''; - } catch (e) { return '' } - }, - - getHeader: Ajax.Request.prototype.getHeader, - - getAllHeaders: function() { - try { - return this.getAllResponseHeaders(); - } catch (e) { return null } - }, - - getResponseHeader: function(name) { - return this.transport.getResponseHeader(name); - }, - - getAllResponseHeaders: function() { - return this.transport.getAllResponseHeaders(); - }, - - _getHeaderJSON: function() { - var json = this.getHeader('X-JSON'); - if (!json) return null; - json = decodeURIComponent(escape(json)); - try { - return json.evalJSON(this.request.options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - }, - - _getResponseJSON: function() { - var options = this.request.options; - if (!options.evalJSON || (options.evalJSON != 'force' && - !(this.getHeader('Content-type') || '').include('application/json')) || - this.responseText.blank()) - return null; - try { - return this.responseText.evalJSON(options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - } -}); - -Ajax.Updater = Class.create(Ajax.Request, { - initialize: function($super, container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - }; - - options = Object.clone(options); - var onComplete = options.onComplete; - options.onComplete = (function(response, json) { - this.updateContent(response.responseText); - if (Object.isFunction(onComplete)) onComplete(response, json); - }).bind(this); - - $super(url, options); - }, - - updateContent: function(responseText) { - var receiver = this.container[this.success() ? 'success' : 'failure'], - options = this.options; - - if (!options.evalScripts) responseText = responseText.stripScripts(); - - if (receiver = $(receiver)) { - if (options.insertion) { - if (Object.isString(options.insertion)) { - var insertion = { }; insertion[options.insertion] = responseText; - receiver.insert(insertion); - } - else options.insertion(receiver, responseText); - } - else receiver.update(responseText); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { - initialize: function($super, container, url, options) { - $super(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = { }; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.options.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(response) { - if (this.options.decay) { - this.decay = (response.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = response.responseText; - } - this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -function $(element) { - if (arguments.length > 1) { - for (var i = 0, elements = [], length = arguments.length; i < length; i++) - elements.push($(arguments[i])); - return elements; - } - if (Object.isString(element)) - element = document.getElementById(element); - return Element.extend(element); -} - -if (Prototype.BrowserFeatures.XPath) { - document._getElementsByXPath = function(expression, parentElement) { - var results = []; - var query = document.evaluate(expression, $(parentElement) || document, - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for (var i = 0, length = query.snapshotLength; i < length; i++) - results.push(Element.extend(query.snapshotItem(i))); - return results; - }; -} - -/*--------------------------------------------------------------------------*/ - -if (!window.Node) var Node = { }; - -if (!Node.ELEMENT_NODE) { - // DOM level 2 ECMAScript Language Binding - Object.extend(Node, { - ELEMENT_NODE: 1, - ATTRIBUTE_NODE: 2, - TEXT_NODE: 3, - CDATA_SECTION_NODE: 4, - ENTITY_REFERENCE_NODE: 5, - ENTITY_NODE: 6, - PROCESSING_INSTRUCTION_NODE: 7, - COMMENT_NODE: 8, - DOCUMENT_NODE: 9, - DOCUMENT_TYPE_NODE: 10, - DOCUMENT_FRAGMENT_NODE: 11, - NOTATION_NODE: 12 - }); -} - -(function() { - var element = this.Element; - this.Element = function(tagName, attributes) { - attributes = attributes || { }; - tagName = tagName.toLowerCase(); - var cache = Element.cache; - if (Prototype.Browser.IE && attributes.name) { - tagName = '<' + tagName + ' name="' + attributes.name + '">'; - delete attributes.name; - return Element.writeAttribute(document.createElement(tagName), attributes); - } - if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); - return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); - }; - Object.extend(this.Element, element || { }); -}).call(window); - -Element.cache = { }; - -Element.Methods = { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function(element) { - element = $(element); - Element[Element.visible(element) ? 'hide' : 'show'](element); - return element; - }, - - hide: function(element) { - $(element).style.display = 'none'; - return element; - }, - - show: function(element) { - $(element).style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - content = Object.toHTML(content); - element.innerHTML = content.stripScripts(); - content.evalScripts.bind(content).defer(); - return element; - }, - - replace: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - else if (!Object.isElement(content)) { - content = Object.toHTML(content); - var range = element.ownerDocument.createRange(); - range.selectNode(element); - content.evalScripts.bind(content).defer(); - content = range.createContextualFragment(content.stripScripts()); - } - element.parentNode.replaceChild(content, element); - return element; - }, - - insert: function(element, insertions) { - element = $(element); - - if (Object.isString(insertions) || Object.isNumber(insertions) || - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) - insertions = {bottom:insertions}; - - var content, insert, tagName, childNodes; - - for (var position in insertions) { - content = insertions[position]; - position = position.toLowerCase(); - insert = Element._insertionTranslations[position]; - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - insert(element, content); - continue; - } - - content = Object.toHTML(content); - - tagName = ((position == 'before' || position == 'after') - ? element.parentNode : element).tagName.toUpperCase(); - - childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - - if (position == 'top' || position == 'after') childNodes.reverse(); - childNodes.each(insert.curry(element)); - - content.evalScripts.bind(content).defer(); - } - - return element; - }, - - wrap: function(element, wrapper, attributes) { - element = $(element); - if (Object.isElement(wrapper)) - $(wrapper).writeAttribute(attributes || { }); - else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); - else wrapper = new Element('div', wrapper); - if (element.parentNode) - element.parentNode.replaceChild(wrapper, element); - wrapper.appendChild(element); - return wrapper; - }, - - inspect: function(element) { - element = $(element); - var result = '<' + element.tagName.toLowerCase(); - $H({'id': 'id', 'className': 'class'}).each(function(pair) { - var property = pair.first(), attribute = pair.last(); - var value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property) { - element = $(element); - var elements = []; - while (element = element[property]) - if (element.nodeType == 1) - elements.push(Element.extend(element)); - return elements; - }, - - ancestors: function(element) { - return $(element).recursivelyCollect('parentNode'); - }, - - descendants: function(element) { - return $(element).select("*"); - }, - - firstDescendant: function(element) { - element = $(element).firstChild; - while (element && element.nodeType != 1) element = element.nextSibling; - return $(element); - }, - - immediateDescendants: function(element) { - if (!(element = $(element).firstChild)) return []; - while (element && element.nodeType != 1) element = element.nextSibling; - if (element) return [element].concat($(element).nextSiblings()); - return []; - }, - - previousSiblings: function(element) { - return $(element).recursivelyCollect('previousSibling'); - }, - - nextSiblings: function(element) { - return $(element).recursivelyCollect('nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return element.previousSiblings().reverse().concat(element.nextSiblings()); - }, - - match: function(element, selector) { - if (Object.isString(selector)) - selector = new Selector(selector); - return selector.match($(element)); - }, - - up: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(element.parentNode); - var ancestors = element.ancestors(); - return Object.isNumber(expression) ? ancestors[expression] : - Selector.findElement(ancestors, expression, index); - }, - - down: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return element.firstDescendant(); - return Object.isNumber(expression) ? element.descendants()[expression] : - element.select(expression)[index || 0]; - }, - - previous: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); - var previousSiblings = element.previousSiblings(); - return Object.isNumber(expression) ? previousSiblings[expression] : - Selector.findElement(previousSiblings, expression, index); - }, - - next: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); - var nextSiblings = element.nextSiblings(); - return Object.isNumber(expression) ? nextSiblings[expression] : - Selector.findElement(nextSiblings, expression, index); - }, - - select: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element, args); - }, - - adjacent: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element.parentNode, args).without(element); - }, - - identify: function(element) { - element = $(element); - var id = element.readAttribute('id'), self = arguments.callee; - if (id) return id; - do { id = 'anonymous_element_' + self.counter++ } while ($(id)); - element.writeAttribute('id', id); - return id; - }, - - readAttribute: function(element, name) { - element = $(element); - if (Prototype.Browser.IE) { - var t = Element._attributeTranslations.read; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - if (name.include(':')) { - return (!element.attributes || !element.attributes[name]) ? null : - element.attributes[name].value; - } - } - return element.getAttribute(name); - }, - - writeAttribute: function(element, name, value) { - element = $(element); - var attributes = { }, t = Element._attributeTranslations.write; - - if (typeof name == 'object') attributes = name; - else attributes[name] = Object.isUndefined(value) ? true : value; - - for (var attr in attributes) { - name = t.names[attr] || attr; - value = attributes[attr]; - if (t.values[attr]) name = t.values[attr](element, value); - if (value === false || value === null) - element.removeAttribute(name); - else if (value === true) - element.setAttribute(name, name); - else element.setAttribute(name, value); - } - return element; - }, - - getHeight: function(element) { - return $(element).getDimensions().height; - }, - - getWidth: function(element) { - return $(element).getDimensions().width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - return (elementClassName.length > 0 && (elementClassName == className || - new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName))); - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - if (!element.hasClassName(className)) - element.className += (element.className ? ' ' : '') + className; - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - element.className = element.className.replace( - new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - return element[element.hasClassName(className) ? - 'removeClassName' : 'addClassName'](className); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - var node = element.firstChild; - while (node) { - var nextNode = node.nextSibling; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - element.removeChild(node); - node = nextNode; - } - return element; - }, - - empty: function(element) { - return $(element).innerHTML.blank(); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - var originalAncestor = ancestor; - - if (element.compareDocumentPosition) - return (element.compareDocumentPosition(ancestor) & 8) === 8; - - if (element.sourceIndex && !Prototype.Browser.Opera) { - var e = element.sourceIndex, a = ancestor.sourceIndex, - nextAncestor = ancestor.nextSibling; - if (!nextAncestor) { - do { ancestor = ancestor.parentNode; } - while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode); - } - if (nextAncestor && nextAncestor.sourceIndex) - return (e > a && e < nextAncestor.sourceIndex); - } - - while (element = element.parentNode) - if (element == originalAncestor) return true; - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = element.cumulativeOffset(); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - style = style == 'float' ? 'cssFloat' : style.camelize(); - var value = element.style[style]; - if (!value) { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } - if (style == 'opacity') return value ? parseFloat(value) : 1.0; - return value == 'auto' ? null : value; - }, - - getOpacity: function(element) { - return $(element).getStyle('opacity'); - }, - - setStyle: function(element, styles) { - element = $(element); - var elementStyle = element.style, match; - if (Object.isString(styles)) { - element.style.cssText += ';' + styles; - return styles.include('opacity') ? - element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; - } - for (var property in styles) - if (property == 'opacity') element.setOpacity(styles[property]); - else - elementStyle[(property == 'float' || property == 'cssFloat') ? - (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') : - property] = styles[property]; - - return element; - }, - - setOpacity: function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - return element; - }, - - getDimensions: function(element) { - element = $(element); - var display = $(element).getStyle('display'); - if (display != 'none' && display != null) // Safari bug - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - var originalDisplay = els.display; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = 'block'; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = originalDisplay; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (window.opera) { - element.style.top = 0; - element.style.left = 0; - } - } - return element; - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - return element; - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return element; - element._overflow = Element.getStyle(element, 'overflow') || 'auto'; - if (element._overflow !== 'hidden') - element.style.overflow = 'hidden'; - return element; - }, - - undoClipping: function(element) { - element = $(element); - if (!element._overflow) return element; - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; - element._overflow = null; - return element; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if (element.tagName == 'BODY') break; - var p = Element.getStyle(element, 'position'); - if (p !== 'static') break; - } - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - absolutize: function(element) { - element = $(element); - if (element.getStyle('position') == 'absolute') return; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - var offsets = element.positionedOffset(); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - return element; - }, - - relativize: function(element) { - element = $(element); - if (element.getStyle('position') == 'relative') return; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - return element; - }, - - cumulativeScrollOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - getOffsetParent: function(element) { - if (element.offsetParent) return $(element.offsetParent); - if (element == document.body) return $(element); - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return $(element); - - return $(document.body); - }, - - viewportOffset: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent == document.body && - Element.getStyle(element, 'position') == 'absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!Prototype.Browser.Opera || element.tagName == 'BODY') { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return Element._returnOffset(valueL, valueT); - }, - - clonePosition: function(element, source) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || { }); - - // find page position of source - source = $(source); - var p = source.viewportOffset(); - - // find coordinate system to use - element = $(element); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(element, 'position') == 'absolute') { - parent = element.getOffsetParent(); - delta = parent.viewportOffset(); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if (options.setWidth) element.style.width = source.offsetWidth + 'px'; - if (options.setHeight) element.style.height = source.offsetHeight + 'px'; - return element; - } -}; - -Element.Methods.identify.counter = 1; - -Object.extend(Element.Methods, { - getElementsBySelector: Element.Methods.select, - childElements: Element.Methods.immediateDescendants -}); - -Element._attributeTranslations = { - write: { - names: { - className: 'class', - htmlFor: 'for' - }, - values: { } - } -}; - -if (Prototype.Browser.Opera) { - Element.Methods.getStyle = Element.Methods.getStyle.wrap( - function(proceed, element, style) { - switch (style) { - case 'left': case 'top': case 'right': case 'bottom': - if (proceed(element, 'position') === 'static') return null; - case 'height': case 'width': - // returns '0px' for hidden elements; we want it to return null - if (!Element.visible(element)) return null; - - // returns the border-box dimensions rather than the content-box - // dimensions, so we subtract padding and borders from the value - var dim = parseInt(proceed(element, style), 10); - - if (dim !== element['offset' + style.capitalize()]) - return dim + 'px'; - - var properties; - if (style === 'height') { - properties = ['border-top-width', 'padding-top', - 'padding-bottom', 'border-bottom-width']; - } - else { - properties = ['border-left-width', 'padding-left', - 'padding-right', 'border-right-width']; - } - return properties.inject(dim, function(memo, property) { - var val = proceed(element, property); - return val === null ? memo : memo - parseInt(val, 10); - }) + 'px'; - default: return proceed(element, style); - } - } - ); - - Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( - function(proceed, element, attribute) { - if (attribute === 'title') return element.title; - return proceed(element, attribute); - } - ); -} - -else if (Prototype.Browser.IE) { - // IE doesn't report offsets correctly for static elements, so we change them - // to "relative" to get the values, then change them back. - Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( - function(proceed, element) { - element = $(element); - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - - $w('positionedOffset viewportOffset').each(function(method) { - Element.Methods[method] = Element.Methods[method].wrap( - function(proceed, element) { - element = $(element); - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - // Trigger hasLayout on the offset parent so that IE6 reports - // accurate offsetTop and offsetLeft values for position: fixed. - var offsetParent = element.getOffsetParent(); - if (offsetParent && offsetParent.getStyle('position') === 'fixed') - offsetParent.setStyle({ zoom: 1 }); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - }); - - Element.Methods.getStyle = function(element, style) { - element = $(element); - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); - var value = element.style[style]; - if (!value && element.currentStyle) value = element.currentStyle[style]; - - if (style == 'opacity') { - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if (value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - - if (value == 'auto') { - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) - return element['offset' + style.capitalize()] + 'px'; - return null; - } - return value; - }; - - Element.Methods.setOpacity = function(element, value) { - function stripAlpha(filter){ - return filter.replace(/alpha\([^\)]*\)/gi,''); - } - element = $(element); - var currentStyle = element.currentStyle; - if ((currentStyle && !currentStyle.hasLayout) || - (!currentStyle && element.style.zoom == 'normal')) - element.style.zoom = 1; - - var filter = element.getStyle('filter'), style = element.style; - if (value == 1 || value === '') { - (filter = stripAlpha(filter)) ? - style.filter = filter : style.removeAttribute('filter'); - return element; - } else if (value < 0.00001) value = 0; - style.filter = stripAlpha(filter) + - 'alpha(opacity=' + (value * 100) + ')'; - return element; - }; - - Element._attributeTranslations = { - read: { - names: { - 'class': 'className', - 'for': 'htmlFor' - }, - values: { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - _getAttrNode: function(element, attribute) { - var node = element.getAttributeNode(attribute); - return node ? node.value : ""; - }, - _getEv: function(element, attribute) { - attribute = element.getAttribute(attribute); - return attribute ? attribute.toString().slice(23, -2) : null; - }, - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - title: function(element) { - return element.title; - } - } - } - }; - - Element._attributeTranslations.write = { - names: Object.extend({ - cellpadding: 'cellPadding', - cellspacing: 'cellSpacing' - }, Element._attributeTranslations.read.names), - values: { - checked: function(element, value) { - element.checked = !!value; - }, - - style: function(element, value) { - element.style.cssText = value ? value : ''; - } - } - }; - - Element._attributeTranslations.has = {}; - - $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + - 'encType maxLength readOnly longDesc').each(function(attr) { - Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; - Element._attributeTranslations.has[attr.toLowerCase()] = attr; - }); - - (function(v) { - Object.extend(v, { - href: v._getAttr, - src: v._getAttr, - type: v._getAttr, - action: v._getAttrNode, - disabled: v._flag, - checked: v._flag, - readonly: v._flag, - multiple: v._flag, - onload: v._getEv, - onunload: v._getEv, - onclick: v._getEv, - ondblclick: v._getEv, - onmousedown: v._getEv, - onmouseup: v._getEv, - onmouseover: v._getEv, - onmousemove: v._getEv, - onmouseout: v._getEv, - onfocus: v._getEv, - onblur: v._getEv, - onkeypress: v._getEv, - onkeydown: v._getEv, - onkeyup: v._getEv, - onsubmit: v._getEv, - onreset: v._getEv, - onselect: v._getEv, - onchange: v._getEv - }); - })(Element._attributeTranslations.read.values); -} - -else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1) ? 0.999999 : - (value === '') ? '' : (value < 0.00001) ? 0 : value; - return element; - }; -} - -else if (Prototype.Browser.WebKit) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - - if (value == 1) - if(element.tagName == 'IMG' && element.width) { - element.width++; element.width--; - } else try { - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch (e) { } - - return element; - }; - - // Safari returns margins on body which is incorrect if the child is absolutely - // positioned. For performance reasons, redefine Element#cumulativeOffset for - // KHTML/WebKit only. - Element.Methods.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return Element._returnOffset(valueL, valueT); - }; -} - -if (Prototype.Browser.IE || Prototype.Browser.Opera) { - // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements - Element.Methods.update = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - - content = Object.toHTML(content); - var tagName = element.tagName.toUpperCase(); - - if (tagName in Element._insertionTranslations.tags) { - $A(element.childNodes).each(function(node) { element.removeChild(node) }); - Element._getContentFromAnonymousElement(tagName, content.stripScripts()) - .each(function(node) { element.appendChild(node) }); - } - else element.innerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -if ('outerHTML' in document.createElement('div')) { - Element.Methods.replace = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - element.parentNode.replaceChild(content, element); - return element; - } - - content = Object.toHTML(content); - var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); - - if (Element._insertionTranslations.tags[tagName]) { - var nextSibling = element.next(); - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - parent.removeChild(element); - if (nextSibling) - fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); - else - fragments.each(function(node) { parent.appendChild(node) }); - } - else element.outerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -Element._returnOffset = function(l, t) { - var result = [l, t]; - result.left = l; - result.top = t; - return result; -}; - -Element._getContentFromAnonymousElement = function(tagName, html) { - var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; - if (t) { - div.innerHTML = t[0] + html + t[1]; - t[2].times(function() { div = div.firstChild }); - } else div.innerHTML = html; - return $A(div.childNodes); -}; - -Element._insertionTranslations = { - before: function(element, node) { - element.parentNode.insertBefore(node, element); - }, - top: function(element, node) { - element.insertBefore(node, element.firstChild); - }, - bottom: function(element, node) { - element.appendChild(node); - }, - after: function(element, node) { - element.parentNode.insertBefore(node, element.nextSibling); - }, - tags: { - TABLE: ['
', '
', 1], - TBODY: ['', '
', 2], - TR: ['', '
', 3], - TD: ['
', '
', 4], - SELECT: ['', 1] - } -}; - -(function() { - Object.extend(this.tags, { - THEAD: this.tags.TBODY, - TFOOT: this.tags.TBODY, - TH: this.tags.TD - }); -}).call(Element._insertionTranslations); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - attribute = Element._attributeTranslations.has[attribute] || attribute; - var node = $(element).getAttributeNode(attribute); - return node && node.specified; - } -}; - -Element.Methods.ByTag = { }; - -Object.extend(Element, Element.Methods); - -if (!Prototype.BrowserFeatures.ElementExtensions && - document.createElement('div').__proto__) { - window.HTMLElement = { }; - window.HTMLElement.prototype = document.createElement('div').__proto__; - Prototype.BrowserFeatures.ElementExtensions = true; -} - -Element.extend = (function() { - if (Prototype.BrowserFeatures.SpecificElementExtensions) - return Prototype.K; - - var Methods = { }, ByTag = Element.Methods.ByTag; - - var extend = Object.extend(function(element) { - if (!element || element._extendedByPrototype || - element.nodeType != 1 || element == window) return element; - - var methods = Object.clone(Methods), - tagName = element.tagName, property, value; - - // extend methods for specific tags - if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); - - for (property in methods) { - value = methods[property]; - if (Object.isFunction(value) && !(property in element)) - element[property] = value.methodize(); - } - - element._extendedByPrototype = Prototype.emptyFunction; - return element; - - }, { - refresh: function() { - // extend methods for all tags (Safari doesn't need this) - if (!Prototype.BrowserFeatures.ElementExtensions) { - Object.extend(Methods, Element.Methods); - Object.extend(Methods, Element.Methods.Simulated); - } - } - }); - - extend.refresh(); - return extend; -})(); - -Element.hasAttribute = function(element, attribute) { - if (element.hasAttribute) return element.hasAttribute(attribute); - return Element.Methods.Simulated.hasAttribute(element, attribute); -}; - -Element.addMethods = function(methods) { - var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; - - if (!methods) { - Object.extend(Form, Form.Methods); - Object.extend(Form.Element, Form.Element.Methods); - Object.extend(Element.Methods.ByTag, { - "FORM": Object.clone(Form.Methods), - "INPUT": Object.clone(Form.Element.Methods), - "SELECT": Object.clone(Form.Element.Methods), - "TEXTAREA": Object.clone(Form.Element.Methods) - }); - } - - if (arguments.length == 2) { - var tagName = methods; - methods = arguments[1]; - } - - if (!tagName) Object.extend(Element.Methods, methods || { }); - else { - if (Object.isArray(tagName)) tagName.each(extend); - else extend(tagName); - } - - function extend(tagName) { - tagName = tagName.toUpperCase(); - if (!Element.Methods.ByTag[tagName]) - Element.Methods.ByTag[tagName] = { }; - Object.extend(Element.Methods.ByTag[tagName], methods); - } - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - for (var property in methods) { - var value = methods[property]; - if (!Object.isFunction(value)) continue; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = value.methodize(); - } - } - - function findDOMClass(tagName) { - var klass; - var trans = { - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": - "FrameSet", "IFRAME": "IFrame" - }; - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName.capitalize() + 'Element'; - if (window[klass]) return window[klass]; - - window[klass] = { }; - window[klass].prototype = document.createElement(tagName).__proto__; - return window[klass]; - } - - if (F.ElementExtensions) { - copy(Element.Methods, HTMLElement.prototype); - copy(Element.Methods.Simulated, HTMLElement.prototype, true); - } - - if (F.SpecificElementExtensions) { - for (var tag in Element.Methods.ByTag) { - var klass = findDOMClass(tag); - if (Object.isUndefined(klass)) continue; - copy(T[tag], klass.prototype); - } - } - - Object.extend(Element, Element.Methods); - delete Element.ByTag; - - if (Element.extend.refresh) Element.extend.refresh(); - Element.cache = { }; -}; - -document.viewport = { - getDimensions: function() { - var dimensions = { }; - var B = Prototype.Browser; - $w('width height').each(function(d) { - var D = d.capitalize(); - dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] : - (B.Opera) ? document.body['client' + D] : document.documentElement['client' + D]; - }); - return dimensions; - }, - - getWidth: function() { - return this.getDimensions().width; - }, - - getHeight: function() { - return this.getDimensions().height; - }, - - getScrollOffsets: function() { - return Element._returnOffset( - window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, - window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); - } -}; -/* Portions of the Selector class are derived from Jack Slocum’s DomQuery, - * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style - * license. Please see http://www.yui-ext.com/ for more information. */ - -var Selector = Class.create({ - initialize: function(expression) { - this.expression = expression.strip(); - this.compileMatcher(); - }, - - shouldUseXPath: function() { - if (!Prototype.BrowserFeatures.XPath) return false; - - var e = this.expression; - - // Safari 3 chokes on :*-of-type and :empty - if (Prototype.Browser.WebKit && - (e.include("-of-type") || e.include(":empty"))) - return false; - - // XPath can't do namespaced attributes, nor can it read - // the "checked" property from DOM nodes - if ((/(\[[\w-]*?:|:checked)/).test(this.expression)) - return false; - - return true; - }, - - compileMatcher: function() { - if (this.shouldUseXPath()) - return this.compileXPathMatcher(); - - var e = this.expression, ps = Selector.patterns, h = Selector.handlers, - c = Selector.criteria, le, p, m; - - if (Selector._cache[e]) { - this.matcher = Selector._cache[e]; - return; - } - - this.matcher = ["this.matcher = function(root) {", - "var r = root, h = Selector.handlers, c = false, n;"]; - - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : - new Template(c[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.matcher.push("return h.unique(n);\n}"); - eval(this.matcher.join('\n')); - Selector._cache[this.expression] = this.matcher; - }, - - compileXPathMatcher: function() { - var e = this.expression, ps = Selector.patterns, - x = Selector.xpath, le, m; - - if (Selector._cache[e]) { - this.xpath = Selector._cache[e]; return; - } - - this.matcher = ['.//*']; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - if (m = e.match(ps[i])) { - this.matcher.push(Object.isFunction(x[i]) ? x[i](m) : - new Template(x[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.xpath = this.matcher.join(''); - Selector._cache[this.expression] = this.xpath; - }, - - findElements: function(root) { - root = root || document; - if (this.xpath) return document._getElementsByXPath(this.xpath, root); - return this.matcher(root); - }, - - match: function(element) { - this.tokens = []; - - var e = this.expression, ps = Selector.patterns, as = Selector.assertions; - var le, p, m; - - while (e && le !== e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - // use the Selector.assertions methods unless the selector - // is too complex. - if (as[i]) { - this.tokens.push([i, Object.clone(m)]); - e = e.replace(m[0], ''); - } else { - // reluctantly do a document-wide search - // and look for a match in the array - return this.findElements(document).include(element); - } - } - } - } - - var match = true, name, matches; - for (var i = 0, token; token = this.tokens[i]; i++) { - name = token[0], matches = token[1]; - if (!Selector.assertions[name](element, matches)) { - match = false; break; - } - } - - return match; - }, - - toString: function() { - return this.expression; - }, - - inspect: function() { - return "#"; - } -}); - -Object.extend(Selector, { - _cache: { }, - - xpath: { - descendant: "//*", - child: "/*", - adjacent: "/following-sibling::*[1]", - laterSibling: '/following-sibling::*', - tagName: function(m) { - if (m[1] == '*') return ''; - return "[local-name()='" + m[1].toLowerCase() + - "' or local-name()='" + m[1].toUpperCase() + "']"; - }, - className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", - id: "[@id='#{1}']", - attrPresence: function(m) { - m[1] = m[1].toLowerCase(); - return new Template("[@#{1}]").evaluate(m); - }, - attr: function(m) { - m[1] = m[1].toLowerCase(); - m[3] = m[5] || m[6]; - return new Template(Selector.xpath.operators[m[2]]).evaluate(m); - }, - pseudo: function(m) { - var h = Selector.xpath.pseudos[m[1]]; - if (!h) return ''; - if (Object.isFunction(h)) return h(m); - return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); - }, - operators: { - '=': "[@#{1}='#{3}']", - '!=': "[@#{1}!='#{3}']", - '^=': "[starts-with(@#{1}, '#{3}')]", - '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", - '*=': "[contains(@#{1}, '#{3}')]", - '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", - '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" - }, - pseudos: { - 'first-child': '[not(preceding-sibling::*)]', - 'last-child': '[not(following-sibling::*)]', - 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', - 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]", - 'checked': "[@checked]", - 'disabled': "[@disabled]", - 'enabled': "[not(@disabled)]", - 'not': function(m) { - var e = m[6], p = Selector.patterns, - x = Selector.xpath, le, v; - - var exclusion = []; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in p) { - if (m = e.match(p[i])) { - v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m); - exclusion.push("(" + v.substring(1, v.length - 1) + ")"); - e = e.replace(m[0], ''); - break; - } - } - } - return "[not(" + exclusion.join(" and ") + ")]"; - }, - 'nth-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); - }, - 'nth-last-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); - }, - 'nth-of-type': function(m) { - return Selector.xpath.pseudos.nth("position() ", m); - }, - 'nth-last-of-type': function(m) { - return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); - }, - 'first-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); - }, - 'last-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); - }, - 'only-of-type': function(m) { - var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); - }, - nth: function(fragment, m) { - var mm, formula = m[6], predicate; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - if (mm = formula.match(/^(\d+)$/)) // digit only - return '[' + fragment + "= " + mm[1] + ']'; - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (mm[1] == "-") mm[1] = -1; - var a = mm[1] ? Number(mm[1]) : 1; - var b = mm[2] ? Number(mm[2]) : 0; - predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + - "((#{fragment} - #{b}) div #{a} >= 0)]"; - return new Template(predicate).evaluate({ - fragment: fragment, a: a, b: b }); - } - } - } - }, - - criteria: { - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', - className: 'n = h.className(n, r, "#{1}", c); c = false;', - id: 'n = h.id(n, r, "#{1}", c); c = false;', - attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;', - attr: function(m) { - m[3] = (m[5] || m[6]); - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m); - }, - pseudo: function(m) { - if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); - return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); - }, - descendant: 'c = "descendant";', - child: 'c = "child";', - adjacent: 'c = "adjacent";', - laterSibling: 'c = "laterSibling";' - }, - - patterns: { - // combinators must be listed first - // (and descendant needs to be last combinator) - laterSibling: /^\s*~\s*/, - child: /^\s*>\s*/, - adjacent: /^\s*\+\s*/, - descendant: /^\s/, - - // selectors follow - tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, - id: /^#([\w\-\*]+)(\b|$)/, - className: /^\.([\w\-\*]+)(\b|$)/, - pseudo: -/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/, - attrPresence: /^\[([\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ - }, - - // for Selector.match and Element#match - assertions: { - tagName: function(element, matches) { - return matches[1].toUpperCase() == element.tagName.toUpperCase(); - }, - - className: function(element, matches) { - return Element.hasClassName(element, matches[1]); - }, - - id: function(element, matches) { - return element.id === matches[1]; - }, - - attrPresence: function(element, matches) { - return Element.hasAttribute(element, matches[1]); - }, - - attr: function(element, matches) { - var nodeValue = Element.readAttribute(element, matches[1]); - return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); - } - }, - - handlers: { - // UTILITY FUNCTIONS - // joins two collections - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - a.push(node); - return a; - }, - - // marks an array of nodes for counting - mark: function(nodes) { - var _true = Prototype.emptyFunction; - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = _true; - return nodes; - }, - - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = undefined; - return nodes; - }, - - // mark each child node with its position (for nth calls) - // "ofType" flag indicates whether we're indexing for nth-of-type - // rather than nth-child - index: function(parentNode, reverse, ofType) { - parentNode._countedByPrototype = Prototype.emptyFunction; - if (reverse) { - for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { - var node = nodes[i]; - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - } else { - for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - }, - - // filters out duplicates and extends all nodes - unique: function(nodes) { - if (nodes.length == 0) return nodes; - var results = [], n; - for (var i = 0, l = nodes.length; i < l; i++) - if (!(n = nodes[i])._countedByPrototype) { - n._countedByPrototype = Prototype.emptyFunction; - results.push(Element.extend(n)); - } - return Selector.handlers.unmark(results); - }, - - // COMBINATOR FUNCTIONS - descendant: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName('*')); - return results; - }, - - child: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) { - for (var j = 0, child; child = node.childNodes[j]; j++) - if (child.nodeType == 1 && child.tagName != '!') results.push(child); - } - return results; - }, - - adjacent: function(nodes) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - var next = this.nextElementSibling(node); - if (next) results.push(next); - } - return results; - }, - - laterSibling: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, Element.nextSiblings(node)); - return results; - }, - - nextElementSibling: function(node) { - while (node = node.nextSibling) - if (node.nodeType == 1) return node; - return null; - }, - - previousElementSibling: function(node) { - while (node = node.previousSibling) - if (node.nodeType == 1) return node; - return null; - }, - - // TOKEN FUNCTIONS - tagName: function(nodes, root, tagName, combinator) { - var uTagName = tagName.toUpperCase(); - var results = [], h = Selector.handlers; - if (nodes) { - if (combinator) { - // fastlane for ordinary descendant combinators - if (combinator == "descendant") { - for (var i = 0, node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName(tagName)); - return results; - } else nodes = this[combinator](nodes); - if (tagName == "*") return nodes; - } - for (var i = 0, node; node = nodes[i]; i++) - if (node.tagName.toUpperCase() === uTagName) results.push(node); - return results; - } else return root.getElementsByTagName(tagName); - }, - - id: function(nodes, root, id, combinator) { - var targetNode = $(id), h = Selector.handlers; - if (!targetNode) return []; - if (!nodes && root == document) return [targetNode]; - if (nodes) { - if (combinator) { - if (combinator == 'child') { - for (var i = 0, node; node = nodes[i]; i++) - if (targetNode.parentNode == node) return [targetNode]; - } else if (combinator == 'descendant') { - for (var i = 0, node; node = nodes[i]; i++) - if (Element.descendantOf(targetNode, node)) return [targetNode]; - } else if (combinator == 'adjacent') { - for (var i = 0, node; node = nodes[i]; i++) - if (Selector.handlers.previousElementSibling(targetNode) == node) - return [targetNode]; - } else nodes = h[combinator](nodes); - } - for (var i = 0, node; node = nodes[i]; i++) - if (node == targetNode) return [targetNode]; - return []; - } - return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; - }, - - className: function(nodes, root, className, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - return Selector.handlers.byClassName(nodes, root, className); - }, - - byClassName: function(nodes, root, className) { - if (!nodes) nodes = Selector.handlers.descendant([root]); - var needle = ' ' + className + ' '; - for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { - nodeClassName = node.className; - if (nodeClassName.length == 0) continue; - if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) - results.push(node); - } - return results; - }, - - attrPresence: function(nodes, root, attr, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var results = []; - for (var i = 0, node; node = nodes[i]; i++) - if (Element.hasAttribute(node, attr)) results.push(node); - return results; - }, - - attr: function(nodes, root, attr, value, operator, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var handler = Selector.operators[operator], results = []; - for (var i = 0, node; node = nodes[i]; i++) { - var nodeValue = Element.readAttribute(node, attr); - if (nodeValue === null) continue; - if (handler(nodeValue, value)) results.push(node); - } - return results; - }, - - pseudo: function(nodes, name, value, root, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - if (!nodes) nodes = root.getElementsByTagName("*"); - return Selector.pseudos[name](nodes, value, root); - } - }, - - pseudos: { - 'first-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.previousElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'last-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.nextElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'only-child': function(nodes, value, root) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) - results.push(node); - return results; - }, - 'nth-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root); - }, - 'nth-last-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true); - }, - 'nth-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, false, true); - }, - 'nth-last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true, true); - }, - 'first-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, false, true); - }, - 'last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, true, true); - }, - 'only-of-type': function(nodes, formula, root) { - var p = Selector.pseudos; - return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); - }, - - // handles the an+b logic - getIndices: function(a, b, total) { - if (a == 0) return b > 0 ? [b] : []; - return $R(1, total).inject([], function(memo, i) { - if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); - return memo; - }); - }, - - // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type - nth: function(nodes, formula, root, reverse, ofType) { - if (nodes.length == 0) return []; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - var h = Selector.handlers, results = [], indexed = [], m; - h.mark(nodes); - for (var i = 0, node; node = nodes[i]; i++) { - if (!node.parentNode._countedByPrototype) { - h.index(node.parentNode, reverse, ofType); - indexed.push(node.parentNode); - } - } - if (formula.match(/^\d+$/)) { // just a number - formula = Number(formula); - for (var i = 0, node; node = nodes[i]; i++) - if (node.nodeIndex == formula) results.push(node); - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (m[1] == "-") m[1] = -1; - var a = m[1] ? Number(m[1]) : 1; - var b = m[2] ? Number(m[2]) : 0; - var indices = Selector.pseudos.getIndices(a, b, nodes.length); - for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { - for (var j = 0; j < l; j++) - if (node.nodeIndex == indices[j]) results.push(node); - } - } - h.unmark(nodes); - h.unmark(indexed); - return results; - }, - - 'empty': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - // IE treats comments as element nodes - if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue; - results.push(node); - } - return results; - }, - - 'not': function(nodes, selector, root) { - var h = Selector.handlers, selectorType, m; - var exclusions = new Selector(selector).findElements(root); - h.mark(exclusions); - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node._countedByPrototype) results.push(node); - h.unmark(exclusions); - return results; - }, - - 'enabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node.disabled) results.push(node); - return results; - }, - - 'disabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.disabled) results.push(node); - return results; - }, - - 'checked': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.checked) results.push(node); - return results; - } - }, - - operators: { - '=': function(nv, v) { return nv == v; }, - '!=': function(nv, v) { return nv != v; }, - '^=': function(nv, v) { return nv.startsWith(v); }, - '$=': function(nv, v) { return nv.endsWith(v); }, - '*=': function(nv, v) { return nv.include(v); }, - '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, - '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } - }, - - split: function(expression) { - var expressions = []; - expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { - expressions.push(m[1].strip()); - }); - return expressions; - }, - - matchElements: function(elements, expression) { - var matches = $$(expression), h = Selector.handlers; - h.mark(matches); - for (var i = 0, results = [], element; element = elements[i]; i++) - if (element._countedByPrototype) results.push(element); - h.unmark(matches); - return results; - }, - - findElement: function(elements, expression, index) { - if (Object.isNumber(expression)) { - index = expression; expression = false; - } - return Selector.matchElements(elements, expression || '*')[index || 0]; - }, - - findChildElements: function(element, expressions) { - expressions = Selector.split(expressions.join(',')); - var results = [], h = Selector.handlers; - for (var i = 0, l = expressions.length, selector; i < l; i++) { - selector = new Selector(expressions[i].strip()); - h.concat(results, selector.findElements(element)); - } - return (l > 1) ? h.unique(results) : results; - } -}); - -if (Prototype.Browser.IE) { - Object.extend(Selector.handlers, { - // IE returns comment nodes on getElementsByTagName("*"). - // Filter them out. - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - if (node.tagName !== "!") a.push(node); - return a; - }, - - // IE improperly serializes _countedByPrototype in (inner|outer)HTML. - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node.removeAttribute('_countedByPrototype'); - return nodes; - } - }); -} - -function $$() { - return Selector.findChildElements(document, $A(arguments)); -} -var Form = { - reset: function(form) { - $(form).reset(); - return form; - }, - - serializeElements: function(elements, options) { - if (typeof options != 'object') options = { hash: !!options }; - else if (Object.isUndefined(options.hash)) options.hash = true; - var key, value, submitted = false, submit = options.submit; - - var data = elements.inject({ }, function(result, element) { - if (!element.disabled && element.name) { - key = element.name; value = $(element).getValue(); - if (value != null && (element.type != 'submit' || (!submitted && - submit !== false && (!submit || key == submit) && (submitted = true)))) { - if (key in result) { - // a key is already present; construct an array of values - if (!Object.isArray(result[key])) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return options.hash ? data : Object.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, options) { - return Form.serializeElements(Form.getElements(form), options); - }, - - getElements: function(form) { - return $A($(form).getElementsByTagName('*')).inject([], - function(elements, child) { - if (Form.Element.Serializers[child.tagName.toLowerCase()]) - elements.push(Element.extend(child)); - return elements; - } - ); - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) return $A(inputs).map(Element.extend); - - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || (name && input.name != name)) - continue; - matchingInputs.push(Element.extend(input)); - } - - return matchingInputs; - }, - - disable: function(form) { - form = $(form); - Form.getElements(form).invoke('disable'); - return form; - }, - - enable: function(form) { - form = $(form); - Form.getElements(form).invoke('enable'); - return form; - }, - - findFirstElement: function(form) { - var elements = $(form).getElements().findAll(function(element) { - return 'hidden' != element.type && !element.disabled; - }); - var firstByIndex = elements.findAll(function(element) { - return element.hasAttribute('tabIndex') && element.tabIndex >= 0; - }).sortBy(function(element) { return element.tabIndex }).first(); - - return firstByIndex ? firstByIndex : elements.find(function(element) { - return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - }, - - request: function(form, options) { - form = $(form), options = Object.clone(options || { }); - - var params = options.parameters, action = form.readAttribute('action') || ''; - if (action.blank()) action = window.location.href; - options.parameters = form.serialize(true); - - if (params) { - if (Object.isString(params)) params = params.toQueryParams(); - Object.extend(options.parameters, params); - } - - if (form.hasAttribute('method') && !options.method) - options.method = form.method; - - return new Ajax.Request(action, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -Form.Element = { - focus: function(element) { - $(element).focus(); - return element; - }, - - select: function(element) { - $(element).select(); - return element; - } -}; - -Form.Element.Methods = { - serialize: function(element) { - element = $(element); - if (!element.disabled && element.name) { - var value = element.getValue(); - if (value != undefined) { - var pair = { }; - pair[element.name] = value; - return Object.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - setValue: function(element, value) { - element = $(element); - var method = element.tagName.toLowerCase(); - Form.Element.Serializers[method](element, value); - return element; - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - try { - element.focus(); - if (element.select && (element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type))) - element.select(); - } catch (e) { } - return element; - }, - - disable: function(element) { - element = $(element); - element.blur(); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.disabled = false; - return element; - } -}; - -/*--------------------------------------------------------------------------*/ - -var Field = Form.Element; -var $F = Form.Element.Methods.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element, value) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element, value); - default: - return Form.Element.Serializers.textarea(element, value); - } - }, - - inputSelector: function(element, value) { - if (Object.isUndefined(value)) return element.checked ? element.value : null; - else element.checked = !!value; - }, - - textarea: function(element, value) { - if (Object.isUndefined(value)) return element.value; - else element.value = value; - }, - - select: function(element, index) { - if (Object.isUndefined(index)) - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - else { - var opt, value, single = !Object.isArray(index); - for (var i = 0, length = element.length; i < length; i++) { - opt = element.options[i]; - value = this.optionValue(opt); - if (single) { - if (value == index) { - opt.selected = true; - return; - } - } - else opt.selected = index.include(value); - } - } - }, - - selectOne: function(element) { - var index = element.selectedIndex; - return index >= 0 ? this.optionValue(element.options[index]) : null; - }, - - selectMany: function(element) { - var values, length = element.length; - if (!length) return null; - - for (var i = 0, values = []; i < length; i++) { - var opt = element.options[i]; - if (opt.selected) values.push(this.optionValue(opt)); - } - return values; - }, - - optionValue: function(opt) { - // extend element because hasAttribute may not be native - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -}; - -/*--------------------------------------------------------------------------*/ - -Abstract.TimedObserver = Class.create(PeriodicalExecuter, { - initialize: function($super, element, frequency, callback) { - $super(callback, frequency); - this.element = $(element); - this.lastValue = this.getValue(); - }, - - execute: function() { - var value = this.getValue(); - if (Object.isString(this.lastValue) && Object.isString(value) ? - this.lastValue != value : String(this.lastValue) != String(value)) { - this.callback(this.element, value); - this.lastValue = value; - } - } -}); - -Form.Element.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = Class.create({ - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - Form.getElements(this.element).each(this.registerCallback, this); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - default: - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -}); - -Form.Element.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) var Event = { }; - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - KEY_HOME: 36, - KEY_END: 35, - KEY_PAGEUP: 33, - KEY_PAGEDOWN: 34, - KEY_INSERT: 45, - - cache: { }, - - relatedTarget: function(event) { - var element; - switch(event.type) { - case 'mouseover': element = event.fromElement; break; - case 'mouseout': element = event.toElement; break; - default: return null; - } - return Element.extend(element); - } -}); - -Event.Methods = (function() { - var isButton; - - if (Prototype.Browser.IE) { - var buttonMap = { 0: 1, 1: 4, 2: 2 }; - isButton = function(event, code) { - return event.button == buttonMap[code]; - }; - - } else if (Prototype.Browser.WebKit) { - isButton = function(event, code) { - switch (code) { - case 0: return event.which == 1 && !event.metaKey; - case 1: return event.which == 1 && event.metaKey; - default: return false; - } - }; - - } else { - isButton = function(event, code) { - return event.which ? (event.which === code + 1) : (event.button === code); - }; - } - - return { - isLeftClick: function(event) { return isButton(event, 0) }, - isMiddleClick: function(event) { return isButton(event, 1) }, - isRightClick: function(event) { return isButton(event, 2) }, - - element: function(event) { - var node = Event.extend(event).target; - return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node); - }, - - findElement: function(event, expression) { - var element = Event.element(event); - if (!expression) return element; - var elements = [element].concat(element.ancestors()); - return Selector.findElement(elements, expression, 0); - }, - - pointer: function(event) { - return { - x: event.pageX || (event.clientX + - (document.documentElement.scrollLeft || document.body.scrollLeft)), - y: event.pageY || (event.clientY + - (document.documentElement.scrollTop || document.body.scrollTop)) - }; - }, - - pointerX: function(event) { return Event.pointer(event).x }, - pointerY: function(event) { return Event.pointer(event).y }, - - stop: function(event) { - Event.extend(event); - event.preventDefault(); - event.stopPropagation(); - event.stopped = true; - } - }; -})(); - -Event.extend = (function() { - var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { - m[name] = Event.Methods[name].methodize(); - return m; - }); - - if (Prototype.Browser.IE) { - Object.extend(methods, { - stopPropagation: function() { this.cancelBubble = true }, - preventDefault: function() { this.returnValue = false }, - inspect: function() { return "[object Event]" } - }); - - return function(event) { - if (!event) return false; - if (event._extendedByPrototype) return event; - - event._extendedByPrototype = Prototype.emptyFunction; - var pointer = Event.pointer(event); - Object.extend(event, { - target: event.srcElement, - relatedTarget: Event.relatedTarget(event), - pageX: pointer.x, - pageY: pointer.y - }); - return Object.extend(event, methods); - }; - - } else { - Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__; - Object.extend(Event.prototype, methods); - return Prototype.K; - } -})(); - -Object.extend(Event, (function() { - var cache = Event.cache; - - function getEventID(element) { - if (element._prototypeEventID) return element._prototypeEventID[0]; - arguments.callee.id = arguments.callee.id || 1; - return element._prototypeEventID = [++arguments.callee.id]; - } - - function getDOMEventName(eventName) { - if (eventName && eventName.include(':')) return "dataavailable"; - return eventName; - } - - function getCacheForID(id) { - return cache[id] = cache[id] || { }; - } - - function getWrappersForEventName(id, eventName) { - var c = getCacheForID(id); - return c[eventName] = c[eventName] || []; - } - - function createWrapper(element, eventName, handler) { - var id = getEventID(element); - var c = getWrappersForEventName(id, eventName); - if (c.pluck("handler").include(handler)) return false; - - var wrapper = function(event) { - if (!Event || !Event.extend || - (event.eventName && event.eventName != eventName)) - return false; - - Event.extend(event); - handler.call(element, event); - }; - - wrapper.handler = handler; - c.push(wrapper); - return wrapper; - } - - function findWrapper(id, eventName, handler) { - var c = getWrappersForEventName(id, eventName); - return c.find(function(wrapper) { return wrapper.handler == handler }); - } - - function destroyWrapper(id, eventName, handler) { - var c = getCacheForID(id); - if (!c[eventName]) return false; - c[eventName] = c[eventName].without(findWrapper(id, eventName, handler)); - } - - function destroyCache() { - for (var id in cache) - for (var eventName in cache[id]) - cache[id][eventName] = null; - } - - if (window.attachEvent) { - window.attachEvent("onunload", destroyCache); - } - - return { - observe: function(element, eventName, handler) { - element = $(element); - var name = getDOMEventName(eventName); - - var wrapper = createWrapper(element, eventName, handler); - if (!wrapper) return element; - - if (element.addEventListener) { - element.addEventListener(name, wrapper, false); - } else { - element.attachEvent("on" + name, wrapper); - } - - return element; - }, - - stopObserving: function(element, eventName, handler) { - element = $(element); - var id = getEventID(element), name = getDOMEventName(eventName); - - if (!handler && eventName) { - getWrappersForEventName(id, eventName).each(function(wrapper) { - element.stopObserving(eventName, wrapper.handler); - }); - return element; - - } else if (!eventName) { - Object.keys(getCacheForID(id)).each(function(eventName) { - element.stopObserving(eventName); - }); - return element; - } - - var wrapper = findWrapper(id, eventName, handler); - if (!wrapper) return element; - - if (element.removeEventListener) { - element.removeEventListener(name, wrapper, false); - } else { - element.detachEvent("on" + name, wrapper); - } - - destroyWrapper(id, eventName, handler); - - return element; - }, - - fire: function(element, eventName, memo) { - element = $(element); - if (element == document && document.createEvent && !element.dispatchEvent) - element = document.documentElement; - - var event; - if (document.createEvent) { - event = document.createEvent("HTMLEvents"); - event.initEvent("dataavailable", true, true); - } else { - event = document.createEventObject(); - event.eventType = "ondataavailable"; - } - - event.eventName = eventName; - event.memo = memo || { }; - - if (document.createEvent) { - element.dispatchEvent(event); - } else { - element.fireEvent(event.eventType, event); - } - - return Event.extend(event); - } - }; -})()); - -Object.extend(Event, Event.Methods); - -Element.addMethods({ - fire: Event.fire, - observe: Event.observe, - stopObserving: Event.stopObserving -}); - -Object.extend(document, { - fire: Element.Methods.fire.methodize(), - observe: Element.Methods.observe.methodize(), - stopObserving: Element.Methods.stopObserving.methodize(), - loaded: false -}); - -(function() { - /* Support for the DOMContentLoaded event is based on work by Dan Webb, - Matthias Miller, Dean Edwards and John Resig. */ - - var timer; - - function fireContentLoadedEvent() { - if (document.loaded) return; - if (timer) window.clearInterval(timer); - document.fire("dom:loaded"); - document.loaded = true; - } - - if (document.addEventListener) { - if (Prototype.Browser.WebKit) { - timer = window.setInterval(function() { - if (/loaded|complete/.test(document.readyState)) - fireContentLoadedEvent(); - }, 0); - - Event.observe(window, "load", fireContentLoadedEvent); - - } else { - document.addEventListener("DOMContentLoaded", - fireContentLoadedEvent, false); - } - - } else { - document.write(" - - - - - - - - - - - - - - - - - -
- - - -
- -
- Portfolio 01 -
Cras Ac Nisl Vel Leo Accumsan
-

Mauris imperdiet dictum erat quis gravida phasellus ac pulvinar justo.

- -
- -
- Portfolio 02 -
Suspendisse Eu Iaculis Tellus
-

Nulla augue mi, posuere vehicula euismod id, gravida vitae massa.

- -
- -
-
- Portfolio 03 -
Donec Mollis Volutpat Erat
-

Aliquam rutrum vehicula turpis sed erat tortor. Validate XHTML & CSS.

- -
- -
- Portfolio 04 -
Nullam Volutpat Elit Nunc Lacinia
-

Integer venenatis pharetra magna vitae quis mauris elementum.

- -
-
- -
-
- -
-
-
-
- - - - \ No newline at end of file diff --git a/Website/LOC.Website.Web/Controllers/PetsController.cs b/Website/LOC.Website.Web/Controllers/PetsController.cs index dad43482d..6cf868c76 100644 --- a/Website/LOC.Website.Web/Controllers/PetsController.cs +++ b/Website/LOC.Website.Web/Controllers/PetsController.cs @@ -6,14 +6,17 @@ using Core.Model.Server; using Core.Tokens.Client; using Newtonsoft.Json; + using LOC.Website.Common; public class PetsController : Controller { private readonly IPetAdministrator _petAdministrator; + private readonly ILogger _logger; - public PetsController(IPetAdministrator petAdministrator) + public PetsController(IPetAdministrator petAdministrator, ILogger logger) { _petAdministrator = petAdministrator; + _logger = logger; } [HttpPost] @@ -23,6 +26,13 @@ return Content(json, "application/json"); } + [HttpPost] + public ContentResult GetBulkPets(BulkConfig bulkConfig) + { + var json = JsonConvert.SerializeObject(_petAdministrator.GetBulkPets(bulkConfig.Start, bulkConfig.Count)); + return Content(json, "application/json"); + } + [HttpPost] public ContentResult GetPetExtras(List petExtras) { diff --git a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml index 360c78f15..1b821a3b2 100644 --- a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml +++ b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml @@ -1,6 +1,7 @@  + @@ -16,8 +17,10 @@ - + + + @@ -25,40 +28,42 @@ + + - + - + - + - + + - + - - - + + @@ -69,33 +74,32 @@ - + + - - - + + - - - + + - - + + @@ -103,40 +107,42 @@ - - - + + - + - + + - + - + - + + - + + @@ -148,80 +154,72 @@ - - - - - + - - - + - - - + + + - + - - + - - + + - + - - + + - - + + - + - - - - + + + @@ -229,47 +227,50 @@ - + - + + - - + + + - - + + - + - - + + - - + + - + + + - @@ -282,24 +283,19 @@ - - + - - - - @@ -307,16 +303,16 @@ - + + - @@ -325,7 +321,9 @@ + + @@ -336,21 +334,22 @@ - - + - + + + @@ -358,6 +357,8 @@ + + @@ -365,12 +366,11 @@ + - - @@ -378,60 +378,65 @@ + + - + + - - - - + - - + + - + - + + + + + + - - + + @@ -441,200 +446,169 @@ - + - - + - - - + - + - - + + - + - + - - + + - - + - - + - + - + - - + + - + - - + + - - + + - + + + - - - - - - - - - - + + - - - - - - + + - - + + - - + - - - - - + + - - - - - - - + + - - - + + - - - + - - - + + - - - - + + - @@ -645,157 +619,113 @@ + - - + - - - + - - + - - - - - - - - + - + + + - - - + + - - - - + + + - - + - - + - - + - - - - - - + - - - - + + + - - - - + - - - + - - - - - - - + + - - - - - - + - - + - - + - - - - - - - + - - - - + + + - @@ -806,40 +736,41 @@ - + - - + + - - - + + - + + + + - @@ -849,6 +780,7 @@ + @@ -859,21 +791,21 @@ - - + + - - + + @@ -881,7 +813,7 @@ - + @@ -892,164 +824,161 @@ - - + + - + + - + + - + - - + + - - + - - + - + + + + + + - - + - - + - + - - + - - - + - + - - + + - + - + - + - - - + - - + - + - + - - + + - + - - + + - - + + - + \ No newline at end of file diff --git a/Website/LOC.Website.Web/LOC.Website.Web.csproj b/Website/LOC.Website.Web/LOC.Website.Web.csproj index 98e3e0776..fa49ff7d8 100644 --- a/Website/LOC.Website.Web/LOC.Website.Web.csproj +++ b/Website/LOC.Website.Web/LOC.Website.Web.csproj @@ -56,9 +56,6 @@ ..\packages\structuremap.2.6.4.1\lib\net40\StructureMap.dll
- - True - @@ -69,6 +66,7 @@ + @@ -98,6 +96,7 @@ + @@ -184,84 +183,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index ad5303fcc..563cf8165 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ