diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index 25c4be6ac..06f154806 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -66,6 +66,7 @@ + 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 c1e19b5f8..27c94de9e 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -56,7 +56,7 @@ public class MotdManager implements Listener, Runnable // Add in default MOTD listing to database List lines = new ArrayList(); - lines.add(" §d§lMaster Builders§f - §d§lWizards§f - §d§lGravity"); + lines.add("§f§lNEW: §a§lMaster Builders§f - §a§lWizards§f - §a§lGravity"); //lines.add(" §d§lRank Sale §a§l40% Off"); updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines); 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 790cae05c..2f9baceb2 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -8,14 +8,16 @@ import org.bukkit.entity.Player; public enum Rank { + LT("LT", ChatColor.DARK_RED), OWNER("Owner", ChatColor.DARK_RED), DEVELOPER("Dev", ChatColor.RED), ADMIN("Admin", ChatColor.RED), SNR_MODERATOR("Sr.Mod", ChatColor.GOLD), MODERATOR("Mod", ChatColor.GOLD), - HELPER("Helper", ChatColor.DARK_AQUA), - MAPDEV("Builder", ChatColor.BLUE), + HELPER("Trainee", ChatColor.DARK_AQUA), MAPLEAD("MapLead", ChatColor.DARK_PURPLE), + MAPDEV("Builder", ChatColor.BLUE), + EVENT("Event", ChatColor.WHITE), diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/FileUtil.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/FileUtil.java index dcba90040..61a9f3ad5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/FileUtil.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/FileUtil.java @@ -12,7 +12,11 @@ public class FileUtil public static void DeleteFolder(File folder) { if (!folder.exists()) + { + System.out.println("Delete target does not exist: " + folder); return; + } + File[] files = folder.listFiles(); 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 bf726be24..d87d16fa5 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 @@ -7,9 +7,14 @@ import java.util.List; 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.Navigation; +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 org.bukkit.Bukkit; @@ -76,6 +81,47 @@ public class UtilEnt leashed.setLeashHolder(holder); } + + public static void addLookAtPlayerAI(Entity entity, float dist) + { + if (((CraftEntity) entity).getHandle() instanceof EntityInsentient) + { + addAI(entity, 7, new PathfinderGoalLookAtPlayer(((EntityInsentient) ((CraftEntity) entity).getHandle()), EntityHuman.class, dist)); + addAI(entity, 8, new PathfinderGoalRandomLookaround(((EntityInsentient) ((CraftEntity) entity).getHandle()))); + } + } + + public static void addAI(Entity entity, int value, PathfinderGoal ai) + { + if (((CraftEntity) entity).getHandle() instanceof EntityInsentient) + { + EntityInsentient ei = ((EntityInsentient) ((CraftEntity) entity).getHandle()); + + if (_goalSelector == null) + { + try + { + _goalSelector = EntityInsentient.class.getDeclaredField("goalSelector"); + } + catch (NoSuchFieldException e) + { + e.printStackTrace(); + return; + } + _goalSelector.setAccessible(true); + } + + try + { + ((PathfinderGoalSelector) _goalSelector.get(ei)).a(value, ai); + } + catch (IllegalAccessException e) + { + e.printStackTrace(); + } + } + + } public static void Vegetate(Entity entity) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java index ed2b39f8c..15a286157 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java @@ -98,8 +98,8 @@ public class UtilTime if (type == TimeUnit.DAYS) text = (num = UtilMath.trim(trim, time / 86400000d)) + " Day"; else if (type == TimeUnit.HOURS) text = (num = UtilMath.trim(trim, time / 3600000d)) + " Hour"; else if (type == TimeUnit.MINUTES) text = (num = UtilMath.trim(trim, time / 60000d)) + " Minute"; - else if (type == TimeUnit.SECONDS) text = (num = UtilMath.trim(trim, time / 1000d)) + " Second"; - else text = (num = UtilMath.trim(trim, time)) + " Millisecond"; + else if (type == TimeUnit.SECONDS) text = (int) (num = (int) UtilMath.trim(0, time / 1000d)) + " Second"; + else text = (int) (num = (int) UtilMath.trim(0, time)) + " Millisecond"; } if (num != 1) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java index a0998c60d..db1244267 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java @@ -103,17 +103,17 @@ public abstract class MiniPlugin implements Listener System.out.println(F.main(_moduleName, message)); } - protected void runAsync(Runnable runnable) + public void runAsync(Runnable runnable) { _plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, runnable); } - protected void runSync(Runnable runnable) + public void runSync(Runnable runnable) { _plugin.getServer().getScheduler().runTask(_plugin, runnable); } - protected void runSyncLater(Runnable runnable, long delay) + public void runSyncLater(Runnable runnable, long delay) { _plugin.getServer().getScheduler().runTaskLater(_plugin, runnable, delay); } 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 7bf400dd2..8a7efe8fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java @@ -52,8 +52,14 @@ public class UpdateRank extends CommandBase final Rank rank = tempRank; - if (rank == Rank.YOUTUBE || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR) + 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) { + if (rank == Rank.ADMIN && !Plugin.hasRank(caller, Rank.LT)) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Insufficient privileges!")); + return; + } + Plugin.getRepository().matchPlayerName(new Callback>() { public void run(List matches) 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 5d45845fe..b2fbd8368 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -38,7 +38,7 @@ public class AccountRepository extends RepositoryBase private static String UPDATE_ACCOUNT_RANK_DONOR_PERM = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=true WHERE uuid = ?;"; private static String UPDATE_ACCOUNT_NULL_RANK = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=?, rankExpire=? WHERE uuid = ? AND rank IS NULL;"; - private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ?;"; + private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ? ORDER BY lastLogin DESC;"; private String _webAddress; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 3c6d242b2..c51dc9972 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -95,7 +95,7 @@ public enum Achievement WIZARDS_WINS("Supreme Wizard", 600, new String[]{"Wizards.Wins"}, new String[]{"Win 50 games of Wizards"}, - new int[]{10}, + new int[]{50}, AchievementCategory.WIZARDS), //Smash Mobs @@ -191,6 +191,13 @@ public enum Achievement new int[]{1}, AchievementCategory.DRAW_MY_THING), + // Master Builders + MASTER_BUILDER_WINS("Master Builder", 1000, + new String[]{"Master Builders.Wins"}, + new String[]{"Win 30 games of Master Builders"}, + new int[]{30}, + AchievementCategory.MASTER_BUILDERS), + //Castle Siege CASTLE_SIEGE_WINS("FOR THE KING!", 600, new String[]{"Castle Siege.ForTheKing"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 7f57f711c..4a8be498d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -12,136 +12,113 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; -/** - * Created by Shaun on 8/21/2014. - * Edited by Chris on 9/13/2059. - */ public enum AchievementCategory { GLOBAL("Global", null, - new String[] { "GemsEarned", null, "GamesPlayed", "TimeInGame" }, - new String[] { "Gems Earned", null, "Games Played", "Time In Game" }, + new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME }, Material.EMERALD, 0, GameCategory.GLOBAL, null), //Survival BRIDGES("The Bridges", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.IRON_PICKAXE, 0, GameCategory.SURVIVAL, "Destructor Kit"), SURVIVAL_GAMES("Survival Games", null, - new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, - new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, - Material.IRON_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"), + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + Material.DIAMOND_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"), + + MINE_STRIKE("MineStrike", null, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + Material.TNT, 0, GameCategory.CLASSICS, null), + + WIZARDS("Wizards", null, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"), UHC("Ultra Hardcore", null, - new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, - new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"), - - WIZARDS("Wizards", null, - new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, - new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, - Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"), - - MINE_STRIKE("MineStrike", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, - Material.TNT, 0, GameCategory.CLASSICS, null), //Classics SMASH_MOBS("Super Smash Mobs", null, - new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, - new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.SKULL_ITEM, 4, GameCategory.CLASSICS, "Sheep Kit"), BLOCK_HUNT("Block Hunt", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.GRASS, 0, GameCategory.CLASSICS, null), - + + MASTER_BUILDERS("Master Builders", null, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED }, + Material.WOOD, 0, GameCategory.CLASSICS, null), + DRAW_MY_THING("Draw My Thing", null, - new String[] {"Wins", "Losses", "GemsEarned"}, - new String[] {"Wins", "Losses", "GemsEarned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED }, Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, null), CASTLE_SIEGE("Castle Siege", null, - new String[] {"Wins", "Losses", "Kills as Defenders", "Deaths as Defenders", "Kills as Undead", "Deaths as Undead", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills as Defenders", "Deaths as Defenders", "Kills as Undead", "Deaths as Undead", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"), + new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED }, Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null), //Champions CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"), //Arcade DRAGONS("Dragons", null, - new String[] {"Wins", "Losses", "GemsEarned"}, - new String[] {"Wins", "Losses", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED }, Material.ENDER_STONE, 0, GameCategory.ARCADE, null), DRAGON_ESCAPE("Dragon Escape", null, - new String[] {"Wins", "Losses", "GemsEarned"}, - new String[] {"Wins", "Losses", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED_GAME, StatDisplay.GEMS_EARNED }, Material.DRAGON_EGG, 0, GameCategory.ARCADE, null), SHEEP_QUEST("Sheep Quest", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.WOOL, 0, GameCategory.ARCADE, null), SNEAKY_ASSASSINS("Sneaky Assassins", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.INK_SACK, 0, GameCategory.ARCADE, null), ONE_IN_THE_QUIVER("One in the Quiver", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.BOW, 0, GameCategory.ARCADE, null), SUPER_PAINTBALL("Super Paintball", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.ENDER_PEARL, 0, GameCategory.ARCADE, null), TURF_WARS("Turf Wars", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.HARD_CLAY, 14, GameCategory.ARCADE, null), RUNNER("Runner", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null), SPLEEF("Super Spleef", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.IRON_SPADE, 0, GameCategory.ARCADE, null), DEATH_TAG("Death Tag", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.SKULL_ITEM, 0, GameCategory.ARCADE, null), SNAKE("Snake", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.WOOL, 4, GameCategory.ARCADE, null), BACON_BRAWL("Bacon Brawl", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.PORK, 0, GameCategory.ARCADE, null), MICRO_BATTLE("Micro Battle", null, - new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, - new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.LOSSES, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.LAVA, 0, GameCategory.ARCADE, null), ; @@ -149,14 +126,13 @@ public enum AchievementCategory private String _name; private String[] _statsToPull; - private String[] _statsToDisplay; - private String[] _friendlyStatNames; + private StatDisplay[] _statDisplays; private Material _icon; private GameCategory _gameCategory; private byte _iconData; private String _kitReward; - AchievementCategory(String name, String[] statsToPull, String[] statsToDisplay, String[] friendlyStatNames, Material icon, int iconData, GameCategory gameCategory, String kitReward) + AchievementCategory(String name, String[] statsToPull, StatDisplay[] statDisplays, Material icon, int iconData, GameCategory gameCategory, String kitReward) { _name = name; @@ -164,9 +140,7 @@ public enum AchievementCategory _statsToPull = statsToPull; else _statsToPull = new String[] {name}; - - _statsToDisplay = statsToDisplay; - _friendlyStatNames = friendlyStatNames; + _statDisplays = statDisplays; _icon = icon; _iconData = (byte)iconData; _gameCategory = gameCategory; @@ -193,9 +167,9 @@ public enum AchievementCategory return _statsToPull; } - public String[] getStatsToDisplay() + public StatDisplay[] getStatsToDisplay() { - return _statsToDisplay; + return _statDisplays; } public byte getIconData() @@ -208,11 +182,6 @@ public enum AchievementCategory return _gameCategory; } - public String[] getFriendlyStatNames() - { - return _friendlyStatNames; - } - public void addStats(CoreClientManager clientManager, StatsManager statsManager, List lore, Player player, Player target) { addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, target); @@ -221,29 +190,32 @@ public enum AchievementCategory public void addStats(CoreClientManager clientManager, StatsManager statsManager, List lore, int max, Player player, Player target) { PlayerStats stats = statsManager.Get(target); - for (int i = 0; i < _statsToDisplay.length && i < max; i++) + for (int i = 0; i < _statDisplays.length && i < max; i++) { // If the stat is null then just display a blank line instead - if (_statsToDisplay[i] == null || _friendlyStatNames[i] == null) + if (_statDisplays[i] == null) { lore.add(" "); continue; } + String displayName = _statDisplays[i].getDisplayName(); + // Skip showing Losses, Kills, Deaths for other players - if (!clientManager.Get(player).GetRank().Has(Rank.MODERATOR) && !player.equals(target) && (_statsToDisplay[i].contains("Losses") || _statsToDisplay[i].contains("Kills") || _statsToDisplay[i].contains("Deaths") || _statsToDisplay[i].equals("Time In Game") || _statsToDisplay.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; for (String statToPull : _statsToPull) - statNumber += stats.getStat(statToPull + "." + _statsToDisplay[i]); + for (String statName : _statDisplays[i].getStats()) + statNumber += stats.getStat(statToPull + "." + statName); String statString = C.cWhite + statNumber; // Need to display special for time - if (_statsToDisplay[i].equalsIgnoreCase("TimeInGame")) + if (displayName.equalsIgnoreCase("Time In Game")) statString = C.cWhite + UtilTime.convertString(statNumber * 1000L, 0, UtilTime.TimeUnit.FIT); - lore.add(C.cYellow + _friendlyStatNames[i] + ": " + statString); + lore.add(C.cYellow + displayName + ": " + statString); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java new file mode 100644 index 000000000..23d65027c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java @@ -0,0 +1,44 @@ +package mineplex.core.achievement; + +/** + * The purpose of extracting stats to this class is so we can display stats that are a combination + * of different stat values. For example, since we don't have a specific stat for games played of a game, + * we can use this class to display the stat "Games Played" that sums up "Wins" and "Losses" + * See: StatDisplay.GAMES_PLAYED_GAME + */ +public class StatDisplay +{ + public String _displayName; + public String[] _stats; + + public StatDisplay(String stat) + { + _displayName = stat; + _stats = new String[] { stat }; + } + + public StatDisplay(String displayName, String... stats) + { + _displayName = displayName; + _stats = stats; + } + + public String getDisplayName() + { + return _displayName; + } + + public String[] getStats() + { + return _stats; + } + + public static final StatDisplay WINS = new StatDisplay("Wins"); + public static final StatDisplay LOSSES = new StatDisplay("Losses"); + public static final StatDisplay KILLS = new StatDisplay("Kills"); + public static final StatDisplay DEATHS = new StatDisplay("Deaths"); + public static final StatDisplay GEMS_EARNED = new StatDisplay("Gems Earned", "GemsEarned"); + public static final StatDisplay TIME_IN_GAME = new StatDisplay("Time In Game", "TimeInGame"); + public static final StatDisplay GAMES_PLAYED_GAME = new StatDisplay("Games Played", "Wins", "Losses"); + +} 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 1ad16a15f..eaf02d841 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 @@ -17,13 +17,11 @@ import mineplex.core.achievement.ui.button.ArcadeButton; import mineplex.core.achievement.ui.button.CategoryButton; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemLayout; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; import mineplex.core.stats.StatsManager; -/** - * Created by Shaun on 8/21/2014. - */ public class AchievementMainPage extends ShopPageBase { protected Player _target; @@ -31,7 +29,7 @@ public class AchievementMainPage extends ShopPageBase pageLayout = new ItemLayout( + "XXXXOXXXX", + "XOXOXOXOX", + "XOXOXOXOX", + "XOXOXOXOX").getItemSlots(); + int listSlot = 0; for (AchievementCategory category : AchievementCategory.values()) { if (category.getGameCategory() == AchievementCategory.GameCategory.ARCADE) continue; - CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), getClientManager(), _target); + CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), + getClientManager(), _target); ArrayList lore = new ArrayList(); lore.add(" "); - category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 5 : 2, getPlayer(), _target); + category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 5 : 2, + getPlayer(), _target); lore.add(" "); addAchievements(category, lore, 9); lore.add(" "); lore.add(ChatColor.RESET + "Click for more details!"); - int slot; - switch(category.getGameCategory()) - { - case GLOBAL: - slot = globalSlot; - break; - default: - slot = normalSlot; - normalSlot += 2; - } - - if (normalSlot == 28) - normalSlot = 36; - - ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), lore.toArray(new String[0]), 1, false, false); - addButton(slot, shopItem, button); + ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), + lore.toArray(new String[0]), 1, false, false); + addButton(pageLayout.get(listSlot++), shopItem, button); } - addArcadeButton(); + + addArcadeButton(pageLayout.get(listSlot++)); } - protected void addArcadeButton() + protected void addArcadeButton(int slot) { ArcadeButton button = new ArcadeButton(getShop(), getPlugin(), _statsManager, getDonationManager(), getClientManager(), _target); ShopItem shopItem = new ShopItem(Material.BOW, (byte) 0, C.Bold + "Arcade Games", new String[] {" ", ChatColor.RESET + "Click for more!"}, 1, false, false); - addButton(44, shopItem, button); + addButton(slot, shopItem, button); } protected void addAchievements(AchievementCategory category, List lore, int max) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/ArcadeMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/ArcadeMainPage.java index 5ffbe3e88..da96e2cc1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/ArcadeMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/ArcadeMainPage.java @@ -19,9 +19,6 @@ import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.stats.StatsManager; -/** - * Created by Shaun on 8/25/2014. - */ public class ArcadeMainPage extends AchievementMainPage { public ArcadeMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Player target) @@ -32,7 +29,7 @@ public class ArcadeMainPage extends AchievementMainPage @Override protected void buildPage() { - int slot = 10; + int slot = 9; for (AchievementCategory category : AchievementCategory.values()) { @@ -49,13 +46,10 @@ public class ArcadeMainPage extends AchievementMainPage lore.add(" "); lore.add(ChatColor.RESET + "Click for more details!"); - if (slot == 18 || slot == 27 || slot == 36) - slot++; - ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), lore.toArray(new String[0]), 1, false, false); addButton(slot, shopItem, button); - slot += 2; + slot += ((slot + 1) % 9 == 0) ? 1 : 2; } addBackButton(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index c67a3286a..3fec3bf24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilTime; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -198,6 +199,30 @@ 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; + + // Prevent silenced players from using signs + if (SilenceCheck(event.getPlayer())) + { + event.setCancelled(true); + return; + } + + for (int i = 0; i < event.getLines().length; i++) + { + String line = event.getLine(i); + if (line != null && line.length() > 0) + { + String filteredLine = getFilteredMessage(event.getPlayer(), line); + if (filteredLine != null) + event.setLine(i, filteredLine); + } + } + } @EventHandler(priority = EventPriority.HIGHEST) public void filterChat(AsyncPlayerChatEvent event) @@ -224,7 +249,7 @@ public class Chat extends MiniPlugin originalMessage = originalMessage.replaceAll("[^\\x00-\\x7F]", "").trim(); final String filterType = "moderate"; final String displayName = player.getPlayerListName(); - + JSONObject message = buildJsonChatObject(filterType, displayName, playerName, originalMessage, _serverName, 1); String response = getResponseFromCleanSpeak(message, filterType); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index b8b2bf46b..fcc110d79 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -16,6 +16,9 @@ import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; +import mineplex.core.donation.command.CoinCommand; +import mineplex.core.donation.command.GemCommand; +import mineplex.core.donation.command.GoldCommand; import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/CoinCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CoinCommand.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/CoinCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/donation/command/CoinCommand.java index 3b6620451..bff145333 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/CoinCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CoinCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.donation; +package mineplex.core.donation.command; import java.util.UUID; @@ -11,6 +11,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; public class CoinCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/GemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/GemCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java index 302d7b2d2..5f28ce5e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/GemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.donation; +package mineplex.core.donation.command; import java.util.UUID; @@ -10,6 +10,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; public class GemCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/GoldCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/GoldCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java index 384b0b997..28a435e02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/GoldCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.donation; +package mineplex.core.donation.command; import java.util.UUID; @@ -11,6 +11,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; public class GoldCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java index 29c79adb3..458ad6400 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java @@ -1,9 +1,11 @@ package mineplex.core.give; +import java.util.HashMap; import java.util.LinkedList; import java.util.Map.Entry; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; @@ -43,13 +45,16 @@ public class Give extends MiniPlugin help(player); else if (args.length == 1) - give(player, player.getName(), args[0], "1"); + give(player, player.getName(), args[0], "1", ""); else if (args.length == 2) - give(player, args[0], args[1], "1"); + give(player, args[0], args[1], "1", ""); + else if (args.length == 3) + give(player, args[0], args[1], args[2], ""); + else - give(player, args[0], args[1], args[2]); + give(player, args[0], args[1], args[2], args[3]); } public void help(Player player) @@ -57,7 +62,7 @@ public class Give extends MiniPlugin UtilPlayer.message(player, F.main("Give", "Commands List;")); } - public void give(Player player, String target, String itemNames, String amount) + public void give(Player player, String target, String itemNames, String amount, String enchants) { //Item LinkedList> itemList = new LinkedList>(); @@ -97,7 +102,25 @@ public class Give extends MiniPlugin { UtilPlayer.message(player, F.main("Give", "Invalid Amount [" + amount + "]. Defaulting to [1].")); } - + + //Enchants + HashMap enchs = new HashMap(); + if (enchants.length() > 0) + { + for (String cur : enchants.split(",")) + { + try + { + String[] tokens = cur.split(":"); + enchs.put(Enchantment.getByName(tokens[0]), Integer.parseInt(tokens[1])); + } + catch (Exception e) + { + UtilPlayer.message(player, F.main("Give", "Invalid Enchantment [" + cur + "].")); + } + } + } + //Create String givenList = ""; for (Player cur : giveList) @@ -110,7 +133,10 @@ public class Give extends MiniPlugin for (Player cur : giveList) { ItemStack stack = ItemStackFactory.Instance.CreateStack(curItem.getKey(), curItem.getValue(), count); - + + //Enchants + stack.addUnsafeEnchantments(enchs); + //Give if (UtilInv.insert(cur, stack)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java index 86254b037..006688a96 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -21,7 +21,7 @@ public class GiveItemCommand extends CommandBase { public GiveItemCommand(InventoryManager plugin) { - super(plugin, Rank.DEVELOPER, "giveitem"); + super(plugin, Rank.ADMIN, "giveitem"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java index 8679dec3e..95837a935 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java @@ -98,10 +98,10 @@ public class InventoryRepository extends RepositoryBase public boolean incrementClientInventoryItem(int accountId, int itemId, int count) { - System.out.println("Updating " + accountId + "'s " + itemId + " with " + count); + //System.out.println("Updating " + accountId + "'s " + itemId + " with " + count); if (executeUpdate(UPDATE_CLIENT_INVENTORY, new ColumnInt("count", count), new ColumnInt("id", accountId), new ColumnInt("itemid", itemId)) < 1) { - System.out.println("Inserting " + accountId + "'s " + itemId + " with " + count); + //System.out.println("Inserting " + accountId + "'s " + itemId + " with " + count); return executeUpdate(INSERT_CLIENT_INVENTORY, new ColumnInt("id", accountId), new ColumnInt("itemid", itemId), new ColumnInt("count", count)) > 0; } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java b/Plugins/Mineplex.Core/src/mineplex/core/map/BlockMap.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/map/Map.java rename to Plugins/Mineplex.Core/src/mineplex/core/map/BlockMap.java index 98ebc3d34..b6a14996a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/BlockMap.java @@ -36,17 +36,17 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; -public class Map implements Listener +public class BlockMap implements Listener { private HashMap _maps = new HashMap(); - public Map(MiniPlugin plugin, String location, Block corner1, Block corner2) + public BlockMap(MiniPlugin plugin, String imageUrl, Block corner1, Block corner2) { - this(plugin, location, corner1, corner2, null); + this(plugin, imageUrl, corner1, corner2, null); } - public Map(MiniPlugin plugin, String location, Block corner1, Block corner2, BlockFace facingDirection) + public BlockMap(MiniPlugin plugin, String imageUrl, Block corner1, Block corner2, BlockFace facingDirection) { try @@ -138,11 +138,11 @@ public class Map implements Listener corner = corner.getRelative(facingDirection.getOppositeFace()); // Load image - BufferedImage image = loadImage(location); + BufferedImage image = loadImage(imageUrl); if (image == null) { - throw new IllegalArgumentException("Cannot load image at '" + location + "'"); + throw new IllegalArgumentException("Cannot load image at '" + imageUrl + "'"); } // Resize image to fit into the dimensions diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMap.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMap.java new file mode 100644 index 000000000..f0c6c3e18 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMap.java @@ -0,0 +1,42 @@ +package mineplex.core.map; + +import net.minecraft.server.v1_7_R4.WorldMap; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class ChunkMap +{ + public ItemStack getItem(Location loc) + { + MapView map = Bukkit.createMap(Bukkit.getWorlds().get(0)); + + for (MapRenderer r : map.getRenderers()) + { + map.removeRenderer(r); + } + + ItemStack item = new ItemStack(Material.MAP); + + item.setDurability(map.getId()); + + WorldMap worldMap = new WorldMap("map_" + map.getId()); + + ChunkMapRenderer renderer = new ChunkMapRenderer(worldMap); + + map.addRenderer(renderer); + + worldMap.scale=(byte)3; + worldMap.centerX = loc.getBlockX(); + worldMap.centerZ = loc.getBlockZ(); + worldMap.c(); + + renderer.setupMap(loc.getWorld()); + + return item; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMapRenderer.java new file mode 100644 index 000000000..ef6431a2b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMapRenderer.java @@ -0,0 +1,203 @@ +package mineplex.core.map; + +import java.util.HashMap; +import java.util.Map.Entry; + +import net.minecraft.server.v1_7_R4.Block; +import net.minecraft.server.v1_7_R4.Blocks; +import net.minecraft.server.v1_7_R4.Chunk; +import net.minecraft.server.v1_7_R4.MaterialMapColor; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.WorldMap; +import net.minecraft.util.com.google.common.collect.HashMultiset; +import net.minecraft.util.com.google.common.collect.Iterables; +import net.minecraft.util.com.google.common.collect.Multisets; + +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class ChunkMapRenderer extends MapRenderer +{ + private final WorldMap worldmap; + private byte[] colors = new byte[128 * 128 * 128]; + + public ChunkMapRenderer(WorldMap worldMap) + { + super(false); + this.worldmap = worldMap; + } + + public void setupMap(World world) + { + int i = 1 << worldmap.scale; + int j = worldmap.centerX; + int k = worldmap.centerZ; + int l = MathHelper.floor(0) / i + 64; + int i1 = MathHelper.floor(0) / i + 64; + int j1 = 128 / i; + + for (int k1 = l - j1 + 1; k1 < l + j1; k1++) + { + int l1 = 255; + int i2 = 0; + double d0 = 0.0D; + + for (int j2 = i1 - j1 - 1; j2 < i1 + j1; j2++) + { + if ((k1 >= 0) && (j2 >= -1) && (k1 < 128) && (j2 < 128)) + { + int k2 = k1 - l; + int l2 = j2 - i1; + boolean flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2); + int i3 = (j / i + k1 - 64) * i; + int j3 = (k / i + j2 - 64) * i; + HashMultiset hashmultiset = HashMultiset.create(); + Chunk chunk = ((CraftWorld) world).getHandle().getChunkAtWorldCoords(i3, j3); + + if (!chunk.isEmpty()) + { + int k3 = i3 & 0xF; + int l3 = j3 & 0xF; + int i4 = 0; + double d1 = 0.0D; + + for (int j4 = 0; j4 < i; j4++) + { + for (int k4 = 0; k4 < i; k4++) + { + int l4 = chunk.b(j4 + k3, k4 + l3) + 1; + Block block = Blocks.AIR; + int i5 = 0; + + if (l4 > 1) + { + do + { + l4--; + block = chunk.getType(j4 + k3, l4, k4 + l3); + i5 = chunk.getData(j4 + k3, l4, k4 + l3); + } + while ((block.f(i5) == MaterialMapColor.b) && (l4 > 0)); + + if ((l4 > 0) && (block.getMaterial().isLiquid())) + { + int j5 = l4 - 1; + Block block1; + do + { + block1 = chunk.getType(j4 + k3, j5--, k4 + l3); + i4++; + } + while ((j5 > 0) && (block1.getMaterial().isLiquid())); + } + } + + d1 += l4 / (i * i); + hashmultiset.add(block.f(i5)); + } + } + + i4 /= i * i; + double d2 = (d1 - d0) * 4.0D / (i + 4) + ((k1 + j2 & 0x1) - 0.5D) * 0.4D; + byte b0 = 1; + + if (d2 > 0.6D) + { + b0 = 2; + } + + if (d2 < -0.6D) + { + b0 = 0; + } + + MaterialMapColor materialmapcolor = (MaterialMapColor) Iterables.getFirst( + Multisets.copyHighestCountFirst(hashmultiset), MaterialMapColor.b); + + if (materialmapcolor == MaterialMapColor.n) + { + d2 = i4 * 0.1D + (k1 + j2 & 0x1) * 0.2D; + b0 = 1; + if (d2 < 0.5D) + { + b0 = 2; + } + + if (d2 > 0.9D) + { + b0 = 0; + } + } + + d0 = d1; + if ((j2 >= 0) && (k2 * k2 + l2 * l2 < j1 * j1) && ((!flag) || ((k1 + j2 & 0x1) != 0))) + { + byte b1 = colors[(k1 + j2 * 128)]; + byte b2 = (byte) (materialmapcolor.M * 4 + b0); + + if (b1 != b2) + { + if (l1 > j2) + { + l1 = j2; + } + + if (i2 < j2) + { + i2 = j2; + } + + colors[(k1 + j2 * 128)] = b2; + } + } + } + } + } + + if (l1 <= i2) + worldmap.flagDirty(k1, l1, i2); + } + } + + @Override + public void render(MapView view, MapCanvas canvas, Player player) + { + int scale = 1 << worldmap.scale; + byte i = 30; + + HashMap map = new HashMap(); + + for (int mapX = 0; mapX < 128; mapX++) + { + for (int mapZ = 0; mapZ < 128; mapZ++) + { + byte color = (byte) 0;// worldmap.colors[(z * 128 + x)]; + + int bX = (worldmap.centerX + ((mapX - 64) * scale)) & 0x000F; + int bZ = (worldmap.centerZ + ((mapZ - 64) * scale)) & 0x000F; + + if (bX == 0 || bX == 15 || bZ == 0 || bZ == 15) + { + Entry entry = new HashMap.SimpleEntry((mapX - bX) / 16, (mapZ - bZ) / 16); + + if (!map.containsKey(entry)) + { + map.put(entry, i++); + } + + color = map.get(entry); + } + else + { + color = colors[(mapZ * 128 + mapX)]; + } + + canvas.setPixel(mapX, mapZ, color); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java index b853aad2f..80b57ae69 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java @@ -1,6 +1,5 @@ package mineplex.core.map; -import java.awt.Image; import java.awt.image.BufferedImage; import org.bukkit.entity.Player; @@ -10,21 +9,22 @@ import org.bukkit.map.MapView; public class ImageMapRenderer extends MapRenderer { - private Image _image; - private boolean _first = true; + private BufferedImage _image; + private boolean _first = true; - public ImageMapRenderer(BufferedImage image) - { - _image = image; - } + public ImageMapRenderer(BufferedImage image) + { + _image = image; + } - @Override - public void render(MapView view, MapCanvas canvas, Player player) - { - if (_image != null && _first) - { - canvas.drawImage(0, 0, _image); - _first = false; - } - } + @Override + public void render(MapView view, MapCanvas canvas, Player player) + { + if (_image != null && _first) + { + canvas.drawImage(0, 0, _image); + + _first = false; + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java new file mode 100644 index 000000000..d11f032dc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java @@ -0,0 +1,191 @@ +package mineplex.core.map; + +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; + +import javax.imageio.ImageIO; + +import mineplex.core.common.util.UtilServer; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class MapText +{ + private static HashMap _characters = new HashMap(); + + private void loadCharacters() + { + try + { + InputStream inputStream = getClass().getResourceAsStream("ascii.png"); + BufferedImage image = ImageIO.read(inputStream); + + char[] text = new char[] + { + ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', + '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', + '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', + 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~' + }; + + int x = 0; + int y = 16; + + for (char c : text) + { + grab(c, image, x, y); + + if (x < 15 * 8) + { + x += 8; + } + else + { + x = 0; + y += 8; + } + } + + inputStream.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + private static void grab(Character character, BufferedImage image, int imageX, int imageY) + { + BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8); + + int width = character == ' ' ? 4 : 0; + + if (width == 0) + { + for (int x = 0; x < 8; x++) + { + width++; + boolean foundNonTrans = false; + + for (int y = 0; y < 8; y++) + { + int pixel = newImage.getRGB(x, y); + + if ((pixel >> 24) != 0x00) + { + foundNonTrans = true; + break; + } + } + + if (!foundNonTrans) + { + break; + } + } + } + + newImage = newImage.getSubimage(0, 0, width, 8); + + _characters.put(character, newImage); + } + + private ArrayList split(String text) + { + ArrayList returns = new ArrayList(); + int lineWidth = 0; + String current = ""; + + for (String word : text.split("(?<= )")) + { + int length = 0; + + for (char c : word.toCharArray()) + { + length += _characters.get(c).getWidth(); + } + + if (lineWidth + length >= 127) + { + lineWidth = 0; + returns.add(current); + current = ""; + } + + current += word; + lineWidth += length; + } + + returns.add(current); + + return returns; + } + + public ItemStack getMap(boolean sendToServer, String... text) + { + if (_characters.isEmpty()) + { + loadCharacters(); + } + + BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB); + Graphics g = image.getGraphics(); + int height = 1; + + for (String string : text) + { + for (String line : split(string)) + { + int length = 1; + + for (char c : line.toCharArray()) + { + BufferedImage img = _characters.get(c); + + if (img == null) + { + System.out.print("Error: '" + c + "' has no image associated"); + continue; + } + + g.drawImage(img, length, height, null); + + length += img.getWidth(); + } + + height += 8; + } + } + + MapView map = Bukkit.createMap(Bukkit.getWorlds().get(0)); + + for (MapRenderer r : map.getRenderers()) + { + map.removeRenderer(r); + } + + map.addRenderer(new ImageMapRenderer(image)); + + ItemStack item = new ItemStack(Material.MAP); + + item.setDurability(map.getId()); + + if (sendToServer) + { + for (Player player : UtilServer.getPlayers()) + player.sendMap(map); + } + + return item; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png b/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png new file mode 100644 index 000000000..587966dc3 Binary files /dev/null and b/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png differ diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java index 323e59347..c27e778fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java @@ -4,4 +4,6 @@ public class ClientMessage { public String LastTo; public String LastAdminTo; + public long LastToTime; + public int SpamCounter; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index b531744a8..db26122a2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -1,5 +1,6 @@ package mineplex.core.message; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.UUID; @@ -22,6 +23,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.event.StackerEvent; import mineplex.core.friend.FriendManager; import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendStatus; @@ -48,7 +50,7 @@ public class MessageManager extends MiniClientPlugin private PreferencesManager _preferences; private Punish _punish; private Chat _chat; - private LinkedList _randomMessage; + private ArrayList _randomMessage; private String _serverName; public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, @@ -96,7 +98,7 @@ public class MessageManager extends MiniClientPlugin } public boolean canMessage(Player from, Player to) - { + { if (!canSenderMessageThem(from, to.getName())) { return false; @@ -179,11 +181,35 @@ public class MessageManager extends MiniClientPlugin public void DoMessage(Player from, Player to, String message) { + PrivateMessageEvent pmEvent = new PrivateMessageEvent(from, to, message); + Bukkit.getServer().getPluginManager().callEvent(pmEvent); + if (pmEvent.isCancelled()) + return; + if (!canMessage(from, to)) { return; } + // 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 && !Get(from).LastTo.equalsIgnoreCase(to.getName())) + { + long delta = System.currentTimeMillis() - Get(from).LastToTime; + + if (Get(from).SpamCounter > 3 && delta < Get(from).SpamCounter * 1000) + { + from.sendMessage(F.main("Cooldown", "Try sending that message again in a few seconds")); + Get(from).LastTo = to.getName(); + return; + } + else if (delta < 8000) + { + // Silently increment spam counter whenever delta is less than 8 seconds + Get(from).SpamCounter++; + } + } + message = _chat.getFilteredMessage(from, message); // Inform @@ -191,11 +217,12 @@ public class MessageManager extends MiniClientPlugin // Save Get(from).LastTo = to.getName(); + Get(from).LastToTime = System.currentTimeMillis(); // Chiss or defek7 - if (to.getName().equals("Chiss") || to.getName().equals("defek7")) + if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary")) { - UtilPlayer.message(from, C.cPurple + to.getName() + "is often AFK or minimized, due to plugin development."); + 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."); } @@ -248,7 +275,7 @@ public class MessageManager extends MiniClientPlugin @Override public void enable() { - _randomMessage = new LinkedList(); + _randomMessage = new ArrayList(); _randomMessage.clear(); _randomMessage.add("Hello, do you have any wild boars for purchase?"); _randomMessage.add("There's a snake in my boot!"); @@ -301,7 +328,7 @@ public class MessageManager extends MiniClientPlugin return _randomMessage.get(UtilMath.r(_randomMessage.size())); } - public LinkedList GetRandomMessages() + public ArrayList GetRandomMessages() { return _randomMessage; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/PrivateMessageEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/message/PrivateMessageEvent.java new file mode 100644 index 000000000..07716d21b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/PrivateMessageEvent.java @@ -0,0 +1,59 @@ +package mineplex.core.message; + + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PrivateMessageEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private boolean _cancelled = false; + private Player _sender; + private Player _recipient; + private String _msg; + + public PrivateMessageEvent(Player sender, Player recipient, String msg) + { + _sender = sender; + _recipient = recipient; + _msg = msg; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public void setCancelled(boolean cancel) + { + _cancelled = cancel; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public Player getSender() + { + return _sender; + } + + public Player getRecipient() + { + return _recipient; + } + + public String getMessage() + { + return _msg; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 0c4d99a75..6b7eb9053 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -349,6 +349,9 @@ public class NpcManager extends MiniPlugin UtilEnt.Vegetate(entity); UtilEnt.silence(entity, true); UtilEnt.ghost(entity, true, false); + + // Add Look AI + UtilEnt.addLookAtPlayerAI(entity, 10.0F); } if (npc.getDatabaseRecord().getHelmet() != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/timing/TimingManager.java b/Plugins/Mineplex.Core/src/mineplex/core/timing/TimingManager.java index 762edb3d4..8935e5eb4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/timing/TimingManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/timing/TimingManager.java @@ -75,10 +75,7 @@ public class TimingManager implements Listener { if (_totalList.containsKey(title)) { - TimeData data = _totalList.get(title); - data.addTime(); - - _totalList.put(title, data); + _totalList.get(title).addTime(); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 61753ea16..d38e276db 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -120,7 +120,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat new Field(plugin, creature, _condition, energy, serverName); - DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager); + DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager, _condition); new Weapon(plugin, energy); new Gameplay(plugin, this, blockRestore, damageManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 7e4dc80e3..0e586d82e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -146,7 +146,7 @@ public class Hub extends JavaPlugin implements IRelation ProjectileManager throwManager = new ProjectileManager(this); SkillConditionManager conditionManager = new SkillConditionManager(this); - DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager); + DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); Fire fire = new Fire(this, conditionManager, damage); Teleport teleport = new Teleport(this); Energy energy = new Energy(this); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index ebff189d5..d2637c0b7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -70,6 +70,7 @@ 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.party.Party; @@ -92,7 +93,6 @@ import mineplex.hub.modules.JumpManager; import mineplex.hub.modules.NewsManager; import mineplex.hub.modules.ParkourManager; import mineplex.hub.modules.TextManager; -import mineplex.hub.modules.UHCManager; import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.WorldManager; import mineplex.hub.poll.PollManager; @@ -169,7 +169,6 @@ public class HubManager extends MiniClientPlugin new WorldManager(this); new JumpManager(this); - new UHCManager(this); //new TournamentInviter(this); _news = new NewsManager(this); @@ -524,8 +523,6 @@ public class HubManager extends MiniClientPlugin else { event.setJoinMessage(C.cGreen + C.Bold + "Legend " + playerName + " has joined!"); - UtilFirework.playFirework(player.getEyeLocation(), org.bukkit.FireworkEffect.Type.BALL_LARGE, Color.LIME, true, true); - player.getWorld().playSound(player.getEyeLocation(), Sound.WITHER_SPAWN, 2f, 1f); } //Teleport @@ -612,6 +609,17 @@ 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)) + { + UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); + event.setCancelled(true); + } + } @EventHandler public void PlayerChat(AsyncPlayerChatEvent event) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/UHCManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/UHCManager.java deleted file mode 100644 index f548a0b62..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/UHCManager.java +++ /dev/null @@ -1,101 +0,0 @@ -package mineplex.hub.modules; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import mineplex.serverdata.Utility; - -public class UHCManager extends MiniPlugin -{ - public HubManager Manager; - - private long _delay = 3600000; - private boolean _canAnnounce3 = true; - private boolean _canAnnounce2 = true; - private boolean _canAnnounce1 = true; - private boolean _canAnnounce0 = true; - - public UHCManager(HubManager manager) - { - super("UHC Manager", manager.getPlugin()); - - Manager = manager; - } - - @EventHandler - public void AnnounceUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - Bukkit.getScheduler().runTaskAsynchronously(Manager.getPlugin(), new Runnable() - { - @Override - public void run() - { - long time = Utility.currentTimeMillis(); - - //System.out.println("UHC in " + UtilTime.MakeStr(_delay - (time % _delay))); - - //Reset - if (time % _delay > 30000 && time % _delay < _delay - 180000) - { - _canAnnounce3 = true; - _canAnnounce2 = true; - _canAnnounce1 = true; - _canAnnounce0 = true; - } - //Announce - else - { - if (_canAnnounce3 && time % _delay > _delay - 180000) - { - _canAnnounce3 = false; - announce("Opening in 3 minutes..."); - - UtilTextMiddle.display(C.cRed + "Ultra Hardcore", "Open in 3 minutes...", 10, 100, 20); - } - - else if (_canAnnounce2 && time % _delay > _delay - 120000) - { - _canAnnounce2 = false; - announce("Opening in 2 minutes..."); - - UtilTextMiddle.display(C.cRed + "Ultra Hardcore", "Open in 2 minutes...", 10, 100, 20); - } - - else if (_canAnnounce1 && time % _delay > _delay - 60000) - { - _canAnnounce1 = false; - announce("Opening in 1 minute..."); - - UtilTextMiddle.display(C.cRed + "Ultra Hardcore", "Open in 1 minute...", 10, 100, 20); - } - - else if (_canAnnounce0 && time % _delay < 30000) - { - _canAnnounce0 = false; - announce("UHC Open! Join at the Ultra Hardcore NPC!"); - - UtilTextMiddle.display(C.cRed + "Ultra Hardcore", "Join at the NPC to play", 10, 100, 20); - } - } - } - }); - } - - public void announce(String message) - { - for (Player player : UtilServer.getPlayers()) - UtilPlayer.message(player, C.cDPurple + "[Ultra Hardcore] " + C.cPurple + C.Bold + message); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index c1a058b9c..c59880714 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -413,7 +413,7 @@ public class ServerManager extends MiniPlugin public void run(Collection serverStatusList) { _serverPlayerCounts.clear(); - + for (MinecraftServer serverStatus : serverStatusList) { if (!_serverInfoMap.containsKey(serverStatus.getName())) @@ -454,10 +454,10 @@ public class ServerManager extends MiniPlugin if (_serverKeyTagMap.containsKey(tag)) { _serverKeyInfoMap.get(_serverKeyTagMap.get(tag)).add(serverInfo); - + if (!_serverPlayerCounts.containsKey(tag)) _serverPlayerCounts.put(tag, 0); - + _serverPlayerCounts.put(tag, _serverPlayerCounts.get(tag) + serverInfo.CurrentPlayers); } } @@ -709,6 +709,21 @@ public class ServerManager extends MiniPlugin { return _serverNpcShopMap.get("Block Hunt"); } + + public ServerNpcShop getBetaShop() + { + return _serverNpcShopMap.get("Beta Games"); + } + + public ServerNpcShop getUHCShop() + { + return _serverNpcShopMap.get("Ultra Hardcore"); + } + + public ServerNpcShop getPlayerGamesShop() + { + return _serverNpcShopMap.get("Mineplex Player Servers"); + } private Vector ParseVector(String vectorString) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerSorter.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerSorter.java index d778d7989..68b487d49 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerSorter.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerSorter.java @@ -1,7 +1,10 @@ package mineplex.hub.server; +import java.awt.Color; import java.util.Comparator; +import org.bukkit.ChatColor; + public class ServerSorter implements Comparator { private int _requiredSlots; @@ -19,12 +22,36 @@ public class ServerSorter implements Comparator if ((a.MOTD.contains("Restarting"))) return 1; - if ((a.MOTD.contains("Recruiting") || a.MOTD.contains("Waiting") || a.MOTD.contains("Starting") || a.MOTD.contains("Cup")) && !b.MOTD.contains("Recruiting") && !b.MOTD.contains("Waiting") && !b.MOTD.contains("Starting") && !b.MOTD.contains("Cup")) + if ((a.MOTD.contains("Recruiting") || a.MOTD.contains("Waiting") || a.MOTD.contains("Starting") || a.MOTD.contains("Cup") || a.MOTD.contains("Generating")) && !b.MOTD.contains("Recruiting") && !b.MOTD.contains("Waiting") && !b.MOTD.contains("Starting") && !b.MOTD.contains("Cup") && !b.MOTD.contains("Generating")) return -1; - if ((b.MOTD.contains("Recruiting") || b.MOTD.contains("Waiting") || b.MOTD.contains("Starting") || b.MOTD.contains("Cup")) && !a.MOTD.contains("Recruiting") && !a.MOTD.contains("Waiting") && !a.MOTD.contains("Starting") && !a.MOTD.contains("Cup")) + if ((b.MOTD.contains("Recruiting") || b.MOTD.contains("Waiting") || b.MOTD.contains("Starting") || b.MOTD.contains("Cup") || b.MOTD.contains("Generating")) && !a.MOTD.contains("Recruiting") && !a.MOTD.contains("Waiting") && !a.MOTD.contains("Starting") && !a.MOTD.contains("Cup") && !a.MOTD.contains("Generating")) return 1; + if (a.MOTD.contains("Generating") && b.MOTD.contains("Generating")) + { + try + { + String aTime = ChatColor.stripColor(a.MOTD.substring(a.MOTD.indexOf("(") + 1, a.MOTD.indexOf(")"))); + String bTime = ChatColor.stripColor(b.MOTD.substring(b.MOTD.indexOf("(") + 1, b.MOTD.indexOf(")"))); + + int timeOfA = (int)Double.parseDouble(aTime.split(" ")[0]) * (aTime.contains("Minute") ? 60 : 1); + int timeOfB = (int)Double.parseDouble(bTime.split(" ")[0]) * (bTime.contains("Minute") ? 60 : 1); + + if (timeOfA < timeOfB) + return -1; + else if (timeOfB < timeOfA) + return 1; + else + return 0; + } + catch (Exception exception) + { + exception.printStackTrace(); + return 0; + } + } + if (a.MaxPlayers - a.CurrentPlayers < _requiredSlots && b.MaxPlayers - b.CurrentPlayers >= _requiredSlots) return -1; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 6c8cbe089..18734c897 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -14,6 +14,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; +import mineplex.hub.server.ui.button.SelectBETAButton; import mineplex.hub.server.ui.button.SelectBHButton; import mineplex.hub.server.ui.button.SelectBLDButton; import mineplex.hub.server.ui.button.SelectBRButton; @@ -22,9 +23,11 @@ import mineplex.hub.server.ui.button.SelectDMTButton; import mineplex.hub.server.ui.button.SelectDOMButton; import mineplex.hub.server.ui.button.SelectMINButton; import mineplex.hub.server.ui.button.SelectMSButton; +import mineplex.hub.server.ui.button.SelectPLAYERButton; import mineplex.hub.server.ui.button.SelectSGButton; import mineplex.hub.server.ui.button.SelectSSMButton; import mineplex.hub.server.ui.button.SelectTDMButton; +import mineplex.hub.server.ui.button.SelectUHCButton; import mineplex.hub.server.ui.button.SelectWIZButton; public class ServerGameMenu extends ShopPageBase @@ -37,7 +40,7 @@ public class ServerGameMenu extends ShopPageBase public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) { - super(plugin, quickShop, clientManager, donationManager, name, player, 56); + super(plugin, quickShop, clientManager, donationManager, name, player, 47); createSuperSmashCycle(); createMinigameCycle(); @@ -65,7 +68,7 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "", ChatColor.RESET + "Search for chests to find loot and ", ChatColor.RESET + "fight others to be the last man standing. ", - ChatColor.RESET + "Beware of the deep freeze!", + ChatColor.RESET + "Stay away from the borders!", ChatColor.RESET + "", ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("HG") + ChatColor.RESET + " other players!", })); @@ -82,14 +85,14 @@ public class ServerGameMenu extends ShopPageBase setItem(6, _superSmashCycle.get(_ssmIndex)); - setItem(8, ItemStackFactory.Instance.CreateStack(Material.BLAZE_ROD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Wizards " + C.cGray + "Last Man Standing", new String[] - { - ChatColor.RESET + "", - ChatColor.RESET + "Wield powerful spells to fight", - ChatColor.RESET + "against other players in this", - ChatColor.RESET + "exciting free-for-all brawl!", - ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("WIZ") + ChatColor.RESET + " other players!", + setItem(8, ItemStackFactory.Instance.CreateStack(Material.BLAZE_ROD.getId(), (byte) 0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Wizards " + C.cGray + "Last Man Standing", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Wield powerful spells to fight", + ChatColor.RESET + "against other players in this", + ChatColor.RESET + "exciting free-for-all brawl!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("WIZ") + ChatColor.RESET + " other players!", })); setItem(18, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Draw My Thing " + C.cGray + "Pictionary!", new String[] @@ -141,8 +144,18 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "", ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BH") + ChatColor.RESET + " other players!", })); + + setItem(36, ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "UHC " + C.cGray + "Ultra Hardcore Mode", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Extremely hard team-based survival ", + ChatColor.RESET + "Gather materials and fight your way", + ChatColor.RESET + "to become the last team standing!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("UHC") + ChatColor.RESET + " other players!", + })); - setItem(36, ItemStackFactory.Instance.CreateStack(Material.WOOD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Master Builders " + C.cGray + "Creative Build", new String[] + setItem(38, ItemStackFactory.Instance.CreateStack(Material.WOOD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Master Builders " + C.cGray + "Creative Build", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Players are given a Build Theme and ", @@ -152,7 +165,25 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BLD") + ChatColor.RESET + " other players!", })); - setItem(44, _minigameCycle.get(_minigameIndex)); + setItem(40, _minigameCycle.get(_minigameIndex)); + + setItem(42, ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM.getId(), (byte) 3, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Player Servers " + C.cGray + "Player Hosted Games", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Join your friends in their own ", + ChatColor.RESET + "Mineplex Player Server. You can play", + ChatColor.RESET + "the games you want, when you want.", + ChatColor.RESET + "", + })); + + setItem(44, ItemStackFactory.Instance.CreateStack(Material.ANVIL.getId(), (byte) 0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Beta Games " + C.cGray + "Play Unreleased Games", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Help test and improve our ", + ChatColor.RESET + "unreleased games.", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BETA") + ChatColor.RESET + " other players!", + })); getButtonMap().put(0, new SelectBRButton(this)); getButtonMap().put(2, new SelectSGButton(this)); @@ -165,8 +196,11 @@ public class ServerGameMenu extends ShopPageBase getButtonMap().put(22, new SelectDOMButton(this)); getButtonMap().put(24, new SelectTDMButton(this)); getButtonMap().put(26, new SelectBHButton(this)); - getButtonMap().put(36, new SelectBLDButton(this)); - getButtonMap().put(44, new SelectMINButton(this)); + getButtonMap().put(36, new SelectUHCButton(this)); + getButtonMap().put(38, new SelectBLDButton(this)); + getButtonMap().put(40, new SelectMINButton(this)); + getButtonMap().put(42, new SelectPLAYERButton(this)); + getButtonMap().put(44, new SelectBETAButton(this)); } @SuppressWarnings("deprecation") @@ -493,4 +527,19 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getBuildShop().attemptShopOpen(player); } + + public void openBeta(Player player) + { + getPlugin().getBetaShop().attemptShopOpen(player); + } + + public void openUHC(Player player) + { + getPlugin().getUHCShop().attemptShopOpen(player); + } + + public void openPlayerGames(Player player) + { + getPlugin().getPlayerGamesShop().attemptShopOpen(player); + } } 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 d44b40c67..8504c0a66 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -327,7 +327,7 @@ public class ServerNpcPage extends ShopPageBase im private boolean isStarting(ServerInfo serverInfo) { - return (serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Open")); + return (serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Generating") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Open")); } private boolean isInProgress(ServerInfo serverInfo) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBETAButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBETAButton.java new file mode 100644 index 000000000..8e062b27a --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBETAButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectBETAButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectBETAButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openBeta(player); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectPLAYERButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectPLAYERButton.java new file mode 100644 index 000000000..0359ebcbf --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectPLAYERButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectPLAYERButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectPLAYERButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openPlayerGames(player); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectUHCButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectUHCButton.java new file mode 100644 index 000000000..ce17cdd24 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectUHCButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectUHCButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectUHCButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openUHC(player); + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index 69a258f60..aab72ed1e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.damage; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Map; import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; @@ -16,6 +17,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.npc.NpcManager; import mineplex.minecraft.game.core.combat.CombatManager; +import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.compatibility.NpcProtectListener; import net.minecraft.server.v1_7_R4.DamageSource; import net.minecraft.server.v1_7_R4.EntityHuman; @@ -28,6 +30,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; import org.bukkit.entity.Fish; import org.bukkit.entity.LivingEntity; @@ -42,24 +45,28 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import com.sun.jndi.ldap.ManageReferralControl; + public class DamageManager extends MiniPlugin { private CombatManager _combatManager; private DisguiseManager _disguiseManager; + private ConditionManager _conditionManager; protected Field _lastDamageByPlayerTime; protected Method _k; public boolean UseSimpleWeaponDamage = false; public boolean DisableDamageChanges = false; - + private boolean _enabled = true; - - public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager) + + public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager, ConditionManager conditionManager) { super("Damage Manager", plugin); _combatManager = combatManager; _disguiseManager = disguiseManager; + _conditionManager = conditionManager; try { @@ -100,9 +107,9 @@ public class DamageManager extends MiniPlugin //Pre-Event Modifications if (!DisableDamageChanges) WeaponDamage(event, damager); - + double damage = event.getDamage(); - + //Consistent Arrow Damage if (projectile != null && projectile instanceof Arrow) { @@ -113,7 +120,7 @@ public class DamageManager extends MiniPlugin NewDamageEvent(damagee, damager, projectile, event.getCause(), damage, true, false, false, null, null, preCancel); //System.out.println(UtilEnt.getName(damagee) + " by " + event.getCause() + " at " + UtilWorld.locToStr(damagee.getLocation())); - + event.setCancelled(true); } @@ -123,7 +130,7 @@ public class DamageManager extends MiniPlugin if (event.isCancelled()) { Projectile projectile = GetProjectile(event); - + if (projectile instanceof Arrow) { projectile.teleport(new Location(projectile.getWorld(), 0, 0, 0)); @@ -191,7 +198,7 @@ public class DamageManager extends MiniPlugin event.SetCancelled("Damagee in Creative"); return; } - + if (UtilPlayer.isSpectator(damagee)) { event.SetCancelled("Damagee in Spectator"); @@ -230,13 +237,80 @@ public class DamageManager extends MiniPlugin } } + @EventHandler(priority = EventPriority.NORMAL) + public void handleEnchants(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + //Defensive + Player damagee = event.GetDamageePlayer(); + if (damagee != null) + { + for (ItemStack stack : damagee.getInventory().getArmorContents()) + { + if (stack == null) + continue; + + Map enchants = stack.getEnchantments(); + for (Enchantment e : enchants.keySet()) + { + if (e.equals(Enchantment.PROTECTION_ENVIRONMENTAL)) + event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); + + else if (e.equals(Enchantment.PROTECTION_FIRE) && + event.GetCause() == DamageCause.FIRE && + event.GetCause() == DamageCause.FIRE_TICK && + event.GetCause() == DamageCause.LAVA) + event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); + + else if (e.equals(Enchantment.PROTECTION_FALL) && + event.GetCause() == DamageCause.FALL) + event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); + + else if (e.equals(Enchantment.PROTECTION_EXPLOSIONS) && + event.GetCause() == DamageCause.ENTITY_EXPLOSION) + event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); + + else if (e.equals(Enchantment.PROTECTION_PROJECTILE) && + event.GetCause() == DamageCause.PROJECTILE) + event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); + } + } + } + + //Offensive + Player damager = event.GetDamagerPlayer(true); + if (damager != null) + { + ItemStack stack = damager.getItemInHand(); + if (stack == null) + return; + + Map enchants = stack.getEnchantments(); + for (Enchantment e : enchants.keySet()) + { + if (e.equals(Enchantment.ARROW_KNOCKBACK) || e.equals(Enchantment.KNOCKBACK)) + event.AddKnockback("Ench Knockback", 1 + (0.5 * (double)enchants.get(e))); + + else if (e.equals(Enchantment.ARROW_DAMAGE)) + event.AddMod("Enchant", "Ench Damage", 0.5 * (double)enchants.get(e), true); + + else if (e.equals(Enchantment.ARROW_FIRE) || e.equals(Enchantment.FIRE_ASPECT)) + if (_conditionManager != null) + _conditionManager.Factory().Ignite("Ench Fire", event.GetDamageeEntity(), damager, + 1 * (double)enchants.get(e), false, false); + } + } + } + @EventHandler(priority = EventPriority.MONITOR) public void EndDamageEvent(CustomDamageEvent event) { if (!event.IsCancelled() && event.GetDamage() > 0) { Damage(event); - + //DING ARROW if (event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) { @@ -247,7 +321,7 @@ public class DamageManager extends MiniPlugin } } } - + DisplayDamage(event); } @@ -255,10 +329,10 @@ public class DamageManager extends MiniPlugin { if (event.GetDamageeEntity() == null) return; - + if (event.GetDamageeEntity().getHealth() <= 0) return; - + //Player Conditions if (event.GetDamageePlayer() != null) { @@ -293,29 +367,34 @@ public class DamageManager extends MiniPlugin //Sticky Arrow if (event.GetCause() == DamageCause.PROJECTILE) ((CraftLivingEntity)event.GetDamageeEntity()).getHandle().p(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().aZ() + 1); - + //Knockback - double knockback = event.GetDamage(); - if (knockback < 2) knockback = 2; - knockback = Math.log10(knockback); - - for (double cur : event.GetKnockback().values()) - knockback = knockback * cur; + if (event.IsKnockback() && event.GetDamagerEntity(true) != null) + { + //Base + double knockback = event.GetDamage(); + if (knockback < 2) knockback = 2; + knockback = Math.log10(knockback); - if (event.IsKnockback()) - if (event.GetDamagerEntity(true) != null) - { - Location origin = event.GetDamagerEntity(true).getLocation(); - if (event.getKnockbackOrigin() != null) - origin = event.getKnockbackOrigin(); - - Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation()); - trajectory.multiply(0.6 * knockback); - trajectory.setY(Math.abs(trajectory.getY())); + //Mults + for (double cur : event.GetKnockback().values()) + knockback = knockback * cur; + + //Origin + Location origin = event.GetDamagerEntity(true).getLocation(); + if (event.getKnockbackOrigin() != null) + origin = event.getKnockbackOrigin(); + + //Vec + Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation()); + trajectory.multiply(0.6 * knockback); + trajectory.setY(Math.abs(trajectory.getY())); + + //Apply + UtilAction.velocity(event.GetDamageeEntity(), + trajectory, 0.2 + trajectory.length() * 0.8, false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true); + } - UtilAction.velocity(event.GetDamageeEntity(), - trajectory, 0.2 + trajectory.length() * 0.8, false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true); - } } catch (IllegalAccessException e) { @@ -365,7 +444,7 @@ public class DamageManager extends MiniPlugin { EntityLiving entityDamagee = ((CraftLivingEntity)damagee).getHandle(); EntityLiving entityDamager = null; - + if (damager != null) entityDamager= ((CraftLivingEntity)damager).getHandle(); @@ -426,7 +505,7 @@ public class DamageManager extends MiniPlugin LivingEntity damagee = event.GetDamageeEntity(); if (damagee == null) return; - + if (_disguiseManager.isDisguised(damagee)) { _disguiseManager.getDisguise(damagee).playHurtSound(); @@ -576,7 +655,7 @@ public class DamageManager extends MiniPlugin return null; } - + public void SetEnabled(boolean var) { _enabled = var; @@ -586,4 +665,9 @@ public class DamageManager extends MiniPlugin { return _combatManager; } + + public void setConditionManager(ConditionManager cm) + { + _conditionManager = cm; + } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java index b1aaf1c97..31adb7fe8 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/MinecraftServer.java @@ -96,7 +96,7 @@ public class MinecraftServer public boolean isJoinable() { if (_motd != null && (_motd.contains("Starting") || _motd.contains("Recruiting") - || _motd.contains("Waiting") || _motd.contains("Open in") || _motd.isEmpty())) + || _motd.contains("Waiting") || _motd.contains("Open in") || _motd.isEmpty() || _motd.contains("Generating"))) { if (_playerCount < _maxPlayerCount) { 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 a3b81be8e..340a24e22 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -1,10 +1,10 @@ package nautilus.game.arcade; import java.io.File; - import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import net.minecraft.server.v1_7_R4.BiomeBase; import net.minecraft.server.v1_7_R4.MinecraftServer; import mineplex.core.CustomTagFix; import mineplex.core.TablistFix; @@ -41,7 +41,6 @@ import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; import mineplex.core.serverConfig.ServerConfiguration; -import mineplex.core.spawn.Spawn; import mineplex.core.status.ServerStatusManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.FileUpdater; @@ -105,7 +104,7 @@ public class Arcade extends JavaPlugin DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); - _damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager); + _damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, null); Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); @@ -141,6 +140,12 @@ public class Arcade extends JavaPlugin getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); + + // Remove nasty biomes from natural terrain generation, used for UHC + BiomeBase.getBiomes()[BiomeBase.OCEAN.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.DEEP_OCEAN.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.SWAMPLAND.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.RIVER.id] = BiomeBase.PLAINS; } @Override 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 8c69eddb5..64daf9a76 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -84,6 +84,7 @@ import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.timing.TimingManager; +import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; @@ -214,7 +215,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Modules _blockRestore = new BlockRestore(plugin); - _blood = blood; _preferencesManager = preferences; @@ -222,8 +222,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _explosionManager.SetDebris(false); if (serverConfig.GameList.contains(GameType.ChampionsDominate) - || serverConfig.GameList.contains(GameType.ChampionsTDM) - || serverConfig.GameList.contains(GameType.ChampionsMOBA)) + || serverConfig.GameList.contains(GameType.ChampionsTDM) + || serverConfig.GameList.contains(GameType.ChampionsMOBA)) { _conditionManager = new SkillConditionManager(plugin); } @@ -231,7 +231,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { _conditionManager = new ConditionManager(plugin); } - + _clientManager = clientManager; _serverStatusManager = serverStatusManager; _chat = chat; @@ -239,7 +239,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _damageManager = damageManager; _damageManager.UseSimpleWeaponDamage = true; - + _damageManager.setConditionManager(_conditionManager); + _disguiseManager = disguiseManager; _donationManager = donationManager; @@ -815,7 +816,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation || _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA")) { - if (GetGame() != null && (GetGame().GetType() == GameType.UHC || GetGame().GetType() == GameType.Halloween || GetGame().GetType() == GameType.Christmas || GetGame().GetType() == GameType.ChampionsDominate || GetGame().GetType() == GameType.ChampionsTDM || GetGame().GetType() == GameType.MineStrike)) + if (GetGame() != null && GetGame().DontAllowOverfill) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, C.Bold + "Server has reached max capacity for gameplay purposes."); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java index 2320c9083..140e9e87e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.cards.Cards; import nautilus.game.arcade.game.games.castlesiege.CastleSiege; import nautilus.game.arcade.game.games.champions.ChampionsDominate; import nautilus.game.arcade.game.games.champions.ChampionsTDM; @@ -70,6 +71,7 @@ public class GameFactory else if (gameType == GameType.BaconBrawl) return new BaconBrawl(_manager); else if (gameType == GameType.Bridge) return new Bridge(_manager); else if (gameType == GameType.Build) return new Build(_manager); + else if (gameType == GameType.Cards) return new Cards(_manager); else if (gameType == GameType.CastleSiege) return new CastleSiege(_manager); else if (gameType == GameType.Christmas) return new Christmas(_manager); else if (gameType == GameType.DeathTag) return new DeathTag(_manager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 3a514a456..2b2c97eec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -54,7 +54,9 @@ public enum GameType WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47), Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48, "http://chivebox.com/file/c/ResWizards.zip", true), ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49), + Build("Master Builders", Material.BRICK, (byte)0, GameCategory.CLASSICS, 50), + Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/YoutubeCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/YoutubeCommand.java index 6bc32e6c5..454b19375 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/YoutubeCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/YoutubeCommand.java @@ -10,7 +10,7 @@ public class YoutubeCommand extends CommandBase { public YoutubeCommand(ArcadeManager plugin) { - super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE}, "youtube"); + super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, new String[] {"youtube", "twitch"}); } @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 318e93d47..1d247b2c7 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 @@ -188,6 +188,7 @@ public abstract class Game implements Listener public boolean WorldFireSpread = false; public boolean WorldLeavesDecay = false; public boolean WorldSoilTrample = false; + public boolean WorldBoneMeal = false; public int HungerSet = -1; public int HealthSet = -1; @@ -217,6 +218,8 @@ public abstract class Game implements Listener public boolean GadgetsDisabled = true; public boolean TeleportsDisqualify = true; + + public boolean DontAllowOverfill = false; //Addons public boolean CompassEnabled = false; 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 a1aad7241..c465dbf1d 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 @@ -54,6 +54,7 @@ public class GameTeam } private String _name; + private String _displayName; private ChatColor _color; private HashMap _players = new HashMap(); @@ -75,6 +76,7 @@ public class GameTeam { Host = host; + _displayName = name; _name = name; _color = color; _spawns = spawns; @@ -139,11 +141,19 @@ public class GameTeam { _players.put(player, in ? PlayerState.IN : PlayerState.OUT); - UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + _name + " Team") + "."); + UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + _displayName + " Team.")); VisibilityManager.Instance.refreshPlayerToAll(player); } + public void DisbandTeam() + { + for (Player player : _players.keySet()) + UtilPlayer.message(player, F.main("Team", _color + C.Bold + _displayName + " Team was disbanded.")); + + _players.clear(); + } + public void RemovePlayer(Player player) { _players.remove(player); @@ -261,6 +271,11 @@ public class GameTeam { _name = name; } + + public void setDisplayName(String name) + { + _displayName = name; + } public byte GetColorData() { @@ -375,4 +390,6 @@ public class GameTeam return _places; } + + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java index dcc877d8f..48ae4e9de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.kit.*; import nautilus.game.arcade.stats.TeamDeathsStatTracker; import nautilus.game.arcade.stats.TeamKillsStatTracker; +import org.bukkit.Bukkit; import org.bukkit.entity.*; import org.bukkit.event.*; import org.bukkit.event.player.*; @@ -71,9 +72,9 @@ public abstract class TeamGame extends Game if (player.isDead()) return; - + if (player.getWorld().getName().equalsIgnoreCase("world")) - return; + return; if (!QuitOut) { @@ -83,7 +84,7 @@ public abstract class TeamGame extends Game if (GetKit(player) != null) RejoinKit.put(player.getName(), GetKit(player)); - + RejoinHealth.put(player.getName(), player.getHealth()); GetLocationStore().put(player.getName(), player.getLocation()); @@ -110,22 +111,40 @@ public abstract class TeamGame extends Game Kit kit = RejoinKit.remove(event.getPlayer().getName()); if (kit != null) _playerKit.put(event.getPlayer(), kit); - - if (RejoinHealth.containsKey(event.getPlayer().getName())) - event.getPlayer().setHealth(RejoinHealth.remove(event.getPlayer().getName())); +// final Player player = event.getPlayer(); +// Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() +// { +// @Override +// public void run() +// { +// if (RejoinHealth.containsKey(player.getName())) +// { +// double health = RejoinHealth.remove(player.getName()); +// player.setHealth(health); +// player.sendMessage("DEBUG: restored hp to " + health); +// } +// } +// }, 20); + return; } - - /* - //Owner Bypass - if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER)) + } + + //Do this on Join, not Login, otherwise player no get heal. + @EventHandler + public void playerRejoinGame(PlayerJoinEvent event) + { + if (!InProgress() || QuitOut) return; - //Disallow - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.YELLOW + "You cannot join this UHC."); - */ + Player player = event.getPlayer(); + + if (RejoinHealth.containsKey(player.getName())) + { + double health = RejoinHealth.remove(player.getName()); + player.setHealth(health); + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index db8d93e7b..9e5a9bc64 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.build; import java.util.AbstractMap; import java.util.ArrayList; -import java.util.Map; import java.util.Map.Entry; import org.bukkit.ChatColor; @@ -13,6 +12,8 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Boat; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Hanging; import org.bukkit.entity.Item; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LivingEntity; @@ -41,10 +42,15 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -93,6 +99,8 @@ import nautilus.game.arcade.kit.Kit; public class Build extends SoloGame { private NautHashMap _data = new NautHashMap(); + + private NautHashMap> _votes = new NautHashMap>(); private ArrayList> _scoreboardPlaces = new ArrayList>(); @@ -113,7 +121,7 @@ public class Build extends SoloGame private MobShop _mobShop; private ItemStack _shopItem; - private String[] _hintText = new String[] + private String[] _hintText = new String[] { "Click Creatures to change their settings!", "Set the Time/Weather in the Options Menu!", @@ -163,11 +171,30 @@ public class Build extends SoloGame this.CreatureAllow = true; this.WorldFireSpread = true; + this.WorldBoneMeal = true; + + this.DontAllowOverfill = true; + + UtilServer.getServer().spigot().getConfig().set("view-distance", 4); _words = new String[] { - "Rollercoaster", "Archery Range", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", "Burger", "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Cannon", "Catapult", "Sailing Boat", "Grim Reaper", "Star Wars", "Elephant", "Penguin", "Ninja", "Pot of Gold", "Shrek", "Fruit", "Breakfast", "Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Cannibals", "Flying Creature", "Beach Creature", "Sea Creature", "Spongebob", "Car", "Pot Plant", "Weapons", "Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Aeroplane" - + "Rollercoaster", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", + "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Pot of Gold", "Shrek", "Fruit", "Breakfast", + "Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Spongebob", "Car", "Potted Plant", "Weapons", + "Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Helicopter", "Knight", "Rabbit", + "Sandwich", "Snowman", "Ice Cream", "Sea Shell", "Rainbow", + "Volcano", "Hot Tub", "Octopus", "Ghost", "Ant", "Cheese", "Kite Flying", "Reptile", + "Space Ship", "Pixel Art", "Chicken", "Shoe", "Owl", "Bear", "Flowers", "Lighthouse", + "Lion", "Television", "Batman", "Tiger", "Castle", "House", + "Bed", "Party", "Volleyball", "Toys", "Library", "Love", "Skull", + "Hat", "Snake", "Vacation", "Umbrella", "Magic", "Tornado", "Candy", "Dentist", "Pizza", "Bird", + "Superhero", "Turtle", "Chicken", "Build Anything!", "Food", "Picnic", + "Trophy", "Pool Party", "Hot Air Balloon", "Train", "Chocolate Bar", + "Clown", "Windmill", "Alligator", + "Police", "Igloo", "Gift", "Bumblebee", "Jellyfish", "Speedboat", + "Fall", "Summer", "Autumn", "Winter", "Disco", "Moose", + "Water Gun", "Astronaut", "Wither", "Meteor" }; _mobShop = new MobShop(getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); @@ -328,9 +355,24 @@ public class Build extends SoloGame //Verdict if (!_viewData.Judged) { - BuildQuality quality = BuildQuality.getQuality(_viewData.getScore()); - - if (quality == BuildQuality.Failure) + boolean hasDecentVote = false; + + + for (Player player : _votes.keySet()) + { + NautHashMap votes = _votes.get(player); + + if (votes.containsKey(_viewData.Player)) + { + if (votes.get(_viewData.Player) > 2) + { + hasDecentVote = true; + break; + } + } + } + + if (!hasDecentVote) { Manager.GetExplosion().BlockExplosion(_viewData.Blocks, _viewData.Spawn, false); @@ -341,7 +383,7 @@ public class Build extends SoloGame } //Announce Builder - UtilTextMiddle.display(quality.getText(), "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5); + UtilTextMiddle.display(hasDecentVote ? null : C.cRed + "Failure", "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5); } _viewData.Judged = true; @@ -382,12 +424,12 @@ public class Build extends SoloGame { UtilInv.Clear(player); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)14, 1, C.Bold + "+0 " + C.cRed + C.Bold + "MY EYES ARE BLEEDING!")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)1, 1, C.Bold + "+1 " + C.cGold + C.Bold + "MEH...")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)4, 1, C.Bold + "+2 " + C.cYellow + C.Bold + "It's okay...")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)5, 1, C.Bold + "+3 " + C.cGreen + C.Bold + "Good")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)3, 1, C.Bold + "+4 " + C.cAqua + C.Bold + "Amazing")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)10, 1, C.Bold + "+5 " + C.cPurple + C.Bold + "WOW! EVERYTHING IS AWESOME!")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)14, 1, C.cRed + C.Bold + "MY EYES ARE BLEEDING!")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)1, 1, C.cGold + C.Bold + "MEH...")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)4, 1, C.cYellow + C.Bold + "It's okay...")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)5, 1, C.cGreen + C.Bold + "Good")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)3, 1, C.cAqua + C.Bold + "Amazing")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)10, 1, C.cPurple + C.Bold + "WOW! EVERYTHING IS AWESOME!")); UtilTextMiddle.display(null, C.cYellow + "Click to Vote", 0, 60, 5, player); } @@ -408,6 +450,8 @@ public class Build extends SoloGame } else if (_buildGameState == 4) { + tallyScores(); + ArrayList places = new ArrayList(); //Calculate Places @@ -415,21 +459,21 @@ public class Build extends SoloGame while (!_data.isEmpty()) { Player bestPlayer = null; - double bestScore = 0; + double bestPoints = 0; for (Player player : _data.keySet()) { - double score = _data.get(player).getScore(); + double points = _data.get(player).getPoints(); - if (bestPlayer == null || score > bestScore) + if (bestPlayer == null || points > bestPoints) { bestPlayer = player; - bestScore = score; + bestPoints = points; } } - AddGems(bestPlayer, bestScore, "Build Votes", false, false); - + //Average points per player is 1000, so divided by 50 = 20 gems + AddGems(bestPlayer, bestPoints / 50, "Build Votes", false, false); BuildData data = _data.remove(bestPlayer); @@ -440,11 +484,8 @@ public class Build extends SoloGame first = false; } - //Only count if they got above TERRIBLE score - if (BuildQuality.getQuality(bestScore) != BuildQuality.Failure) - places.add(bestPlayer); - - _scoreboardPlaces.add(new AbstractMap.SimpleEntry(bestPlayer, bestScore)); + places.add(bestPlayer); + _scoreboardPlaces.add(new AbstractMap.SimpleEntry(bestPlayer, bestPoints)); } writeScoreboard(); @@ -471,6 +512,66 @@ public class Build extends SoloGame } } + private void tallyScores() + { + //Reset, if being re-called + for (BuildData data : _data.values()) + { + data.clearPoints(); + } + + //Each player has 1000 points to give to the other builders. + //They are assigned based on a ratio of points given. + + //in a 5 player game, a player who gives everyone +0 will be giving everyone equally 250 Points + for (Player voter : _votes.keySet()) + { + //Gather Data + double votesCast = 0; + double voteTotal = 0; + + NautHashMap votes = _votes.get(voter); + + for (int vote : votes.values()) + { + votesCast++; + voteTotal += vote; + } + + AddGems(voter, (int)(voteTotal / 3), "Voting Fairly", false, false); + + double votesNotCast = (GetPlayers(true).size() - 1) - votesCast; + + double averageVote = 1; + if (votesCast > 0) + averageVote = voteTotal/votesCast; + + //This ensures that only 1000 points will be shared among builds + voteTotal += votesNotCast * averageVote; + + //Apply Points to builds + for (Player builder : _data.keySet()) + { + if (builder.equals(voter)) + continue; + + //If the voter didnt vote on this build, it will be given the average of their votes + double vote = averageVote; + if (votes.containsKey(builder)) + vote = votes.get(builder); + + double points = 1000d * (vote/voteTotal); + + _data.get(builder).addPoints(points); + +// System.out.println(voter.getName() + " = " + builder.getName() + " " + +// (votes.containsKey(builder) ? vote : "No Vote (" + averageVote + ")") + " ~ " + points); + } + + //System.out.println( " " ); + } + } + public boolean isBuildTime() { return _buildStateTime == 0; @@ -489,6 +590,11 @@ public class Build extends SoloGame Location loc = data.Spawn.clone().add(oX, 0, oZ); loc.setDirection(UtilAlg.getTrajectory(loc, data.Spawn)); + // This is supposed to be a quick fix for players being teleported into blocks + // I am not sure the exact cause of this bug, it seems to happen when there is a specific amount of players + if (loc.getBlock() != null && loc.getBlock().getType() != Material.AIR) + loc.setY(loc.getWorld().getHighestBlockYAt(loc) + 1); + UtilServer.getPlayers()[i].closeInventory(); UtilServer.getPlayers()[i].eject(); UtilServer.getPlayers()[i].leaveVehicle(); @@ -620,30 +726,33 @@ public class Build extends SoloGame if (!UtilTime.elapsed(_buildStateTime, 1500)) return; + if (!_votes.containsKey(event.getPlayer())) + _votes.put(event.getPlayer(), new NautHashMap()); + switch (event.getPlayer().getItemInHand().getData().getData()) { case 14: - _viewData.addScore(event.getPlayer(), 0); + _votes.get(event.getPlayer()).put(_viewData.Player, 1); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 1: - _viewData.addScore(event.getPlayer(), 1); + _votes.get(event.getPlayer()).put(_viewData.Player, 2); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 4: - _viewData.addScore(event.getPlayer(), 2); + _votes.get(event.getPlayer()).put(_viewData.Player, 3); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 5: - _viewData.addScore(event.getPlayer(), 3); + _votes.get(event.getPlayer()).put(_viewData.Player, 4); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 3: - _viewData.addScore(event.getPlayer(), 4); + _votes.get(event.getPlayer()).put(_viewData.Player, 5); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 10: - _viewData.addScore(event.getPlayer(), 5); + _votes.get(event.getPlayer()).put(_viewData.Player, 6); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; default: @@ -655,9 +764,11 @@ public class Build extends SoloGame public void playerQuit(PlayerQuitEvent event) { _data.remove(event.getPlayer()); - - for (BuildData data : _data.values()) - data.removeScore(event.getPlayer()); + + for (NautHashMap votedFor : _votes.values()) + votedFor.remove(event.getPlayer()); + + _votes.remove(event.getPlayer()); } @EventHandler @@ -678,6 +789,67 @@ public class Build extends SoloGame } } + @Override + @EventHandler + public void onHangingPlace(HangingPlaceEvent event) + { + Player player = event.getPlayer(); + if (_buildGameState == 0 && IsLive() && IsAlive(player)) + { + BuildData buildData = _data.get(player); + + if (buildData != null) + { + // Allow placing paintings and item frames in your own plot + if (buildData.inBuildArea(event.getBlock())) return; + } + } + + event.setCancelled(true); + } + + @Override + @EventHandler + public void onHangingBreak(HangingBreakEvent event) + { + if (event instanceof HangingBreakByEntityEvent) + { + HangingBreakByEntityEvent ev = ((HangingBreakByEntityEvent) event); + if (ev.getRemover() instanceof Player) + if (_buildGameState != 0 || !IsAlive(ev.getRemover())) + event.setCancelled(true); + } + } + + @Override + @EventHandler + public void onDamageHanging(EntityDamageEvent event) + { + if (!(event.getEntity() instanceof Hanging)) return; + + if (event instanceof EntityDamageByEntityEvent) + { + EntityDamageByEntityEvent ev = ((EntityDamageByEntityEvent) event); + + if (ev.getDamager() instanceof Player) + { + Player player = ((Player) ev.getDamager()); + + if (_buildGameState != 0 || !IsAlive(player)) + event.setCancelled(true); + } + } + else super.onDamageHanging(event); + } + + @EventHandler + public void preventRotateHanging(PlayerInteractEntityEvent event) + { + EntityType type = event.getRightClicked().getType(); + if (_buildGameState != 0 && (type == EntityType.PAINTING || type == EntityType.ITEM_FRAME)) + event.setCancelled(true); + } + @EventHandler public void potionThrow(ProjectileLaunchEvent event) { @@ -1032,9 +1204,7 @@ public class Build extends SoloGame { for (Entry score : _scoreboardPlaces) { - int percent = (int)(score.getValue() * 20); - - Scoreboard.Write(BuildQuality.getQuality(score.getValue()).getColor() + percent + "% " + ChatColor.RESET + score.getKey().getName()); + Scoreboard.Write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getName()); } } @@ -1241,7 +1411,7 @@ public class Build extends SoloGame @EventHandler public void openMobGui(PlayerInteractEntityEvent event) { - if (!IsLive() || !IsAlive(event.getPlayer())) return; + if (!IsLive() || !IsAlive(event.getPlayer()) || _buildGameState != 0) return; Player player = event.getPlayer(); BuildData buildData = _data.get(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java index 177277b8d..d1892ca79 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java @@ -57,7 +57,7 @@ public class BuildData public WeatherType Weather = WeatherType.SUNNY; - public NautHashMap Score = new NautHashMap(); + private double _totalPoints = 0; public BuildData(Player player, Location spawn, ArrayList buildBorders) { @@ -155,29 +155,6 @@ public class BuildData { Blocks.add(block); } - - public void addScore(Player player, int i) - { - Score.put(player, i); - } - - public void removeScore(Player player) - { - Score.remove(player); - } - - public double getScore() - { - if (Score.isEmpty()) - return -1; - - double score = 0; - - for (int i : Score.values()) - score += i; - - return score/(double)Score.size(); - } public boolean inBuildArea(Block block) { @@ -327,4 +304,19 @@ public class BuildData MapUtil.QuickChangeBlockAt(Player.getWorld(), x, y, z, mat, data); } } + + public void addPoints(double d) + { + _totalPoints += d; + } + + public double getPoints() + { + return _totalPoints; + } + + public void clearPoints() + { + _totalPoints = 0; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java index 78e1c1a42..f308f5227 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java @@ -26,13 +26,14 @@ public enum BuildQuality return _text; } - public static BuildQuality getQuality(double avgScore) + //1000 points is average, if everyone votes for everyone equally + public static BuildQuality getFinalQuality(double avgScore) { if (avgScore < 0) return NoVotes; - if (avgScore <= 1) return Failure; - if (avgScore <= 2) return Satisfactory; - if (avgScore <= 3) return Good; - if (avgScore <= 4) return Awesome; + if (avgScore <= 400) return Failure; + if (avgScore <= 800) return Satisfactory; + if (avgScore <= 1200) return Good; + if (avgScore <= 1600) return Awesome; return Mindblowing; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/GroundPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/GroundPage.java index bd4a56350..369b13f2c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/GroundPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/GroundPage.java @@ -32,7 +32,8 @@ public class GroundPage extends ShopPageBase new GroundData(Material.STAINED_CLAY, (byte) 0), new GroundData(Material.STAINED_CLAY, (byte) 15), new GroundData(Material.STAINED_CLAY, (byte) 4), new GroundData(Material.STAINED_CLAY, (byte) 3), new GroundData(Material.STAINED_CLAY, (byte) 5), new GroundData(Material.STAINED_CLAY, (byte) 6), - new GroundData(Material.QUARTZ_BLOCK)}; + new GroundData(Material.QUARTZ_BLOCK), new GroundData(Material.ICE), new GroundData(Material.IRON_BLOCK), + new GroundData(Material.GOLD_BLOCK), new GroundData(Material.DIAMOND_BLOCK)}; private Build _game; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java index 8c3c0c3ab..bf0395491 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.build.gui.page; +import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; import org.bukkit.entity.Ageable; @@ -7,14 +9,12 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; +import org.bukkit.entity.Villager; import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.meta.SkullMeta; import mineplex.core.account.CoreClientManager; -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.donation.DonationManager; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; @@ -38,37 +38,18 @@ public class MobPage extends ShopPageBase buildPage(); } + private String format(String s) + { + return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); + } + @Override protected void buildPage() { -// byte entityData = UtilSkull.getSkullData(_entity); - - // Add Skull delete button final String entityName = _entity.getType().getName(); -// ShopItem head = new ShopItem(Material.SKULL_ITEM, entityData, entityName, new String[] {C.cGray + "Right Click to Delete Entity" }, 0, false, false); -// if (UtilSkull.isPlayerHead(entityData)) -// { -// SkullMeta meta = ((SkullMeta) head.getItemMeta()); -// meta.setOwner(UtilSkull.getPlayerHeadName(_entity)); -// head.setItemMeta(meta); -// } + int buttonSlot = 0; -// addButton(4, head, new IButton() -// { -// @Override -// public void onClick(Player player, ClickType clickType) -// { -// if (clickType == ClickType.RIGHT) -// { -// _buildData.removeEntity(_entity); -// UtilPlayer.message(player, F.main("Game", "Entity Deleted")); -// player.closeInventory(); -// } -// } -// }); - - - int buttonSlot = 1; + // Set Baby if (_entity instanceof Ageable) { final Ageable ageable = ((Ageable) _entity); @@ -84,14 +65,14 @@ public class MobPage extends ShopPageBase else ageable.setAdult(); - UtilPlayer.message(player, F.main("Game", entityName + " is now a " + (ageable.isAdult() ? "Adult" : "Baby"))); + UtilPlayer.message(player, F.main("Game", entityName + " is now an " + (ageable.isAdult() ? "Adult" : "Baby"))); buildPage(); } }); - buttonSlot+= 2; } + // Enable/Disable Ghosting if (_entity instanceof LivingEntity) { final LivingEntity livingEntity = ((LivingEntity) _entity); @@ -108,17 +89,15 @@ public class MobPage extends ShopPageBase buildPage(); } }); - - buttonSlot += 2; } + // Increase and Decrease Slime Size if (_entity instanceof Slime) { final Slime slime = ((Slime) _entity); ShopItem decreaseSize = new ShopItem(Material.CLAY_BALL, "Decrease Size", null, 0, false, false); - ShopItem increaseSize = new ShopItem(Material.CLAY, "Increase Size", null, 0, false, false); addButton(buttonSlot, decreaseSize, new IButton() @@ -136,7 +115,6 @@ public class MobPage extends ShopPageBase } } }); - buttonSlot += 2; addButton(buttonSlot, increaseSize, new IButton() @@ -154,20 +132,69 @@ public class MobPage extends ShopPageBase } } }); + buttonSlot += 2; } + // Change Villager Profession + if (_entity instanceof Villager) + { + final Villager villager = ((Villager) _entity); + ShopItem shopItem = new ShopItem(Material.DIAMOND_PICKAXE, "Change Profession", new String[] { " ", ChatColor.GRAY + "Currently " + format(villager.getProfession().name()) }, 0, false); + addButton(buttonSlot, shopItem, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + Villager.Profession next = + Villager.Profession.values()[(villager.getProfession().ordinal() + 1) % Villager.Profession.values().length]; + villager.setProfession(next); + UtilPlayer.message(player, F.main("Game", "Villager is now a " + format(next.name()))); + buildPage(); + } + }); + buttonSlot += 2; + } + + // Entity look at player (Currently Bugged) + if (_entity instanceof LivingEntity) + { + ShopItem lookAtMe = new ShopItem(Material.GHAST_TEAR, "Look at Me", null, 0, false); + addButton(buttonSlot, lookAtMe, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + final Location newLoc = _entity.getLocation(); + newLoc.setDirection(player.getLocation().getDirection().multiply(-1)); + + ((CraftLivingEntity) _entity).getHandle().setPositionRotation(newLoc.getX(), newLoc.getY(), newLoc.getZ(), newLoc.getYaw(), newLoc.getPitch()); + ((CraftLivingEntity) _entity).getHandle().g(0.05, 0.0, 0.05); + + getPlugin().runSyncLater(new Runnable() + { + @Override + public void run() + { + _entity.teleport(newLoc); + } + }, 1L); + + UtilPlayer.message(player, F.main("Game", entityName + " is now looking at you")); + } + }); + buttonSlot += 2; + } + + // Delete Entity ShopItem deleteButton = new ShopItem(Material.TNT, "Delete " + entityName, null, 0, false); addButton(8, deleteButton, new IButton() { @Override public void onClick(Player player, ClickType clickType) { - if (clickType == ClickType.RIGHT) - { - _buildData.removeEntity(_entity); - UtilPlayer.message(player, F.main("Game", "Entity Deleted")); - player.closeInventory(); - } + _buildData.removeEntity(_entity); + UtilPlayer.message(player, F.main("Game", "Entity Deleted")); + player.closeInventory(); } }); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java new file mode 100644 index 000000000..ac0f3834d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java @@ -0,0 +1,66 @@ +package nautilus.game.arcade.game.games.cards; + +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; +import mineplex.core.map.MapText; + +public class CardFactory +{ + private MapText _mapText; + + public CardFactory() + { + _mapText = new MapText(); + } + + private String[] _questions = new String[] + { + "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thanks to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", + + }; + + private String[] _answers = new String[] + { + "A Stinky Pig Butt", "Mouldy Raw Fish", "A sawed off 10-foot pole", "billions of diamonds", "A whiny forum post", "Sparkling Diamonds", "Sheep that don’t know when to stop", "Villager Legs", "Curdled cow milk", "That one popcorn piece stuck in your teeth.", "THE DIAMOND DANCE!", "an unstoppable addiction to fly hacks", "the biggest pile of poop you've ever seen!", "Bed time", "A bag of Doritos and a Mountain Dew.", "zombies chewing on my butt", "Jazz hands", "Brain surgery", "A disappointing birthday party.", "Overly friendly Iron Golems", "An Endermans favourite block", "Puppies!", "your friend who deleted you from Skype", "being on fire", "two cows stealing your wallet", "a lifetime of sadness", "a golden notch apple", "dragon eggs", "holding hands", "kissing", "wearing parents on your head", "soup that is too hot", "edible underpants", "people who are terrible at PvP", "obesity", "sheep eating potatoes", "my collection of spider eyes", "oversized fishing rods", "working as a team", "horse meat", "zombies screaming while on fire", "a ghast calling her dad to say happy birthday", "Microsoft releasing a good game", "bad childhood memories", "a bad haircut", "a steamy locker room", "armed robbery", "bankruptcy", "stacks of TNT", "a block of dirt", "cold pizza", "a pack of angry wolves", "eternal sadness", "the Nether", "a blaze having a barbeque", "Endermen robbing your house", "dental surgery", "religious villagers", "poor villagers", "flesh-eating bacteria", "the drive to win", "friends who take all your loot", "Morgan Freeman", "Darth Vader", "Villager #17", "Barrack Obama", "Lady Gaga", "That one hobo that lives down the street", "A Sad Creeper", "Parker Games", "A shaved sheep", "CaptainSparklez", "DanTDM", "SkyDoesMinecraft", "Mineplex", "A Mineplex Administrator", "Miley Cyrus", "Notch", "Mojang", "Pikachu", "BATMAN!!!", "The Hulk", "Justin Beiber", "Herobrine", "Pirates", "Vikings", "Ninjas", "Uncontrollably pooping", "Dancing until a helper warned me", "Making passive aggressive tweets", "complaining about balance on the forums", "Chopping down the mineplex lobby tree", "crashing servers", "falling off a cliff", "Realizing that you arent actually a ninja.", "Eating a hot pepper", "Digging straight down", "using xray hacks", "picking your nose", "Playing against a team in SSM", "Mining diamond with a stone pickaxe", "stepping on Legos", "Shaking it off", "Watching Parker games", "Accidentally hiding an egg as Easter bunny morph", "doing a poop and realizing there is no toilet paper", "Eating rotten flesh", "Understanding how magnets work", "watching videos on YouTube", "finding Legendary loot in a Treasure Chest", "Doing homework", "dividing by 0", "Finding out the meaning of life", "banning players for no reason", "dying", "so angry that he pooped himself.", "spending hours planting carrots", "doing the right thing", "sleeping in a cave", "getting drunk on potions", "trolling on the internet", "punching a tree", "leaving a stinky surprise", "doing math", "being devoured by zombie pigmen", "farting and walking away", "sneakily doing a poop", "blowing everything up with TNT", "peeing a little bit", "Tweeting about cats", "reading the instructions carefully", + "leaving some poop in the corner of the room", "eating a balanced breakfast", "puking", "shooting arrows at bats", "typing /kill", "watching Frozen repeatedly", "building a house out of dirt", "winking at chickens", "yelling at a toaster", "putting in 110% effort", "paying a lot of money", "bribing with candy", "throwing rocks at people", "crying until everything is better" + }; + + public String getQuestionCard() + { + return _questions[UtilMath.r(_questions.length)]; + } + + public String getAnswerCard() + { + return _answers[UtilMath.r(_answers.length)]; + } + + public ItemStack getAnswerStack() + { + String text = getAnswerCard(); + + ItemStack stack = _mapText.getMap(true, text); + + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(C.cGreen + text); + stack.setItemMeta(meta); + + return stack; + } + + public ItemStack getQuestionStack() + { + String text = getQuestionCard(); + + ItemStack stack = _mapText.getMap(true, text); + + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(C.cYellow + text); + stack.setItemMeta(meta); + + return stack; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java new file mode 100644 index 000000000..07e2ab006 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java @@ -0,0 +1,271 @@ +package nautilus.game.arcade.game.games.cards; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.GameScore; +import nautilus.game.arcade.game.games.cards.kits.KitPlayer; +import nautilus.game.arcade.kit.Kit; + +public class Cards extends SoloGame +{ + private CardFactory _cardFactory; + + private ArrayList _ranks = new ArrayList(); + + private NautHashMap _voteRooms = new NautHashMap(); + + private Location _questionLoc = null; + private ItemFrame _questionEnt = null; + + private RoundState _roundState = RoundState.View; + private long _roundStateTime = 0; + private Player _roundDealer = null; + + private String _question = null; + + private long _playTime = 16000; + private long _judgeTime = 16000; + private long _viewTime = 6000; + + private ArrayList _dealerOrder = new ArrayList();; + + public Cards(ArcadeManager manager) + { + super(manager, GameType.Cards, + + new Kit[] + { + new KitPlayer(manager), + }, + + new String[] + { + "Be creative and build something", + "based on the build theme!" + }); + + this.StrictAntiHack = true; + this.Damage = false; + this.HungerSet = 20; + this.HealthSet = 20; + + this.WorldTimeSet = 6000; + + this.PrepareFreeze = false; + + _cardFactory = new CardFactory(); + } + + @Override + public void ParseData() + { + for (Location loc : WorldData.GetDataLocs("RED")) loc.getBlock().setType(Material.OBSIDIAN); + for (Location loc : WorldData.GetDataLocs("ORANGE")) loc.getBlock().setType(Material.OBSIDIAN); + for (Location loc : WorldData.GetDataLocs("GREEN")) loc.getBlock().setType(Material.OBSIDIAN); + + + _questionLoc = WorldData.GetDataLocs("PINK").get(0); + _questionLoc.getBlock().setType(Material.OBSIDIAN); + } + + @EventHandler + public void prepare(PlayerPrepareTeleportEvent event) + { + for (int i=0 ; i<9 ; i++) + { + event.GetPlayer().getInventory().addItem(_cardFactory.getAnswerStack()); + } + + _dealerOrder.add(event.GetPlayer()); + + //Prep Vote Room + _voteRooms.put(event.GetPlayer(), new VoteRoom( + WorldData.GetDataLocs("YELLOW").remove(0), + WorldData.GetDataLocs("ORANGE"), + WorldData.GetDataLocs("GREEN"), + WorldData.GetDataLocs("RED"))); + + addScore(event.GetPlayer(), 0); + } + + @EventHandler + public void roundStateUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_roundState == RoundState.PlaceCards && UtilTime.elapsed(_roundStateTime, _playTime)) + { + setRoundState(RoundState.Judge); + } + else if (_roundState == RoundState.Judge && UtilTime.elapsed(_roundStateTime, _judgeTime)) + { + setRoundState(RoundState.View); + } + else if (_roundState == RoundState.View && UtilTime.elapsed(_roundStateTime, _viewTime)) + { + setRoundState(RoundState.PlaceCards); + } + } + + public void setRoundState(RoundState state) + { + _roundStateTime = System.currentTimeMillis(); + _roundState = state; + + if (state == RoundState.PlaceCards) + { + + //Get Dealer + _roundDealer = _dealerOrder.remove(0); + _dealerOrder.add(_roundDealer); + + //New Question + ItemStack questionStack = _cardFactory.getQuestionStack(); + + if (_questionEnt != null) + { + _questionEnt.remove(); + _questionEnt = null; + } + + _questionEnt = _questionLoc.getWorld().spawn(_questionLoc.getBlock().getLocation(), ItemFrame.class); + _questionEnt.setItem(questionStack); + + //Teleport Players to Card Room + for (Player player : _voteRooms.keySet()) + { + VoteRoom room = _voteRooms.get(player); + + room.resetFrames(false); + + if (player.equals(_roundDealer)) + continue; + + player.teleport(room.Spawn); + + room.QuestionEnt.setItem(questionStack); + } + } + else if (state == RoundState.Judge) + { + GetTeamList().get(0).SpawnTeleport(); + + int i=0; + for (VoteRoom room : _voteRooms.values()) + { + room.displayAnswer(); + } + } + } + + public void addScore(Player player, double amount) + { + for (GameScore score : _ranks) + { + if (score.Player.equals(player)) + { + score.Score += amount; + EndCheck(); + return; + } + } + + _ranks.add(new GameScore(player, amount)); + + sortScores(); + } + + private void sortScores() + { + for (int i=0 ; i<_ranks.size() ; i++) + { + for (int j=_ranks.size()-1 ; j>0 ; j--) + { + if (_ranks.get(j).Score > _ranks.get(j-1).Score) + { + GameScore temp = _ranks.get(j); + _ranks.set(j, _ranks.get(j-1)); + _ranks.set(j-1, temp); + } + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + writeScoreboard(); + } + + public void writeScoreboard() + { + //Wipe Last + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + if (_roundState == RoundState.PlaceCards) + { + Scoreboard.Write(C.cYellow + C.Bold + "Select Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _playTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellow + C.Bold + "Judge"); + Scoreboard.Write(C.cWhite + _roundDealer.getName()); + } + else if (_roundState == RoundState.Judge) + { + Scoreboard.Write(C.cYellow + C.Bold + "Judge Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _judgeTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellow + C.Bold + "Judge"); + Scoreboard.Write(C.cWhite + _roundDealer.getName()); + } + else if (_roundState == RoundState.View) + { + Scoreboard.Write(C.cYellow + C.Bold + "View Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _viewTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + } + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Round Wins"); + for (GameScore score : _ranks) + { + Scoreboard.Write((int)score.Score + " " + C.Bold + score.Player.getName()); + } + + + Scoreboard.Draw(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/RoundState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/RoundState.java new file mode 100644 index 000000000..1bce0902c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/RoundState.java @@ -0,0 +1,8 @@ +package nautilus.game.arcade.game.games.cards; + +public enum RoundState +{ + PlaceCards, + Judge, + View, +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/VoteRoom.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/VoteRoom.java new file mode 100644 index 000000000..264d4f45b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/VoteRoom.java @@ -0,0 +1,86 @@ +package nautilus.game.arcade.game.games.cards; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilAlg; + +import org.bukkit.Location; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.ItemFrame; + +public class VoteRoom +{ + public Location Spawn; + public Location Question; + public Location AnswerA; + public Location AnswerB; + + public ItemFrame QuestionEnt; + public ItemFrame AnswerAEnt; + public ItemFrame AnswerBEnt; + + public Location BoardAnswer; + public ItemFrame BoardAnswerEnt; + + public VoteRoom(Location spawn, ArrayList questions, ArrayList answers, ArrayList board) + { + Spawn = spawn; + + Question = UtilAlg.findClosest(spawn, questions); + questions.remove(Question); + + AnswerA = UtilAlg.findClosest(Question, answers); + answers.remove(AnswerA); + + AnswerB = UtilAlg.findClosest(Question, answers); + answers.remove(AnswerB); + + BoardAnswer = UtilAlg.findClosest(Question, board); + board.remove(BoardAnswer); + } + + public void resetFrames(boolean doubleAnswer) + { + if (QuestionEnt != null) + { + QuestionEnt.remove(); + QuestionEnt = null; + } + + if (AnswerAEnt != null) + { + AnswerAEnt.remove(); + AnswerAEnt = null; + } + + if (AnswerBEnt != null) + { + AnswerBEnt.remove(); + AnswerBEnt = null; + } + + if (BoardAnswerEnt != null) + { + BoardAnswerEnt.remove(); + BoardAnswerEnt = null; + } + + QuestionEnt = Question.getWorld().spawn(Question.getBlock().getLocation(), ItemFrame.class); + AnswerAEnt = AnswerA.getWorld().spawn(AnswerA.getBlock().getLocation(), ItemFrame.class); + BoardAnswerEnt = BoardAnswer.getWorld().spawn(BoardAnswer.getBlock().getLocation(), ItemFrame.class); + +// if (doubleAnswer) +// AnswerBEnt = AnswerB.getWorld().spawn(AnswerB, ItemFrame.class); + +// i.setFacingDirection(BlockFace.SOUTH); +// HangingPlaceEvent hEvent = new HangingPlaceEvent(i, player, bodyBlock, BlockFace.NORTH); +// plugin.getServer().getPluginManager().callEvent(hEvent); + } + + public void displayAnswer() + { + System.out.println(BoardAnswerEnt == null); + System.out.println(AnswerAEnt == null); + BoardAnswerEnt.setItem(AnswerAEnt.getItem()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/kits/KitPlayer.java new file mode 100644 index 000000000..2e078e7a6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/kits/KitPlayer.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.cards.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitPlayer extends Kit +{ + public KitPlayer(ArcadeManager manager) + { + super(manager, "Player", KitAvailability.Free, + + new String[] + { + ";dsgoasdyay" + }, + + new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.MAP)); + + } + + @Override + public void GiveItems(Player player) + { + + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index a3b8b3edd..f7eb0d360 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -66,6 +66,8 @@ public class ChampionsDominate extends Domination EloRanking = false; EloStart = 1000; + this.DontAllowOverfill = true; + this.DisableKillCommand = false; registerStatTrackers( diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index 490688277..cc414be9b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -65,6 +65,8 @@ public class ChampionsTDM extends TeamDeathmatch InventoryOpenChest = true; this.DisableKillCommand = false; + + this.DontAllowOverfill = true; registerStatTrackers( new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 1b5bd2003..bed10c978 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -28,8 +28,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; @@ -48,7 +46,6 @@ 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.Game.GameState; import nautilus.game.arcade.game.games.GameScore; import nautilus.game.arcade.game.games.draw.kits.*; import nautilus.game.arcade.game.games.draw.tools.*; @@ -111,15 +108,15 @@ public class Draw extends SoloGame this.WorldTimeSet = 8000; _words = new String[] - { - "Bird", "Volcano", "Sloth", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Leash", "Magic", "Wizard", "Igloo", "Plant", "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", "Cheese", "Beans", "Water", "Chicken", "Cannibal", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", "Tomato", "Alcohol", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin", - }; - + { + "Bird", "Volcano", "Sloth", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Leash", "Magic", "Wizard", "Igloo", "Plant", "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", "Cheese", "Beans", "Water", "Chicken", "Cannibal", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", "Tomato", "Alcohol", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar", "Book", + }; + _tools = new HashSet(); _tools.add(new ToolLine(this)); _tools.add(new ToolSquare(this)); _tools.add(new ToolCircle(this)); - + registerStatTrackers( new MrSquiggleStatTracker(this), new KeenEyeStatTracker(this), @@ -302,28 +299,48 @@ public class Draw extends SoloGame return; Player player = event.getPlayer(); - - if (event.getMessage().toLowerCase().contains(_round.Word.toLowerCase())) + + if (_guessers.HasPlayer(player)) { - if (_guessers.HasPlayer(player)) + int wordsInMessage = 0; + String message = event.getMessage().toLowerCase().replace(_round.Word.toLowerCase(), "");; + + for (String word : _words) { - //First Guess + if (message.contains(word.toLowerCase())) + { + message = message.replace(word.toLowerCase(), ""); + + if (++wordsInMessage >= 3) + { + UtilPlayer.message(player, F.main("Game", "Multiple guesses are not allowed!")); + + event.setCancelled(true); + return; + } + } + } + + if (event.getMessage().toLowerCase().contains(_round.Word.toLowerCase())) + { + // First Guess int score = 1; if (_round.Guessed.isEmpty()) { score = 3; - - //Points for Drawer + + // Points for Drawer AddScore(_round.Drawer, 2); - + this.AddGems(_round.Drawer, 2, "Drawings Guessed", true, true); } - + if (_round.Guessed(player)) { AddScore(player, score); - Announce(C.cYellow + C.Bold + "+" + score + " " + C.cGreen + C.Bold + player.getName() + " has guessed the word!"); - + Announce(C.cYellow + C.Bold + "+" + score + " " + C.cGreen + C.Bold + player.getName() + + " has guessed the word!"); + if (score == 1) this.AddGems(player, 1, "Words Guessed", true, true); else @@ -333,10 +350,10 @@ public class Draw extends SoloGame { UtilPlayer.message(player, F.main("Game", "You have already guessed the word!")); } - } - event.setCancelled(true); - return; + event.setCancelled(true); + return; + } } } 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 b5ed70c5a..2cf41e397 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 @@ -78,7 +78,7 @@ import nautilus.game.arcade.managers.GameHostManager; public class EventGame extends SoloGame { - private GameHostManager _mps; + private GameHostManager _mps; private String[] _sideText = new String[] { " "," "," "," "," "," "," "," "," "," "," "," " @@ -89,7 +89,7 @@ public class EventGame extends SoloGame private NautHashMap _forcefield = new NautHashMap(); private ItemStack[] _kitItems = new ItemStack[6]; - + private boolean _allowAllGadgets = false; private HashSet _gadgetWhitelist = new HashSet(); @@ -176,38 +176,40 @@ public class EventGame extends SoloGame private void commandHelp(Player player) { UtilPlayer.message(player, F.main("Event", "Displaying Commands;")); - + UtilPlayer.message(player, F.value("/e settings", "View Settings Help")); - + UtilPlayer.message(player, F.value("/e tp ", "Teleport to Target")); UtilPlayer.message(player, F.value("/e tp here ", "Teleport Target to Self")); UtilPlayer.message(player, F.value("/e tp here all", "Teleport Everyone to Self")); - + UtilPlayer.message(player, F.value("/e gadget", "Toggle Gadgets")); UtilPlayer.message(player, F.value("/e gadget list", "Lists Gadgets (Shows Whitelist)")); UtilPlayer.message(player, F.value("/e gadget ", "Toggles Whitelist for Gadget")); UtilPlayer.message(player, F.value("/e gadget clear", "Clears Gadget Whitelist")); - + UtilPlayer.message(player, F.value("/e silence [Time]", "Silence Chat")); - + + UtilPlayer.message(player, F.value("/e admin [Player]", "Toggle Event Admin")); + UtilPlayer.message(player, F.value("/e gm [Player]", "Toggle Creative Mode")); - + UtilPlayer.message(player, F.value("/e radius [Radius]", "Set Forcefield Radius")); - UtilPlayer.message(player, F.value("/e give ", "Give Item to Self")); - UtilPlayer.message(player, F.value("/e give ", "Give Item to Player")); + UtilPlayer.message(player, F.value("/e give ", "Give Item")); + 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 scoreboard [Text]", "Sets Scoreboard Text")); - + UtilPlayer.message(player, F.value("/e mob [#Amount] n[Name] s[Size] [angry] [baby]", "")); UtilPlayer.message(player, F.value("/e mob kill ", "Kill Mobs")); - + UtilPlayer.message(player, F.value("/e kit set", "Sets Player Kit to your Hotbar")); UtilPlayer.message(player, F.value("/e kit apply", "Gives Kit to Players")); UtilPlayer.message(player, F.value("/e kit clear", "Gives Kit to Players")); - + UtilPlayer.message(player, F.value("/e effect ", "")); UtilPlayer.message(player, F.value("/e effect clear", "")); } @@ -276,6 +278,10 @@ public class EventGame extends SoloGame { commandSilence(event.getPlayer(), args); } + else if (args[0].equalsIgnoreCase("admin")) + { + commandAdmin(event.getPlayer(), args); + } else if (args[0].equalsIgnoreCase("gm")) { commandGamemode(event.getPlayer(), args); @@ -590,7 +596,7 @@ public class EventGame extends SoloGame commandHelpSettings(player); } - + private void commandTime(Player player, String[] args) { try @@ -680,32 +686,32 @@ public class EventGame extends SoloGame Announce(F.main("Inventory", F.value("Allow All Gadgets", F.ed(_allowAllGadgets)))); return; } - + if (args.length >= 2 && args[1].equalsIgnoreCase("clear")) { _gadgetWhitelist.clear(); Announce(F.main("Inventory", F.value("Gadget Whitelist", "Cleared."))); return; } - + if (args.length >= 2 && args[1].equalsIgnoreCase("list")) { ChatColor color = ChatColor.AQUA; - + //Gadgets for (GadgetType type : GadgetType.values()) { String items = C.Bold + type + " Gadgets> "; - + for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type)) { items += color + gadget.GetName().replaceAll(" ", "") + " "; color = (color == ChatColor.AQUA ? ChatColor.DARK_AQUA : ChatColor.AQUA); } - + UtilPlayer.message(player, items); } - + //Mounts String mounts = C.Bold + "Mount Gadgets> "; for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) @@ -714,10 +720,10 @@ public class EventGame extends SoloGame color = (color == ChatColor.AQUA ? ChatColor.DARK_AQUA : ChatColor.AQUA); } UtilPlayer.message(player, mounts); - + return; } - + if (args.length >= 2) { //Gadgets @@ -737,12 +743,12 @@ public class EventGame extends SoloGame Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget", F.ed(true)))); _gadgetWhitelist.add(gadget); } - + return; } } } - + //Mounts for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) { @@ -758,16 +764,16 @@ public class EventGame extends SoloGame Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget", F.ed(true)))); _gadgetWhitelist.add(mount); } - + return; } } - + UtilPlayer.message(player, F.main("Inventory", args[1] + " is not a valid gadget.")); - + return; } - + commandHelp(player); } @@ -804,6 +810,28 @@ public class EventGame extends SoloGame } } + //Gamemode (Self and Others) + private void commandAdmin(Player player, String[] args) + { + Player target = player; + + if (args.length >= 2) + { + Player newTarget = UtilPlayer.searchOnline(player, args[1], true); + if (newTarget != null) + target = newTarget; + else + return; + } + + if (!Manager.GetGameHostManager().isAdmin(target, false)) + Manager.GetGameHostManager().giveAdmin(target); + else + Manager.GetGameHostManager().removeAdmin(target.getName()); + + UtilPlayer.message(player, F.main("Event Admin", target.getName() + " Admin: " + F.tf(Manager.GetGameHostManager().isAdmin(target, false)))); + } + //Gamemode (Self and Others) private void commandGamemode(Player player, String[] args) { @@ -856,13 +884,13 @@ public class EventGame extends SoloGame private void commandGive(Player player, String[] args) { String[] newArgs = new String[args.length-1]; - + for (int i=0 ; i= 2 && args[1].equalsIgnoreCase("apply")) { for (Player player : UtilServer.getPlayers()) giveItems(player); - + Announce(F.main("Event Settings", F.value("Player Kit", "Applied to Players"))); return; } - + if (args.length >= 2 && args[1].equalsIgnoreCase("clear")) { - _kitItems = new ItemStack[6]; - Announce(F.main("Event Settings", F.value("Player Kit", "Cleared Kit"))); + _kitItems = new ItemStack[6]; + Announce(F.main("Event Settings", F.value("Player Kit", "Cleared Kit"))); return; } - + if (args.length >= 2 && args[1].equalsIgnoreCase("set")) { - _kitItems = new ItemStack[6]; - - for (int i=0 ; i<6 ; i++) - { - if (caller.getInventory().getItem(i) != null) - _kitItems[i] = caller.getInventory().getItem(i).clone(); - else - _kitItems[i] = null; - } - - Announce(F.main("Event Settings", F.value("Player Kit", "Updated Items"))); - return; + _kitItems = new ItemStack[6]; + + for (int i=0 ; i<6 ; i++) + { + if (caller.getInventory().getItem(i) != null) + _kitItems[i] = caller.getInventory().getItem(i).clone(); + else + _kitItems[i] = null; + } + + Announce(F.main("Event Settings", F.value("Player Kit", "Updated Items"))); + return; } - + commandHelp(caller); } - + private void commandEffect(Player caller, String[] args) { //Clear @@ -1302,12 +1330,12 @@ public class EventGame extends SoloGame if (targets.isEmpty()) return; } - + for (Player player : targets) { //Remove all conditions Manager.GetCondition().EndCondition(player, null, null); - + //Remove all effects player.removePotionEffect(PotionEffectType.ABSORPTION); player.removePotionEffect(PotionEffectType.BLINDNESS); @@ -1333,10 +1361,10 @@ public class EventGame extends SoloGame player.removePotionEffect(PotionEffectType.WEAKNESS); player.removePotionEffect(PotionEffectType.WITHER); } - + return; } - + //Apply if (args.length >= 5) { @@ -1354,7 +1382,7 @@ public class EventGame extends SoloGame if (targets.isEmpty()) return; } - + //Get Type PotionEffectType type = PotionEffectType.getByName(args[2]); if (type == null) @@ -1363,7 +1391,7 @@ public class EventGame extends SoloGame UtilPlayer.message(caller, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect")); return; } - + //Get Multiplier int mult = 0; try @@ -1380,7 +1408,7 @@ public class EventGame extends SoloGame UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Level: " + args[3])); return; } - + //Get Duration int dur = 0; try @@ -1395,25 +1423,25 @@ public class EventGame extends SoloGame UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Duration: " + args[4])); return; } - + //Apply PotionEffect effect = new PotionEffect(type, dur*20, mult); for (Player cur : targets) { cur.addPotionEffect(effect); } - + if (args[1].equalsIgnoreCase("all")) Announce(F.main("Effect", F.value("Applied Effect", type.getName() + " " + (mult+1) + " for " + dur + "s"))); else UtilPlayer.message(caller, F.main("Effect", "Applied " + type.getName() + " " + (mult+1) + " for " + dur + "s for Targets.")); - + return; } - + commandHelp(caller); } - + @EventHandler public void doubleJumpTrigger(PlayerToggleFlightEvent event) { @@ -1500,7 +1528,7 @@ public class EventGame extends SoloGame if (_mps.isAdmin(other, false)) continue; - + int range = _forcefield.get(player.getName()); if (UtilMath.offset(other, player) > range) @@ -1613,10 +1641,10 @@ public class EventGame extends SoloGame { if (_kitItems[i] == null) continue; - + player.getInventory().addItem(_kitItems[i].clone()); } - + UtilInv.Update(player); } @@ -1626,13 +1654,13 @@ public class EventGame extends SoloGame if (event.getSpawnReason() != SpawnReason.CUSTOM) event.setCancelled(true); } - + @EventHandler public void gadgetDisable(GadgetActivateEvent event) { if (_allowAllGadgets) return; - + if (!_gadgetWhitelist.contains(event.getGadget())) { event.setCancelled(true); @@ -1640,13 +1668,13 @@ public class EventGame extends SoloGame //event.getPlayer().closeInventory(); } } - + @EventHandler public void mountDisable(MountActivateEvent event) { if (_allowAllGadgets) return; - + if (!_gadgetWhitelist.contains(event.getMount())) { event.setCancelled(true); @@ -1654,7 +1682,7 @@ public class EventGame extends SoloGame //event.getPlayer().closeInventory(); } } - + @EventHandler(priority = EventPriority.HIGHEST) public void entityDeathEvent(EntityDeathEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java index 3858e54c8..8d03a03a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -120,6 +120,8 @@ public class Halloween extends SoloGame //this.HungerSet = 20; this.WorldBoundaryKill = false; + + this.DontAllowOverfill = true; } @Override 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 c4f5a47ed..cfc70dab1 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 @@ -262,6 +262,8 @@ public class MineStrike extends TeamGame this.JoinInProgress = true; this.VersionRequire1_8 = true; + + this.DontAllowOverfill = true; _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index 488896052..5343d64f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -15,11 +15,13 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.itemstack.ItemStackFactory; @@ -46,6 +48,8 @@ public class SnowFight extends TeamGame { "Just like... kill your enemies. with snow." }); + + this.HungerSet = 20; } @@ -80,11 +84,12 @@ public class SnowFight extends TeamGame if (!IsSnow(event.getBlock())) return; - if (player.getInventory().getHeldItemSlot() != 0) + + if (UtilInv.contains(player, Material.SNOW_BALL, (byte)0, 16)) return; //Item - SnowballCount(player, 1); + UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); //Snow Height SnowDecrease(event.getBlock(), 1); @@ -93,83 +98,83 @@ public class SnowFight extends TeamGame event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, 80); } - @EventHandler - public void InteractSnowball(PlayerInteractEvent event) - { - Player player = event.getPlayer(); +// @EventHandler +// public void InteractSnowball(PlayerInteractEvent event) +// { +// Player player = event.getPlayer(); +// +// if (!IsLive()) +// return; +// +// if (!IsPlaying(player)) +// return; +// +// if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL)) +// return; +// +// event.setCancelled(true); +// +// if (UtilEvent.isAction(event, ActionType.L)) +// SnowballThrow(player); +// +// else if (UtilEvent.isAction(event, ActionType.R_BLOCK)) +// SnowballPlace(player, event.getClickedBlock(), 1); +// } +// +// private void SnowballPlace(Player player, Block block, int above) +// { +// if (block.getTypeId() == 78 || UtilBlock.airFoliage(block)) +// { +// //Build +// if (block.getTypeId() == 78) +// { +// block.setTypeIdAndData(78, (byte)(block.getData() + 1), true); +// +// if (block.getData() >= 7) +// block.setTypeIdAndData(80, (byte)0, true); +// } +// else +// { +// block.setTypeIdAndData(78, (byte)0, true); +// } +// +// //Sound +// block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, 0.6f); +// +// //Use Snow +// SnowballCount(player, -1); +// } +// else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0) +// { +// SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1); +// } +// } +// +// private void SnowballThrow(Player player) +// { +// //Throw +// player.launchProjectile(Snowball.class); +// +// //Use Snow +// SnowballCount(player, -1); +// +// //Sound +// player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, 1.5f); +// } - if (!IsLive()) - return; - - if (!IsPlaying(player)) - return; - - if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL)) - return; - - event.setCancelled(true); - - if (UtilEvent.isAction(event, ActionType.L)) - SnowballThrow(player); - - else if (UtilEvent.isAction(event, ActionType.R_BLOCK)) - SnowballPlace(player, event.getClickedBlock(), 1); - } - - private void SnowballPlace(Player player, Block block, int above) - { - if (block.getTypeId() == 78 || UtilBlock.airFoliage(block)) - { - //Build - if (block.getTypeId() == 78) - { - block.setTypeIdAndData(78, (byte)(block.getData() + 1), true); - - if (block.getData() >= 7) - block.setTypeIdAndData(80, (byte)0, true); - } - else - { - block.setTypeIdAndData(78, (byte)0, true); - } - - //Sound - block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, 0.6f); - - //Use Snow - SnowballCount(player, -1); - } - else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0) - { - SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1); - } - } - - private void SnowballThrow(Player player) - { - //Throw - player.launchProjectile(Snowball.class); - - //Use Snow - SnowballCount(player, -1); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, 1.5f); - } - - private void SnowballCount(Player player, int count) - { - if (player.getInventory().getItem(1) != null) - count += player.getInventory().getItem(1).getAmount(); - - if (count > 16) - count = 16; - - if (count > 0) - player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count)); - else - player.getInventory().setItem(1, null); - } +// private void SnowballCount(Player player, int count) +// { +// if (player.getInventory().getItem(1) != null) +// count += player.getInventory().getItem(1).getAmount(); +// +// if (count > 16) +// count = 16; +// +// if (count > 0) +// player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count)); +// else +// player.getInventory().setItem(1, null); +// } private void SnowDecrease(Block block, int height) { 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 603f1c2bf..85a62be1d 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 @@ -2,11 +2,11 @@ package nautilus.game.arcade.game.games.uhc; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Chunk; import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.Material; @@ -30,15 +30,20 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapedRecipe; @@ -53,23 +58,26 @@ import org.bukkit.scoreboard.Objective; import mineplex.core.common.util.C; 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.UtilEvent; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilWorld; -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.common.util.UtilTextMiddle; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.packethandler.PacketPlayOutWorldBorder; +import mineplex.core.recharge.Recharge; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatLog; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.serverdata.Utility; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -80,44 +88,55 @@ import nautilus.game.arcade.kit.Kit; public class UHC extends TeamGame { + private NautHashMap _teamReqs = new NautHashMap(); + private NautHashMap _deathTime = new NautHashMap(); - //private NautHashMap _combatTime = new NautHashMap(); + // private NautHashMap _combatTime = new NautHashMap(); - private int _borderSize = 1000; private int _yMax = 0; + private boolean _mapLoaded = false; + private double _mapLoadPercent = 0; + private int _chunksPerTick = 1; + private int _chunkTotal; + private Chunk _chunk = null; + private int _chunkX = 0; + private int _chunkZ = 0; + private int _chunksLoaded = 0; + private int _gameMinutes = 0; private int _safeTime = 11; private long _lastMinute = System.currentTimeMillis(); private Objective _scoreObj; - private long _hour = 3600000; private long _createTime; private long _serverTime; - private boolean _joinable = false; - private boolean _ended = false; + private boolean xrayDebug = false; - private long lastInform = 0; + // Border + private int _secondsSinceStart; + private HashMap _borderPositions = new HashMap(); + private double _currentBorder = 1000; + private double _previousBorder = 1000; + private long _borderStartedMoving; public UHC(ArcadeManager manager) - { + { super(manager, GameType.UHC, - new Kit[] - { + new Kit[] + { new KitUHC(manager) - }, + }, - new String[] { - "10 minutes of no PvP", - "Only Golden Apples restore health", - "Ores can only be found in caves", - "Borders shrink over time", - "Last player/team alive wins!" - }); + new String[] + { + "10 minutes of no PvP", "Only Golden Apples restore health", "Ores can only be found in caves", + "Borders shrink over time", "Last player/team alive wins!" + }); this.StrictAntiHack = true; @@ -137,7 +156,7 @@ public class UHC extends TeamGame this.InventoryOpenChest = true; this.InventoryClick = true; - this.DeathOut = true; + this.DeathOut = true; this.QuitOut = false; this.CreatureAllow = true; @@ -146,14 +165,14 @@ public class UHC extends TeamGame this.DisplayLobbySide = true; - this.DeathMessages = false; + this.DeathMessages = false; this.SoupEnabled = false; this.CompassEnabled = true; this.CompassGiveItem = false; - this.WorldBoundaryKill = false; + this.WorldBoundaryKill = false; this.TickPerTeleport = 3; @@ -161,18 +180,23 @@ public class UHC extends TeamGame this.GemDoubleEnabled = false; this.GemHunterEnabled = false; - WorldTimeSet = -1; + this.WorldBoneMeal = true; + this.DontAllowOverfill = true; + + this.VersionRequire1_8 = true; + + WorldTimeSet = -1; + CraftRecipes(); - //Disable Custom Mob Drops (and EXP Disable) + // Disable Custom Mob Drops (and EXP Disable) Manager.GetCreature().SetDisableCustomDrops(true); - //Disable Anti-Stack + // Disable Anti-Stack setItemMerge(true); - // Manager.GetAntiStack().SetEnabled(false); - //Damage Settings + // Damage Settings Manager.GetDamage().SetEnabled(false); _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); @@ -186,6 +210,364 @@ public class UHC extends TeamGame public void ParseData() { WorldData.World.setDifficulty(Difficulty.HARD); + + _chunkX = (int) -(_currentBorder / 16); + _chunkZ = (int) -(_currentBorder / 16); + _chunkTotal = (int) ((_currentBorder * 2 / 16) * (_currentBorder * 2 / 16)); + + WorldData.MinX = -1000; + WorldData.MinZ = -1000; + WorldData.MaxX = 1000; + WorldData.MaxZ = 1000; + + int i = 0; + + for (double border : buildBorders(1000, 1000, 32)) + { + _borderPositions.put(i++ * 4, border); + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (!IsLive()) + return; + + if (UtilTime.elapsed(getGameLiveTime(), 20000)) + return; + + if (!(event.GetDamageeEntity() instanceof Player)) + return; + + event.SetCancelled("Spawn Invincibility"); + event.GetDamageeEntity().setFireTicks(0); + + } + + @EventHandler + public void onSecond(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + if (!IsLive()) + { + return; + } + + _previousBorder = _currentBorder; + + // We half the number so this only activates every 2nd second. + if (_borderPositions.containsKey(_secondsSinceStart)) + { + _currentBorder = _borderPositions.get(_secondsSinceStart); + + setBorder(); + } + + _secondsSinceStart++; + } + + private void setBorder() + { + _borderStartedMoving = System.currentTimeMillis(); + + PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(); + packet.worldBorderType = 1; + + packet.newRadius = _currentBorder; + packet.oldRadius = _previousBorder; + + packet.speed = _currentBorder != _previousBorder ? 1000 : 0; + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (UtilPlayer.is1_8(player)) + { + UtilPlayer.sendPacket(player, packet); + } + } + } + + @EventHandler + public void outsideBorder(UpdateEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getType() != UpdateType.FAST) + { + return; + } + + // The distance between the old border and the new + double distanceMovedSince = _currentBorder - _previousBorder; + + // Multiply that distance depending on how long its been since it moved. + long timeSinceMoved = System.currentTimeMillis() - _borderStartedMoving; + double percentageBorderMoved = Math.min(timeSinceMoved, 1000D) / 1000D; + + distanceMovedSince *= percentageBorderMoved; + + double border = (_previousBorder - 0.3D) + distanceMovedSince; + + for (Player player : UtilServer.getPlayers()) + { + Location loc = player.getLocation(); + + // Bump Players Back In + if (loc.getX() > border || loc.getX() < -border || loc.getZ() > border || loc.getZ() < -border) + { + if (Recharge.Instance.use(player, "Hit by Border", 1000, false, false)) + { + Entity bottom = player; + while (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction + .velocity(bottom, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, true); + + if (Manager.IsAlive(player)) + { + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 10, false, false, false, + "Nether Field", "Vaporize"); + + player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f); + player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f); + } + } + } + } + } + + @EventHandler + public void onGameState(PlayerChangedWorldEvent event) + { + if (GetState() == GameState.Prepare || IsLive()) + { + setupBorder(event.getPlayer()); + } + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (GetState() == GameState.Prepare || IsLive()) + { + setupBorder(event.getPlayer()); + } + } + + private void setupBorder(Player player) + { + PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(); + packet.worldBorderType = 3; + + packet.newRadius = _currentBorder; + packet.oldRadius = _previousBorder; + + packet.warningBlocks = -10; + packet.warningTime = -10; + + if (_currentBorder != _previousBorder) + { + packet.speed = 1000 - Math.min(1000, (System.currentTimeMillis() - _borderStartedMoving)); + } + + // We don't set warnings speed or blocks as its not particularly useful for this game. + // Also if we don't use it here, its more effective in other places to reinforce the idea what its for. + + if (UtilPlayer.is1_8(player)) + { + UtilPlayer.sendPacket(player, packet); + } + } + + private ArrayList buildBorders(int seconds, double border, double leaveRemaining) + { + double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50); + + ArrayList borders = new ArrayList(); + + for (int i = 0; i <= seconds; i++) + { + borders.add(border - ((border - leaveRemaining) * (((Math.pow(i, 1.9D) + (i * 50))) / totalNumber))); + } + + return borders; + } + + @EventHandler + public void loadMap(UpdateEvent event) + { + if (_mapLoaded) + return; + + if (WorldData.World == null) + return; + + if (GetState() != GameState.Recruit) + return; + + // Print Debug + if (event.getType() == UpdateType.SLOWER) + { + Announce(C.cGreen + C.Bold + "Generating Map: " + C.cWhite + getMapLoadETA() + " Remaining...", false); + + TimingManager.endTotal("UHC Generation", true); + return; + } + + if (event.getType() != UpdateType.TICK) + return; + + // Timings + TimingManager.startTotal("UHC Generation"); + + for (int i = 0; i < _chunksPerTick ; i++) + { + // Unload Previous +// if (_chunk != null) +// _chunk.unload(true); + + // Load Chunks + _chunk = WorldData.World.getChunkAt(_chunkX, _chunkZ); + _chunk.load(true); + + // Scan Map + if (_chunkX < _currentBorder / 16) + { + _chunkX++; + } + else if (_chunkZ < _currentBorder / 16) + { + _chunkX = (int) -(_currentBorder / 16); + _chunkZ++; + } + else + { + _mapLoaded = true; + System.out.println("Map Loading Finished!"); + generateSpawns(); + break; + } + + _chunksLoaded++; + } + + _mapLoadPercent = (double)_chunksLoaded / (double)_chunkTotal; + + // Timings + TimingManager.stopTotal("UHC Generation"); + } + + @EventHandler + public void chunkUnload(ChunkUnloadEvent event) + { + //Allow unloading after players in + if (IsLive()) + return; + + if (WorldData.World != null && event.getWorld().equals(WorldData.World)) + { + System.out.println("Disallowing Unload of World"); + event.setCancelled(true); + } + } + + public void generateSpawns() + { + // Wipe Spawns + for (GameTeam team : this.GetTeamList()) + { + team.GetSpawns().clear(); + } + + TimingManager.start("UHC Spawn Generation"); + + // Solo Game + if (this.GetTeamList().size() == 1) + { + while (GetTeamList().get(0).GetSpawns().size() < this.GetPlayers(true).size()) + { + Location loc = GetRandomSpawn(null); + + // Dynamically scale distance requirement based on how many teams need to fit + double dist = (2 * _currentBorder) / (Math.sqrt(this.GetPlayers(true).size()) + 3); + + // Ensure distance between Teams - 500 Attempts + for (int i=0 ; i<500 ; i++) + { + boolean clash = false; + + for (Location otherSpawn : GetTeamList().get(0).GetSpawns()) + { + if (UtilMath.offset(loc, otherSpawn) < dist) + { + clash = true; + break; + } + } + + if (!clash) + break; + + loc = GetRandomSpawn(null); + } + + GetTeamList().get(0).GetSpawns().add(loc); + } + } + // Team Game + else + { + for (GameTeam team : GetTeamList()) + { + Location loc = GetRandomSpawn(null); + + // Dynamically scale distance requirement based on how many teams need to fit + double dist = (2 * _currentBorder) / (Math.sqrt(GetTeamList().size()) + 3); + + // Ensure distance between Teams - 500 Attempts + for (int i=0 ; i<500 ; i++) + { + boolean clash = false; + + for (GameTeam otherTeam : GetTeamList()) + { + if (otherTeam.GetSpawns().isEmpty()) + continue; + + if (UtilMath.offset(loc, otherTeam.GetSpawn()) < dist) + { + clash = true; + break; + } + } + + if (!clash) + break; + + loc = GetRandomSpawn(null); + } + + team.GetSpawns().add(loc); + + while (team.GetSpawns().size() < 20) + { + Location other = GetRandomSpawn(loc); + + team.GetSpawns().add(other); + } + } + } + + TimingManager.stop("UHC Spawn Generation"); } @EventHandler @@ -212,11 +594,11 @@ public class UHC extends TeamGame if (_gameMinutes < _safeTime) { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in " + (_safeTime - _gameMinutes) + " minutes."); + UtilTextMiddle.display(null, "PvP enabled in " + (_safeTime - _gameMinutes) + " minutes.", 5, 80, 5); } else if (_gameMinutes == _safeTime) { - Announce(ChatColor.WHITE + C.Bold + "PvP has been enabled!"); + UtilTextMiddle.display(null, "PvP has been enabled!", 5, 80, 5); for (Player player : UtilServer.getPlayers()) player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f); @@ -227,7 +609,6 @@ public class UHC extends TeamGame } } - @EventHandler public void EarlyGameUpdate(UpdateEvent event) { @@ -244,7 +625,7 @@ public class UHC extends TeamGame for (Player player : GetPlayers(true)) { - player.setSaturation(3f); + player.setSaturation(3f); player.setExhaustion(0f); player.setFoodLevel(20); } @@ -258,7 +639,7 @@ public class UHC extends TeamGame WorldData.World.setTime(2000); - //Kill Evil Mobs + // Kill Evil Mobs for (Entity ent : WorldData.World.getEntities()) { if (!(ent instanceof Monster)) @@ -267,37 +648,15 @@ public class UHC extends TeamGame ent.remove(); } - //Hunger + // Hunger for (Player player : GetPlayers(true)) { - player.setSaturation(4f); + player.setSaturation(4f); player.setExhaustion(0f); } } - /* - @EventHandler - public void WorldBoundaryCheck(PlayerMoveEvent event) - { - if (!IsLive()) - return; - - //Allowed - if ( - event.getTo().getX() < _borderSize&& - event.getTo().getX() >= -_borderSize && - event.getTo().getZ() < _borderSize && - event.getTo().getZ() >= -_borderSize) - return; - - if (Recharge.Instance.use(event.getPlayer(), "Border Shrink", 500, false, false)) - { - Manager.GetCondition().Factory().Poison("Border", event.getPlayer(), event.getPlayer(), 1.9, 0, false, false, false); - } - } - */ - - @EventHandler + /*@EventHandler public void WorldBoundaryCheck(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) @@ -310,92 +669,6 @@ public class UHC extends TeamGame { player.damage(0.75); } - - VisualBoundary(player); - VisualBoundaryClose(player); - } - } - - public void VisualBoundary(Player player) - { - //Effect 1 - if (Math.abs(player.getLocation().getX()) + 16 < _borderSize && Math.abs(player.getLocation().getZ()) + 16 < _borderSize) - return; - - //X Wall - if (Math.abs(player.getLocation().getX()) + 16 >= _borderSize) - { - Location loc = player.getLocation().getBlock().getLocation().add(0.5, 0.5, 0.5); - loc.setX(_borderSize); - - for (int y=-16 ; y<=16 ; y++) - { - for (int z=-16 ; z<=16 ; z++) - { - if (Math.abs(loc.getZ() + z) > _borderSize) - continue; - - Location newLoc = loc.clone().add(0, y, z); - - if (UtilMath.offset(player.getLocation(), newLoc) > 16) - continue; - - UtilParticle.PlayParticle(ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1, - ViewDist.NORMAL, player); - - if (_borderSize > 16) - player.playSound(newLoc, Sound.FIZZ, 0.1f, 0.1f); - } - } - } - - //Z Wall - if (Math.abs(player.getLocation().getZ()) + 16 >= _borderSize) - { - Location loc = player.getLocation().getBlock().getLocation().add(0.5, 0.5, 0.5); - loc.setZ(_borderSize); - - for (int x=-16 ; x<=16 ; x++) - { - for (int y=-16 ; y<=16 ; y++) - { - if (Math.abs(loc.getX() + x) > _borderSize) - continue; - - Location newLoc = loc.clone().add(x, y, 0); - - if (UtilMath.offset(player.getLocation(), newLoc) > 16) - continue; - - UtilParticle.PlayParticle(ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1, - ViewDist.NORMAL, player); - - if (_borderSize > 16) - player.playSound(newLoc, Sound.FIZZ, 0.1f, 0.1f); - } - } - } - } - - public void VisualBoundaryClose(Player player) - { - //Effect - if (Math.abs(player.getLocation().getX()) + 5 < _borderSize && Math.abs(player.getLocation().getZ()) + 5 < _borderSize) - return; - - for (Block block : UtilBlock.getInRadius(player.getLocation(), 5d).keySet()) - { - if (Math.random() > 0.80) - continue; - - if (Math.abs(block.getX()) < _borderSize && Math.abs(block .getZ()) < _borderSize) - continue; - - if (!UtilBlock.airFoliage(block)) - continue; - - UtilParticle.PlayParticle(ParticleType.LAVA, block.getLocation().add(0.5, 0.5, 0.5), 0.5f, 0.5f, 0.5f, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); } } @@ -410,7 +683,7 @@ public class UHC extends TeamGame _borderSize--; } - @EventHandler + //@EventHandler public void WorldBoundarySet(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) @@ -426,18 +699,6 @@ public class UHC extends TeamGame this.WorldData.MinY = -1000; this.WorldData.MaxY = 1000; - /* - for (int y=0 ; y<128 ; y++) - for (int x=-_borderSize ; x<_borderSize ; x++) - for (int z=-_borderSize ; z<_borderSize ; z++) - { - if (x == -_borderSize || x == _borderSize-1 || z == -_borderSize || z == _borderSize-1) - { - MapUtil.QuickChangeBlockAt(WorldData.World, x, y, z , 159, (byte)14); - } - } - */ - //Find Y Max for (int x=-16 ; x<16 ; x++) for (int z=-16 ; z<16 ; z++) @@ -447,152 +708,55 @@ public class UHC extends TeamGame if (y > _yMax) _yMax = y; } + System.out.println("Y Max: " + _yMax); System.out.println("Time: " + UtilTime.MakeStr(System.currentTimeMillis() - time)); - } + }*/ @EventHandler public void WorldBoundaryYLimit(BlockPlaceEvent event) { - if (event.getBlock().getX() >= -16 && - event.getBlock().getX() <= 16 && - event.getBlock().getZ() >= -16 && - event.getBlock().getZ() <= 16 && - event.getBlock().getY() >= _yMax) + if (event.getBlock().getX() >= -16 && event.getBlock().getX() <= 16 && event.getBlock().getZ() >= -16 + && event.getBlock().getZ() <= 16 && event.getBlock().getY() >= _yMax) { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high up.")); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high near center of map.")); event.setCancelled(true); } } - @EventHandler(priority = EventPriority.HIGHEST) - public void GenerateSpawns(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - //Wipe Spawns - for (GameTeam team : this.GetTeamList()) - { - team.GetSpawns().clear(); - } - - TimingManager.start("UHC Spawn Generation"); - - //Solo Game - if (this.GetTeamList().size() == 1) - { - while (GetTeamList().get(0).GetSpawns().size() < this.GetPlayers(true).size()) - { - Location loc = GetRandomSpawn(null); - - //Dynamically scale distance requirement based on how many teams need to fit - double dist = (2*_borderSize) / (Math.sqrt(this.GetPlayers(true).size()) + 3); - - //Ensure distance between Teams - while (true) - { - boolean clash = false; - - for (Location otherSpawn : GetTeamList().get(0).GetSpawns()) - { - if (UtilMath.offset(loc, otherSpawn) < dist) - { - clash = true; - break; - } - } - - if (!clash) - break; - - loc = GetRandomSpawn(null); - } - - GetTeamList().get(0).GetSpawns().add(loc); - } - } - //Team Game - else - { - for (GameTeam team : GetTeamList()) - { - Location loc = GetRandomSpawn(null); - - //Dynamically scale distance requirement based on how many teams need to fit - double dist = (2*_borderSize) / (Math.sqrt(GetTeamList().size()) + 3); - - //Ensure distance between Teams - while (true) - { - boolean clash = false; - - for (GameTeam otherTeam : GetTeamList()) - { - if (otherTeam.GetSpawns().isEmpty()) - continue; - - if (UtilMath.offset(loc, otherTeam.GetSpawn()) < dist) - { - clash = true; - break; - } - } - - if (!clash) - break; - - loc = GetRandomSpawn(null); - } - - team.GetSpawns().add(loc); - - while (team.GetSpawns().size() < 20) - { - Location other = GetRandomSpawn(loc); - - team.GetSpawns().add(other); - } - } - } - - TimingManager.stop("UHC Spawn Generation"); - } - public Location GetRandomSpawn(Location around) { - HashSet ignore = new HashSet(); - ignore.add(Material.LEAVES); - Location loc = null; while (loc == null) { Block block = null; - //Get Team Location + // Get Team Location if (around == null) { - int x = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize)); - int z = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize)); + // Return a int from 0 - 1800, then remove 900 so its a int from -900 to 900 + int x = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder)); + int z = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder)); - block = UtilBlock.getHighest(WorldData.World, x, z, ignore); + block = UtilBlock.getHighest(WorldData.World, x, z, null); } - //Get Radius Location + // Get Radius Location else { - block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(8), around.getBlockZ() - 4 + UtilMath.r(8), ignore); + block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(8), around.getBlockZ() - 4 + + UtilMath.r(8), null); } - //Check Validity + // Check Validity - //Liquid + // Liquid if (block.getRelative(BlockFace.DOWN).isLiquid()) continue; - //Suffocated - if (block.getTypeId() != 0 || block.getRelative(BlockFace.UP).getTypeId() != 0) + // Suffocated + if (block.getType() != Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR) continue; loc = block.getLocation().add(0.5, 0.5, 0.5); @@ -617,7 +781,8 @@ public class UHC extends TeamGame Player player = event.getPlayer(); GameTeam team = GetTeam(player); - if (team == null) return; + if (team == null) + return; if (!IsAlive(player)) return; @@ -625,13 +790,14 @@ public class UHC extends TeamGame if (!QuitOut) return; - //Drop Items + // Drop Items UtilInv.drop(player, true); - //Skull Drop - ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head"); + // Skull Drop + ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, + team.GetColor() + player.getName() + "'s Head"); - SkullMeta meta = (SkullMeta)stack.getItemMeta(); + SkullMeta meta = (SkullMeta) stack.getItemMeta(); meta.setOwner(player.getName()); stack.setItemMeta(meta); @@ -644,30 +810,32 @@ public class UHC extends TeamGame Player player = event.getEntity(); GameTeam team = GetTeam(player); - if (team == null) return; + if (team == null) + return; - //Skull Drop - ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head"); + // Skull Drop + ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, + team.GetColor() + player.getName() + "'s Head"); - SkullMeta meta = (SkullMeta)stack.getItemMeta(); + SkullMeta meta = (SkullMeta) stack.getItemMeta(); meta.setOwner(player.getName()); stack.setItemMeta(meta); event.getDrops().add(stack); - //Lightning + // Lightning Location loc = player.getLocation(); loc.setY(-150); player.getWorld().strikeLightningEffect(loc); - //Gems + // Gems if (IsLive()) { long timeAlive = System.currentTimeMillis() - GetStateTime(); AddGems(player, timeAlive / 60000d, "Survived " + UtilTime.MakeStr(timeAlive), false, false); } - //Time + // Time _deathTime.put(player.getName(), System.currentTimeMillis()); } @@ -677,7 +845,7 @@ public class UHC extends TeamGame if (!(event.GetEvent().getEntity() instanceof Player)) return; - Player dead = (Player)event.GetEvent().getEntity(); + Player dead = (Player) event.GetEvent().getEntity(); CombatLog log = event.GetLog(); @@ -685,26 +853,23 @@ public class UHC extends TeamGame if (log.GetKiller() != null) killer = UtilPlayer.searchExact(log.GetKiller().GetName()); - //Simple + // Simple if (killer != null) { - Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + - C.cGray + C.Bold + " was killed by " + - Manager.GetColor(killer) + C.Bold + killer.getName() + - C.cGray + C.Bold + "."); + Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + C.cGray + C.Bold + " was killed by " + + Manager.GetColor(killer) + C.Bold + killer.getName() + C.cGray + C.Bold + "."); } else { if (log.GetAttackers().isEmpty()) { - Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + - C.cGray + C.Bold + " has died by unknown causes."); + Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + C.cGray + C.Bold + " has died by unknown causes."); } else { - Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + - C.cGray + C.Bold + " was killed by " + log.GetAttackers().getFirst().GetName() + "."); + Announce(Manager.GetColor(dead) + C.Bold + dead.getName() + C.cGray + C.Bold + " was killed by " + + log.GetAttackers().getFirst().GetName() + "."); } } } @@ -724,7 +889,7 @@ public class UHC extends TeamGame continue; _deathTime.remove(player.getName()); - //XXX Need this ? Manager.GetPortal().SendPlayerToServer(player, "Lobby"); + // XXX Need this ? Manager.GetPortal().SendPlayerToServer(player, "Lobby"); } } @@ -773,7 +938,6 @@ public class UHC extends TeamGame } */ - @EventHandler public void CreatureCull(UpdateEvent event) { @@ -793,7 +957,7 @@ public class UHC extends TeamGame ents.get(ent.getType()).add(ent); } - for (EntityType type : ents.keySet()) + for (EntityType type : ents.keySet()) { ArrayList entList = ents.get(type); int count = 0; @@ -813,7 +977,7 @@ public class UHC extends TeamGame } } - private void CraftRecipes() + private void CraftRecipes() { ShapelessRecipe goldMelon = new ShapelessRecipe(new ItemStack(Material.SPECKLED_MELON, 1)); goldMelon.addIngredient(1, Material.MELON); @@ -821,9 +985,9 @@ public class UHC extends TeamGame UtilServer.getServer().addRecipe(goldMelon); ShapedRecipe headApple2 = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1)); - headApple2.shape("GGG","GHG","GGG"); + headApple2.shape("GGG", "GHG", "GGG"); headApple2.setIngredient('G', Material.GOLD_INGOT); - headApple2.setIngredient('H', new MaterialData(Material.SKULL_ITEM, (byte)3)); + headApple2.setIngredient('H', new MaterialData(Material.SKULL_ITEM, (byte) 3)); UtilServer.getServer().addRecipe(headApple2); } @@ -841,7 +1005,7 @@ public class UHC extends TeamGame if (!(event.getInventory() instanceof CraftingInventory)) return; - CraftingInventory inv = (CraftingInventory)event.getInventory(); + CraftingInventory inv = (CraftingInventory) event.getInventory(); for (ItemStack item : inv.getMatrix()) if (item != null && item.getType() != Material.AIR) @@ -865,7 +1029,7 @@ public class UHC extends TeamGame if (!(event.getInventory() instanceof CraftingInventory)) return; - CraftingInventory inv = (CraftingInventory)event.getInventory(); + CraftingInventory inv = (CraftingInventory) event.getInventory(); for (ItemStack item : inv.getMatrix()) if (item != null && item.getType() != Material.AIR) @@ -877,7 +1041,8 @@ public class UHC extends TeamGame if (item.getItemMeta().getDisplayName() == null) continue; - ItemStack apple = ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE, (byte)0, 1, item.getItemMeta().getDisplayName() + ChatColor.AQUA + " Golden Apple"); + ItemStack apple = ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE, (byte) 0, 1, item + .getItemMeta().getDisplayName() + ChatColor.AQUA + " Golden Apple"); apple.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); inv.setResult(apple); @@ -899,9 +1064,9 @@ public class UHC extends TeamGame if (!(event.getInventory() instanceof CraftingInventory)) return; - CraftingInventory inv = (CraftingInventory)event.getInventory(); + CraftingInventory inv = (CraftingInventory) event.getInventory(); - //Allow FULL BLOCK Gold Melon + // Allow FULL BLOCK Gold Melon for (ItemStack item : inv.getMatrix()) if (item != null && item.getType() != Material.AIR) if (item.getType() == Material.GOLD_BLOCK) @@ -996,42 +1161,42 @@ public class UHC extends TeamGame { if (event.getBlock().getType() == Material.OBSIDIAN) { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Obsidian") + " in the " + F.elem("Nether") + ".")); + UtilPlayer.message(event.getPlayer(), + F.main("Game", "You cannot place " + F.elem("Obsidian") + " in the " + F.elem("Nether") + ".")); event.setCancelled(true); } } } - @EventHandler public void Commands(PlayerCommandPreprocessEvent event) { if (event.getMessage().startsWith("/kill")) event.setCancelled(true); -// if (event.getMessage().startsWith("/uhc time day")) -// { -// this.WorldTimeSet = 4000; -// event.setCancelled(true); -// -// Announce(event.getPlayer().getName() + " set time to Always Day!"); -// } -// -// if (event.getMessage().startsWith("/uhc time night")) -// { -// this.WorldTimeSet = 16000; -// event.setCancelled(true); -// -// Announce(event.getPlayer().getName() + " set time to Always Night!"); -// } -// -// if (event.getMessage().startsWith("/uhc time cycle")) -// { -// this.WorldTimeSet = -1; -// event.setCancelled(true); -// -// Announce(event.getPlayer().getName() + " set time to Day and Night!"); -// } + // if (event.getMessage().startsWith("/uhc time day")) + // { + // this.WorldTimeSet = 4000; + // event.setCancelled(true); + // + // Announce(event.getPlayer().getName() + " set time to Always Day!"); + // } + // + // if (event.getMessage().startsWith("/uhc time night")) + // { + // this.WorldTimeSet = 16000; + // event.setCancelled(true); + // + // Announce(event.getPlayer().getName() + " set time to Always Night!"); + // } + // + // if (event.getMessage().startsWith("/uhc time cycle")) + // { + // this.WorldTimeSet = -1; + // event.setCancelled(true); + // + // Announce(event.getPlayer().getName() + " set time to Day and Night!"); + // } } @EventHandler(priority = EventPriority.LOWEST) @@ -1046,71 +1211,23 @@ public class UHC extends TeamGame event.setCancelled(false); } - /* - @EventHandler - public void TabHealth(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (!InProgress()) - return; - - for (Player player : GetPlayers(true)) - { - GameTeam team = GetTeam(player); - - ChatColor col = ChatColor.GREEN; - if (player.getHealth() <= 12) col = ChatColor.YELLOW; - if (player.getHealth() <= 6) col = ChatColor.RED; - - String health = " - " + col; - if (_soloGame) - health = " - "; - - int hp = (int)(player.getHealth() + 0.9999999999); - - if (hp % 2 == 0) - health += (int)(hp/2); - else - health += UtilMath.trim(1, hp/2d); - - String name = team.GetColor() + player.getName(); - if (_soloGame) - name = col + player.getName(); - - try - { - while (name.length() + health.length() > 16) - name = name.substring(0, name.length()-1); - - player.setPlayerListName(name + health); - } - catch (Exception e) - { - System.out.println("TAB NAME: " + name + health); - e.printStackTrace(); - } - } - }*/ - @Override public void EndCheck() { if (!IsLive()) return; - //Solo + // Solo if (GetTeamList().size() == 1) { if (GetPlayers(true).size() <= 1) - { + { ArrayList places = GetTeamList().get(0).GetPlacements(true); - //Announce + // Announce AnnounceEnd(places); - //Gems + // Gems if (places.size() >= 1) AddGems(places.get(0), 20, "1st Place", false, false); @@ -1124,7 +1241,7 @@ public class UHC extends TeamGame if (player.isOnline()) AddGems(player, 10, "Participation", false, false); - //End + // End SetState(GameState.End); } } @@ -1132,12 +1249,12 @@ public class UHC extends TeamGame { ArrayList teamsAlive = new ArrayList(); - //Online Teams + // Online Teams for (GameTeam team : this.GetTeamList()) if (team.GetPlayers(true).size() > 0) teamsAlive.add(team); - //Offline Player Team + // Offline Player Team if (!QuitOut) for (GameTeam team : RejoinTeam.values()) teamsAlive.add(team); @@ -1149,7 +1266,7 @@ public class UHC extends TeamGame AddGems(player, 8000, "Winning Team", false, false); AnnounceEnd(teamsAlive.get(0)); - SetState(GameState.End); + SetState(GameState.End); } } } @@ -1170,7 +1287,7 @@ public class UHC extends TeamGame Scoreboard.WriteBlank(); - //Solo + // Solo if (GetTeamList().size() == 1) { if (GetPlayers(true).size() < 8) @@ -1186,7 +1303,7 @@ public class UHC extends TeamGame Scoreboard.Write(GetPlayers(true).size() + " Alive"); } } - //Team + // Team else { ArrayList aliveList = new ArrayList(); @@ -1215,14 +1332,14 @@ public class UHC extends TeamGame Scoreboard.WriteBlank(); Scoreboard.Write(C.cYellow + C.Bold + "Borders"); - Scoreboard.Write("-" + _borderSize + " to " + "+" + _borderSize); + Scoreboard.Write("-" + (int) _currentBorder + " to " + "+" + (int) _currentBorder); Scoreboard.Draw(); } public int GetHealth(Player player) { - int health = (int)player.getHealth(); + int health = (int) player.getHealth(); if (player.getHealth() % 1d != 0) { @@ -1237,62 +1354,19 @@ public class UHC extends TeamGame return _serverTime + (System.currentTimeMillis() - _createTime); } - @EventHandler - public void returnToHub(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (_joinable) - return; - - //Cannot become Joinable within first 10 seconds of creation - if (!UtilTime.elapsed(_createTime, 10000)) - { - return; - } - - //Become Joinable (first 5 seconds of the hour) - if (getServerTime() % _hour < 5000) - { - _joinable = true; - } - } - - @EventHandler - public void kickPlayers(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!_ended) - if (_joinable) - return; - - for (final Player player : UtilServer.getPlayers()) - { - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cGold + C.Bold + "This UHC game is closed!"); - UtilPlayer.message(player, " "); - - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); - Manager.GetPortal().sendPlayerToServer(player, "Lobby"); - } - } - @Override public boolean CanJoinTeam(GameTeam team) { return team.GetSize() < 2; } - //Ensure 2 players per team + // Ensure 2 players per team @Override public GameTeam ChooseTeam(Player player) { GameTeam team = null; - //Random Team + // Random Team for (int i = 0; i < _teamList.size(); i++) { if (_teamList.get(i).GetSize() == 1) @@ -1315,7 +1389,7 @@ public class UHC extends TeamGame for (GameTeam team : GetTeamList()) { - //Big Team + // Big Team if (team.GetSize() > 2) { team.SetName("Team " + team.GetName()); @@ -1324,7 +1398,7 @@ public class UHC extends TeamGame String name = ""; - for (int i=0 ; i< team.GetPlayers(false).size() ; i++) + for (int i = 0; i < team.GetPlayers(false).size(); i++) { Player player = team.GetPlayers(false).get(i); @@ -1338,25 +1412,6 @@ public class UHC extends TeamGame } } - @EventHandler(priority = EventPriority.MONITOR) - public void setEnded(final GameStateChangeEvent event) - { - if (!Manager.IsRewardItems()) - return; - - if (event.GetState() != GameState.Dead) - return; - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - _ended = true; - } - }, 360); - //Delay 18 Seconds - } - @Override public double GetKillsGems(Player killer, Player killed, boolean assist) { @@ -1378,33 +1433,33 @@ public class UHC extends TeamGame if (!IsLive()) event.setCancelled(true); - //Damagee + // Damagee Player damagee = null; if (event.getEntity() instanceof Player) { - damagee = (Player)event.getEntity(); + damagee = (Player) event.getEntity(); - //Dead + // Dead if (!IsAlive(damagee)) event.setCancelled(true); - } + } - //Damager + // Damager LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true); if (damagerEnt instanceof Player) { - //PvP + // PvP if (!DamagePvP && damagee != null) event.setCancelled(true); - Player damager = (Player)damagerEnt; + Player damager = (Player) damagerEnt; - //Dead + // Dead if (!IsAlive(damager)) event.setCancelled(true); - //Same Team + // Same Team if (damagee != null) if (GetTeam(damager) != null && GetTeam(damagee) != null && GetTeam(damager).equals(GetTeam(damagee))) { @@ -1415,25 +1470,22 @@ public class UHC extends TeamGame public String getMotdStatus() { - //In Progress + // In Progress if (InProgress()) { return ChatColor.YELLOW + "In Progress"; } - //Ended + // Ended if (GetState() == GameState.End || GetState() == GameState.Dead) { - if (_ended) - return ChatColor.RED + "Finished"; - else - return ChatColor.YELLOW + "In Progress"; + return ChatColor.YELLOW + "In Progress"; } - //Not Joinable Yet - if (!_joinable) + // Not Loaded (but still joinable) + if (!_mapLoaded) { - return ChatColor.GOLD + "Open in " + UtilTime.MakeStr(_hour - (getServerTime() % _hour)); + return ChatColor.GREEN + "Generating Map (" + C.cWhite + getMapLoadETA() + C.cGreen + ")"; } return ChatColor.GREEN + "Recruiting"; @@ -1450,10 +1502,10 @@ public class UHC extends TeamGame int range = 3; - //Find Nearby Ores + // Find Nearby Ores ArrayList ores = findOres(event.getBlock(), range); - //Anti-Xray + // Anti-Xray removeNonAirVeins(generateVeins(ores)); if (xrayDebug) @@ -1464,9 +1516,9 @@ public class UHC extends TeamGame { ArrayList ores = new ArrayList(); - for (int x=-range ; x <= range ; x++) - for (int z=-range ; z <= range ; z++) - for (int y=-range ; y <= range ; y++) + for (int x = -range; x <= range; x++) + for (int z = -range; z <= range; z++) + for (int y = -range; y <= range; y++) { Block block = source.getRelative(x, y, z); @@ -1498,9 +1550,7 @@ public class UHC extends TeamGame public boolean isOre(Block block) { - return (block.getType() == Material.IRON_ORE || - block.getType() == Material.GOLD_ORE || - block.getType() == Material.DIAMOND_ORE); + return (block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.DIAMOND_ORE); } private ArrayList> generateVeins(ArrayList ores) @@ -1514,12 +1564,12 @@ public class UHC extends TeamGame if (xrayDebug) System.out.println("NEW VEIN - " + block.getType()); - //Start New Vein + // Start New Vein ArrayList vein = new ArrayList(); veins.add(vein); vein.add(block); - //Find Vein Ores + // Find Vein Ores boolean addedToVein = true; while (addedToVein) { @@ -1533,11 +1583,11 @@ public class UHC extends TeamGame boolean inVein = false; - //Check if in Vein + // Check if in Vein for (Block veinOre : vein) { - //if (veinOre.getType() != ore.getType()) - // continue; + // if (veinOre.getType() != ore.getType()) + // continue; if (UtilMath.offset(ore.getLocation(), veinOre.getLocation()) <= 2) { @@ -1546,7 +1596,7 @@ public class UHC extends TeamGame } } - //Add to Vein + // Add to Vein if (inVein) { vein.add(ore); @@ -1566,12 +1616,12 @@ public class UHC extends TeamGame private void removeNonAirVeins(ArrayList> oreVeins) { - //Remove Non-Aired Veins + // Remove Non-Aired Veins for (ArrayList vein : oreVeins) { boolean visible = false; - //Check if Air is near Vein + // Check if Air is near Vein for (Block ore : vein) { for (Block visibleCheckBlock : UtilBlock.getSurrounding(ore, true)) @@ -1589,7 +1639,7 @@ public class UHC extends TeamGame break; } - //Remove Vein + // Remove Vein if (!visible) { if (xrayDebug) @@ -1611,13 +1661,157 @@ public class UHC extends TeamGame } } - public void informStartSoon() + public boolean isMapLoaded() { - if (UtilTime.elapsed(lastInform, 20000)) - { - lastInform = System.currentTimeMillis(); + return _mapLoaded; + } - Bukkit.broadcastMessage(C.cGray + "Countdown will start in " + UtilTime.MakeStr(150000 - (System.currentTimeMillis() - GetStateTime())) +"..."); + public String getMapLoadPercent() + { + return (int)(_mapLoadPercent * 100) + "%"; + } + + public String getMapLoadETA() + { + int chunksToGo = _chunkTotal - _chunksLoaded; + + return UtilTime.MakeStr((long) ((double)chunksToGo / (double)(_chunksPerTick * 20) * 1000d), 1); + } + + @EventHandler(priority = EventPriority.HIGH) + public void teamSelectInteract(PlayerInteractEntityEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (event.getRightClicked() == null) + return; + + if (!(event.getRightClicked() instanceof Player)) + return; + + Player player = event.getPlayer(); + + //Observer + if (Manager.IsObserver(player)) + { + UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); + return; + } + + selectTeamMate(player, (Player)event.getRightClicked()); + } + + @EventHandler + public void teamSelectCommand(PlayerCommandPreprocessEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (!event.getMessage().toLowerCase().startsWith("/team ")) + return; + + event.setCancelled(true); + + Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true); + if (target == null) + return; + + //Observer + if (Manager.IsObserver(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games.")); + return; + } + + if (event.getPlayer().equals(target)) + return; + + selectTeamMate(event.getPlayer(), target); + } + + public void selectTeamMate(Player player, Player ally) + { + //Accept Invite + if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player)) + { + //Remove Prefs + _teamReqs.remove(player); + _teamReqs.remove(ally); + + //Inform + UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!")); + UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!")); + + //Leave Old Teams + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + if (GetTeam(ally) != null) + GetTeam(ally).DisbandTeam(); + + //Get Team + GameTeam team = getEmptyTeam(); + if (team == null) + return; + + team.setDisplayName(player.getName() + " & " + ally.getName()); + + //Join Team + SetPlayerTeam(player, team, true); + SetPlayerTeam(ally, team, true); + } + //Send Invite + else + { + //Already on Team with Target + if (GetTeam(player) != null) + if (GetTeam(player).HasPlayer(ally)) + return; + + //Inform Player + UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!")); + + //Inform Target + if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false)) + { + UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!")); + UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!")); + } + + //Add Pref + _teamReqs.put(player, ally); } } + + @EventHandler + public void teamQuit(PlayerQuitEvent event) + { + if (GetState() != GameState.Recruit) + return; + + Player player = event.getPlayer(); + + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + Iterator teamIter = _teamReqs.keySet().iterator(); + while (teamIter.hasNext()) + { + Player sender = teamIter.next(); + if (sender.equals(player) || _teamReqs.get(sender).equals(player)) + teamIter.remove(); + } + } + + public GameTeam getEmptyTeam() + { + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(false).isEmpty()) + return team; + } + + return null; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java index c72976da6..10a79928f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java @@ -105,13 +105,15 @@ public enum SpellType // ❤ 0, // Cooldown change per level 5, // Item amount in loot - C.cYellow + C.Bold + "Gust Size: " + C.Bold + C.cWhite + "10 x Spell Level blocks", + C.cYellow + C.Bold + "Gust Size: " + C.Bold + C.cWhite + "(Spell Level x 3) + 10 blocks", C.cYellow + C.Bold + "Gust Strength: " + C.Bold + C.cWhite + "Spell Level x 30%", "", - "Cast the spell and watch your enemies fly!"), + "Cast the spell and watch your enemies fly!", + + "Spell strength decreases with distance"), Heal(SpellElement.SUPPORT, // Spell element WandElement.LIFE, // Wand element @@ -158,7 +160,7 @@ public enum SpellType // ❤ "Ice Shards", // Spell name new ItemStack(Material.GOLDEN_CARROT), // Spell icon SpellIceShards.class, // Spell class - 5, // Spell max level + 3, // Spell max level 30, // Mana cost 20, // Spell cooldown 0, // Mana cost change per level @@ -264,7 +266,7 @@ public enum SpellType // ❤ "Creates a ball of fire that grows", - "the longer it lives. At an large size", + "the longer it lives. At a large size", "it even burns away nearby blocks!"), @@ -280,7 +282,7 @@ public enum SpellType // ❤ 1, // Cooldown change per level 10, // Item amount in loot - C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 2", + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 1", C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "80", @@ -321,7 +323,7 @@ public enum SpellType // ❤ "Rumble", // Spell name new ItemStack(Material.PUMPKIN_SEEDS), // Spell icon SpellRumble.class, // Spell class - 5, // Spell max level + 3, // Spell max level 30, // Mana cost 15, // Spell cooldown 0, // Mana cost change per level @@ -443,8 +445,6 @@ public enum SpellType // ❤ 0, // Cooldown change per level 3, // Item amount in loot - C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "1 heart", - C.cYellow + C.Bold + "Webs: " + C.Bold + C.cWhite + "Spell Level x 2", "", 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 1998bcfa6..be15c1195 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 @@ -20,7 +20,6 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; @@ -92,7 +91,6 @@ import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.AnvilInventory; @@ -313,7 +311,7 @@ public class Wizards extends SoloGame public void onWandHit(CustomDamageEvent event) { // Damager is ENTITY - if (event.GetDamagerEntity(true) != null) + if (!event.isCancelled() && event.GetDamagerEntity(true) != null) { if (event.GetReason() == null) { @@ -325,9 +323,12 @@ public class Wizards extends SoloGame { Wizard wizard = getWizard(damager); - String reason = damager.getInventory().getHeldItemSlot() < wizard.getWandsOwned() ? "Wand" : "Fist"; + if (wizard != null) + { + String reason = damager.getInventory().getHeldItemSlot() < wizard.getWandsOwned() ? "Wand" : "Fist"; - event.AddMod(reason, reason, 0, true); + event.AddMod(reason, reason, 0, true); + } } } } @@ -355,19 +356,19 @@ public class Wizards extends SoloGame if (name.contains("LEATHER")) { - percent = 8; + percent = 10; } else if (name.contains("GOLDEN") || name.contains("CHAINMAIL")) { - percent = 12; + percent = 15; } else if (name.contains("IRON")) { - percent = 15; + percent = 19; } else if (name.contains("DIAMOND")) { - percent = 20; + percent = 25; } if (name.contains("BOOTS")) @@ -683,7 +684,6 @@ public class Wizards extends SoloGame _chestLoot.addLoot(Material.WHEAT, 5, 1, 2); _chestLoot.addLoot(Material.WOOD, 5, 1, 10); - _chestLoot.addLoot(Material.BOAT, 5, 1, 2); _chestLoot.addLoot(Material.GOLD_INGOT, 5, 1, 2); _chestLoot.addLoot(Material.IRON_INGOT, 5, 1, 2); @@ -694,10 +694,10 @@ public class Wizards extends SoloGame _chestLoot.addLoot(Material.LEATHER_CHESTPLATE, 6, 1, 1); _chestLoot.addLoot(Material.LEATHER_HELMET, 6, 1, 1); - _chestLoot.addLoot(Material.CHAINMAIL_BOOTS, 5, 1, 1); - _chestLoot.addLoot(Material.CHAINMAIL_CHESTPLATE, 5, 1, 1); - _chestLoot.addLoot(Material.CHAINMAIL_HELMET, 5, 1, 1); - _chestLoot.addLoot(Material.CHAINMAIL_LEGGINGS, 5, 1, 1); + _chestLoot.addLoot(Material.GOLD_BOOTS, 5, 1, 1); + _chestLoot.addLoot(Material.GOLD_CHESTPLATE, 5, 1, 1); + _chestLoot.addLoot(Material.GOLD_HELMET, 5, 1, 1); + _chestLoot.addLoot(Material.GOLD_LEGGINGS, 5, 1, 1); _chestLoot.addLoot(Material.IRON_BOOTS, 2, 1, 1); _chestLoot.addLoot(Material.IRON_CHESTPLATE, 2, 1, 1); @@ -752,12 +752,9 @@ public class Wizards extends SoloGame progressBar += "▌"; } - // Send to Player - for (Player player : players) - { - UtilTextBottom.display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar - + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players); - } + UtilTextBottom.display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players); + } public void drawUtilTextBottom(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java index da0c492d1..730274a97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java @@ -1,6 +1,8 @@ package nautilus.game.arcade.game.games.wizards.spells; import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.games.wizards.Spell; @@ -20,7 +22,21 @@ public class SpellGust extends Spell implements SpellClick final Vector vector = player.getLocation().getDirection().setY(0).normalize().multiply(1.5).setY(0.3) .multiply(1.2 + (getSpellLevel(player) * 0.4D)); - final HashMap effected = UtilPlayer.getPlayersInPyramid(player, 45, 10 * getSpellLevel(player)); + final double gustSize = (getSpellLevel(player) * 3) + 10; + + final HashMap effected = UtilPlayer.getPlayersInPyramid(player, 45, gustSize); + + Iterator> itel = effected.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (!entry.getKey().canSee(player)) + { + itel.remove(); + } + } if (!effected.isEmpty()) { @@ -37,9 +53,11 @@ public class SpellGust extends Spell implements SpellClick continue; } - Wizards.getArcadeManager().GetCondition().Factory().Falling("Gust", target, player, 10, false, true); + Vector vec = vector.clone().multiply(Math.max(0.2, effected.get(target))); - target.setVelocity(vector); + Wizards.getArcadeManager().GetCondition().Factory().Falling("Gust", target, player, 40, false, true); + + target.setVelocity(vec); target.getWorld().playSound(target.getLocation(), Sound.BAT_TAKEOFF, 1, 0.7F); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java index 4be60e6c1..ef51b077a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java @@ -35,7 +35,7 @@ public class SpellRainbowBeam extends Spell implements SpellClick p.getEyeLocation().getDirection().normalize() .multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation()))); - double damage = (getSpellLevel(p) * 2) + 4; + double damage = (getSpellLevel(p) * 2) + 2; double dist = loc.distance(p.getLocation()) - (80 * .2D); // If target is more than 20% away diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java index c3763e50b..73e1f544b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java @@ -92,10 +92,10 @@ public class SpellWebShot extends Spell implements SpellClick, IThrown } // Damage Event - Wizards.getArcadeManager() - .GetDamage() - .NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 2, false, false, false, - "Web Shot", "Web Shot"); + /* Wizards.getArcadeManager() + .GetDamage() + .NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 2, false, false, false, + "Web Shot", "Web Shot");*/ } Web(data, loc); 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 61b7da7af..8c156cff4 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 @@ -32,151 +32,153 @@ import nautilus.game.arcade.gui.spectatorMenu.button.SpectatorButton; public class SpectatorPage extends ShopPageBase { - private ArcadeManager _arcadeManager; + private ArcadeManager _arcadeManager; - public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, SpectatorShop shop, CoreClientManager clientManager, - DonationManager donationManager, Player player) - { - super(plugin, shop, clientManager, donationManager, "Spectator Menu", player); - _arcadeManager = arcadeManager; - buildPage(); - } + public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, SpectatorShop shop, CoreClientManager clientManager, + DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Spectator Menu", player); + _arcadeManager = arcadeManager; + buildPage(); + } - @Override - protected void buildPage() - { - int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); - List teamList = _arcadeManager.GetGame().GetTeamList(); + @Override + protected void buildPage() + { + int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); + List teamList = _arcadeManager.GetGame().GetTeamList(); - if (teamList.size() == 1 && playerCount < 28) - buildSingleTeam(teamList.get(0), playerCount); - else - buildMultipleTeams(teamList, playerCount); + 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() - { + private void buildSingleTeam(GameTeam team, int playerCount) + { + setItem(13, getTeamItem(team, playerCount)); - @Override - public int compare(Player o1, Player o2) - { - return o1.getName().compareToIgnoreCase(o2.getName()); - } - - }); + ArrayList players = team.GetPlayers(true); - int slot = 19; + Collections.sort(players, new Comparator() + { - for (Player other : players) - { - addPlayerItem(slot, team, other); + @Override + public int compare(Player o1, Player o2) + { + return o1.getName().compareToIgnoreCase(o2.getName()); + } - if ((slot + 2) % 9 == 0) - slot += 3; - else - slot++; - } - } + }); - private void buildMultipleTeams(List teamList, int playerCount) - { - int currentRow = 0; + int slot = 19; - for (GameTeam team : teamList) - { - ArrayList teamPlayers = team.GetPlayers(true); - int rowsNeeded = (teamPlayers.size() / 8) + 1; - - Collections.sort(teamPlayers, new Comparator() - { + for (Player other : players) + { + addPlayerItem(slot, team, other); - @Override - public int compare(Player o1, Player o2) - { - return o1.getName().compareToIgnoreCase(o2.getName()); - } - - }); + if ((slot + 2) % 9 == 0) + slot += 3; + else + slot++; + } + } - for (int row = 0; row < rowsNeeded; row++) - { - int woolSlot = (row * 9) + (currentRow * 9); + private void buildMultipleTeams(List teamList, int playerCount) + { + int currentRow = 0; - // TODO Need to handle too many players in a better way - if (woolSlot >= getSize()) - continue; + for (GameTeam team : teamList) + { + ArrayList teamPlayers = team.GetPlayers(true); + int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0); - setItem(woolSlot, getTeamItem(team, teamPlayers.size())); + Collections.sort(teamPlayers, new Comparator() + { - int startPlayerIndex = row * 9; - for (int playerIndex = startPlayerIndex; playerIndex < teamPlayers.size() && playerIndex < startPlayerIndex + 9; playerIndex++) - { - Player other = teamPlayers.get(playerIndex); - int slot = woolSlot + 1 + playerIndex; + @Override + public int compare(Player o1, Player o2) + { + return o1.getName().compareToIgnoreCase(o2.getName()); + } - // TODO Need to handle too many players in a better way - if (slot >= getSize()) - continue; + }); - addPlayerItem(slot, team, other); - } - } + for (int row = 0; row < rowsNeeded; row++) + { + int woolSlot = (row * 9) + (currentRow * 9); - // 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; - } - } + // TODO Need to handle too many players in a better way + if (woolSlot >= getSize()) + continue; - 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)); - } + setItem(woolSlot, getTeamItem(team, teamPlayers.size())); - private ItemStack getTeamItem(GameTeam team, int playerCount) - { - ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, UtilColor.chatColorToWoolData(team.GetColor())); + int startPlayerIndex = row * 8; + int count = 0; + for (int playerIndex = startPlayerIndex; playerIndex < teamPlayers.size() && count < 8; playerIndex++) + { + count++; + Player other = teamPlayers.get(playerIndex); + int slot = woolSlot + 1 + playerIndex; - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(team.GetFormattedName()); - meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + "Players Alive: " + C.cWhite + playerCount)); - item.setItemMeta(meta); + // TODO Need to handle too many players in a better way + if (slot >= getSize()) + continue; - return item; - } + addPlayerItem(slot, team, other); + } + } - private ItemStack getPlayerItem(GameTeam team, Player other) - { - ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3); + // 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; + } + } - double distance = UtilMath.offset(getPlayer(), other); - double heightDifference = other.getLocation().getY() - getPlayer().getLocation().getY(); + 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)); + } - 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(" "); - lore.add(ChatColor.RESET + C.Line + "Click to Spectate"); - SkullMeta skullMeta = ((SkullMeta) item.getItemMeta()); - skullMeta.setOwner(other.getName()); - skullMeta.setDisplayName(team.GetColor() + other.getName()); - skullMeta.setLore(lore); - item.setItemMeta(skullMeta); + private ItemStack getTeamItem(GameTeam team, int playerCount) + { + ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, UtilColor.chatColorToWoolData(team.GetColor())); - return item; - } + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(team.GetFormattedName()); + meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + "Players Alive: " + C.cWhite + playerCount)); + item.setItemMeta(meta); + + return item; + } + + private ItemStack getPlayerItem(GameTeam team, Player other) + { + ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3); + + double distance = UtilMath.offset(getPlayer(), other); + 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(" "); + lore.add(ChatColor.RESET + C.Line + "Click to Spectate"); + SkullMeta skullMeta = ((SkullMeta) item.getItemMeta()); + skullMeta.setOwner(other.getName()); + skullMeta.setDisplayName(team.GetColor() + other.getName()); + skullMeta.setLore(lore); + item.setItemMeta(skullMeta); + + return item; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java index b432b532b..ac6763c56 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java @@ -108,12 +108,16 @@ public class PerkFletcher extends Perk if (!Kit.HasKit(cur)) continue; - + if (!Manager.GetGame().IsAlive(cur)) continue; - - if (UtilPlayer.isChargingBow(cur)) - continue; + + // Enabling this causes a bug that will sometimes prevent players from getting new arrows + // Believe this bug is related to when a player fires an arrow and gets an arrow in their inventory at the same + // time which causes their inventory to not be in sync with the server. Best known fix right now + // is to remove this check or keep calling UtilInv.update() +// if (UtilPlayer.isChargingBow(cur)) +// continue; if (!Recharge.Instance.use(cur, GetName(), _time * 1000, false, false)) continue; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index 2337f1f77..f91764e84 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -72,11 +72,7 @@ public class GameCreationManager implements Listener //Archive Game if (Manager.GetGame() != null) - { - //Don't End UHC - if (Manager.GetGame().GetType() == GameType.UHC) - return; - + { if (Manager.GetGame().GetState() == GameState.Dead) { HandlerList.unregisterAll(Manager.GetGame()); 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 a7ad88e59..deba82717 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 @@ -509,7 +509,7 @@ public class GameHostManager implements Listener public int getMaxPlayerCap() { - if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE) + if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE || _hostRank == Rank.TWITCH) return 100; else if (hasRank(Rank.LEGEND)) return 40; 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 fe3a858b4..e70531e48 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 @@ -35,10 +35,10 @@ import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; + import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_7_R4.WatchableObject; - import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -70,6 +70,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitSorter; @@ -110,6 +111,8 @@ public class GameLobbyManager implements Listener, IPacketHandler private boolean _handlingPacket = false; private String _serverName; + + private boolean _colorTick = false; public GameLobbyManager(ArcadeManager manager, PacketHandler packetHandler) { @@ -130,7 +133,7 @@ public class GameLobbyManager implements Listener, IPacketHandler _teamDisplay = new Location(world, 18, 101, 0); Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - + _serverName = Manager.getPlugin().getConfig().getString("serverstatus.name"); _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); } @@ -327,50 +330,52 @@ public class GameLobbyManager implements Listener, IPacketHandler //UHC if (game.GetType() == GameType.UHC) { - if (game.GetTeamList().size() > 1) - { - //Text - WriteTeamLine("", 0, 159, (byte)15); - WriteTeamLine("", 1, 159, (byte)4); - - for (int i=0 ; i 1) +// { +// //Text +// WriteTeamLine("", 0, 159, (byte)15); +// WriteTeamLine("", 1, 159, (byte)4); +// +// for (int i=0 ; i entry : _scoreboardMap.entrySet()) { Objective objective = entry.getValue().getObjective("§l" + "Lobby"); @@ -959,7 +966,14 @@ public class GameLobbyManager implements Listener, IPacketHandler } else { - objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players"); + if (Manager.GetGame() instanceof UHC && !((UHC)Manager.GetGame()).isMapLoaded()) + { + objective.setDisplayName(((UHC)Manager.GetGame()).getMapLoadPercent() + " " + (_colorTick ? ChatColor.GREEN : ChatColor.YELLOW) + "§l" + "Generating Map"); + } + else + { + objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players"); + } } int line = 15; @@ -1203,21 +1217,42 @@ public class GameLobbyManager implements Listener, IPacketHandler rankName = Rank.ULTRA.Name; } - teamName = rankName + teamName; + String rankTeamName = rankName + teamName; for (Scoreboard scoreboard : GetScoreboards()) { try { - scoreboard.getTeam(teamName).addPlayer(player); + scoreboard.getTeam(rankTeamName).addPlayer(player); } catch (Exception e) { - System.out.println("GameLobbyManager AddPlayerToScoreboard Error"); - System.out.println("[" + rankName + teamName + "] adding [" + player.getName() + "]"); - System.out.println("Team is Null [" + (scoreboard.getTeam(rankName + teamName) == null) + "]"); + //UHC adds people to teams earlier than usual, which can case this + if (Manager.GetGame() instanceof UHC) + { + try + { + Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName).addPlayer(player); + System.out.println("GameLobbyManager UHC Team Assignment Success"); + break; + } + catch(Exception f) + { + System.out.println("GameLobbyManager AddPlayerToScoreboard UHC Error"); + System.out.println("[" + teamName + "] adding [" + player.getName() + "]"); + System.out.println("Team is Null [" + (Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName) == null) + "]"); + } + } + else + { + System.out.println("GameLobbyManager AddPlayerToScoreboard Error"); + System.out.println("[" + rankTeamName + "] adding [" + player.getName() + "]"); + System.out.println("Team is Null [" + (scoreboard.getTeam(rankTeamName) == null) + "]"); + } } } + + } @EventHandler 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 03dbcb835..561ebbb7f 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 @@ -224,16 +224,8 @@ public class GameManager implements Listener public void StateCountdown(Game game, int timer, boolean force) { - //Always give time to pick team. - if (!game.GetCountdownForce() && !force && !UtilTime.elapsed(game.GetStateTime(), game.GetType() == GameType.UHC ? 150000 : 15000)) - { - if (game.GetType() == GameType.UHC) - { - ((UHC)game).informStartSoon(); - } - + if (game instanceof UHC && !((UHC)game).isMapLoaded()) return; - } //Disabling Cosmetics if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0 && game.GadgetsDisabled) @@ -247,7 +239,7 @@ public class GameManager implements Listener if (force) game.SetCountdownForce(true); - + //Team Preference TeamPreferenceJoin(game); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java index 400e46a4a..418871ce9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java @@ -50,10 +50,12 @@ public class MiscManager implements Listener Player player = event.getPlayer(); //BoneMeal - if (event.getPlayer().getItemInHand().getType() == Material.INK_SACK && event.getPlayer().getItemInHand().getData().getData() == (byte)15) + if (!Manager.GetGame().WorldBoneMeal && + event.getAction() == Action.RIGHT_CLICK_BLOCK && + event.getPlayer().getItemInHand().getType() == Material.INK_SACK && + event.getPlayer().getItemInHand().getData().getData() == (byte)15) { - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && Manager.GetGame().GetType() != GameType.UHC && Manager.GetGame().GetType() != GameType.Build) - event.setCancelled(true); + event.setCancelled(true); } else if (Manager.GetGame().GetState() != GameState.Live) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java index e8fd01bf0..1280ce912 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java @@ -44,7 +44,7 @@ public class ExperienceStatTracker extends StatTracker for (Player player : event.GetGame().GetPlayers(false)) { //Tally Gems - double gems = 0; + double gemExp = 0; for (String reason : event.GetGame().GetGems(player).keySet()) { if (reason.toLowerCase().contains("participation")) @@ -52,21 +52,20 @@ public class ExperienceStatTracker extends StatTracker GemData gem = event.GetGame().GetGems(player).get(reason); - gems += (int)gem.Gems; + gemExp += (int)gem.Gems; } - - gems = Math.min(gems, 250); + gemExp = Math.min(gemExp, 250) * 6; - //Game Time - double time = (System.currentTimeMillis() - _startTime)/60000d; + //Game Time = 1 Exp per 3 Seconds + double timeExp = (System.currentTimeMillis() - _startTime)/1500d; //Mult double mult = 1; - if (!winners.contains(player)) - mult = 0.25; + if (winners.contains(player)) + mult = 1.5; - //Exp - int expGained = (int)(time*gems*mult); + //Exp + int expGained = (int)((timeExp + gemExp)*mult); //Record Global and per Game addStat(player, "ExpEarned", expGained, false, true); 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 9d1649f64..1f2a1c78c 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 @@ -17,11 +17,13 @@ import mineplex.core.common.util.WorldUtil; import mineplex.core.common.util.ZipUtil; import mineplex.core.timing.TimingManager; import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.uhc.UHC; import net.minecraft.server.v1_7_R4.ChunkPreLoadEvent; import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.World.Environment; import org.bukkit.WorldCreator; import org.bukkit.event.world.ChunkUnloadEvent; @@ -80,7 +82,31 @@ public class WorldData { TimingManager.start("WorldData loading world."); //Start World - World = WorldUtil.LoadWorld(new WorldCreator(GetFolder())); + + if (Host instanceof UHC) + { + //Delete Old World + File dir = new File(GetFolder() + "/data"); + FileUtil.DeleteFolder(dir); + + dir = new File(GetFolder() + "/region"); + FileUtil.DeleteFolder(dir); + + dir = new File(GetFolder() + "/level.dat"); + if (dir.exists()) + dir.delete(); + + //Create Fresh World with Random Seed + WorldCreator creator = new WorldCreator(GetFolder()); + creator.seed(UtilMath.r(999999999)); + creator.environment(Environment.NORMAL); + creator.generateStructures(true); + World = WorldUtil.LoadWorld(creator); + } + else + { + World = WorldUtil.LoadWorld(new WorldCreator(GetFolder())); + } TimingManager.stop("WorldData loading world."); World.setDifficulty(Difficulty.HARD); diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index 2fcca62f9..5aa571908 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -59,10 +59,17 @@ public List GetAllAccountNamesMatching(string name) { + var accounts = new List(); + using (var repository = _repositoryFactory.CreateRepository()) { - return repository.GetAll().Where(c => c.Name == name).Select(y => y.Name).ToList(); + var account = repository.Where(x => x.Name == name).OrderByDescending(y => y.LastLogin).FirstOrDefault(); + + if (account != null) + accounts.Add(account.Name); } + + return accounts; } private object getAccountLock(string name) @@ -86,9 +93,6 @@ { var account = repository.Where(x => x.Uuid == loginToken.Uuid).FirstOrDefault(); - if (account == default(Account)) - account = repository.Where(x => x.Name == loginToken.Name).FirstOrDefault(); - if (account == default(Account)) account = CreateAccount(loginToken, repository); @@ -234,7 +238,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == token.Name).FirstOrDefault(); + var account = repository.Where(x => x.Name == token.Name).OrderByDescending(x => x.LastLogin).FirstOrDefault(); if (account == null) return false; @@ -261,7 +265,7 @@ using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == token.Name).FirstOrDefault(); + var account = repository.Where(x => x.Name == token.Name).OrderByDescending(x => x.LastLogin).FirstOrDefault(); if (account == null) return false; @@ -280,7 +284,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == token.Name).FirstOrDefault(); + var account = repository.Where(x => x.Name == token.Name).OrderByDescending(x => x.LastLogin).FirstOrDefault(); if (account == null) return false; @@ -307,7 +311,7 @@ using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == token.Name).FirstOrDefault(); + var account = repository.Where(x => x.Name == token.Name).OrderByDescending(x => x.LastLogin).FirstOrDefault(); if (account == null) return false; @@ -324,7 +328,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == token.Name).Include(x => x.Tasks).FirstOrDefault(); + var account = repository.Where(x => x.Name == token.Name).OrderByDescending(x => x.LastLogin).Include(x => x.Tasks).FirstOrDefault(); if (account != null) { @@ -349,7 +353,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == punish.Target).Include(x => x.Rank).FirstOrDefault(); + var account = repository.Where(x => x.Name == punish.Target).OrderByDescending(x => x.LastLogin).Include(x => x.Rank).FirstOrDefault(); if (account == null) return PunishmentResponse.AccountDoesNotExist; @@ -357,7 +361,7 @@ if (!String.Equals(punish.Admin, "Mineplex Enjin Server")) { var punisher = - repository.Where(x => x.Name == punish.Admin).Include(x => x.Rank).FirstOrDefault(); + repository.Where(x => x.Name == punish.Admin).OrderByDescending(x => x.LastLogin).Include(x => x.Rank).FirstOrDefault(); if (punisher == null) return PunishmentResponse.NotPunished; @@ -392,7 +396,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == token.Target).Include(x => x.Punishments).FirstOrDefault(); + var account = repository.Where(x => x.Name == token.Target).OrderByDescending(x => x.LastLogin).Include(x => x.Punishments).FirstOrDefault(); if (account == null) return PunishmentResponse.AccountDoesNotExist; @@ -429,7 +433,7 @@ using (var repository = _repositoryFactory.CreateRepository()) { var account = - repository.Where(x => x.Name == token.AccountName) + repository.Where(x => x.Name == token.AccountName).OrderByDescending(x => x.LastLogin) .Include(x => x.PvpTransactions) .First(); @@ -489,7 +493,7 @@ using (var repository = _repositoryFactory.CreateRepository()) { var account = - repository.Where(x => x.Name == token.PlayerName).Include(x => x.CustomBuilds).First(); + repository.Where(x => x.Name == token.PlayerName).OrderByDescending(x => x.LastLogin).Include(x => x.CustomBuilds).First(); var customBuild = account.CustomBuilds.FirstOrDefault( @@ -531,7 +535,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == accountName).First(); + var account = repository.Where(x => x.Name == accountName).OrderByDescending(x => x.LastLogin).First(); account.IgnoredPlayers.Add(ignoredPlayer); @@ -543,7 +547,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == accountName).First(); + var account = repository.Where(x => x.Name == accountName).OrderByDescending(x => x.LastLogin).First(); account.IgnoredPlayers.Remove(ignoredPlayer); @@ -561,6 +565,7 @@ { var account = repository.Where(x => x.Name == token.AccountName) + .OrderByDescending(x => x.LastLogin) .Include(x => x.AccountTransactions) .First(); @@ -610,7 +615,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => String.Equals(x.Name, name)).Include(x => x.Rank).FirstOrDefault(); + var account = repository.Where(x => String.Equals(x.Name, name)).OrderByDescending(x => x.LastLogin).Include(x => x.Rank).FirstOrDefault(); account.LoadNavigationProperties(repository.Context); addAccountTransaction(repository, account, "Bacon Brawl Bebe Piggles", 0, 0); @@ -693,7 +698,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); + var account = repository.Where(x => String.Equals(x.Name, token.Name)).OrderByDescending(x => x.LastLogin).Include(x => x.Rank).FirstOrDefault(); rank = repository.Where(x => String.Equals(x.Name, token.Rank)).FirstOrDefault(); if (account == null) @@ -717,7 +722,7 @@ using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); + var account = repository.Where(x => String.Equals(x.Name, token.Name)).OrderByDescending(x => x.LastLogin).Include(x => x.Rank).FirstOrDefault(); if (token.Retries >= 3) _logger.Log("ERROR", "Applying UpdateRank, retried 3 times and something didn't stick."); @@ -740,7 +745,7 @@ { using (var repository = _repositoryFactory.CreateRepository()) { - var account = repository.Where(x => x.Name == token.Target).Include(x => x.Punishments).FirstOrDefault(); + var account = repository.Where(x => x.Name == token.Target).OrderByDescending(x => x.LastLogin).Include(x => x.Punishments).FirstOrDefault(); if (account == null) return; @@ -801,7 +806,7 @@ protected Account GetAccountByName(string name, IRepository repository) { - var account = repository.Where(x => x.Name == name).FirstOrDefault(); + var account = repository.Where(x => x.Name == name).OrderByDescending(y => y.LastLogin).FirstOrDefault(); account.LoadNavigationProperties(repository.Context); return account; diff --git a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml index 3aaebf02d..2d91aaa08 100644 --- a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml +++ b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml @@ -7,7 +7,6 @@ - @@ -18,7 +17,7 @@ - + @@ -27,27 +26,27 @@ - - + - + - + + @@ -61,9 +60,10 @@ - + + @@ -78,7 +78,9 @@ + + @@ -92,12 +94,11 @@ - - + @@ -107,17 +108,17 @@ - + - + + - + - @@ -125,24 +126,22 @@ - - + - + - - + @@ -156,7 +155,7 @@ - + @@ -176,8 +175,8 @@ - - + + @@ -188,13 +187,12 @@ - - + @@ -215,16 +213,16 @@ - + - + - + - + @@ -239,14 +237,15 @@ - + - + + - + @@ -261,12 +260,14 @@ + + @@ -280,27 +281,28 @@ - + + + - - + - + @@ -319,7 +321,6 @@ - @@ -335,8 +336,6 @@ - - @@ -348,7 +347,6 @@ - @@ -365,17 +363,20 @@ + - + + + @@ -388,16 +389,17 @@ + - + - + @@ -409,7 +411,7 @@ - + @@ -437,10 +439,9 @@ - - + @@ -448,7 +449,6 @@ - @@ -461,13 +461,13 @@ - + - + @@ -481,7 +481,7 @@ - + @@ -500,9 +500,9 @@ - + - + @@ -516,7 +516,7 @@ - + @@ -526,10 +526,11 @@ - + + @@ -543,28 +544,29 @@ - + - + + - + - + @@ -582,7 +584,7 @@ - + @@ -599,8 +601,6 @@ - - @@ -611,10 +611,10 @@ - + @@ -622,24 +622,23 @@ - - + + - - + - + @@ -649,13 +648,15 @@ - + + + @@ -673,13 +674,13 @@ - + - + @@ -694,16 +695,15 @@ - + - + - - + @@ -711,7 +711,6 @@ - @@ -724,13 +723,13 @@ - + - + - + @@ -744,11 +743,12 @@ + - + - + @@ -763,9 +763,9 @@ - + - + @@ -779,7 +779,7 @@ - + @@ -793,6 +793,7 @@ + @@ -806,28 +807,29 @@ - + - + + - + - + @@ -862,8 +864,6 @@ - - @@ -874,10 +874,10 @@ - + @@ -890,19 +890,18 @@ - - + - + @@ -912,13 +911,15 @@ - + + + @@ -936,13 +937,13 @@ - + - + @@ -963,10 +964,9 @@ - - + @@ -974,7 +974,6 @@ - @@ -987,13 +986,13 @@ - + - + - + @@ -1007,8 +1006,9 @@ + - + @@ -1026,9 +1026,9 @@ - + - + @@ -1042,7 +1042,7 @@ - + diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index e04015bc9..16718f837 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ