diff --git a/Art/Carl.png b/Art/Carl.png new file mode 100644 index 000000000..5d4fe6d36 Binary files /dev/null and b/Art/Carl.png differ diff --git a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml b/Plugins/.idea/artifacts/Mineplex_Hub_test.xml index d164c4c6a..0527ee7d4 100644 --- a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml +++ b/Plugins/.idea/artifacts/Mineplex_Hub_test.xml @@ -1,5 +1,5 @@ - + $PROJECT_DIR$/../Testing/Hub/plugins diff --git a/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml b/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml new file mode 100644 index 000000000..372114469 --- /dev/null +++ b/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml @@ -0,0 +1,24 @@ + + + $PROJECT_DIR$/out/artifacts/ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index ccd5607c1..27bcf4d80 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -20,8 +20,16 @@ + + + + + + - + + + + + + diff --git a/Plugins/.idea/modules.xml b/Plugins/.idea/modules.xml index 1a9d9336c..14d5d7c0f 100644 --- a/Plugins/.idea/modules.xml +++ b/Plugins/.idea/modules.xml @@ -15,6 +15,8 @@ + + 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 941527a80..fa7f5c43c 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -39,8 +39,9 @@ public class MotdManager implements Listener, Runnable if (new File("updateMOTD.dat").exists()) { List lines = new ArrayList(); - lines.add(" §b§l◄§f§lNEW§b§l► §f§l◄§b§lSKYWARS§f§l► §b§l◄§f§lNEW§b§l►"); + lines.add(" §f§l◄ §6§lNEW §f§l▬ §c§lSSM/SG/SW Teams§f§l ▬ §c§lMPS Update §f§l►"); //lines.add(" §d§lRank Sale §a§l40% Off"); + //lines.add(" §f§l◄§c§lMAINTENANCE§f§l►"); updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines); System.out.println("Updated Bungee MOTD"); diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java index 24e40892c..1b8117d04 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java @@ -56,7 +56,7 @@ public class PlayerTracker implements Listener { public void run() { - _repository.removeElement(event.getPlayer().getName()); + _repository.removeElement(event.getPlayer().getName().toLowerCase()); } }); } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java index b8c7eb796..6a007fefa 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java @@ -8,7 +8,7 @@ public enum CurrencyType Coins(" Coins", Material.DOUBLE_PLANT), Gems(" Gems", Material.EMERALD), Gold(" Gold", Material.GOLD_NUGGET); - + private String _prefix; private Material _displayMaterial; 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 47719668a..74e648808 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -1,23 +1,24 @@ package mineplex.core.common; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; - import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; + public enum Rank { LT("LT", ChatColor.DARK_RED), OWNER("Owner", ChatColor.DARK_RED), DEVELOPER("Dev", ChatColor.RED), ADMIN("Admin", ChatColor.RED), + JNR_DEV("Jr.Dev", ChatColor.RED), SNR_MODERATOR("Sr.Mod", ChatColor.GOLD), MODERATOR("Mod", ChatColor.GOLD), - JNR_DEV("Jr.Dev", ChatColor.RED), HELPER("Trainee", ChatColor.DARK_AQUA), MAPLEAD("MapLead", ChatColor.DARK_PURPLE), MAPDEV("Builder", ChatColor.BLUE), + MEDIA("Media", ChatColor.BLUE), EVENT("Event", ChatColor.WHITE), @@ -51,10 +52,6 @@ public enum Rank public boolean Has(Player player, Rank rank, Rank[] specific, boolean inform) { - if (player != null) - if (player.getName().equals("Chiss")) - return true; - //Specific Rank if (specific != null) { @@ -75,7 +72,7 @@ public enum Rank { UtilPlayer.message(player, C.mHead + "Permissions> " + C.mBody + "This requires Permission Rank [" + - C.mHead + rank + + C.mHead + rank.Name.toUpperCase() + C.mBody + "]."); } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java index 95ebe63d8..e3b8c1d0a 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.plugin.java.JavaPlugin; @@ -85,7 +86,8 @@ public class SchematicRunnable implements Runnable // We are done System.out.println("Finished importing schematic with setblockrunnable!"); - if (_callback != null) _callback.run(_changedBlocks); + if (_callback != null) + _callback.run(_changedBlocks); _task.cancel(); return; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java index 1b870ada9..50d8fe661 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java @@ -1,11 +1,23 @@ package mineplex.core.common.util; - import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.util.Vector; public class UtilAction { + private static VelocityReceiver _velocityFix; + + public static void registerVelocityFix(VelocityReceiver velocityFix) + { + _velocityFix = velocityFix; + } + + public static void velocity(Entity ent, Vector vec) + { + velocity(ent, vec, vec.length(), false, 0, 0, vec.length(), false); + } + public static void velocity(Entity ent, double str, double yAdd, double yMax, boolean groundBoost) { velocity(ent, ent.getLocation().getDirection(), str, false, 0, yAdd, yMax, groundBoost); @@ -14,8 +26,11 @@ public class UtilAction public static void velocity(Entity ent, Vector vec, double str, boolean ySet, double yBase, double yAdd, double yMax, boolean groundBoost) { if (Double.isNaN(vec.getX()) || Double.isNaN(vec.getY()) || Double.isNaN(vec.getZ()) || vec.length() == 0) + { + zeroVelocity(ent); return; - + } + //YSet if (ySet) vec.setY(yBase); @@ -23,20 +38,43 @@ public class UtilAction //Modify vec.normalize(); vec.multiply(str); - + //YAdd vec.setY(vec.getY() + yAdd); - + //Limit if (vec.getY() > yMax) vec.setY(yMax); - + if (groundBoost) if (UtilEnt.isGrounded(ent)) vec.setY(vec.getY() + 0.2); - + //Velocity ent.setFallDistance(0); - ent.setVelocity(vec); + + //Store It! + if (ent instanceof Player && _velocityFix != null) + { + _velocityFix.setPlayerVelocity(((Player)ent), vec); + } + + ent.setVelocity(vec); } + + public static void zeroVelocity(Entity ent) + { + Vector vec = new Vector(0,0,0); + ent.setFallDistance(0); + + //Store It! + if (ent instanceof Player && _velocityFix != null) + { + _velocityFix.setPlayerVelocity(((Player)ent), vec); + } + + ent.setVelocity(vec); + } + + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index fad8f1eef..8969368a4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -7,6 +7,7 @@ import java.util.TreeSet; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -25,7 +26,7 @@ public class UtilAlg public static Location getMidpoint(Location a, Location b) { - return a.add(b.subtract(a).multiply(0.5)); + return a.clone().add(b.clone().subtract(a.clone()).multiply(0.5)); } public static Vector getTrajectory(Entity from, Entity to) @@ -260,4 +261,132 @@ public class UtilAlg return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) || isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit); } + + public static Location getLocationAwayFromPlayers(ArrayList locs, ArrayList players) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double closest = -1; + + for (Player player : players) + { + //Different Worlds + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (closest == -1 || dist < closest) + { + closest = dist; + } + } + + if (closest == -1) + continue; + + if (bestLoc == null || closest > bestDist) + { + bestLoc = loc; + bestDist = closest; + } + } + + return bestLoc; + } + + public static Location getLocationNearPlayers(ArrayList locs, ArrayList players, ArrayList dontOverlap) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double closest = -1; + + boolean valid = true; + + //Dont spawn on other players + for (Player player : dontOverlap) + { + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (dist < 0.8) + { + valid = false; + break; + } + } + + if (!valid) + continue; + + //Find closest player + for (Player player : players) + { + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (closest == -1 || dist < closest) + { + closest = dist; + } + } + + if (closest == -1) + continue; + + if (bestLoc == null || closest < bestDist) + { + bestLoc = loc; + bestDist = closest; + } + } + + return bestLoc; + } + + public static Vector calculateVelocity(Vector from, Vector to, int heightGain) + { + // Gravity of a potion + double gravity = 0.115; + // Block locations + int endGain = to.getBlockY() - from.getBlockY(); + + double dx1 = to.getBlockX() - from.getBlockX(); + double dz1 = to.getBlockZ() - from.getBlockZ(); + + double horizDist = Math.sqrt(dx1 * dx1 + dz1 * dz1); + // Height gain + int gain = heightGain; + double maxGain = gain > (endGain + gain) ? gain : (endGain + gain); + // Solve quadratic equation for velocity + double a = -horizDist * horizDist / (4 * maxGain); + double b = horizDist; + double c = -endGain; + double slope = -b / (2 * a) - Math.sqrt(b * b - 4 * a * c) / (2 * a); + // Vertical velocity + double vy = Math.sqrt(maxGain * gravity); + // Horizontal velocity + double vh = vy / slope; + // Calculate horizontal direction + int dx = to.getBlockX() - from.getBlockX(); + int dz = to.getBlockZ() - from.getBlockZ(); + double mag = Math.sqrt(dx * dx + dz * dz); + double dirx = dx / mag; + double dirz = dz / mag; + // Horizontal velocity components + double vx = vh * dirx; + double vz = vh * dirz; + return new Vector(vx, vy, vz); + } + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index d87d16fa5..8b489c952 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -4,21 +4,24 @@ import java.lang.reflect.Field; import java.util.HashMap; import java.util.LinkedList; 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.EntityTrackerEntry; import net.minecraft.server.v1_7_R4.Navigation; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityHeadRotation; import net.minecraft.server.v1_7_R4.PathfinderGoal; import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer; import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction; import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_7_R4.PathfinderGoalSelector; +import net.minecraft.server.v1_7_R4.WorldServer; import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -32,6 +35,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Giant; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; @@ -582,6 +586,36 @@ public class UtilEnt return false; } + public static boolean CreatureLook(Entity ent, Entity target) + { + return CreatureLook(ent, target instanceof LivingEntity ? ((LivingEntity) target).getEyeLocation() : target.getLocation()); + } + + public static boolean CreatureLook(Entity ent, Location target) + { + Vector vec = UtilAlg.getTrajectory(ent.getLocation(), target); + + return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); + } + + public static boolean CreatureLook(Entity ent, float pitch, float yaw) + { + if (!(ent instanceof LivingEntity)) + return false; + + EntityLiving ec = ((CraftLivingEntity) ent).getHandle(); + Location loc = ent.getLocation(); + + ec.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), yaw, pitch); + ec.al = true; + + EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.world).tracker.trackedEntities.get(ec.getId()); + + entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, (byte) (ec.yaw * 256.0F / 360.0F))); + + return true; + } + public static void CreatureMove(Entity ent, Location target, float speed) { if (!(ent instanceof Creature)) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java index 79059c454..bd5346696 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java @@ -16,7 +16,8 @@ public class UtilEvent L_BLOCK, R, R_AIR, - R_BLOCK + R_BLOCK, + ANY } public static boolean isAction(PlayerInteractEvent event, ActionType action) @@ -39,6 +40,9 @@ public class UtilEvent if (action == ActionType.R_BLOCK) return (event.getAction() == Action.RIGHT_CLICK_BLOCK); + if (action == ActionType.ANY) + return event.getAction() != Action.PHYSICAL; + return false; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 396526e82..7c5f2ce64 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -90,5 +90,11 @@ public class UtilMath return Math.random() * d; } + + public static T randomElement(T[] array) { + if (array.length == 0) + return null; + return array[random.nextInt(array.length)]; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 5ad7351a6..60b2d613d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -7,21 +7,25 @@ import java.util.List; import java.util.Random; import java.util.UUID; +import net.minecraft.server.v1_7_R4.EntityPlayer; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PlayerConnection; + import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; -import net.minecraft.server.v1_7_R4.Packet; -import net.minecraft.server.v1_7_R4.PlayerConnection; - public class UtilPlayer { private static Random RANDOM = new Random(); @@ -655,7 +659,19 @@ public class UtilPlayer return ((CraftPlayer) player).getHandle().spectating; return false; } - + + public static InventoryView swapToInventory(Player player, Inventory inv) { + + EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + if (nmsPlayer.activeContainer != nmsPlayer.defaultContainer) + { + // Do this so that other inventories know their time is over. + CraftEventFactory.handleInventoryCloseEvent(nmsPlayer); + nmsPlayer.m(); + } + return player.openInventory(inv); + } + /* public void setListName(Player player, CoreClient client) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index 694739fa9..4372b6fba 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -2,6 +2,8 @@ package mineplex.core.common.util; import java.util.Collection; +import org.apache.commons.lang.WordUtils; + public class UtilText { public static String listToString(Collection inputList, boolean comma) { String out = ""; @@ -48,6 +50,11 @@ public class UtilText { public static boolean isStringSimilar(String newString, String oldString, float matchRequirement) { + if (newString.length() <= 3) + { + return newString.toLowerCase().equals(oldString.toLowerCase()); + } + for (int i=0 ; i < newString.length() * matchRequirement ; i++) { int matchFromIndex = 0; @@ -56,7 +63,7 @@ public class UtilText { for (int j=0 ; j < oldString.length() ; j++) { //End of newString - if (i+j > newString.length()) + if (i+j >= newString.length()) { break; } @@ -79,4 +86,13 @@ public class UtilText { return false; } + + public static String[] wrap(String text, int lineLength) + { + return wrap(text, lineLength, true); + } + + public static String[] wrap(String text, int lineLength, boolean wrapLongerWords) { + return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0"); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/VelocityReceiver.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/VelocityReceiver.java new file mode 100644 index 000000000..8d621dab8 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/VelocityReceiver.java @@ -0,0 +1,9 @@ +package mineplex.core.common.util; + +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public interface VelocityReceiver +{ + public void setPlayerVelocity(Player player, Vector velocity); +} diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index 8171cd881..b60bc08f6 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -12,7 +12,7 @@ - + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java index 92e2ea3cb..2f479adeb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java @@ -21,7 +21,7 @@ public abstract class MiniDbClientPlugin extends MiniCl clientManager.addStoredProcedureLoginProcessor(this); } - public abstract void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException; + public abstract void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException; public CoreClientManager getClientManager() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java b/Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java new file mode 100644 index 000000000..c531ad097 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java @@ -0,0 +1,10 @@ +package mineplex.core; + +import fr.neatmonster.nocheatplus.config.ConfigManager; + +public class NCPDataManFix +{ + public NCPDataManFix() { + //ConfigManager.getConfigFile().set("data.consistencychecks.suppresswarnings", true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index ebec4be13..df6717c6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -8,8 +8,11 @@ public class CoreClient { private int _accountId = -1; private String _name; + private String _disguisedAs; private Player _player; private Rank _rank; + private Rank _disguisedRank; + private boolean _disguised; public CoreClient(Player player) { @@ -62,4 +65,34 @@ public class CoreClient { _rank = rank; } + + public String getDisguisedAs() + { + return _disguisedAs; + } + + public void setDisguisedAs(String originalName) + { + this._disguisedAs = originalName; + } + + /** + * Only use this method if the client is actually disguised! + * @return + */ + public Rank getDisguisedRank() { + return _disguisedRank; + } + + public void setDisguisedRank(Rank disguisedRank) { + this._disguisedRank = disguisedRank; + } + + public boolean isDisguised() { + return _disguised; + } + + public void setDisguised(boolean disguised) { + this._disguised = disguised; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index a76be2fcd..481bda4dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -2,6 +2,7 @@ package mineplex.core.account; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; import java.util.UUID; @@ -50,6 +51,7 @@ public class CoreClientManager extends MiniPlugin private RedisDataRepository _accountCacheRepository; private NautHashMap _loginProcessors = new NautHashMap(); + private LinkedList _querylessLoginProcessors = new LinkedList(); private Object _clientLock = new Object(); @@ -110,7 +112,7 @@ public class CoreClientManager extends MiniPlugin { _clientList.remove(name); } - + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name)); } @@ -118,16 +120,19 @@ public class CoreClientManager extends MiniPlugin { synchronized(_clientLock) { + for(CoreClient client : _clientList.values()) + { + if(client.getDisguisedAs() != null) + if(client.getDisguisedAs().equalsIgnoreCase(name)) + return client; + } return _clientList.get(name); } } public CoreClient Get(Player player) { - synchronized(_clientLock) - { - return _clientList.get(player.getName()); - } + return Get(player.getName()); } public int getPlayerCountIncludingConnecting() @@ -135,6 +140,16 @@ public class CoreClientManager extends MiniPlugin return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get()); } + /** + * Get the databse account id for a player. Requires the player is online + * @param player + * @return + */ + public int getAccountId(Player player) + { + return Get(player).getAccountId(); + } + @EventHandler(priority = EventPriority.LOWEST) public void AsyncLogin(AsyncPlayerPreLoginEvent event) { @@ -221,13 +236,13 @@ public class CoreClientManager extends MiniPlugin CoreClient client = Add(playerName); client.SetRank(Rank.valueOf(token.Rank)); - client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName())); + client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); if (client.getAccountId() > 0) - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId())); + _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); } catch (Exception exception) { @@ -248,7 +263,7 @@ public class CoreClientManager extends MiniPlugin }); } - private boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) + public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) { TimingManager.start(client.GetPlayerName() + " LoadClient Total."); long timeStart = System.currentTimeMillis(); @@ -261,7 +276,7 @@ public class CoreClientManager extends MiniPlugin { public void run() { - client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName())); + client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); _clientLoginLock.remove(client.GetPlayerName()); } }); @@ -301,7 +316,16 @@ public class CoreClientManager extends MiniPlugin System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId()); if (client.getAccountId() > 0) - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId())); + { + try + { + _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); + } + catch (Exception e) + { + e.printStackTrace(); + } + } return !_clientLoginLock.containsKey(client.GetPlayerName()); } @@ -442,7 +466,7 @@ public class CoreClientManager extends MiniPlugin callback.run(matchedName); return; } - + callback.run(matchedName); } }, caller, playerName, true); @@ -473,7 +497,9 @@ public class CoreClientManager extends MiniPlugin clientIterator.remove(); if (clientPlayer != null) + { _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName())); + } } } } @@ -495,6 +521,11 @@ public class CoreClientManager extends MiniPlugin { _loginProcessors.put(processor.getName(), processor); } + + public void addStoredProcedureLoginProcessor(IQuerylessLoginProcessor processor) + { + _querylessLoginProcessors.add(processor); + } public boolean hasRank(Player player, Rank rank) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java index aca0eb341..2f278165b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java @@ -7,7 +7,7 @@ public interface ILoginProcessor { String getName(); - void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException; + void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException; String getQuery(int accountId, String uuid, String name); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java new file mode 100644 index 000000000..7c69bb1c1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/IQuerylessLoginProcessor.java @@ -0,0 +1,6 @@ +package mineplex.core.account; + +public interface IQuerylessLoginProcessor +{ + public void processLogin(String playerName, int accountId); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java index 8ba37d68a..529148615 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java @@ -19,12 +19,20 @@ public class UpdateRank extends CommandBase { public UpdateRank(CoreClientManager plugin) { - super(plugin, Rank.ADMIN, "updateRank"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV /*On test servers only*/}, "updateRank"); } @Override public void Execute(final Player caller, String[] args) { + boolean testServer = Plugin.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + + if (Plugin.Get(caller).GetRank() == Rank.JNR_DEV && !testServer) + { + F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.GetTag(true, true)) + "s are only permitted to set ranks on test servers!"); + return; + } + if (args == null) { UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + AliasUsed + " joeschmo MODERATOR")); @@ -52,9 +60,10 @@ public class UpdateRank extends CommandBase final Rank rank = tempRank; - if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.JNR_DEV || rank == Rank.TWITCH || 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.JNR_DEV || 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.JNR_DEV || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR) { - if (rank == Rank.ADMIN && !Plugin.hasRank(caller, Rank.LT)) + if (!testServer && rank.Has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT)) { UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Insufficient privileges!")); return; @@ -114,4 +123,4 @@ public class UpdateRank extends CommandBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index 954f3eaa9..c8dccb23e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -6,6 +6,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.UUID; @@ -14,6 +15,7 @@ import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.IQuerylessLoginProcessor; import mineplex.core.account.repository.token.LoginToken; import mineplex.core.account.repository.token.RankUpdateToken; import mineplex.core.common.Rank; @@ -55,7 +57,7 @@ public class AccountRepository extends RepositoryBase //executeUpdate(CREATE_ACCOUNT_TABLE); } - public int login(NautHashMap loginProcessors, String uuid, String name) + public int login(NautHashMap loginProcessors, LinkedList querylessLoginProcessors, String uuid, String name) { int accountId = -1; try ( @@ -142,9 +144,14 @@ public class AccountRepository extends RepositoryBase for (ILoginProcessor loginProcessor : loginProcessors.values()) { - loginProcessor.processLoginResultSet(name, statement.getResultSet()); + loginProcessor.processLoginResultSet(name, accountId, statement.getResultSet()); statement.getMoreResults(); } + + for (IQuerylessLoginProcessor loginProcessor : querylessLoginProcessors) + { + loginProcessor.processLogin(name, accountId); + } } catch (Exception exception) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index a1d818cca..f122d3034 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -56,7 +56,7 @@ public enum Achievement //Survival Games SURVIVAL_GAMES_WINS("Katniss Everdeen", 600, new String[]{"Survival Games.Wins"}, - new String[]{"Win 30 games of Survival Games"}, + new String[]{"Win 20 games of Survival Games"}, new int[]{30}, AchievementCategory.SURVIVAL_GAMES), @@ -87,8 +87,8 @@ public enum Achievement //Skywars SKYWARS_WINS("Sky King",2000, new String[]{"Skywars.Wins"}, - new String[]{"Win 30 Games of Skywars"}, - new int[]{30}, + new String[]{"Win 20 Games of Skywars"}, + new int[]{20}, AchievementCategory.SKYWARS), SKYWARS_BOMBER("Master Bomber",500, @@ -326,7 +326,7 @@ public enum Achievement SUPER_PAINTBALL_FLAWLESS_VICTORY("Flawless Victory", 1000, new String[]{"Super Paintball.Wins"}, - new String[]{"Win a team with your entire team alive"}, + new String[]{"Win a game with your entire team alive"}, new int[]{1}, AchievementCategory.SUPER_PAINTBALL), @@ -630,6 +630,44 @@ public enum Achievement new String[]{"Kill 2 enemies while blinded from", "a single flashbang"}, new int[]{1}, AchievementCategory.MINE_STRIKE), + + //Bomb Lobbers + BOMB_LOBBERS_WINS("Master Bomber", 1200, + new String[]{"Bomb Lobbers.Wins"}, + new String[]{"Win 100 games of Bomb Lobbers"}, + new int[] {100}, + AchievementCategory.BOMB_LOBBERS), + + BOMB_LOBBERS_PROFESSIONAL_LOBBER("Professional Lobber", 1000, + new String[]{"Bomb Lobbers.Thrown"}, + new String[]{"Throw 2000 TNT"}, + new int[]{2000}, + AchievementCategory.BOMB_LOBBERS), + + BOMB_LOBBERS_ULTIMATE_KILLER("Ultimate Killer", 800, + new String[]{"Bomb Lobbers.Killer"}, + new String[]{"Kill 6 players in a single game"}, + new int[]{1}, + AchievementCategory.BOMB_LOBBERS), + + BOMB_LOBBERS_EXPLOSION_PROOF("Jelly Skin", 1200, + new String[]{"Bomb Lobbers.JellySkin"}, + new String[]{"Win a game without taking any damage."}, + new int[]{1}, + AchievementCategory.BOMB_LOBBERS), + + BOMB_LOBBERS_BLAST_PROOF("Blast Proof", 800, + new String[]{"Bomb Lobbers.BlastProof"}, + new String[]{"Win 20 games using Armorer"}, + new int[]{20}, + AchievementCategory.BOMB_LOBBERS), + + BOMB_LOBBERS_SNIPER("Sniper", 1000, + new String[]{"Bomb Lobbers.Direct Hit"}, + new String[]{"Get 50 direct hits"}, + new int[]{50}, + AchievementCategory.BOMB_LOBBERS) + ; private String _name; @@ -754,7 +792,7 @@ public enum Achievement return _category; } - public AchievementData getLevelData(int exp) + public AchievementData getLevelData(long exp) { for (int i = 0; i < _levels.length; i++) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index d777224ac..d19f0e93a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -15,8 +15,8 @@ import mineplex.core.stats.StatsManager; public enum AchievementCategory { GLOBAL("Global", null, - new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME }, - Material.EMERALD, 0, GameCategory.GLOBAL, null), + new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null, new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote") }, + Material.EMERALD, 0, GameCategory.GLOBAL, "None"), BRIDGES("The Bridges", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -28,15 +28,15 @@ public enum AchievementCategory SKYWARS("Skywars",null, new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, - Material.FEATHER, 5, GameCategory.SURVIVAL, "Destructor Kit"), + Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit"), UHC("Ultra Hardcore", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "Extra Class Skills"), + Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"), WIZARDS("Wizards", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"), + Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit"), CASTLE_SIEGE("Castle Siege", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"), @@ -45,7 +45,7 @@ public enum AchievementCategory BLOCK_HUNT("Block Hunt", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.GRASS, 0, GameCategory.CLASSICS, null), + Material.GRASS, 0, GameCategory.CLASSICS, "Infestor Kit"), SMASH_MOBS("Super Smash Mobs", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -53,11 +53,11 @@ public enum AchievementCategory MINE_STRIKE("MineStrike", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.TNT, 0, GameCategory.CLASSICS, null), + Material.TNT, 0, GameCategory.CLASSICS, "None"), DRAW_MY_THING("Draw My Thing", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, - Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, null), + Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit"), CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -65,7 +65,7 @@ public enum AchievementCategory MASTER_BUILDERS("Master Builders", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, - Material.WOOD, 0, GameCategory.CLASSICS, null), + Material.WOOD, 0, GameCategory.CLASSICS, "None"), //Arcade DRAGONS("Dragons", null, @@ -74,7 +74,7 @@ public enum AchievementCategory DRAGON_ESCAPE("Dragon Escape", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, - Material.DRAGON_EGG, 0, GameCategory.ARCADE, null), + Material.DRAGON_EGG, 0, GameCategory.ARCADE, "Digger Kit"), SHEEP_QUEST("Sheep Quest", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -82,11 +82,11 @@ public enum AchievementCategory SNEAKY_ASSASSINS("Sneaky Assassins", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.INK_SACK, 0, GameCategory.ARCADE, null), + Material.INK_SACK, 0, GameCategory.ARCADE, "Briber Kit"), ONE_IN_THE_QUIVER("One in the Quiver", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.BOW, 0, GameCategory.ARCADE, null), + Material.BOW, 0, GameCategory.ARCADE, "Slam Shooter Kit"), SUPER_PAINTBALL("Super Paintball", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -97,11 +97,11 @@ public enum AchievementCategory Material.HARD_CLAY, 14, GameCategory.ARCADE, null), RUNNER("Runner", null, - new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null), SPLEEF("Super Spleef", null, - new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.IRON_SPADE, 0, GameCategory.ARCADE, null), DEATH_TAG("Death Tag", null, @@ -110,7 +110,7 @@ public enum AchievementCategory SNAKE("Snake", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.WOOL, 4, GameCategory.ARCADE, null), + Material.WOOL, 4, GameCategory.ARCADE, "Reversal Snake Kit"), BACON_BRAWL("Bacon Brawl", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -118,9 +118,12 @@ public enum AchievementCategory MICRO_BATTLE("Micro Battle", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.LAVA, 0, GameCategory.ARCADE, null); + Material.LAVA, 0, GameCategory.ARCADE, null), + + BOMB_LOBBERS("Bomb Lobbers", null, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit"); - private String _name; private String[] _statsToPull; private StatDisplay[] _statDisplays; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementData.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementData.java index 41e9562a2..5f1f617fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementData.java @@ -3,10 +3,10 @@ package mineplex.core.achievement; public class AchievementData { private int _level; - private int _expRemainder; - private int _expNextLevel; + private long _expRemainder; + private long _expNextLevel; - public AchievementData(int level, int expRemainder, int expNextLevel) + public AchievementData(int level, long expRemainder, long expNextLevel) { _level = level; _expRemainder = expRemainder; @@ -18,12 +18,12 @@ public class AchievementData return _level; } - public int getExpRemainder() + public long getExpRemainder() { return _expRemainder; } - public int getExpNextLevel() + public long getExpNextLevel() { return _expNextLevel; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementLog.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementLog.java index 6d6e37f91..1684c162f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementLog.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementLog.java @@ -2,10 +2,10 @@ package mineplex.core.achievement; public class AchievementLog { - public int Amount; + public long Amount; public boolean LevelUp; - public AchievementLog(int amount, boolean levelUp) + public AchievementLog(long amount, boolean levelUp) { Amount = amount; LevelUp = levelUp; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 4fe166860..76e58b6fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -137,15 +137,6 @@ public class AchievementManager extends MiniPlugin _log.remove(event.getPlayer().getName()); } - @EventHandler - public void playerJoin(PlayerJoinEvent event) - { - if (_giveInterfaceItem) - { - giveInterfaceItem(event.getPlayer()); - } - } - public void clearLog(Player player) { _log.remove(player.getName()); @@ -161,22 +152,7 @@ public class AchievementManager extends MiniPlugin _giveInterfaceItem = giveInterfaceItem; } - public void giveInterfaceItem(Player player) - { - if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.SKULL_ITEM)) - { - ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats"); - SkullMeta meta = ((SkullMeta) item.getItemMeta()); - meta.setOwner(player.getName()); - item.setItemMeta(meta); - - player.getInventory().setItem(_interfaceSlot, item); - - UtilInv.Update(player); - } - } - - @EventHandler + /*@EventHandler public void openShop(PlayerInteractEvent event) { if (!_shopEnabled) @@ -188,7 +164,7 @@ public class AchievementManager extends MiniPlugin openShop(event.getPlayer()); } - } + }*/ public boolean hasCategory(Player player, Achievement[] required) { @@ -208,18 +184,22 @@ public class AchievementManager extends MiniPlugin { int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(); + if (sender.getName().equalsIgnoreCase("B2_mp")) + return 101; + + if (rank.Has(Rank.MODERATOR)) + level = Math.max(level, 5); + if (rank.Has(Rank.SNR_MODERATOR)) + level = Math.max(level, 15); + if (rank.Has(Rank.JNR_DEV)) + level = Math.max(level, 25); + if (rank.Has(Rank.ADMIN)) + level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); + if (rank.Has(Rank.OWNER)) + level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); + if (sender.getName().equalsIgnoreCase("Phinary")) level = -level; - else if (sender.getName().equalsIgnoreCase("B2_mp")) - return 101; - else if (rank.Has(Rank.OWNER)) - level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); - else if (rank.Has(Rank.ADMIN)) - level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); - else if (rank.Has(Rank.SNR_MODERATOR)) - level = Math.max(level, 15); - else if (rank.Has(Rank.MODERATOR)) - level = Math.max(level, 5); return level; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 2ab5e498f..7867fab9a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -57,7 +57,7 @@ public class AchievementMainPage extends ShopPageBase lore = new ArrayList(); lore.add(" "); - category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 5 : 2, + category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 10 : 2, getPlayer(), _target); lore.add(" "); addAchievements(category, lore, 9); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index f7371bf4c..37ff11c9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -345,7 +345,7 @@ public class AntiHack extends MiniPlugin } //Auto-Kick - if (!handled && _clientManager.Get(player).GetRank() == Rank.YOUTUBE) + if (!handled && _clientManager.Get(player).GetRank() != Rank.YOUTUBE && _clientManager.Get(player).GetRank() != Rank.TWITCH) { player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java index 973950020..0301e0225 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java @@ -73,7 +73,7 @@ public class BenefitManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.retrievePlayerBenefitData(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java index fd5b8bbc0..c7fe26dcc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java @@ -100,6 +100,8 @@ public class BlockRestoreData if (_toID == 78) _toData = (byte)Math.min(7, _toData + addData); else _toData = addData; } + else + _toData = addData; _toID = toID; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java new file mode 100644 index 000000000..bb6d8c9f3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java @@ -0,0 +1,159 @@ +package mineplex.core.bonuses; + +import java.util.List; + +import org.bukkit.ChatColor; + +import mineplex.core.common.util.C; + +public class BonusAmount +{ + private int _gems; + private int _coins; + private int _gold; + private int _bonusGems; + private int _bonusCoins; + private int _bonusGold; + private int _experience; + private int _bonusExperience; + private int _tickets; + + public BonusAmount() + { + + } + + public int getGems() + { + return _gems; + } + + public void setGems(int gems) + { + _gems = gems; + } + + public int getCoins() + { + return _coins; + } + + public void setCoins(int coins) + { + _coins = coins; + } + + public int getGold() + { + return _gold; + } + + public void setGold(int gold) + { + _gold = gold; + } + + public int getBonusGems() + { + return _bonusGems; + } + + public void setBonusGems(int bonusGems) + { + _bonusGems = bonusGems; + } + + public int getBonusCoins() + { + return _bonusCoins; + } + + public void setBonusCoins(int bonusCoins) + { + _bonusCoins = bonusCoins; + } + + public int getBonusGold() + { + return _bonusGold; + } + + public void setBonusGold(int bonusGold) + { + _bonusGold = bonusGold; + } + + public int getTotalGems() + { + return getGems() + getBonusGems(); + } + + public int getTotalCoins() + { + return getCoins() + getBonusCoins(); + } + + public int getTotalGold() + { + return getGold() + getBonusGold(); + } + + public int getExperience() + { + return _experience; + } + + public void setExperience(int experience) + { + _experience = experience; + } + + public int getBonusExperience() + { + return _bonusExperience; + } + + public void setBonusExperience(int bonusExperience) + { + _bonusExperience = bonusExperience; + } + + public int getTotalExperience() + { + return getExperience() + getBonusExperience(); + } + + public int getTickets() + { + return _tickets; + } + + public void setTickets(int tickets) + { + _tickets = tickets; + } + + public boolean isGreaterThanZero() + { + return _bonusCoins > 0 || _coins > 0 || _bonusGems > 0 || _gems > 0 || _gold > 0 || _bonusGold > 0; + } + + public void addLore(List lore) + { + lore.add(C.cYellow + "Rewards"); + addLore(lore, getTickets(), 0, "Carl Spin Ticket" + (getTickets() > 1 ? "s" : "")); + addLore(lore, getCoins(), getBonusCoins(), "Coins"); + addLore(lore, getGems(), getBonusGems(), "Gems"); + addLore(lore, getGold(), getBonusGold(), "Gold"); + addLore(lore, getExperience(), getBonusExperience(), "Experience"); + } + + private void addLore(List lore, int amount, int bonus, String suffix) + { + if (amount > 0) + lore.add(" " + C.cWhite + amount + " " + suffix); + +// if (bonus > 0) +// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java new file mode 100644 index 000000000..346f58b1c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusClientData.java @@ -0,0 +1,127 @@ +package mineplex.core.bonuses; + +import java.sql.Date; +import java.sql.Timestamp; + +import mineplex.core.hologram.Hologram; +import mineplex.database.tables.records.BonusRecord; + +public class BonusClientData +{ + private Hologram _hologram; + + private int _accountId; + private Timestamp _dailyTime; + private Date _rankTime; + private Date _voteTime; + private int _dailyStreak; + private int _maxDailyStreak; + private int _voteStreak; + private int _maxVoteStreak; + private int _tickets; + + public BonusClientData() + { + _accountId = -1; + } + + public void setAccountId(Integer value) + { + _accountId = value; + } + + public Integer getAccountId() + { + return _accountId; + } + + public void setDailyTime(Timestamp value) + { + _dailyTime = value; + } + + public Timestamp getDailyTime() + { + return _dailyTime; + } + + public void setRankTime(Date value) + { + _rankTime = value; + } + + public Date getRankTime() + { + return _rankTime; + } + + public void setVoteTime(Date value) + { + _voteTime = value; + } + + public Date getVoteTime() + { + return _voteTime; + } + + public void setDailyStreak(Integer value) + { + _dailyStreak = value; + } + + public Integer getDailyStreak() + { + return _dailyStreak; + } + + public void setMaxDailyStreak(Integer value) + { + _maxDailyStreak = value; + } + + public Integer getMaxDailyStreak() + { + return _maxDailyStreak; + } + + public void setVoteStreak(Integer value) + { + _voteStreak = value; + } + + public Integer getVoteStreak() + { + return _voteStreak; + } + + public void setMaxVoteStreak(Integer value) + { + _maxVoteStreak = value; + } + + public Integer getMaxVoteStreak() + { + return _maxVoteStreak; + } + + public void setTickets(Integer value) + { + _tickets = value; + } + + public Integer getTickets() + { + return _tickets; + } + + public Hologram getHologram() + { + return _hologram; + } + + public void setHologram(Hologram hologram) + { + _hologram = hologram; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java new file mode 100644 index 000000000..0e0b52abf --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -0,0 +1,1152 @@ +package mineplex.core.bonuses; + +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; +import java.util.TimeZone; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.IQuerylessLoginProcessor; +import mineplex.core.account.event.ClientUnloadEvent; +import mineplex.core.bonuses.redis.VoteHandler; +import mineplex.core.bonuses.redis.VotifierCommand; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.database.DBPool; +import mineplex.core.donation.DonationManager; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.npc.Npc; +import mineplex.core.npc.NpcManager; +import mineplex.core.pet.PetManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.reward.RewardManager; +import mineplex.core.stats.StatsManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.database.Tables; +import mineplex.core.bonuses.animations.AnimationCarl; +import mineplex.core.bonuses.commands.AnimationCommand; +import mineplex.core.bonuses.commands.GuiCommand; +import mineplex.core.bonuses.commands.TicketCommand; +import mineplex.core.bonuses.event.CarlSpinnerEvent; +import mineplex.core.bonuses.gui.BonusGui; +import mineplex.database.tables.records.BonusRecord; +import mineplex.core.bonuses.gui.SpinGui; +import mineplex.core.poll.PollManager; +import mineplex.serverdata.commands.ServerCommandManager; + +import org.jooq.DSLContext; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import net.minecraft.server.v1_7_R4.DataWatcher; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; + +public class BonusManager extends MiniClientPlugin implements ILoginProcessor +{ + + public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC"); + + private static long timeOffSet = 0; + + private ArrayList _pendingExplosions = new ArrayList<>(); + private ArrayList _pendingExplosionsPlayers = new ArrayList<>(); + private HashMap _showCarl = new HashMap<>(); + private long _explode; + private boolean _canVote; + + public static long getSqlTime() + { + return getSqlTime(System.currentTimeMillis()); + } + + public static long getSqlTime(long currentTime) + { + return currentTime + timeOffSet; + } + + public static long getLocalTime() + { + return System.currentTimeMillis(); + } + + public static long getLocalTime(long sqlTime) + { + return sqlTime - timeOffSet; + } + + public void updateOffSet() + { + _repository.getTimeOffset(new Callback() { + + @Override + public void run(Long data) + { + timeOffSet = data; + } + }); + } + + private BonusRepository _repository; + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private PollManager _pollManager; + private NpcManager _npcManager; + private HologramManager _hologramManager; + private RewardManager _rewardManager; + private StatsManager _statsManager; + public boolean _enabled; + private Npc _carlNpc; + private AnimationCarl _animation; + private int _visualTick; + + // Streak + private StreakRecord _dailyStreak; + private StreakRecord _voteStreak; + + private ArrayList _voteList; + + // Donor Queues + private Queue _coinQueue; + private Queue _gemQueue; + + /** + * THIS SHOULD ONLY BE USED FOR VOTIFIER! + */ + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super("Bonus", plugin); + _enabled = false; + + _repository = new BonusRepository(plugin, this, donationManager); + _clientManager = clientManager; + _donationManager = donationManager; + + _voteList = new ArrayList(); + _voteList.add("http://vote1.mineplex.com"); + _voteList.add("http://vote2.mineplex.com"); + + _coinQueue = new LinkedList(); + _gemQueue = new LinkedList(); + + updateOffSet(); + } + + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager) + { + super("Bonus", plugin); + _repository = new BonusRepository(plugin, this, donationManager); + _clientManager = clientManager; + _donationManager = donationManager; + _npcManager = npcManager; + _hologramManager = hologramManager; + + _rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager, statsManager, + 100, 250, + 500, 1000, + 4000, 6000, + 12000, 32000, + true, true); + + _pollManager = pollManager; + _statsManager = statsManager; + + _voteList = new ArrayList(); + _voteList.add("http://vote1.mineplex.com"); + _voteList.add("http://vote2.mineplex.com"); + + _canVote = true; + _coinQueue = new LinkedList(); + _gemQueue = new LinkedList(); + + + if (npcManager != null) + { + _carlNpc = _npcManager.getNpcByName("Carl the Creeper"); + if (_carlNpc == null) + { + _enabled = false; + } + else + { + _enabled = true; +// _carlNpc.getEntity().setCustomName(""); +// _carlNpc.getEntity().setCustomNameVisible(false); + _animation = new AnimationCarl(_carlNpc.getEntity()); + _animation.setRunning(false); + } + } + else + { + _enabled = false; + } + + clientManager.addStoredProcedureLoginProcessor(this); + + ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class, + new VoteHandler(this)); + + updateOffSet(); + updateStreakRecord(); + } + + @Override + public void addCommands() + { + addCommand(new GuiCommand(this)); + addCommand(new AnimationCommand(this)); + addCommand(new TicketCommand(this)); + } + + // Just keeping things up-to-date + @EventHandler + public void onSlow(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_16) + return; + updateOffSet(); + } + + @EventHandler + public void updateStreak(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_16) + return; + + updateStreakRecord(); + } + + private void updateStreakRecord() + { + _repository.getDailyStreakRecord(new Callback() + { + @Override + public void run(StreakRecord data) + { + _dailyStreak = data; + } + }); + + _repository.getVoteStreakRecord(new Callback() + { + @Override + public void run(StreakRecord data) + { + _voteStreak = data; + } + }); + } + + public StreakRecord getDailyStreak() + { + return _dailyStreak; + } + + public StreakRecord getVoteStreak() + { + return _voteStreak; + } + + public void handleVote(final Player player, final int gemsRecieved) + { + final int accountId = _clientManager.getAccountId(player); + + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.getClientData(accountId, new Callback() + { + @Override + public void run(final BonusClientData data) + { + runSync(new Runnable() + { + @Override + public void run() + { + Set(player, data); + _statsManager.incrementStat(player, "Global.DailyVote", 1); + addPendingExplosion(player, player.getName()); + UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!")); + UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(gemsRecieved + " Gems") + " and " + F.elem("1 Carl Spinner Ticket") + "!")); + } + }); + } + }); + } + }); + + } + + @EventHandler + public void fireCreeper(UpdateEvent event) + { + if(event.getType() != UpdateType.SLOW) + return; + + if(_pendingExplosions.isEmpty()) + return; + + if(!_canVote) + return; + + if (!_enabled) + return; + + _explode = System.currentTimeMillis(); + _animation.setTicks(0); + _canVote = false; + } + + @EventHandler + public void creeperAnimation(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + _animation.itemClean(); + + if(_canVote) + return; + + if (!_enabled) + return; + + Entity creeper = _carlNpc.getEntity(); + + double elapsed = (System.currentTimeMillis() - _explode)/1000d; + + //Not Detonated + if (elapsed < 1) + { + //Sound + creeper.getWorld().playSound(creeper.getLocation(), Sound.CREEPER_HISS, (float)(0.5 + elapsed), (float)(0.5 + elapsed)); + + IncreaseSize(creeper); + return; + } + + if(!_animation.isRunning()) + { + //Effect + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, creeper.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + creeper.getWorld().playSound(creeper.getLocation(), Sound.EXPLODE, 2f, 1f); + _animation.setType(_pendingExplosions.get(0)); + _animation.setPlayer(_pendingExplosionsPlayers.get(0)); + _animation.setRunning(true); + } + + if(!_animation.isDone()) + return; + + DecreaseSize(creeper); + _pendingExplosions.remove(0); + _pendingExplosionsPlayers.remove(0); + _canVote = true; + } + + @EventHandler + public void updateAnimation(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if (!_enabled) + return; + + if(!_animation.isRunning()) + return; + + _animation.run(); + } + + public void DecreaseSize(Entity player) + { + if (!_enabled) + return; + + ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, -1); + } + + public void IncreaseSize(Entity player) + { + if (!_enabled) + return; + + ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, 1); + } + + // DAILY BONUS + + public static final long TIME_BETWEEN_BONUSES = 1000 * 60 * 60 * 20; + public static final long DAILY_STREAK_RESET_TIME = 1000 * 60 * 60 * 12; + public static final long VOTE_STREAK_RESET_TIME = 1000 * 60 * 60 * 24; + + public void attemptDailyBonus(final Player player, final BonusAmount amount, final Callback result) + { + if (timeTillDailyBonus(player) > 0) + result.run(false); + + getRepository().attemptDailyBonus(player, new Callback() + { + @Override + public void run(Boolean r) + { + if (r) + { + incrementDailyStreak(player); + awardBonus(player, amount); + updateCreeperVisual(player, true, C.cAqua); + + _statsManager.incrementStat(player, "Global.DailyReward", 1); + } + + result.run(r); + } + }); + } + + public long timeTillDailyBonus(Player player) + { + return nextDailyBonus(player) - getLocalTime(); + } + + // This calculates the the next daily bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION. + public long nextDailyBonus(Player player) + { + Timestamp timestamp = Get(player).getDailyTime(); + + if (timestamp == null) + return 0; + + long lastBonus = timestamp.getTime(); + + return getLocalTime(lastBonus + TIME_BETWEEN_BONUSES); + } + + // RANK BONUS + public void attemptRankBonus(final Player player, final Callback result) + { + if (timeTillRankBonus(player) > 0) + result.run(false); + getRepository().attemptRankBonus(player, new Callback() + { + @Override + public void run(Boolean aBoolean) + { + if (aBoolean) + { + awardBonus(player, getRankBonusAmount(player)); + updateCreeperVisual(player, true, C.cAqua); + } + + result.run(aBoolean); + } + }); + } + + public void attemptCarlSpin(final Player player) + { + final BonusClientData clientData = Get(player); + + if (clientData.getTickets() > 0) + { + CarlSpinnerEvent event = new CarlSpinnerEvent(player); + Bukkit.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) + { + final int accountId = _clientManager.Get(player).getAccountId(); + + _repository.attemptAddTickets(accountId, clientData, -1, new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + new SpinGui(_plugin, player, _rewardManager, BonusManager.this).openInventory(); + } + else + { + UtilPlayer.message(player, F.main("Carl", "There waa an error processing your request. Try again later")); + } + } + }); + } + } + } + + public long timeTillRankBonus(Player player) + { + return nextRankBonus(player) - getLocalTime(); + } + + + // This calculates the the next rank bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION. + public long nextRankBonus(Player player) + { + Date date = Get(player).getRankTime(); + + if (date == null) + return 0; + + long lastBonus = date.getTime(); + + + return getNextRankBonusTime(getLocalTime(lastBonus)); + } + + public void updateDailyStreak(Player player) + { + BonusClientData client = Get(player); + if (client.getDailyStreak() > 0 && client.getDailyTime() != null) + { + long lastBonus = getLocalTime(client.getDailyTime().getTime()); + long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME); + + if (timeLeft < 0) + { + client.setDailyStreak(0); + } + } + } + + public void updateVoteStreak(BonusRecord client) + { + if (client.getVoteStreak() > 0 && client.getVotetime() != null) + { + long lastBonus = getLocalTime(client.getVotetime().getTime()); + long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); + + if (timeLeft < 0) + { + client.setVoteStreak(0); + } + } + } + + public void incrementDailyStreak(Player player) + { + BonusClientData data = Get(player); + + data.setDailyStreak(data.getDailyStreak() + 1); + + if (data.getDailyStreak() > data.getMaxDailyStreak()) + data.setMaxDailyStreak(data.getDailyStreak()); + } + + public void incrementVoteStreak(BonusRecord client) + { + client.setVoteStreak(client.getVoteStreak() + 1); + + if (client.getVoteStreak() > client.getMaxVoteStreak()) + client.setMaxVoteStreak(client.getVoteStreak()); + } + + public boolean continueStreak(long localLastBonus, long extendTime) + { + long maxTime = localLastBonus + TIME_BETWEEN_BONUSES + extendTime; + return System.currentTimeMillis() < maxTime; + } + + public long getStreakTimeRemaining(long localLastBonus, long extendTime) + { + long maxTime = localLastBonus + TIME_BETWEEN_BONUSES + extendTime; + return maxTime - System.currentTimeMillis(); + } + + public static long getNextRankBonusTime(long time) + { + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeZone(TIMEZONE); + calendar.setTimeInMillis(time); + + calendar.add(Calendar.MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); + + return calendar.getTimeInMillis(); + } + + public int getDailyMultiplier(Player player) + { + BonusClientData client = Get(player); + int streak = client.getDailyStreak(); + + int multiplyer = Math.min(200, 5 * streak); + if (streak >= 40) multiplyer += (1 * (streak - 40)); + return multiplyer; + } + + public int getVoteMultiplyer(int streak) + { + int multiplyer = Math.min(100, 5 * streak); + if (streak >= 20) multiplyer += (1 * (streak - 40)); + return multiplyer; + } + + public BonusAmount getDailyBonusAmount(Player player) + { + double mult = getDailyMultiplier(player) / 100.0; + + BonusAmount amount = new BonusAmount(); + int coins = 100; + int gems = 100; + int experience = 250; + + amount.setCoins(coins); + amount.setGems(gems); + amount.setExperience(experience); + amount.setBonusCoins((int) (mult * coins)); + amount.setBonusGems((int) (mult * gems)); + amount.setBonusExperience((int) (mult * experience)); + + return amount; + } + + public BonusAmount getVoteBonusAmount(Player player) + { + return getVoteBonusAmount(Get(player).getVoteStreak()); + } + + public BonusAmount getVoteBonusAmount(int voteStreak) + { + double mult = getVoteMultiplyer(voteStreak) / 100.0; + + BonusAmount amount = new BonusAmount(); + amount.setTickets(1); + amount.setGems(400); + amount.setBonusGems((int) (mult * 400)); + + return amount; + } + + public BonusAmount getRankBonusAmount(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(); + + BonusAmount data = new BonusAmount(); + + if (rank.Has(Rank.MODERATOR)) + { + data.setCoins(35000); + } + if (rank.Has(Rank.LEGEND)) + { + data.setCoins(30000); + } + else if (rank.Has(Rank.HERO)) + { + data.setCoins(15000); + } + else if (rank.Has(Rank.ULTRA)) + { + data.setCoins(7500); + } + + return data; + } + + //VOTE + + public long timeTillVoteBonus(Player player) + { + return nextVoteTime(player) - getLocalTime(); + } + + // This calculates the the next vote bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION. + public long nextVoteTime(Player player) + { + Date date = Get(player).getVoteTime(); + if (date == null) + return 0; + long lastBonus = date.getTime(); + + return getNextVoteTime(getLocalTime(lastBonus)); + + } + + public void awardBonus(final Player player, BonusAmount amount) + { + final BonusClientData bonusClient = Get(player); + CoreClient coreClient = _clientManager.Get(player); + + final int gems = amount.getTotalGems(); + final int gold = amount.getTotalGold(); + final int coins = amount.getTotalCoins(); + final int tickets = amount.getTickets(); + int experience = amount.getTotalExperience(); + + if (gems > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems"))); + _gemQueue.add(new GiveDonorData(player.getName(), coreClient.getAccountId(), player.getUniqueId(), gems)); + } + + if (gold > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold"))); + _donationManager.RewardGold(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + } + else + { + UtilPlayer.message(player, F.main("Carl", "Failed to process Gold")); + } + } + }, "Earned", player.getName(), coreClient.getAccountId(), gold, true); + } + + if (coins > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Coins"))); + _coinQueue.add(new GiveDonorData(player.getName(), coreClient.getAccountId(), player.getUniqueId(), coins)); + } + + if (tickets > 0) + { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(tickets + " Carl Spin Ticket"))); + final int accountId = _clientManager.Get(player).getAccountId(); + runAsync(new Runnable() + { + @Override + public void run() + { + try + { + final int newTickets = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). + where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets(); + runSync(new Runnable() + { + @Override + public void run() + { + bonusClient.setTickets(newTickets); + } + }); + } + catch (Exception e) + { + System.out.println("Failed to award ticket to player: " + player); + e.printStackTrace(); + } + } + }); + } + + if (experience > 0) + { + _statsManager.incrementStat(player, "Global.ExpEarned", experience); + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience"))); + } + + UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); + + } + + @EventHandler + public void openGui(PlayerInteractEntityEvent event) + { + if (!_enabled) + return; + + Entity entity = event.getRightClicked(); + if (entity.equals(_carlNpc.getEntity())) + { + updateDailyStreak(event.getPlayer()); + new BonusGui(_plugin, event.getPlayer(), this, _rewardManager).openInventory(); + } + } + + @EventHandler + public void openGui(EntityDamageByEntityEvent event) + { + if (!_enabled) + return; + + if (event.getDamager() instanceof Player) + { + Player player = (Player) event.getDamager(); + if (event.getEntity().equals(_carlNpc.getEntity())) + { + updateDailyStreak(player); + new BonusGui(_plugin, player, this, _rewardManager).openInventory(); + } + } + } + + public static long getNextVoteTime(long time) { + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeZone(TIMEZONE); + calendar.setTimeInMillis(time); + + calendar.add(Calendar.DAY_OF_YEAR, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + return calendar.getTimeInMillis(); + } + + public boolean canVote(Player player) + { + long nextVoteTime = nextVoteTime(player); + return System.currentTimeMillis() >= nextVoteTime; + } + + public boolean canDaily(Player player) + { + long nextDailyTime = nextDailyBonus(player); + return System.currentTimeMillis() >= nextDailyTime; + } + + public boolean canRank(Player player) + { + long nextRankTime = nextRankBonus(player); + return System.currentTimeMillis() >= nextRankTime; + } + + @EventHandler + public void join(final PlayerJoinEvent event) + { + runSyncLater(new Runnable() + { + @Override + public void run() + { + if (event.getPlayer().isOnline()) + updateCreeperVisual(event.getPlayer(), true, C.cAqua); + } + }, 10); + } + + public void updateCreeperVisual(Player player, boolean updateDataWatcher, String rewardPrefix) + { + if (!_enabled) + return; + + BonusClientData client = Get(player); + + int availableRewards = 0; + + if (canVote(player)) availableRewards++; + if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; + if (canDaily(player)) availableRewards++; + if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; + + Hologram hologram; + + + if (client.getHologram() == null) + { + double yAdd = UtilPlayer.is1_8(player) ? 2.18 : 2.3; + hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), ""); + hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); + hologram.addPlayer(player); + client.setHologram(hologram); + hologram.start(); + } + else + { + hologram = client.getHologram(); + } + + if (availableRewards > 0) + { + // Hologram +// String name = "Carl the Creeper"; + String text = rewardPrefix + availableRewards + " Reward" + (availableRewards > 1 ? "s" : "") + " to Claim"; + hologram.setText(text); + + if (updateDataWatcher) + { + // Charged + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 0); + watcher.a(1, (short) 300); + watcher.a(17, (byte) 1); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); + packet.a = _carlNpc.getEntity().getEntityId(); + packet.b = watcher.c(); + + UtilPlayer.sendPacket(player, packet); + } + } + else + { + String text = C.cGray + "No Rewards"; + hologram.setText(text); + + if (updateDataWatcher) + { + // Charged + DataWatcher watcher = new DataWatcher(null); + watcher.a(17, (byte) 0); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); + packet.a = _carlNpc.getEntity().getEntityId(); + packet.b = watcher.c(); + + UtilPlayer.sendPacket(player, packet); + } + } + } + + @EventHandler + public void updateCreeper(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER || !_enabled) + return; + + for (Player player : UtilServer.getPlayers()) + { + String prefix = _visualTick % 2 == 0 ? C.cAqua : C.cDAqua; + updateCreeperVisual(player, false, prefix); + } + + _visualTick++; + } + + @Override + protected BonusClientData AddPlayer(String player) + { + return new BonusClientData(); + } + + public BonusRepository getRepository() + { + return _repository; + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public RewardManager getRewardManager() + { + return _rewardManager; + } + + @Override + @EventHandler + public void UnloadPlayer(final ClientUnloadEvent event) + { + final BonusClientData clientData = Get(event.GetName()); + + if (clientData.getHologram() != null) + clientData.getHologram().stop(); + + // Save streaks + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.saveStreak(clientData.getAccountId(), clientData); + } + }); + + // This shouldnt be necessary anymore +// runAsync(new Runnable() +// { +// @Override +// public void run() +// { +// clientData.getRecord().store(); +// } +// }); + + super.UnloadPlayer(event); + } + + public void addPendingExplosion(Player player, Object obj) + { + _pendingExplosions.add(obj); + _pendingExplosionsPlayers.add(player); + } + + public PollManager getPollManager() + { + return _pollManager; + } + + + + @EventHandler + public void Join(final PlayerJoinEvent event) + { + runSyncLater(new Runnable() + { + @Override + public void run() + { + _showCarl.put(event.getPlayer().getName(), true); + } + }, 200); + } + + @EventHandler + public void Quit(PlayerQuitEvent event) + { + _showCarl.remove(event.getPlayer().getName()); + } + + @EventHandler + public void carlUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) + { + if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player)) + { + if(_showCarl.containsKey(player.getName())) + { + if(_plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Lobby")) + UtilPlayer.message(player, C.cDGreen + C.Bold + "Carl the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!"); + } + } + } + } + } + + @EventHandler + public void processQueue(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + // Gems + final GiveDonorData gemData = _gemQueue.poll(); + if (gemData != null && gemData.getAttempts() < 10) + { + _donationManager.RewardGems(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + System.out.println("Successfully processed " + gemData.getGiveAmount() + " gems for " + gemData.getPlayerName()); + } + else + { + gemData.incrementAttempts(); + System.out.println("Failed to process gems for " + gemData.getPlayerName() + " adding to back of queue. Attempts: " + gemData.getAttempts()); + _gemQueue.add(gemData); + } + } + }, "Earned", gemData.getPlayerName(), gemData.getUuid(), gemData.getGiveAmount()); + } + + // Coins + final GiveDonorData coinData = _coinQueue.poll(); + if (coinData != null && coinData.getAttempts() < 10) + { + _donationManager.RewardCoins(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + System.out.println("Successfully processed " + coinData.getGiveAmount() + " coins for " + coinData.getPlayerName()); + } + else + { + coinData.incrementAttempts(); + System.out.println("Failed to process coins for " + coinData.getPlayerName() + " adding to back of queue. Attempts: " + coinData.getAttempts()); + _coinQueue.add(coinData); + } + } + }, "Earned", coinData.getPlayerName(), coinData.getAccountId(), coinData.getGiveAmount()); + } + } + + public String getVoteLink() + { + long sqlTime = getSqlTime(); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(sqlTime); + int date = calendar.get(Calendar.DAY_OF_YEAR); + int index = date % _voteList.size(); + return _voteList.get(index); + } + + /** + * Used for disabling rank rewards during first month of release + * @return + */ + public boolean isPastAugust() + { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeZone(TIMEZONE); + calendar.setTimeInMillis(getSqlTime()); + + if (calendar.get(Calendar.YEAR) == 2015 && calendar.get(Calendar.MONTH) == Calendar.AUGUST) + return false; + + return true; + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + Set(playerName, _repository.loadData(accountId, resultSet)); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT * FROM bonus WHERE accountId = '" + accountId + "';"; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java new file mode 100644 index 000000000..ee21b56a0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java @@ -0,0 +1,446 @@ +package mineplex.core.bonuses; + +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.sql.Types; +import java.util.Map; + +import com.sun.org.apache.xpath.internal.operations.Bool; +import mineplex.core.bonuses.gui.SpinGui; +import mineplex.core.common.Pair; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; +import mineplex.database.Tables; +import mineplex.database.tables.records.BonusRecord; +import org.jooq.Configuration; +import org.jooq.DSLContext; +import org.jooq.Record2; +import org.jooq.SQLDialect; +import org.jooq.TableField; +import org.jooq.impl.DSL; +import org.jooq.impl.DefaultConfiguration; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +public class BonusRepository extends RepositoryBase +{ + private static String CREATE_BONUS_TABLE = "CREATE TABLE IF NOT EXISTS bonus (accountId INT NOT NULL AUTO_INCREMENT, dailytime TIMESTAMP NULL DEFAULT NULL, ranktime DATE NULL DEFAULT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));"; + private BonusManager _manager; + private DonationManager _donationManager; + + public BonusRepository(JavaPlugin plugin, BonusManager bonusManager, DonationManager donationManager) + { + super(plugin, DBPool.ACCOUNT); + _manager = bonusManager; + _donationManager = donationManager; + } + + public BonusRecord loadRecord(String playerName, int accountId) + { + DSLContext create = jooq(); + + BonusRecord record = create.selectFrom(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne(); + + if (record == null) + { + // Need to create new record! + record = create.newRecord(Tables.bonus); + record.setAccountId(accountId); + record.setDailyStreak(0); + record.setMaxDailyStreak(0); + record.setVoteStreak(0); + record.setMaxVoteStreak(0); + record.setTickets(0); + record.store(); // Todo - is this necessary? + } + System.out.println("Loaded record. Daily time: " + record.getDailytime()); + return record; + } + + public BonusClientData loadData(final int accountId, ResultSet resultSet) throws SQLException + { + BonusClientData clientData = new BonusClientData(); + clientData.setAccountId(accountId); + + boolean foundClient = false; + while (resultSet.next()) + { + foundClient = true; + clientData.setDailyTime(resultSet.getTimestamp(2)); + clientData.setRankTime(resultSet.getDate(3)); + clientData.setVoteTime(resultSet.getDate(4)); + clientData.setDailyStreak(resultSet.getInt(5)); + clientData.setMaxDailyStreak(resultSet.getInt(6)); + clientData.setVoteStreak(resultSet.getInt(7)); + clientData.setMaxVoteStreak(resultSet.getInt(8)); + clientData.setTickets(resultSet.getInt(9)); + } + + if (!foundClient) + { + _manager.runAsync(new Runnable() + { + @Override + public void run() + { + executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null); + } + }); + } + + return clientData; + } + + public void getDailyStreakRecord(Callback callback) + { + getStreakRecord(Tables.bonus.maxDailyStreak, callback); + } + + public void getVoteStreakRecord(Callback callback) + { + getStreakRecord(Tables.bonus.maxVoteStreak, callback); + } + + private void getStreakRecord(final TableField field, final Callback callback) + { + Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + final Record2 record = jooq().select(Tables.accounts.name, field) + .from(Tables.bonus.join(Tables.accounts).on(Tables.bonus.accountId.eq(Tables.accounts.id))) + .orderBy(field.desc()).limit(1).fetchOne(); + + Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + if (record.value1() != null && record.value2() != null) + { + callback.run(new StreakRecord(record.value1(), record.value2())); + } + } + }); + } + }); + } + + public void attemptAddTickets(final int accountId, final BonusClientData client, final int tickets, final Callback callback) + { + if (client.getTickets() + tickets < 0) + callback.run(false); + + Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + try + { + DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). + where(Tables.bonus.accountId.eq(accountId)).execute(); + final int newTickets = create.select(Tables.bonus.tickets).from(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne().value1(); + + Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + client.setTickets(newTickets); + callback.run(true); + } + }); + } + catch (Exception e) + { + e.printStackTrace(); + callback.run(false); + } + } + }); + } + + public void attemptDailyBonus(final Player player, final Callback result) + { + final int accountId = _manager.getClientManager().Get(player).getAccountId(); + final int coins = 0; + final int gems = 0; + /* + * if (coins == 0 && gems == 0) { result.accept(false); return; } + */ + final JavaPlugin plug = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() + { + @Override + public void run() + { + try (Connection connection = getConnection(); + CallableStatement callableStatement = connection.prepareCall("{call check_daily(?, ?, ?, ?, ?)}")) + { + callableStatement.setInt(1, accountId); + callableStatement.setInt(2, coins); + callableStatement.setInt(3, gems); + callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN); + callableStatement.registerOutParameter(5, java.sql.Types.TIMESTAMP); + + callableStatement.executeUpdate(); + + final boolean pass = callableStatement.getBoolean(4); + + final Timestamp timeStamp = callableStatement.getTimestamp(5); + + Bukkit.getScheduler().runTask(plug, new Runnable() + { + @Override + public void run() + { + + if (pass) + { + _manager.Get(player).setDailyTime(new Timestamp(BonusManager.getSqlTime())); + result.run(true); + } + else + { + Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 10, false, false); + _manager.Get(player).setDailyTime(timeStamp); + result.run(false); + } + } + }); + } + catch (Exception e) + { + Recharge.Instance.use(player, "AttemptDailyBonus", 1000 * 30, false, false); + e.printStackTrace(); + result.run(false); + } + } + }); + } + + @Deprecated + public void giveTickets(final Player player, final Callback result) + { + final int accountId = _manager.getClientManager().Get(player).getAccountId(); + + Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + final int newTickets = jooq().update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.sub(-1)). + where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets(); + + Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + + + } + }); + + } + }); + } + + public void attemptRankBonus(final Player player, final Callback result) + { + if (!Recharge.Instance.usable(player, "AttemptRankBonus")) { + result.run(false); + return; + } + final int accountId = _manager.getClientManager().Get(player).getAccountId(); + final int coins = _manager.getRankBonusAmount(player).getCoins(); + + if (coins == 0/* && gems == 0 */) { + result.run(false); + return; + } + + final JavaPlugin plug = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() { + + @Override + public void run() + { + + try (Connection connection = getConnection(); + CallableStatement callableStatement = connection.prepareCall("{call check_rank(?, ?, ?, ?, ?)}")) { + callableStatement.setInt(1, accountId); + callableStatement.setInt(2, coins); + callableStatement.setInt(3, 0); + callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN); + callableStatement.registerOutParameter(5, java.sql.Types.DATE); + + callableStatement.executeUpdate(); + + final boolean pass = callableStatement.getBoolean(4); + + final Date date = callableStatement.getDate(5); + + Bukkit.getScheduler().runTask(plug, new Runnable() { + + @Override + public void run() + { + _manager.Get(player).setRankTime(date); + + if (pass) + { + result.run(true); + } + else + { + Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 10, false, false); + result.run(false); + } + } + }); + } catch (Exception e) { + Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false); + e.printStackTrace(); + result.run(false); + } + } + }); + } + + public void attemptVoteBonus(final int accountId, final Callback> result) + { + final int coins = 0; + final int gems = 0; + + final JavaPlugin plug = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() { + + @Override + public void run() + { + + try (Connection connection = getConnection(); + CallableStatement callableStatement = connection.prepareCall("{call check_vote(?, ?, ?, ?, ?)}")) { + callableStatement.setInt(1, accountId); + callableStatement.setInt(2, coins); + callableStatement.setInt(3, gems); + callableStatement.registerOutParameter(4, Types.BOOLEAN); + callableStatement.registerOutParameter(5, Types.DATE); + + callableStatement.executeUpdate(); + + final boolean pass = callableStatement.getBoolean(4); + final Date date = callableStatement.getDate(5); + + Bukkit.getScheduler().runTask(plug, new Runnable() { + + @Override + public void run() + { +// _manager.Get(player).setVoteTime(date); + result.run(Pair.create(pass, date)); + } + }); + } catch (Exception e) { + e.printStackTrace(); + result.run(null); + } + } + }); + } + + public void getTimeOffset(final Callback callback) + { + final long startTime = System.currentTimeMillis(); + final Plugin plugin = _manager.getPlugin(); + + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() + { + executeQuery("SELECT CURRENT_TIMESTAMP", new ResultSetCallable() { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + resultSet.next(); + + long theirTimeUnadjusted = resultSet.getTimestamp(1).getTime(); + + long ourCurrentTime = System.currentTimeMillis(); + + long latencyOffset = (ourCurrentTime - startTime) / 2; + + long theirTime = theirTimeUnadjusted - latencyOffset; + + final long offSet = theirTime - ourCurrentTime; + + Bukkit.getScheduler().runTask(plugin, new Runnable() { + @Override + public void run() + { + callback.run(offSet); + } + }); + } + }); + } + }); + } + + public void getClientData(final int accountId, final Callback callback) + { + String query = "SELECT * FROM bonus WHERE accountId = '" + accountId + "';"; + + executeQuery(query, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + BonusClientData clientData = loadData(accountId, resultSet); + callback.run(clientData); + } + }); + } + + public void saveStreak(int accountId, BonusClientData clientData) + { + jooq().update(Tables.bonus).set(Tables.bonus.dailyStreak, clientData.getDailyStreak()) + .set(Tables.bonus.maxDailyStreak, clientData.getMaxDailyStreak()) + .set(Tables.bonus.voteStreak, clientData.getVoteStreak()) + .set(Tables.bonus.maxVoteStreak, clientData.getMaxVoteStreak()) + .where(Tables.bonus.accountId.eq(accountId)).execute(); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE_BONUS_TABLE); + } + + @Override + protected void update() + { + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java new file mode 100644 index 000000000..1aa07d0d5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java @@ -0,0 +1,50 @@ +package mineplex.core.bonuses; + +import java.util.UUID; + +public class GiveDonorData +{ + private String _playerName; + private int _accountId; + private UUID _uuid; + private int _giveAmount; + private int _attempts; + + public GiveDonorData(String playerName, int accountId, UUID uuid, int giveAmount) + { + _playerName = playerName; + _accountId = accountId; + _uuid = uuid; + _giveAmount = giveAmount; + } + + public String getPlayerName() + { + return _playerName; + } + + public int getAccountId() + { + return _accountId; + } + + public UUID getUuid() + { + return _uuid; + } + + public int getGiveAmount() + { + return _giveAmount; + } + + public int getAttempts() + { + return _attempts; + } + + public void incrementAttempts() + { + _attempts++; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/StreakRecord.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/StreakRecord.java new file mode 100644 index 000000000..7757a2c8c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/StreakRecord.java @@ -0,0 +1,23 @@ +package mineplex.core.bonuses; + +public class StreakRecord +{ + private String _playerName; + private int _streak; + + public StreakRecord(String playerName, int streak) + { + _playerName = playerName; + _streak = streak; + } + + public String getPlayerName() + { + return _playerName; + } + + public int getStreak() + { + return _streak; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java new file mode 100644 index 000000000..4cc2ac529 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java @@ -0,0 +1,290 @@ +package mineplex.core.bonuses.animations; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Random; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.treasure.animation.Animation; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class AnimationCarl extends Animation +{ + private boolean _isDone; + private Block _creeper; + private Object _type; + private Player _player; + + private HashSet _items = new HashSet(); + + public AnimationCarl(Entity creeper) + { + _creeper = creeper.getLocation().getBlock(); + } + + @Override + protected void tick() + { + if(_type instanceof String) + { + if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL")) + { + for (int i = 50; i < 60; i++) + { + Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i)); + Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + _items.add(gem); + _items.add(coin); + + Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); + UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false); + UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false); + + } + } + if(((String) _type).contentEquals("RANK")) + { + for (int i = 50; i < 60; i++) + { + Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + _items.add(coin); + + Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d)); + UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false); + + } + } + if(!((String) _type).contentEquals("DAILY")&& !((String) _type).contentEquals("RANK")&& !((String) _type).contentEquals("POLL")) + { + + Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64)); + _items.add(paper); + + Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d)); + UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false); + + for (int i = 50; i < 60; i++) + { + Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i)); + _items.add(gem); + + Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d)); + UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false); + + } + } + finish(); + } + if(_type instanceof Reward) + { + if(getTicks() == 0) + { + RewardData rewardData = ((Reward)_type).getFakeRewardData(_player); + ItemStack itemStack = rewardData.getDisplayItem(); + Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack); + _items.add(item); + + Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ()); + + UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false); + } + + if(((Reward)_type).getRarity() == RewardRarity.RARE) + { + RareAnimation(); + } + else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY) + { + LegendAnimation(); + } + else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL) + { + MythicalAnimation(); + } + else + { + finish(); + } + } + } + + @Override + protected void onFinish() { + _isDone = true; + setTicks(0); + } + + public boolean isDone() + { + return _isDone; + } + + public void setDone(boolean b) + { + _isDone = b; + } + + public void setType(Object type) + { + _type = type; + } + + public void setPlayer(Player player) + { + _player = player; + } + + public void LegendAnimation() + { + if (getTicks() < 1) + { + UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true); + } + + if (getTicks() == 1) + { + _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F); + } + else if (getTicks() < 35) + { + double radius = 2 - (getTicks() / 10D * 2); + int particleAmount = 20 - (getTicks() * 2); + Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5); + for (int i = 0; i < particleAmount; i++) + { + double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; + for(double e = 0.1 ; e < 3 ; e += 0.6) + { + Location location = _centerLocation.clone().add(xDiff, e, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + else + { + finish(); + } + } + + public void MythicalAnimation() + { + if (getTicks() < 30) + { + UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true); + } + + if (getTicks() == 1) + { + _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F); + _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F); + } + else if (getTicks() < 40) + { + UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true, + new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1); + + //Particle Spiral Up + double radius = getTicks() / 20D; + int particleAmount = getTicks() / 2; + for (int i = 0; i < particleAmount; i++) + { + double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + + Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5); + for (int i = 0; i < particleAmount; i++) + { + double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; + for(double e = 0.1 ; e < 3 ; e += 0.5) + { + Location location = _centerLocation.clone().add(xDiff, e, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + else + { + finish(); + } + } + + public void RareAnimation() + { + if (getTicks() == 1) + { + for(int i = 0; i < 3; i++) + { + UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false); + } + _creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F); + } + else if (getTicks() >= 60) + { + finish(); + } + + else if (getTicks() < 35) + { + double radius = 2 - (getTicks() / 10D * 2); + int particleAmount = 20 - (getTicks() * 2); + Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5); + for (int i = 0; i < particleAmount; i++) + { + double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; + for(double e = 0.1 ; e < 3 ; e += 0.6) + { + Location location = _centerLocation.clone().add(xDiff, e, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + } + + public void itemClean() + { + Iterator itemIterator = _items.iterator(); + + while (itemIterator.hasNext()) + { + Item item = itemIterator.next(); + + if (item.isOnGround() || !item.isValid() || item.getTicksLived() > 60) + { + item.remove(); + itemIterator.remove(); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java new file mode 100644 index 000000000..c3356c9b7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java @@ -0,0 +1,37 @@ +package mineplex.core.bonuses.commands; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.reward.RewardType; +import mineplex.core.bonuses.BonusManager; + +public class AnimationCommand extends CommandBase{ + + private BonusManager _plugin; + + public AnimationCommand(BonusManager plugin) + { + super(plugin, Rank.DEVELOPER, "animation"); + _plugin = plugin; + } + + @Override + public void Execute(Player caller, String[] args) + { + + if(args != null) + { + caller = Bukkit.getPlayer(args[0]); + _plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true)); + } + if(args.length >= 2) + { + _plugin.addPendingExplosion(caller, args[1]); + } + + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java new file mode 100644 index 000000000..ccc55a251 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java @@ -0,0 +1,23 @@ +package mineplex.core.bonuses.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.gui.BonusGui; + +public class GuiCommand extends CommandBase{ + + public GuiCommand(BonusManager plugin) + { + super(plugin, Rank.DEVELOPER, "bonus"); + } + + @Override + public void Execute(Player caller, String[] args) + { + new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager()).openInventory(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java new file mode 100644 index 000000000..307a57427 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java @@ -0,0 +1,68 @@ +package mineplex.core.bonuses.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.bonuses.BonusManager; + +import org.bukkit.entity.Player; + +public class TicketCommand extends CommandBase +{ + public TicketCommand(BonusManager plugin) + { + super(plugin, Rank.ADMIN, "ticket"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main("Carl", "Missing Args: " + F.elem("/ticket "))); + return; + } + + final String targetName = args[0]; + final String ticketString = args[1]; + Player target = UtilPlayer.searchExact(targetName); + + + rewardTickets(caller, target, target.getName(), ticketString); + } + + private void rewardTickets(final Player caller, final Player target, final String targetName, String ticketString) + { + try + { + final int tickets = Integer.parseInt(ticketString); + int accountId = Plugin.getClientManager().getAccountId(target); + Plugin.getRepository().attemptAddTickets(accountId, Plugin.Get(target), tickets, new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + ".")); + + if (target != null && !target.equals(caller)) + { + UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + ".")); + } + } + else + { + UtilPlayer.message(caller, F.main("Carl", "Failed to give tickets. Try again later!")); + } + } + }); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main("Carl", "Invalid Ticket Amount")); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/event/CarlSpinnerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/event/CarlSpinnerEvent.java new file mode 100644 index 000000000..a07e1770e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/event/CarlSpinnerEvent.java @@ -0,0 +1,54 @@ +package mineplex.core.bonuses.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Called when a player attempts to purchase a spin through carl + */ +public class CarlSpinnerEvent extends Event implements Cancellable +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private boolean _cancelled; + + public CarlSpinnerEvent(Player player) + { + _player = player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Player getPlayer() + { + return _player; + } + + public void setPlayer(Player player) + { + _player = player; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean b) + { + _cancelled = b; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java new file mode 100644 index 000000000..8306c84d5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -0,0 +1,42 @@ +package mineplex.core.bonuses.gui; + +import mineplex.core.gui.SimpleGui; +import mineplex.core.reward.RewardManager; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.gui.buttons.CarlSpinButton; +import mineplex.core.bonuses.gui.buttons.DailyBonusButton; +import mineplex.core.bonuses.gui.buttons.PollButton; +import mineplex.core.bonuses.gui.buttons.RankBonusButton; +import mineplex.core.bonuses.gui.buttons.VoteButton; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public class BonusGui extends SimpleGui +{ + + private BonusManager manager; + + public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager) + { + super(plugin, player, player.getName() + "'s Bonuses", 5 * 9); + + this.manager = manager; + + setItem(10, new VoteButton(plugin, player, this, manager)); + + setItem(12, new RankBonusButton(getPlugin(), player, this, manager)); + + setItem(14, new DailyBonusButton(getPlugin(), player, this, manager)); + + setItem(16, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager)); + + setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); + } + + @Override + protected void finalize() throws Throwable + { + super.finalize(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java new file mode 100644 index 000000000..779c9e431 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/SpinGui.java @@ -0,0 +1,280 @@ +package mineplex.core.bonuses.gui; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gui.DisplayItem; +import mineplex.core.gui.SimpleGui; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardManager; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.gui.buttons.RewardButton; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class SpinGui extends SimpleGui +{ + private static final int HOPPER_SLOT = 4; + private static final int CARL_SLOT = 22; + private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ }; + + private int _tickCount; + private RewardData _rewardData; + private Reward _reward; + private BonusManager _manager; + private int _currentRewardIndex; + private int _ticksThisSwap; + private int _ticksPerSwap; + private int _swapCount; + private Reward[] _rewards; + private boolean _stopped; + private boolean _rewarded; + private ArrayList _ticks; + private int _frame; + private float _pitch; + private int _stopSpinnerAt; + + public SpinGui(Plugin plugin, Player player, RewardManager rewardManager, BonusManager manager) + { + super(plugin, player, "Carl's Spinner", 27); + + _manager = manager; + + ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false); + + setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER))); + //setItem(CARL_SLOT, new DisplayItem(carlItem)); + + + _ticks = new ArrayList<>(); + _frame = 0; + _pitch = 1; + + + + _ticksPerSwap = 1; + + for (int i=0 ; i<40 ; i++) + _ticks.add(1); + + for (int i=0 ; i<20 ; i++) + _ticks.add(2); + + for (int i=0 ; i<10 ; i++) + _ticks.add(4); + + for (int i=0 ; i<4 ; i++) + _ticks.add(6); + + for (int i=0 ; i<3 ; i++) + _ticks.add(8); + + if (Math.random() > 0.5) + { + _ticks.add(12); + } + + _stopSpinnerAt = _ticks.size(); + + //Create Rewards + _rewards = new Reward[_stopSpinnerAt+10]; //Adding 10, so theres items to the right still. + for (int i = 0; i < _stopSpinnerAt+10 ; i++) + { + if (i != _stopSpinnerAt + 4) + { + _rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerFiller, true); + } + else + { + _rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerReal, true); + _reward = _rewards[i]; + } + } + + _rewardData = _reward.giveReward("Carls Spinner", getPlayer()); + } + + private void tick() + { + + if(_stopped) + return; + + _ticksThisSwap++; + + // Swap + if (_ticksThisSwap >= _ticksPerSwap) + { + _ticksThisSwap = 0; + _swapCount++; + + if(_pitch == 1) + _pitch = (float) 1.5; + else if(_pitch == 1.5) + _pitch = 2; + else if(_pitch == 2) + _pitch = 1; + + getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch); + + _currentRewardIndex++; + + updateGui(); + + // Slow + _ticksPerSwap = _ticks.get(_currentRewardIndex - 1); + + if(_currentRewardIndex == _stopSpinnerAt) + _stopped = true; + } + + _tickCount++; + } + + public void updateGui() + { + for (int i = 0; i < 9; i++) + { + int index = _currentRewardIndex + i; + + int slot = 9 + i; + RewardData data = _rewards[index].getFakeRewardData(getPlayer()); + setItem(slot, new RewardButton(data)); + + // Glass Panes + for (int j = 0; j < LINE_NUMS.length; j++) + { + int paneSlot = slot + LINE_NUMS[j]; + if (paneSlot == HOPPER_SLOT) + continue; + + setItem(paneSlot, new DisplayItem(data.getRarity().getItemStack())); + } + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + tick(); + checkIfDone(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void close(InventoryCloseEvent event) + { + if(_rewarded) + return; + + if(event.getPlayer() != getPlayer()) + return; + + _manager.addPendingExplosion(getPlayer(), _reward); + + if (_reward.getRarity() == RewardRarity.RARE) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.LEGENDARY) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.MYTHICAL) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + } + + @EventHandler + public void Glass(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if(!_stopped) + return; + + if(!_rewarded) + return; + + if(_frame == 0) + { + setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack())); + _frame++; + } + else if(_frame < 5) + { + setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + + setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + + setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack())); + _frame++; + } + if(_frame == 6) + { + + } + } + + public void checkIfDone() + { + if(!_stopped) + return; + + if(_rewarded) + return; + + _manager.addPendingExplosion(getPlayer(), _reward); + if (_reward.getRarity() == RewardRarity.RARE) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.LEGENDARY) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else if (_reward.getRarity() == RewardRarity.MYTHICAL) + { + Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner.")); + } + ItemStack item = getInventory().getItem(13); + getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName())); + _rewarded = true; + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/CarlSpinButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/CarlSpinButton.java new file mode 100644 index 000000000..006135c5d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/CarlSpinButton.java @@ -0,0 +1,85 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.reward.RewardManager; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; + +public class CarlSpinButton implements GuiItem +{ + private Plugin _plugin; + private Player _player; + private BonusManager _bonusManager; + private RewardManager _rewardManager; + + public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, RewardManager rewardManager) + { + _plugin = plugin; + _player = player; + _bonusManager = bonusManager; + _rewardManager = rewardManager; + } + + @Override + public void setup() + { + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + BonusClientData client = _bonusManager.Get(_player); + int tickets = client.getTickets(); + + if (tickets > 0) + { + _bonusManager.attemptCarlSpin(_player); + } + +// new SpinGui(_plugin, _player, _rewardManager).openInventory(); + } + + @Override + public ItemStack getObject() + { + BonusClientData client = _bonusManager.Get(_player); + int tickets = client.getTickets(); + + String name = (tickets > 0 ? C.cGreen : C.cRed) + C.Bold + "Carl's Spinner"; + ArrayList lore = new ArrayList(); + Material material = Material.SKULL_ITEM; + byte data = (byte) 4; + + lore.add(" "); + if (tickets > 0) + { + lore.add(ChatColor.RESET + "Click to Spin"); + } + else + { + lore.add(ChatColor.RESET + "You need a Carl Spin Ticket to Spin"); + } + + lore.add(" "); + lore.add(ChatColor.YELLOW + "Your Tickets: " + C.cWhite + tickets); + + return new ShopItem(material, data, name, lore.toArray(new String[0]), 1, false, false); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java new file mode 100644 index 000000000..0c2ea37d2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java @@ -0,0 +1,211 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.ItemRefresher; +import mineplex.core.gui.pages.LoadingWindow; +import mineplex.core.gui.pages.TimedMessageWindow; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.StreakRecord; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class DailyBonusButton implements GuiItem, Listener +{ + + private ItemStack _item; + + private Player _player; + private Plugin _plugin; + private ItemRefresher _gui; + + private BonusManager _bonusManager; + + public DailyBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager) + { + this._bonusManager = bonusManager; + this._player = player; + this._plugin = plugin; + this._gui = gui; + } + + @Override + public void setup() + { + Bukkit.getPluginManager().registerEvents(this, getPlugin()); + setItem(); + } + + @Override + public void close() + { + HandlerList.unregisterAll(this); + } + + @Override + public void click(ClickType clickType) + { + if (isAvailable()) { + _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); + refreshItem(); + new LoadingWindow(getPlugin(), getPlayer(), 6*9); + _bonusManager.attemptDailyBonus(getPlayer(), _bonusManager.getDailyBonusAmount(_player), new Callback() { + @Override + public void run(Boolean t) + { + if (t) { + + setItem(); + + if (getPlayer().getOpenInventory() != null) { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6*9, 20*3, getGui()).openInventory(); + } else { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!")); + } + _bonusManager.addPendingExplosion(getPlayer(), "DAILY"); + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + } else { + if (getPlayer().getOpenInventory() != null) { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6*9, 20*3, getGui()).openInventory(); + } else { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!")); + } + getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10); + } + getPlayer().closeInventory(); + } + }); + } else + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10); + return; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + return; +// refreshItem(); // Todo Unnecessary? + } + + private void setItem() + { + ArrayList lore = new ArrayList(); + Material material; + String itemName; + byte data = 0; + + if (isAvailable()) + { + material = Material.CHEST; + itemName = C.cGreen + C.Bold + "Daily Reward"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Click to Claim!"); + } + else + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + C.Bold + "Daily Reward"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!"); + } + + lore.add(" "); + + BonusClientData client = _bonusManager.Get(_player); + + BonusAmount bonusAmount = _bonusManager.getDailyBonusAmount(_player); + bonusAmount.addLore(lore); + lore.add(" "); + + lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getDailyStreak()); + lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + _bonusManager.getDailyMultiplier(_player) + "%"); + lore.add(" "); + lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak()); + + if (client.getDailyTime() != null) + { + long lastBonus = _bonusManager.getLocalTime(client.getDailyTime().getTime()); + long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME); + + if (timeLeft > 0) + { + lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT)); + } + } + + StreakRecord streakRecord = _bonusManager.getDailyStreak(); + if (streakRecord != null) + { + lore.add(" "); + lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName()); + lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak()); + } + + + _item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false); + } + + @Override + public ItemStack getObject() + { + return _item; + } + + public void refreshItem() + { + getGui().refreshItem(this); + } + + public long timeLeft() + { + long timeLeft = _bonusManager.nextDailyBonus(getPlayer()) - System.currentTimeMillis(); + return timeLeft; + } + + public boolean isAvailable() + { + return (timeLeft() <= 0); + } + + public Plugin getPlugin() + { + return _plugin; + } + + public Player getPlayer() + { + return _player; + } + + public ItemRefresher getGui() + { + return _gui; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java new file mode 100644 index 000000000..8e7a5889e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java @@ -0,0 +1,219 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; +import java.util.HashMap; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilText; +import mineplex.core.gui.GuiInventory; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.SimpleGui; +import mineplex.core.gui.SimpleGuiItem; +import mineplex.core.gui.botton.BackBotton; +import mineplex.core.gui.pages.TimedMessageWindow; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.poll.Poll; +import mineplex.core.poll.PollManager; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class PollButton extends SimpleGui implements GuiItem { + + protected boolean _create; + + private PollManager _pollManager; + private BonusManager _bonusManager; + private CoreClientManager _clientManager; + private GuiInventory _master; + + private HashMap hard = new HashMap(); + + private Poll _poll; + + public PollButton(Plugin plugin, Player player, PollManager pollManager, CoreClientManager clientManager, GuiInventory master, BonusManager bonusManager) + { + super(plugin, player, "Poll:", 6 * 9); + this._create = true; + this._master = master; + this._clientManager = clientManager; + this._pollManager = pollManager; + hard.put(0, new BackBotton(master)); + _bonusManager = bonusManager; + } + + @Override + public void setup() + { + if (_create) + { + this._poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).GetRank()); + + if (_poll != null) + { + + setItem(13, getQuestionItem(_poll.getQuestion())); + + int[] slots = even(9, _poll.getAnswers().length); + + for (int i = 0; i < slots.length; i++) + { + AnswerItem item = new AnswerItem(_poll, i); + setItem(9 * 3 + slots[i], item); + } + } + } + } + + @Override + public ItemStack getObject() + { + ArrayList lore = new ArrayList<>(); + if (_poll == null) + { + lore.add(""); + lore.add(C.cWhite + "You've voted on all of the polls!"); + return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, ChatColor.RED + C.Bold + "Vote on Poll", lore); + } + else + { + lore.add(""); + lore.add(C.cWhite + _poll.getQuestion()); + lore.add(""); + int i = 1; + for(String str : _poll.getAnswers()) + { + lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str); + i++; + } + lore.add(""); + BonusAmount amount = new BonusAmount(); + amount.setCoins(_poll.getCoinReward()); + amount.setGems(_poll.getCoinReward()); + amount.addLore(lore); +// lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems"); + lore.add(""); + lore.add(C.cGreen + "Click to go to the vote page!"); + return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore); + } + } + + @Override + public void click(ClickType clickType) + { + if (_poll == null) + { + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f); + } + else + { + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + openInventory(); + } + } + + public GuiItem getQuestionItem(String question) + { + + ArrayList lore = new ArrayList<>(); + lore.add(""); + for (String string : wrap(question)) + lore.add(C.cWhite + string); + lore.add(""); + int i = 1; + for(String str : _poll.getAnswers()) + { + lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str); + i++; + } + lore.add(""); + BonusAmount amount = new BonusAmount(); + amount.setCoins(_poll.getCoinReward()); + amount.setGems(_poll.getCoinReward()); + amount.addLore(lore); + + return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + C.cGreen + C.Bold + "Vote on Poll", + lore)); + } + + public static String[] wrap(String text) + { + return UtilText.wrap(text, 40); + } + + public static int[] even(int size, int amount) + { + int[] list = new int[amount]; + + float interval = (size / amount); + float offset = -(interval / 2); + + for (int i = 1; i <= amount; i++) + { + list[i - 1] = (int) (Math.ceil(i * interval) + offset); + } + return list; + } + + public Poll getPoll() + { + return _poll; + } + + public GuiInventory getMaster() + { + return _master; + } + + private class AnswerItem implements GuiItem + { + + private int num; + + private AnswerItem(Poll poll, int num) + { + this.num = num; + } + + @Override + public ItemStack getObject() + { + ArrayList lore = new ArrayList<>(); + lore.add(""); + lore.add(C.cWhite + getPoll().getAnswers()[num]); + return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore); + } + + @Override + public void click(ClickType clickType) + { + _create = true; + + _pollManager.answerPoll(getPlayer(), _poll, num); + + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory(); + _bonusManager.addPendingExplosion(getPlayer(), "POLL"); + getPlayer().closeInventory(); + } + + @Override + public void setup() {} + + @Override + public void close() {} + + } + + @Override + public void close() {} +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java new file mode 100644 index 000000000..5fe0fc0f0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java @@ -0,0 +1,242 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.ItemRefresher; +import mineplex.core.gui.pages.LoadingWindow; +import mineplex.core.gui.pages.TimedMessageWindow; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusManager; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class RankBonusButton implements GuiItem, Listener { + + private boolean hasRank; + + private ItemStack _item; + + private Player _player; + private Plugin _plugin; + private ItemRefresher _gui; + + private BonusManager _bonusManager; + + public RankBonusButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager) + { + this._bonusManager = bonusManager; + this._player = player; + this._plugin = plugin; + this._gui = gui; + } + + @Override + public void setup() + { + if (_bonusManager.getRankBonusAmount(getPlayer()).isGreaterThanZero()) + { + this.hasRank = true; + Bukkit.getPluginManager().registerEvents(this, getPlugin()); + } + else + { + this.hasRank = false; + } + + setItem(); + } + + @Override + public void close() + { + HandlerList.unregisterAll(this); + } + + + @Override + public void click(ClickType clickType) + { + if (isAvailable() && _bonusManager.isPastAugust()) { + _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); + refreshItem(); + new LoadingWindow(getPlugin(), getPlayer(), 6*9); + _bonusManager.attemptRankBonus(getPlayer(), new Callback() + { + @Override + public void run(Boolean t) + { + setItem(); + + if (t) + { + if (getPlayer().getOpenInventory() != null) + { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Bonus collected!"), "Bonus collected!", 6 * 9, 20 * 3, getGui()).openInventory(); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Bonus collected!")); + } + _bonusManager.addPendingExplosion(getPlayer(), "RANK"); + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + } + else + { + if (getPlayer().getOpenInventory() != null) + { + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Failed to collect bonus!"), "Failed to collect bonus!", 6 * 9, 20 * 3, getGui()).openInventory(); + } + else + { + UtilPlayer.message(getPlayer(), F.main("Bonus", "Failed to collect bonus!")); + } + getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10); + } + getPlayer().closeInventory(); + } + }); + } else + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10); + return; + + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + return; +// refreshItem(); // Todo Unnecessary? + } + + @Override + public ItemStack getObject() + { + return _item; + } + + private void setItem() + { + ArrayList lore = new ArrayList(); + Material material; + String itemName; + byte data = 0; + + if (_bonusManager.isPastAugust()) + { + if (!hasRank) + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus"; + lore.add(" "); + lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!"); + lore.add(ChatColor.WHITE + ""); + lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly"); + lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly"); + lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly"); + lore.add(ChatColor.WHITE + ""); + lore.add(ChatColor.WHITE + "Purchase a Rank at;"); + lore.add(ChatColor.WHITE + "www.mineplex.com/shop"); + } + else + { + if (isAvailable()) + { + material = Material.ENDER_CHEST; + itemName = C.cGreen + C.Bold + "Rank Monthly Bonus"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Click to Claim!"); + } + else + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + C.Bold + "Rank Monthly Bonus"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!"); + } + + lore.add(" "); + lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name); + BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player); + bonusAmount.addLore(lore); + } + } + else + { + itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus"; + material = Material.REDSTONE_BLOCK; + lore.add(" "); + lore.add(ChatColor.RESET + "You can claim your Monthly Bonus"); + lore.add(ChatColor.RESET + "here, starting from September!"); + } + + + _item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false); + } + + public void refreshItem() + { + _gui.refreshItem(this); + } + + public long timeLeft() + { + return _bonusManager.nextRankBonus(getPlayer()) - System.currentTimeMillis(); + } + + public boolean isAvailable() + { + if (!hasRank) + { + UtilPlayer.message(getPlayer(), "----------------------------------------"); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "Purchase a Rank at the Mineplex Shop:"); + UtilPlayer.message(getPlayer(), C.cGreen + "www.mineplex.com/shop"); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "----------------------------------------"); + + getPlayer().closeInventory(); + return false; + } + return (timeLeft() <= 0); + } + + public Plugin getPlugin() + { + return _plugin; + } + + public Player getPlayer() + { + return _player; + } + + public ItemRefresher getGui() + { + return _gui; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RewardButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RewardButton.java new file mode 100644 index 000000000..73ff6c9cc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RewardButton.java @@ -0,0 +1,46 @@ +package mineplex.core.bonuses.gui.buttons; + +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.gui.GuiItem; +import mineplex.core.reward.RewardData; + +public class RewardButton implements GuiItem +{ + private RewardData _data; + + public RewardButton(RewardData data) + { + _data = data; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + // Do nothing + } + + @Override + public ItemStack getObject() + { + ItemStack stack = _data.getDisplayItem(); + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(_data.getFriendlyName()); + stack.setItemMeta(meta); + return stack; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java new file mode 100644 index 000000000..b2d46d294 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java @@ -0,0 +1,186 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.gui.GuiItem; +import mineplex.core.gui.ItemRefresher; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.bonuses.StreakRecord; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class VoteButton implements GuiItem, Listener { + + private ItemStack _item; + + private String _url; + + private Player _player; + private Plugin _plugin; + private ItemRefresher _gui; + + private BonusManager _bonusManager; + + public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager) + { + this._bonusManager = bonusManager; + this._player = player; + this._plugin = plugin; + this._gui = gui; + } + + @Override + public void setup() + { + //TODO get url from db + _url = _bonusManager.getVoteLink(); + + setItem(); + Bukkit.getPluginManager().registerEvents(this, getPlugin()); + } + + @Override + public void close() + { + HandlerList.unregisterAll(this); + } + + @Override + public void click(ClickType clickType) + { + if (isAvailable()) + { + getPlayer().closeInventory(); + + getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); + + UtilPlayer.message(getPlayer(), "----------------------------------------------------"); + UtilPlayer.message(getPlayer(), ""); + + new JsonMessage("Click to Open in Web Browser").click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer()); + new JsonMessage(C.cGreen + _url).click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer()); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "Please be patient, votes may take a few minutes to register."); + UtilPlayer.message(getPlayer(), ""); + UtilPlayer.message(getPlayer(), "----------------------------------------------------"); + + getPlayer().closeInventory(); + + } + else + { + getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10); + } + } + + @Override + public ItemStack getObject() + { + return _item; + } + + private void setItem() + { + ArrayList lore = new ArrayList(); + Material material; + String itemName; + byte data = 0; + + if (isAvailable()) + { + material = Material.JUKEBOX; + itemName = C.cGreen + C.Bold + "Vote for Mineplex"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Click to Vote!"); + } + else + { + material = Material.REDSTONE_BLOCK; + itemName = C.cRed + C.Bold + "Vote for Mineplex"; + + lore.add(" "); + lore.add(ChatColor.RESET + "Next vote in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!"); + } + + lore.add(" "); + + BonusClientData client = _bonusManager.Get(_player); + + BonusAmount bonusAmount = _bonusManager.getVoteBonusAmount(_player); + bonusAmount.addLore(lore); + lore.add(" "); + + lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak()); + lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplyer(client.getVoteStreak()) + "%"); + if (client.getVoteTime() != null) + { + long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime()); + long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); + + if (timeLeft > 0) + { + lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT)); + } + } + + lore.add(" "); + lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak()); + + StreakRecord streakRecord = _bonusManager.getVoteStreak(); + if (streakRecord != null) + { + lore.add(" "); + lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName()); + lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak()); + } + + _item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false); + } + + public long timeLeft() + { + return _bonusManager.nextVoteTime(getPlayer()) - System.currentTimeMillis(); + } + + public boolean isAvailable() + { + if (_url == null) + return false; + + return (timeLeft() <= 0); + } + + public Plugin getPlugin() + { + return _plugin; + } + + public Player getPlayer() + { + return _player; + } + + public ItemRefresher getGui() + { + return _gui; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java new file mode 100644 index 000000000..54f2a820b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java @@ -0,0 +1,31 @@ +package mineplex.core.bonuses.redis; + +import org.bukkit.entity.Player; + +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.UtilPlayer; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; + +public class VoteHandler implements CommandCallback +{ + private BonusManager _bonusManager; + + public VoteHandler(BonusManager bonusManager) + { + _bonusManager = bonusManager; + } + + @Override + public void run(ServerCommand command) + { + VotifierCommand v = ((VotifierCommand) command); + + Player player = UtilPlayer.searchExact(v.getPlayerName()); + + if (player != null) + { + _bonusManager.handleVote(player, v.getGemsReceived()); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java new file mode 100644 index 000000000..95dbb06a4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java @@ -0,0 +1,28 @@ +package mineplex.core.bonuses.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class VotifierCommand extends ServerCommand +{ + private String _playerName; + private int _gemsReceived; + + public VotifierCommand(String playerName, int gemsReceived, String... targetServer) + { + super(targetServer); + + _playerName = playerName; + _gemsReceived = gemsReceived; + } + + public String getPlayerName() + { + return _playerName; + } + + public int getGemsReceived() + { + return _gemsReceived; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index d48239d6e..9279f5bd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -144,7 +144,7 @@ public class Chat extends MiniPlugin @EventHandler public void lagTest(PlayerCommandPreprocessEvent event) { - if (event.getMessage().equals("lag") || event.getMessage().equals("ping")) + if (event.getMessage().equals("/lag") || event.getMessage().equals("/ping")) { event.getPlayer().sendMessage(F.main(getName(), "PONG!")); event.setCancelled(true); @@ -329,7 +329,7 @@ public class Chat extends MiniPlugin UtilPlayer.message(sender, F.main("Chat", "Accusing players of cheating in-game is against the rules." + "If you think someone is cheating, please gather evidence and report it at " - + F.link("www.mineplex.com/supporthub/"))); + + F.link("www.mineplex.com/reports"))); event.setCancelled(true); } else if (_playerLastMessage.containsKey(sender.getUniqueId())) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index d41da36a3..48e7d35f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -19,6 +19,9 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.mount.MountManager; @@ -191,4 +194,15 @@ public class CosmeticManager extends MiniPlugin { return _treasureManager; } + + public void disableTeamArmor() + { + for (Gadget gadget : getGadgetManager().getGadgets(GadgetType.Costume)) + { + if (gadget instanceof OutfitTeam) + { + ((OutfitTeam)gadget).setEnabled(false); + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index d54efdff3..1189a4162 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -11,12 +11,15 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.ActivateGadgetButton; import mineplex.core.cosmetic.ui.button.DeactivateGadgetButton; import mineplex.core.cosmetic.ui.button.GadgetButton; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.gadgets.MorphBlock; import mineplex.core.gadget.gadgets.MorphNotch; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -41,6 +44,9 @@ public class GadgetPage extends ShopPageBase for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.Item)) { + if (gadget.GetCost(CurrencyType.Coins) == -3) + continue; + addGadget(gadget, slot); if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetDisplayName()) > 0) @@ -68,6 +74,13 @@ public class GadgetPage extends ShopPageBase //setItem(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Disabled " + gadget.GetName(), new String[] { "Sorry! Currently disabled until fix is made for 1.8 players!" }, 1, false, false)); //return; } + else if (gadget instanceof MorphBlock) + { + //Prevent stacker bug + if (getPlayer().getPassenger() != null) + return; + } + List itemLore = new ArrayList(); if (gadget.GetCost(CurrencyType.Coins) >= 0) @@ -78,6 +91,11 @@ public class GadgetPage extends ShopPageBase { itemLore.add(C.cGold + "Found in Treasure Chests."); } + else if (gadget.GetCost(CurrencyType.Coins) == -3) + { + + } + itemLore.add(C.cBlack); itemLore.addAll(Arrays.asList(gadget.GetDescription())); @@ -113,6 +131,11 @@ public class GadgetPage extends ShopPageBase public void purchaseGadget(final Player player, final Gadget gadget) { + if(getClientManager().Get(player).isDisguised()) + { + UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); + return; + } getShop().openPageForPlayer(getPlayer(), new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() { public void run() @@ -141,7 +164,7 @@ public class GadgetPage extends ShopPageBase } public void handleRightClick(Player player, Gadget gadget) - { + { if (gadget instanceof ItemGadget) { purchaseGadget(player, gadget); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 4e779d687..f77c4851f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -52,6 +52,9 @@ public class Menu extends ShopPageBase " ", ChatColor.RESET + C.cPurple + "Hero Rank", ChatColor.RESET + "Receives 15000 Coins per Month", + " ", + ChatColor.RESET + C.cGreen + "Legend Rank", + ChatColor.RESET + "Recieves 30000 Coins per Month" }, 1, false)); addButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java index a9fd03414..9bdcadd54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java @@ -82,8 +82,13 @@ public class PetTagPage extends ShopPageBase public void run() { PetChangeToken token = new PetChangeToken(); + + if (getClientManager().Get(getPlayer()) != null) + token.AccountId = getClientManager().Get(getPlayer()).getAccountId(); + token.Name = getPlayer().getName(); token.PetType = _pet.GetPetType().toString(); + token.PetId = _pet.GetPetType().ordinal(); token.PetName = _tagName; PetToken petToken = new PetToken(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java index 41b08748e..832c02506 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java @@ -65,6 +65,11 @@ public abstract class RepositoryBase implements Listener { return _dataSource; } + + protected DSLContext jooq() + { + return DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + } /** * Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool! diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 521812057..86a78df78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -1143,18 +1143,20 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity(); + if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid) disguiseIterator.remove(); - else - { + + try{ for (Iterator playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();) { Player player = playerIterator.next(); - + if (!player.isOnline() || !player.isValid()) playerIterator.remove(); } } + catch (Exception exception) {} } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index 33126f3d6..5fcff15ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -2,140 +2,152 @@ package mineplex.core.disguise.disguises; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.spigotmc.ProtocolData; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayInSettings; import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo; import net.minecraft.util.com.mojang.authlib.GameProfile; public class DisguisePlayer extends DisguiseHuman { - private GameProfile _profile; - private boolean _sneaking; - private BlockFace _sleeping; + private GameProfile _profile; + private boolean _sneaking; + private BlockFace _sleeping; - public DisguisePlayer(org.bukkit.entity.Entity entity) + public DisguisePlayer(org.bukkit.entity.Entity entity) + { + super(entity); + } + + public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile) + { + this(entity); + + setProfile(profile); + } + + public void setProfile(GameProfile profile) + { + GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName()); + + newProfile.getProperties().putAll(profile.getProperties()); + + _profile = newProfile; + } + + public BlockFace getSleepingDirection() + { + return _sleeping; + } + + /** + * Don't use this if the disguise is already on as it will not work the way + * you want it to. Contact libraryaddict if you need that added. + */ + public void setSleeping(BlockFace sleeping) + { + _sleeping = sleeping; + } + + public void setSneaking(boolean sneaking) + { + _sneaking = sneaking; + } + + public boolean getSneaking() + { + return _sneaking; + } + + public Packet getOldInfoPacket(boolean add) + { + PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(); + + if(Entity instanceof Player) { - super(entity); + playerInfo.username = Entity.getName(); + playerInfo.action = add ? 0 : 4; + playerInfo.ping = 90; + playerInfo.player = ((CraftPlayer) (Player) Entity).getProfile(); + playerInfo.gamemode = 0; } - public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile) - { - this(entity); + return playerInfo; + } - setProfile(profile); - } + public Packet getNewInfoPacket(boolean add) + { + PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); + newDisguiseInfo.username = _profile.getName(); + newDisguiseInfo.action = add ? 0 : 4; + newDisguiseInfo.ping = 90; + newDisguiseInfo.player = _profile; + newDisguiseInfo.gamemode = 0; - public void setProfile(GameProfile profile) - { - GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName()); + return newDisguiseInfo; + } - newProfile.getProperties().putAll(profile.getProperties()); + @SuppressWarnings("static-access") + @Override + public void UpdateDataWatcher() + { + super.UpdateDataWatcher(); - _profile = newProfile; - } + byte b0 = DataWatcher.getByte(0); + DataWatcher.watch(10, (Object)(byte)0x40); + + if(_sneaking) + DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1))); + else + DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1)))); + } - public BlockFace getSleepingDirection() - { - return _sleeping; - } + public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation) + { + Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30)); + loc.setY(Math.max(loc.getY(), 0)); - /** - * Don't use this if the disguise is already on as it will not work the way you want it to. Contact libraryaddict if you need - * that added. - */ - public void setSleeping(BlockFace sleeping) - { - _sleeping = sleeping; - } + PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); + packet.a = Entity.getId(); + packet.b = _profile; + packet.c = MathHelper.floor(loc.getX() * 32.0D); + packet.d = MathHelper.floor(loc.getY() * 32.0D); + packet.e = MathHelper.floor(loc.getZ() * 32.0D); + packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F)); + packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F)); + packet.i = DataWatcher; - public void setSneaking(boolean sneaking) - { - _sneaking = sneaking; - } + return packet; + } - public Packet getOldInfoPacket(boolean add) - { - PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(); + @Override + public PacketPlayOutNamedEntitySpawn GetSpawnPacket() + { + PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); + packet.a = Entity.getId(); + packet.b = _profile; + packet.c = MathHelper.floor(Entity.locX * 32.0D); + packet.d = MathHelper.floor(Entity.locY * 32.0D); + packet.e = MathHelper.floor(Entity.locZ * 32.0D); + packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); + packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); + packet.i = DataWatcher; - if (Entity instanceof Player) - { - playerInfo.username = Entity.getName(); - playerInfo.action = add ? 0 : 4; - playerInfo.ping = 90; - playerInfo.player = ((CraftPlayer) (Player) Entity).getProfile(); - playerInfo.gamemode = 0; - } + return packet; + } - return playerInfo; - } - - public Packet getNewInfoPacket(boolean add) - { - PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); - newDisguiseInfo.username = _profile.getName(); - newDisguiseInfo.action = add ? 0 : 4; - newDisguiseInfo.ping = 90; - newDisguiseInfo.player = _profile; - newDisguiseInfo.gamemode = 0; - - return newDisguiseInfo; - } - - @Override - public void UpdateDataWatcher() - { - super.UpdateDataWatcher(); - - byte b0 = DataWatcher.getByte(0); - - if (_sneaking) - DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1))); - else - DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1)))); - } - - public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation) - { - Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30)); - loc.setY(Math.max(loc.getY(), 0)); - - PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); - packet.a = Entity.getId(); - packet.b = _profile; - packet.c = MathHelper.floor(loc.getX() * 32.0D); - packet.d = MathHelper.floor(loc.getY() * 32.0D); - packet.e = MathHelper.floor(loc.getZ() * 32.0D); - packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F)); - packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F)); - packet.i = DataWatcher; - - return packet; - } - - @Override - public PacketPlayOutNamedEntitySpawn GetSpawnPacket() - { - PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); - packet.a = Entity.getId(); - packet.b = _profile; - packet.c = MathHelper.floor(Entity.locX * 32.0D); - packet.d = MathHelper.floor(Entity.locY * 32.0D); - packet.e = MathHelper.floor(Entity.locZ * 32.0D); - packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); - packet.i = DataWatcher; - - return packet; - } - - public String getName() - { - return _profile.getName(); - } + public String getName() + { + return _profile.getName(); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 41410dfd6..bfd29d925 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -206,7 +206,7 @@ public class DonationManager extends MiniDbClientPlugin } public void RewardCoins(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) - { + { _repository.rewardCoins(new Callback() { public void run(Boolean success) @@ -295,6 +295,11 @@ public class DonationManager extends MiniDbClientPlugin _coinQueue.clear(); } + public void rewardGold(Callback callback, String caller, Player player, int amount) + { + rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), amount); + } + public void rewardGold(Callback callback, String caller, String name, int accountId, int amount) { rewardGold(callback, caller, name, accountId, amount, true); @@ -405,7 +410,7 @@ public class DonationManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Get(playerName).addGold(_repository.retrieveDonorInfo(resultSet).getGold()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java index 01f927d39..d1c44b6d6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java @@ -108,7 +108,7 @@ public class EloManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadClientInformation(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index c30bb11eb..ab9c70d52 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -29,6 +29,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ItemSpawnEvent; @@ -175,6 +176,7 @@ public class Explosion extends MiniPlugin if (Math.random() > Math.min(0.975, chance)) { FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue()); + fall.setDropItem(false); Vector vec = UtilAlg.getTrajectory(fEnt, fall); if (vec.getY() < 0) vec.setY(vec.getY() * -1); @@ -207,6 +209,13 @@ public class Explosion extends MiniPlugin }, 1); } + @EventHandler + public void ExplosionChangeBlock(EntityChangeBlockEvent event) + { + if (_explosionBlocks.contains(event.getEntity())) + event.setCancelled(true); + } + @EventHandler public void ExplosionBlockUpdate(UpdateEvent event) { @@ -256,14 +265,6 @@ public class Explosion extends MiniPlugin } } - @EventHandler - public void ExplosionItemSpawn(ItemSpawnEvent event) - { - for (FallingBlock block : _explosionBlocks) - if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1) - event.setCancelled(true); - } - @EventHandler(priority = EventPriority.LOW) public void ExplosionBlocks(EntityExplodeEvent event) { @@ -347,6 +348,7 @@ public class Explosion extends MiniPlugin if (Math.random() > Math.min(0.98, chance)) { FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue()); + fall.setDropItem(false); Vector vec = UtilAlg.getTrajectory(fLoc, fall.getLocation()); if (vec.getY() < 0) vec.setY(vec.getY() * -1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index c25fec865..cafd20ec9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -401,7 +401,7 @@ public class FriendManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadClientInformation(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index 359220020..c7ab1ae90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -159,7 +159,7 @@ public class FriendRepository extends RepositoryBase Set friendNames = new HashSet(); for(FriendStatus status : friendData.getFriends()) { - friendNames.add(status.Name); + friendNames.add(status.Name.toLowerCase()); } // Load PlayerStatus' for friends @@ -188,7 +188,7 @@ public class FriendRepository extends RepositoryBase */ public String fetchPlayerServer(String playerName) { - PlayerStatus status = _repository.getElement(playerName); + PlayerStatus status = _repository.getElement(playerName.toLowerCase()); return (status == null) ? null : status.getServer(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 775206ffd..54a3ea799 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -6,16 +6,19 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Rank; import mineplex.core.common.util.NautHashMap; @@ -50,6 +53,7 @@ public class GadgetManager extends MiniPlugin private DisguiseManager _disguiseManager; private BlockRestore _blockRestore; private ProjectileManager _projectileManager; + private AchievementManager _achievementManager; private NautHashMap> _gadgets; @@ -61,7 +65,7 @@ public class GadgetManager extends MiniPlugin public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager, - DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager) + DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager) { super("Gadget Manager", plugin); @@ -73,14 +77,15 @@ public class GadgetManager extends MiniPlugin _disguiseManager = disguiseManager; _blockRestore = blockRestore; _projectileManager = projectileManager; - + _achievementManager = achievementManager; + CreateGadgets(); } private void CreateGadgets() { _gadgets = new NautHashMap>(); - + // Items addGadget(new ItemEtherealPearl(this)); addGadget(new ItemFirework(this)); @@ -90,9 +95,8 @@ public class GadgetManager extends MiniPlugin addGadget(new ItemPaintballGun(this)); addGadget(new ItemBatGun(this)); addGadget(new ItemCoinBomb(this)); - //addGadget(new ItemGemBomb(this)); - //addGadget(new ItemFootball(this)); - //addGadget(new ItemDuelingSword(this)); + addGadget(new ItemPaintbrush(this)); + addGadget(new ItemDuelingSword(this)); // Costume addGadget(new OutfitRaveSuit(this, "Rave Hat", -2, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0)); @@ -105,6 +109,11 @@ public class GadgetManager extends MiniPlugin addGadget(new OutfitSpaceSuit(this, "Space Pants", -2, ArmorSlot.Legs, Material.GOLD_LEGGINGS, (byte)0)); addGadget(new OutfitSpaceSuit(this, "Space Boots", -2, ArmorSlot.Boots, Material.GOLD_BOOTS, (byte)0)); + addGadget(new OutfitTeam(this, "Team Helmet", -1, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0)); + addGadget(new OutfitTeam(this, "Team Shirt", -1, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte)0)); + addGadget(new OutfitTeam(this, "Team Pants", -1, ArmorSlot.Legs, Material.LEATHER_LEGGINGS, (byte)0)); + addGadget(new OutfitTeam(this, "Team Boots", -1, ArmorSlot.Boots, Material.LEATHER_BOOTS, (byte)0)); + // Morphs addGadget(new MorphVillager(this)); addGadget(new MorphCow(this)); @@ -112,14 +121,13 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphBlock(this)); addGadget(new MorphEnderman(this)); addGadget(new MorphBat(this)); - //addGadget(new MorphNotch(this)); addGadget(new MorphPumpkinKing(this)); addGadget(new MorphPig(this)); addGadget(new MorphCreeper(this)); addGadget(new MorphBlaze(this)); - //addGadget(new MorphGeno(this)); addGadget(new MorphWither(this)); addGadget(new MorphBunny(this)); + addGadget(new MorphSlime(this, _achievementManager)); // Particles addGadget(new ParticleFoot(this)); @@ -144,7 +152,6 @@ public class GadgetManager extends MiniPlugin addGadget(new MusicGadget(this, "Stal Disc", new String[] {""}, -2, 2263, 150000)); addGadget(new MusicGadget(this, "Strad Disc", new String[] {""}, -2, 2264, 188000)); addGadget(new MusicGadget(this, "Ward Disc", new String[] {""}, -2, 2265, 251000)); - //addGadget(new MusicGadget(this, "11 Disc", new String[] {""}, -2, 2266, 71000)); addGadget(new MusicGadget(this, "Wait Disc", new String[] {""}, -2, 2267, 238000)); } @@ -272,6 +279,20 @@ public class GadgetManager extends MiniPlugin } } } + + public void DisableAll(Player player, List dontDisable) + { + for (GadgetType gadgetType : _gadgets.keySet()) + { + for (Gadget gadget : _gadgets.get(gadgetType)) + { + if (dontDisable.contains(gadget.GetName())) + continue; + + gadget.Disable(player); + } + } + } public PetManager getPetManager() { @@ -430,4 +451,16 @@ public class GadgetManager extends MiniPlugin return true; } + + @EventHandler + public void chissMeow(PlayerToggleSneakEvent event) + { + if (event.getPlayer().getName().equals("Chiss")) + { + if (!event.getPlayer().isSneaking()) + { + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f); + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java index 6635ddbe3..c5d37b9c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java @@ -3,7 +3,6 @@ package mineplex.core.gadget.gadgets; import java.util.ArrayList; import java.util.List; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilBlock; @@ -64,6 +63,7 @@ public class BlockForm DisguiseChicken disguise = new DisguiseChicken(_player); disguise.setBaby(); disguise.setSoundDisguise(new DisguiseCat(_player)); + disguise.setInvisible(true); _host.Manager.getDisguiseManager().disguise(disguise); //Apply Falling Block diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java index 7d56300dd..94d4bfea3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java @@ -1,66 +1,48 @@ package mineplex.core.gadget.gadgets; -import java.util.HashSet; - import org.bukkit.Material; -import org.bukkit.entity.Bat; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.itemstack.ItemStackFactory; public class ItemDuelingSword extends ItemGadget { public ItemDuelingSword(GadgetManager manager) { - super(manager, "Dueling Sword", new String[] + super(manager, "PvP Sword", new String[] { - C.cWhite + "While active, you are able to fight", - C.cWhite + "against other people who are also", - C.cWhite + "wielding a dueling sword.", + C.cGreen + "Activated in King of the Hill", }, - -1, - Material.WOOD_SWORD, (byte)3, + -3, + Material.GOLD_SWORD, (byte)0, 1000, new Ammo("Dueling Sword", "10 Swords", Material.WOOD_SWORD, (byte)0, new String[] { C.cWhite + "10 Swords to duel with" }, 1000, 10)); } + + @Override + public void ApplyItem(Player player, boolean inform) + { + Manager.RemoveItem(player); + + _active.add(player); + + player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "PvP Sword")); + } + + @Override + @EventHandler + public void Activate(PlayerInteractEvent event) + { + + } @Override public void ActivateCustom(Player player) - { - ItemStack stack = new ItemStack(Material.GOLD_SWORD); - ItemMeta meta = stack.getItemMeta(); - meta.setDisplayName("Dueling Sword"); - stack.setItemMeta(meta); + { - player.getInventory().setItem(Manager.getActiveItemSlot(), stack); - - //Inform - UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void damage(EntityDamageByEntityEvent event) - { - if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player)) - return; - - Player damager = (Player)event.getDamager(); - Player damagee = (Player)event.getEntity(); - - if (!UtilGear.isMat(damager.getItemInHand(), Material.GOLD_SWORD) || !UtilGear.isMat(damagee.getItemInHand(), Material.GOLD_SWORD)) - return; - - event.setCancelled(false); - - event.setDamage(4); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemKothSword.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemKothSword.java new file mode 100644 index 000000000..6bb5d66a0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemKothSword.java @@ -0,0 +1,5 @@ +package mineplex.core.gadget.gadgets; + +public class ItemKothSword { + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java index a2ee2c308..90c80cc1c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java @@ -126,7 +126,8 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.EAT, 1f, 1f); - event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 80, 1), true); + if (!event.getPlayer().hasPotionEffect(PotionEffectType.SPEED)) + event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 80, 1), true); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java index 859f1e3e3..68fba27a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java @@ -18,9 +18,15 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.gadget.types.ItemGadget; @@ -30,16 +36,17 @@ import mineplex.core.updater.event.UpdateEvent; public class ItemPaintballGun extends ItemGadget { private HashSet _balls = new HashSet(); - - public ItemPaintballGun(GadgetManager manager) + + public ItemPaintballGun(GadgetManager manager) { - super(manager, "Paintball Gun", new String[] - { + super(manager, "Paintball Gun", new String[] + { C.cWhite + "PEW PEW PEW PEW!", - }, - -1, - Material.GOLD_BARDING, (byte)0, - 200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING, (byte)0, new String[] { C.cWhite + "100 Paintballs for you to shoot!" }, 500, 100)); + }, -1, Material.GOLD_BARDING, (byte) 0, 200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING, + (byte) 0, new String[] + { + C.cWhite + "100 Paintballs for you to shoot!" + }, 500, 100)); } @Override @@ -48,77 +55,56 @@ public class ItemPaintballGun extends ItemGadget Projectile proj = player.launchProjectile(EnderPearl.class); proj.setVelocity(proj.getVelocity().multiply(2)); _balls.add(proj); - - //Sound + + // Sound player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 1.2f); } - + @EventHandler public void Paint(ProjectileHitEvent event) { if (!_balls.remove(event.getEntity())) return; - - Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity()); - loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 49); - - byte color = 2; - double r = Math.random(); - if (r > 0.8) color = 4; - else if (r > 0.6) color = 5; - else if (r > 0.4) color = 9; - else if (r > 0.2) color = 14; - for (Block block : UtilBlock.getInRadius(loc, 3d).keySet()) + Location loc = event.getEntity().getLocation(); + + Vector vec = event.getEntity().getVelocity().normalize().multiply(0.05); + + if (vec.length() > 0) { - if (block.getType() == Material.PORTAL) - return; - - if (block.getType() == Material.CACTUS) - return; - - if (block.getType() == Material.SUGAR_CANE_BLOCK) - return; - } - - List blocks = new ArrayList(); - blocks.addAll(UtilBlock.getInRadius(loc, 1.5d).keySet()); - - GadgetBlockEvent gadgetEvent = new GadgetBlockEvent(this, blocks); - Bukkit.getServer().getPluginManager().callEvent(gadgetEvent); - - if (gadgetEvent.isCancelled()) - return; - - for (Block block : gadgetEvent.getBlocks()) - { - if (!UtilBlock.solid(block)) - continue; - - if (block.getType() == Material.CARPET) - Manager.getBlockRestore().add(block, 171, color, 4000); - else - Manager.getBlockRestore().add(block, 35, color, 4000); + int i = 0; + + while (UtilBlock.airFoliage(loc.getBlock())) + { + loc.add(vec); + + if (i++ > 50) + break; + } } + + loc.getWorld().playSound(loc, Sound.DIG_STONE, 1.3F, 1.3F); + + UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, 0.2F, 0.2F, 0.2F, 1, 70, ViewDist.LONG, UtilServer.getPlayers()); } - + @EventHandler public void Teleport(PlayerTeleportEvent event) { if (event.getCause() == TeleportCause.ENDER_PEARL) event.setCancelled(true); } - + @EventHandler public void cleanupBalls(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - + for (Iterator ballIterator = _balls.iterator(); ballIterator.hasNext();) { Projectile ball = ballIterator.next(); - + if (ball.isDead() || !ball.isValid()) ballIterator.remove(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java new file mode 100644 index 000000000..0217485cf --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java @@ -0,0 +1,207 @@ +package mineplex.core.gadget.gadgets; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ItemPaintbrush extends ItemGadget +{ + private NautHashMap _brushColor = new NautHashMap(); + private NautHashMap _brushPrevious = new NautHashMap(); + + private NautHashMap _playerLocation = new NautHashMap(); + + public ItemPaintbrush(GadgetManager manager) + { + super(manager, "Paintbrush", new String[] + { + C.cWhite + "Unleash your inner creativity!", + C.cWhite + "", + C.cGreen + "Activated at a Painter NPC", + }, + -3, + Material.WOOD_SWORD, (byte)0, + 200, new Ammo("Paint", "100 Pixels", Material.INK_SACK, (byte)0, new String[] { C.cWhite + "100 Pixels worth of Paint!" }, 500, 100)); + } + + @Override + public void ApplyItem(Player player, boolean inform) + { + Manager.RemoveItem(player); + + _active.add(player); + + List itemLore = new ArrayList(); + itemLore.addAll(Arrays.asList(GetDescription())); + + player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, GetName())); + + if (inform) + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + ".")); + } + + @Override + @EventHandler + public void Activate(PlayerInteractEvent event) + { + + } + + @Override + public void ActivateCustom(Player player) + { + + } + + @Override + public void EnableCustom(Player player) + { + ApplyItem(player, true); + + _brushColor.put(player.getName(), (byte)15); + _playerLocation.put(player.getName(), player.getLocation()); + } + + + @Override + public void DisableCustom(Player player) + { + _brushColor.remove(player.getName()); + _brushPrevious.remove(player.getName()); + _playerLocation.remove(player.getName()); + + RemoveItem(player); + } + + @EventHandler + public void colorSelect(PlayerInteractEvent event) + { + if (!IsActive(event.getPlayer())) + return; + + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) + return; + + Block block = player.getTargetBlock(null, 100); + if (block == null || block.getType() != Material.STAINED_CLAY) + return; + + _brushColor.put(player.getName(), block.getData()); + + player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f); + } + + + @EventHandler + public void disableDistance(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (!GetActive().contains(player)) + continue; + + Location loc = _playerLocation.get(player.getName()); + + if (loc == null || UtilMath.offset(player.getLocation(), loc) > 12) + { + Disable(player); + } + } + } + + @EventHandler + public void paint(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : GetActive()) + { + if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) + continue; + + if (!player.isBlocking()) + { + _brushPrevious.remove(player.getName()); + continue; + } + + Block block = player.getTargetBlock(null, 100); + if (block == null || block.getType() != Material.WOOL) + continue; + + //Color + Manager.getBlockRestore().add(block, 35, _brushColor.get(player.getName()), 30000); + + //Join Dots + if (_brushPrevious.containsKey(player.getName())) + { + while (UtilMath.offset(_brushPrevious.get(player.getName()), block.getLocation().add(0.5, 0.5, 0.5)) > 0.5) + { + _brushPrevious.get(player.getName()).add(UtilAlg.getTrajectory(_brushPrevious.get(player.getName()), block.getLocation().add(0.5, 0.5, 0.5)).multiply(0.5)); + + Block fixBlock = _brushPrevious.get(player.getName()).getBlock(); + + if (fixBlock.getType() != Material.WOOL) + continue; + + Manager.getBlockRestore().add(fixBlock, 35, _brushColor.get(player.getName()), 30000); + } + } + + player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.25f, 2f); + + + _brushPrevious.put(player.getName(), block.getLocation().add(0.5, 0.5, 0.5)); + } + } + + @EventHandler + public void enableInteract(PlayerInteractEntityEvent event) + { + if (IsActive(event.getPlayer())) + return; + + if (!(event.getRightClicked() instanceof Villager)) + return; + + Villager villager = (Villager)event.getRightClicked(); + + if (villager.getCustomName() != null && villager.getCustomName().contains("Painter")) + { + Enable(event.getPlayer()); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSlime.java new file mode 100644 index 000000000..12f9a3eca --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSlime.java @@ -0,0 +1,103 @@ +package mineplex.core.gadget.gadgets; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.*; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.recharge.Recharge; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; + +public class MorphSlime extends MorphGadget +{ + private CoreClientManager _clientManager; + private AchievementManager _achievementManager; + + public MorphSlime(GadgetManager manager, AchievementManager achievements) + { + super(manager, "Big Larry Morph", new String[] + { + C.cWhite + "Become a slime like Big Larry!", + " ", + C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Bounce", + " ", + C.cWhite + "+1 Slime Size for every 10 Mineplex Levels", + }, + 80000, + Material.SLIME_BALL, (byte)0); + + _achievementManager = achievements; + _clientManager = manager.getClientManager(); + } + + @Override + public void EnableCustom(final Player player) + { + this.ApplyArmor(player); + + DisguiseSlime disguise = new DisguiseSlime(player); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setCustomNameVisible(true); + + int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8; + + if (size < 1) + size = 1; + + if (size > 12) + size = 12; + + disguise.SetSize(size); + + Manager.getDisguiseManager().disguise(disguise); + } + + @Override + public void DisableCustom(Player player) + { + this.RemoveArmor(player); + Manager.getDisguiseManager().undisguise(player); + } + + @EventHandler + public void skill(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!IsActive(player)) + return; + + if (!UtilEvent.isAction(event, ActionType.L)) + return; + + if (!UtilEnt.isGrounded(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 1000, false, false)) + return; + + player.getWorld().playSound(player.getLocation(), Sound.SLIME_ATTACK, 1f, 1f); + + //Size + int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8; + + if (size < 1) + size = 1; + + if (size > 12) + size = 12; + + //Vel + UtilAction.velocity(player, 1 + (size * 0.2), 0, 10, true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java index 62ff23a36..da9d82ebd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java @@ -146,7 +146,7 @@ public class MorphWither extends MorphGadget { WitherSkull skull = skullIterator.next(); - if (!skull.isValid()) + if (!skull.isValid() || skull.getTicksLived() > 60) { skullIterator.remove(); skull.remove(); @@ -170,7 +170,7 @@ public class MorphWither extends MorphGadget player.setFlying(true); if (UtilEnt.isGrounded(player)) - player.setVelocity(new Vector(0,1,0)); + UtilAction.velocity(player, new Vector(0,1,0)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitRaveSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitRaveSuit.java index 265ad7952..2834498a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitRaveSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitRaveSuit.java @@ -2,11 +2,13 @@ package mineplex.core.gadget.gadgets; import java.util.HashMap; +import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; @@ -25,7 +27,7 @@ public class OutfitRaveSuit extends OutfitGadget public OutfitRaveSuit(GadgetManager manager, String name, int cost, ArmorSlot slot, Material mat, byte data) { - super(manager, name, new String[] {"Wear the complete set for","awesome bonus effects!", "Bonus coming soon..."}, cost, slot, mat, data); + super(manager, name, new String[] {ChatColor.RESET + "Wear the complete set for",ChatColor.RESET + "awesome bonus effects!", ChatColor.RESET + "Bonus coming soon..."}, cost, slot, mat, data); } @Override @@ -147,4 +149,10 @@ public class OutfitRaveSuit extends OutfitGadget stack.setItemMeta(meta); } } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _colorPhase.remove(event.getPlayer().getName()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitSpaceSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitSpaceSuit.java index f69ccf7eb..fe25b7843 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitSpaceSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitSpaceSuit.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -11,7 +12,7 @@ public class OutfitSpaceSuit extends OutfitGadget public OutfitSpaceSuit(GadgetManager manager, String name, int cost, ArmorSlot slot, Material mat, byte data) { - super(manager, name, new String[] {"Wear the complete set for","awesome bonus effects!", "Bonus coming soon..."}, cost, slot, mat, data); + super(manager, name, new String[] {ChatColor.RESET + "Wear the complete set for",ChatColor.RESET + "awesome bonus effects!", ChatColor.RESET + "Bonus coming soon..."}, cost, slot, mat, data); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java new file mode 100644 index 000000000..9090eb81e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java @@ -0,0 +1,248 @@ +package mineplex.core.gadget.gadgets; + +import java.util.HashMap; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.types.OutfitGadget; +import mineplex.core.gadget.types.OutfitGadget.ArmorSlot; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; + +public class OutfitTeam extends OutfitGadget +{ + private boolean _enabled = true; + + private HashMap _colorSetting = new HashMap(); + + public OutfitTeam(GadgetManager manager, String name, + int cost, ArmorSlot slot, Material mat, byte data) + { + super(manager, name, new String[] {ChatColor.RESET + "Team up with other players!", ChatColor.RESET + "Equip by typing;", ChatColor.RESET + C.cGreen + "/team "}, cost, slot, mat, data); + } + + @Override + public void Enable(Player player) + { + GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this); + Bukkit.getServer().getPluginManager().callEvent(gadgetEvent); + + if (gadgetEvent.isCancelled()) + { + return; + } + + EnableCustom(player); + Manager.setActive(player, this); + } + + @Override + public void ApplyArmor(Player player) + { + Manager.RemoveMorph(player); + + Manager.RemoveOutfit(player, _slot); + + _active.add(player); + + if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + + else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + + else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + + else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + } + + @Override + public void RemoveArmor(Player player) + { + if (!_active.remove(player)) + return; + + if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null); + else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null); + else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null); + else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null); + } + + @Override + public void EnableCustom(Player player) + { + ApplyArmor(player); + colorArmor(player); + } + + @Override + public void DisableCustom(Player player) + { + RemoveArmor(player); + } + + @EventHandler(priority=EventPriority.LOWEST) + public void setColor(PlayerCommandPreprocessEvent event) + { + if (!_enabled) + return; + + Player player = event.getPlayer(); + + if (!event.getMessage().toLowerCase().startsWith("/team")) + return; + + event.setCancelled(true); + + String[] args = event.getMessage().toLowerCase().split(" "); + + if (args.length < 2) + { + Disable(player); + return; + } + + + //Will only display the message once + if (GetSlot() == ArmorSlot.Legs) + { + if (!Recharge.Instance.use(player, "Set Team Color", 20000, true, false)) + return; + } + else + { + if (!Recharge.Instance.use(player, "Set Team Color " + GetSlot(), 20000, false, false)) + return; + } + + //Color + if (args[1].equals("red")) + { + _colorSetting.put(player.getName(), Color.RED); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cRed + "Red Team Outfit") + "!")); + } + else if (args[1].equals("yellow")) + { + _colorSetting.put(player.getName(), Color.YELLOW); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cYellow + "Yellow Team Outfit") + "!")); + } + else if (args[1].equals("green")) + { + _colorSetting.put(player.getName(), Color.LIME); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cGreen + "Green Team Outfit") + "!")); + } + else if (args[1].equals("blue")) + { + _colorSetting.put(player.getName(), Color.AQUA); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cAqua + "Blue Team Outfit") + "!")); + } + else + return; + + colorArmor(player); + + Enable(player); + } + + private void colorArmor(Player player) + { + if (!_colorSetting.containsKey(player.getName())) + return; + + //Get Item + ItemStack stack; + + if (GetSlot() == ArmorSlot.Helmet) + { + stack = player.getInventory().getHelmet(); + + if (!UtilGear.isMat(stack, GetDisplayMaterial())) + { + Disable(player); + return; + } + } + else if (GetSlot() == ArmorSlot.Chest) + { + stack = player.getInventory().getChestplate(); + + if (!UtilGear.isMat(stack, GetDisplayMaterial())) + { + Disable(player); + return; + } + } + else if (GetSlot() == ArmorSlot.Legs) + { + stack = player.getInventory().getLeggings(); + + if (!UtilGear.isMat(stack, GetDisplayMaterial())) + { + Disable(player); + return; + } + } + else if (GetSlot() == ArmorSlot.Boots) + { + stack = player.getInventory().getBoots(); + + if (!UtilGear.isMat(stack, GetDisplayMaterial())) + { + Disable(player); + return; + } + } + else + { + return; + } + + + //Set! + LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta(); + meta.setColor(_colorSetting.get(player.getName())); + stack.setItemMeta(meta); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _colorSetting.remove(event.getPlayer().getName()); + } + + public Color getTeamColor(Player player) + { + return _colorSetting.get(player.getName()); + } + + public void setEnabled(boolean var) + { + _enabled = var; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index 1ab3daa45..fabae966d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -18,7 +18,7 @@ public abstract class OutfitGadget extends Gadget Boots } - private ArmorSlot _slot; + protected ArmorSlot _slot; public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 196b046e2..1d66c4c91 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -7,6 +7,7 @@ public enum GameDisplay //Mini BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1), Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.EXTRA, 2), + BossBattles("Boss Battles", Material.SKULL_ITEM, (byte) 0, GameCategory.EVENT, 55), Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3), CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4), ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6), @@ -27,6 +28,7 @@ public enum GameDisplay HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20), HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52), Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21), + Micro("Micro Battle", Material.LAVA_BUCKET, (byte)0, GameCategory.ARCADE, 24), MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27), MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CHAMPIONS, 25),// Temp set to CHAMPIONS to fix UI bug @@ -50,7 +52,7 @@ public enum GameDisplay SquidShooter("Squid Shooter", Material.FIREWORK_CHARGE, (byte)0, GameCategory.ARCADE, 43), Stacker("Super Stacker", Material.BOWL, (byte)0, GameCategory.ARCADE, 42), SurvivalGames("Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.SURVIVAL, 22), - SurvivalGamesTeams("Survival Games Teams", Material.IRON_SWORD, (byte)0, GameCategory.TEAM_VARIANT, 23), + SurvivalGamesTeams("Survival Games Teams", "Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.TEAM_VARIANT, 23), Tug("Tug of Wool", Material.WHEAT, (byte)0, GameCategory.ARCADE, 44), TurfWars("Turf Wars", Material.STAINED_CLAY, (byte)14, GameCategory.ARCADE, 45), UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46), @@ -60,7 +62,10 @@ public enum GameDisplay Build("Master Builders", Material.WOOD, (byte)0, GameCategory.CLASSICS, 50), Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51), - Skywars("Skywars", Material.FEATHER, (byte)5, GameCategory.SURVIVAL, 52), + Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52), + SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53), + + Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); @@ -124,4 +129,10 @@ public enum GameDisplay return null; } + //May need to actually add this to each game individually, but for now, LobbyName works fine + public String getKitGameName() + { + return _lobbyName; + } + } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/ClickExecutor.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/ClickExecutor.java new file mode 100644 index 000000000..18c9fbf2b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/ClickExecutor.java @@ -0,0 +1,8 @@ +package mineplex.core.gui; + +import org.bukkit.event.inventory.ClickType; + +public interface ClickExecutor +{ + public void click(ClickType clickType); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/Container.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/Container.java new file mode 100644 index 000000000..9ad939f28 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/Container.java @@ -0,0 +1,5 @@ +package mineplex.core.gui; + +public interface Container { + public T getObject(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java new file mode 100644 index 000000000..87e844b1c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/DisplayItem.java @@ -0,0 +1,40 @@ +package mineplex.core.gui; + +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.gui.GuiItem; + +public class DisplayItem implements GuiItem +{ + private ItemStack _item; + + public DisplayItem(ItemStack item) + { + _item = item; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + + } + + @Override + public ItemStack getObject() + { + return _item; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiInventory.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiInventory.java new file mode 100644 index 000000000..68d347477 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiInventory.java @@ -0,0 +1,9 @@ +package mineplex.core.gui; + +import org.bukkit.inventory.Inventory; + + +public interface GuiInventory { + public void openInventory(); + public Inventory getInventory(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java new file mode 100644 index 000000000..cae592783 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/GuiItem.java @@ -0,0 +1,9 @@ +package mineplex.core.gui; + +import org.bukkit.inventory.ItemStack; + +public interface GuiItem extends ClickExecutor, Container +{ + public void setup(); + public void close(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/ItemRefresher.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/ItemRefresher.java new file mode 100644 index 000000000..e736a72bc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/ItemRefresher.java @@ -0,0 +1,6 @@ +package mineplex.core.gui; + +public interface ItemRefresher extends GuiInventory +{ + public void refreshItem(GuiItem item); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java new file mode 100644 index 000000000..0029d1864 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java @@ -0,0 +1,241 @@ +package mineplex.core.gui; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilPlayer; + +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class SimpleGui implements ItemRefresher, Listener +{ +// private Map _buttonMap = new HashMap(); + private GuiItem[] _items; + + private Player _player; + private Plugin _plugin; + private int _size; + private String _title; + private Inventory _inv; + + public SimpleGui(Plugin plugin, Player player) + { + this(plugin, player, null, 0); + } + + public SimpleGui(Plugin plugin, Player player, int size) + { + this(plugin, player, null, size); + } + + public SimpleGui(Plugin plugin, Player player, String title) + { + this(plugin, player, title, 0); + } + + public SimpleGui(Plugin plugin, Player player, String title, int size) + { + + Validate.notNull(plugin, "The plugin cannot be null!"); + Validate.notNull(player, "The player cannot be null!"); + + this._plugin = plugin; + this._player = player; + + if (size == 0) + setSize(9); + else + setSize(size); + + if (title == null) + setTitle(" "); + else + setTitle(title); + + updateArray(); + + _inv = createInventory(); + refreshInventory(); + } + + private void updateArray() + { + _items = new GuiItem[_size]; + } + + public void setItem(int i, GuiItem item) + { + Validate.isTrue(i >= 0 && i < _size, "Tried to add a gui item outside of inventory range"); + + GuiItem oldItem = getItem(i); + if (oldItem != null) oldItem.close(); + + if (item != null) + { + _items[i] = item; + item.setup(); + } + + refreshItem(i); + } + + public GuiItem getItem(int i) + { + return _items[i]; + } + + @Override + public void openInventory() + { + refreshInventory(); + UtilPlayer.swapToInventory(_player, _inv); + Bukkit.getPluginManager().registerEvents(this, _plugin); + } + + public Inventory createInventory() + { + Inventory inv = Bukkit.createInventory(_player, getSize(), getTitle()); + return inv; + } + + public void refreshInventory() + { + for (int i = 0; i < _size; i++) + { + refreshItem(i); + } + } + + @EventHandler + public void inventoryClick(InventoryClickEvent event) + { + if (!event.getWhoClicked().equals(_player) || !event.getInventory().equals(_inv)) + return; + + if (event.getSlot() >= 0 && event.getSlot() < _size) + { + GuiItem item = getItem(event.getSlot()); + if (item == null) + return; + + event.setCancelled(true); + + item.click(event.getClick()); + } + } + + @EventHandler + public void teleport(PlayerTeleportEvent event) + { + if (!event.getPlayer().equals(_player)) + return; + + close(); + } + + @EventHandler + public void inventoryClose(InventoryCloseEvent event) + { + if (!event.getPlayer().equals(_player)) + return; + + close(); + } + + @EventHandler + public void quit(PlayerQuitEvent event) + { + if (!event.getPlayer().equals(_player)) + return; + + close(); + } + + private void close() + { +// _inv = null; // TODO - do we really need to null the inventory? + HandlerList.unregisterAll(this); + + for (int i = 0; i < _size; i++) + { + GuiItem item = getItem(i); + if (item != null) item.close(); + } + } + + @Override + @Deprecated + public void refreshItem(GuiItem item) + { + if (_inv == null) + return; + + for (int i = 0; i < _size; i++) + { + if (item.equals(getItem(i))) + refreshItem(i); + } + } + + public void refreshItem(int slot) + { + GuiItem gi = getItem(slot); + + ItemStack itemStack = null; + if (gi != null) itemStack = gi.getObject(); + + _inv.setItem(slot, itemStack); + } + + public int getSize() + { + return _size; + } + + public String getTitle() + { + return _title; + } + + public Player getPlayer() + { + return _player; + } + + public Plugin getPlugin() + { + return _plugin; + } + + public void setTitle(String title) + { + this._title = title; + } + + @Override + public Inventory getInventory() + { + return _inv; + } + + public void setSize(int size) + { + Validate.isTrue(size % 9 == 0, "The size " + size + " is not divisible by 9"); + this._size = size; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGuiItem.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGuiItem.java new file mode 100644 index 000000000..187aa259f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGuiItem.java @@ -0,0 +1,50 @@ +package mineplex.core.gui; + +import org.bukkit.Material; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class SimpleGuiItem extends ItemStack implements GuiItem { + + public SimpleGuiItem(Material type, int amount, short damage) + { + super(type, amount, damage); + } + + public SimpleGuiItem(Material type, int amount) + { + super(type, amount); + } + + public SimpleGuiItem(Material type) + { + super(type); + } + + public SimpleGuiItem(ItemStack itemStack) + { + super(itemStack); + } + + @Override + public void click(ClickType clickType) + { + } + + @Override + public ItemStack getObject() + { + return this; + } + + @Override + public void setup() + { + } + + @Override + public void close() + { + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/botton/BackBotton.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/botton/BackBotton.java new file mode 100644 index 000000000..4335408eb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/botton/BackBotton.java @@ -0,0 +1,36 @@ +package mineplex.core.gui.botton; + +import mineplex.core.gui.GuiInventory; +import mineplex.core.gui.SimpleGuiItem; +import mineplex.core.itemstack.ItemStackFactory; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class BackBotton extends SimpleGuiItem { + + private GuiInventory _gui; + + public BackBotton(GuiInventory gui) { + this(ItemStackFactory.Instance.CreateStack(Material.BED, (byte) 0, 1, ChatColor.DARK_GRAY + "<-- Go Back"), gui); + } + + public BackBotton(ItemStack itemStack, GuiInventory gui) + { + super(itemStack); + this._gui = gui; + } + + @Override + public void click(ClickType clickType) + { + getGui().openInventory(); + } + + public GuiInventory getGui() + { + return _gui; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java new file mode 100644 index 000000000..6398b4e6b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java @@ -0,0 +1,238 @@ +package mineplex.core.gui.pages; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; + +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +public class LoadingWindow implements Runnable, Listener { + + public static String[] messages = new String[]{"Sending Carrier Pigeons...", "#BlameChiss", "Converting to Morse Code...", "Training monkeys..."}; + public static long defaultWait = 30; + + public ItemStack _background; + public ItemStack _barLoading; + public ItemStack _barBack; + + private Inventory _inv; + private final InventoryView _currentInventory; + + private final int _id; + + private final Plugin _plugin; + private final UUID _playersUUID; + + private String _message; + private String _title; + + private final int _size; + + private final int[] _activeRows; + + private long _ticker = 0; + + public LoadingWindow(Plugin plugin, Player player, int size) { + this(plugin, player, null, size, null, null); + } + + public LoadingWindow(Plugin plugin, Player player, long startTime, int size) { + this(plugin, player, startTime, size, null, null); + } + + public LoadingWindow(Plugin plugin, Player player, long startTime, int size, String message) + { + this(plugin, player, startTime, size, message, message); + } + + @SuppressWarnings("deprecation") + public LoadingWindow(Plugin plugin, Player player, Long startTime, int size, String title, String message) + { + Validate.notNull(plugin, "The plugin can not be null!"); + Validate.notNull(player, "The player can not be null!"); + + _currentInventory = player.getOpenInventory(); + + _size = size; + _activeRows = getActiveRows(size / 9); + + _plugin = plugin; + _playersUUID = player.getUniqueId(); + + + _background = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData(), 1, _message); + _barLoading = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, _message); + _barBack = ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.WHITE.getData(), 1, _message); + + + if (title == null && message == null) + { + String randomName = UtilMath.randomElement(messages); + title = randomName; + message = randomName; + } + else if (title == null) + { + title = " "; + } + else if (message == null) + { + message = UtilMath.randomElement(messages); + } + if (startTime == null) + startTime = defaultWait; + + + _title = title; + setMessage(message); + _id = Bukkit.getScheduler().runTaskTimer(plugin, this, startTime, 5).getTaskId(); + } + + public void setMessage(String message) { + _message = message; + ItemMeta im =_background.getItemMeta(); + im.setDisplayName(_message); + _background.setItemMeta(im); + _barBack.setItemMeta(im); + _barLoading.setItemMeta(im); + + setBackGround(); + setLoadingBarItems(); + } + + public void setTitle(String title) { + _title = title; + + Player player = Bukkit.getPlayer(_playersUUID); + if (_inv == null || player == null) + return; + + ItemStack[] con = _inv.getContents(); + + _inv = Bukkit.createInventory(null, _size, _title); + _inv.setContents(con); + UtilPlayer.swapToInventory(player, _inv); + } + + @EventHandler + public void onClick(InventoryClickEvent event) { + if (event.getWhoClicked().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) { + event.setCancelled(true); + } + } + + @EventHandler + public void inventoryClose(InventoryCloseEvent event) { + if (event.getPlayer().getUniqueId().equals(_playersUUID) && event.getInventory().equals(_inv)) { + end(); + } + } + + @Override + public void run() + { + Player player = Bukkit.getPlayer(_playersUUID); + + if (player == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) { + end(); + return; + } + if (_inv == null) { + _inv = Bukkit.createInventory(null, _size, _title); + + setBackGround(); + setLoadingBarItems(); + UtilPlayer.swapToInventory(player, _inv); + Bukkit.getPluginManager().registerEvents(this, _plugin); + } else + setLoadingBarItems(); + + _ticker++; + } + + public void end() { + HandlerList.unregisterAll(this); + Bukkit.getScheduler().cancelTask(_id); + _inv = null; + } + + private void setBackGround() { + if (_inv == null) + return; + + List ignore = new ArrayList(); + + for (int row : _activeRows) { + + int rowStart = row * 9; + int rowEnd = rowStart + 9; + + for (int i = rowStart; i < rowEnd; i++) { + ignore.add(i); + } + } + + for (int i = 0; i < _size; i++) { + if (!ignore.contains(i)) + _inv.setItem(i, _background); + } + } + + private void setLoadingBarItems() { + if (_inv == null) + return; + ItemStack[] loadingBar = getLoadingBar(); + + for (int row : _activeRows) { + int rowStart = row * 9; + for (int i = 0; i < 9; i++) { + _inv.setItem(i + rowStart, loadingBar[i]); + } + } + } + + public ItemStack[] getLoadingBar() + { + ItemStack[] loadingBar = new ItemStack[9]; + + int barStart = (int) (_ticker % 9); + int barEnd = (barStart + 3) % 9; + + boolean endAfter = barEnd > barStart; + + for (int i = 0; i < loadingBar.length; i++) { + if (endAfter ? (i >= barStart && i < barEnd) : (i >= barStart || i < barEnd)) + loadingBar[i] = _barLoading; + else + loadingBar[i] = _barBack; + } + return loadingBar; + } + + private static int[] getActiveRows(int rows) + { + float mid = rows / 2.0f; + if (mid == (int) mid) + return new int[] { (int) mid , (int) mid -1}; + else + return new int[] { (int) Math.floor(mid)}; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/MessageWindow.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/MessageWindow.java new file mode 100644 index 000000000..d51bbcf79 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/MessageWindow.java @@ -0,0 +1,87 @@ +package mineplex.core.gui.pages; + +import java.util.UUID; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gui.GuiInventory; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class MessageWindow implements Listener, GuiInventory { + + private UUID _playersUUID; + private Plugin _plugin; + private Inventory _inv; + + public MessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size) + { + _plugin = plugin; + + this._playersUUID = player.getUniqueId(); + + _inv = Bukkit.createInventory(null, size, title); + + for (int i = 0; i < size; i++) { + _inv.setItem(i, is); + } + } + + @EventHandler(ignoreCancelled = true) + public void onClick(InventoryClickEvent e) + { + if (!e.getWhoClicked().getUniqueId().equals(_playersUUID)) + return; + e.setCancelled(true); + } + + @EventHandler + public void onClose(InventoryCloseEvent e) + { + if (!e.getPlayer().getUniqueId().equals(_playersUUID)) + return; + HandlerList.unregisterAll(this); + close(); + } + + @Override + public void openInventory() + { + Player player = Bukkit.getPlayer(_playersUUID); + + if (player == null || player.getOpenInventory().getTopInventory().equals(_inv)) + return; + + UtilPlayer.swapToInventory(player, _inv); + Bukkit.getPluginManager().registerEvents(this, _plugin); + open(); + } + + @Override + public Inventory getInventory() + { + return _inv; + } + public UUID getPlayersUUID() + { + return _playersUUID; + } + public Plugin getPlugin() + { + return _plugin; + } + public void open() { + + } + public void close() { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/TimedMessageWindow.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/TimedMessageWindow.java new file mode 100644 index 000000000..d84b3bdfa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/TimedMessageWindow.java @@ -0,0 +1,65 @@ +package mineplex.core.gui.pages; + +import mineplex.core.gui.GuiInventory; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class TimedMessageWindow extends MessageWindow implements Runnable { + private GuiInventory _gui; + private int _id; + private long _time; + + public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time) + { + this(plugin, player, is, title, size, time, null); + } + + public TimedMessageWindow(Plugin plugin, Player player, ItemStack is, String title, int size, long time, GuiInventory gui) + { + super(plugin, player, is, title, size); + + this._gui = gui; + this._time = time; + } + + @Override + @EventHandler + public void onClick(InventoryClickEvent e) + { + super.onClick(e); + if (e.isCancelled() && _gui != null && (e.getWhoClicked() instanceof Player)) { + _gui.openInventory(); + } + } + + @Override + public void open() + { + this._id = Bukkit.getScheduler().runTaskLater(getPlugin(), this, _time).getTaskId(); + } + + @Override + public void close() + { + Bukkit.getScheduler().cancelTask(_id); + } + + @Override + public void run() + { + Player player = Bukkit.getPlayer(getPlayersUUID()); + if (player == null) + return; + + if (_gui != null) { + _gui.openInventory(); + } else + player.closeInventory(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java index 7edaa801f..e7b8732c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -230,7 +230,7 @@ public class IgnoreManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadClientInformation(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 2cb728e5c..8c87db300 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -251,7 +251,7 @@ public class InventoryManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadClientInformation(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index b81e7fbb1..34956ecda 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -224,6 +224,11 @@ public class MessageManager extends MiniClientPlugin UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); } + + if(to.getName().equals("ishh")) + { + UtilPlayer.message(from, C.cPurple + "Hi, my name is ishh. If I don't respond to your message, please be patient and try again later!"); + } // Log // Logger().logChat("Private Message", from, to.getName(), message); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 00dcd9fdb..38152a878 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -115,6 +115,12 @@ public class MountManager extends MiniPlugin mount.Disable(player); } + public void DisableAll(Player player) + { + for (Mount mount : _types) + mount.Disable(player); + } + @EventHandler public void quit(PlayerQuitEvent event) { @@ -161,4 +167,6 @@ public class MountManager extends MiniPlugin { return _disguiseManager; } + + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java index bcee6ee2a..e2982d6ab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java @@ -52,7 +52,6 @@ public class MountSheep extends HorseMount DisguiseSheep disguise = new DisguiseSheep(horse); disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); - disguise.setCustomNameVisible(true); //disguise.setColor(DyeColor.getByColor(org.bukkit.Color.fromRGB(100, 0, 200))); Manager.getDisguiseManager().disguise(disguise); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java index 5bf9b6da2..1dccbdad5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java @@ -48,7 +48,6 @@ public class MountSlime extends Mount mount.setSize(2); mount.setCustomName(player.getName() + "'s " + GetName()); - mount.setCustomNameVisible(true); //Inform UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 808d3fe33..a2214adb2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -42,11 +42,11 @@ public class NotificationManager extends MiniPlugin if (!_enabled) return; -// if (event.getType() == UpdateType.MIN_08) -// hugeSale(); + if (event.getType() == UpdateType.MIN_08) + hugeSale(); - if (event.getType() == UpdateType.MIN_16) - sale(); +// if (event.getType() == UpdateType.MIN_16) +// sale(); } private void sale() @@ -95,17 +95,17 @@ public class NotificationManager extends MiniPlugin if (rank == Rank.ALL) { UtilPlayer.message(player, C.cWhite + " " + player.getName() + ", you can get 75% Off " + C.cAqua + C.Bold + "All Lifetime Ranks" + C.cWhite + "!"); - UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!"); + UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } else if (rank == Rank.ULTRA) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for only $7.50!"); - UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!"); + UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } else if (rank == Rank.HERO) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for only $7.50!"); - UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, available " + C.cRed + C.Line + "this weekend only" + C.cWhite + "!"); + UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } UtilPlayer.message(player, " "); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 6b7eb9053..d92a8690e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -161,6 +161,17 @@ public class NpcManager extends MiniPlugin return _npcMap.get(uuid); } + public Npc getNpcByName(String name) + { + for (Npc npc : _npcs) + { + if (npc.getDatabaseRecord().getName() != null && npc.getDatabaseRecord().getName().contains(name)) + return npc; + } + + return null; + } + public Npc getNpcByEntity(Entity entity) { if (entity == null) @@ -484,7 +495,7 @@ public class NpcManager extends MiniPlugin String serverType = getServerName(); try (Connection connection = DBPool.ACCOUNT.getConnection()) - { + { Result result = DSL.using(connection) .selectFrom(Tables.npcs) .where(Tables.npcs.server.eq(serverType)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java index 957816f12..03382bf95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java @@ -12,7 +12,7 @@ public class HomeCommand extends CommandBase { public HomeCommand(NpcManager plugin) { - super(plugin, Rank.DEVELOPER, "home"); + super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "home"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java index 3e3037964..5e66eee21 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java @@ -10,7 +10,7 @@ public class NpcCommand extends MultiCommandBase { public NpcCommand(NpcManager plugin) { - super(plugin, Rank.DEVELOPER, "npc"); + super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "npc"); AddCommand(new AddCommand(plugin)); AddCommand(new DeleteCommand(plugin)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 566c95a04..65d95c26a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; public class HostEventServerCommand extends CommandBase @@ -19,6 +21,11 @@ public class HostEventServerCommand extends CommandBase if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false)) return; + if(Plugin.getClients().Get(caller).isDisguised()) + { + UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + return; + } Plugin.hostServer(caller, caller.getName(), true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index b09c4cc54..8fe9045d6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -4,13 +4,15 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; public class HostServerCommand extends CommandBase { public HostServerCommand(PersonalServerManager plugin) { - super(plugin, Rank.LEGEND, "hostserver"); + super(plugin, Rank.LEGEND, "hostserver", "mps"); } @Override @@ -19,6 +21,11 @@ public class HostServerCommand extends CommandBase if (!Recharge.Instance.use(caller, "Host Server", 30000, false, false)) return; + if(Plugin.getClients().Get(caller).isDisguised()) + { + UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + return; + } Plugin.hostServer(caller, caller.getName(), false); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 22b0f6e19..3896622be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -59,7 +59,6 @@ public class PersonalServerManager extends MiniPlugin { if (_giveInterfaceItem) { - event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem); } } @@ -125,7 +124,7 @@ public class PersonalServerManager extends MiniPlugin Rank rank = _clientManager.Get(player).GetRank(); - if (eventServer || rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE) + if (eventServer || rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH) { ram = 2048; cpu = 4; @@ -157,7 +156,7 @@ public class PersonalServerManager extends MiniPlugin } final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers, - true, false, false, games, "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU); + true, false, false, games, "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU, "", "", "", ""); getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() { @@ -177,4 +176,9 @@ public class PersonalServerManager extends MiniPlugin } }); } + + public CoreClientManager getClients() + { + return _clientManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index bb9d4c7f7..a95bcb150 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -77,7 +77,7 @@ public class PetManager extends MiniClientPlugin _creatureModule = creatureModule; _disguiseManager = disguiseManager; - _repository = new PetRepository(webAddress); + _repository = new PetRepository(plugin, webAddress); _petFactory = new PetFactory(_repository); _blockRestore = restore; _donationManager = donationManager; @@ -205,16 +205,6 @@ public class PetManager extends MiniClientPlugin ((Villager) pet).setBaby(); ((Villager) pet).setAgeLock(true); } - /* - else if (pet instanceof Sheep) - { - DisguiseWither disguise = new DisguiseWither(pet); - disguise.s(350); - - _disguiseManager.disguise(disguise); - UtilEnt.silence(pet, true); - } - */ _activePetOwners.put(player.getName(), pet); _failedAttempts.put(player.getName(), 0); @@ -411,9 +401,15 @@ public class PetManager extends MiniClientPlugin for (Player player : UtilServer.getPlayers()) RemovePet(player, true); } + + public void DisableAll(Player player) + { + RemovePet(player, true); + } public Collection getPets() { return _activePetOwners.values(); } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java index 344f4f165..85973eeb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -3,35 +3,57 @@ package mineplex.core.pet.repository; import java.util.List; import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken; +import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.database.column.ColumnVarChar; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetExtraToken; import mineplex.core.pet.repository.token.PetSalesToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; -public class PetRepository +public class PetRepository extends RepositoryBase { private String _webAddress; - public PetRepository(String webAddress) + public PetRepository(JavaPlugin plugin, String webAddress) { + super(plugin, DBPool.ACCOUNT); + _webAddress = webAddress; } - public List GetPets(List petTokens) - { - return new JsonWebCall(_webAddress + "Pets/GetPets").Execute(new TypeToken>(){}.getType(), petTokens); - } - - public void AddPet(PetChangeToken token) + public void AddPet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/AddPet").Execute(token); + + Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + { + public void run() + { + executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName) + , new ColumnInt("petId", token.PetId) + , new ColumnInt("accountId", token.AccountId)); + } + }); } - public void RemovePet(PetChangeToken token) + public void RemovePet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/RemovePet").Execute(token); + + Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + { + public void run() + { + executeUpdate("DELETE FROM accountPets WHERE petId = ? AND accountId = ?;" + , new ColumnInt("petId", token.PetId) + , new ColumnInt("accountId", token.AccountId)); + } + }); } public List GetPetExtras(List petExtraTokens) @@ -39,18 +61,35 @@ public class PetRepository return new JsonWebCall(_webAddress + "Pets/GetPetExtras").Execute(new TypeToken>(){}.getType(), petExtraTokens); } - public void UpdatePet(PetChangeToken token) + public void UpdatePet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token); + + Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + { + public void run() + { + int rowsChanged = executeUpdate("UPDATE accountPets SET petName = ? WHERE petId = ? AND accountId = ?;", new ColumnVarChar("petName", 32, token.PetName) + , new ColumnInt("petId", token.PetId) + , new ColumnInt("accountId", token.AccountId)); + + if (rowsChanged < 1) + { + executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName) + , new ColumnInt("petId", token.PetId) + , new ColumnInt("accountId", token.AccountId)); + } + } + }); } - public void AddPetNameTag(String name) + @Override + protected void initialize() { - new AsyncJsonWebCall(_webAddress + "Pets/AddPetNameTag").Execute(name); } - public void RemovePetNameTag(String name) + @Override + protected void update() { - new AsyncJsonWebCall(_webAddress + "Pets/RemovePetNameTag").Execute(name); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetChangeToken.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetChangeToken.java index e42a5e61e..4bd7a5236 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetChangeToken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/token/PetChangeToken.java @@ -2,6 +2,8 @@ package mineplex.core.pet.repository.token; public class PetChangeToken { + public int AccountId; + public int PetId; public String Name; public String PetName; public String PetType; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/DisplayType.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java similarity index 91% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/DisplayType.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java index 3045f5277..c593307e9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/DisplayType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import mineplex.core.common.Rank; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PlayerPollData.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java similarity index 97% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PlayerPollData.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java index e0de0ec32..3465fae3b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PlayerPollData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import mineplex.core.common.util.NautHashMap; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java similarity index 95% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java index 1998173ff..715b1f275 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java @@ -1,6 +1,4 @@ -package mineplex.hub.poll; - -import mineplex.core.common.Rank; +package mineplex.core.poll; /** * Created by Shaun on 8/16/2014. diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java similarity index 81% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java index e9a7af389..09f0e4ec3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,10 +11,10 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; + import net.minecraft.server.v1_7_R4.ChatSerializer; import net.minecraft.server.v1_7_R4.PacketPlayOutChat; import net.minecraft.util.com.google.gson.JsonObject; - import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -23,9 +23,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.poll.command.PollCommand; +import mineplex.core.poll.command.PollCommand; public class PollManager extends MiniDbClientPlugin { @@ -64,7 +62,7 @@ public class PollManager extends MiniDbClientPlugin pollData.setPollCooldown(5000); } - @EventHandler + /*@EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) @@ -88,7 +86,7 @@ public class PollManager extends MiniDbClientPlugin pollData.updatePollCooldown(); } } - } + }*/ public Poll getNextPoll(PlayerPollData pollData, Rank playerRank) { @@ -101,6 +99,11 @@ public class PollManager extends MiniDbClientPlugin return null; } + public boolean hasPoll(Player player) + { + return getNextPoll(Get(player), getClientManager().Get(player).GetRank()) != null; + } + public void displayPoll(Player player, Poll poll) { String[] answers = poll.getAnswers(); @@ -146,6 +149,7 @@ public class PollManager extends MiniDbClientPlugin { final String name = player.getName(); final UUID uuid = player.getUniqueId(); + final int accountId = getClientManager().getAccountId(player); // First update answer locally so we know it was answered Get(player).addAnswer(poll.getId(), answer); @@ -166,17 +170,28 @@ public class PollManager extends MiniDbClientPlugin { if (completed) { - // Need to get out of Async code - _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() + _donationManager.RewardCoins(new Callback() { @Override - public void run() + public void run(Boolean completed) { - UtilPlayer.message(player, F.main("Poll", "Thanks for your response!")); - player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0); - UtilPlayer.message(player, F.main("Gem", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!")); + if (completed) + { + // Need to get out of Async code + _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() + { + @Override + public void run() + { + UtilPlayer.message(player, F.main("Carl", "Thanks for your response!")); + player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0); + UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!")); + UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Coins!")); + } + }); + } } - }); + }, "Poll", name, accountId, poll.getCoinReward()); } } }, "Poll", name, uuid, poll.getCoinReward()); @@ -212,7 +227,7 @@ public class PollManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadPollData(resultSet)); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java similarity index 99% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollRepository.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java index e38e980ec..53884c66f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollStats.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java similarity index 97% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollStats.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java index 591302c01..5f3ecdb2a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll; +package mineplex.core.poll; /** * Created by Shaun on 8/26/2014. diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/command/PollCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java similarity index 96% rename from Plugins/Mineplex.Hub/src/mineplex/hub/poll/command/PollCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java index fe5997c79..bafdb1dbe 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/poll/command/PollCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java @@ -1,4 +1,4 @@ -package mineplex.hub.poll.command; +package mineplex.core.poll.command; import java.text.DecimalFormat; import java.util.List; @@ -13,10 +13,10 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.hub.poll.PlayerPollData; -import mineplex.hub.poll.Poll; -import mineplex.hub.poll.PollManager; -import mineplex.hub.poll.PollStats; +import mineplex.core.poll.PlayerPollData; +import mineplex.core.poll.Poll; +import mineplex.core.poll.PollManager; +import mineplex.core.poll.PollStats; /** * Created by Shaun on 8/17/2014. diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java index 3e447d5ae..e35d2f15e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java @@ -14,7 +14,7 @@ public class SendCommand extends CommandBase { public SendCommand(Portal plugin) { - super(plugin, Rank.ADMIN, "send"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "send"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index b24e700ba..c69ab7bed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -4,6 +4,19 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map.Entry; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.preferences.command.PreferencesCommand; +import mineplex.core.preferences.ui.PreferencesShop; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -11,18 +24,10 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.preferences.command.PreferencesCommand; -import mineplex.core.preferences.ui.PreferencesShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - public class PreferencesManager extends MiniDbClientPlugin { private PreferencesRepository _repository; @@ -53,6 +58,27 @@ public class PreferencesManager extends MiniDbClientPlugin _saveBuffer.put(caller.getUniqueId().toString(), Get(caller)); } + @EventHandler + public void givePlayerItem(PlayerJoinEvent event) + { + if (!GiveItem) + return; + + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM)) + { + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "My Profile"); + SkullMeta meta = ((SkullMeta) item.getItemMeta()); + meta.setOwner(player.getName()); + item.setItemMeta(meta); + + player.getInventory().setItem(8, item); + + UtilInv.Update(player); + } + } + @EventHandler public void storeBuffer(UpdateEvent event) { @@ -76,15 +102,6 @@ public class PreferencesManager extends MiniDbClientPlugin } }); } - - @EventHandler - public void givePlayerItem(PlayerJoinEvent event) - { - if (!GiveItem) - return; - - event.getPlayer().getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, ChatColor.GREEN + "/prefs")); - } @EventHandler(priority = EventPriority.LOWEST) public void playerInteract(PlayerInteractEvent event) @@ -106,7 +123,7 @@ public class PreferencesManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadClientInformation(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java index d09e9c3db..31e1bb563 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java @@ -255,13 +255,13 @@ public class PreferencesPage extends ShopPageBase canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + null, 1f, 1f, null, 0, null, null, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, boolean pickup, float hitboxGrow, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, pickup, + null, 1f, 1f, null, 0, null, null, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, Effect effect, int effectData, UpdateType effectRate , float hitboxGrow, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, effect, effectData, effectRate, null, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, Effect effect, int effectData, UpdateType effectRate, float hitboxGrow, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, effect, effectData, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxGrow, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); + } + + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult, List canHit) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, pX, pY, pZ, pS, pC, hitboxMult, canHit)); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index a19cf5caa..3d71c0831 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -1,16 +1,15 @@ package mineplex.core.projectile; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; +import java.util.List; + import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguiseSquid; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_7_R4.AxisAlignedBB; import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_7_R4.MovingObjectPosition; @@ -25,7 +24,6 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -46,19 +44,64 @@ public class ProjectileUser private Sound _sound = null; private float _soundVolume = 1f; private float _soundPitch = 1f; + private ParticleType _particle = null; + private float _particleX = 0F; + private float _particleY = 0F; + private float _particleZ = 0F; + private float _particleS = 0F; + private int _particleC = 1; + private Effect _effect = null; private int _effectData = 0; private UpdateType _effectRate = UpdateType.TICK; private double _hitboxGrow; + + private List _canHit; + + public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, boolean pickup, + Sound sound, float soundVolume, float soundPitch, + Effect effect, int effectData, UpdateType effectRate, + ParticleType particle, float particleX, float particleY, + float particleZ, float particleS, int particleC, double hitboxMult) + { + Throw = throwInput; + + _thrown = thrown; + _thrower = thrower; + _callback = callback; + + _expireTime = expireTime; + _hitPlayer = hitPlayer; + _hitBlock = hitBlock; + _idle = idle; + _pickup = pickup; + + _sound = sound; + _soundVolume = soundVolume; + _soundPitch = soundPitch; + _particle = particle; + _particleX = particleX; + _particleY = particleY; + _particleZ = particleZ; + _particleS = particleS; + _particleC = particleC; + _effect = effect; + _effectData = effectData; + _effectRate = effectRate; + + _hitboxGrow = hitboxMult; + _canHit = null; + } public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitBlock, boolean idle, boolean pickup, Sound sound, float soundVolume, float soundPitch, Effect effect, int effectData, UpdateType effectRate, - ParticleType particle, - double hitboxMult) + ParticleType particle, float particleX, float particleY, + float particleZ, float particleS, int particleC, double hitboxMult, List canHit) { Throw = throwInput; @@ -76,11 +119,17 @@ public class ProjectileUser _soundVolume = soundVolume; _soundPitch = soundPitch; _particle = particle; + _particleX = particleX; + _particleY = particleY; + _particleZ = particleZ; + _particleS = particleS; + _particleC = particleC; _effect = effect; _effectData = effectData; _effectRate = effectRate; _hitboxGrow = hitboxMult; + _canHit = canHit; } public void Effect(UpdateEvent event) @@ -95,7 +144,7 @@ public class ProjectileUser _thrown.getWorld().playEffect(_thrown.getLocation(), _effect, _effectData); if (_particle != null) - UtilParticle.PlayParticle(_particle, _thrown.getLocation(), 0f, 0f, 0f, 0, 1, + UtilParticle.PlayParticle(_particle, _thrown.getLocation(), _particleX, _particleY, _particleZ, _particleS, _particleC, ViewDist.LONG, UtilServer.getPlayers()); } @@ -144,11 +193,22 @@ public class ProjectileUser if (ent.equals(_thrower)) continue; - //Creative or Spec + //Creative or Spec or No Hit if (ent instanceof Player) - if (((Player)ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + { + if (((Player)ent).getGameMode() == GameMode.CREATIVE) continue; + if (UtilPlayer.isSpectator(ent)) + continue; + + if (_canHit != null) + { + if (!_canHit.contains(((Player)ent))) + continue; + } + } + //float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); AxisAlignedBB axisalignedbb1 = ((CraftEntity)ent).getHandle().boundingBox.grow(1F, 1F, 1F); MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java index 528b66253..b2a8768aa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java @@ -7,6 +7,19 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventoryCustom; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.ItemStack; + import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -23,18 +36,6 @@ import mineplex.core.punish.PunishmentSorter; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventoryCustom; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.inventory.ItemStack; - public class PunishPage extends CraftInventoryCustom implements Listener { private Punish _plugin; @@ -232,14 +233,12 @@ public class PunishPage extends CraftInventoryCustom implements Listener examplePrefixEx + " Forcefield", examplePrefixEx + " Speed Hack", examplePrefixEx + " Reach Hack", - examplePrefixEx + " Speed Hack", examplePrefixEx + " Other Hack", " ", examplePrefix + "Hack Reports (SR & FR);", examplePrefixEx + " Forcefield", examplePrefixEx + " Speed Hack", examplePrefixEx + " Reach Hack", - examplePrefixEx + " Speed Hack", examplePrefixEx + " Other Hack", examplePrefixEx + " Fly Hack", } @@ -294,6 +293,20 @@ public class PunishPage extends CraftInventoryCustom implements Listener }, 1, false, true), new PunishButton(this, Category.ChatOffense, 4, false, -1)); } + if (_plugin.GetClients().Get(_player).GetRank() == Rank.DEVELOPER || _plugin.GetClients().Get(_player).GetRank() == Rank.JNR_DEV) + { + ShopItem devWarning = new ShopItem(Material.YELLOW_FLOWER, "DEV WARNING", new String[] {ChatColor.RESET + "Developers are advised against using the punish system", ChatColor.RESET + "unless permitted by LT"}, 1, true, true); + devWarning.addGlow(); + + AddButton(0, devWarning, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + } + }); + } + Collections.sort(punishments, new PunishmentSorter()); int slot = 45; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java b/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java index 100b63432..c5f4633de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java @@ -1,6 +1,7 @@ package mineplex.core.recharge; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import org.bukkit.entity.Player; @@ -218,6 +219,26 @@ public class Recharge extends MiniPlugin { _recharge.put(player.getName(), new NautHashMap()); } + + public void Reset(Player player, String stringContains) + { + NautHashMap data = _recharge.get(player.getName()); + + if (data == null) + return; + + Iterator rechargeIter = data.keySet().iterator(); + + while (rechargeIter.hasNext()) + { + String key = rechargeIter.next(); + + if (key.toLowerCase().contains(stringContains.toLowerCase())) + { + rechargeIter.remove(); + } + } + } public void debug(Player player, String ability) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java index 67659dc64..3bd5e8202 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java @@ -27,6 +27,8 @@ public abstract class Reward protected abstract RewardData giveRewardCustom(Player player); + public abstract RewardData getFakeRewardData(Player player); + public abstract boolean canGiveReward(Player player); public RewardRarity getRarity() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java index 77f8b91e3..0a20e5ccf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java @@ -9,11 +9,13 @@ public class RewardData { private final String _friendlyName; private final ItemStack _displayItem; + private final RewardRarity _rarity; - public RewardData(String friendlyName, ItemStack displayItem) + public RewardData(String friendlyName, ItemStack displayItem, RewardRarity rarity) { _friendlyName = friendlyName; _displayItem = displayItem; + _rarity = rarity; } public String getFriendlyName() @@ -26,4 +28,9 @@ public class RewardData return _displayItem; } + public RewardRarity getRarity() + { + return _rarity; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 775ab3cd5..8932c3658 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -18,27 +18,32 @@ import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; import mineplex.core.reward.rewards.CoinReward; +import mineplex.core.reward.rewards.ExperienceReward; +import mineplex.core.reward.rewards.GemReward; import mineplex.core.reward.rewards.InventoryReward; import mineplex.core.reward.rewards.PetReward; import mineplex.core.reward.rewards.RankReward; import mineplex.core.reward.rewards.UnknownPackageReward; +import mineplex.core.stats.StatsManager; +import mineplex.core.timing.TimingManager; public class RewardManager { private JavaPlugin _plugin; private HashMap> _treasureMap; private Random _random; - + private boolean _carlSpinner; + private CoreClientManager _clientManager; - + private boolean _doubleGadgetValue; - - public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, - int commonValueMin, int commonValueMax, - int uncommonValueMin, int uncommonValueMax, - int rareValueMin, int rareValueMax, - int legendValueMin, int legendValueMax, - boolean doubleGadgetValue) + + public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, + int commonValueMin, int commonValueMax, + int uncommonValueMin, int uncommonValueMax, + int rareValueMin, int rareValueMax, + int legendValueMin, int legendValueMax, + boolean doubleGadgetValue, boolean carlSpinner) { _plugin = donationManager.getPlugin(); _treasureMap = new HashMap>(); @@ -48,23 +53,33 @@ public class RewardManager { _treasureMap.put(rarity, new ArrayList()); } - - _clientManager = clientManager; - - _doubleGadgetValue = doubleGadgetValue; - addCommon(donationManager, inventoryManager, petManager, commonValueMin, commonValueMax); - addUncommon(donationManager, inventoryManager, petManager, uncommonValueMin, uncommonValueMax); - addRare(donationManager, inventoryManager, petManager, rareValueMin, rareValueMax); - addLegendary(donationManager, inventoryManager, petManager, legendValueMin, legendValueMax); + _clientManager = clientManager; + + _doubleGadgetValue = doubleGadgetValue; + _carlSpinner = carlSpinner; + + addCommon(donationManager, inventoryManager, petManager, statsManager, commonValueMin, commonValueMax); + addUncommon(donationManager, inventoryManager, petManager, statsManager, uncommonValueMin, uncommonValueMax); + addRare(donationManager, inventoryManager, petManager, statsManager, rareValueMin, rareValueMax); + addLegendary(donationManager, inventoryManager, petManager, statsManager, legendValueMin, legendValueMax); } - public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.COMMON; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1, rarity)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 25, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 5, rarity)); + } //Increase Value if (_doubleGadgetValue) @@ -72,43 +87,54 @@ public class RewardManager minValue *= 2; maxValue *= 2; } - + // Gadgets addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun", (int)(100*(minValue/500)), (int)(100*(maxValue/500)), new ItemStack(Material.GOLD_BARDING), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.FIREWORK), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.MELON_BLOCK), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook", (int)(40*(minValue/500)), (int)(40*(maxValue/500)), new ItemStack(Material.getMaterial(131)), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl", (int)(30*(minValue/500)), (int)(30*(maxValue/500)), new ItemStack(Material.ENDER_PEARL), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.IRON_BARDING), rarity, 10)); - + addReward(new InventoryReward(inventoryManager, "TNT", "TNT", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.TNT), rarity, 10)); + + } - public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.UNCOMMON; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 1200, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1200, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 1200, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON)); + } //Increase Value if (_doubleGadgetValue) @@ -116,32 +142,32 @@ public class RewardManager minValue *= 2; maxValue *= 2; } - + // Gadgets addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun", (int)(100*(minValue/500)), (int)(100*(maxValue/500)), new ItemStack(Material.GOLD_BARDING), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.FIREWORK), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher", (int)(50*(minValue/500)), (int)(50*(maxValue/500)), new ItemStack(Material.MELON_BLOCK), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook", (int)(40*(minValue/500)), (int)(40*(maxValue/500)), new ItemStack(Material.getMaterial(131)), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl", (int)(30*(minValue/500)), (int)(30*(maxValue/500)), new ItemStack(Material.ENDER_PEARL), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.IRON_BARDING), rarity, 250)); - + addReward(new InventoryReward(inventoryManager, "TNT", "TNT", (int)(20*(minValue/500)), (int)(20*(maxValue/500)), new ItemStack(Material.TNT), rarity, 250)); @@ -189,12 +215,22 @@ public class RewardManager new ItemStack(2267), rarity, 25)); } - public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.RARE; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 150, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 150, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 150, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE)); + } + // Mounts addReward(new UnknownPackageReward(donationManager, "Mount Mule", "Mount Mule", @@ -215,7 +251,7 @@ public class RewardManager new ItemStack(Material.FEATHER), rarity, 50)); addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph", new ItemStack(Material.ENDER_PEARL), rarity, 33)); - + // Gadgets addReward(new InventoryReward(inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1, @@ -238,15 +274,23 @@ public class RewardManager new ItemStack(Material.GOLD_LEGGINGS), rarity, 50)); addReward(new UnknownPackageReward(donationManager, "Space Boots", "Space Boots", new ItemStack(Material.GOLD_BOOTS), rarity, 50)); - } - public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue) + public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue) { RewardRarity rarity = RewardRarity.LEGENDARY; // Coins - addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY)); + if (_carlSpinner) + { + addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 10, rarity)); + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 10, rarity)); + addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 10, rarity)); + } + else + { + addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); + } // Mounts addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror", @@ -269,12 +313,14 @@ public class RewardManager new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), rarity, 13)); addReward(new UnknownPackageReward(donationManager, "Blood Helix Particles", "Blood Helix", new ItemStack(Material.REDSTONE), rarity, 10)); - addReward(new UnknownPackageReward(donationManager, "Emerald Twirl Particles", "Green Ring", + addReward(new UnknownPackageReward(donationManager, "Green Rings Particles", "Green Ring", new ItemStack(Material.EMERALD), rarity, 8)); addReward(new UnknownPackageReward(donationManager, "Flame Fairy Particles", "Flame Fairy", new ItemStack(Material.APPLE), rarity, 4)); addReward(new UnknownPackageReward(donationManager, "Heart Particles", "I Heart You", new ItemStack(Material.BLAZE_POWDER), rarity, 2)); + + } public void addReward(Reward reward) @@ -306,13 +352,13 @@ public class RewardManager { hasUncommon = true; } - + //Only allow 1 Mythical if (reward.getRarity().ordinal() >= RewardRarity.MYTHICAL.ordinal()) { canGiveMythical = false; } - + rewards[currentReward] = reward; currentReward++; } @@ -339,7 +385,7 @@ public class RewardManager public Reward nextReward(Player player, Reward[] excludedRewards, boolean requiresUncommon, RewardType type, boolean canGiveMythical) { RewardRarity rarity = type.generateRarity(requiresUncommon); - + //Dont give Rank Upgrade if already has Legend if (rarity == RewardRarity.MYTHICAL) { @@ -352,7 +398,7 @@ public class RewardManager return new RankReward(_clientManager, 0, rarity); } } - + List treasureList = _treasureMap.get(rarity); int totalWeight = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java index fc186ed03..1f56de46a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java @@ -1,5 +1,9 @@ package mineplex.core.reward; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + import mineplex.core.common.util.C; import static mineplex.core.common.util.C.*; @@ -14,20 +18,31 @@ public enum RewardRarity * (Fireworks, sounds, etc) */ - OTHER("Other", cWhite), - COMMON("Common", cWhite), - UNCOMMON("Uncommon", cAqua), - RARE("Rare", cPurple), - LEGENDARY("Legendary", cGreen), - MYTHICAL("Mythical", cRed); + OTHER("Other", cWhite, Material.STAINED_GLASS_PANE, (byte) 0), + COMMON("Common", cWhite, Material.STAINED_GLASS_PANE, (byte) 0), + GAME("Game", cYellow, Material.STAINED_GLASS_PANE, (byte) 4), + UNCOMMON("Uncommon", cAqua, Material.STAINED_GLASS_PANE, (byte) 3), + RARE("Rare", cPurple, Material.STAINED_GLASS_PANE, (byte) 10), + LEGENDARY("Legendary", cGreen, Material.STAINED_GLASS_PANE, (byte) 5), + MYTHICAL("Mythical", cRed, Material.STAINED_GLASS_PANE, (byte) 14); private String _name; private String _color; + private Material _material; + private byte _data; + private ItemStack _stack; - RewardRarity(String name, String color) + RewardRarity(String name, String color, Material material, byte data) { _name = name; _color = color; + _material = material; + _data = data; + + _stack = new ItemStack(getMaterial(), 1, (short) 0, getData()); + ItemMeta meta = _stack.getItemMeta(); + meta.setDisplayName(_color + _name); + _stack.setItemMeta(meta); } public String getColor() @@ -40,4 +55,19 @@ public enum RewardRarity return _name; } + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public ItemStack getItemStack() + { + return _stack; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index c6c5caef8..15fa1f9aa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -6,15 +6,19 @@ public enum RewardType { //% Chances Mythic Legend Rare Uncommon GameLoot( 0.000001, 0.00001, 0.0001, 3), + OldChest( 0, 0.05, 0.4, 5), AncientChest( 0, 1, 4, 25), - MythicalChest( 0.5, 3, 12, 75); + MythicalChest( 0.4, 3, 12, 75), + SpinnerFiller( 0.1, 1, 4, 20), + SpinnerReal( 0.000001, 0.05, 0.4, 5); + private double _mythicalChance; private double _legendaryChance; private double _rareChance; private double _uncommonChance; - + RewardType(double mythical, double legend, double rare, double uncommon) { _mythicalChance = (mythical / 100d); @@ -26,9 +30,9 @@ public enum RewardType public RewardRarity generateRarity(boolean requiresUncommon) { double rand = Math.random(); - + RewardRarity rarity = RewardRarity.COMMON; - + if (rand <= _mythicalChance) rarity = RewardRarity.MYTHICAL; else if (rand <= _legendaryChance) rarity = RewardRarity.LEGENDARY; else if (rand <= _rareChance) rarity = RewardRarity.RARE; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java index a0023e137..1bf59afb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/CoinReward.java @@ -37,7 +37,7 @@ public class CoinReward extends Reward @Override public RewardData giveRewardCustom(Player player) { - int gemsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount; + int coinsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount; _donationManager.RewardCoins(new Callback() { @@ -46,9 +46,15 @@ public class CoinReward extends Reward { } - }, "Treasure Chest", player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), gemsToReward); + }, "Treasure Chest", player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), coinsToReward); - return new RewardData(getRarity().getColor() + gemsToReward + " Coins", new ItemStack(175)); + return new RewardData(getRarity().getColor() + coinsToReward + " Coins", new ItemStack(175), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + "Coins", new ItemStack(175), getRarity()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ExperienceReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ExperienceReward.java new file mode 100644 index 000000000..ad1ad3b5b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ExperienceReward.java @@ -0,0 +1,52 @@ +package mineplex.core.reward.rewards; + +import java.util.Random; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.stats.StatsManager; + +public class ExperienceReward extends Reward +{ + private StatsManager _statsManager; + private Random _random; + private int _minExperience; + private int _maxExperience; + + public ExperienceReward(StatsManager statsManager, int minExperience, int maxExperience, int weight, RewardRarity rarity) + { + super(rarity, weight); + + _statsManager = statsManager; + _random = new Random(); + _minExperience = minExperience; + _maxExperience = maxExperience; + } + + @Override + protected RewardData giveRewardCustom(Player player) + { + int experience = _random.nextInt(_maxExperience - _minExperience) + _minExperience; + + _statsManager.incrementStat(player, "Global.ExpEarned", experience); + + return new RewardData(getRarity().getColor() + experience + " Experience", new ItemStack(Material.EXP_BOTTLE), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + "Experience", new ItemStack(Material.EXP_BOTTLE), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GemReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GemReward.java new file mode 100644 index 000000000..26e695abb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GemReward.java @@ -0,0 +1,75 @@ +package mineplex.core.reward.rewards; + +import java.util.Random; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.Callback; +import mineplex.core.donation.DonationManager; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardManager; +import mineplex.core.reward.RewardRarity; + +public class GemReward extends Reward +{ + private DonationManager _donationManager; + private Random _random; + private int _minGemCount; + private int _maxGemCount; + + public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity) + { + this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM); + } + + public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity, Random random) + { + super(rarity, weight); + _donationManager = donationManager; + _minGemCount = minGemCount; + _maxGemCount = maxGemCount; + + _random = random; + } + + @Override + public RewardData giveRewardCustom(Player player) + { + int GemsToReward = _random.nextInt(_maxGemCount - _minGemCount) + _minGemCount; + + _donationManager.RewardGems(new Callback() + { + @Override + public void run(Boolean data) + { + + } + }, "Treasure Chest", player.getName(), player.getUniqueId(), GemsToReward); + + return new RewardData(getRarity().getColor() + GemsToReward + " Gems", new ItemStack(Material.EMERALD), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + "Gems", new ItemStack(Material.EMERALD), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof GemReward) + return true; + + return false; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java index 83c219e1c..0eb1504e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java @@ -59,7 +59,13 @@ public class InventoryReward extends Reward _inventoryManager.addItemToInventory(player, "Item", _packageName, amountToGive); - return new RewardData(getRarity().getColor() + amountToGive + " " + _name, _itemStack); + return new RewardData(getRarity().getColor() + amountToGive + " " + _name, _itemStack, getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java index 815edb705..6c3ce1a6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -33,12 +33,26 @@ public class RankReward extends Reward else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; if (rank == null) - return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER)); + return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity()); _clientManager.Get(player).SetRank(rank); _clientManager.getRepository().saveRank(null, player.getName(), player.getUniqueId(), rank, true); - return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR)); + return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + Rank rank = null; + if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA; + else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO; + else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; + + if (rank == null) + return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity()); + + return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index 892810098..5f2dcd442 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -34,7 +34,7 @@ public class UnknownPackageReward extends Reward { _donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, CurrencyType.Coins, 0, true); - return new RewardData(getRarity().getColor() + _name, _itemStack); + return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity()); } @Override @@ -49,6 +49,12 @@ public class UnknownPackageReward extends Reward return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName); } + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity()); + } + protected String getPackageName() { return _packageName; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index 08037eae5..0452a13cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -66,7 +66,6 @@ public abstract class ShopBase implements Listene return _availableCurrencyTypes; } - @EventHandler(priority = EventPriority.LOWEST) public void onPlayerDamageEntity(NpcDamageByEntityEvent event) { @@ -88,35 +87,14 @@ public abstract class ShopBase implements Listene private boolean attemptShopOpen(Player player, LivingEntity entity) { - if (!_openedShop.contains(player.getName()) && entity.isCustomNameVisible() && entity.getCustomName() != null && ChatColor.stripColor(entity.getCustomName()).equalsIgnoreCase(ChatColor.stripColor(_name))) - { - if (!canOpenShop(player)) - return false; - - _openedShop.add(player.getName()); - - openShopForPlayer(player); - if (!_playerPageMap.containsKey(player.getName())) - { - - _playerPageMap.put(player.getName(), buildPagesFor(player)); - System.out.println("Put " + player.getName()); - } - - openPageForPlayer(player, getOpeningPageForPlayer(player)); - - return true; - } + if (entity.isCustomNameVisible() && entity.getCustomName() != null && ChatColor.stripColor(entity.getCustomName()).equalsIgnoreCase(ChatColor.stripColor(_name))) + { + return attemptShopOpen(player); + } return false; } - public void removePlayerPages(String playerName) - { - System.out.println("REMOVING " + playerName); - _playerPageMap.remove(playerName); - } - public boolean attemptShopOpen(Player player) { if (!_openedShop.contains(player.getName())) @@ -151,6 +129,7 @@ public abstract class ShopBase implements Listene if (_playerPageMap.containsKey(event.getWhoClicked().getName()) && _playerPageMap.get(event.getWhoClicked().getName()).getName().equalsIgnoreCase(event.getInventory().getName())) { _playerPageMap.get(event.getWhoClicked().getName()).playerClicked(event); + event.setCancelled(true); } } @@ -162,7 +141,7 @@ public abstract class ShopBase implements Listene _playerPageMap.get(event.getPlayer().getName()).playerClosed(); _playerPageMap.get(event.getPlayer().getName()).dispose(); - removePlayerPages(event.getPlayer().getName()); + _playerPageMap.remove(event.getPlayer().getName()); closeShopForPlayer((Player) event.getPlayer()); @@ -170,16 +149,18 @@ public abstract class ShopBase implements Listene } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR) public void onInventoryOpen(InventoryOpenEvent event) { - if (true) return; + if (!event.isCancelled()) + return; + if (_playerPageMap.containsKey(event.getPlayer().getName()) && _playerPageMap.get(event.getPlayer().getName()).getTitle() != null && _playerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle())) { _playerPageMap.get(event.getPlayer().getName()).playerClosed(); _playerPageMap.get(event.getPlayer().getName()).dispose(); - removePlayerPages(event.getPlayer().getName()); + _playerPageMap.remove(event.getPlayer().getName()); closeShopForPlayer((Player) event.getPlayer()); @@ -207,7 +188,7 @@ public abstract class ShopBase implements Listene event.getPlayer().closeInventory(); closeShopForPlayer(event.getPlayer()); - removePlayerPages(event.getPlayer().getName()); + _playerPageMap.remove(event.getPlayer().getName()); _openedShop.remove(event.getPlayer().getName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java index 02b67752a..b5caa1745 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java @@ -6,13 +6,13 @@ import mineplex.core.common.util.NautHashMap; public class PlayerStats { - private NautHashMap _statHash = new NautHashMap(); + private NautHashMap _statHash = new NautHashMap(); - public int addStat(String statName, int value) + public long addStat(String statName, long value) { if (!_statHash.containsKey(statName)) { - _statHash.put(statName, 0); + _statHash.put(statName, 0L); } _statHash.put(statName, _statHash.get(statName) + value); @@ -20,9 +20,9 @@ public class PlayerStats return _statHash.get(statName); } - public int getStat(String statName) + public long getStat(String statName) { - return _statHash.containsKey(statName) ? _statHash.get(statName) : 0; + return _statHash.containsKey(statName) ? _statHash.get(statName) : 0L; } public Set getStatsNames() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java new file mode 100644 index 000000000..eb13e4940 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java @@ -0,0 +1,184 @@ +package mineplex.core.stats; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.jooq.Configuration; +import org.jooq.DSLContext; +import org.jooq.Delete; +import org.jooq.Insert; +import org.jooq.SQLDialect; +import org.jooq.TransactionalRunnable; +import org.jooq.Update; +import org.jooq.impl.DSL; + +import mineplex.core.account.ILoginProcessor; +import mineplex.core.database.DBPool; +import mineplex.database.Tables; +import org.jooq.types.ULong; + +public class SecondaryStatHandler implements ILoginProcessor +{ + private StatsManager _statsManager; + private StatsRepository _repository; + + public SecondaryStatHandler(StatsManager statsManager, StatsRepository repository) + { + _statsManager = statsManager; + _repository = repository; + } + + @Override + public String getName() + { + return "Secondary Stat Handler"; + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + PlayerStats oldPlayerStats = _statsManager.Get(playerName); + PlayerStats newPlayerStats = _repository.loadClientInformation(resultSet); + + if (newPlayerStats.getStatsNames().size() == 0 && oldPlayerStats.getStatsNames().size() != 0) + { + try + { + DSLContext context = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + + final List inserts = new ArrayList<>(); + + for (String statName : oldPlayerStats.getStatsNames()) + { + Integer statId = _statsManager.getStatId(statName); + + Insert insert = context + .insertInto(Tables.accountStat) + .set(Tables.accountStat.accountId, accountId) + .set(Tables.accountStat.statId, statId) + .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))); + + inserts.add(insert); + } + + context.transaction(new TransactionalRunnable() + { + @Override + public void run(Configuration config) throws Exception + { + DSL.using(config).batch(inserts).execute(); + } + }); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + else + { + _statsManager.replacePlayerHack(playerName, newPlayerStats); + + if (oldPlayerStats.getStatsNames().size() != 0) + { + try + { + final DSLContext context = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + final List updates = new ArrayList<>(); + final List inserts = new ArrayList<>(); + boolean foundNegativeStat = false; + boolean foundLessThanStat = false; + + for (String statName : oldPlayerStats.getStatsNames()) + { + Integer statId = _statsManager.getStatId(statName); + + Insert insert = context + .insertInto(Tables.accountStat) + .set(Tables.accountStat.accountId, accountId) + .set(Tables.accountStat.statId, statId) + .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))); + + inserts.add(insert); + + Update update = context + .update(Tables.accountStat) + .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))) + .where(Tables.accountStat.accountId.eq(accountId)) + .and(Tables.accountStat.statId.eq(statId)); + + updates.add(update); + + if (oldPlayerStats.getStat(statName) < 0) + { + foundNegativeStat = true; + } + else if (newPlayerStats.getStat(statName) < oldPlayerStats.getStat(statName)) + { + foundLessThanStat = true; + } + } + + if (foundNegativeStat && foundLessThanStat) + { + context.transaction(new TransactionalRunnable() + { + @Override + public void run(Configuration config) throws Exception + { + int[] updateResult = context.batch(updates).execute(); + + for (int i = 0; i < updateResult.length; i++) + { + if (updateResult[i] > 0) + inserts.set(i, null); + } + + inserts.removeAll(Collections.singleton(null)); + + context.batch(inserts).execute(); + + System.out.println("Updating"); + } + }); + } + +/* + final List deletes = new ArrayList<>(); + + for (String statName : oldPlayerStats.getStatsNames()) + { + Delete delete = context.delete(Tables.accountStats) + .where(Tables.accountStats.accountId.equal(accountId)); + + deletes.add(delete); + } + + context.transaction(new TransactionalRunnable() + { + @Override + public void run(Configuration config) throws Exception + { + DSL.using(config).batch(deletes).execute(); + } + }); + */ + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT stats.name, value FROM accountStat INNER JOIN stats ON stats.id = accountStat.statId WHERE accountStat.accountId = '" + accountId + "';"; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 8ab29b11d..ef9fbad63 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -1,16 +1,23 @@ package mineplex.core.stats; +import java.lang.reflect.Field; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.util.com.mojang.authlib.GameProfile; + import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; @@ -24,7 +31,7 @@ public class StatsManager extends MiniDbClientPlugin private StatsRepository _repository; private NautHashMap _stats = new NautHashMap(); - private NautHashMap> _statUploadQueue = new NautHashMap>(); + private NautHashMap> _statUploadQueue = new NautHashMap>(); private Runnable _saveRunnable; public StatsManager(JavaPlugin plugin, CoreClientManager clientManager) @@ -50,11 +57,16 @@ public class StatsManager extends MiniDbClientPlugin { _stats.put(stat.Name, stat.Id); } + + clientManager.addStoredProcedureLoginProcessor(new SecondaryStatHandler(this, _repository)); } - public void incrementStat(final Player player, final String statName, final int value) + public void incrementStat(final Player player, final String statName, final long value) { - int newValue = Get(player).addStat(statName, value); + if (value <= 0) + return; + + long newValue = Get(player).addStat(statName, value); //Event UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue)); @@ -97,15 +109,15 @@ public class StatsManager extends MiniDbClientPlugin } } - private void addToQueue(String statName, Player player, int value) + private void addToQueue(String statName, Player player, long value) { synchronized (_statSync) { if (!_statUploadQueue.containsKey(player)) - _statUploadQueue.put(player, new NautHashMap()); + _statUploadQueue.put(player, new NautHashMap()); if (!_statUploadQueue.get(player).containsKey(statName)) - _statUploadQueue.get(player).put(statName, 0); + _statUploadQueue.get(player).put(statName, 0L); _statUploadQueue.get(player).put(statName, _statUploadQueue.get(player).get(statName) + value); } @@ -118,7 +130,7 @@ public class StatsManager extends MiniDbClientPlugin try { - NautHashMap> uploadQueue = new NautHashMap>(); + NautHashMap> uploadQueue = new NautHashMap>(); synchronized (_statSync) { @@ -131,7 +143,7 @@ public class StatsManager extends MiniDbClientPlugin int uploadKey = ClientManager.getCachedClientAccountId(player.getUniqueId()); - uploadQueue.put(uploadKey, new NautHashMap()); + uploadQueue.put(uploadKey, new NautHashMap()); for (String statName : _statUploadQueue.get(player).keySet()) { @@ -152,13 +164,13 @@ public class StatsManager extends MiniDbClientPlugin } } - public boolean incrementStat(final int accountId, final String statName, final int value) + public boolean incrementStat(final int accountId, final String statName, final long value) { if (_stats.containsKey(statName)) return false; - final NautHashMap> uploadQueue = new NautHashMap>(); - uploadQueue.put(accountId, new NautHashMap()); + final NautHashMap> uploadQueue = new NautHashMap>(); + uploadQueue.put(accountId, new NautHashMap()); uploadQueue.get(accountId).put(_stats.get(statName), value); runAsync(new Runnable() @@ -172,6 +184,16 @@ public class StatsManager extends MiniDbClientPlugin return true; } + public int getStatId(String statName) + { + return _stats.get(statName); + } + + public void replacePlayerHack(String playerName, PlayerStats playerStats) + { + Set(playerName, playerStats); + } + @Override protected PlayerStats AddPlayer(String player) { @@ -191,7 +213,7 @@ public class StatsManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadClientInformation(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 23d3daa9d..e1524436d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -22,6 +22,7 @@ import org.jooq.Result; import org.jooq.SQLDialect; import org.jooq.Update; import org.jooq.impl.DSL; +import org.jooq.types.ULong; public class StatsRepository extends RepositoryBase { @@ -77,7 +78,7 @@ public class StatsRepository extends RepositoryBase } @SuppressWarnings("rawtypes") - public void saveStats(NautHashMap> uploadQueue) + public void saveStats(NautHashMap> uploadQueue) { try { @@ -91,18 +92,18 @@ public class StatsRepository extends RepositoryBase for (Integer statId : uploadQueue.get(accountId).keySet()) { Update update = context - .update(Tables.accountStats) - .set(Tables.accountStats.value, Tables.accountStats.value.plus(uploadQueue.get(accountId).get(statId))) - .where(Tables.accountStats.accountId.eq(accountId)) - .and(Tables.accountStats.statId.eq(statId)); + .update(Tables.accountStat) + .set(Tables.accountStat.value, Tables.accountStat.value.plus(uploadQueue.get(accountId).get(statId))) + .where(Tables.accountStat.accountId.eq(accountId)) + .and(Tables.accountStat.statId.eq(statId)); updates.add(update); Insert insert = context - .insertInto(Tables.accountStats) - .set(Tables.accountStats.accountId, accountId) - .set(Tables.accountStats.statId, statId) - .set(Tables.accountStats.value, uploadQueue.get(accountId).get(statId)); + .insertInto(Tables.accountStat) + .set(Tables.accountStat.accountId, accountId) + .set(Tables.accountStat.statId, statId) + .set(Tables.accountStat.value, ULong.valueOf(uploadQueue.get(accountId).get(statId))); inserts.add(insert); } @@ -137,10 +138,10 @@ public class StatsRepository extends RepositoryBase context = DSL.using(getConnectionPool(), SQLDialect.MYSQL); } - Result> result = context.select(Tables.stats.name, Tables.accountStats.value).from(Tables.accountStats) + Result> result = context.select(Tables.stats.name, Tables.accountStat.value).from(Tables.accountStat) .join(Tables.stats) - .on(Tables.stats.id.eq(Tables.accountStats.statId)) - .where(Tables.accountStats.accountId.eq(DSL.select(Tables.accounts.id) + .on(Tables.stats.id.eq(Tables.accountStat.statId)) + .where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id) .from(Tables.accounts) .where(Tables.accounts.name.eq(playerName))) ).fetch(); @@ -149,9 +150,9 @@ public class StatsRepository extends RepositoryBase if (result.isNotEmpty()) { playerStats = new PlayerStats(); - for (Record2 record : result) + for (Record2 record : result) { - playerStats.addStat(record.value1(), record.value2()); + playerStats.addStat(record.value1(), record.value2().longValue()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java index 35293a2b5..d7815f41b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java @@ -13,7 +13,7 @@ public class GiveStatCommand extends CommandBase { public GiveStatCommand(StatsManager plugin) { - super(plugin, Rank.OWNER, "givestat"); + super(plugin, Rank.ADMIN, "givestat"); } @Override @@ -47,7 +47,7 @@ public class GiveStatCommand extends CommandBase final CoreClient client = Plugin.getClientManager().Get(args[0]); if (client != null) - Plugin.incrementStat(client.getAccountId(), statName, Integer.parseInt(args[args.length - 1])); + Plugin.incrementStat(client.getAccountId(), statName, Long.parseLong(args[args.length - 1])); else caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + args[0] + "'s account!")); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java index 18d592581..42fe8b841 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java @@ -55,7 +55,7 @@ public class TimeCommand extends CommandBase } else { - int time = stats.getStat("Global.TimeInGame"); + long time = stats.getStat("Global.TimeInGame"); UtilPlayer.message(caller, F.main("Time", F.name(args[0]) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT)) + " in game")); } } @@ -70,7 +70,7 @@ public class TimeCommand extends CommandBase } else { - int time = Plugin.Get(target).getStat("Global.TimeInGame"); + long time = Plugin.Get(target).getStat("Global.TimeInGame"); UtilPlayer.message(caller, F.main("Time", F.name(target.getName()) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT)) + " in game")); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/event/StatChangeEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/event/StatChangeEvent.java index ec1c230f1..2dc93919f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/event/StatChangeEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/event/StatChangeEvent.java @@ -11,10 +11,10 @@ public class StatChangeEvent extends Event private String _player; private String _statName; - private int _valueBefore; - private int _valueAfter; + private long _valueBefore; + private long _valueAfter; - public StatChangeEvent(String player, String statName, int valueBefore, int valueAfter) + public StatChangeEvent(String player, String statName, long valueBefore, long valueAfter) { _player = player; _statName = statName; @@ -42,12 +42,12 @@ public class StatChangeEvent extends Event return _statName; } - public int getValueBefore() + public long getValueBefore() { return _valueBefore; } - public int getValueAfter() + public long getValueAfter() { return _valueAfter; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index c4137e453..80abd5078 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -116,10 +116,8 @@ public class ServerStatusManager extends MiniPlugin if (event.getType() != UpdateType.FASTER) return; - if (!_enabled) - return; - - saveServerStatus(); + if (_enabled) + saveServerStatus(); } /** @@ -139,19 +137,6 @@ public class ServerStatusManager extends MiniPlugin if (server != null && !server.getPublicAddress().equalsIgnoreCase(serverSnapshot.getPublicAddress())) { timeout = -DEFAULT_SERVER_TIMEOUT; - /* - ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", "/home/mineplex/config/killServer.sh", serverSnapshot.getName()}); - pr.start(new GenericRunnable() - { - public void run(Boolean error) - { - if (error) - log("Error Killing myself."); - else - log("It worked."); - } - }); - */ } _repository.updataServerStatus(serverSnapshot, timeout); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index fc9e67158..2ecce2580 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -134,7 +134,7 @@ public class TaskManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { Set(playerName, _repository.loadClientInformation(resultSet)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index 79c342ce9..09aabb2ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -20,6 +20,7 @@ import mineplex.core.common.jsonchat.JsonMessage; 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.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; @@ -285,7 +286,7 @@ public class Teleport extends MiniPlugin } player.setFallDistance(0); - player.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(player); player.teleport(loc); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java index a2371ce9a..264695e3a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java @@ -10,7 +10,7 @@ public class HereCommand extends CommandBase { public HereCommand(Teleport plugin) { - super(plugin, Rank.ADMIN, "here", "h"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "here", "h"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index 8911e6d3a..7f4ef7667 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -99,7 +99,10 @@ public class TreasureLocation implements Listener setHoloChestVisible(false); - if (treasureType == TreasureType.ANCIENT || treasureType == TreasureType.MYTHICAL) + if (treasureType == TreasureType.ANCIENT) + Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening an " + treasureType.getName())); + + if (treasureType == TreasureType.MYTHICAL) Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName())); Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardType()); @@ -324,6 +327,11 @@ public class TreasureLocation implements Listener _hologram.start(); } + public Treasure getCurrentTreasure() + { + return _currentTreasure; + } + public void openShop(Player player) { _shop.attemptShopOpen(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 8eb5f02a3..fbd14ea54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -20,6 +20,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardType; +import mineplex.core.stats.StatsManager; /** * Created by Shaun on 8/27/2014. @@ -32,19 +33,19 @@ public class TreasureManager extends MiniPlugin private HologramManager _hologramManager; private List _treasureLocations; - public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager) + public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager) { super("Treasure", plugin); _inventoryManager = inventoryManager; _blockRestore = blockRestore; _hologramManager = hologramManager; - _rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager, + _rewardManager = new RewardManager(clientManager, donationManager, _inventoryManager, petManager, statsManager, 100, 250, 500, 1000, 4000, 6000, 12000, 32000, - true); + true, false); World world = Bukkit.getWorlds().get(0); @@ -125,6 +126,22 @@ public class TreasureManager extends MiniPlugin return _rewardManager.getRewards(player, rewardType); } + public boolean isOpening(Player player) + { + for (TreasureLocation treasureLocation : _treasureLocations) + { + Treasure treasure = treasureLocation.getCurrentTreasure(); + + if (treasure == null) + continue; + + if (treasure.getPlayer().equals(player)) + return true; + } + + return false; + } + public BlockRestore getBlockRestore() { return _blockRestore; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java index c3fbe6e62..a6b986660 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java @@ -16,6 +16,8 @@ public abstract class Animation _treasure = treasure; _running = true; } + + public Animation() {} public void run() { @@ -50,5 +52,15 @@ public abstract class Animation { return _treasure; } + + public void setRunning(boolean b) + { + _running = b; + } + + public void setTicks(int ticks) + { + _ticks = ticks; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index 1e932656f..e1afeaf64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -4,7 +4,10 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.account.event.GetClientEvent; import mineplex.core.common.CurrencyType; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.inventory.InventoryManager; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ConfirmationPage; @@ -36,6 +39,11 @@ public class BuyChestButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { + if(_inventoryManager.getClientManager().Get(player).isDisguised()) + { + UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); + return; + } _page.getShop().openPageForPlayer(player, new ConfirmationPage( _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartServerCommand.java index ff2a51f08..1067506b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartServerCommand.java @@ -15,7 +15,7 @@ public class RestartServerCommand extends CommandBase { public RestartServerCommand(FileUpdater plugin) { - super(plugin, Rank.ADMIN, "restart"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "restart"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/velocity/VelocityFix.java b/Plugins/Mineplex.Core/src/mineplex/core/velocity/VelocityFix.java new file mode 100644 index 000000000..7649f3431 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/velocity/VelocityFix.java @@ -0,0 +1,78 @@ +package mineplex.core.velocity; + +import java.util.Iterator; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.VelocityReceiver; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +public class VelocityFix extends MiniPlugin implements VelocityReceiver +{ + /* + * The purpose of this class is to fix a bug inherent in Minecraft, + * where player join order will somehow modify the velocity sent to players. + * + * To fix it, we simply save the velocity that the player should have received, + * then we re-set those values in CB the moment its about to actually apply the velocity to a player. + * + * The problem was caused by the fact that CB does not run a PlayerVelocityEvent the moment we + * set a players velocity, instead it waits until the next tick, and the velocity may have been changed. + * + */ + + private NautHashMap _velocityData = new NautHashMap(); + + public VelocityFix(JavaPlugin plugin) + { + super("Velocity Fix", plugin); + + UtilAction.registerVelocityFix(this); + } + + @Override + public void setPlayerVelocity(Player player, Vector velocity) + { + _velocityData.put(player, velocity); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void fixVelocity(PlayerVelocityEvent event) + { + if (_velocityData.containsKey(event.getPlayer())) + event.getPlayer().setVelocity(_velocityData.remove(event.getPlayer())); + } + + @EventHandler + public void cleanVelocity(PlayerQuitEvent event) + { + _velocityData.remove(event.getPlayer()); + } + + @EventHandler + public void cleanVelocity(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + return; + + Iterator keyIter = _velocityData.keySet().iterator(); + + while (keyIter.hasNext()) + { + Player player = keyIter.next(); + + if (player.isOnline()) + keyIter.remove(); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java index 29b8bba98..26fe0e706 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java @@ -91,7 +91,7 @@ public class VisibilityManager extends MiniPlugin _data.remove(event.getPlayer()); } - @EventHandler + //@EventHandler DISABLED public void updateDebug(UpdateEvent event) { if (event.getType() != UpdateType.MIN_01) diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Account.java b/Plugins/Mineplex.Database/src/mineplex/database/Account.java index 2217fc08f..745edad55 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Account.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Account.java @@ -16,7 +16,7 @@ package mineplex.database; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Account extends org.jooq.impl.SchemaImpl implements java.io.Serializable, java.lang.Cloneable { - private static final long serialVersionUID = 1150881021; + private static final long serialVersionUID = 2034846771; /** * The reference instance of Account @@ -48,11 +48,13 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.AccountPolls.accountPolls, mineplex.database.tables.AccountPreferences.accountPreferences, mineplex.database.tables.Accounts.accounts, + mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStats.accountStats, mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.ActiveTournaments.activeTournaments, mineplex.database.tables.Bonus.bonus, + mineplex.database.tables.Chatsnap.chatsnap, mineplex.database.tables.ClanAlliances.clanAlliances, mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanMember.clanMember, diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java index b9148c7e7..58b66870c 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java @@ -34,6 +34,7 @@ public class Keys { public static final org.jooq.Identity IDENTITY_accountTasks = Identities0.IDENTITY_accountTasks; public static final org.jooq.Identity IDENTITY_accountTransactions = Identities0.IDENTITY_accountTransactions; public static final org.jooq.Identity IDENTITY_bonus = Identities0.IDENTITY_bonus; + public static final org.jooq.Identity IDENTITY_chatsnap = Identities0.IDENTITY_chatsnap; public static final org.jooq.Identity IDENTITY_clanAlliances = Identities0.IDENTITY_clanAlliances; public static final org.jooq.Identity IDENTITY_clanEnemies = Identities0.IDENTITY_clanEnemies; public static final org.jooq.Identity IDENTITY_clans = Identities0.IDENTITY_clans; @@ -77,11 +78,13 @@ public class Keys { public static final org.jooq.UniqueKey KEY_accountPreferences_uuid_index = UniqueKeys0.KEY_accountPreferences_uuid_index; public static final org.jooq.UniqueKey KEY_accounts_PRIMARY = UniqueKeys0.KEY_accounts_PRIMARY; public static final org.jooq.UniqueKey KEY_accounts_uuidIndex = UniqueKeys0.KEY_accounts_uuidIndex; + public static final org.jooq.UniqueKey KEY_accountStat_PRIMARY = UniqueKeys0.KEY_accountStat_PRIMARY; public static final org.jooq.UniqueKey KEY_accountStats_PRIMARY = UniqueKeys0.KEY_accountStats_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTasks_PRIMARY = UniqueKeys0.KEY_accountTasks_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTransactions_PRIMARY = UniqueKeys0.KEY_accountTransactions_PRIMARY; public static final org.jooq.UniqueKey KEY_activeTournaments_PRIMARY = UniqueKeys0.KEY_activeTournaments_PRIMARY; public static final org.jooq.UniqueKey KEY_bonus_PRIMARY = UniqueKeys0.KEY_bonus_PRIMARY; + public static final org.jooq.UniqueKey KEY_chatsnap_PRIMARY = UniqueKeys0.KEY_chatsnap_PRIMARY; public static final org.jooq.UniqueKey KEY_clanAlliances_PRIMARY = UniqueKeys0.KEY_clanAlliances_PRIMARY; public static final org.jooq.UniqueKey KEY_clanEnemies_PRIMARY = UniqueKeys0.KEY_clanEnemies_PRIMARY; public static final org.jooq.UniqueKey KEY_clanEnemies_unique_clanId = UniqueKeys0.KEY_clanEnemies_unique_clanId; @@ -135,6 +138,8 @@ public class Keys { public static final org.jooq.ForeignKey accountInventory_ibfk_2 = ForeignKeys0.accountInventory_ibfk_2; public static final org.jooq.ForeignKey accountPolls_ibfk_1 = ForeignKeys0.accountPolls_ibfk_1; public static final org.jooq.ForeignKey accountPolls_ibfk_2 = ForeignKeys0.accountPolls_ibfk_2; + public static final org.jooq.ForeignKey accountStat_account = ForeignKeys0.accountStat_account; + public static final org.jooq.ForeignKey accountStat_stat = ForeignKeys0.accountStat_stat; public static final org.jooq.ForeignKey accountStats_ibfk_1 = ForeignKeys0.accountStats_ibfk_1; public static final org.jooq.ForeignKey accountStats_ibfk_2 = ForeignKeys0.accountStats_ibfk_2; public static final org.jooq.ForeignKey ACCOUNTTASKS_ACCOUNTID = ForeignKeys0.ACCOUNTTASKS_ACCOUNTID; @@ -172,6 +177,7 @@ public class Keys { public static org.jooq.Identity IDENTITY_accountTasks = createIdentity(mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.id); public static org.jooq.Identity IDENTITY_accountTransactions = createIdentity(mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.id); public static org.jooq.Identity IDENTITY_bonus = createIdentity(mineplex.database.tables.Bonus.bonus, mineplex.database.tables.Bonus.bonus.accountId); + public static org.jooq.Identity IDENTITY_chatsnap = createIdentity(mineplex.database.tables.Chatsnap.chatsnap, mineplex.database.tables.Chatsnap.chatsnap.id); public static org.jooq.Identity IDENTITY_clanAlliances = createIdentity(mineplex.database.tables.ClanAlliances.clanAlliances, mineplex.database.tables.ClanAlliances.clanAlliances.id); public static org.jooq.Identity IDENTITY_clanEnemies = createIdentity(mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanEnemies.clanEnemies.id); public static org.jooq.Identity IDENTITY_clans = createIdentity(mineplex.database.tables.Clans.clans, mineplex.database.tables.Clans.clans.id); @@ -213,11 +219,13 @@ public class Keys { public static final org.jooq.UniqueKey KEY_accountPreferences_uuid_index = createUniqueKey(mineplex.database.tables.AccountPreferences.accountPreferences, mineplex.database.tables.AccountPreferences.accountPreferences.uuid); public static final org.jooq.UniqueKey KEY_accounts_PRIMARY = createUniqueKey(mineplex.database.tables.Accounts.accounts, mineplex.database.tables.Accounts.accounts.id); public static final org.jooq.UniqueKey KEY_accounts_uuidIndex = createUniqueKey(mineplex.database.tables.Accounts.accounts, mineplex.database.tables.Accounts.accounts.uuid); + public static final org.jooq.UniqueKey KEY_accountStat_PRIMARY = createUniqueKey(mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStat.accountStat.accountId, mineplex.database.tables.AccountStat.accountStat.statId); public static final org.jooq.UniqueKey KEY_accountStats_PRIMARY = createUniqueKey(mineplex.database.tables.AccountStats.accountStats, mineplex.database.tables.AccountStats.accountStats.id); public static final org.jooq.UniqueKey KEY_accountTasks_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.id); public static final org.jooq.UniqueKey KEY_accountTransactions_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.id); public static final org.jooq.UniqueKey KEY_activeTournaments_PRIMARY = createUniqueKey(mineplex.database.tables.ActiveTournaments.activeTournaments, mineplex.database.tables.ActiveTournaments.activeTournaments.name); public static final org.jooq.UniqueKey KEY_bonus_PRIMARY = createUniqueKey(mineplex.database.tables.Bonus.bonus, mineplex.database.tables.Bonus.bonus.accountId); + public static final org.jooq.UniqueKey KEY_chatsnap_PRIMARY = createUniqueKey(mineplex.database.tables.Chatsnap.chatsnap, mineplex.database.tables.Chatsnap.chatsnap.id); public static final org.jooq.UniqueKey KEY_clanAlliances_PRIMARY = createUniqueKey(mineplex.database.tables.ClanAlliances.clanAlliances, mineplex.database.tables.ClanAlliances.clanAlliances.id); public static final org.jooq.UniqueKey KEY_clanEnemies_PRIMARY = createUniqueKey(mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanEnemies.clanEnemies.id); public static final org.jooq.UniqueKey KEY_clanEnemies_unique_clanId = createUniqueKey(mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanEnemies.clanEnemies.clanId); @@ -269,6 +277,8 @@ public class Keys { public static final org.jooq.ForeignKey accountInventory_ibfk_2 = createForeignKey(mineplex.database.Keys.KEY_items_PRIMARY, mineplex.database.tables.AccountInventory.accountInventory, mineplex.database.tables.AccountInventory.accountInventory.itemId); public static final org.jooq.ForeignKey accountPolls_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountPolls.accountPolls, mineplex.database.tables.AccountPolls.accountPolls.accountId); public static final org.jooq.ForeignKey accountPolls_ibfk_2 = createForeignKey(mineplex.database.Keys.KEY_polls_PRIMARY, mineplex.database.tables.AccountPolls.accountPolls, mineplex.database.tables.AccountPolls.accountPolls.pollId); + public static final org.jooq.ForeignKey accountStat_account = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStat.accountStat.accountId); + public static final org.jooq.ForeignKey accountStat_stat = createForeignKey(mineplex.database.Keys.KEY_stats_PRIMARY, mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStat.accountStat.statId); public static final org.jooq.ForeignKey accountStats_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountStats.accountStats, mineplex.database.tables.AccountStats.accountStats.accountId); public static final org.jooq.ForeignKey accountStats_ibfk_2 = createForeignKey(mineplex.database.Keys.KEY_stats_PRIMARY, mineplex.database.tables.AccountStats.accountStats, mineplex.database.tables.AccountStats.accountStats.statId); public static final org.jooq.ForeignKey ACCOUNTTASKS_ACCOUNTID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.accountId); diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java index 21ae7415e..9a5c0f4de 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java @@ -54,6 +54,19 @@ public class Routines { return p; } + /** + * Call Account.check_vote + */ + public static mineplex.database.routines.Check_vote callCheckVote(org.jooq.Configuration configuration, java.lang.Integer accountId_in, java.lang.Integer coinsChange, java.lang.Integer gemsChange) { + mineplex.database.routines.Check_vote p = new mineplex.database.routines.Check_vote(); + p.setAccountId_in(accountId_in); + p.setCoinsChange(coinsChange); + p.setGemsChange(gemsChange); + + p.execute(configuration); + return p; + } + /** * Call Account.createLeaderboard */ diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java index 22ea101ee..6036ed719 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java @@ -61,6 +61,11 @@ public class Tables { */ public static final mineplex.database.tables.Accounts accounts = mineplex.database.tables.Accounts.accounts; + /** + * The table Account.accountStat + */ + public static final mineplex.database.tables.AccountStat accountStat = mineplex.database.tables.AccountStat.accountStat; + /** * The table Account.accountStats */ @@ -86,6 +91,11 @@ public class Tables { */ public static final mineplex.database.tables.Bonus bonus = mineplex.database.tables.Bonus.bonus; + /** + * The table Account.chatsnap + */ + public static final mineplex.database.tables.Chatsnap chatsnap = mineplex.database.tables.Chatsnap.chatsnap; + /** * The table Account.clanAlliances */ diff --git a/Plugins/Mineplex.Database/src/mineplex/database/routines/Check_vote.java b/Plugins/Mineplex.Database/src/mineplex/database/routines/Check_vote.java new file mode 100644 index 000000000..847580a4c --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/routines/Check_vote.java @@ -0,0 +1,93 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.routines; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Check_vote extends org.jooq.impl.AbstractRoutine implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 2035299030; + + /** + * The parameter Account.check_vote.accountId_in. + */ + public static final org.jooq.Parameter accountId_in = createParameter("accountId_in", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.check_vote.coinsChange. + */ + public static final org.jooq.Parameter coinsChange = createParameter("coinsChange", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.check_vote.gemsChange. + */ + public static final org.jooq.Parameter gemsChange = createParameter("gemsChange", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.check_vote.pass. + */ + public static final org.jooq.Parameter pass = createParameter("pass", org.jooq.impl.SQLDataType.TINYINT, false); + + /** + * The parameter Account.check_vote.outTime. + */ + public static final org.jooq.Parameter outTime = createParameter("outTime", org.jooq.impl.SQLDataType.DATE, false); + + /** + * Create a new routine call instance + */ + public Check_vote() { + super("check_vote", mineplex.database.Account.Account); + + addInParameter(accountId_in); + addInParameter(coinsChange); + addInParameter(gemsChange); + addOutParameter(pass); + addOutParameter(outTime); + } + + /** + * Set the accountId_in parameter IN value to the routine + */ + public void setAccountId_in(java.lang.Integer value) { + setValue(mineplex.database.routines.Check_vote.accountId_in, value); + } + + /** + * Set the coinsChange parameter IN value to the routine + */ + public void setCoinsChange(java.lang.Integer value) { + setValue(mineplex.database.routines.Check_vote.coinsChange, value); + } + + /** + * Set the gemsChange parameter IN value to the routine + */ + public void setGemsChange(java.lang.Integer value) { + setValue(mineplex.database.routines.Check_vote.gemsChange, value); + } + + /** + * Get the pass parameter OUT value from the routine + */ + public java.lang.Byte getPass() { + return getValue(pass); + } + + /** + * Get the outTime parameter OUT value from the routine + */ + public java.sql.Date getOutTime() { + return getValue(outTime); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountStat.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountStat.java new file mode 100644 index 000000000..a73aa75b4 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountStat.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountStat extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 34581219; + + /** + * The reference instance of Account.accountStat + */ + public static final mineplex.database.tables.AccountStat accountStat = new mineplex.database.tables.AccountStat(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountStatRecord.class; + } + + /** + * The column Account.accountStat.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountStat.statId. + */ + public final org.jooq.TableField statId = createField("statId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountStat.value. + */ + public final org.jooq.TableField value = createField("value", org.jooq.impl.SQLDataType.BIGINTUNSIGNED.defaulted(true), this, ""); + + /** + * Create a Account.accountStat table reference + */ + public AccountStat() { + this("accountStat", null); + } + + /** + * Create an aliased Account.accountStat table reference + */ + public AccountStat(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountStat.accountStat); + } + + private AccountStat(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountStat(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountStat_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountStat_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountStat_account, mineplex.database.Keys.accountStat_stat); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountStat as(java.lang.String alias) { + return new mineplex.database.tables.AccountStat(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountStat rename(java.lang.String name) { + return new mineplex.database.tables.AccountStat(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java index a2acbbbb5..4547730a3 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Bonus.java @@ -16,7 +16,7 @@ package mineplex.database.tables; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Bonus extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { - private static final long serialVersionUID = -70389593; + private static final long serialVersionUID = -384307684; /** * The reference instance of Account.bonus @@ -46,6 +46,36 @@ public class Bonus extends org.jooq.impl.TableImpl ranktime = createField("ranktime", org.jooq.impl.SQLDataType.DATE, this, ""); + /** + * The column Account.bonus.votetime. + */ + public final org.jooq.TableField votetime = createField("votetime", org.jooq.impl.SQLDataType.DATE, this, ""); + + /** + * The column Account.bonus.dailyStreak. + */ + public final org.jooq.TableField dailyStreak = createField("dailyStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); + + /** + * The column Account.bonus.maxDailyStreak. + */ + public final org.jooq.TableField maxDailyStreak = createField("maxDailyStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); + + /** + * The column Account.bonus.voteStreak. + */ + public final org.jooq.TableField voteStreak = createField("voteStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); + + /** + * The column Account.bonus.maxVoteStreak. + */ + public final org.jooq.TableField maxVoteStreak = createField("maxVoteStreak", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); + + /** + * The column Account.bonus.tickets. + */ + public final org.jooq.TableField tickets = createField("tickets", org.jooq.impl.SQLDataType.INTEGER.defaulted(true), this, ""); + /** * Create a Account.bonus table reference */ diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Chatsnap.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Chatsnap.java new file mode 100644 index 000000000..044ee5e36 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Chatsnap.java @@ -0,0 +1,129 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Chatsnap extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -176946707; + + /** + * The reference instance of Account.chatsnap + */ + public static final mineplex.database.tables.Chatsnap chatsnap = new mineplex.database.tables.Chatsnap(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.ChatsnapRecord.class; + } + + /** + * The column Account.chatsnap.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.chatsnap.reporterId. + */ + public final org.jooq.TableField reporterId = createField("reporterId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.chatsnap.reporteeId. + */ + public final org.jooq.TableField reporteeId = createField("reporteeId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.chatsnap.time. + */ + public final org.jooq.TableField time = createField("time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.chatsnap.status. + */ + public final org.jooq.TableField status = createField("status", org.jooq.impl.SQLDataType.VARCHAR.length(10).nullable(false).defaulted(true), this, ""); + + /** + * The column Account.chatsnap.reason. + */ + public final org.jooq.TableField reason = createField("reason", org.jooq.impl.SQLDataType.CLOB.length(65535).nullable(false), this, ""); + + /** + * The column Account.chatsnap.data. + */ + public final org.jooq.TableField data = createField("data", org.jooq.impl.SQLDataType.CLOB.length(16777215).nullable(false), this, ""); + + /** + * Create a Account.chatsnap table reference + */ + public Chatsnap() { + this("chatsnap", null); + } + + /** + * Create an aliased Account.chatsnap table reference + */ + public Chatsnap(java.lang.String alias) { + this(alias, mineplex.database.tables.Chatsnap.chatsnap); + } + + private Chatsnap(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private Chatsnap(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_chatsnap; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_chatsnap_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_chatsnap_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.Chatsnap as(java.lang.String alias) { + return new mineplex.database.tables.Chatsnap(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.Chatsnap rename(java.lang.String name) { + return new mineplex.database.tables.Chatsnap(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Clans.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Clans.java index 2e0a0b810..a72409235 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/Clans.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Clans.java @@ -16,7 +16,7 @@ package mineplex.database.tables; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Clans extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { - private static final long serialVersionUID = -194264445; + private static final long serialVersionUID = -1842631086; /** * The reference instance of Account.clans @@ -76,6 +76,31 @@ public class Clans extends org.jooq.impl.TableImpl energy = createField("energy", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + /** + * The column Account.clans.kills. + */ + public final org.jooq.TableField kills = createField("kills", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.clans.murder. + */ + public final org.jooq.TableField murder = createField("murder", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.clans.deaths. + */ + public final org.jooq.TableField deaths = createField("deaths", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.clans.warWins. + */ + public final org.jooq.TableField warWins = createField("warWins", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.clans.warLosses. + */ + public final org.jooq.TableField warLosses = createField("warLosses", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + /** * Create a Account.clans table reference */ diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountStatRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountStatRecord.java new file mode 100644 index 000000000..df8d59c6e --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountStatRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountStatRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = -516667486; + + /** + * Setter for Account.accountStat.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountStat.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountStat.statId. + */ + public void setStatId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountStat.statId. + */ + public java.lang.Integer getStatId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.accountStat.value. + */ + public void setValue(org.jooq.types.ULong value) { + setValue(2, value); + } + + /** + * Getter for Account.accountStat.value. + */ + public org.jooq.types.ULong getValue() { + return (org.jooq.types.ULong) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountStat.accountStat.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountStat.accountStat.statId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountStat.accountStat.value; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getStatId(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.types.ULong value3() { + return getValue(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord value2(java.lang.Integer value) { + setStatId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord value3(org.jooq.types.ULong value) { + setValue(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord values(java.lang.Integer value1, java.lang.Integer value2, org.jooq.types.ULong value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountStatRecord + */ + public AccountStatRecord() { + super(mineplex.database.tables.AccountStat.accountStat); + } + + /** + * Create a detached, initialised AccountStatRecord + */ + public AccountStatRecord(java.lang.Integer accountId, java.lang.Integer statId, org.jooq.types.ULong value) { + super(mineplex.database.tables.AccountStat.accountStat); + + setValue(0, accountId); + setValue(1, statId); + setValue(2, value); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/BonusRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/BonusRecord.java index be35509b0..ee1c0bb21 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/BonusRecord.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/BonusRecord.java @@ -14,9 +14,9 @@ package mineplex.database.tables.records; comments = "This class is generated by jOOQ" ) @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { +public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record9 { - private static final long serialVersionUID = -64019858; + private static final long serialVersionUID = -785434679; /** * Setter for Account.bonus.accountId. @@ -60,6 +60,90 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImplAccount.bonus.votetime. + */ + public void setVotetime(java.sql.Date value) { + setValue(3, value); + } + + /** + * Getter for Account.bonus.votetime. + */ + public java.sql.Date getVotetime() { + return (java.sql.Date) getValue(3); + } + + /** + * Setter for Account.bonus.dailyStreak. + */ + public void setDailyStreak(java.lang.Integer value) { + setValue(4, value); + } + + /** + * Getter for Account.bonus.dailyStreak. + */ + public java.lang.Integer getDailyStreak() { + return (java.lang.Integer) getValue(4); + } + + /** + * Setter for Account.bonus.maxDailyStreak. + */ + public void setMaxDailyStreak(java.lang.Integer value) { + setValue(5, value); + } + + /** + * Getter for Account.bonus.maxDailyStreak. + */ + public java.lang.Integer getMaxDailyStreak() { + return (java.lang.Integer) getValue(5); + } + + /** + * Setter for Account.bonus.voteStreak. + */ + public void setVoteStreak(java.lang.Integer value) { + setValue(6, value); + } + + /** + * Getter for Account.bonus.voteStreak. + */ + public java.lang.Integer getVoteStreak() { + return (java.lang.Integer) getValue(6); + } + + /** + * Setter for Account.bonus.maxVoteStreak. + */ + public void setMaxVoteStreak(java.lang.Integer value) { + setValue(7, value); + } + + /** + * Getter for Account.bonus.maxVoteStreak. + */ + public java.lang.Integer getMaxVoteStreak() { + return (java.lang.Integer) getValue(7); + } + + /** + * Setter for Account.bonus.tickets. + */ + public void setTickets(java.lang.Integer value) { + setValue(8, value); + } + + /** + * Getter for Account.bonus.tickets. + */ + public java.lang.Integer getTickets() { + return (java.lang.Integer) getValue(8); + } + // ------------------------------------------------------------------------- // Primary key information // ------------------------------------------------------------------------- @@ -73,23 +157,23 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl fieldsRow() { - return (org.jooq.Row3) super.fieldsRow(); + public org.jooq.Row9 fieldsRow() { + return (org.jooq.Row9) super.fieldsRow(); } /** * {@inheritDoc} */ @Override - public org.jooq.Row3 valuesRow() { - return (org.jooq.Row3) super.valuesRow(); + public org.jooq.Row9 valuesRow() { + return (org.jooq.Row9) super.valuesRow(); } /** @@ -116,6 +200,54 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl field4() { + return mineplex.database.tables.Bonus.bonus.votetime; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field5() { + return mineplex.database.tables.Bonus.bonus.dailyStreak; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field6() { + return mineplex.database.tables.Bonus.bonus.maxDailyStreak; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field7() { + return mineplex.database.tables.Bonus.bonus.voteStreak; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field8() { + return mineplex.database.tables.Bonus.bonus.maxVoteStreak; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field9() { + return mineplex.database.tables.Bonus.bonus.tickets; + } + /** * {@inheritDoc} */ @@ -140,6 +272,54 @@ public class BonusRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record7 { + + private static final long serialVersionUID = 2087133341; + + /** + * Setter for Account.chatsnap.id. + */ + public void setId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.chatsnap.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.chatsnap.reporterId. + */ + public void setReporterId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.chatsnap.reporterId. + */ + public java.lang.Integer getReporterId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.chatsnap.reporteeId. + */ + public void setReporteeId(java.lang.Integer value) { + setValue(2, value); + } + + /** + * Getter for Account.chatsnap.reporteeId. + */ + public java.lang.Integer getReporteeId() { + return (java.lang.Integer) getValue(2); + } + + /** + * Setter for Account.chatsnap.time. + */ + public void setTime(java.sql.Timestamp value) { + setValue(3, value); + } + + /** + * Getter for Account.chatsnap.time. + */ + public java.sql.Timestamp getTime() { + return (java.sql.Timestamp) getValue(3); + } + + /** + * Setter for Account.chatsnap.status. + */ + public void setStatus(java.lang.String value) { + setValue(4, value); + } + + /** + * Getter for Account.chatsnap.status. + */ + public java.lang.String getStatus() { + return (java.lang.String) getValue(4); + } + + /** + * Setter for Account.chatsnap.reason. + */ + public void setReason(java.lang.String value) { + setValue(5, value); + } + + /** + * Getter for Account.chatsnap.reason. + */ + public java.lang.String getReason() { + return (java.lang.String) getValue(5); + } + + /** + * Setter for Account.chatsnap.data. + */ + public void setData(java.lang.String value) { + setValue(6, value); + } + + /** + * Getter for Account.chatsnap.data. + */ + public java.lang.String getData() { + return (java.lang.String) getValue(6); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record7 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row7 fieldsRow() { + return (org.jooq.Row7) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row7 valuesRow() { + return (org.jooq.Row7) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.Chatsnap.chatsnap.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.Chatsnap.chatsnap.reporterId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.Chatsnap.chatsnap.reporteeId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field4() { + return mineplex.database.tables.Chatsnap.chatsnap.time; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field5() { + return mineplex.database.tables.Chatsnap.chatsnap.status; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field6() { + return mineplex.database.tables.Chatsnap.chatsnap.reason; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field7() { + return mineplex.database.tables.Chatsnap.chatsnap.data; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getReporterId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value3() { + return getReporteeId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value4() { + return getTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value5() { + return getStatus(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value6() { + return getReason(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value7() { + return getData(); + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord value1(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord value2(java.lang.Integer value) { + setReporterId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord value3(java.lang.Integer value) { + setReporteeId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord value4(java.sql.Timestamp value) { + setTime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord value5(java.lang.String value) { + setStatus(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord value6(java.lang.String value) { + setReason(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord value7(java.lang.String value) { + setData(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChatsnapRecord values(java.lang.Integer value1, java.lang.Integer value2, java.lang.Integer value3, java.sql.Timestamp value4, java.lang.String value5, java.lang.String value6, java.lang.String value7) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ChatsnapRecord + */ + public ChatsnapRecord() { + super(mineplex.database.tables.Chatsnap.chatsnap); + } + + /** + * Create a detached, initialised ChatsnapRecord + */ + public ChatsnapRecord(java.lang.Integer id, java.lang.Integer reporterId, java.lang.Integer reporteeId, java.sql.Timestamp time, java.lang.String status, java.lang.String reason, java.lang.String data) { + super(mineplex.database.tables.Chatsnap.chatsnap); + + setValue(0, id); + setValue(1, reporterId); + setValue(2, reporteeId); + setValue(3, time); + setValue(4, status); + setValue(5, reason); + setValue(6, data); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansRecord.java index d1ca82539..59efbb657 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansRecord.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansRecord.java @@ -14,9 +14,9 @@ package mineplex.database.tables.records; comments = "This class is generated by jOOQ" ) @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class ClansRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record9 { +public class ClansRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record14 { - private static final long serialVersionUID = -1803774546; + private static final long serialVersionUID = -1588610871; /** * Setter for Account.clans.id. @@ -144,6 +144,76 @@ public class ClansRecord extends org.jooq.impl.UpdatableRecordImplAccount.clans.kills. + */ + public void setKills(java.lang.Integer value) { + setValue(9, value); + } + + /** + * Getter for Account.clans.kills. + */ + public java.lang.Integer getKills() { + return (java.lang.Integer) getValue(9); + } + + /** + * Setter for Account.clans.murder. + */ + public void setMurder(java.lang.Integer value) { + setValue(10, value); + } + + /** + * Getter for Account.clans.murder. + */ + public java.lang.Integer getMurder() { + return (java.lang.Integer) getValue(10); + } + + /** + * Setter for Account.clans.deaths. + */ + public void setDeaths(java.lang.Integer value) { + setValue(11, value); + } + + /** + * Getter for Account.clans.deaths. + */ + public java.lang.Integer getDeaths() { + return (java.lang.Integer) getValue(11); + } + + /** + * Setter for Account.clans.warWins. + */ + public void setWarWins(java.lang.Integer value) { + setValue(12, value); + } + + /** + * Getter for Account.clans.warWins. + */ + public java.lang.Integer getWarWins() { + return (java.lang.Integer) getValue(12); + } + + /** + * Setter for Account.clans.warLosses. + */ + public void setWarLosses(java.lang.Integer value) { + setValue(13, value); + } + + /** + * Getter for Account.clans.warLosses. + */ + public java.lang.Integer getWarLosses() { + return (java.lang.Integer) getValue(13); + } + // ------------------------------------------------------------------------- // Primary key information // ------------------------------------------------------------------------- @@ -157,23 +227,23 @@ public class ClansRecord extends org.jooq.impl.UpdatableRecordImpl fieldsRow() { - return (org.jooq.Row9) super.fieldsRow(); + public org.jooq.Row14 fieldsRow() { + return (org.jooq.Row14) super.fieldsRow(); } /** * {@inheritDoc} */ @Override - public org.jooq.Row9 valuesRow() { - return (org.jooq.Row9) super.valuesRow(); + public org.jooq.Row14 valuesRow() { + return (org.jooq.Row14) super.valuesRow(); } /** @@ -248,6 +318,46 @@ public class ClansRecord extends org.jooq.impl.UpdatableRecordImpl field10() { + return mineplex.database.tables.Clans.clans.kills; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field11() { + return mineplex.database.tables.Clans.clans.murder; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field12() { + return mineplex.database.tables.Clans.clans.deaths; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field13() { + return mineplex.database.tables.Clans.clans.warWins; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field14() { + return mineplex.database.tables.Clans.clans.warLosses; + } + /** * {@inheritDoc} */ @@ -320,6 +430,46 @@ public class ClansRecord extends org.jooq.impl.UpdatableRecordImpl mLocalMap(Player player, Chunk chunk, boolean local) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 5b0a0ea4b..5cd314af0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -21,6 +21,9 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -168,6 +171,41 @@ public class ClansGame extends MiniPlugin }, 0); } + + @EventHandler + public void onFishHookEvent(PlayerFishEvent event) + { + if (event.getCaught() instanceof Player) + { + Player defender = (Player) event.getCaught(); + Player attacker = event.getPlayer(); + + if (!Clans.getClanUtility().canHurt(defender, attacker)) + { + event.setCancelled(true); + ClanRelation rel = Clans.getRelation(defender.getName(), attacker.getName()); + UtilPlayer.message(attacker, F.main("Clans", "You cannot harm " + Clans.getClanUtility().mRel(rel, defender.getName(), false) + ".")); + } + } + } + + @EventHandler + public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) + { + Material bucket = event.getBucket(); + + if (bucket == Material.LAVA_BUCKET || bucket == Material.WATER_BUCKET) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot empty buckets!")); + } + } + + @EventHandler + public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event) + { + ((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original food level changes + } @EventHandler(priority = EventPriority.LOW) public void BlockBreak(BlockBreakEvent event) @@ -251,7 +289,7 @@ public class ClansGame extends MiniPlugin mimic)); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOW) public void Damage(CustomDamageEvent event) { if (event.IsCancelled()) 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 907c09646..40e4a9b20 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 @@ -3,6 +3,7 @@ package mineplex.game.clans.clans; import java.util.HashSet; import java.util.TimeZone; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -33,6 +34,7 @@ import mineplex.core.creature.event.CreatureSpawnCustomEvent; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.energy.Energy; +import mineplex.core.explosion.Explosion; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; @@ -109,6 +111,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat private WorldEventManager _worldEvent; private Chat _chat; private ItemMapManager _itemMapManager; + private Explosion _explosion; private int _inviteExpire = 2; private int _nameMin = 3; @@ -160,6 +163,8 @@ public class ClansManager extends MiniClientPlugin implements IRelat _clanUtility = new ClansUtility(this); _itemMapManager = new ItemMapManager(this, _worldEvent); + _explosion = new Explosion(plugin, blockRestore); + Energy energy = new Energy(plugin); // TODO: Re-enable customtagfix with NCP update? //new CustomTagFix(plugin, packetHandler); @@ -183,6 +188,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat ItemFactory itemFactory = new ItemFactory(plugin, blockRestore, _condition, damageManager, energy, fire, _projectileManager, webServerAddress, itemIgnore); SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, _projectileManager, disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress); skillManager.RemoveSkill("Dwarf Toss", "Block Toss"); + skillManager.removeSkill("Whirlwind Axe"); _classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress); StatsManager statsManager = new StatsManager(plugin, _clientManager); @@ -225,6 +231,11 @@ public class ClansManager extends MiniClientPlugin implements IRelat return _itemMapManager; } + public Explosion getExplosion() + { + return _explosion; + } + public int getInviteExpire() { return _inviteExpire; @@ -258,6 +269,12 @@ public class ClansManager extends MiniClientPlugin implements IRelat return x <= FIELD_RADIUS && z <= FIELD_RADIUS; } + public boolean canUnclaimChunk(ClanInfo stealer, ClanInfo owner) + { + return owner.getClaims() > owner.getClaimsMax() + && !owner.isAdmin() && !owner.isAlly(stealer); + } + public ClanInfo getClan(Player player) { return _clanMemberMap.get(player.getName()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 856476ef5..78c7d6ebc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -30,7 +30,7 @@ public class ClansCommand extends CommandBase public ClansCommand(ClansManager plugin) { - super(plugin, Rank.ALL, "c", "clans", "factions"); + super(plugin, Rank.ALL, "c", "clan", "clans", "factions"); _manager = plugin; } @@ -703,6 +703,12 @@ public class ClansCommand extends CommandBase UtilPlayer.message(caller, F.main("Clans", F.elem("Clan " + cB.getName()) + " cannot have any more allies.")); return; } + + if (cA.isEnemy(cB.getName())) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot form an alliance with an enemy clan.")); + return; + } if (cB.isRequested(cA.getName())) { @@ -806,16 +812,16 @@ public class ClansCommand extends CommandBase if (cB.isSelf(cA.getName())) { UtilPlayer.message(caller, F.main("Clans", "You prefer to think of yourself positively...")); - return; } - - if (cB.isNeutral(cA.getName())) + else if (cB.isEnemy(cA.getName())) + { + UtilPlayer.message(caller, F.main("Clans", "You are currently enemies with " + F.elem("Clan " + cB.getName()) + ".")); + } + else if (cB.isNeutral(cA.getName())) { UtilPlayer.message(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + ".")); - return; } - - if (cB.isAlly(cA.getName())) + else if (cB.isAlly(cA.getName())) { //Task Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true); @@ -824,8 +830,6 @@ public class ClansCommand extends CommandBase UtilPlayer.message(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + ".")); cA.inform(F.name(caller.getName()) + " revoked alliance with " + F.elem("Clan " + cB.getName()) + ".", caller.getName()); cB.inform(F.elem("Clan " + cA.getName()) + " has revoked alliance with you.", null); - - return; } } @@ -904,29 +908,24 @@ public class ClansCommand extends CommandBase if (adjClan == null) continue; - // Shaun: Added true so this applies to edges as well as corners - if (true || x == 0 || z == 0) + if (checkBox(caller.getWorld().getChunkAt( + caller.getLocation().getChunk().getX()+x, + caller.getLocation().getChunk().getZ()+z), 3)) { - if (checkBox(caller.getWorld().getChunkAt( - caller.getLocation().getChunk().getX()+x, - caller.getLocation().getChunk().getZ()+z), 3)) - { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); - UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed.")); - return; - } + UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); + UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed.")); + return; + } - if (Plugin.getClanUtility().rel(clan, adjClan) == ClanRelation.SELF) - { - selfAdj = true; - } - - else if (Plugin.getClanUtility().rel(clan, adjClan) != ClanRelation.SELF) - { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory next to " + - Plugin.getClanUtility().mRel(Plugin.getClanUtility().rel(ownerClan, adjClan), adjClan.getName(), true) + ".")); - return; - } + if (Plugin.getClanUtility().rel(clan, adjClan) == ClanRelation.SELF) + { + selfAdj = true; + } + else if (Plugin.getClanUtility().rel(clan, adjClan) != ClanRelation.SELF) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory next to " + + Plugin.getClanUtility().mRel(Plugin.getClanUtility().rel(ownerClan, adjClan), adjClan.getName(), true) + ".")); + return; } } @@ -1048,8 +1047,10 @@ public class ClansCommand extends CommandBase public boolean unclaimSteal(Player caller, ClanInfo clientClan, ClanInfo ownerClan) { - if (ownerClan.getClaimsMax() >= ownerClan.getClaims() || ownerClan.isAdmin()) + if (!_manager.canUnclaimChunk(clientClan, ownerClan)) + { return false; + } //Change Inform UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java index 9560beae7..c3b22e419 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java @@ -28,11 +28,11 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.worldevent.WorldEventManager; - import net.minecraft.server.v1_7_R4.Block; import net.minecraft.server.v1_7_R4.Blocks; import net.minecraft.server.v1_7_R4.MaterialMapColor; import net.minecraft.server.v1_7_R4.PersistentCollection; +import net.minecraft.util.com.google.common.base.Objects; 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; @@ -57,7 +57,9 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; @@ -471,21 +473,32 @@ public class ItemMapManager extends MiniPlugin } @EventHandler - public void mapMoveInventories(InventoryClickEvent event) + public void preventMapMoveInventories(InventoryClickEvent event) { - ItemStack item = event.getCurrentItem(); + Inventory inv = event.getClickedInventory(); - if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId - || item.getDurability() > _mapId + 100) + if (inv == null) return; - if (event.getClickedInventory() == null || event.getClickedInventory().getHolder() instanceof Player) + // Yeah, the loop looks a little weird.. + for (ItemStack item : new ItemStack[] + { + event.getCurrentItem(), event.getCursor() + }) + { + if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId + || item.getDurability() > _mapId + 100) + continue; + + if (inv.getHolder() instanceof Player ? !event.isShiftClick() : Objects.equal(event.getCurrentItem(), item)) + continue; + + event.setCancelled(true); + + UtilPlayer.message(event.getWhoClicked(), + F.main("Inventory", "You cannot move " + F.item("Clans Map") + " between inventories.")); return; - - event.setCancelled(true); - - UtilPlayer.message(event.getWhoClicked(), - F.main("Inventory", "You cannot move " + F.item("Clans Map") + " between inventories.")); + } } @EventHandler @@ -523,6 +536,8 @@ public class ItemMapManager extends MiniPlugin || item.getDurability() > _mapId + 100) return; + event.setCancelled(true); + Player player = event.getPlayer(); MapInfo info = getMap(player); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java index 97f00b479..082dd636c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java @@ -1,11 +1,12 @@ package mineplex.game.clans.clans.map; import java.awt.Color; + import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.clans.worldevent.event.EventState; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -82,6 +83,7 @@ public class ItemMapRenderer extends MapRenderer if (owningClan != null) { + boolean colorAll = scale > 0; Color clanColor = null; if (owningClan == clan) @@ -92,6 +94,8 @@ public class ItemMapRenderer extends MapRenderer { if (owningClan.isAdmin()) { + colorAll = false; + if (owningClan.getName().equals("Shops") || owningClan.getName().equals("Spawn")) { clanColor = Color.WHITE; @@ -126,7 +130,7 @@ public class ItemMapRenderer extends MapRenderer int chunkX1 = (int) Math.floor(blockX / 16D); int chunkZ1 = (int) Math.floor(blockZ / 16D); - if ( + if (colorAll || ((chunkBX == 0 || zoom == 13) && @@ -145,7 +149,7 @@ public class ItemMapRenderer extends MapRenderer owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 + 1)))) { Color cColor = MapPalette.getColor(color); - double clans = 0.65; + double clans = colorAll ? 1 : 0.8;// 0.65; double base = 1 - clans; int r = (int) ((cColor.getRed() * base) + (clanColor.getRed() * clans)); @@ -158,7 +162,7 @@ public class ItemMapRenderer extends MapRenderer { Color cColor = MapPalette.getColor(color); - double clans = 0.4; + double clans = 0.65;// 0.4; double base = 1 - clans; int r = (int) ((cColor.getRed() * base) + (clanColor.getRed() * clans)); @@ -201,7 +205,7 @@ public class ItemMapRenderer extends MapRenderer double mapX = (point.getX() - info.getX()) / zoom; double mapZ = (point.getZ() - info.getZ()) / zoom; - // To make these appear at the edges of the map, just change it from 64 to something like 128 for double the map size + // To make these appear at the edges of the map, just change it from 64 to something like 128 for double the map size if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64) { byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D); @@ -209,7 +213,7 @@ public class ItemMapRenderer extends MapRenderer byte cursorType = 4; // http://i.imgur.com/wpH6PT8.png // Those are byte 5 and 6 - byte rotation = (byte) (int) ((point.getYaw() * 16D) / 360D); + byte rotation = (byte) ((int) Math.floor(System.currentTimeMillis() / 1000D) % 16); MapCursor cursor = new MapCursor(b0, b1, rotation, cursorType, true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 15c5d6bfa..13af8311e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -1,12 +1,24 @@ package mineplex.game.clans.clans.worldevent; import java.util.ArrayList; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Random; -import java.util.Set; + +import mineplex.core.MiniPlugin; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; +import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.loot.LootManager; +import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.damage.DamageManager; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -19,23 +31,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniPlugin; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.loot.LootManager; -import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; -import mineplex.game.clans.clans.worldevent.event.EventState; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; -import mineplex.minecraft.game.core.damage.DamageManager; - public class WorldEventManager extends MiniPlugin implements ScoreboardElement { private final List _events; @@ -145,6 +140,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { assert(event != null); + event.loadMap(); event.start(); getPlugin().getServer().getPluginManager().registerEvents(event, getPlugin()); _events.add(event); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index d2a50e064..e1598e018 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -1,17 +1,19 @@ package mineplex.game.clans.clans.worldevent; +import java.lang.reflect.Constructor; + +import mineplex.game.clans.clans.worldevent.kinghill.KingHill; +import mineplex.game.clans.clans.worldevent.undead.UndeadCamp; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; + import org.bukkit.Location; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; -import mineplex.game.clans.clans.worldevent.event.slimeking.SlimeBoss; -import mineplex.game.clans.clans.worldevent.event.kinghill.KingHill; -import mineplex.game.clans.clans.worldevent.event.undead.UndeadCamp; - public enum WorldEventType { - SLIME_KING("Slime King", SlimeBoss.class, 30), - KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), - UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30); + SLIME_KING("Slime King", SlimeBoss.class, 30), KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), UNDEAD_CAMP( + "Undead Camp", UndeadCamp.class, 30), Golem("Iron Wizard", GolemBoss.class, 30); private String _name; private Class _clazz; @@ -35,7 +37,25 @@ public enum WorldEventType try { - worldEvent = _clazz.getConstructor(WorldEventManager.class, Location.class).newInstance(eventManager, centerLocation); + for (Constructor con : _clazz.getConstructors()) + { + Class[] classes = con.getParameterTypes(); + + if (classes[0] == WorldEventManager.class) + { + worldEvent = (WorldEvent) con.newInstance(eventManager, centerLocation); + } + else if (classes.length == 4) + { + worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), + eventManager.getClans().getCondition(), centerLocation); + } + else + { + worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), + eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation); + } + } } catch (Exception e) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index 380d2f1fe..7027980c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -6,8 +6,8 @@ import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.minecraft.game.core.boss.WorldEvent; public class StartCommand extends CommandBase { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/kinghill/HillData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/HillData.java similarity index 96% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/kinghill/HillData.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/HillData.java index e32bc4b3d..ba2308ad4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/kinghill/HillData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/HillData.java @@ -1,13 +1,13 @@ -package mineplex.game.clans.clans.worldevent.event.kinghill; +package mineplex.game.clans.clans.worldevent.kinghill; import java.io.File; import java.io.IOException; -import org.bukkit.Location; - import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.UtilSchematic; +import org.bukkit.Location; + public class HillData { private Schematic _schematic; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/kinghill/KingHill.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java similarity index 83% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/kinghill/KingHill.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java index 03f1e5de7..2b9f4bd73 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/kinghill/KingHill.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java @@ -1,23 +1,26 @@ -package mineplex.game.clans.clans.worldevent.event.kinghill; +package mineplex.game.clans.clans.worldevent.kinghill; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; - +import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.worldevent.EventMap; import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.clans.worldevent.event.EventState; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; import mineplex.game.clans.economy.GoldManager; +import mineplex.minecraft.game.core.boss.EventMap; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; public class KingHill extends WorldEvent { @@ -45,7 +48,7 @@ public class KingHill extends WorldEvent public KingHill(WorldEventManager eventManager, Location centerLocation) { - super(eventManager, "King of the Hill", centerLocation); + super(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "King of the Hill", centerLocation); _clansManager = eventManager.getClans(); _scoreMap = new HashMap(); _hill = LOADED_HILLS.get(0); @@ -55,7 +58,7 @@ public class KingHill extends WorldEvent @Override protected void customStart() { - setMap(new EventMap(_hill.getSchematic(), getCenterLocation(), 10, 10, 10, 10, 10, 10), new Runnable() + setMap(new EventMap(_hill.getSchematic(), getCenterLocation()), new Runnable() { @Override public void run() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/CampSize.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java similarity index 96% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/CampSize.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java index a9bbaf4b7..7d87361c1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/CampSize.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.worldevent.event.undead; +package mineplex.game.clans.clans.worldevent.undead; import mineplex.core.common.util.UtilMath; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/CampType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampType.java similarity index 95% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/CampType.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampType.java index 4511cbe32..2ba66823f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/CampType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampType.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.worldevent.event.undead; +package mineplex.game.clans.clans.worldevent.undead; import org.bukkit.Material; import org.bukkit.material.MaterialData; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/UndeadCamp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCamp.java similarity index 94% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/UndeadCamp.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCamp.java index 2aa441594..72c07120c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/UndeadCamp.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCamp.java @@ -1,25 +1,12 @@ -package mineplex.game.clans.clans.worldevent.event.undead; +package mineplex.game.clans.clans.worldevent.undead; import java.util.HashSet; import java.util.Iterator; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.Chest; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityInteractEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - +import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; @@ -28,10 +15,20 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.clans.worldevent.event.EventState; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; -import mineplex.game.clans.clans.worldevent.event.undead.creature.UndeadArcher; -import mineplex.game.clans.clans.worldevent.event.undead.creature.UndeadWarrior; +import mineplex.game.clans.clans.worldevent.undead.creature.UndeadArcher; +import mineplex.game.clans.clans.worldevent.undead.creature.UndeadWarrior; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; public class UndeadCamp extends WorldEvent { @@ -43,10 +40,11 @@ public class UndeadCamp extends WorldEvent private final CampType _campType; private final CampSize _campSize; private HashSet _chests; + private WorldEventManager _eventManager; public UndeadCamp(WorldEventManager eventManager, Location centerLocation) { - super(eventManager, "Undead Camp", centerLocation); + super(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "Undead Camp", centerLocation); _campSize = CampSize.getCampSize(UtilServer.getPlayers().length); _campType = CampType.values()[getRandom().nextInt(CampType.values().length)]; @@ -59,6 +57,11 @@ public class UndeadCamp extends WorldEvent setName(_campSize.getName()); } + + public WorldEventManager getEventManager() + { + return _eventManager; + } @Override protected void customStart() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadArcher.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadArcher.java similarity index 89% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadArcher.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadArcher.java index 57822be24..cbb07088f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadArcher.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadArcher.java @@ -1,16 +1,15 @@ -package mineplex.game.clans.clans.worldevent.event.undead.creature; +package mineplex.game.clans.clans.worldevent.undead.creature; + +import mineplex.core.common.util.UtilMath; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Zombie; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.util.UtilMath; -import mineplex.game.clans.clans.worldevent.creature.EventCreature; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; - public class UndeadArcher extends EventCreature { public UndeadArcher(WorldEvent event, Location spawnLocation) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadWarrior.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadWarrior.java similarity index 92% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadWarrior.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadWarrior.java index e884b189c..9fa7fdbff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadWarrior.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadWarrior.java @@ -1,4 +1,12 @@ -package mineplex.game.clans.clans.worldevent.event.undead.creature; +package mineplex.game.clans.clans.worldevent.undead.creature; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; import org.bukkit.Location; import org.bukkit.Material; @@ -8,14 +16,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.creature.EventCreature; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; - public class UndeadWarrior extends EventCreature { public UndeadWarrior(WorldEvent event, Location spawnLocation) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index 38b921019..f28d0a278 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -179,8 +179,7 @@ public class GoldManager extends MiniPlugin public void deductGold(Callback resultCallback, Player player, int amount) { - _donationManager.RewardGoldLater("GoldManager", player, -amount); - _donationManager.updateGoldQueue(resultCallback, player); + _donationManager.rewardGold(resultCallback, "GoldManager", player, -amount); } public void cashIn(Player player, GoldToken token) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 2ea89a33f..0e13253bc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -20,6 +20,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.items.generation.Weight; +import mineplex.game.clans.items.generation.WeightSet; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -28,16 +30,21 @@ import org.bukkit.Sound; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -49,6 +56,7 @@ public class Gameplay extends MiniPlugin private ClansManager _clansManager; private BlockRestore _blockRestore; private DamageManager _damageManager; + private WeightSet _foodDecrease; // Weighted probability sets for food decrease event outcomes private HashMap _bucketWater = new HashMap(); @@ -59,6 +67,7 @@ public class Gameplay extends MiniPlugin _clansManager = clansManager; _blockRestore = blockRestore; _damageManager = damageManager; + _foodDecrease = new WeightSet(new Weight(50, true), new Weight(50, false)); } @EventHandler @@ -86,6 +95,21 @@ public class Gameplay extends MiniPlugin UtilInv.Update(event.getPlayer()); } + /** + * Decreases the hunger rate decrease speed by arbitrarily canceling a portion of decrease events. + * @param event + */ + @EventHandler(ignoreCancelled=true) + public void foodChangeLevel(FoodLevelChangeEvent event) + { + Player player = (Player) event.getEntity(); + + if (event.getFoodLevel() < player.getFoodLevel()) // Hunger is decreasing for player + { + event.setCancelled(_foodDecrease.generateRandom()); + } + } + @EventHandler public void BucketFill(PlayerBucketFillEvent event) { @@ -136,6 +160,28 @@ public class Gameplay extends MiniPlugin } } + @EventHandler(priority = EventPriority.LOWEST) + public void RedstoneCancel(BlockPlaceEvent event) + { + if (event.getBlock().getType().toString().startsWith("REDSTONE")) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place redstone based items.")); + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void DispenseLiquidCancel(BlockDispenseEvent event) + { + Material material = event.getItem().getType(); + + if (material == Material.LAVA_BUCKET || material == Material.LAVA + || material == Material.WATER_BUCKET || material == Material.WATER) + { + event.setCancelled(true); + } + } + @EventHandler public void WebBreak(BlockDamageEvent event) { @@ -188,6 +234,37 @@ public class Gameplay extends MiniPlugin event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.ENDER_CHEST)); } + @EventHandler + public void disableEnderPearls(PlayerInteractEvent event) + { + if (!isRightClick(event.getAction())) + return; + + if (event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot use ender pearls!")); + } + } + + @EventHandler + public void disableFlintNSteel(PlayerInteractEvent event) + { + if (!isRightClick(event.getAction())) + return; + + if (event.hasItem() && event.getItem().getType() == Material.FLINT_AND_STEEL) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot use flint & steel!")); + } + } + + private static boolean isRightClick(Action action) + { + return action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK; + } + @EventHandler public void IronDoor(PlayerInteractEvent event) { @@ -394,6 +471,19 @@ public class Gameplay extends MiniPlugin event.SetCancelled("Spawn Fall"); } + /** + * Cancel the spawning of all Witches. + * @param event + */ + @EventHandler + public void cancelWitchSpawns(EntitySpawnEvent event) + { + if (event.getEntityType() == EntityType.WITCH) + { + event.setCancelled(true); + } + } + @EventHandler public void Repair(PlayerInteractEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index 71f371d27..a50b6d18b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -10,6 +10,7 @@ import mineplex.game.clans.items.attributes.AttributeContainer; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -25,14 +26,11 @@ import org.bukkit.inventory.meta.ItemMeta; public class CustomItem { - private ItemAttribute _superPrefix; - public void setSuperPrefix(ItemAttribute attribute) { _superPrefix = attribute; } - - private ItemAttribute _prefix; - public void setPrefix(ItemAttribute attribute) { _prefix = attribute; } + private static final ChatColor TITLE_COLOR = ChatColor.GOLD; // Chat color used for item display name + private static final ChatColor ATTRIBUTE_COLOR = ChatColor.WHITE; // Chat color used for attribute descriptions - private ItemAttribute _suffix; - public void setSuffix(ItemAttribute attribute) { _suffix = attribute; } + private AttributeContainer _attributes; + public AttributeContainer getAttributes() { return _attributes; } protected String _displayName; private String _description; @@ -59,25 +57,7 @@ public class CustomItem */ public String getDisplayName() { - // Concatenate attribute prefixes/suffixes to display name. - String display = _displayName; - - if (_prefix != null) - { - display = _prefix.getDisplayName() + " " + display; - } - - if (_superPrefix != null) - { - display = _superPrefix.getDisplayName() + " " + display; - } - - if (_suffix != null) - { - display += " of " + _suffix.getDisplayName(); - } - - return display; + return ChatColor.RESET.toString() + TITLE_COLOR + _attributes.formatItemName(_displayName); } public String getDescription() @@ -87,8 +67,6 @@ public class CustomItem public List getLore() { - String serialization = GearManager.getItemSerialization(this); - List lore = new ArrayList(); if (getDescription() != null) @@ -97,20 +75,15 @@ public class CustomItem } // Display attribute descriptions and stats in lore - for (ItemAttribute attribute : getAttributes()) + for (ItemAttribute attribute : _attributes.getAttributes()) { - String attributeLine = attribute.getDisplayName() + " - " + attribute.getDescription(); + String attributeLine = ATTRIBUTE_COLOR + "-" + attribute.getDescription(); lore.add(attributeLine); } - // Tack on serialized JSON encoded line for utility purposes. (Not seen by user) - List serializedLines = new ArrayList(); - String[] seri = serialization.split("\n"); - for (String line : seri) - { - serializedLines.add(line); - } - lore.addAll(serializedLines); + // Add encoded JSON form of this item, not seen by user. + String serialization = GearManager.getItemSerialization(this); + lore.add(serialization); return lore; } @@ -131,8 +104,7 @@ public class CustomItem public void onInteract(PlayerInteractEvent event) { -// System.out.println("Triggered interact!"); - for (ItemAttribute attribute : getAttributes()) + for (ItemAttribute attribute : _attributes.getAttributes()) { attribute.onInteract(event); } @@ -140,8 +112,7 @@ public class CustomItem public void onAttack(CustomDamageEvent event) { -// System.out.println("Triggered attack!"); - for (ItemAttribute attribute : getAttributes()) + for (ItemAttribute attribute : _attributes.getAttributes()) { attribute.onAttack(event); } @@ -149,25 +120,12 @@ public class CustomItem public void onAttacked(CustomDamageEvent event) { -// System.out.println("Triggered damage!"); - for (ItemAttribute attribute : getAttributes()) + for (ItemAttribute attribute : _attributes.getAttributes()) { attribute.onAttacked(event); } } - /** - * @return the (possibly empty) set of {@link ItemAttribute}s attached to this item. - */ - public Set getAttributes() - { - Set attributes = new HashSet(); - if (_superPrefix != null) attributes.add(_superPrefix); - if (_prefix != null) attributes.add(_prefix); - if (_suffix != null) attributes.add(_suffix); - return attributes; - } - /** * @param item - the item to check for a matching link * @return true, if {@code item} matches this CustomItem via UUID, false otherwise. @@ -194,27 +152,6 @@ public class CustomItem item.setItemMeta(meta); } - - public void addAttribute(ItemAttribute attribute) - { - if (_superPrefix == null) - { - _superPrefix = attribute; - } - else if (_prefix == null) - { - _prefix = attribute; - } - else if (_suffix == null) - { - _suffix = attribute; - } - } - - public AttributeContainer cloneAttributes() - { - return new AttributeContainer(_superPrefix, _prefix, _suffix); - } public static String prettifyName(Material material) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index fd9eb3cbd..c81f22bab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -18,6 +18,7 @@ import mineplex.core.portal.TransferHandler; import mineplex.core.portal.Commands.SendCommand; import mineplex.core.portal.Commands.ServerCommand; import mineplex.game.clans.items.attributes.AttributeContainer; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.attributes.weapon.*; import mineplex.game.clans.items.attributes.armor.*; @@ -101,7 +102,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable // Armour-based attributes _armourAttributes = new WeightSet>(SlantedAttribute.class, ReinforcedAttribute.class, - ProtectionAttribute.class, PaddedAttribute.class, LavaAttribute.class); + ConqueringArmorAttribute.class, PaddedAttribute.class, LavaAttribute.class); // Bow-based attributes _bowAttributes = new WeightSet>(HeavyArrowsAttribute.class, HuntingAttribute.class, InverseAttribute.class, @@ -180,7 +181,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable { for (PlayerGear gear : _playerGears.values()) { - gear.update(); + if (gear.isOnline()) + { + gear.update(); + } + else + { + _playerGears.remove(gear.getPlayerName()); + } } } @@ -204,18 +212,11 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable { int attributeCount = _attributeWeights.generateRandom(); ItemType itemType = _typeWeights.generateRandom(); - - System.out.println("Generating item of type " + itemType.toString() + " with attribute count of " + attributeCount); CustomItem item = generateItem(itemType); - System.out.println("Generated item!"); if (itemType != ItemType.LEGENDARY) // Only non-legendaries have attributes { - for (ItemAttribute attribute : generateAttributes(itemType, attributeCount)) - { - item.addAttribute(attribute); - } - // Add up to attributeCount attributes + generateAttributes(item.getAttributes(), itemType, attributeCount); } return item; @@ -240,29 +241,41 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable } } - private Set generateAttributes(ItemType type, int count) + private void generateAttributes(AttributeContainer container, ItemType type, int count) { - Set attributes = new HashSet(); - for (int i = 0; i < count; i++) { - switch (type) + int attempts = 0; + Set remaining = container.getRemainingTypes(); + ItemAttribute attribute = null; + + while (remaining.size() > 0 && attempts < 10 && attribute == null) { - case ARMOUR: - attributes.add(instantiate(_armourAttributes.generateRandom())); - break; - case WEAPON: - attributes.add(instantiate(_weaponAttributes.generateRandom())); - break; - case BOW: - attributes.add(instantiate(_bowAttributes.generateRandom())); - break; - default: - break; + ItemAttribute sampleAttribute = null; + + switch (type) + { + case ARMOUR: + sampleAttribute = instantiate(_armourAttributes.generateRandom()); + break; + case WEAPON: + sampleAttribute = instantiate(_weaponAttributes.generateRandom()); + break; + case BOW: + sampleAttribute = instantiate(_bowAttributes.generateRandom()); + break; + default: + break; + } + + if (sampleAttribute != null && remaining.contains(sampleAttribute.getType())) + { + attribute = sampleAttribute; // Select valid attribute to add + } } + + container.addAttribute(attribute); } - - return attributes; } public void spawnItem(Location location) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java index 4e1f0514b..83ccab3de 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -69,21 +70,23 @@ public class ItemListener implements Listener * Handle the trigger of custom gear related effects and abilities. * @param event */ - @EventHandler + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerAttack(CustomDamageEvent event) { + if (event.IsCancelled()) return; // Checks for Pre-Cancelled event and stops + Player damager = event.GetDamagerPlayer(false); // For non-ranged attacks Player damagee = event.GetDamageePlayer(); Projectile projectile = event.GetProjectile(); - // Trigger custom gear effects for attacker - if (damager != null) + // Trigger custom gear effects for attacker melee weapons + if (damager != null && event.GetCause() == DamageCause.ENTITY_ATTACK) { PlayerGear attackerGear = getGear(damager); attackerGear.onAttack(event); } - // Trigger custom gear effects for defender + // Trigger custom gear effects for defender armour if (damagee != null) { PlayerGear defenderGear = getGear(damagee); @@ -126,7 +129,7 @@ public class ItemListener implements Listener if (weapon != null) { // Copy weapon attributes onto projectile for later processing - AttributeContainer attributes = weapon.cloneAttributes(); + AttributeContainer attributes = weapon.getAttributes(); String serialization = GearManager.serialize(attributes); Entity projectile = event.getProjectile(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index 25191f7b6..c05c1ad5b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -23,6 +23,7 @@ import org.bukkit.inventory.PlayerInventory; public class PlayerGear { private String _playerName; // Name of player who owns the gear + public String getPlayerName() { return _playerName; } // Cached custom item information for player's gear private CustomItem weapon; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java index 82afb586a..836665064 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java @@ -19,8 +19,10 @@ public abstract class AttackAttribute extends ItemAttribute private int _attackCount; - public AttackAttribute(int attackLimit) + public AttackAttribute(AttributeType type, int attackLimit) { + super(type); + _attackLimit = attackLimit; _attackCount = 0; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java index 2a2a46cab..a68aa36b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java @@ -6,16 +6,82 @@ import java.util.Set; public class AttributeContainer { - private Set _attributes; - public Set getAttributes() { return _attributes; } + private ItemAttribute _superPrefix; + public ItemAttribute getSuperPrefix() { return _superPrefix; } + public void setSuperPrefix(ItemAttribute attribute) { _superPrefix = attribute; } + + private ItemAttribute _prefix; + public ItemAttribute getPrefix() { return _prefix; } + public void setPrefix(ItemAttribute attribute) { _prefix = attribute; } - public AttributeContainer(ItemAttribute... attributes) + private ItemAttribute _suffix; + public ItemAttribute getSuffix() { return _suffix; } + public void setSuffix(ItemAttribute attribute) { _suffix = attribute; } + + public AttributeContainer(ItemAttribute superPrefix, ItemAttribute prefix, ItemAttribute suffix) { - _attributes = new HashSet(); - - for (ItemAttribute attribute : attributes) + _superPrefix = superPrefix; + _prefix = prefix; + _suffix = suffix; + } + + public Set getAttributes() + { + Set attributes = new HashSet(); + + if (_superPrefix != null) attributes.add(_superPrefix); + if (_prefix != null) attributes.add(_prefix); + if (_suffix != null) attributes.add(_suffix); + + return attributes; + } + + public Set getRemainingTypes() + { + Set remainingTypes = new HashSet(); + + if (_superPrefix == null) remainingTypes.add(AttributeType.SUPER_PREFIX); + if (_prefix == null) remainingTypes.add(AttributeType.PREFIX); + if (_suffix == null) remainingTypes.add(AttributeType.SUFFIX); + + return remainingTypes; + } + + public String formatItemName(String displayName) + { + String itemName = displayName; + + if (_prefix != null) { - _attributes.add(attribute); + itemName = _prefix.getDisplayName() + " " + itemName; + } + + if (_superPrefix != null) + { + itemName = _superPrefix.getDisplayName() + " " + itemName; + } + + if (_suffix != null) + { + itemName += " of " + _suffix.getDisplayName(); + } + + return itemName; + } + + public void addAttribute(ItemAttribute attribute) + { + switch(attribute.getType()) + { + case SUPER_PREFIX: + setSuperPrefix(attribute); + break; + case PREFIX: + setPrefix(attribute); + break; + case SUFFIX: + setSuffix(attribute); + break; } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeType.java new file mode 100644 index 000000000..df1a59954 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeType.java @@ -0,0 +1,8 @@ +package mineplex.game.clans.items.attributes; + +public enum AttributeType +{ + SUPER_PREFIX, + PREFIX, + SUFFIX; +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/DamageAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/DamageAttribute.java index 31c44551d..b61ef7dd7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/DamageAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/DamageAttribute.java @@ -11,8 +11,10 @@ public abstract class DamageAttribute extends ItemAttribute private double _bonusDamage; public double getBonusDamage() { return _bonusDamage; } - public DamageAttribute(ValueDistribution damageGen) + public DamageAttribute(AttributeType type, ValueDistribution damageGen) { + super(type); + _bonusDamage = damageGen.generateValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/ItemAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/ItemAttribute.java index e136ca42c..a2593c271 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/ItemAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/ItemAttribute.java @@ -14,6 +14,15 @@ import org.bukkit.event.player.PlayerInteractEvent; */ public abstract class ItemAttribute { + + private AttributeType _type; + public AttributeType getType() { return _type; } + public boolean matchesType(AttributeType type) { return _type == type; } + + public ItemAttribute(AttributeType type) + { + _type = type; + } /** * @return the attribute name display to players. @@ -24,7 +33,7 @@ public abstract class ItemAttribute * @return a user-friendly description of this attribute, entailing it's effects * and current associated values. */ - public String getDescription() { return "???IMPLEMENT"; } + public String getDescription() { return "???IMPLEMENT???"; } public void onInteract(PlayerInteractEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ConqueringArmorAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ConqueringArmorAttribute.java new file mode 100644 index 000000000..7568d7c44 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ConqueringArmorAttribute.java @@ -0,0 +1,39 @@ +package mineplex.game.clans.items.attributes.armor; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.game.clans.items.attributes.AttributeType; +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +// A.K.A Conquering for Armor +public class ConqueringArmorAttribute extends FlatReductionAttribute +{ + private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d); + private static ReductionConfig config = new ReductionConfig(); + + public ConqueringArmorAttribute() + { + super(AttributeType.SUFFIX, reductionGen, config); + } + + @Override + public String getDisplayName() + { + return "Conquering"; + } + + @Override + public String getDescription() + { + return String.format("-%.1f damage taken from mobs & bosses.", getFlatReduction()); + } + + @Override + public boolean reducesDamage(DamageCause cause, Entity attacker) + { + return attacker != null; // Reduces damage from all entities + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/EscapeAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/EscapeAttribute.java index 5e79f4679..c4f0db81e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/EscapeAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/EscapeAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.armor; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,6 +13,8 @@ public class EscapeAttribute extends ItemAttribute public EscapeAttribute() { + super(AttributeType.SUFFIX); + _healPercent = healGen.generateIntValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/FlatReductionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/FlatReductionAttribute.java index 7df8fe1c5..b78b4d143 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/FlatReductionAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/FlatReductionAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.armor; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; public abstract class FlatReductionAttribute extends ReductionAttribute @@ -8,9 +9,9 @@ public abstract class FlatReductionAttribute extends ReductionAttribute private double _reduction; public double getFlatReduction() { return _reduction; } - public FlatReductionAttribute(ValueDistribution reductionGen, ReductionConfig config) + public FlatReductionAttribute(AttributeType type, ValueDistribution reductionGen, ReductionConfig config) { - super(config); + super(type, config); _reduction = reductionGen.generateValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/LavaAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/LavaAttribute.java index 12e76c9a0..a9b01ae2c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/LavaAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/LavaAttribute.java @@ -2,6 +2,7 @@ package mineplex.game.clans.items.attributes.armor; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,8 +13,7 @@ public class LavaAttribute extends PercentReductionAttribute public LavaAttribute() { - - super(reductionGen, lavaConfig); + super(AttributeType.SUPER_PREFIX, reductionGen, lavaConfig); } @Override @@ -25,6 +25,6 @@ public class LavaAttribute extends PercentReductionAttribute @Override public String getDescription() { - return String.format("Reduce fire-related damage by %.2f percent.", getReductionPercent()); + return String.format("Reduces damage from fire and lava by %.1f%.", getReductionPercent() * 100d); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PaddedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PaddedAttribute.java index f3a4458a9..cc094a167 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PaddedAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PaddedAttribute.java @@ -2,6 +2,7 @@ package mineplex.game.clans.items.attributes.armor; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,7 +13,7 @@ public class PaddedAttribute extends FlatReductionAttribute public PaddedAttribute() { - super(reductionGen, config); + super(AttributeType.PREFIX, reductionGen, config); } @Override @@ -24,6 +25,6 @@ public class PaddedAttribute extends FlatReductionAttribute @Override public String getDescription() { - return String.format("Reduce fall damage by %.2f half-hearts.", getFlatReduction()); + return String.format("-%.1f damage taken from falls.", getFlatReduction()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PercentReductionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PercentReductionAttribute.java index aeee83b22..681324004 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PercentReductionAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PercentReductionAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.armor; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; public abstract class PercentReductionAttribute extends ReductionAttribute @@ -7,9 +8,10 @@ public abstract class PercentReductionAttribute extends ReductionAttribute private double _reductionPercent; public double getReductionPercent() { return _reductionPercent; } - public PercentReductionAttribute(ValueDistribution reductionGen, ReductionConfig config) + public PercentReductionAttribute(AttributeType type, ValueDistribution reductionGen, ReductionConfig config) { - super(config); + super(type, config); + _reductionPercent = reductionGen.generateValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ProtectionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ProtectionAttribute.java deleted file mode 100644 index ec97366ec..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ProtectionAttribute.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.game.clans.items.attributes.armor; - -import org.bukkit.entity.EntityType; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.game.clans.items.attributes.ItemAttribute; -import mineplex.game.clans.items.generation.ValueDistribution; - -// A.K.A Conquering for Armor -public class ProtectionAttribute extends FlatReductionAttribute -{ - private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d); - private static ReductionConfig config = new ReductionConfig(EntityType.values()); - - public ProtectionAttribute() - { - super(reductionGen, config); - } - - @Override - public String getDisplayName() - { - return "Protection"; - } - - @Override - public String getDescription() - { - return String.format("Reduce incoming attack damage by %.2f half-hearts.", getFlatReduction()); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java index 196f187ef..7928e1170 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java @@ -8,6 +8,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -17,8 +18,10 @@ public abstract class ReductionAttribute extends ItemAttribute private ReductionConfig _config; - public ReductionAttribute(ReductionConfig config) + public ReductionAttribute(AttributeType type, ReductionConfig config) { + super(type); + _config = config; } @@ -28,11 +31,11 @@ public abstract class ReductionAttribute extends ItemAttribute DamageCause cause = event.GetCause(); Entity attacker = event.GetDamagerEntity(true); - if (_config.reducesDamage(cause, attacker)) + if (reducesDamage(cause, attacker)) { double damage = event.GetDamage(); double reduction = getDamageReduction(damage); - event.AddMod("Reduction Armor", reduction); + event.AddMod("Reduction Armor", -reduction); System.out.println("Reduced damage by " + reduction); } else @@ -41,5 +44,10 @@ public abstract class ReductionAttribute extends ItemAttribute } } + public boolean reducesDamage(DamageCause cause, Entity attacker) + { + return _config.reducesDamage(cause, attacker); + } + public abstract double getDamageReduction(double originalDamage); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReinforcedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReinforcedAttribute.java index 17763f8af..1a982151d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReinforcedAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReinforcedAttribute.java @@ -1,7 +1,8 @@ -package mineplex.game.clans.items.attributes.armor; + package mineplex.game.clans.items.attributes.armor; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; public class ReinforcedAttribute extends FlatReductionAttribute @@ -11,7 +12,7 @@ public class ReinforcedAttribute extends FlatReductionAttribute public ReinforcedAttribute() { - super(reductionGen, config); + super(AttributeType.PREFIX, reductionGen, config); } @Override @@ -23,6 +24,6 @@ public class ReinforcedAttribute extends FlatReductionAttribute @Override public String getDescription() { - return String.format("Reduce incoming attacks by enemies by %.2f half-hearts.", getFlatReduction()); + return String.format("-%.1f damage taken from melee.", getFlatReduction()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SeaAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SeaAttribute.java index 3b90c71d6..4292b3d56 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SeaAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SeaAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.armor; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,6 +13,8 @@ public class SeaAttribute extends ItemAttribute public SeaAttribute() { + super(AttributeType.SUFFIX); + _healPercent = healGen.generateIntValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SlantedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SlantedAttribute.java index b1bcfffe7..23bd57c41 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SlantedAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SlantedAttribute.java @@ -2,6 +2,7 @@ package mineplex.game.clans.items.attributes.armor; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,7 +13,7 @@ public class SlantedAttribute extends FlatReductionAttribute public SlantedAttribute() { - super(reductionGen, config); + super(AttributeType.PREFIX, reductionGen, config); } @Override @@ -24,6 +25,6 @@ public class SlantedAttribute extends FlatReductionAttribute @Override public String getDescription() { - return String.format("Reduce arrow damage by %.2f half-hearts.", getFlatReduction()); + return String.format("-%.1f damage taken from projectiles.", getFlatReduction()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/DestructionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/DestructionAttribute.java index 88b12e450..b9586869d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/DestructionAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/DestructionAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -14,7 +15,7 @@ public class DestructionAttribute extends ItemAttribute public DestructionAttribute() { - + super(AttributeType.SUFFIX); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HeavyArrowsAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HeavyArrowsAttribute.java index 5785d0757..e69521ea8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HeavyArrowsAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HeavyArrowsAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -14,6 +15,8 @@ public class HeavyArrowsAttribute extends ItemAttribute public HeavyArrowsAttribute() { + super(AttributeType.PREFIX); + _knockbackPercent = knockbackGen.generateValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HuntingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HuntingAttribute.java index 749c56914..28e9f5257 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HuntingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/HuntingAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -19,6 +20,8 @@ public class HuntingAttribute extends ItemAttribute public HuntingAttribute() { + super(AttributeType.PREFIX); + _slowAmount = amountGen.generateIntValue(); _slowDuration = durationGen.generateValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java index 43afb72cd..4ab887df4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -14,6 +15,8 @@ private static ValueDistribution knockbackGen = generateDistribution(-0.5d, 1.0d public InverseAttribute() { + super(AttributeType.PREFIX); + _knockbackModifier = knockbackGen.generateValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java index 035a86e77..27fb2a699 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -15,6 +16,8 @@ public class LeechingAttribute extends ItemAttribute public LeechingAttribute() { + super(AttributeType.SUPER_PREFIX); + _healPercent = healGen.generateIntValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ReboundingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ReboundingAttribute.java index 8e2a404c5..51889a397 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ReboundingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ReboundingAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -14,7 +15,7 @@ public class ReboundingAttribute extends ItemAttribute public ReboundingAttribute() { - + super(AttributeType.SUPER_PREFIX); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/RecursiveAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/RecursiveAttribute.java index 5cf4e8e50..97342b5e2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/RecursiveAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/RecursiveAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.DamageAttribute; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -13,7 +14,7 @@ public class RecursiveAttribute extends DamageAttribute public RecursiveAttribute() { - super(attackGen); + super(AttributeType.PREFIX, attackGen); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java index a774cf466..54c241c17 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java @@ -1,6 +1,7 @@ package mineplex.game.clans.items.attributes.bow; import mineplex.game.clans.items.attributes.AttackAttribute; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; import org.bukkit.entity.Entity; @@ -13,7 +14,7 @@ public class ScorchingAttribute extends AttackAttribute public ScorchingAttribute() { - super(1); // Activates every hit + super(AttributeType.SUPER_PREFIX, 1); // Activates every hit _fireDuration = fireGen.generateValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SlayingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SlayingAttribute.java index a79777769..b8ddb2f6b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SlayingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SlayingAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.DamageAttribute; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -14,7 +15,7 @@ public class SlayingAttribute extends DamageAttribute public SlayingAttribute() { - super(attackGen); + super(AttributeType.SUFFIX, attackGen); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SpectralAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SpectralAttribute.java index 0d7e03087..3107b5614 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SpectralAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/SpectralAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -14,7 +15,7 @@ public class SpectralAttribute extends ItemAttribute public SpectralAttribute() { - + super(AttributeType.SUPER_PREFIX); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java index 08f0d8bbc..aefc18270 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.weapon; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.DamageAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,7 +13,7 @@ public class ConqueringAttribute extends DamageAttribute public ConqueringAttribute() { - super(damageGen); + super(AttributeType.SUFFIX, damageGen); } @Override @@ -24,7 +25,7 @@ public class ConqueringAttribute extends DamageAttribute @Override public String getDescription() { - return String.format("Deal an extra %.2f hearts of damage to mobs.", getBonusDamage()); + return String.format("%.2f bonus damage against mobs & bosses.", getBonusDamage()); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FlamingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FlamingAttribute.java index 8783a8043..770eaca23 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FlamingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FlamingAttribute.java @@ -1,6 +1,7 @@ package mineplex.game.clans.items.attributes.weapon; import mineplex.game.clans.items.attributes.AttackAttribute; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; import org.bukkit.entity.Entity; @@ -14,20 +15,20 @@ public class FlamingAttribute extends AttackAttribute public FlamingAttribute() { - super(attackGen.generateIntValue()); + super(AttributeType.SUPER_PREFIX, attackGen.generateIntValue()); _fireDuration = fireGen.generateIntValue(); } @Override public String getDisplayName() { - return "Flaming"; // TODO: Fill in name + return "Flaming"; } @Override public String getDescription() { - return String.format("Enemies catch fire for %d ticks every %d attacks.", _fireDuration, getAttackLimit()); + return String.format("Every %d attacks gives Fire for %.1f seconds.", getAttackLimit(), (_fireDuration / 20d)); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FrostedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FrostedAttribute.java index ef5d4ac95..8bb79a2ac 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FrostedAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FrostedAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.weapon; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -28,6 +29,8 @@ public class FrostedAttribute extends ItemAttribute */ public FrostedAttribute() { + super(AttributeType.SUPER_PREFIX); + _slowAmount = amountGen.generateIntValue(); _slowDuration = durationGen.generateIntValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HasteAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HasteAttribute.java index 5ffff8639..960e8b2ad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HasteAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HasteAttribute.java @@ -1,6 +1,7 @@ package mineplex.game.clans.items.attributes.weapon; import mineplex.game.clans.items.attributes.AttackAttribute; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; import org.bukkit.entity.Entity; @@ -20,7 +21,7 @@ public class HasteAttribute extends AttackAttribute public HasteAttribute() { - super(attackGen.generateIntValue()); + super(AttributeType.SUFFIX, attackGen.generateIntValue()); _speedAmount = speedGen.generateIntValue(); _speedDuration = durationGen.generateIntValue(); @@ -35,7 +36,7 @@ public class HasteAttribute extends AttackAttribute @Override public String getDescription() { - return String.format("Gain speed %s for %d ticks every %d attacks.", amplifierToRoman(_speedAmount), _speedDuration, getAttackLimit()); + return String.format("Every %d attacks gives you Speed %s for %.1f seconds.", getAttackLimit(), amplifierToRoman(_speedAmount), (_speedDuration / 20f)); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HeavyAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HeavyAttribute.java index 338950352..0f85c87dd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HeavyAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HeavyAttribute.java @@ -1,25 +1,39 @@ package mineplex.game.clans.items.attributes.weapon; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class HeavyAttribute extends ItemAttribute { - // TODO: Replace with your generators - private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount + private static ValueDistribution knockbackGen = generateDistribution(25, 75); // Value generator for knockback % boost. - private int _healPercent; + private double _knockbackBoost; public HeavyAttribute() { - _healPercent = healGen.generateIntValue(); + super(AttributeType.PREFIX); + + _knockbackBoost = knockbackGen.generateValue(); } @Override public String getDisplayName() { - return ""; // TODO: Fill in name + return "Heavy"; + } + + @Override + public String getDescription() + { + return String.format("%.1f% additional knockback.", _knockbackBoost); } - + @Override + public void onAttack(CustomDamageEvent event) + { + double knockback = (_knockbackBoost / 100d) * event.getKnockbackValue(); + event.AddKnockback("Heavy Attribute", knockback); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java index 073ee1c39..f233c2913 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java @@ -1,6 +1,7 @@ package mineplex.game.clans.items.attributes.weapon; import mineplex.game.clans.items.attributes.AttackAttribute; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; import org.bukkit.entity.Entity; @@ -12,7 +13,7 @@ public class JaggedAttribute extends AttackAttribute public JaggedAttribute() { - super(attackGen.generateIntValue()); + super(AttributeType.PREFIX, attackGen.generateIntValue()); } @Override @@ -24,7 +25,7 @@ public class JaggedAttribute extends AttackAttribute @Override public String getDescription() { - return String.format("Temporarily halt enemies every %d attacks.", getAttackLimit()); + return String.format("Every %d attacks mini-stuns enemies.", getAttackLimit()); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SharpAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SharpAttribute.java index ef28a3695..73c0260e7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SharpAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SharpAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.weapon; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.DamageAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -11,7 +12,7 @@ public class SharpAttribute extends DamageAttribute public SharpAttribute() { - super(damageGen); + super(AttributeType.PREFIX, damageGen); } @Override @@ -23,7 +24,7 @@ public class SharpAttribute extends DamageAttribute @Override public String getDescription() { - return String.format("Deal an extra %.2f damage.", getBonusDamage()); + return String.format("%.2f bonus damage.", getBonusDamage()); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SmashingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SmashingAttribute.java index 0a50290aa..6dc1833b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SmashingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SmashingAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.weapon; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,6 +13,7 @@ public class SmashingAttribute extends ItemAttribute public SmashingAttribute() { + super(AttributeType.SUFFIX); _healPercent = healGen.generateIntValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SwiftAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SwiftAttribute.java index 1cfce1379..587fb09b1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SwiftAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SwiftAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.weapon; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -12,6 +13,8 @@ public class SwiftAttribute extends ItemAttribute public SwiftAttribute() { + super(AttributeType.PREFIX); + _healPercent = healGen.generateIntValue(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/VampiricAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/VampiricAttribute.java index cffa42840..b3813cf47 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/VampiricAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/VampiricAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.weapon; +import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -15,6 +16,8 @@ public class VampiricAttribute extends ItemAttribute public VampiricAttribute() { + super(AttributeType.SUPER_PREFIX); + _healPercent = healGen.generateIntValue(); } @@ -27,7 +30,7 @@ public class VampiricAttribute extends ItemAttribute @Override public String getDescription() { - return String.format("Heal yourself for %d percentage of damage dealt to enemy players.", _healPercent); + return String.format("Heal yourself for %d% of damage dealt.", _healPercent); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/AlligatorsTooth.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/AlligatorsTooth.java index 568240b4b..8926bb09c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/AlligatorsTooth.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/AlligatorsTooth.java @@ -7,6 +7,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; public class AlligatorsTooth extends LegendaryItem @@ -29,9 +30,15 @@ public class AlligatorsTooth extends LegendaryItem @Override public void update(Player wielder) { - if (isHoldingRightClick() && isInWater(wielder)) + if (isInWater(wielder)) { - propelPlayer(wielder); + // Player gain water breathing while under water with legendary equipped + grantPotionEffect(wielder, PotionEffectType.WATER_BREATHING, 0, 50); + + if (isHoldingRightClick()) + { + propelPlayer(wielder); + } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java index 05621969e..8754f065f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java @@ -14,6 +14,10 @@ import org.bukkit.potion.PotionEffectType; public class GiantsBroadsword extends LegendaryItem { + public static final int SLOW_AMPLIFIER = 4; + public static final int REGEN_AMPLIFIER = 1; + public static final int EFFECT_DURATION = 10; // Duration of potion effect (in ticks) + public GiantsBroadsword() { super("Giants Broadsword", "Deal huge damage and block to gain defensive abilities!", Material.RECORD_4); @@ -38,17 +42,7 @@ public class GiantsBroadsword extends LegendaryItem private void buffPlayer(Player player) { - player.addPotionEffects(generateBlockBuff()); - } - - private Set generateBlockBuff() - { - Set potions = new HashSet(); - - // Slow 5 and Regen 1 for 5 ticks - potions.add(new PotionEffect(PotionEffectType.SLOW, 4, 5)); - potions.add(new PotionEffect(PotionEffectType.REGENERATION, 0, 5)); - - return potions; + grantPotionEffect(player, PotionEffectType.SLOW, 4, 10); + grantPotionEffect(player, PotionEffectType.REGENERATION, 1, 10); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java index 3257e5811..82f95e210 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -5,6 +5,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import mineplex.game.clans.items.CustomItem; import mineplex.game.clans.items.generation.ValueDistribution; @@ -77,4 +79,17 @@ public class LegendaryItem extends CustomItem { return new ValueDistribution(minValue, maxValue); } + + /** + * Add a {@link PotionEffect} to {@code player} with specified {@code type}, {@code amplifier} (power) and + * {@code tickDuration} of the effect. + * @param player - the player to receive the potion effect + * @param type - the type of potion to apply + * @param tickDuration - the duration (in ticks) to apply the potion for + * @param amplifier - the amplifier (level/power, zero-based) of the potion effect + */ + public static void grantPotionEffect(Player player, PotionEffectType type, int tickDuration, int amplifier) + { + player.addPotionEffect(new PotionEffect(type, amplifier, tickDuration)); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticBlade.java index a368a99ae..85486e9a2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticBlade.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticBlade.java @@ -7,6 +7,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.util.Vector; @@ -26,7 +27,7 @@ public class MagneticBlade extends LegendaryItem { if (isHoldingRightClick() && canPull()) { - pullPlayers(wielder); + pullEntities(wielder); } } @@ -38,23 +39,24 @@ public class MagneticBlade extends LegendaryItem // TODO: Apply negative knockback with [???] velocity/power to victims of attacks } - private void pullPlayers(Player player) - { - log("Pulling players!"); + private void pullEntities(Player player) + { Vector direction = player.getLocation().getDirection().normalize().multiply(10.0d); Location target = player.getEyeLocation().add(direction); double targetDistance = player.getLocation().distance(target); - for (Player other : player.getWorld().getPlayers()) + for (LivingEntity entity : player.getWorld().getLivingEntities()) { - double otherDistance = player.getLocation().distance(other.getLocation()); - double otherTargetDistance = target.distance(other.getLocation()); + if (entity.getEntityId() == player.getEntityId()) continue; // Skip player pulling + + double otherDistance = player.getLocation().distance(entity.getLocation()); + double otherTargetDistance = target.distance(entity.getLocation()); // If player is in-front of us and within pulling range if (otherTargetDistance < targetDistance && otherDistance <= PULL_RANGE) { - UtilAction.velocity(other, UtilAlg.getTrajectory(other, player), 0.3, false, 0, 0, 1, true); + UtilAction.velocity(entity, UtilAlg.getTrajectory(entity, player), 0.3, false, 0, 0, 1, true); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java index 95a5a4c7b..fbc0abe19 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java @@ -49,6 +49,7 @@ public class WindBlade extends LegendaryItem direction.multiply(FLIGHT_VELOCITY); // Set velocity magnitude player.setVelocity(direction); + player.setFallDistance(0f); // To prevent bug with fall distances killing players inappropriately. } private boolean canPropel() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java index 45ec9a154..5e00d6962 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java @@ -87,7 +87,7 @@ public class BankPage extends ShopPageBase private void buildTransferGemsCooldown() { - StoreGoldButton button = new StoreGoldButton(this); + DisplayButton button = new DisplayButton(); String title = ChatColor.RED + C.Bold + "Conversion Cooldown!"; String purchaseString = ChatColor.RESET + C.cWhite + "You have already converted gems into coins today"; ShopItem shopItem = new ShopItem(Material.REDSTONE_BLOCK, title, new String[] {" ", purchaseString, " "}, 0, true, true); @@ -112,7 +112,7 @@ public class BankPage extends ShopPageBase int playerGold = getPlayerGold(); int goldCost = TOKEN_VALUE; - StoreGoldButton button = new StoreGoldButton(this); + DisplayButton button = new DisplayButton(); String title = ChatColor.RED + C.Bold + "Missing Gold!"; String playerGoldString = ChatColor.RESET + F.value("Your Gold", playerGold + "g"); String purchaseString = ChatColor.RESET + C.cWhite + "You don't have enough gold"; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/DisplayButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/DisplayButton.java new file mode 100644 index 000000000..f2e04bb5e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/DisplayButton.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.shop.bank; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.game.clans.economy.GoldManager; + +public class DisplayButton implements IButton +{ + + public DisplayButton() + { + + } + + @Override + public void onClick(Player player, ClickType clickType) + { + // Display button doesn't activate any on click events + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 67dcdba3e..a2a5d1e1b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -6,16 +6,25 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.items.generation.WeightSet; public class Spawn extends MiniPlugin @@ -48,12 +57,78 @@ public class Spawn extends MiniPlugin } } + /** + * Prevent {@link ItemFrame}s from being broken inside Spawn. + * @param event + */ + @EventHandler + public void onItemFrameDestroyed(HangingBreakByEntityEvent event) + { + if (event.getEntity() instanceof ItemFrame) + { + if (isInSpawn(event.getEntity().getLocation())) + { + event.setCancelled(true); + } + } + } + @EventHandler public void onRespawn(PlayerRespawnEvent event) { event.setRespawnLocation(getSpawnLocation()); } + @EventHandler + public void onPlayerFirstJoin(PlayerJoinEvent event) + { + if (!event.getPlayer().hasPlayedBefore()) // First time playing on server, teleport to a spawn + { + teleport(event.getPlayer(), getSpawnLocation(), 2); // Teleport player to spawn after 2-tick delay to prevent on-join bug + } + } + + @EventHandler + public void onEntitySpawn(EntitySpawnEvent event) + { + if (isInSpawn(event.getLocation())) + { + event.setCancelled(true); + } + } + + /** + * Despawns any monsters within a spawn zone every two seconds. + * @param event + */ + @EventHandler + public void onUpdateTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TWOSEC) return; + + for (LivingEntity entity : getSpawnWorld().getLivingEntities()) + { + if (entity instanceof Monster) + { + Monster monster = (Monster) entity; + + if (isInSpawn(monster.getLocation())) + { + monster.remove(); + } + } + } + } + + @EventHandler + public void onEntityTarget(EntityTargetEvent event) + { + if (event.getTarget() != null && isInSpawn(event.getTarget().getLocation())) + { + event.setCancelled(true); + } + } + @EventHandler public void onBlockBreak(BlockBreakEvent event) { @@ -151,4 +226,14 @@ public class Spawn extends MiniPlugin { } + + private void teleport(final Player player, final Location location, int delay) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { + @Override + public void run() { + player.teleport(location); + } + }, delay); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index d78ba70fb..8890b8e4b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -31,6 +31,7 @@ import mineplex.core.packethandler.PacketHandler; import mineplex.core.party.PartyManager; import mineplex.core.personalServer.PersonalServerManager; import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -45,9 +46,9 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; +import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import mineplex.hub.modules.StackerManager; -import mineplex.hub.poll.PollManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -65,23 +66,26 @@ import mineplex.minecraft.game.core.fire.Fire; public class Hub extends JavaPlugin implements IRelation { private String WEB_CONFIG = "webServer"; - - @Override + + @Override public void onEnable() { getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); saveConfig(); - + String webServerAddress = getConfig().getString(WEB_CONFIG); - + //Logger.initialize(this); - + + //Velocity Fix + new VelocityFix(this); + //Static Modules CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); - + ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); VisibilityManager.Initialize(this); Give.Initialize(this); @@ -90,7 +94,7 @@ public class Hub extends JavaPlugin implements IRelation DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); new ServerConfiguration(this, clientManager); - + //Other Modules PacketHandler packetHandler = new PacketHandler(this); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); @@ -100,31 +104,32 @@ public class Hub extends JavaPlugin implements IRelation NpcManager npcManager = new NpcManager(this, creature); PetManager petManager = new PetManager(this, clientManager, donationManager, disguiseManager, creature, blockRestore, webServerAddress); PollManager pollManager = new PollManager(this, clientManager, donationManager); - + //Main Modules ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); - + Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); - + IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); - FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); - + FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + StatsManager statsManager = new StatsManager(this, clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager); - + PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); - - HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this)); + + PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); Chat chat = new Chat(this, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); - new MemoryFix(this); + new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); new TablistFix(this); @@ -136,21 +141,20 @@ public class Hub extends JavaPlugin implements IRelation } }); //new Replay(this, packetHandler); - new PersonalServerManager(this, clientManager); - + AprilFoolsManager.Initialize(this, clientManager, disguiseManager); - + CombatManager combatManager = new CombatManager(this); - + ProjectileManager throwManager = new ProjectileManager(this); SkillConditionManager conditionManager = new SkillConditionManager(this); - + DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); Fire fire = new Fire(this, conditionManager, damage); - Teleport teleport = new Teleport(this); + Teleport teleport = new Teleport(this); Energy energy = new Energy(this); energy.setEnabled(false); - + ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager, webServerAddress); SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, disguiseManager, blockRestore, fire, new Movement(this), teleport, energy, webServerAddress); ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, webServerAddress); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index b5987a194..8d58d26b1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -25,6 +25,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -66,87 +67,97 @@ import mineplex.core.gadget.event.GadgetActivateEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.message.PrivateMessageEvent; import mineplex.core.mount.MountManager; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.notifier.NotificationManager; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; +import mineplex.core.personalServer.PersonalServerManager; import mineplex.core.pet.PetManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; +import mineplex.core.reward.RewardManager; import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; import mineplex.core.treasure.TreasureManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.bonuses.BonusManager; +import mineplex.hub.commands.DisguiseCommand; import mineplex.hub.commands.ForcefieldRadius; import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.NewsCommand; import mineplex.hub.modules.ForcefieldManager; +import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.JumpManager; +import mineplex.hub.modules.KothManager; import mineplex.hub.modules.NewsManager; import mineplex.hub.modules.ParkourManager; +import mineplex.hub.modules.SoccerManager; import mineplex.hub.modules.TextManager; -import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.WorldManager; -import mineplex.hub.poll.PollManager; +import mineplex.core.poll.PollManager; +import mineplex.hub.profile.gui.GUIProfile; import mineplex.hub.tutorial.TutorialManager; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class HubManager extends MiniClientPlugin { // ☃❅ Snowman! - public HubType Type = HubType.Normal; - + public HubType Type = HubType.Normal; + private BlockRestore _blockRestore; private CoreClientManager _clientManager; private ConditionManager _conditionManager; private DonationManager _donationManager; private DisguiseManager _disguiseManager; - private PartyManager _partyManager; - private ForcefieldManager _forcefieldManager; - private Portal _portal; - private StatsManager _statsManager; + private PartyManager _partyManager; + private ForcefieldManager _forcefieldManager; + private PollManager _pollManager; + private Portal _portal; + private StatsManager _statsManager; private GadgetManager _gadgetManager; private MountManager _mountManager; - private HubVisibilityManager _visibilityManager; - private TutorialManager _tutorialManager; + private HubVisibilityManager _visibilityManager; + private TutorialManager _tutorialManager; private TextManager _textCreator; - private ParkourManager _parkour; - private PreferencesManager _preferences; + private ParkourManager _parkour; + private PreferencesManager _preferences; private InventoryManager _inventoryManager; private NewsManager _news; private AchievementManager _achievementManager; private TreasureManager _treasureManager; private PetManager _petManager; + private PacketHandler _packetHandler; + private PersonalServerManager _personalServerManager; private Location _spawn; private int _scoreboardTick = 0; private HashMap _scoreboards = new HashMap(); - private String _pigStacker = "0 - Nobody"; private String _serverName = ""; - - private ItemStack _ruleBook = null; private boolean _shuttingDown; private HashMap _portalTime = new HashMap(); - + private HashMap> _creativeAdmin = new HashMap>(); //Admin private boolean _gadgetsEnabled = true; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler) { super("Hub Manager", plugin); @@ -155,7 +166,9 @@ public class HubManager extends MiniClientPlugin _conditionManager = conditionManager; _donationManager = donationManager; _disguiseManager = disguiseManager; - + _pollManager = pollManager; + _personalServerManager = personalServerManager; + _portal = portal; _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); @@ -168,171 +181,48 @@ public class HubManager extends MiniClientPlugin new WorldManager(this); new JumpManager(this); //new TournamentInviter(this); - + + _news = new NewsManager(this); _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _inventoryManager = new InventoryManager(plugin, clientManager); new BenefitManager(plugin, clientManager, _inventoryManager); - _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin)); - _treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager); + _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager); + + _treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); + new SoccerManager(this, _gadgetManager); + new KothManager(this, _gadgetManager); + _petManager = petManager; _partyManager = partyManager; _preferences = preferences; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); _visibilityManager = new HubVisibilityManager(this); - + _forcefieldManager = new ForcefieldManager(this); addCommand(new ForcefieldRadius(_forcefieldManager)); - + _statsManager = statsManager; _achievementManager = achievementManager; _achievementManager.setGiveInterfaceItem(true); - + _packetHandler = packetHandler; + new NotificationManager(getPlugin(), clientManager); ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; + + new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager); + + // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); - - _ruleBook = ItemStackFactory.Instance.CreateStack(Material.WRITTEN_BOOK, (byte)0, 1, ChatColor.GREEN + "Rule Book", new String[] { }); - BookMeta meta = (BookMeta)_ruleBook.getItemMeta(); + _serverName = getPlugin().getConfig().getString("serverstatus.name"); _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); - - meta.addPage("§m-------------------§r\n" - + "Welcome to §6§lMineplex§r\n" - + "§r§0§l§r§m§0§m-------------------§r§0\n" - + "\n" - + "§2Please §0take a moment to read through this book!\n" - + "\n" - + "\n" - + "Part 1 - Rules\n" - + "\n" - + "Part 2 - FAQ\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l1.§§§r §4No§r spamming.\n" - + "\n" - + "§0This is sending too many messages and/or repeating the same message in a short period of time.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l2.§m§r §4No§0 use of excessive caps.\n" - + "\n" - + "This is sending messages with an excessive amount of capital letters.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l3.§r §4No§0 hacking or use of any unapproved mods.\n" - + "\n" - + "This means we do not tolerate any sort of hacked client or any unapproved mods, such as fly hacks.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l4.§r §4No§0 advertising non-Mineplex related links.\n" - + "\n" - + "This is when a link is sent in chat which directs others to non-Mineplex related content.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l5.§r §4No§0 trolling or use of any exploits.\n" - + "\n" - + "This means that abuse of bugs/glitches is not tolerated. You also may not do things such as teamkilling and/or blocking spawns.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§l6.§r §2Be§0 respectful to others, yourself, and the environment around you.\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lRules§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§rPlease report any bugs, exploits, and/or rule breakers on our forums with evidence.\n" - + "§omineplex.com/forums\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lWhat is stacker and how do you play it?\n" - + "\n" - + "§rStacker is a hub game where you can stack & throw players/mobs.\n" - + "\n" - + "§9Right-Click: pick up\n" - + "Left-Click: throw\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lHow do I get §bUltra§l, §5Hero§l, or §aLegend§l?\n" - + "\n" - + "§r§0You are able to purchase these ranks through our shop on our website at:\n" - + "\n" - + "§owww.mineplex.com/shop\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lWhy hasn't my rank been applied yet?\n" - + "\n" - + "§m§rYour rank may take a while to be applied. If it has been over 24 hours please contact:\n" - + "\n" - + "§omineplex.com/support\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lWhat do I do if I was wrongfully punished?\n" - + "\n" - + "§0If you believe you were wrongfully punished, please submit an appeal at:\n" - + "\n" - + "§omineplex.com/appeals\n"); - - meta.addPage("§m-------------------\n" - + "§r §2§lFAQ§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "§lHow do I apply for Trainee?\n" - + "\n" - + "§rYou may only apply for Helper if you have §bUltra§0, §5Hero§0, or §aLegend§0.\n" - + "Apply at:\n" - + "§omineplex.com/application\n"); - - meta.addPage("§m-------------------\n" - + "§r §6§lThank you for \n" - + " reading!§r§0\n" - + "§m-------------------\n" - + "§r\n" - + "Remember to visit our website §2mineplex.com§0 for important news & updates!\n" - + "\n" - + "\n" - + "§c§lH§6§lA§a§lV§9§lE §c§lF§6§lU§a§lN§9§l!\n"); - - // These are needed or 1.8 clients will not show book correctly - meta.setTitle("Rule Book"); - meta.setAuthor("Mineplex"); - - _ruleBook.setItemMeta(meta); } @Override @@ -341,6 +231,7 @@ public class HubManager extends MiniClientPlugin addCommand(new GadgetToggle(this)); addCommand(new NewsCommand(this)); addCommand(new GameModeCommand(this)); + addCommand(new DisguiseCommand(this)); } @EventHandler(priority = EventPriority.HIGHEST) @@ -351,7 +242,7 @@ public class HubManager extends MiniClientPlugin event.setMotd("Restarting soon"); } } - + public boolean BumpDisabled(Entity ent) { if (ent == null) @@ -361,54 +252,54 @@ public class HubManager extends MiniClientPlugin { return !_preferences.Get((Player)ent).HubGames; } - + return true; } - + @EventHandler public void SnowballPickup(BlockDamageEvent event) { if (Type != HubType.Christmas) return; - + if (event.getBlock().getType() != Material.SNOW) return; - + Player player = event.getPlayer(); - + _gadgetManager.RemoveItem(player); - + player.getInventory().setItem(3, new ItemStack(Material.SNOW_BALL, 16)); } - + @EventHandler public void SnowballHit(CustomDamageEvent event) { if (Type != HubType.Christmas) return; - + Projectile proj = event.GetProjectile(); if (proj == null) return; if (!(proj instanceof Snowball)) return; - + event.SetCancelled("Snowball Cancel"); - + if (BumpDisabled(event.GetDamageeEntity())) return; - + if (BumpDisabled(event.GetDamagerEntity(true))) return; - - UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()), + + UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()), 0.4, false, 0, 0.2, 1, false); - + //No Portal SetPortalDelay(event.GetDamageeEntity()); } - + @EventHandler public void redirectStopCommand(PlayerCommandPreprocessEvent event) { @@ -495,12 +386,15 @@ public class HubManager extends MiniClientPlugin @EventHandler(priority = EventPriority.LOW) public void AdminOP(PlayerJoinEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.OWNER)) + // Give developers operator on their servers + boolean testServer = _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + + if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.OWNER) || (testServer && (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER) || _clientManager.Get(event.getPlayer()).GetRank() == Rank.JNR_DEV))) event.getPlayer().setOp(true); else event.getPlayer().setOp(false); } - + @EventHandler public void PlayerRespawn(PlayerRespawnEvent event) { @@ -519,32 +413,29 @@ public class HubManager extends MiniClientPlugin //Public Message event.setJoinMessage(null); - + // if (_clientManager.Get(player).GetRank() != Rank.LEGEND) // event.setJoinMessage(null); // else // { // event.setJoinMessage(C.cGreen + C.Bold + "Legend " + playerName + " has joined!"); // } - + //Teleport player.teleport(GetSpawn().add(0, 10, 0)); - + //Survival player.setGameMode(GameMode.SURVIVAL); - + //Clear Inv UtilInv.Clear(player); - + //Allow Double Jump player.setAllowFlight(true); - + //Health player.setHealth(20); - //Rules - player.getInventory().setItem(2, _ruleBook); - //Scoreboard Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); player.setScoreboard(board); @@ -588,14 +479,6 @@ public class HubManager extends MiniClientPlugin } } - - @EventHandler - public void PlayerDeath(PlayerDeathEvent event) - { - //XXX make this work > event.setKeepInventory(true); - event.getDrops().clear(); - } - @EventHandler public void PlayerQuit(PlayerQuitEvent event) { @@ -611,7 +494,7 @@ public class HubManager extends MiniClientPlugin _portalTime.remove(event.getPlayer().getName()); } - + @EventHandler public void playerPrivateMessage(PrivateMessageEvent event) { @@ -628,7 +511,7 @@ public class HubManager extends MiniClientPlugin { if (event.isCancelled()) return; - + //Dont Let Chat Near Spawn! if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.HELPER)) { @@ -636,21 +519,24 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); return; } - + Player player = event.getPlayer(); String playerName = player.getName(); - + // April Fools if (AprilFoolsManager.Instance.isActive()) playerName = AprilFoolsManager.Instance.getName(player); Rank rank = GetClients().Get(player).GetRank(); + if(GetClients().Get(player).isDisguised()) + rank = GetClients().Get(player).getDisguisedRank(); + boolean ownsUltra = _donationManager.Get(player.getName()).OwnsUltraPackage(); //Level Prefix String levelStr = _achievementManager.getMineplexLevel(player, rank); - + //Rank Prefix String rankStr = ""; if (rank != Rank.ALL) @@ -685,7 +571,7 @@ public class HubManager extends MiniClientPlugin } return; - } + } else { for (Player other : UtilServer.getPlayers()) @@ -719,6 +605,20 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); } + @EventHandler(priority = EventPriority.LOWEST) + public void handleDeath(PlayerDeathEvent event) + { + event.setKeepInventory(true); + event.getDrops().clear(); + event.getEntity().setHealth(20); + event.getEntity().teleport(GetSpawn()); + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.None); + } @EventHandler public void FoodHealthUpdate(UpdateEvent event) @@ -802,14 +702,14 @@ public class HubManager extends MiniClientPlugin obj.setDisplayName(C.cWhite + C.Bold + Get(player).GetScoreboardText()); int line = 15; - + //Stacker obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--); obj.getScore(_serverName).setScore(line--); - + //Space obj.getScore(" ").setScore(line--); - + //Gems obj.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); // Remove Old/Add New @@ -825,16 +725,16 @@ public class HubManager extends MiniClientPlugin // Remove Old player.getScoreboard().resetScores(Get(player.getName()).GetLastCoinCount() + ""); - // Add New + // Add New obj.getScore(GetDonation().Get(player.getName()).getCoins() + "").setScore(line--); Get(player.getName()).SetLastCoinCount(GetDonation().Get(player.getName()).getCoins()); - + //Space obj.getScore(" ").setScore(line--); - - + + //Display Rank obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--); if (GetClients().Get(player).GetRank().Has(Rank.ULTRA)) @@ -847,7 +747,7 @@ public class HubManager extends MiniClientPlugin obj.getScore("Single Ultra").setScore(line--); else obj.getScore("No Rank").setScore(line--); - + //Space obj.getScore(" ").setScore(line--); @@ -895,6 +795,11 @@ public class HubManager extends MiniClientPlugin return _gadgetManager; } + public TreasureManager GetTreasure() + { + return _treasureManager; + } + public MountManager GetMount() { return _mountManager; @@ -909,12 +814,12 @@ public class HubManager extends MiniClientPlugin { return _preferences; } - + public Location GetSpawn() { return _spawn.clone(); } - + public PetManager getPetManager() { return _petManager; @@ -934,7 +839,7 @@ public class HubManager extends MiniClientPlugin { return _visibilityManager; } - + @EventHandler(priority = EventPriority.MONITOR) public void gadgetCollide(GadgetCollideEntityEvent event) { @@ -992,7 +897,7 @@ public class HubManager extends MiniClientPlugin return _gadgetsEnabled; } - + public NewsManager GetNewsManager() { return _news; @@ -1010,24 +915,24 @@ public class HubManager extends MiniClientPlugin public void ToggleGadget(Player caller) { _gadgetsEnabled = !_gadgetsEnabled; - + if (!_gadgetsEnabled) { GetMount().DisableAll(); GetGadget().DisableAll(); } - + for (Player player : UtilServer.getPlayers()) player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled")); } - + @EventHandler public void GadgetActivate(GadgetActivateEvent event) { if (!_gadgetsEnabled) event.setCancelled(true); } - + @EventHandler public void MountActivate(MountActivateEvent event) { @@ -1039,7 +944,7 @@ public class HubManager extends MiniClientPlugin { if (!_creativeAdmin.containsKey(caller.getName())) _creativeAdmin.put(caller.getName(), new ArrayList()); - + if (target.getGameMode() == GameMode.CREATIVE) { _creativeAdmin.get(caller.getName()).add(target.getName()); @@ -1049,24 +954,38 @@ public class HubManager extends MiniClientPlugin _creativeAdmin.get(caller.getName()).remove(target.getName()); } } - + @EventHandler public void clearGameMode(PlayerQuitEvent event) { ArrayList creative = _creativeAdmin.remove(event.getPlayer().getName()); - + if (creative == null) return; - + for (String name : creative) { Player player = UtilPlayer.searchExact(name); if (player == null) continue; - + player.setGameMode(GameMode.SURVIVAL); - + UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false))); } } + + public PacketHandler getPacketHandler() + { + return _packetHandler; + } + + @EventHandler + public void openProfile(PlayerInteractEvent event) + { + if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) + return; + + new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java index a8216b3fe..5c09e8423 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java @@ -33,33 +33,6 @@ public class HubRepository public void initialize(boolean us) { _us = us; - - PreparedStatement preparedStatement = null; - - try (Connection connection = DBPool.MINEPLEX.getConnection()) - { - // Create table - preparedStatement = connection.prepareStatement(CREATE_NEWS_TABLE); - preparedStatement.execute(); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } } public HashMap retrieveNewsEntries() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java new file mode 100644 index 000000000..0402366e7 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -0,0 +1,355 @@ +package mineplex.hub.commands; + +import java.lang.reflect.Field; +import java.util.UUID; + +import mineplex.core.NCPDataManFix; +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.ProfileLoader; +import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.donation.Donor; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation; +import net.minecraft.util.com.mojang.authlib.GameProfile; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scoreboard.Team; + +import com.mysql.jdbc.BalanceStrategy; + +public class DisguiseCommand extends CommandBase implements Listener +{ + + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + + public DisguiseCommand(HubManager plugin) + { + super(plugin, Rank.JNR_DEV, new Rank[] + { + Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + new NCPDataManFix(); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if(args == null) + { + if(!Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); + + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(caller, playerName); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(caller)) + { + team.removePlayer(caller); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + if(args != null && args.length > 1) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + return; + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + for(Player other : UtilServer.getPlayers()) + { + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.Has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0]); + + Plugin.GetGadget().RemoveItem(caller); + + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); + } + + @EventHandler + public void updateDisguises(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; + + for(Player other : UtilServer.getPlayers()) + { + try + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(player)) + { + team.removePlayer(player); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); + } + } + + public void changeName(Player player, String changedName) + { + try + { + Field name = GameProfile.class.getDeclaredField("name"); + Field declaredProfile = EntityHuman.class.getDeclaredField("i"); + declaredProfile.setAccessible(true); + GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } + } + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java index 810e964d8..2d99ce5d7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java @@ -10,7 +10,7 @@ public class GadgetToggle extends CommandBase { public GadgetToggle(HubManager plugin) { - super(plugin, Rank.ADMIN, new String[] {"gadget"}); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, new String[] {"gadget"}); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java index 7900e79ee..4416e7b15 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java @@ -13,7 +13,7 @@ public class GameModeCommand extends CommandBase { public GameModeCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, new String[] {"gm"}); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, new String[] {"gm"}); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java index dd1e33d77..a9e6cf029 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java @@ -10,7 +10,7 @@ public class NewsCommand extends MultiCommandBase { public NewsCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, "news"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "news"); AddCommand(new NewsAddCommand(plugin)); AddCommand(new NewsDeleteCommand(plugin)); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java index e3ca7c240..fa32eb919 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java @@ -19,7 +19,7 @@ public class NewsListCommand extends CommandBase { public NewsListCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, "list"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "list"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index 425ce1a0f..07caf2363 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().Get(player).HubForcefield && Manager.GetClients().Get(player).GetRank().Has(Rank.ADMIN)) + if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().Has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV)) { for (Player other : UtilServer.getPlayers()) { @@ -56,7 +56,7 @@ public class ForcefieldManager extends MiniPlugin if (UtilMath.offset(other, player) > range) continue; - if (Manager.GetClients().Get(other).GetRank().Has(Rank.ADMIN)) + if (Manager.GetClients().Get(other).GetRank().Has(Rank.ADMIN) || Manager.GetClients().Get(other).GetRank() == Rank.JNR_DEV) continue; if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java new file mode 100644 index 000000000..373bb1e5d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java @@ -0,0 +1,270 @@ +package mineplex.hub.modules; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.gadgets.ItemDuelingSword; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import mineplex.hub.modules.koth.CapturePoint; + +public class KothManager extends MiniPlugin +{ + public HubManager Manager; + + private HashSet _active = new HashSet(); + + private ArrayList _teamArmor = new ArrayList(); + private ItemDuelingSword _kothSword; + + private Location _cornerPlayerA; + private Location _cornerPlayerB; + + private Location _cornerHillA; + private Location _cornerHillB; + + private CapturePoint _cp; + + Color _hillOwner = null; + long _hillOwnTime = 0; + + public KothManager(HubManager manager, GadgetManager gadgets) + { + super("KOTH Manager", manager.getPlugin()); + + Manager = manager; + + _cornerPlayerA = new Location(Manager.GetSpawn().getWorld(), -52.5,0,-23.5); + _cornerPlayerB = new Location(Manager.GetSpawn().getWorld(), -133.5,200,80.5); + + _cornerHillA = new Location(Manager.GetSpawn().getWorld(), -88.5,60,47.5); + _cornerHillB = new Location(Manager.GetSpawn().getWorld(), -102.5,80,61.5); + + _cp = new CapturePoint(this, "Desert Pyramid", new Location(Manager.GetSpawn().getWorld(), -95.5,72,54.5)); + + //Store Gadgets + for (Gadget gadget : gadgets.getGadgets(GadgetType.Costume)) + { + if (gadget instanceof OutfitTeam) + { + _teamArmor.add((OutfitTeam)gadget); + } + } + + for (Gadget gadget : gadgets.getGadgets(GadgetType.Item)) + { + if (gadget instanceof ItemDuelingSword) + { + _kothSword = (ItemDuelingSword)gadget; + } + } + } + + @EventHandler + public void cpUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + _cp.captureUpdate(); + } + + public Color getTeamColor(Player player) + { + //All peices are always same color! + for (OutfitTeam outfit : _teamArmor) + { + if (outfit.IsActive(player)) + return outfit.getTeamColor(player); + } + + return null; + } + + public boolean inPlayerArena(Entity entity) + { + return UtilAlg.inBoundingBox(entity.getLocation(), _cornerPlayerA, _cornerPlayerB); + } + + @EventHandler + public void joinLeaveGame(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (_active.contains(player)) + { + if (!inPlayerArena(player)) + { + setKOTHMode(player, false, null); + continue; + } + + //Took armor off + Color color = getTeamColor(player); + if (color == null) + { + setKOTHMode(player, false, null); + } + } + else + { + if (inPlayerArena(player)) + { + Color color = getTeamColor(player); + + //Join + if (color != null) + { + setKOTHMode(player, true, color); + continue; + } + //Eject + else if (UtilAlg.inBoundingBox(player.getLocation(), _cornerHillA, _cornerHillB)) + { + Location bounce = UtilAlg.getMidpoint(_cornerHillA, _cornerHillB); + bounce.setY(Math.min(_cornerHillA.getY(), _cornerHillB.getY())); + + Entity bottom = player; + if (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(bounce, player.getLocation()), 1.2, false, 0, 0.6, 1, true); + + if (Recharge.Instance.use(player, "KOTH Eject", 5000, false, false)) + { + UtilPlayer.message(player, F.main("KOTH", "You must be wearing a Team Outfit.")); + UtilPlayer.message(player, F.main("KOTH", "Type " + F.elem("/team red|yellow|green|blue") + "!")); + } + } + } + } + } + } + + public void setKOTHMode(Player player, boolean enabled, Color color) + { + if (enabled) + { + _kothSword.Enable(player); + + _active.add(player); + + if (color == null) + UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("KOTH Mode") + ".")); + else if (color == Color.RED) + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cRed + "Red KOTH Team") + ".")); + else if (color == Color.AQUA) + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cAqua + "Blue KOTH Team") + ".")); + else if (color == Color.LIME) + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cGreen + "Green KOTH Team") + ".")); + else if (color == Color.YELLOW) + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cYellow + "Yellow KOTH Team") + ".")); + + ArrayList outfit = new ArrayList(); + outfit.add("Team Helmet"); + outfit.add("Team Shirt"); + outfit.add("Team Pants"); + outfit.add("Team Boots"); + outfit.add("PvP Sword"); + + Manager.GetGadget().DisableAll(player, outfit); + Manager.GetMount().DisableAll(player); + Manager.getPetManager().DisableAll(player); + } + else + { + _kothSword.Disable(player); + _active.remove(player); + UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("KOTH Mode") + ".")); + } + } + + public boolean isKothMode(Player player) + { + return _active.contains(player); + } + + @EventHandler + public void disableGadgets(GadgetActivateEvent event) + { + if (isKothMode(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void disableMounts(MountActivateEvent event) + { + if (isKothMode(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void disableStacker(PlayerInteractEntityEvent event) + { + if (_active.contains(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _active.remove(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void allowDamage(EntityDamageByEntityEvent event) + { + if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player)) + return; + + Player damager = (Player)event.getDamager(); + Player damagee = (Player)event.getEntity(); + + if (!_active.contains(damager) || !_active.contains(damagee)) + return; + + if (getTeamColor(damager) == null || getTeamColor(damagee) == null) + return; + + if (getTeamColor(damager) == getTeamColor(damagee)) + return; + + event.setCancelled(false); + + event.setDamage(3.5); + } + + public HashSet getActive() + { + return _active; + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 727b3c312..efc323beb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -58,7 +58,7 @@ public class NewsManager extends MiniPlugin "News Line 3", "News Line 4", }; - + RefreshNews(); } @@ -77,15 +77,8 @@ public class NewsManager extends MiniPlugin for (Iterator iterator = newsEntries.keySet().iterator(); iterator.hasNext();) { int newsPos = Integer.parseInt(iterator.next()); - - ChatColor col = ChatColor.RED; - if (newsPos == 1) col = ChatColor.GOLD; - else if (newsPos == 2) col = ChatColor.YELLOW; - else if (newsPos == 3) col = ChatColor.GREEN; - else if (newsPos == 4) col = ChatColor.AQUA; - else if (newsPos == 5) col = ChatColor.LIGHT_PURPLE; - - newsStrings[newsPos - 1] = col + C.Bold + "MINEPLEX" + ChatColor.RESET + " - " + newsEntries.get(newsPos + ""); + + newsStrings[newsPos - 1] = newsEntries.get(newsPos + ""); if (newsStrings[newsPos - 1].length() > 64) newsStrings[newsPos - 1] = newsStrings[newsPos - 1].substring(0, 64); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index 8110f0cef..76c1b72d0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -470,15 +470,4 @@ public class ParkourManager extends MiniPlugin } } } - -// @EventHandler -// public void snakeUpdate(UpdateEvent event) -// { -// if (event.getType() != UpdateType.FASTER) -// return; -// -// for (ParkourData parkour : _parkour) -// if (parkour instanceof ParkourSnake) -// ((ParkourSnake)parkour).Update(); -// } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java new file mode 100644 index 000000000..3fde170ec --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -0,0 +1,533 @@ +package mineplex.hub.modules; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.bukkit.EntityEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.util.Vector; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; + +public class SoccerManager extends MiniPlugin +{ + public HubManager Manager; + + private HashSet _active = new HashSet(); + + private ArrayList _teamArmor = new ArrayList(); + + private Location _cornerFieldPlayerA; + private Location _cornerFieldPlayerB; + + private Location _cornerGoalPlayerA; + private Location _cornerGoalPlayerB; + + private Location _cornerFieldA; + private Location _cornerFieldB; + + private Location _cornerRedGoalA; + private Location _cornerRedGoalB; + + private Location _cornerBlueGoalA; + private Location _cornerBlueGoalB; + + int _blueGoals = 0; + int _redGoals = 0; + + int _insideGoalTicks = 0; + + private Slime _ball; + private Vector _ballVel; + private long _ballDeadTime = -1; + + private String _lastKicker = ""; + private Color _lastKick = null; + + //Item Rebound + protected Vector _vel; + protected Location _lastLoc; + protected ArrayList _velHistory = new ArrayList(); + + public SoccerManager(HubManager manager, GadgetManager gadgets) + { + super("Football Manager", manager.getPlugin()); + + Manager = manager; + + _cornerFieldPlayerA = new Location(Manager.GetSpawn().getWorld(), 28.5,70,-27.5); + _cornerFieldPlayerB = new Location(Manager.GetSpawn().getWorld(), 50.5,100,-65.5); + + _cornerGoalPlayerA = new Location(Manager.GetSpawn().getWorld(), 35.5,70,-24.5); + _cornerGoalPlayerB = new Location(Manager.GetSpawn().getWorld(), 43.5,100,-68.5); + + _cornerFieldA = new Location(Manager.GetSpawn().getWorld(), 29.75,70,-28.75); + _cornerFieldB = new Location(Manager.GetSpawn().getWorld(), 49.25,100,-64.25); + + _cornerRedGoalA = new Location(Manager.GetSpawn().getWorld(), 36.75,70,-64.25); + _cornerRedGoalB = new Location(Manager.GetSpawn().getWorld(), 42.25,73.5,-67.25); + + _cornerBlueGoalA = new Location(Manager.GetSpawn().getWorld(), 36.75,70,-25.75); + _cornerBlueGoalB = new Location(Manager.GetSpawn().getWorld(), 42.25,73.5,-28.75); + + //Store Gadgets + for (Gadget gadget : gadgets.getGadgets(GadgetType.Costume)) + { + if (gadget instanceof OutfitTeam) + { + _teamArmor.add((OutfitTeam)gadget); + } + } + } + + @EventHandler + public void ballUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (_active.size() <= 0) + { + _blueGoals = 0; + _redGoals = 0; + + if (_ball != null) + _ball.remove();; + + return; + } + + //New Ball Needed + if (_ballDeadTime == -1 && (_ball == null || !_ball.isValid())) + { + if (_ball != null) + _ball.remove(); + + _ballDeadTime = System.currentTimeMillis(); + } + + //Spawn Ball + if (_ballDeadTime > 0 && UtilTime.elapsed(_ballDeadTime, 4000)) + { + Location mid = UtilAlg.getMidpoint(_cornerFieldPlayerA, _cornerFieldPlayerB); + + if (!mid.getChunk().isLoaded()) + return; + + _ball = mid.getWorld().spawn(mid, Slime.class); + _ball.setSize(2); + + UtilEnt.Vegetate(_ball); + UtilEnt.ghost(_ball, true, false); + + _ballVel = new Vector(0,-0.1,0); + + UtilFirework.playFirework(mid, Type.BALL, Color.YELLOW, false, false); + + _ballDeadTime = -1; + + _vel = new Vector(0,-0.1,0); + _velHistory.add(_vel); + _lastLoc = _ball.getLocation(); + } + + if (_ball == null) + return; + + if (_lastKick == Color.AQUA) + { + for (int i = 0 ; i < 3 ; i++) + UtilParticle.PlayParticle(ParticleType.RED_DUST, _ball.getLocation().add(0.0, 0.5, 0.0), -1, 1, 1, 1, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + for (int i = 0 ; i < 3 ; i++) + UtilParticle.PlayParticle(ParticleType.RED_DUST, _ball.getLocation().add(0.0, 0.5, 0.0), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + + //Kick + for (Player player : _active) + { + if (UtilMath.offset(player, _ball) < 1.5 || + UtilMath.offset(player.getEyeLocation(), _ball.getLocation()) < 1.25) + { + if (Recharge.Instance.use(player, "Football Kick", 600, false, false)) + { + _ballVel = player.getLocation().getDirection(); + _ballVel.setY(_ballVel.getY() + 0.4); + + if (UtilEnt.isGrounded(_ball) && _ballVel.getY() <= 0) + _ballVel.setY(0); + + _ballVel.setY(Math.min(_ballVel.getY(), 1)); + + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + + UtilParticle.PlayParticle(ParticleType.SLIME, + UtilAlg.getMidpoint(_ball.getLocation(), player.getLocation()), + 0, 0, 0, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers()); + + UtilAction.zeroVelocity(player); + + _lastKick = getTeamColor(player); + if (_lastKick == null) + _lastKicker = player.getName(); + else if (_lastKick == Color.RED) + _lastKicker = C.cRed + player.getName(); + else if (_lastKick == Color.AQUA) + _lastKicker = C.cAqua + player.getName(); + } + } + } + + //Blue Goal + if (UtilAlg.inBoundingBox(_ball.getLocation(), _cornerRedGoalA, _cornerRedGoalB) && + !UtilAlg.inBoundingBox(_ball.getLocation(), _cornerFieldA, _cornerFieldB)) + { + + _insideGoalTicks++; + + if (_insideGoalTicks > 3) + { + UtilFirework.playFirework(_ball.getLocation(), Type.BALL, Color.AQUA, true, true); + + _blueGoals++; + + for (Player player : _active) + UtilTextMiddle.display("Goal! (" + C.cRed + _redGoals + C.cWhite + " : " + C.cBlue + _blueGoals + C.cWhite + ")", + _lastKicker + C.cWhite + " scored for " + C.cAqua + "Blue Team", 0, 70, 20, player); + + _ball.remove(); + _ball = null; + } + + + + return; + } + + //Red Goal + else if (UtilAlg.inBoundingBox(_ball.getLocation(), _cornerBlueGoalA, _cornerBlueGoalB) && + !UtilAlg.inBoundingBox(_ball.getLocation(), _cornerFieldA, _cornerFieldB)) + { + _insideGoalTicks++; + + if (_insideGoalTicks > 3) + { + UtilFirework.playFirework(_ball.getLocation(), Type.BALL, Color.RED, true, true); + + _redGoals++; + + for (Player player : _active) + UtilTextMiddle.display("Goal! (" + C.cRed + _redGoals + C.cWhite + " : " + C.cBlue + _blueGoals + C.cWhite + ")", + _lastKicker + C.cWhite + " scored for " + C.cRed + "Red Team", 0, 70, 20, player); + + _ball.remove(); + _ball = null; + } + + return; + } + else + { + _insideGoalTicks = 0; + } + + //Wind Drag + _ballVel = _ballVel.multiply(0.99); + + //Ground Drag + if (UtilEnt.isGrounded(_ball)) + _ballVel = _ballVel.multiply(0.98); + + //Rebound Y + if (UtilEnt.isGrounded(_ball)) + { + if (_ballVel.getY() < -0.1) + { + _ballVel.setY(_ballVel.getY() * -0.65); + } + } + + //Gravity + if (!UtilEnt.isGrounded(_ball)) + _ballVel.setY(_ballVel.getY() - 0.04); + + //Rebound X + if ((_ballVel.getX() > 0 && _ball.getLocation().getX() > Math.max(_cornerFieldA.getX(), _cornerFieldB.getX())) || + (_ballVel.getX() < 0 && _ball.getLocation().getX() < Math.min(_cornerFieldA.getX(), _cornerFieldB.getX()))) + { + _ballVel.setX(_ballVel.getX() * -1); + + _ballVel = _ballVel.multiply(0.9); + + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + + //Rebound Z + if ((_ballVel.getZ() > 0 && _ball.getLocation().getZ() > Math.max(_cornerFieldA.getZ(), _cornerFieldB.getZ())) || + (_ballVel.getZ() < 0 && _ball.getLocation().getZ() < Math.min(_cornerFieldA.getZ(), _cornerFieldB.getZ()))) + { + _ballVel.setZ(_ballVel.getZ() * -1); + + _ballVel = _ballVel.multiply(0.9); + + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + + //Move Ball + _ball.setVelocity(_ballVel); + } + + public Color getTeamColor(Player player) + { + //All peices are always same color! + for (OutfitTeam outfit : _teamArmor) + { + if (outfit.IsActive(player)) + return outfit.getTeamColor(player); + } + + return null; + } + + public boolean inPlayerArena(Entity entity) + { + return UtilAlg.inBoundingBox(entity.getLocation(), _cornerFieldPlayerA, _cornerFieldPlayerB) || + UtilAlg.inBoundingBox(entity.getLocation(), _cornerGoalPlayerA, _cornerGoalPlayerB); + } + + @EventHandler + public void clean(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + for (Entity ent : _cornerFieldA.getWorld().getEntities()) + { + if (ent instanceof Player) + continue; + + if (_ball != null && _ball.equals(ent)) + continue; + + if (inPlayerArena(ent)) + { + if (ent instanceof Bat || ent instanceof WitherSkull || ent instanceof TNTPrimed) + { + ent.remove(); + continue; + } + + Location bounce = UtilAlg.getMidpoint(_cornerFieldPlayerA, _cornerFieldPlayerB); + bounce.setY(Math.min(_cornerFieldPlayerA.getY(), _cornerFieldPlayerB.getY())); + + Entity bottom = ent; + if (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction.velocity(bottom, UtilAlg.getTrajectory(bounce, ent.getLocation()), 1, false, 0, 0.4, 1, true); + } + } + } + + @EventHandler + public void joinLeaveGame(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (_active.contains(player)) + { + if (!inPlayerArena(player)) + { + setSoccerMode(player, false, null); + continue; + } + + //Took armor off + Color color = getTeamColor(player); + if (color == null || (color != Color.RED && color != Color.AQUA)) + { + setSoccerMode(player, false, null); + } + } + else + { + if (inPlayerArena(player)) + { + Color color = getTeamColor(player); + + //Join + if (color != null && (color == Color.RED || color == Color.AQUA) && _active.size() < 8) + { + setSoccerMode(player, true, color); + } + //Eject + else + { + Location bounce = UtilAlg.getMidpoint(_cornerFieldPlayerA, _cornerFieldPlayerB); + bounce.setY(Math.min(_cornerFieldPlayerA.getY(), _cornerFieldPlayerB.getY())); + + Entity bottom = player; + if (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(bounce, player.getLocation()), 1, false, 0, 0.8, 1, true); + + if (Recharge.Instance.use(player, "Soccer Eject", 5000, false, false)) + { + if (_active.size() < 8) + { + UtilPlayer.message(player, F.main("Slimeball", "You must be wearing Red/Blue Team Outfit.")); + UtilPlayer.message(player, F.main("Slimeball", "Type " + F.elem("/team red") + " or " + F.elem("/team blue") + "!")); + } + else + { + UtilPlayer.message(player, F.main("Slimeball", "The game is currently full!")); + } + } + } + } + } + } + } + + public void setSoccerMode(Player player, boolean enabled, Color color) + { + if (enabled) + { + _active.add(player); + + if (color == null) + UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Slimeball Mode") + ".")); + else if (color == Color.RED) + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cRed + "Red Slimeball Team") + ".")); + else if (color == Color.AQUA) + UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cAqua + "Blue Slimeball Team") + ".")); + + ArrayList outfit = new ArrayList(); + outfit.add("Team Helmet"); + outfit.add("Team Shirt"); + outfit.add("Team Pants"); + outfit.add("Team Boots"); + + Manager.GetGadget().DisableAll(player, outfit); + Manager.GetMount().DisableAll(player); + Manager.getPetManager().DisableAll(player); + } + else + { + _active.remove(player); + UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Slimeball Mode") + ".")); + } + } + + public boolean isSoccerMode(Player player) + { + return _active.contains(player); + } + + @EventHandler + public void disableGadgets(GadgetActivateEvent event) + { + if (isSoccerMode(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void disableMounts(MountActivateEvent event) + { + if (isSoccerMode(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerGrabSlime(PlayerInteractEntityEvent event) + { + if (_active.contains(event.getPlayer())) + event.setCancelled(true); + + if (_ball != null && event.getRightClicked().equals(_ball)) + event.setCancelled(true); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _active.remove(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void allowDamage(EntityDamageByEntityEvent event) + { + if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player)) + return; + + Player damager = (Player)event.getDamager(); + Player damagee = (Player)event.getEntity(); + + if (!_active.contains(damager) || !_active.contains(damagee)) + return; + + if (getTeamColor(damager) == null || getTeamColor(damagee) == null) + return; + + if (getTeamColor(damager) == getTeamColor(damagee)) + return; + + if (Recharge.Instance.use(damagee, "Football Damage", 800, false, false)) + { + UtilAction.velocity(damagee, UtilAlg.getTrajectory2d(damager, damagee), 0.6, false, 0, 0.3, 1, true); + + damagee.playEffect(EntityEffect.HURT); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index c7b57d2e4..ed43ae6d2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -28,6 +28,8 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.event.StackerEvent; +import mineplex.core.gadget.gadgets.MorphBlock; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileUser; @@ -105,15 +107,33 @@ public class StackerManager extends MiniPlugin implements IThrown return; } + if (Manager.GetGadget().getActive(stacker, GadgetType.Morph) instanceof MorphBlock) + { + UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack while using the Block Morph.")); + return; + } + + if (Manager.GetTreasure().isOpening(stacker)) + return; + stackerEvent = new StackerEvent(stackee); Bukkit.getServer().getPluginManager().callEvent(stackerEvent); if (stackerEvent.isCancelled()) return; - if (stackee instanceof Player && !Manager.CanBump(((Player)stackee))) + if (stackee instanceof Player) { - UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is not playing stacker.")); - return; + if (!Manager.CanBump(((Player)stackee))) + { + UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is not playing stacker.")); + return; + } + + if (Manager.GetTreasure().isOpening((Player) stackee)) + { + UtilPlayer.message(stacker, F.main("Stacker", F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is opening a chest!"))); + return; + } } if (stackee instanceof LivingEntity) @@ -235,7 +255,7 @@ public class StackerManager extends MiniPlugin implements IThrown Manager.SetPortalDelay(rider); rider.leaveVehicle(); - rider.setVelocity(new Vector(0.25 - Math.random()/2, Math.random()/2, 0.25 - Math.random()/2)); + UtilAction.velocity(rider, new Vector(0.25 - Math.random()/2, Math.random()/2, 0.25 - Math.random()/2)); rider = rider.getPassenger(); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index f63d53001..4ef748120 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -37,7 +37,10 @@ import org.bukkit.entity.Snowman; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.LeavesDecayEvent; @@ -103,9 +106,8 @@ public class WorldManager extends MiniPlugin Location loc = Manager.GetSpawn(); - if (r > 0.75) loc = new Location(Manager.GetSpawn().getWorld(), -9, 72, 42); - else if (r > 0.5) loc = new Location(Manager.GetSpawn().getWorld(), -36, 72, -28); - else if (r > 0.25) loc = new Location(Manager.GetSpawn().getWorld(), 31, 72, -34); + if (r > 0.66) loc = new Location(Manager.GetSpawn().getWorld(), -9, 72, 42); + else if (r > 0.33) loc = new Location(Manager.GetSpawn().getWorld(), -36, 72, -28); else loc = new Location(Manager.GetSpawn().getWorld(), 43, 72, 5); //Spawn @@ -148,6 +150,18 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } + + @EventHandler + public void BlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockIgnite(BlockIgniteEvent event) + { + event.setCancelled(true); + } @EventHandler(priority = EventPriority.LOWEST) public void Explosion(EntityExplodeEvent event) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/koth/CapturePoint.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/koth/CapturePoint.java new file mode 100644 index 000000000..1a2177ce1 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/koth/CapturePoint.java @@ -0,0 +1,389 @@ +package mineplex.hub.modules.koth; + +import java.util.ArrayList; +import java.util.Collection; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.hub.modules.KothManager; + +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +public class CapturePoint +{ + private KothManager Host; + + private String _name; + + //Locations + private ArrayList _floor = new ArrayList(); + private ArrayList _indicators = new ArrayList(); + private Location _loc; + + //Capture + private double _captureMax = 24; + private double _captureRate = 1; + private double _captureAmount = 0; + + private Color _owner = null; + private boolean _captured = false; + + private ArrayList _captureFloor = new ArrayList(); + private long _decayDelay = 0; + + private int _indicatorTick = 0; + + public CapturePoint(KothManager host, String name, Location loc) + { + Host = host; + + _name = name; + + for (int x=-3 ; x<= 3 ; x++) + { + for (int z=-3 ; z<= 3 ; z++) + { + //Indicators + if (Math.abs(x) == 3 && Math.abs(z) == 3) + { + Block ind = loc.getBlock().getRelative(x, 3, z); + ind.setType(Material.WOOL); + ind.setData((byte) 0); + _indicators.add(ind); + } + + //Floors + if (Math.abs(x) <= 2 && Math.abs(z) <= 2) + { + if (x != 0 || z != 0) + { + Block floor = loc.getBlock().getRelative(x, -2, z); + floor.setType(Material.WOOL); + floor.setData((byte) 0); + _floor.add(floor); + } + else + { + Block block = loc.getBlock().getRelative(x, -2, z); + block.setType(Material.BEACON); + } + } + + //Glass + if (Math.abs(x) <= 2 && Math.abs(z) <= 2) + { + Block block = loc.getBlock().getRelative(x, -1, z); + block.setType(Material.STAINED_GLASS); + block.setData((byte) 0); + } + + //Iron + if (Math.abs(x) <= 1 && Math.abs(z) <= 1) + { + Block block = loc.getBlock().getRelative(x, -3, z); + block.setType(Material.IRON_BLOCK); + } + } + } + + //Firework + _loc = loc; + } + + public void captureUpdate() + { + //Who's on the CP? + ArrayList red = new ArrayList(); + ArrayList yellow = new ArrayList(); + ArrayList green = new ArrayList(); + ArrayList blue = new ArrayList(); + + ArrayList players = new ArrayList(); + + for (Player player : Host.getActive()) + { + Color team = Host.getTeamColor(player); + + if (team == null) + continue; + + if (Math.abs(_loc.getX() - player.getLocation().getX()) > 2.5) + continue; + + if (Math.abs(_loc.getY() - player.getLocation().getY()) > 2.5) + continue; + + if (Math.abs(_loc.getZ() - player.getLocation().getZ()) > 2.5) + continue; + + if (team == Color.RED) + { + red.add(player); + } + else if (team == Color.YELLOW) + { + yellow.add(player); + } + else if (team == Color.LIME) + { + green.add(player); + } + else if (team == Color.AQUA) + { + blue.add(player); + } + + players.add(player); + } + + //No one around (DEGENERATE CAPTURE) + if (players.isEmpty()) + { + if (_captureAmount > 0) + regenDegen(); + + return; + } + + //Capture + if (red.size() > players.size() - red.size()) + capture(Color.RED, red.size() - (players.size() - red.size()), red); + + else if (yellow.size() > players.size() - yellow.size()) + capture(Color.YELLOW, yellow.size() - (players.size() - yellow.size()), yellow); + + else if (green.size() > players.size() - green.size()) + capture(Color.LIME, green.size() - (players.size() - green.size()), green); + + else if (blue.size() > players.size() - blue.size()) + capture(Color.AQUA, blue.size() - (players.size() - blue.size()), blue); + } + + private void regenDegen() + { + if (!UtilTime.elapsed(_decayDelay, 1000)) + return; + + //Degen + if (!_captured || Host.getActive().isEmpty()) + { + _captureAmount = Math.max(0, (_captureAmount - (_captureRate*1))); + + //Floor Color + while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) > _captureAmount/_captureMax) + { + Block block = _captureFloor.remove(UtilMath.r(_captureFloor.size())); + + _floor.add(block); + + setWoolColor(block, null, false); + } + + //Set Uncaptured + if (_captureAmount == 0) + { + _owner = null; + + _loc.getBlock().getRelative(BlockFace.DOWN).setData((byte)0); + + //Indicators + for (Block block : _indicators) + { + block.setData((byte)0); + } + } + + //Effect + for (Block block : _indicators) + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 35); + } + //Regen + else if (_captureAmount < _captureMax) + { + _captureAmount = Math.min(_captureMax, (_captureAmount + (_captureRate*1))); + + //Floor Color + while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) < _captureAmount/_captureMax) + { + Block block = _floor.remove(UtilMath.r(_floor.size())); + + _captureFloor.add(block); + + setWoolColor(block, _owner, false); + } + + //Effect + indicate(_owner); + } + } + + private void capture(Color team, int count, Collection capturers) + { + //Decay Delay + _decayDelay = System.currentTimeMillis(); + + //Count Up + if (_owner != null && _owner.equals(team)) + { + //Given if the other team hadnt actually captured it fully + int bonus = 0; + if (_captured) + bonus = 1; + + _captureAmount = Math.min(_captureMax, (_captureAmount + ((_captureRate*count)+bonus))); + + //Floor Color + while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) < _captureAmount/_captureMax) + { + Block block = _floor.remove(UtilMath.r(_floor.size())); + + _captureFloor.add(block); + + setWoolColor(block, team, false); + } + + //Set Fully Captured + if (_captureAmount == _captureMax && !_captured) + { + _captured = true; + + //Firework + UtilFirework.playFirework(_loc, FireworkEffect.builder().flicker(true).withColor(team).with(Type.BALL_LARGE).trail(true).build()); + + //Indicators + indicate(team); + + for (Block block : _indicators) + { + if (team == Color.RED) + block.setData((byte) 14); + else if (team == Color.YELLOW) + block.setData((byte) 4); + else if (team == Color.LIME) + block.setData((byte) 5); + else if (team == Color.AQUA) + block.setData((byte) 3); + } + + //Center + setWoolColor(_loc.getBlock().getRelative(0, -2, 0), _owner, true); + + String teamName = C.cRed + "Red"; + if (team == Color.YELLOW) teamName = C.cYellow + "Yellow"; + if (team == Color.LIME) teamName = C.cGreen + "Green"; + if (team == Color.AQUA) teamName = C.cAqua + "Blue"; + + for (Player player : Host.getActive()) + UtilTextMiddle.display("KOTH", teamName + " Team captured the Hill!", 0, 60, 10, player); + } + } + //Count Down + else + { + //Given if the other team hadnt actually captured it fully + int bonus = 0; + if (!_captured) + bonus = 1; + + _captureAmount = Math.max(0, (_captureAmount - ((_captureRate*count)+bonus))); + + //Floor Color + while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) > _captureAmount/_captureMax) + { + Block block = _captureFloor.remove(UtilMath.r(_captureFloor.size())); + + _floor.add(block); + + setWoolColor(block, null, false); + } + + //Set Uncaptured + if (_captureAmount == 0) + { + _captured = false; + _owner = team; + + //Center + setWoolColor(_loc.getBlock().getRelative(0, -2, 0), null, true); + + //Indicators + for (Block block : _indicators) + { + block.setData((byte)0); + } + } + } + + if (_captureAmount != _captureMax) + { + indicate(team); + } + + } + + private void setWoolColor(Block block, Color color, boolean glassOnly) + { + if (color == null) + { + if (!glassOnly) + block.setData((byte)0); + + block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)0, true); + } + else if (color == Color.RED) + { + if (!glassOnly) + block.setData((byte)14); + + block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)14, true); + } + else if (color == Color.YELLOW) + { + if (!glassOnly) + block.setData((byte)4); + + block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)4, true); + } + else if (color == Color.LIME) + { + if (!glassOnly) + block.setData((byte)5); + + block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)5, true); + } + else if (color == Color.AQUA) + { + if (!glassOnly) + block.setData((byte)3); + + block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)3, true); + } + } + + private void indicate(Color color) + { + //Effect + for (Block block : _indicators) + { + if (color == Color.RED) + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); + else if (color == Color.YELLOW) + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.GOLD_BLOCK); + else if (color == Color.LIME) + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.EMERALD_BLOCK); + else if (color == Color.AQUA) + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIAMOND_BLOCK); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonMPS.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonMPS.java new file mode 100644 index 000000000..00135e777 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonMPS.java @@ -0,0 +1,60 @@ +package mineplex.hub.profile.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.profile.gui.GUIProfile; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class ButtonMPS implements GuiItem +{ + + private GUIProfile _profile; + private Player _player; + + public ButtonMPS(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getPersonalManager().showHostMessage(_player); + } + + @Override + public ItemStack getObject() + { + return ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, + ChatColor.RESET + C.cYellow + "Mineplex Player Server", + new String[] + { + "", + C.cWhite + "Create a server where you are the Host.", + C.cWhite + "You can choose the game, map and much more!", + "", + C.cWhite + "Type " + C.cGreen + "/mps" + C.cWhite + " to access this anywhere!" + }); + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java new file mode 100644 index 000000000..38652a7c7 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java @@ -0,0 +1,61 @@ +package mineplex.hub.profile.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.profile.gui.GUIProfile; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class ButtonPrefs implements GuiItem +{ + + private GUIProfile _profile; + private Player _player; + + public ButtonPrefs(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getPrefManager().openShop(_player); + } + + @Override + public ItemStack getObject() + { + return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, + ChatColor.RESET + C.cYellow + "Preferences", + new String[] + { + "", + C.cWhite + "Set your preferences to your liking", + C.cWhite + "so you can enjoy the game more!", + + "", + C.cWhite + "Type " + C.cGreen + "/prefs" + C.cWhite + " to access this anywhere!" + }); + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonStats.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonStats.java new file mode 100644 index 000000000..3e36c712d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonStats.java @@ -0,0 +1,65 @@ +package mineplex.hub.profile.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.profile.gui.GUIProfile; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class ButtonStats implements GuiItem +{ + + private GUIProfile _profile; + private Player _player; + + public ButtonStats(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getAchievementManager().openShop(_player); + } + + @Override + public ItemStack getObject() + { + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, + ChatColor.RESET + C.cYellow + "Stats and Achievements", + new String[] + { + "", + C.cWhite + "View your Statistics and Achievements", + C.cWhite + "for all of the games on Mineplex!", + + "", + C.cWhite + "Type " + C.cGreen + "/stats" + C.cWhite + " to access this anywhere!" + }); + SkullMeta meta = ((SkullMeta) item.getItemMeta()); + meta.setOwner(_player.getName()); + item.setItemMeta(meta); + return item; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/gui/GUIProfile.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/gui/GUIProfile.java new file mode 100644 index 000000000..a7dca223b --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/gui/GUIProfile.java @@ -0,0 +1,48 @@ +package mineplex.hub.profile.gui; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import mineplex.core.achievement.AchievementManager; +import mineplex.core.gui.SimpleGui; +import mineplex.core.personalServer.PersonalServerManager; +import mineplex.core.preferences.PreferencesManager; +import mineplex.hub.profile.buttons.ButtonMPS; +import mineplex.hub.profile.buttons.ButtonPrefs; +import mineplex.hub.profile.buttons.ButtonStats; + +public class GUIProfile extends SimpleGui +{ + + private PreferencesManager _preferencesManager; + private AchievementManager _achievementManager; + private PersonalServerManager _personalServerManager; + + public GUIProfile(Plugin plugin, Player player, PreferencesManager preferencesManager, AchievementManager achievementManager, PersonalServerManager personalServerManager) + { + super(plugin, player, "My Profile", 9*3); + _preferencesManager = preferencesManager; + _achievementManager = achievementManager; + _personalServerManager = personalServerManager; + + setItem(11, new ButtonStats(this, player)); + setItem(13, new ButtonPrefs(this, player)); + setItem(15, new ButtonMPS(this, player)); + } + + public PreferencesManager getPrefManager() + { + return _preferencesManager; + } + + public AchievementManager getAchievementManager() + { + return _achievementManager; + } + + public PersonalServerManager getPersonalManager() + { + return _personalServerManager; + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java index a9dcdccba..235b7c99b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java @@ -10,4 +10,9 @@ public class ServerInfo public String ServerType; public String Game; public boolean HostedByStaff; + + public int getAvailableSlots() + { + return MaxPlayers - CurrentPlayers; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index bba026899..9cfa24d21 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -9,9 +9,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Random; import java.util.Set; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; @@ -56,7 +60,9 @@ import mineplex.hub.queue.QueueManager; import mineplex.hub.queue.ui.QueueShop; import mineplex.hub.server.ui.LobbyShop; import mineplex.hub.server.ui.QuickShop; +import mineplex.hub.server.ui.ServerCountSorter; import mineplex.hub.server.ui.ServerNpcShop; +import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.data.ServerGroup; @@ -64,7 +70,12 @@ public class ServerManager extends MiniPlugin { private static final Long FREE_PORTAL_TIMER = 20000L; private static final Long BETA_PORTAL_TIMER = 120000L; + private static final Random random = new Random(); + public final int TOP_SERVERS = 3; // The number of top contending servers for auto-joining games + public final int MIN_SLOTS_REQUIRED = 12; // The number of slots the max server must have for auto-join + + public final long QUEUE_COOLDOWN = 2000; // Cooldown (in milliseconds) between queueing again for players private CoreClientManager _clientManager; private DonationManager _donationManager; private Portal _portal; @@ -73,9 +84,9 @@ public class ServerManager extends MiniPlugin private HubManager _hubManager; private StackerManager _stackerManager; private QueueManager _queueManager; - + + private NautHashMap _queueCooldowns = new NautHashMap(); private NautHashMap> _serverKeyInfoMap = new NautHashMap>(); - private NautHashMap _serverKeyTagMap = new NautHashMap(); private NautHashMap _serverPlayerCounts = new NautHashMap(); private NautHashMap _serverNpcShopMap = new NautHashMap(); private NautHashMap _serverInfoMap = new NautHashMap(); @@ -108,7 +119,7 @@ public class ServerManager extends MiniPlugin plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord"); - LoadServers(); + loadServers(); _quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu"); _lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu"); @@ -178,13 +189,13 @@ public class ServerManager extends MiniPlugin if (serverName != null) { - List serverList = new ArrayList(GetServerList(serverName)); + List serverList = new ArrayList(getServerList(serverName)); int slots = 1; if (serverList.size() > 0) { - slots = GetRequiredSlots(player, serverList.get(0).ServerType); + slots = getRequiredSlots(player, serverList.get(0).ServerType); } try @@ -195,7 +206,7 @@ public class ServerManager extends MiniPlugin { if ((serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Cup")) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slots) { - SelectServer(player, serverInfo); + selectServer(player, serverInfo); return; } } @@ -278,22 +289,10 @@ public class ServerManager extends MiniPlugin timeLeft = 0; } -// if (party != null) -// { -// if (player.getName().equals(party.GetLeader())) -// { -// for (Player partyPlayer : party.GetPlayersOnline()) -// { -// if (!partyPlayer.equals(player)) -// timeLeft = Math.max(timeLeft, getMillisecondsUntilPortal(partyPlayer)); -// } -// } -// } - return timeLeft; } - public void RemoveServer(String serverName) + public void removeServer(String serverName) { for (String key : _serverKeyInfoMap.keySet()) { @@ -303,21 +302,17 @@ public class ServerManager extends MiniPlugin _serverInfoMap.remove(serverName); } - public void addServerGroup(String serverKey, String...serverTag) + public void addServerGroup(ServerGroup serverGroup) { - _serverKeyInfoMap.put(serverKey, new HashSet()); - - for (String tag : serverTag) - _serverKeyTagMap.put(tag, serverKey); + _serverKeyInfoMap.put(serverGroup.getPrefix(), new HashSet()); } - public void AddServerNpc(String serverNpcName, String...serverTag) + public void addServerNpc(ServerGroup serverGroup) { - addServerGroup(serverNpcName, serverTag); - _serverNpcShopMap.put(serverNpcName, new ServerNpcShop(this, _clientManager, _donationManager, serverNpcName)); + _serverNpcShopMap.put(serverGroup.getServerNpcName(), new ServerNpcShop(this, _clientManager, _donationManager, serverGroup)); } - public void RemoveServerNpc(String serverNpcName) + public void removeServerNpc(String serverNpcName) { Set mappedServers = _serverKeyInfoMap.remove(serverNpcName); _serverNpcShopMap.remove(serverNpcName); @@ -349,22 +344,22 @@ public class ServerManager extends MiniPlugin } } - public Collection GetServerList(String serverNpcName) + public Collection getServerList(String serverNpcName) { return _serverKeyInfoMap.get(serverNpcName); } - public Set GetAllServers() + public Set getAllServers() { return _serverInfoMap.keySet(); } - public ServerInfo GetServerInfo(String serverName) + public ServerInfo getServerInfo(String serverName) { return _serverInfoMap.get(serverName); } - public boolean HasServerNpc(String serverNpcName) + public boolean hasServerNpc(String serverNpcName) { return _serverKeyInfoMap.containsKey(serverNpcName); } @@ -396,7 +391,6 @@ public class ServerManager extends MiniPlugin _retrieving = true; - _statusManager.retrieveServerGroups(new Callback>() { public void run(final Collection serverGroups) @@ -451,9 +445,9 @@ public class ServerManager extends MiniPlugin _serverUpdate.put(serverStatus.getName(), System.currentTimeMillis()); - if (_serverKeyTagMap.containsKey(tag)) + if (_serverKeyInfoMap.containsKey(tag)) { - _serverKeyInfoMap.get(_serverKeyTagMap.get(tag)).add(serverInfo); + _serverKeyInfoMap.get(tag).add(serverInfo); if (!_serverPlayerCounts.containsKey(tag)) _serverPlayerCounts.put(tag, 0); @@ -482,9 +476,11 @@ public class ServerManager extends MiniPlugin }); } }); + + updateCooldowns(); } - public void Help(Player caller, String message) + public void help(Player caller, String message) { UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); UtilPlayer.message(caller, F.help("/servernpc create ", " is name of npc.", Rank.OWNER)); @@ -499,9 +495,9 @@ public class ServerManager extends MiniPlugin UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message)); } - public void Help(Player caller) + public void help(Player caller) { - Help(caller, null); + help(caller, null); } public PartyManager getPartyManager() @@ -509,7 +505,7 @@ public class ServerManager extends MiniPlugin return _partyManager; } - public void SelectServer(org.bukkit.entity.Player player, ServerInfo serverInfo) + public void selectServer(org.bukkit.entity.Player player, ServerInfo serverInfo) { Party party = _partyManager.GetParty(player); @@ -521,8 +517,120 @@ public class ServerManager extends MiniPlugin _portal.sendPlayerToServer(player, serverInfo.Name); } } + + /** + * Select a {@code serverType} for a {@code player} that wishes to automatically join the best server + * available for that server type. + * @param player - the player hoping to select a server + * @param serverType - the name of the type of server to be joined + */ + public void selectServer(Player player, String serverType) + { + if (isOnCooldown(player)) + { + return; + } + + ServerInfo bestServer = getBestServer(player, serverType); - public void ListServerNpcs(Player caller) + if (bestServer != null) + { + selectServer(player, bestServer); + addCooldown(player); + } + } + + private boolean isOnCooldown(Player player) + { + if (_queueCooldowns.containsKey(player.getName())) + { + long elapsed = System.currentTimeMillis() - _queueCooldowns.get(player.getName()); + + return elapsed < QUEUE_COOLDOWN; + } + + return false; + } + + private void addCooldown(Player player) + { + _queueCooldowns.put(player.getName(), System.currentTimeMillis()); + } + + private void updateCooldowns() + { + for (Iterator playerIterator = _queueCooldowns.keySet().iterator(); playerIterator.hasNext();) + { + Player player = Bukkit.getPlayer(playerIterator.next()); + + if (player == null || !isOnCooldown(player)) + { + playerIterator.remove(); + } + } + } + + /** + * @param serverType - the type of server that should be fetched + * @return the best server that a new player should join according to a {@code serverType} constraint. + */ + public ServerInfo getBestServer(Player player, String serverKey) + { + Collection serverList = getServerList(serverKey); + if (serverList == null) return null; + + List servers = new ArrayList(serverList); + servers = fetchOpenServers(player, servers, servers.size()); // Removes all full servers from list + Collections.sort(servers, new ServerCountSorter()); + + int count = Math.min(servers.size(), TOP_SERVERS); + + if (count > 0) + { + ServerInfo largestServer = servers.get(0); + + if (largestServer.getAvailableSlots() >= MIN_SLOTS_REQUIRED || largestServer.MaxPlayers > 40) + { + System.out.println("Largest."); + return largestServer; + } + else + { + System.out.println("Random."); + return servers.get(random.nextInt(count)); + } + } + + return null; + } + + public List fetchOpenServers(Player player, List servers, int count) + { + List results = new ArrayList(); + int requiredSlots = (servers.size() > 0) ? getRequiredSlots(player, servers.get(0).ServerType) : 0; + + for (ServerInfo server : servers) + { + if (isInProgress(server)) + continue; + + if (results.size() >= count) break; + + if (server.getAvailableSlots() > requiredSlots) + { + results.add(server); + } + } + + return results; + } + + private boolean isInProgress(ServerInfo serverInfo) + { + return serverInfo.MOTD.contains("Progress") || serverInfo.MOTD.contains("Restarting"); + } + + public void listServerNpcs(Player caller) { UtilPlayer.message(caller, F.main(getName(), "Listing Server Npcs:")); @@ -532,7 +640,7 @@ public class ServerManager extends MiniPlugin } } - public void ListServers(Player caller, String serverNpcName) + public void listServers(Player caller, String serverNpcName) { UtilPlayer.message(caller, F.main(getName(), "Listing Servers for '" + serverNpcName + "':")); @@ -542,7 +650,7 @@ public class ServerManager extends MiniPlugin } } - public void ListOfflineServers(Player caller) + public void listOfflineServers(Player caller) { UtilPlayer.message(caller, F.main(getName(), "Listing Offline Servers:")); @@ -555,7 +663,7 @@ public class ServerManager extends MiniPlugin } } - public void LoadServers() + public void loadServers() { _serverInfoMap.clear(); _serverUpdate.clear(); @@ -564,89 +672,59 @@ public class ServerManager extends MiniPlugin { _serverKeyInfoMap.get(npcName).clear(); } - - _serverKeyTagMap.clear(); - FileInputStream fstream = null; - BufferedReader br = null; - - HashSet npcNames = new HashSet(); + Region region = getPlugin().getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU; try { - File npcFile = new File("ServerManager.dat"); - - if (npcFile.exists()) + for (ServerGroup serverGroup : mineplex.serverdata.servers.ServerManager.getServerRepository(region).getServerGroups(null)) { - fstream = new FileInputStream(npcFile); - br = new BufferedReader(new InputStreamReader(fstream)); - - String line = br.readLine(); - - while (line != null) - { - String serverNpcName = line.substring(0, line.indexOf('|')).trim(); - String[] serverTags = line.substring(line.indexOf('|') + 1, line.indexOf('|', line.indexOf('|') + 1)).trim().split(","); - String[] locations = line.substring(line.indexOf('|', line.indexOf('|') + 1) + 1).trim().split(","); + addServerGroup(serverGroup); - for (String location : locations) + if (!serverGroup.getServerNpcName().isEmpty()) + addServerNpc(serverGroup); + + if (!serverGroup.getPortalBottomCornerLocation().isEmpty() && !serverGroup.getPortalTopCornerLocation().isEmpty()) + { + Vector bottomVector = ParseVector(serverGroup.getPortalBottomCornerLocation()); + Vector topVector = ParseVector(serverGroup.getPortalTopCornerLocation()); + int blocks = 0; + + while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ())) { - _serverPortalLocations.put(ParseVector(location), serverNpcName); + _serverPortalLocations.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getServerNpcName()); + + if (bottomVector.getBlockX() != topVector.getBlockX()) + { + bottomVector.add(new Vector(-(bottomVector.getBlockX() - topVector.getBlockX()) / Math.abs(bottomVector.getBlockX() - topVector.getBlockX()), 0, 0)); + } + else if (bottomVector.getBlockZ() != topVector.getBlockZ()) + { + bottomVector.add(new Vector(0, 0, -(bottomVector.getBlockZ() - topVector.getBlockZ()) / Math.abs(bottomVector.getBlockZ() - topVector.getBlockZ()))); + } + + blocks++; } - if (!HasServerNpc(serverNpcName)) - { - AddServerNpc(serverNpcName, serverTags); - } - - npcNames.add(serverNpcName); - - line = br.readLine(); + _serverPortalLocations.put(bottomVector, serverGroup.getServerNpcName()); } } } catch (Exception e) { - System.out.println("ServerManager - Error parsing servers file : " + e.getMessage()); - } - finally - { - if (br != null) - { - try - { - br.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - if (fstream != null) - { - try - { - fstream.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } + System.out.println("ServerManager - Error parsing servergroups : " + e.getMessage()); } - for (String npcName : npcNames) - { - if (!_serverNpcShopMap.containsKey(npcName)) - _serverNpcShopMap.remove(npcName); - - if (!_serverKeyInfoMap.containsKey(npcName)) - _serverKeyInfoMap.remove(npcName); - } + ServerGroup eventGroup = new ServerGroup("Event", "Event Servers", "EVENT"); + ServerGroup mpsGroup = new ServerGroup("MPS", "Mineplex Player Servers", "MPS"); + + addServerNpc(eventGroup); + addServerGroup(eventGroup); + addServerNpc(mpsGroup); + addServerGroup(mpsGroup); } - public int GetRequiredSlots(Player player, String serverType) + public int getRequiredSlots(Player player, String serverType) { int slots = 0; @@ -683,6 +761,18 @@ public class ServerManager extends MiniPlugin { return _serverNpcShopMap.get("Mixed Arcade"); } + + public ServerNpcShop getServerNPCShopByName(String name) + { + for(String shop : _serverNpcShopMap.keySet()) + { + if(shop.equalsIgnoreCase(name)) + { + return _serverNpcShopMap.get(shop); + } + } + return null; + } public ServerNpcShop getSuperSmashMobsShop() { @@ -722,7 +812,7 @@ public class ServerManager extends MiniPlugin public ServerNpcShop getSKYShop() { - return _serverNpcShopMap.get("SkyWars"); + return _serverNpcShopMap.get("Skywars"); } public ServerNpcShop getPlayerGamesShop() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java index 90cc6faa1..f084c2ded 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java @@ -35,7 +35,7 @@ public class LobbyMenu extends ShopPageBase implements @Override protected void buildPage() { - List serverList = new ArrayList(getPlugin().GetServerList(_serverGroup)); + List serverList = new ArrayList(getPlugin().getServerList(_serverGroup)); try { @@ -99,7 +99,7 @@ public class LobbyMenu extends ShopPageBase implements @Override public void SelectServer(org.bukkit.entity.Player player, ServerInfo serverInfo) { - int slots = getPlugin().GetRequiredSlots(player, serverInfo.ServerType); + int slots = getPlugin().getRequiredSlots(player, serverInfo.ServerType); if (serverInfo.MaxPlayers - serverInfo.CurrentPlayers < slots) { @@ -107,6 +107,6 @@ public class LobbyMenu extends ShopPageBase implements return; } - getPlugin().SelectServer(player, serverInfo); + getPlugin().selectServer(player, serverInfo); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyShop.java index 8cd3347df..dc7f9477e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyShop.java @@ -14,7 +14,8 @@ public class LobbyShop extends ShopBase { super(plugin, clientManager, donationManager, name); - plugin.addServerGroup("Lobby", "Lobby"); + // TODO: Why is this needed? Re-add? + //plugin.addServerGroup("Lobby", "Lobby"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerCountSorter.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerCountSorter.java new file mode 100644 index 000000000..6587030d7 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerCountSorter.java @@ -0,0 +1,13 @@ +package mineplex.hub.server.ui; + +import java.util.Comparator; + +import mineplex.hub.server.ServerInfo; + +public class ServerCountSorter implements Comparator +{ + public int compare(ServerInfo a, ServerInfo b) + { + return b.CurrentPlayers - a.CurrentPlayers; + } +} \ No newline at end of file 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 4e0c5bb3a..3e17d1070 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -64,17 +64,17 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BR") + ChatColor.RESET + " other players!", })); - setItem(2, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Survival Games " + C.cGray + "Last Man Standing", new String[] + setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Survival Games " + C.cGray + "Solo/Team Survival", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Search for chests to find loot and ", ChatColor.RESET + "fight others to be the last man standing. ", ChatColor.RESET + "Stay away from the borders!", ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("HG") + ChatColor.RESET + " other players!", - })); + ChatColor.RESET + "Join " + ChatColor.GREEN + (getPlugin().getGroupTagPlayerCount("HG") + getPlugin().getGroupTagPlayerCount("SG2")) + ChatColor.RESET + " other players!", + })); - setItem(4, ItemStackFactory.Instance.CreateStack(Material.FEATHER.getId(), (byte) 0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Skywars " + C.cGray + "Solo Survival", new String[] + setItem(4, ItemStackFactory.Instance.CreateStack(Material.FEATHER.getId(), (byte) 0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Skywars " + C.cGray + "Solo/Team Survival", new String[] { ChatColor.RESET + "", ChatColor.RESET + "16 contenders fight for the right to rule the skies!", @@ -83,7 +83,7 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Way up there, death ever looming if you fall..", ChatColor.RESET + "Can you fight? Can you live? Can you win Skywars?", ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("SKY") + ChatColor.RESET + " other players!", + ChatColor.RESET + "Join " + ChatColor.GREEN + (getPlugin().getGroupTagPlayerCount("SKY") + getPlugin().getGroupTagPlayerCount("SKY2")) + ChatColor.RESET + " other players!", })); setItem(6, ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "UHC " + C.cGray + "Ultra Hardcore Mode", new String[] @@ -453,10 +453,10 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "then battle other players to the ", ChatColor.RESET + "death with your monsters skills!", ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("SSM") + ChatColor.RESET + " other players!", + ChatColor.RESET + "Join " + ChatColor.GREEN + (getPlugin().getGroupTagPlayerCount("SSM") + getPlugin().getGroupTagPlayerCount("SSM2")) + ChatColor.RESET + " other players!", }; - _superSmashCycle.add(ItemStackFactory.Instance.CreateStack(397, (byte)4, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Super Smash Mobs", desc)); + _superSmashCycle.add(ItemStackFactory.Instance.CreateStack(397, (byte)4, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Super Smash Mobs " + C.cGray + "Solo/Team Deathmatch", desc)); } public void Update() 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 b44045870..64993b32e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -17,6 +17,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.game.GameDisplay; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; @@ -36,14 +37,14 @@ public class ServerNpcPage extends ShopPageBase im private static final String MESSAGE_FULL_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join full servers!"; private static final String MESSAGE_RESTARTING = ChatColor.RESET + C.Line + "This server will be open shortly!"; - private String _serverNpcKey; + private String _serverGroupName; private boolean _onMainPage = true; - public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverNpcKey) + public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName) { super(plugin, shop, clientManager, donationManager, name, player, 54); - _serverNpcKey = serverNpcKey; + _serverGroupName = serverGroupName; buildPage(); } @@ -51,12 +52,14 @@ public class ServerNpcPage extends ShopPageBase im @Override protected void buildPage() { - List serverList = new ArrayList(getPlugin().GetServerList(_serverNpcKey)); + List serverList = new ArrayList(getPlugin().getServerList(_serverGroupName)); + int slotsNeeded = 1; + if (serverList.size() > 0) { - slotsNeeded = getPlugin().GetRequiredSlots(getPlayer(), serverList.get(0).ServerType); + slotsNeeded = getPlugin().getRequiredSlots(getPlayer(), serverList.get(0).ServerType); } try @@ -71,6 +74,13 @@ public class ServerNpcPage extends ShopPageBase im if (_onMainPage) { + addButton(4, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BLOCK, (byte) 0, 1, C.cGreen + "Click to join instantly!"), new IButton() { + + @Override + public void onClick(Player player, ClickType clickType) { + getPlugin().selectServer(player, _serverGroupName); + } + }); buildAvailableServerPage(serverList, slotsNeeded); } else @@ -265,7 +275,9 @@ public class ServerNpcPage extends ShopPageBase im if (serverInfo.MOTD.contains("Open in")) setItem(slot, shopItem); else + { addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); + } if (full) fullCount++; @@ -398,15 +410,16 @@ public class ServerNpcPage extends ShopPageBase im } public void SelectServer(Player player, ServerInfo serverInfo) - { - int slots = getPlugin().GetRequiredSlots(player, serverInfo.ServerType); + { + System.out.println("Selecting server :" + serverInfo.Name); + int slots = getPlugin().getRequiredSlots(player, serverInfo.ServerType); - if (serverInfo.MaxPlayers - serverInfo.CurrentPlayers < slots && !(getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().Has(Rank.ULTRA))) + if (serverInfo.getAvailableSlots() < slots && !(getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().Has(Rank.ULTRA))) { playDenySound(player); return; } - getPlugin().SelectServer(player, serverInfo); + getPlugin().selectServer(player, serverInfo); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java index 0c4af2d90..16e3ccfa7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java @@ -11,18 +11,31 @@ import mineplex.core.party.Party; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; +import mineplex.serverdata.data.ServerGroup; public class ServerNpcShop extends ShopBase { - public ServerNpcShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name) + private ServerGroup _serverGroup; + + public ServerNpcShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager, ServerGroup serverGroup) { - super(plugin, clientManager, donationManager, name); + super(plugin, clientManager, donationManager, serverGroup.getServerNpcName()); + + _serverGroup = serverGroup; } @Override protected ShopPageBase> buildPagesFor(Player player) { - return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), getName(), player, getName()); + if (_serverGroup.getPrefix().equalsIgnoreCase("SSM") || _serverGroup.getPrefix().equalsIgnoreCase("SKY") || _serverGroup.getPrefix().equalsIgnoreCase("HG")) + { + return new ServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); + } + else + { + return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()); + } + } @Override @@ -65,4 +78,16 @@ public class ServerNpcShop extends ShopBase { getPlugin().getHubManager().GetVisibility().removeHiddenPlayer(player); } + + /*@Override + public boolean attemptShopOpen(Player player) + { + if (_serverGroup.getTeamServerKey().isEmpty() && !_serverGroup.getPrefix().equalsIgnoreCase("EVENT") && !_serverGroup.getPrefix().equalsIgnoreCase("MPS")) // Has no team server key, so auto-join + { + getPlugin().selectServer(player, getName()); + return false; + } + + return super.attemptShopOpen(player); + }*/ } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerTypePage.java new file mode 100644 index 000000000..3c909f545 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerTypePage.java @@ -0,0 +1,90 @@ + +package mineplex.hub.server.ui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.meta.SkullMeta; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementCategory; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.game.GameDisplay; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.hub.server.ServerInfo; +import mineplex.hub.server.ServerManager; +import mineplex.hub.server.ServerSorter; +import mineplex.hub.server.ui.button.JoinServerButton; +import mineplex.hub.server.ui.button.SelectBRButton; +import mineplex.hub.server.ui.button.SelectTypeButton; +import mineplex.serverdata.data.ServerGroup; + +public class ServerTypePage extends ShopPageBase +{ + + private ServerGroup _serverGroup; + + public ServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, + Player player, ServerGroup serverGroup) + { + super(plugin, shop, clientManager, donationManager, serverGroup.getServerNpcName(), player, 27); + + _serverGroup = serverGroup; + + buildPage(); + } + + @Override + protected void buildPage() + { + String friendlyName = _serverGroup.getServerNpcName(); + + setItem(12, ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM.getId(), (byte)3, 1, ChatColor.RESET + C.cYellow + "Solo " + friendlyName, new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + C.cRed + C.Bold + "WARNING: " + ChatColor.RESET + "Teaming in Solo Mode is bannable!", + ChatColor.RESET + "", + ChatColor.RESET + C.cGreen + "Click to Play", + })); + + setItem(14, ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM.getId(), (byte)3, 2, ChatColor.RESET + C.cYellow + "Team " + friendlyName, new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + C.cGray + "2 Player Teams", + ChatColor.RESET + "", + ChatColor.RESET + C.cGreen + "Click to Play" + })); + + getButtonMap().put(12, new SelectTypeButton(this, false)); + getButtonMap().put(14, new SelectTypeButton(this, true)); + } + + public void Update() + { + getButtonMap().clear(); + buildPage(); + } + + public void selectServer(Player player, boolean team) + { + if (team) + { + getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName() + " Teams", player, _serverGroup.getTeamServerKey())); + } + else + { + getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName() + " Solo", player, _serverGroup.getPrefix())); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBHButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBHButton.java deleted file mode 100644 index fea9423b6..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBHButton.java +++ /dev/null @@ -1,23 +0,0 @@ -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 SelectBHButton implements IButton -{ - private ServerGameMenu _menu; - - public SelectBHButton(ServerGameMenu menu) - { - _menu = menu; - } - - @Override - public void onClick(Player player, ClickType clickType) - { - _menu.OpenBH(player); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMSButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMSButton.java deleted file mode 100644 index ca500cb25..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMSButton.java +++ /dev/null @@ -1,23 +0,0 @@ -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 SelectMSButton implements IButton -{ - private ServerGameMenu _menu; - - public SelectMSButton(ServerGameMenu menu) - { - _menu = menu; - } - - @Override - public void onClick(Player player, ClickType clickType) - { - _menu.openMS(player); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTypeButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTypeButton.java new file mode 100644 index 000000000..847cb3933 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTypeButton.java @@ -0,0 +1,28 @@ +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.ServerInfo; +import mineplex.hub.server.ServerManager; +import mineplex.hub.server.ui.IServerPage; +import mineplex.hub.server.ui.ServerTypePage; + +public class SelectTypeButton implements IButton +{ + private ServerTypePage _page; + private boolean _teamBased; + + public SelectTypeButton(ServerTypePage page, boolean teamBased) + { + _page = page; + _teamBased = teamBased; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _page.selectServer(player, _teamBased); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java index e8c7d1a8c..c91ce9eca 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java @@ -17,8 +17,8 @@ public class PartyTutorial extends Tutorial double y = -manager.GetSpawn().getY(); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 10), - manager.GetSpawn().add(81, y+68.5, 10), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Parties", new String[] { @@ -32,8 +32,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Creating a Party", new String[] { @@ -47,8 +47,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Inviting and Suggesting Players", new String[] { @@ -61,8 +61,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Leaving Parties", new String[] { @@ -73,8 +73,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Kicking Players from Party", new String[] { @@ -87,8 +87,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Joining Games Together", new String[] { @@ -103,8 +103,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(84, y+69, 9), - manager.GetSpawn().add(81, y+68.5, 9), + manager.GetSpawn().add(0, 65 + y, 0), + manager.GetSpawn().add(4, 66.5 + y, 0), "Party Chat", new String[] { @@ -118,8 +118,8 @@ public class PartyTutorial extends Tutorial )); _phases.add(new TutorialPhase( - manager.GetSpawn().add(0, -2, 0), - manager.GetSpawn().add(0, -2.1, 5), + manager.GetSpawn().add(0, 0, 0), + manager.GetSpawn().add(0, 0.1, 5), "End", new String[] { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java index 5eb6b5ebb..17ddabbad 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java @@ -132,8 +132,8 @@ public class WelcomeTutorial extends Tutorial //END _phases.add(new TutorialPhase( - manager.GetSpawn().add(0, -2, 0), - manager.GetSpawn().add(0, -2.1, 5), + manager.GetSpawn().add(0, 0, 0), + manager.GetSpawn().add(0, 0.1, 5), "End", new String[] { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index 7e627f491..7fe8dd6f8 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -30,6 +30,7 @@ public enum GameType Halloween("Halloween Horror"), HideSeek("Block Hunt"), Horse("Horseback"), + Lobbers("Bomb Lobbers"), SurvivalGames("Survival Games"), SurvivalGamesTeams("Survival Games Teams"), Micro("Micro Battle"), diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 9d1efd727..622e7516c 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -25,6 +25,8 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.EntitySpawnEvent; @@ -36,6 +38,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -260,6 +263,13 @@ public class MapParser extends JavaPlugin implements Listener event.setCancelled(true); } + @EventHandler + public void DisableIgnite(BlockIgniteEvent event) + { + if (event.getCause() == IgniteCause.LAVA || event.getCause() == IgniteCause.SPREAD) + event.setCancelled(true); + } + @EventHandler public void DisableFire(BlockSpreadEvent event) { @@ -710,4 +720,30 @@ public class MapParser extends JavaPlugin implements Listener return blocks; } + + long lastUse = 0; + @EventHandler(priority = EventPriority.LOWEST) + public void leaptest(PlayerInteractEvent event) + { + + if (event.getPlayer().getItemInHand() == null) + return; + + if (event.getPlayer().getItemInHand().getType() != Material.FEATHER) + return; + + if (System.currentTimeMillis() - lastUse < 800) + { + Bukkit.broadcastMessage("Cooldown"); + return; + } + + + lastUse = System.currentTimeMillis(); + + Vector vel = event.getPlayer().getLocation().getDirection().multiply(1.2); + vel.add(new Vector(0,0.6,0)); + + event.getPlayer().setVelocity(vel); + } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java index 490f4b8cf..a229e5e07 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java @@ -1,5 +1,6 @@ package mineplex.mapparser.command; +import java.io.File; import java.util.List; import org.bukkit.Bukkit; @@ -77,6 +78,18 @@ public class MapCommand extends BaseCommand message(player, "That map is being backed up now. Try again soon"); return true; } + + //Delete UID + File file = new File(worldName + "/uid.dat"); + if (file.exists()) + { + System.out.println("Deleting uid.dat for " + worldName); + file.delete(); + } + else + { + System.out.println("Could not delete uid.dat for " + worldName); + } World world = getPlugin().GetMapWorld(worldName); if (world == null) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index 19240ac33..c7c13b2f6 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -354,7 +354,7 @@ public class ClientClass if (notify) { ListSkills(_client.GetPlayer()); - _client.GetPlayer().getWorld().playSound(_client.GetPlayer().getLocation(), Sound.LEVEL_UP, 1f, 1f); + _client.GetPlayer().playSound(_client.GetPlayer().getLocation(), Sound.LEVEL_UP, 1f, 1f); _client.GetPlayer().sendMessage(F.main("Class", "You equipped " + F.skill(customBuild.Name) + ".")); } @@ -558,12 +558,19 @@ public class ClientClass private boolean ValidSkill(String skillName, ISkill skill, SkillType expectedType) { + try + { if (skillName == null || skill == null || expectedType == null) return false; if (!skillName.isEmpty() && (skill == null || skill.GetSkillType() != expectedType || (!skill.IsFree() && !_donor.OwnsUnknownPackage("Champions " + skillName) && !_client.GetRank().Has(Rank.ULTRA) && !_donor.OwnsUnknownPackage("Competitive ULTRA")))) return false; + } catch (NullPointerException ex) + { + System.out.println("Somehow a Nullpointer happens here if someone uses /disguise.\n" + + "shouldnt be a problem because Youtube+ can have all skills."); + } return true; } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index d7894530c..cded12bbe 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -126,9 +126,35 @@ public class BlockToss extends SkillCharge implements IThrown //Usable if (UtilBlock.usable(grab)) return; + + + // Ladder and beacon grabs + if (grab.getType() == Material.LADDER || grab.getType() == Material.BEACON) + { + UtilPlayer.message(player, F.main(GetName(), "You cannot grab this block.")); + return; + } + + //TrapDoor or ladder + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + if (x != z && (z == 0 || x == 0)) + { + Block block = grab.getRelative(x, 0, z); + + if (block.getType() == Material.TRAP_DOOR || block.getType() == Material.LADDER) + { + UtilPlayer.message(player, F.main(GetName(), "You cannot grab this block.")); + return; + } + } + } + } //Block to Item - FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), event.getClickedBlock().getType(), (byte)0); + FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), event.getClickedBlock().getType(), event.getClickedBlock().getData()); //Action player.eject(); @@ -233,7 +259,7 @@ public class BlockToss extends SkillCharge implements IThrown { FallingBlock thrown = (FallingBlock) data.GetThrown(); - FallingBlock newThrown = data.GetThrown().getWorld().spawnFallingBlock(data.GetThrown().getLocation(), thrown.getMaterial(), (byte)0); + FallingBlock newThrown = data.GetThrown().getWorld().spawnFallingBlock(data.GetThrown().getLocation(), thrown.getMaterial(), thrown.getBlockData()); //Remove Old _falling.remove(thrown); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Brute.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Brute.java index 573fa3ff8..63a98526a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Brute.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Brute.java @@ -10,8 +10,9 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.Global.BowDeficiencySkill; -public class Brute extends Skill +public class Brute extends BowDeficiencySkill { public Brute(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -43,25 +44,10 @@ public class Brute extends Skill event.SetBrute(); } - @EventHandler - public void BowShoot(EntityShootBowEvent event) - { - if (getLevel(event.getEntity()) == 0) - return; - - event.getProjectile().setVelocity(event.getProjectile().getVelocity().multiply(0.75)); - } - @EventHandler public void CancelEnergy(EnergyEvent event) { if (getLevel(event.GetPlayer()) > 0) event.setCancelled(true); } - - @Override - public void Reset(Player player) - { - - } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Global/BowDeficiencySkill.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Global/BowDeficiencySkill.java new file mode 100644 index 000000000..9f5978423 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Global/BowDeficiencySkill.java @@ -0,0 +1,57 @@ +package mineplex.minecraft.game.classcombat.Skill.Global; + +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.Skill; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; + +/** + * The BowDeficiencySkill provides a reduction in overall arrow velocity and damage to owners. + * @author MrTwiggy + * + */ +public class BowDeficiencySkill extends Skill +{ + + public BowDeficiencySkill(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int maxLevel) + { + super(skills, name, classType, skillType, cost, maxLevel); + } + + /** + * Reduce outgoing arrow velocity by bow deficiency owners. + * @param event + */ + @EventHandler + public void BowShoot(EntityShootBowEvent event) + { + if (getLevel(event.getEntity()) == 0) + return; + + event.getProjectile().setVelocity(event.getProjectile().getVelocity().multiply(0.75)); + } + + /** + * Reduce damage output of arrows shot by bow deficiency owners. + * @param event + */ + @EventHandler + public void onArrowDamage(CustomDamageEvent event) + { + // Check to see if arrow was shot by owner of this Skill. + if (event.GetProjectile() == null || getLevel(event.GetDamagerEntity(true)) == 0) + return; + + event.AddMod("BowDeficiencySkill", -2.0d); + } + + @Override + public void Reset(Player player) + { + + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Knight.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Knight.java index eff3aec2f..d837b2732 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Knight.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Knight.java @@ -8,8 +8,9 @@ import mineplex.core.energy.event.EnergyEvent; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.Global.BowDeficiencySkill; -public class Knight extends Skill +public class Knight extends BowDeficiencySkill { public Knight(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -20,15 +21,6 @@ public class Knight extends Skill "25% reduction in Arrow Velocity." }); } - - @EventHandler - public void BowShoot(EntityShootBowEvent event) - { - if (getLevel(event.getEntity()) == 0) - return; - - event.getProjectile().setVelocity(event.getProjectile().getVelocity().multiply(0.75)); - } @EventHandler public void CancelEnergy(EnergyEvent event) @@ -36,10 +28,4 @@ public class Knight extends Skill if (getLevel(event.GetPlayer()) > 0) event.setCancelled(true); } - - @Override - public void Reset(Player player) - { - - } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java index ca7f8e68a..f7d16327a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java @@ -26,6 +26,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.common.util.F; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -209,7 +210,7 @@ public class Blizzard extends SkillActive if (damagee == null) return; event.SetCancelled(GetName()); - damagee.setVelocity(proj.getVelocity().multiply(0.1).add(new Vector(0, 0.15, 0))); + UtilAction.velocity(damagee, proj.getVelocity().multiply(0.1).add(new Vector(0, 0.15, 0))); } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java index 6d237c4ec..46ec2eaba 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java @@ -1,10 +1,12 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; import java.util.HashMap; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Item; import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -17,6 +19,7 @@ import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -98,8 +101,8 @@ public class FireBlast extends SkillActive if (level == 0) return; //Velocity Players - HashMap hitMap = UtilPlayer.getInRadius(proj.getLocation(), 5.5 + (0.5 * level)); - for (Player cur : hitMap.keySet()) + HashMap hitMap = UtilEnt.getInRadius(proj.getLocation(), 5.5 + (0.5 * level)); + for (LivingEntity cur : hitMap.keySet()) { double range = hitMap.get(cur); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Mage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Mage.java index 38c119541..96afcc79a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Mage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Mage.java @@ -1,14 +1,20 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.metadata.MetadataValue; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.Global.BowDeficiencySkill; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class Mage extends Skill +public class Mage extends BowDeficiencySkill { public Mage(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -20,18 +26,5 @@ public class Mage extends Skill }); } - @EventHandler - public void BowShoot(EntityShootBowEvent event) - { - if (getLevel(event.getEntity()) == 0) - return; - - event.getProjectile().setVelocity(event.getProjectile().getVelocity().multiply(0.75)); - } - - @Override - public void Reset(Player player) - { - - } + } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Rupture.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Rupture.java index 0f444315d..d8797a258 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Rupture.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Rupture.java @@ -68,7 +68,7 @@ public class Rupture extends SkillActiveCharge "", "Release Block to release the rupture,", "causing earth and players to fly upward,", - "dealing up to #4#1 inital damage." + "dealing up to #4#1 initial damage." }); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java index b265a710d..dbc584655 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java @@ -6,11 +6,14 @@ import java.util.Iterator; + + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -24,6 +27,7 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.event.UpdateEvent; @@ -213,8 +217,8 @@ public class ExplosiveShot extends SkillActive return; //Velocity Players - HashMap hitMap = UtilPlayer.getInRadius(loc, 4.5 + (level * 0.5)); - for (Player cur : hitMap.keySet()) + HashMap hitMap = UtilEnt.getInRadius(loc, 4.5 + (level * 0.5)); + for (LivingEntity cur : hitMap.keySet()) { double range = hitMap.get(cur); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java index 277bf1da1..7f80d6e3c 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java @@ -44,7 +44,7 @@ public class WolfsPounce extends SkillChargeSword GetChargeString(), "Taking damage cancels charge.", "", - "Colliding with another player", + "Colliding with another monster", "mid-air deals up to 6 damage", "and Slow 2 for 3 seconds." @@ -100,7 +100,7 @@ public class WolfsPounce extends SkillChargeSword if (!_live.containsKey(player)) continue; - for (Player other : player.getWorld().getPlayers()) + for (LivingEntity other : player.getWorld().getLivingEntities()) { if (UtilPlayer.isSpectator(other)) continue; @@ -108,7 +108,7 @@ public class WolfsPounce extends SkillChargeSword if (other.equals(player)) continue; - if (!Factory.Relation().canHurt(player, other)) + if (other instanceof Player && !Factory.Relation().canHurt(player, (Player)other)) continue; if (UtilMath.offset(player, other) > 2) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java index 1e24bc023..b215765e1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java @@ -40,6 +40,7 @@ import org.bukkit.plugin.java.JavaPlugin; public class SkillFactory extends MiniPlugin implements ISkillFactory { + private DamageManager _damageManager; private IRelation _relation; private CombatManager _combatManager; @@ -581,6 +582,11 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory System.out.println("Skill Factory: Removed " + remove.GetName() + " from SkillMap."); } + + public void removeSkill(String skillName) + { + RemoveSkill(skillName, null); + } @Override public List GetGlobalSkillsFor(IPvpClass gameClass) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemFactory.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemFactory.java index 139692a0d..ee42ca500 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemFactory.java @@ -92,7 +92,7 @@ public class ItemFactory extends MiniPlugin implements IItemFactory -1, true, true, true, false)); */ AddItem(new Soup(this, Material.MUSHROOM_SOUP, 1, true, 0, 1, - ActionType.R, true, 500, 0, + ActionType.ANY, true, 500, 0, null, false, 0, 0, 0f, -1, true, true, true, false)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/creature/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java similarity index 96% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/creature/EventCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index c69923152..1e7d59ebf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/creature/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -1,23 +1,21 @@ -package mineplex.game.clans.clans.worldevent.creature; +package mineplex.minecraft.game.core.boss; import java.util.UUID; +import mineplex.core.common.util.C; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.world.ChunkUnloadEvent; -import mineplex.core.common.util.C; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - public abstract class EventCreature implements Listener { private WorldEvent _event; @@ -145,6 +143,11 @@ public abstract class EventCreature implements Listener _entityClass = clazz; } + public double getHealthPercent() + { + return getHealth() / getMaxHealth(); + } + public Location getSpawnLocation() { return _spawnLocation; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventMap.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventMap.java similarity index 59% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventMap.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventMap.java index e4791c313..f9f5da8f6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventMap.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventMap.java @@ -1,13 +1,12 @@ -package mineplex.game.clans.clans.worldevent; - -import org.bukkit.Location; +package mineplex.minecraft.game.core.boss; import mineplex.core.common.block.schematic.Schematic; +import org.bukkit.Location; + public class EventMap { private Schematic _schematic; - private Location _cornerLocation; private Location _centerLocation; private double _xDiff; private double _yDiff; @@ -16,18 +15,17 @@ public class EventMap private double _yLength; private double _zLength; - public EventMap(Schematic schematic, Location cornerLocation, double xDiff, double yDiff, double zDiff, double xLength, double yLength, double zLength) + public EventMap(Schematic schematic, Location cornerLocation) { _schematic = schematic; - _cornerLocation = cornerLocation; - _xDiff = xDiff; - _yDiff = yDiff; - _zDiff = zDiff; - _xLength = xLength; - _yLength = yLength; - _zLength = zLength; + _xLength = schematic.getWidth(); + _yLength = schematic.getHeight(); + _zLength = schematic.getLength(); + _xDiff = _xLength / 2D; + _yDiff = _yLength / 2D; + _zDiff = _zLength / 2D; - _centerLocation = _cornerLocation.clone().add(_xDiff, _yDiff, _zDiff); + _centerLocation = cornerLocation.clone().add(_xDiff, _yDiff, _zDiff); } public Location getCenterLocation() @@ -43,7 +41,7 @@ public class EventMap double y = Math.abs(center.getY() - checkLocation.getY()); double z = Math.abs(center.getZ() - checkLocation.getZ()); - return x <= _xLength && y <= _yLength && z <= _zLength; + return x <= _xDiff && y <= _yDiff && z <= _zDiff; } public Schematic getSchematic() @@ -51,6 +49,4 @@ public class EventMap return _schematic; } - - } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/EventState.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventState.java similarity index 60% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/EventState.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventState.java index 951486fe1..751f9e0cf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/EventState.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventState.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.worldevent.event; +package mineplex.minecraft.game.core.boss; public enum EventState { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java similarity index 65% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEvent.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java index 243af4d61..cc97a4d42 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java @@ -1,9 +1,28 @@ -package mineplex.game.clans.clans.worldevent.event; +package mineplex.minecraft.game.core.boss; +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.blockrestore.BlockRestoreMap; +import mineplex.core.common.block.BlockData; +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.block.schematic.SchematicRunnable; +import mineplex.core.common.block.schematic.UtilSchematic; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -11,30 +30,15 @@ import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; - -import mineplex.core.blockrestore.BlockRestoreMap; -import mineplex.core.common.block.schematic.SchematicRunnable; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.block.BlockData; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.EventMap; -import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.clans.worldevent.creature.EventCreature; -import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.plugin.java.JavaPlugin; public abstract class WorldEvent implements Listener { // 20 Minutes private static final int ACTIVE_TIMEOUT = 1200000; - private WorldEventManager _eventManager; private DamageManager _damageManager; + private ConditionManager _conditionManager; private String _name; private EventState _state; @@ -43,27 +47,83 @@ public abstract class WorldEvent implements Listener private Random _random; private int _ticks; private long _lastActive; + private Schematic _schematic; // Creatures private List _creatures; // Block Restore private BlockRestoreMap _blocks; + private boolean _instantSchematic; - public WorldEvent(WorldEventManager eventManager, String name, Location cornerLocation) + public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, + Location cornerLocation) { - _eventManager = eventManager; - _damageManager = eventManager.getDamage(); + this(damageManager, blockRestore, conditionManager, name, cornerLocation, null); + } + + public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, + Location cornerLocation, String schematicName) + { + _damageManager = damageManager; + _conditionManager = conditionManager; _name = name; _state = EventState.PREPARE; _cornerLocation = cornerLocation; - _map = null; _random = new Random(); _ticks = 0; _creatures = new ArrayList(); - _blocks = eventManager.getBlockRestore().createMap(); + _blocks = blockRestore.createMap(); _lastActive = System.currentTimeMillis(); + + if (schematicName != null) + { + try + { + _schematic = UtilSchematic.loadSchematic(new File(schematicName)); + + _cornerLocation.subtract(_schematic.getWidth() / 2, 0, _schematic.getLength() / 2); + } + catch (IOException e) + { + e.printStackTrace(); + setState(EventState.COMPLETE); + } + } + } + + public void setInstantSchematic(boolean instantSchematic) + { + _instantSchematic = instantSchematic; + } + + public void loadMap() + { + loadMap(new Runnable() + { + @Override + public void run() + { + System.out.println("Runnable on complete"); + } + }); + } + + public void loadMap(Runnable runnable) + { + if (_schematic == null) + { + return; + } + + EventMap map = new EventMap(_schematic, _cornerLocation); + setMap(map, runnable); + } + + public ConditionManager getCondition() + { + return _conditionManager; } public final void start() @@ -122,11 +182,6 @@ public abstract class WorldEvent implements Listener return _ticks; } - public WorldEventManager getEventManager() - { - return _eventManager; - } - public DamageManager getDamageManager() { return _damageManager; @@ -159,7 +214,7 @@ public abstract class WorldEvent implements Listener public void registerCreature(EventCreature creature) { - UtilServer.getServer().getPluginManager().registerEvents(creature, _eventManager.getPlugin()); + UtilServer.getServer().getPluginManager().registerEvents(creature, _damageManager.getPlugin()); _creatures.add(creature); } @@ -167,13 +222,14 @@ public abstract class WorldEvent implements Listener { HandlerList.unregisterAll(creature); _creatures.remove(creature); -} + } public void announceStart() { UtilTextMiddle.display(C.cGreen + getName(), UtilWorld.locToStrClean(getCenterLocation()), 10, 40, 10); - Bukkit.broadcastMessage(F.main("Event", F.elem(getName()) + " has started at coordinates " + F.elem(UtilWorld.locToStrClean(getCenterLocation())))); + Bukkit.broadcastMessage(F.main("Event", + F.elem(getName()) + " has started at coordinates " + F.elem(UtilWorld.locToStrClean(getCenterLocation())))); } public void clearCreatures() @@ -187,6 +243,11 @@ public abstract class WorldEvent implements Listener _creatures.clear(); } + public JavaPlugin getPlugin() + { + return _damageManager.getPlugin(); + } + public void restoreBlocks() { _blocks.restore(); @@ -206,21 +267,22 @@ public abstract class WorldEvent implements Listener { _map = map; - SchematicRunnable task = new SchematicRunnable(_eventManager.getPlugin(), map.getSchematic(), _cornerLocation.getBlock(), new Callback>() - { - @Override - public void run(List data) - { - for (BlockData blockData : data) + SchematicRunnable task = new SchematicRunnable(_damageManager.getPlugin(), map.getSchematic(), + _cornerLocation.getBlock(), new Callback>() { - _blocks.addBlockData(blockData); - } + @Override + public void run(List data) + { + for (BlockData blockData : data) + { + _blocks.addBlockData(blockData); + } - onComplete.run(); - } - }); + onComplete.run(); + } + }); - task.setBlocksPerTick(100); + task.setBlocksPerTick(_instantSchematic ? 2000000 : 100); task.start(); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java new file mode 100644 index 000000000..6fc450904 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -0,0 +1,60 @@ +package mineplex.minecraft.game.core.boss.ironwizard; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; + +public class GolemBoss extends WorldEvent +{ + + public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, Location corner) + { + super(damageManager, blockRestore, conditionManager, "Iron Wizard", corner, "schematic/Golem.schematic"); + } + + @Override + protected void customStart() + { + Bukkit.broadcastMessage("Custom Start"); + spawnGolem(getCenterLocation()); + setState(EventState.LIVE); + announceStart(); + } + + /** + * Check if this slime boss has been defeated + */ + private void checkDeath() + { + if (getCreatures().size() == 0) + { + setState(EventState.COMPLETE); + Bukkit.broadcastMessage("FINISHED!"); + } + } + + @Override + public void removeCreature(EventCreature creature) + { + super.removeCreature(creature); + + if (creature instanceof GolemCreature) + { + checkDeath(); + } + } + + private GolemCreature spawnGolem(Location location) + { + GolemCreature slimeCreature = new GolemCreature(this, location, 2500); + registerCreature(slimeCreature); + return slimeCreature; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java new file mode 100644 index 000000000..93443c7a2 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java @@ -0,0 +1,534 @@ +package mineplex.minecraft.game.core.boss.ironwizard; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemAbility; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockHail; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockShot; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemCaveIn; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemEarthquake; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRumble; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.util.Vector; + +public class GolemCreature extends EventCreature +{ + private GolemBoss _boss; + // private GolemAbility _currentAbility; + private int _lastAbility; + private long _lastWalked; + private Location _standing; + private long _spawnDelay = System.currentTimeMillis(); + private long _reverseWalk; + private HashMap _preferedCombos = new HashMap(); + private Class _lastAttack; + private boolean _usedFinalAttack; + private ArrayList _currentAbilities = new ArrayList(); + private double _canCaveIn = 450; + private Vector _afkWalk = new Vector(); + + public GolemCreature(GolemBoss boss, Location location, double maxHealth) + { + super(boss, location, "Iron Wizard", true, maxHealth, IronGolem.class); + _boss = boss; + + spawnEntity(); + + _preferedCombos.put(GolemEarthquake.class, new Class[] + { + GolemBlockHail.class, GolemRumble.class + }); + _preferedCombos.put(GolemMeleeAttack.class, new Class[] + { + GolemEarthquake.class, GolemRumble.class + }); + _preferedCombos.put(GolemCaveIn.class, new Class[] + { + GolemMeleeAttack.class + }); + _preferedCombos.put(GolemBlockShot.class, new Class[] + { + GolemEarthquake.class + }); + _preferedCombos.put(GolemRumble.class, new Class[] + { + GolemBlockShot.class + }); + } + + @Override + protected void spawnCustom() + { + UtilEnt.Vegetate(getEntity()); + // EntityInsentient creature = (EntityInsentient) ((CraftEntity) getEntity()).getHandle(); + + // creature.Vegetated = false; + + _standing = getEntity().getLocation(); + } + + @EventHandler + public void abilityTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!UtilTime.elapsed(_spawnDelay, 5000)) + { + _standing = getEntity().getLocation(); + return; + } + + // if (_currentAbility == null || _currentAbility.hasFinished()) + // { + Iterator itel = _currentAbilities.iterator(); + boolean canDoNew = _currentAbilities.size() < 3; + + while (itel.hasNext()) + { + GolemAbility ability = itel.next(); + + if (ability.hasFinished()) + { + itel.remove(); + ability.setFinished(); + _lastAbility = 20;// _currentAbility.getCooldown(); + + HandlerList.unregisterAll(ability); + System.out.print("Unregistered golem ability " + ability.getClass().getSimpleName()); + } + else if (!ability.inProgress()) + { + canDoNew = false; + } + } + + if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN))) + { + HashMap weight = new HashMap(); + HashMap dist = new HashMap(); + + for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) + { + if (player.hasLineOfSight(getEntity())) + { + dist.put(player, player.getLocation().distance(getEntity().getLocation())); + } + } + + if (!dist.isEmpty()) + { + double hp = getHealthPercent(); + + { // Melee + ArrayList players = getPlayers(dist, 2.5); + + if (!players.isEmpty()) + { + weight.put(GolemMeleeAttack.class, 999); + } + } + + if (hp < 0.7) + { // Earthquake + ArrayList players = getPlayers(dist, 10); + + double score = 0; + + for (Player player : players) + { + score += (8 - dist.get(player)) / 2; + } + + if (players.size() >= 3) + { + score += 7; + } + + if (score > 0) + { + weight.put(GolemEarthquake.class, (int) Math.ceil(score)); + } + } + + { // Wall explode + if (!getPlayers(dist, 12).isEmpty() && getPlayers(dist, 4).isEmpty()) + { + weight.put(GolemWallExplode.class, 5); + } + } + + { // Block Shot + ArrayList players = getPlayers(dist, 30); + + for (Player player : players) + { + if (dist.get(player) > 4) + { + weight.put(GolemBlockShot.class, 6); + break; + } + } + } + + { // Rumble + ArrayList players = getPlayers(dist, 30); + + if (!players.isEmpty()) + { + weight.put(GolemRumble.class, (int) Math.min(5, dist.get(players.get(0)))); + } + } + + if (_canCaveIn <= 0)// Cave in + { + ArrayList players = getPlayers(dist, 30); + + for (GolemAbility ability : _currentAbilities) + { + if (ability instanceof GolemExplodingAura) + { + players.clear(); + } + } + + if (!players.isEmpty()) + { + // weight.put(GolemCaveIn.class, (int) Math.min(players.size() * 2, 7)); + weight.put(GolemCaveIn.class, (int) 30); + } + } + + {// Block Hail + ArrayList players = getPlayers(dist, 30); + + if (!players.isEmpty()) + { + int we = _lastAttack == GolemEarthquake.class ? 5 : UtilMath.r(4) - 2; + + if (we > 0) + { + weight.put(GolemBlockHail.class, we); + } + } + } + + if (!_usedFinalAttack && getHealth() < 90) + { + _usedFinalAttack = true; + weight.clear(); + + weight.put(GolemExplodingAura.class, 999); + } + + if (_lastAttack != null && _preferedCombos.containsKey(_lastAttack)) + { + weight.remove(_lastAttack); + + for (Class c : _preferedCombos.get(_lastAttack)) + { + if (weight.containsKey(c)) + { + weight.put(c, weight.get(c) * 4); + } + } + } + + for (GolemAbility ability : _currentAbilities) + { + weight.remove(ability.getClass()); + } + + GolemAbility ability = null; + + if (!weight.isEmpty()) + { + int i = 0; + + for (Integer entry : weight.values()) + { + i += entry; + } + + for (int a = 0; a < 10; a++) + { + int luckyNumber = UtilMath.r(i); + + for (Entry entry : weight.entrySet()) + { + luckyNumber -= entry.getValue(); + + if (luckyNumber <= 0) + { + try + { + ability = (GolemAbility) entry.getKey().getConstructor(GolemCreature.class).newInstance(this); + + if (ability.getTarget() == null) + { + ability = null; + } + else + { + break; + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + break; + } + } + } + } + + if (ability != null && ability.getTarget() != null) + { + _lastAttack = ability.getClass(); + + if (ability instanceof GolemCaveIn) + { + _canCaveIn = 450; + } + + Bukkit.getPluginManager().registerEvents(ability, _boss.getPlugin()); + + // Bukkit.broadcastMessage("Ability: " + _currentAbility.getClass().getSimpleName()); + + System.out.print("Golem boss is using " + ability.getClass().getSimpleName()); + + _currentAbilities.add(ability); + } + + _lastAbility = 10; + } + + _lastAttack = null; + } + + boolean canMove = true; + + for (GolemAbility ability : _currentAbilities) + { + ability.tick(); + + if (!ability.canMove()) + { + canMove = false; + } + } + + if (canMove) + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + double d = player.getLocation().distance(getEntity().getLocation()); + + if (d > 1.5 && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d))) + { + target = player; + dist = d; + } + } + + Vector vec = null; + + if (target != null) + { + vec = target.getLocation().subtract(getEntity().getLocation()).toVector(); + vec.setY(getEntity().getLocation().getY()); + + double len = vec.length(); + + vec.setX(vec.getX() * (UtilMath.random.nextDouble() / 3D)); + vec.setZ(vec.getZ() * (UtilMath.random.nextDouble() / 3D)); + + vec.multiply(len); + + if (target != null && dist < 8) + { + vec.multiply(-1); + } + + if (!UtilAlg.HasSight(getEntity().getLocation(), + getEntity().getLocation().add(vec.clone().normalize().multiply(2)))) + { + _reverseWalk = System.currentTimeMillis(); + } + + if (!UtilTime.elapsed(_reverseWalk, 4000)) + { + vec.multiply(-1); + } + + } + else if (!UtilTime.elapsed(_lastWalked, 7000)) + { + vec = _afkWalk; + } + else if (UtilTime.elapsed(_lastWalked, 12000)) + { + _afkWalk = new Vector(); + + for (int i = 0; i < 10; i++) + { + Vector vector = new Vector(UtilMath.r(20) - 10, 0, UtilMath.r(20) - 10); + + if (UtilAlg.HasSight(getEntity().getLocation(), + getEntity().getLocation().add(vector.clone().normalize().multiply(2)))) + { + vec = _afkWalk = vector; + break; + } + } + + _lastWalked = System.currentTimeMillis(); + } + + if (vec != null) + { + // if (vec.length() > 1) + { + UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec), target != null ? 1.5F : 1.1F); + } + } + + _standing = getEntity().getLocation(); + } + else + { + Location l = getEntity().getLocation(); + + _standing.setYaw(l.getYaw()); + _standing.setPitch(l.getPitch()); + _standing.setY(l.getY()); + + getEntity().teleport(_standing); + } + } + + private ArrayList getPlayers(final HashMap map, double maxDist) + { + ArrayList list = new ArrayList(); + + for (Player p : map.keySet()) + { + if (map.get(p) <= maxDist) + { + list.add(p); + } + } + + Collections.sort(list, new Comparator() + { + + @Override + public int compare(Player o1, Player o2) + { + return Double.compare(map.get(o2), map.get(o1)); + } + }); + + return list; + } + + @EventHandler + public void onGolemDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getEntity())) + { + event.AddKnockback("Heavy Golem", 0.3); + } + } + + @EventHandler + public void onRangedAttack(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getEntity())) + { + if (event.GetDamageePlayer() != null) + { + double dist = event.GetDamageePlayer().getLocation().distance(getEntity().getLocation()); + + double maxRange = _usedFinalAttack ? 20 : 45; + + double modifier = (maxRange - dist) / maxRange; + + if (modifier > 0) + { + event.AddMod("Ranged Resistance", modifier); + } + else + { + event.SetCancelled("Range too far"); + } + } + } + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + for (GolemAbility ability : _currentAbilities) + { + ability.setFinished(); + HandlerList.unregisterAll(ability); + } + + _currentAbilities.clear(); + } + + @Override + public void setHealth(double health) + { + _canCaveIn -= getHealth() - health; + + super.setHealth(health); + + if (getHealth() <= 100 && !_usedFinalAttack) + { + endAbility(); + } + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/BlockHailBlock.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/BlockHailBlock.java new file mode 100644 index 000000000..58dd30225 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/BlockHailBlock.java @@ -0,0 +1,86 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import mineplex.core.common.util.UtilEnt; +import net.minecraft.server.v1_7_R4.DataWatcher; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.IronGolem; + +public class BlockHailBlock +{ + private int _block = UtilEnt.getNewEntityId(); + private int _silverfish = UtilEnt.getNewEntityId(); + private Location _location; + private Material _mat; + + public BlockHailBlock(Location loc, Material mat) + { + _location = loc; + _mat = mat; + } + + public Packet getDestroyPacket() + { + return new PacketPlayOutEntityDestroy(new int[] + { + _silverfish, _block + }); + } + + public Location getLocation() + { + return _location; + } + + public Material getMaterial() + { + return _mat; + } + + public Packet[] getSpawnPackets(IronGolem entity) + { + Packet[] packets = new Packet[3]; + + PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); + + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 32); + watcher.a(1, 0); + + packet1.a = _silverfish; + packet1.b = EntityType.SILVERFISH.getTypeId(); + packet1.c = (int) Math.floor(_location.getX() * 32); + packet1.d = (int) Math.floor(_location.getY() * 32); + packet1.e = (int) Math.floor(_location.getZ() * 32); + packet1.l = watcher; + + packets[0] = packet1; + + PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftEntity) entity).getHandle(), 70, _mat.getId()); + + packet2.a = _block; + + packet2.b = (int) Math.floor(_location.getX() * 32); + packet2.c = (int) Math.floor(entity.getLocation().getY() * 32); + packet2.d = (int) Math.floor(_location.getZ() * 32); + + packets[1] = packet2; + + PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity(); + + packet3.b = _block; + packet3.c = _silverfish; + + packets[2] = packet3; + + return packets; + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemAbility.java new file mode 100644 index 000000000..47361630a --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemAbility.java @@ -0,0 +1,103 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.HashMap; +import java.util.UUID; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public abstract class GolemAbility implements Listener +{ + private GolemCreature _creature; + private HashMap _damaged = new HashMap(); + + public boolean canDamage(Entity player) + { + if (_damaged.containsKey(player.getUniqueId())) + { + + if (!UtilTime.elapsed(_damaged.get(player.getUniqueId()), 400)) + { + return false; + } + } + + _damaged.put(player.getUniqueId(), System.currentTimeMillis()); + return true; + } + + public GolemAbility(GolemCreature creature) + { + _creature = creature; + } + + public abstract boolean canMove(); + + public abstract boolean inProgress(); + + public int getCooldown() + { + return 60; + } + + public IronGolem getEntity() + { + return getGolem().getEntity(); + } + + public GolemCreature getGolem() + { + return _creature; + } + + public Location getLocation() + { + return getEntity().getLocation(); + } + + public Player getTarget() + { + return getTarget(30); + } + + public Player getTarget(double maxDistance) + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getLocation(), maxDistance, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + double d = player.getLocation().distance(getLocation()); + + if (target == null || dist > d) + { + target = player; + dist = d; + } + } + + return target; + } + + public abstract boolean hasFinished(); + + public abstract void setFinished(); + + public abstract void tick(); + +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java new file mode 100644 index 000000000..7ca1c3841 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java @@ -0,0 +1,482 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_7_R4.AxisAlignedBB; +import net.minecraft.server.v1_7_R4.EntityIronGolem; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MovingObjectPosition; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.Vec3D; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +/** + * Rumble is where the golem picks a target then starts playing a animation for a second where its obviously preparing to use it. + * Copy this from Wizards + */ +public class GolemBlockHail extends GolemAbility +{ + private int _currentBlock; + private int _currentLevel; + private ArrayList _fallingBlocks = new ArrayList(); + private HashMap> _floatingBlocks = new HashMap>(); + private HashMap _blocks = new HashMap(); + private int _levelToReach; + private boolean _spawned; + private ArrayList _spawnLocs = new ArrayList(); + private Player _target; + private Location _center; + private int _ticks; + + public GolemBlockHail(GolemCreature creature) + { + super(creature); + + _center = getLocation(); + + if (creature.getHealthPercent() > 0.75) + { + _levelToReach = 1; + } + else if (creature.getHealthPercent() > 0.5) + { + _levelToReach = 2; + } + else + { + _levelToReach = 3; + } + + _target = getTarget(); + } + + @Override + public Player getTarget() + { + Player target = null; + double dist = 0; + + if (inProgress()) + { + for (Player player : UtilPlayer.getNearby(_center, 40, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + if (target != null && _blocks.containsKey(player.getName()) && _blocks.get(player.getName()) > 8) + { + continue; + } + + double d = player.getLocation().distance(_center); + + if (target == null || dist > d) + { + target = player; + dist = d; + } + } + } + + return target; + } + + @Override + public boolean canMove() + { + return _spawned && _floatingBlocks.isEmpty(); + } + + @Override + public boolean hasFinished() + { + return _target == null || !_target.isValid() || ((_fallingBlocks.isEmpty() && _spawned) && _ticks >= 8 * 9) + || _center.distance(_target.getLocation()) > 100; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( + ((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().boundingBox.grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + // if (canDamage(victim)) + { + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false, + "Iron Wizard Block Hail", "Iron Wizard Block Hail"); + } + + if (victim instanceof Player) + { + getGolem().getEvent().getCondition().Factory() + .Slow("Iron Wizard Block Hail", (LivingEntity) victim, getEntity(), 3, 2, false, false, false, false); + } + + fallingIterator.remove(); + cur.remove(); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ + * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + fallingIterator.remove(); + cur.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() + .add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + @Override + public void setFinished() + { + for (ArrayList floatingBlocks : _floatingBlocks.values()) + { + for (BlockHailBlock falling : floatingBlocks) + { + Packet packet = falling.getDestroyPacket(); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + } + + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + } + + @Override + public void tick() + { + if (inProgress()) + { + for (Player player : UtilPlayer.getNearby(_center, 5, true)) + { + Location loc = player.getLocation(); + + if (Math.abs(loc.getY() - (_center.getY() + 1)) <= 1) + { + loc.setY(_center.getY()); + + if (loc.distance(_center) < 2.8 + (_currentLevel * 0.75)) + { + if (canDamage(player)) + { + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT, 6, true, true, false, + "Iron Wizard Protection", "Iron Wizard Protection"); + + loc.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId()); + loc.getWorld().playEffect(player.getEyeLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId()); + } + } + } + } + } + + if (!_spawned) + { + if (_currentBlock >= _spawnLocs.size()) + { + + if (_currentLevel + 1 <= _levelToReach) + { + _currentLevel++; + _currentBlock = 0; + + _spawnLocs = UtilShapes.getDistancedCircle(_center.clone().add(0, 2.8 + (_currentLevel * 0.75), 0), 1.3, + 1 + (_currentLevel * 1.3)); + + for (int i = UtilMath.r(_spawnLocs.size()); i > 0; i--) + { + _spawnLocs.add(_spawnLocs.remove(0)); + } + } + } + + if (_currentBlock < _spawnLocs.size()) + { + if (_ticks % 2 == 0) + { + IronGolem entity = getEntity(); + + Location loc = _spawnLocs.get(_currentBlock++); + + ArrayList floatingBlocks = new ArrayList(); + + if (_floatingBlocks.containsKey(_currentLevel)) + { + floatingBlocks = _floatingBlocks.get(_currentLevel); + } + else + { + _floatingBlocks.put(_currentLevel, floatingBlocks); + } + + if (loc.getBlock().getType() == Material.AIR && UtilAlg.HasSight(entity.getLocation(), loc)) + { + + BlockHailBlock floating = new BlockHailBlock(loc, Material.STONE); + UtilEnt.CreatureLook(entity, _target); + + floatingBlocks.add(floating); + + Packet[] packets = floating.getSpawnPackets(entity); + + for (Player player : UtilPlayer.getNearby(loc, 100)) + { + UtilPlayer.sendPacket(player, packets); + } + + entity.getWorld().playSound(entity.getLocation(), Sound.DIG_GRASS, 3, 0.9F); + } + + if (_floatingBlocks.size() % 2 == 0) + { + Collections.reverse(floatingBlocks); + } + } + } + else + { + _spawned = true; + _ticks = -20; + } + } + else if (_ticks > 0 && _ticks % 2 == 0 && !_floatingBlocks.isEmpty()) + { + IronGolem entity = getEntity(); + + if (_ticks % 16 == 0) + { + _target = getTarget(); + + if (_target == null) + return; + } + + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + UtilEnt.CreatureLook(entity, _target); + + BlockHailBlock floatingBlock = null; + + for (int i = 1; i <= _currentLevel; i++) + { + if (_floatingBlocks.containsKey(i)) + { + floatingBlock = _floatingBlocks.get(i).remove(0); + + if (_floatingBlocks.get(i).isEmpty()) + { + _floatingBlocks.remove(i); + } + + break; + } + } + + Packet packet = floatingBlock.getDestroyPacket(); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + Location loc = floatingBlock.getLocation(); + + FallingBlock b = loc.getWorld().spawnFallingBlock(loc, floatingBlock.getMaterial(), (byte) 0); + b.setDropItem(false); + + Vector vec = UtilAlg.calculateVelocity( + loc.toVector(), + _target.getLocation() + .toVector() + .add(new Vector(UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel), 0, UtilMath + .r(6 + (_currentLevel * 2)) - (2 + _currentLevel))), 6); + + b.setVelocity(vec); + + _fallingBlocks.add(b); + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 3, 0.9F); + + _blocks.put(_target.getName(), _blocks.containsKey(_target.getName()) ? _blocks.get(_target.getName()) + 1 : 1); + } + + ArrayList points = new ArrayList(); + + for (int i = _currentLevel; i <= _currentLevel; i++) + { + points.addAll(UtilShapes.getDistancedCircle(_center.clone().add(0, 3.3 + (i * 0.75), 0), 0.3, 1 + (i * 1.3))); + } + + for (int i = 0; i < points.size(); i++) + { + if (_spawned || i < _ticks) + { + Location loc = points.get(i); + + UtilParticle.PlayParticle( + ParticleType.BLOCK_DUST.getParticle(_spawned && i < _ticks ? Material.STONE : Material.DIRT, 0), loc, 0, + 0, 0, 0, 0, UtilParticle.ViewDist.LONG, UtilServer.getPlayers()); + } + } + + _ticks++; + } + + @Override + public boolean inProgress() + { + return !_spawned || !_floatingBlocks.isEmpty(); + } + +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockShot.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockShot.java new file mode 100644 index 000000000..e2edcc29e --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockShot.java @@ -0,0 +1,439 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map.Entry; +import java.util.UUID; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_7_R4.AxisAlignedBB; +import net.minecraft.server.v1_7_R4.EntityIronGolem; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MovingObjectPosition; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityVelocity; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_7_R4.Vec3D; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class GolemBlockShot extends GolemAbility +{ + private HashMap _blockLoc = new HashMap(); + private HashMap _blockType = new HashMap(); + private ArrayList _current = new ArrayList(); + private HashMap _preshoot = new HashMap(); + private Player _target; + private HashMap _targetBlock = new HashMap(); + private HashMap _shotAt = new HashMap(); + private int _thrown; + private int _tick; + private int _toThrow; + + public GolemBlockShot(GolemCreature creature) + { + super(creature); + + if (creature.getHealthPercent() > 0.75) + { + _toThrow = 3; + } + else if (creature.getHealthPercent() > 0.5) + { + _toThrow = 6; + } + else + { + _toThrow = 9; + } + + _target = getTarget(); + } + + @Override + public boolean canMove() + { + return _current.isEmpty() && _thrown == _toThrow; + } + + @Override + public Player getTarget() + { + Player target = null; + double dist = 0; + + Location loc1 = getLocation(); + Location loc2 = loc1.clone().add(loc1.getDirection().setY(0).normalize()); + + LinkedList players = UtilPlayer.getNearby(getLocation(), 40, true); + + for (Player player : players) + { + if (_shotAt.containsKey(player.getUniqueId()) && _shotAt.get(player.getUniqueId()) >= 3) + { + continue; + } + + double dist1 = player.getLocation().distance(loc1); + double dist2 = player.getLocation().distance(loc2); + + double dist3 = dist1 - dist2; + + if (dist3 < 0.6 || dist1 > 30 || (target != null && dist3 < dist)) + { + continue; + } + + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + target = player; + dist = dist3; + } + + return target; + } + + @Override + public boolean hasFinished() + { + return _current.isEmpty() && _preshoot.isEmpty() && (_target == null || _thrown >= _toThrow); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _current.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( + ((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().boundingBox.grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false, + "Iron Wizard Block Shot", "Iron Wizard Block Shot"); + + cur.remove(); + fallingIterator.remove(); + + Vector vec = UtilAlg.getTrajectory(getEntity(), victim); + vec.setY(0).normalize(); + + double strength = 1; + + if (!(victim instanceof Player) || !((Player) victim).isBlocking()) + { + strength = 1.3; + } + + UtilAction.velocity(victim, vec, strength, true, 0, 0.2, 1, true); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ + * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + cur.remove(); + fallingIterator.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() + .add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + @Override + public void setFinished() + { + for (FallingBlock falling : _current) + { + falling.remove(); + } + + int[] ids = new int[_preshoot.size()]; + + int a = 0; + for (int id : _preshoot.keySet()) + { + ids[a++] = id; + } + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ids); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + + @Override + public void tick() + { + if (_target == null || _target.getLocation().distance(getLocation()) > 30 || !_target.hasLineOfSight(getEntity())) + { + _target = getTarget(); + } + + Entity entity = getEntity(); + + if (_tick++ % 16 == 0 && _target != null && _thrown < _toThrow) + { + _thrown++; + + UtilEnt.CreatureLook(entity, _target); + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 2, 1); + + Location loc = entity.getLocation(); + loc.setYaw(loc.getYaw() + (UtilMath.r(150) - 75)); + loc.add(loc.getDirection().setY(0).normalize()); + + Block block = loc.getBlock(); + + if (block.getType() == Material.AIR) + { + block = block.getRelative(BlockFace.DOWN); + } + + Material mat = block.getType(); + + if (!UtilBlock.solid(block)) + { + mat = Material.STONE; + } + + int id = UtilEnt.getNewEntityId(); + + _preshoot.put(id, System.currentTimeMillis()); + _blockType.put(id, mat); + _blockLoc.put(id, loc.clone().add(0, 0.6, 0)); + _targetBlock.put(id, _target); + + PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(((CraftEntity) entity).getHandle(), 70, mat.getId()); + + packet.a = id; + + packet.b = (int) Math.floor(loc.getX() * 32); + packet.c = (int) Math.floor(loc.getY() * 32); + packet.d = (int) Math.floor(loc.getZ() * 32); + + packet.g = (int) ((0.45) * 8000); + + PacketPlayOutEntityVelocity packet2 = new PacketPlayOutEntityVelocity(id, 0, 0.45D, 0); + + for (Player player : UtilPlayer.getNearby(loc, 70)) + { + UtilPlayer.sendPacket(player, packet, packet2); + } + + _shotAt.put(_target.getUniqueId(), (_shotAt.containsKey(_target.getUniqueId()) ? _shotAt.get(_target.getUniqueId()) + : 0) + 1); + + _target = getTarget(); + } + else + { + Iterator> itel = _preshoot.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (UtilTime.elapsed(entry.getValue(), 920)) + { + itel.remove(); + + int id = entry.getKey(); + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] + { + id + }); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + Location loc = _blockLoc.get(id); + FallingBlock falling = loc.getWorld().spawnFallingBlock(loc, _blockType.get(id), (byte) 0); + falling.setDropItem(false); + + _current.add(falling); + + Player target = _targetBlock.get(id); + + UtilEnt.CreatureLook(entity, target); + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 2, 1.2F); + entity.getWorld().playEffect(falling.getLocation(), Effect.STEP_SOUND, falling.getBlockId()); + + Location l = falling.getLocation(); + l.setY(entity.getLocation().getY()); + + Location loc1 = target.getEyeLocation(); + + if (loc1.getY() - l.getY() > 1) + { + loc1.setY(l.getY() + 1); + } + + Vector vector = UtilAlg.getTrajectory(l, loc1); + + vector.multiply(13).add(new Vector(UtilMath.r(3) - 1, 0, UtilMath.r(3) - 1)).normalize(); + + falling.setVelocity(vector.multiply(0.5 + (l.distance(target.getEyeLocation()) / 10))); + } + } + } + + if (_thrown >= 3 && !UtilPlayer.getNearby(getLocation(), 10, true).isEmpty()) + { + _thrown = 99; + } + } + + @Override + public boolean inProgress() + { + return _thrown < _toThrow || !_current.isEmpty(); + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java new file mode 100644 index 000000000..51e0a7468 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java @@ -0,0 +1,331 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_7_R4.AxisAlignedBB; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MovingObjectPosition; +import net.minecraft.server.v1_7_R4.Vec3D; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class GolemCaveIn extends GolemAbility +{ + private ArrayList _blocks = new ArrayList(); + private ArrayList _fallingBlocks = new ArrayList(); + private int _tick; + + public GolemCaveIn(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public Player getTarget() + { + if (getTarget(4) == null) + { + return getTarget(40); + } + + return null; + } + + @Override + public boolean hasFinished() + { + return _tick > 60 && _fallingBlocks.isEmpty(); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( + ((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().boundingBox.grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + if (canDamage(victim)) + { + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false, + "Iron Wizard Cave In", "Iron Wizard Cave In"); + } + + cur.remove(); + fallingIterator.remove(); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ + * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + cur.remove(); + fallingIterator.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() + .add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + @Override + public void setFinished() + { + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + + for (Block block : _blocks) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + block.setType(Material.AIR); + } + } + + @Override + public void tick() + { + if (_tick++ == 0) + { + Location l = getLocation(); + + ArrayList blocks = UtilShapes.getSphereBlocks(l, 3, 3, true); + + for (Location loc : blocks) + { + if (loc.getBlockY() >= l.getBlockY()) + { + Block b = loc.getBlock(); + + if (b.getType() == Material.AIR) + { + _blocks.add(b); + + loc.setY(l.getY() - 1); + + b.setType(loc.getBlock().getType()); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId()); + } + } + } + } + + if (_tick % 5 == 0) + { + for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) + { + player.teleport(player.getLocation().add(0, 4, 0)); + UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize()); + } + } + + if (_tick < 200) + { + Location loc = getLocation(); + loc.setY(loc.getY() + 8); + + for (int i = 0; i < 30; i++) + { + loc.setY(loc.getY() + 1); + Block b = loc.getBlock(); + + if (UtilBlock.solid(b)) + { + break; + } + } + + if (!UtilBlock.solid(loc.getBlock())) + { + return; + } + + LinkedList players = UtilPlayer.getNearby(getLocation(), 50, true); + + for (int i = 0; i < players.size(); i++) + { + int dist = UtilMath.r(10); + + if (dist < 3) + { + dist = 2; + } + else if (dist < 5) + { + dist = 5; + } + else + { + dist = 10; + } + + Location l = players.get(UtilMath.r(players.size())).getLocation() + .add(UtilMath.r(dist * 2) - dist, 0, UtilMath.r(dist * 2) - dist); + l.setY(loc.getY()); + + Block b = l.getBlock(); + l.subtract(0, 1, 0); + + if (UtilBlock.solid(b)) + { + if (l.getBlock().getType() == Material.AIR) + { + if (UtilAlg.HasSight(l, getLocation().add(0, 8, 0))) + { + FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(), + b.getData()); + + block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId()); + block.setDropItem(false); + + _fallingBlocks.add(block); + } + } + } + } + } + } + + @Override + public boolean inProgress() + { + return true; + } + +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java new file mode 100644 index 000000000..41ed9c38d --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java @@ -0,0 +1,167 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.UUID; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class GolemEarthquake extends GolemAbility +{ + private Location _center; + private float _range; + private int _tick; + private ArrayList _damaged = new ArrayList(); + private boolean _earthquake; + + public GolemEarthquake(GolemCreature creature) + { + super(creature); + _center = getLocation(); + } + + @Override + public boolean canMove() + { + return !UtilEnt.isGrounded(getEntity()) && _tick > 1; + } + + @Override + public Player getTarget() + { + return getTarget(7); + } + + @Override + public boolean hasFinished() + { + return _range > 19; + } + + @Override + public void setFinished() + { + } + + @Override + public void tick() + { + Entity entity = getEntity(); + + if (_tick == 0) + { + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 4, 0); + + entity.setVelocity(new Vector(0, 1, 0)); + } + else if (!_earthquake) + { + _earthquake = _tick > 10 && UtilEnt.isGrounded(entity); + } + + if (_earthquake) + { + _range += 0.7; + + for (float range = _range - 2; range <= _range; range++) + { + if (range <= 0) + { + continue; + } + + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + if ((x != 0) == (z != 0)) + { + continue; + } + + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + _center.clone().add(x * range, 0.1, z * range), (x != 0) ? 0 : (range / 2), 0.1F, (z != 0) ? 0 + : (range / 2), 0, (int) (range * 4), UtilParticle.ViewDist.NORMAL, UtilServer + .getPlayers()); + } + } + } + + _center.getWorld().playSound(_center, Sound.DIG_GRASS, 2, 0.8F); + + HashSet toDamage = new HashSet(); + + Location cornerA = _center.clone().add(-_range, -1, -_range); + Location cornerB = _center.clone().add(_range, 1, _range); + Location cornerA1 = _center.clone().add(-(_range - 1.5), -1, -(_range - 1.5)); + Location cornerB1 = _center.clone().add(_range - 1.5, 1, _range - 1.5); + + for (Player player : Bukkit.getOnlinePlayers()) + { + Location pLoc = player.getLocation(); + + if (_damaged.contains(player.getUniqueId())) + { + continue; + } + + if (!UtilAlg.inBoundingBox(pLoc, cornerA, cornerB)) + { + continue; + } + + if (UtilAlg.inBoundingBox(pLoc, cornerA1, cornerB1)) + { + continue; + } + + toDamage.add(player); + } + + for (Player player : toDamage) + { + _damaged.add(player.getUniqueId()); + + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent((LivingEntity) player, getEntity(), null, DamageCause.CONTACT, 12, false, true, false, + "Iron Wizard Earthquake", "Iron Wizard Earthquake"); + + getGolem().getEvent().getCondition().Factory() + .Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false, false, false, false); + + // Velocity + UtilAction.velocity(player, UtilAlg.getTrajectory2d(getLocation().toVector(), player.getLocation().toVector()), + 1.8, true, 0, 0.5, 0.5, true); + + // Condition + getGolem().getEvent().getCondition().Factory().Falling("Earthquake", player, getEntity(), 10, false, true); + } + } + + _tick++; + } + + @Override + public boolean inProgress() + { + return !_earthquake; + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplodingAura.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplodingAura.java new file mode 100644 index 000000000..796ec50da --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplodingAura.java @@ -0,0 +1,418 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import net.minecraft.server.v1_7_R4.AxisAlignedBB; +import net.minecraft.server.v1_7_R4.DataWatcher; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MovingObjectPosition; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_7_R4.Vec3D; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class GolemExplodingAura extends GolemAbility +{ + + private HashMap _blocks = new HashMap(); + private HashMap _blocksLoc = new HashMap(); + private ArrayList _fallingBlocks = new ArrayList(); + // private HashMap _blocksExplode = new HashMap(); + private HashMap _blockMaterial = new HashMap(); + private int _tick; + + public GolemExplodingAura(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _tick > 20 * 30 && _blocks.isEmpty() && _fallingBlocks.isEmpty(); + } + + @Override + public void setFinished() + { + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + + int[] ids = new int[_blocks.size() * 2]; + + int i = 0; + + for (Entry id : _blocks.entrySet()) + { + ids[i] = id.getKey(); + ids[i + 1] = id.getValue(); + + i += 2; + } + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ids); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + + @Override + public void tick() + { + if (_tick < 25 * 25) + { + double angle = (2 * Math.PI) / UtilMath.random.nextDouble(); + double x = 1.7 * Math.cos(angle); + double z = 1.7 * Math.sin(angle); + + Location loc = getLocation().add(x, 1 + (UtilMath.random.nextDouble() * 1.6), z); + + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.DIRT.getId()); + + for (Player player : UtilPlayer.getNearby(getLocation(), 3, true)) + { + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT, 2, true, true, false, + "Iron Wizard Protection", "Iron Wizard Protection"); + UtilAction.velocity(player, UtilAlg.getTrajectory(getEntity(), player), 1, true, 0.3, 0, 0.3, false); + } + } + + if (_tick < 20 * 30) + { + int key = UtilEnt.getNewEntityId(); + int value = UtilEnt.getNewEntityId(); + + Location loc = null; + + for (int i = 0; i < 30; i++) + { + double angle = (2 * Math.PI) / UtilMath.random.nextDouble(); + double x = 1.7 * Math.cos(angle); + double z = 1.7 * Math.sin(angle); + + loc = getLocation().add(x, 1 + (UtilMath.random.nextDouble() * 1.6), z); + boolean found = false; + + for (Location l : _blocksLoc.values()) + { + if (l.distance(loc) < 0.3) + { + found = true; + break; + } + } + + if (found) + { + loc = null; + } + else + { + break; + } + } + + if (loc != null) + { + _blocks.put(key, value); + _blocksLoc.put(key, loc); + // _blocksExplode.put(key, System.currentTimeMillis() + UtilMath.r(800) + 100); + _blockMaterial.put(key, UtilMath.random.nextBoolean() ? Material.DIRT : Material.STONE); + + Packet[] packets = new Packet[3]; + + PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); + + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 32); + watcher.a(1, 0); + + packet1.a = key; + packet1.b = EntityType.SILVERFISH.getTypeId(); + packet1.c = (int) Math.floor(loc.getX() * 32); + packet1.d = (int) Math.floor((loc.getY() - 0.125) * 32); + packet1.e = (int) Math.floor(loc.getZ() * 32); + packet1.l = watcher; + + packets[0] = packet1; + + PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftEntity) getEntity()).getHandle(), 70, + _blockMaterial.get(key).getId()); + + packet2.a = value; + + packet2.b = (int) Math.floor(loc.getX() * 32); + packet2.c = (int) Math.floor(loc.getY() * 32); + packet2.d = (int) Math.floor(loc.getZ() * 32); + + packets[1] = packet2; + + PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity(); + + packet3.b = value; + packet3.c = key; + + packets[2] = packet3; + + for (Player player : UtilPlayer.getNearby(getLocation(), 70)) + { + UtilPlayer.sendPacket(player, packets); + } + } + } + + /*Iterator itel = _blocksExplode.keySet().iterator(); + + while (itel.hasNext()) + { + int key = itel.next(); + + if (_blocksExplode.get(key) < System.currentTimeMillis()) + { + itel.remove();*/ + if (_tick % 25 == 0) + { + for (int i = 0; i < 3; i++) + getLocation().getWorld().playSound(getLocation(), Sound.DIG_GRASS, 3, 2); + + for (int key : new ArrayList(_blocksLoc.keySet())) + { + + PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(new int[] + { + key, _blocks.remove(key) + }); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, destroyPacket); + } + + Location loc = _blocksLoc.remove(key); + + FallingBlock falling = loc.getWorld().spawnFallingBlock(loc, _blockMaterial.remove(key), (byte) 0); + + _fallingBlocks.add(falling); + + Vector vec = UtilAlg.getTrajectory(getLocation().add(0, 1, 0), loc); + + vec.setY(Math.max(0.05, vec.getY())); + + falling.setVelocity(vec); + + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.DIRT.getId()); + } + } + + _tick++; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( + ((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().boundingBox.grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + // if (canDamage(victim)) + { + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false, + "Blocky Iron Wizard Aura", "Blocky Iron Wizard Aura"); + } + + if (victim instanceof Player) + { + getGolem() + .getEvent() + .getCondition() + .Factory() + .Slow("Blocky Iron Wizard Aura", (LivingEntity) victim, getEntity(), 3, 2, false, false, false, false); + } + + fallingIterator.remove(); + cur.remove(); + + Vector vec = UtilAlg.getTrajectory(getEntity(), victim); + vec.setY(0).normalize(); + + double strength = 1; + + if (!(victim instanceof Player) || !((Player) victim).isBlocking()) + { + strength = 1.3; + } + + UtilAction.velocity(victim, vec, strength, true, 0, 0.2, 1, true); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ + * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + fallingIterator.remove(); + cur.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() + .add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + @Override + public boolean inProgress() + { + return false; + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplosiveBlock.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplosiveBlock.java new file mode 100644 index 000000000..eda1d77d3 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplosiveBlock.java @@ -0,0 +1,589 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import net.minecraft.server.v1_7_R4.AxisAlignedBB; +import net.minecraft.server.v1_7_R4.DataWatcher; +import net.minecraft.server.v1_7_R4.EntityIronGolem; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MovingObjectPosition; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_7_R4.Vec3D; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +public class GolemExplosiveBlock extends GolemAbility +{ + private HashMap _blocksLocation = new HashMap(); + private Location _center; + private int _explosionsLeft; + private FallingBlock _fallingBlock; + private HashMap _fallingBlocks = new HashMap(); + private ArrayList _items = new ArrayList(); + private int _strength; + private Player _target; + private int _tick; + + public GolemExplosiveBlock(GolemCreature creature, int strength) + { + super(creature); + + _strength = strength; + _center = getLocation().add(0, 3, 0); + _target = getTarget(); + + if (_target != null) + { + UtilEnt.CreatureLook(getEntity(), _target); + } + } + + @Override + public boolean canMove() + { + return _fallingBlock != null; + } + + private int clamp(int value) + { + if (value < -127) + return -127; + + if (value > 127) + return 127; + + return value; + } + + @Override + public Player getTarget() + { + HashMap locs = new HashMap(); + + for (Player player : UtilServer.getPlayers()) + { + double dist = player.getLocation().distance(_center); + + if (dist < 30) + { + double score = (dist > 10 ? 30 - dist : 10); + + for (Player p : UtilServer.getPlayers()) + { + if (player.getLocation().distance(p.getLocation()) < 4) + { + score += 7; + } + } + + if (player.hasLineOfSight(getEntity())) + { + score += 10; + } + + locs.put(player, score); + } + } + + Player lowest = null; + + for (Entry entry : locs.entrySet()) + { + if (lowest == null || locs.get(lowest) > locs.get(entry.getKey())) + { + lowest = entry.getKey(); + } + } + + return lowest; + } + + @Override + public boolean hasFinished() + { + return _target == null || (_fallingBlock != null && !_fallingBlock.isValid() && _explosionsLeft == 0); + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getEntity())) + { + if (_tick >= 40 + (40 * _strength) && _tick <= 50 + (40 * _strength)) + { + event.SetCancelled("Iron Wizard charging bomb"); + } + + event.SetKnockback(false); + } + } + + public void onExplode(final Location loc) + { + for (int i = 0; i < _strength * 2; i++) + { + if (i == 0) + { + onSubExplode(loc); + } + else + { + _explosionsLeft++; + + Bukkit.getScheduler().scheduleSyncDelayedTask(getGolem().getEvent().getPlugin(), new Runnable() + { + public void run() + { + onSubExplode(loc); + _explosionsLeft--; + } + }, 2 * i); + } + } + } + + public void onSubExplode(Location loc) + { + for (int i = 0; i < 2; i++) + { + Location l = loc.clone().add(UtilMath.r(_strength * 4) - (_strength * 2), UtilMath.r(_strength * 2), + UtilMath.r(_strength * 4) - (_strength * 2)); + + /* CustomExplosion explosion = new CustomExplosion(getGolem().getEvent().getDamageManager(), getGolem().getEvent() + .getEventManager().getClans().getExplosion(), l, _strength * 0.8F, "Golem Explosive Block"); + + explosion.setPlayer(getEntity(), false); + + explosion.setDamageBlocks(false); + + explosion.explode();*/ + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, l, _strength * 3, 1, _strength * 3, 0, _strength * 4, + ViewDist.LONG, UtilServer.getPlayers()); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_fallingBlock == null) + { + return; + } + + if (_fallingBlock.isDead() + || !_fallingBlock.isValid() + || _fallingBlock.getTicksLived() > 400 + || !_fallingBlock.getWorld().isChunkLoaded(_fallingBlock.getLocation().getBlockX() >> 4, + _fallingBlock.getLocation().getBlockZ() >> 4)) + { + Block block = _fallingBlock.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + _fallingBlock.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _fallingBlock.getBlockId()); + + // Expire + if (_fallingBlock.getTicksLived() > 400 + || !_fallingBlock.getWorld().isChunkLoaded(_fallingBlock.getLocation().getBlockX() >> 4, + _fallingBlock.getLocation().getBlockZ() >> 4)) + { + _fallingBlock.remove(); + return; + } + + _fallingBlock.remove(); + return; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) _fallingBlock).getHandle(); + Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) _fallingBlock.getWorld()).getHandle().getEntities( + ((CraftEntity) _fallingBlock).getHandle(), + ((CraftEntity) _fallingBlock).getHandle().boundingBox.a(((CraftEntity) _fallingBlock).getHandle().motX, + ((CraftEntity) _fallingBlock).getHandle().motY, ((CraftEntity) _fallingBlock).getHandle().motZ).grow(2, + 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().boundingBox.grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + onExplode(victim.getEyeLocation()); + + _fallingBlock.remove(); + } + else if (finalObjectPosition != null) + { + Block block = _fallingBlock.getWorld() + .getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ + * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + onExplode(block.getLocation().add(0.5, 0.5, 0.5)); + + _fallingBlock.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + _fallingBlock.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + + @Override + public void setFinished() + { + int[] ids = new int[_fallingBlocks.size() * 2]; + + int index = 0; + + for (Entry entry : _fallingBlocks.entrySet()) + { + ids[index] = entry.getKey(); + ids[index + 1] = entry.getValue(); + index += 2; + } + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ids); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + for (Item item : _items) + { + item.remove(); + } + + if (_fallingBlock != null) + { + _fallingBlock.remove(); + } + } + + @Override + public void tick() + { + IronGolem entity = getEntity(); + + Iterator itel = _items.iterator(); + + while (itel.hasNext()) + { + Item item = itel.next(); + + Vector vec = item.getVelocity(); + Location loc = item.getLocation(); + + if (item.getTicksLived() > 100 || vec.getY() <= 0 || loc.distance(_center) > loc.add(vec).distance(_center) + || UtilEnt.isGrounded(item)) + { + itel.remove(); + } + } + + // This spawns a floating block + if (_tick >= 20 && _tick % 60 == 0 && _fallingBlocks.size() < _strength) + { + int id = UtilEnt.getNewEntityId(); + int id2 = UtilEnt.getNewEntityId(); + + _fallingBlocks.put(id, id2); + _blocksLocation.put(id, _center.toVector()); + + Packet[] packets = new Packet[3]; + + PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); + + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 32); + watcher.a(1, 0); + + packet1.a = id; + packet1.b = EntityType.SILVERFISH.getTypeId(); + packet1.c = (int) Math.floor(_center.getX() * 32); + packet1.d = (int) Math.floor((_center.getY() - 0.125) * 32); + packet1.e = (int) Math.floor(_center.getZ() * 32); + packet1.l = watcher; + + packets[0] = packet1; + + PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftEntity) entity).getHandle(), 70, + Material.DIRT.getId()); + + packet2.a = id2; + + packet2.b = (int) Math.floor(_center.getX() * 32); + packet2.c = (int) Math.floor(_center.getY() * 32); + packet2.d = (int) Math.floor(_center.getZ() * 32); + + packets[1] = packet2; + + PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity(); + + packet3.b = id2; + packet3.c = id; + + packets[2] = packet3; + + for (Player player : UtilServer.getPlayers()) + { + if (player.getLocation().distance(_center) < 80) + { + UtilPlayer.sendPacket(player, packets); + } + } + } + + // This spawns a item that flies above the golem's head and disappears + if (UtilMath.r(6) == 0 && _tick < 40 + (_strength * 40)) + { + double angle = ((2 * Math.PI) / 30) * UtilMath.r(30); + double x = 5 * Math.cos(angle); + double z = 5 * Math.sin(angle); + Location loc = _center.clone().add(x, -3, z); + + Material mat = null; + + switch (UtilMath.r(3)) + { + case 0: + mat = Material.DIRT; + break; + case 1: + mat = Material.STONE; + break; + case 2: + mat = Material.COBBLESTONE; + break; + default: + break; + } + + Item item = loc.getWorld().dropItem(loc, new ItemBuilder(mat).setTitle(System.currentTimeMillis() + "").build()); + + item.setPickupDelay(999999); + + Vector vec = UtilAlg.getTrajectory(_center, item.getLocation()); + + vec.normalize().multiply(5); + + item.setVelocity(vec); + + // TODO Fix velocity + + _items.add(item); + } + + // 10 being when items no longer fly in, 0 being when its shot. + int ticksTillFired = (60 + (40 * _strength)) - _tick; + + if (ticksTillFired > 20) + { + int strength = (int) Math.floor(_tick / 20D); + + int nine = 8 - strength; + + if (_tick % nine == 0) + { + _center.getWorld().playSound(_center, Sound.DIG_GRASS, strength + 1, 1F); + } + } + else if (ticksTillFired < 0) + { + if (_tick % 3 == 0) + { + _center.getWorld().playSound(_fallingBlock.getLocation(), Sound.WOOD_CLICK, _strength + 1, 0.4F); + } + } + + // The location the falling blocks need to stick by + Vector blockCenter = _center.toVector(); + + if (ticksTillFired >= 0 && ticksTillFired <= 20) + { + Vector vec = entity.getLocation().add(entity.getLocation().getDirection().setY(0).normalize().multiply(1.2)) + .add(0, 1, 0).toVector(); + + blockCenter = UtilAlg.getTrajectory(_center.toVector(), blockCenter); + vec.multiply(ticksTillFired / 10D); + + _center.getWorld().playSound(_center, Sound.DIG_SNOW, _strength + 1, 0); + } + else if (_fallingBlock != null) + { + blockCenter = _fallingBlock.getLocation().add(0, 0.5, 0).toVector(); + } + + // Move the fake floating blocks + for (Entry entry : _fallingBlocks.entrySet()) + { + int id = entry.getKey(); + Vector vec = _blocksLocation.get(id); + + int x = clamp((int) ((blockCenter.getX() - vec.getX()) * 32) + (UtilMath.r(8) - 4)); + int y = clamp((int) ((blockCenter.getY() - vec.getY()) * 32) + (UtilMath.r(8) - 4)); + int z = clamp((int) ((blockCenter.getZ() - vec.getZ()) * 32) + (UtilMath.r(8) - 4)); + + vec.add(new Vector(x, y, z)); + + PacketPlayOutRelEntityMove packet = new PacketPlayOutRelEntityMove(); + + packet.a = id; + + packet.b = (byte) x; + packet.c = (byte) y; + packet.d = (byte) z; + + for (Player player : UtilServer.getPlayers()) + { + if (player.getLocation().distance(_center) < 70) + { + UtilPlayer.sendPacket(player, packet); + + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + vec.toLocation(_center.getWorld()), 0.7F, 0.7F, 0.7F, 0, 11, ViewDist.NORMAL, player); + } + } + } + + if (ticksTillFired == 0) + { + int id = _fallingBlocks.keySet().iterator().next(); + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] + { + id, _fallingBlocks.get(id) + }); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + _fallingBlocks.remove(id); + + _fallingBlock = _center.getWorld().spawnFallingBlock(_blocksLocation.get(id).toLocation(_center.getWorld()), + Material.STONE, (byte) 0); + + Vector vec1 = _fallingBlock.getLocation().toVector(); + Vector vec2 = _target.getLocation().toVector(); + + Vector vec = UtilAlg.calculateVelocity(vec1, vec2, (int) (vec1.distanceSquared(vec2) / 4)); + + _fallingBlock.setVelocity(vec); + + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + } + + _tick++; + } + + @Override + public boolean inProgress() + { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemMeleeAttack.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemMeleeAttack.java new file mode 100644 index 000000000..9b9a9e220 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemMeleeAttack.java @@ -0,0 +1,95 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_7_R4.EntityIronGolem; + +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class GolemMeleeAttack extends GolemAbility +{ + private boolean _attacked; + + public GolemMeleeAttack(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public Player getTarget() + { + return getTarget(2); + } + + @Override + public boolean hasFinished() + { + return _attacked; + } + + @Override + public void setFinished() + { + } + + @Override + public void tick() + { + _attacked = true; + + for (Player target : UtilPlayer.getNearby(getLocation(), 2.5, true)) + { + if (target.getVelocity().length() > 0.5) + { + continue; + } + + UtilEnt.CreatureLook(getEntity(), target); + + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK, 6, false, true, false, + "Iron Wizard Melee Attack", "Iron Wizard Melee Attack"); + + Vector vec = getLocation().getDirection(); + vec.setY(0).normalize().multiply(0.2); + vec.setY(1); + + UtilAction.velocity(target, vec, 1.4, false, 0, 0, 2, false); + + getGolem().getEvent().getCondition().Factory().Falling("Iron Wizard Throw", target, getEntity(), 3, false, false); + + target.getWorld().playSound(target.getLocation(), Sound.IRONGOLEM_THROW, 3, 0.9F); + + EntityIronGolem golem = ((CraftIronGolem) getEntity()).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + } + } + + @Override + public boolean inProgress() + { + return _attacked; + } + +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRumble.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRumble.java new file mode 100644 index 000000000..6df54698c --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRumble.java @@ -0,0 +1,243 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_7_R4.EntityIronGolem; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +/** + * Rumble is where the golem picks a target then starts playing a animation for a second where its obviously preparing to use it. + * Copy this from Wizards + */ +public class GolemRumble extends GolemAbility +{ + private Location _loc; + private int _ticks; + private int _travelled; + private Vector _vec; + private int _width = 1; + private Location _target; + + public GolemRumble(GolemCreature creature) + { + super(creature); + + Player target = getTarget(); + + if (target != null) + { + _target = target.getLocation(); + + UtilEnt.CreatureLook(getEntity(), _target); + } + } + + @Override + public boolean canMove() + { + return _ticks >= 20; + } + + @Override + public boolean hasFinished() + { + return _travelled > 35; + } + + @Override + public void setFinished() + { + } + + @Override + public void tick() + { + if (_ticks++ < 14) + { + IronGolem entity = getEntity(); + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + + if (_ticks % 2 == 0) + { + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 3, 2F); + } + } + else if (_ticks % 2 == 0) + { + int oldWidth = _width; + + if ((_width <= 3 || _ticks % 4 == 0) && _width <= 6) + { + _width++; + } + + Location newLoc; + boolean validBlock = false; + ArrayList current = new ArrayList(); + + if (_vec == null) + { + _vec = _target.subtract(getLocation()).toVector().setY(0).normalize();// .multiply(0.5); + _loc = getLocation().subtract(0, 1, 0).getBlock().getLocation().add(0, 0.99, 0); + newLoc = _loc; + current.add(_loc.getBlock()); + + validBlock = true; + } + else + { // Move rumble + newLoc = _loc.clone().add(_vec); + + // Check if the rumble needs to go up or drop a block or two + for (int y : new int[] + { + 0, 1, -1 + }) + { + for (int a = 1; a <= 2; a++) + { + Block b = newLoc.clone().add(_vec.clone().multiply(a)).getBlock().getRelative(0, y, 0); + + if (UtilBlock.solid(b) && !UtilBlock.solid(b.getRelative(0, 1, 0))) + { + validBlock = true; + newLoc.add(0, y, 0); + + break; + } + } + + if (validBlock) + { + break; + } + } + + for (int width = -_width; width <= _width; width++) + { + if (Math.abs(width) <= oldWidth) + { + Block b = _loc.clone().add(UtilAlg.getRight(_vec).multiply(width)).getBlock(); + + if (!current.contains(b)) + { + current.add(b); + } + } + + if (validBlock) + { + Block b = newLoc.clone().add(UtilAlg.getRight(_vec).multiply(width)).getBlock(); + + if (!current.contains(b)) + { + current.add(b); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); + } + } + } + } + + UtilEnt.CreatureLook(getEntity(), _loc); + + for (Entity entity : getEntity().getWorld().getEntities()) + { + if (entity instanceof Damageable && !UtilPlayer.isSpectator(entity) && entity != getEntity()) + { + Block b = entity.getLocation().getBlock(); + boolean canDamage = false; + + for (int y = -1; y <= 0; y++) + { + if (current.contains(b.getRelative(0, y, 0))) + { + canDamage = true; + break; + } + } + + if (!canDamage) + { + continue; + } + + if (canDamage(entity)) + { + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent((LivingEntity) entity, getEntity(), null, DamageCause.CONTACT, 4, false, true, + false, "Iron Wizard Rumble", "Iron Wizard Rumble"); + } + + UtilAction.velocity(entity, _vec.clone(), 1.5, true, 0, 0.2, 1, true); + + if (entity instanceof Player) + { + getGolem().getEvent().getCondition().Factory() + .Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1, false, false, false, false); + } + } + } + + if (_travelled++ > 35 || !validBlock) + { + _travelled = 100; + } + + _loc = newLoc; + } + } + + public Player getTarget() + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getLocation(), 30, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + double d = player.getLocation().distance(getLocation()); + + if (d > 2 && (target == null || dist > d)) + { + target = player; + dist = d; + } + } + + return target; + } + + @Override + public boolean inProgress() + { + return _ticks < 14; + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemWallExplode.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemWallExplode.java new file mode 100644 index 000000000..a96961311 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemWallExplode.java @@ -0,0 +1,416 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_7_R4.AxisAlignedBB; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MovingObjectPosition; +import net.minecraft.server.v1_7_R4.Vec3D; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class GolemWallExplode extends GolemAbility +{ + private HashMap> _blockWalls = new HashMap>(); + private ArrayList _dontTarget = new ArrayList(); + private ArrayList _fallingBlocks = new ArrayList(); + private int _maxTimes = UtilMath.r(2) + 1; + private int _tick; + private int _timesDone; + private HashMap _wallTimers = new HashMap(); + + public GolemWallExplode(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public int getCooldown() + { + return 20; + } + + private float getMod(int div) + { + return UtilMath.random.nextFloat() / div; + } + + @Override + public Player getTarget() + { + for (Player player : UtilPlayer.getNearby(getLocation(), 15, true)) + { + if (_dontTarget.contains(player.getName())) + { + continue; + } + + if (player.getLocation().distance(getLocation()) <= 4) + { + continue; + } + + return player; + } + + return null; + } + + @Override + public boolean hasFinished() + { + return _wallTimers.isEmpty() && _fallingBlocks.isEmpty() && _timesDone >= _maxTimes; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( + ((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().boundingBox.grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + if (canDamage(victim)) + { + getGolem() + .getEvent() + .getDamageManager() + .NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false, + "Iron Wizard Wall Explosion", "Iron Wizard Wall Explosion"); + } + + cur.remove(); + fallingIterator.remove(); + + Vector vec = cur.getVelocity(); + + UtilAction.velocity(victim, vec, 1.5, true, 0, 0.2, 1, true); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ + * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + cur.remove(); + fallingIterator.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() + .add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + @Override + public void setFinished() + { + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + + for (ArrayList list : _blockWalls.values()) + { + for (Block b : list) + { + b.setType(Material.AIR); + } + } + } + + @Override + public void tick() + { + if (_tick++ % 30 == 0 && _timesDone < _maxTimes) + { + _dontTarget.clear(); + + _timesDone++; + + for (int i = 0; i < 10; i++) + { + Player target = getTarget(); + + if (target == null) + { + if (_dontTarget.isEmpty()) + { + _timesDone = _maxTimes; + } + } + else + { + _dontTarget.add(target.getName()); + + UtilEnt.CreatureLook(getEntity(), target); + + BlockFace face = UtilShapes.getFacing(getLocation().getYaw()); + + if (_wallTimers.containsKey(face)) + { + continue; + } + + ArrayList blocks = new ArrayList(); + + Location loc = getLocation().getBlock().getLocation().add(0.5, 0, 0.5); + + int mul = (face.getModX() != 0 && face.getModZ() != 0) ? 2 : 3; + + loc.add(face.getModX() * mul, 0, face.getModZ() * mul); + + Block b = loc.getBlock(); + + BlockFace sideFace = UtilShapes.getSideBlockFaces(face, true)[0]; + boolean invalid = false; + + for (int mult = -3; mult <= 3; mult++) + { + Block block = b; + + if (Math.abs(mult) < 3) + { + block = block.getRelative(face); + } + + block = block.getRelative(sideFace, mult); + + if (Math.abs(mult) == 3 && face.getModX() != 0 && face.getModZ() != 0) + { + block = block.getRelative(UtilShapes.getSideBlockFaces(face, false)[mult < 0 ? 0 : 1]); + } + + if (!UtilAlg.HasSight(getLocation(), block.getLocation())) + { + invalid = true; + break; + } + + Block under = block.getRelative(0, -1, 0); + + if (!UtilBlock.solid(under)) + { + continue; + } + + for (int y = 0; y <= 1; y++) + { + block = block.getRelative(0, y, 0); + + if (block.getType() != Material.AIR) + { + invalid = true; + break; + } + + blocks.add(block); + } + + if (invalid) + { + break; + } + } + + if (invalid) + { + continue; + } + + for (Block block : blocks) + { + block.setType(block.getWorld().getBlockAt(block.getX(), b.getY() - 1, block.getZ()).getType()); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + } + + _blockWalls.put(face, blocks); + _wallTimers.put(face, System.currentTimeMillis()); + break; + } + } + } + + Iterator>> itel = _blockWalls.entrySet().iterator(); + boolean doExplode = false; + + while (itel.hasNext()) + { + Entry> entry = itel.next(); + BlockFace face = entry.getKey(); + + if (UtilTime.elapsed(_wallTimers.get(face), 1000)) + { + doExplode = true; + itel.remove(); + _wallTimers.remove(face); + + for (Block b : entry.getValue()) + { + FallingBlock block = getEntity().getWorld().spawnFallingBlock(b.getLocation().add(0.5, 0, 0.5), b.getType(), + (byte) 0); + + block.setDropItem(false); + + int index = entry.getValue().indexOf(b); + + BlockFace f = index == 8 || index == 9 ? BlockFace.SELF + : UtilShapes.getSideBlockFaces(face, true)[index > 6 ? 0 : 1]; + + block.setVelocity(new Vector((face.getModX() * 0.6) + (f.getModX() * (0.05 + getMod(10))), 0.2 + getMod(15), + (face.getModZ() * 0.6) + (f.getModZ() * (0.05 + getMod(10))))); + + _fallingBlocks.add(block); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); + b.setType(Material.AIR); + } + } + } + + if (doExplode) + { + onUpdate(new UpdateEvent(UpdateType.TICK)); + } + } + + @Override + public boolean inProgress() + { + return false; + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/SlimeBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java similarity index 66% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/SlimeBoss.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java index 3fc49866e..9618a13a7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/SlimeBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java @@ -1,51 +1,41 @@ -package mineplex.game.clans.clans.worldevent.event.slimeking; +package mineplex.minecraft.game.core.boss.slimeking; import java.io.File; import java.io.IOException; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.block.schematic.UtilSchematic; +import mineplex.core.projectile.ProjectileManager; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.EventMap; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.slimeking.creature.SlimeCreature; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.util.Vector; -import mineplex.core.common.block.schematic.Schematic; -import mineplex.core.common.block.schematic.UtilSchematic; -import mineplex.game.clans.clans.worldevent.EventMap; -import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.clans.worldevent.creature.EventCreature; -import mineplex.game.clans.clans.worldevent.event.EventState; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; -import mineplex.game.clans.clans.worldevent.event.slimeking.creature.SlimeCreature; - public class SlimeBoss extends WorldEvent { private static final int MAX_SIZE = 16; private static final int MIN_SIZE = 2; + private ProjectileManager _projectileManager; - public SlimeBoss(WorldEventManager eventManager, Location corner) + public SlimeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, + ProjectileManager projectileManager, Location corner) { - super(eventManager, "Slime King", corner); + super(damageManager, blockRestore, conditionManager, "Slime King", corner, "schematic/ClansSlimeFinal.schematic"); - Schematic schematic = null; + _projectileManager = projectileManager; + } - try - { - schematic = UtilSchematic.loadSchematic(new File("schematic/ClansSlimeFinal.schematic")); - } - catch (IOException e) - { - e.printStackTrace(); - setState(EventState.COMPLETE); - } - - EventMap map = new EventMap(schematic, corner, 15, 15, 15, 15, 15, 15); - setMap(map, new Runnable() - { - @Override - public void run() - { - System.out.println("Runnable on complete"); - } - }); + public ProjectileManager getProjectileManager() + { + return _projectileManager; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/AbsorbAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/AbsorbAbility.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/AbsorbAbility.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/AbsorbAbility.java index 051df0106..75c0b6e3d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/AbsorbAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/AbsorbAbility.java @@ -1,16 +1,16 @@ -package mineplex.game.clans.clans.worldevent.event.slimeking.ability; +package mineplex.minecraft.game.core.boss.slimeking.ability; import java.util.HashMap; import java.util.Map; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.boss.slimeking.creature.SlimeCreature; + import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.util.Vector; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.worldevent.event.slimeking.creature.SlimeCreature; - public class AbsorbAbility extends SlimeAbility { private int _ticksPerPulse; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/LeapAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/LeapAbility.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/LeapAbility.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/LeapAbility.java index faac3c0b8..126e22be5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/LeapAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/LeapAbility.java @@ -1,4 +1,9 @@ -package mineplex.game.clans.clans.worldevent.event.slimeking.ability; +package mineplex.minecraft.game.core.boss.slimeking.ability; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.boss.slimeking.creature.SlimeCreature; import org.bukkit.Material; import org.bukkit.World; @@ -7,11 +12,6 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.worldevent.event.slimeking.creature.SlimeCreature; - public class LeapAbility extends SlimeAbility { private Player _target; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/RocketAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/RocketAbility.java similarity index 93% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/RocketAbility.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/RocketAbility.java index d1b10a69d..5b0319cad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/RocketAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/RocketAbility.java @@ -1,17 +1,8 @@ -package mineplex.game.clans.clans.worldevent.event.slimeking.ability; +package mineplex.minecraft.game.core.boss.slimeking.ability; import java.util.Iterator; import java.util.LinkedList; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.util.Vector; - import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; @@ -20,7 +11,16 @@ import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; -import mineplex.game.clans.clans.worldevent.event.slimeking.creature.SlimeCreature; +import mineplex.minecraft.game.core.boss.slimeking.creature.SlimeCreature; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.util.Vector; public class RocketAbility extends SlimeAbility implements IThrown { @@ -98,7 +98,7 @@ public class RocketAbility extends SlimeAbility implements IThrown projectile.setSize(1); _shots.add(new ShotData(projectile, target)); - ProjectileManager pm = getSlime().getEvent().getEventManager().getClans().getProjectile(); + ProjectileManager pm = getSlime().getProjectileManager(); pm.AddThrow(projectile, getSlime().getEntity(), this, -1, true, true, true, null, 0, 0, UtilParticle.ParticleType.SLIME, UpdateType.FASTEST, 1F); // Bukkit.broadcastMessage("Shot Slime at target " + target); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/SlamAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/SlamAbility.java similarity index 95% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/SlamAbility.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/SlamAbility.java index eaba235d8..3063aab0c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/SlamAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/SlamAbility.java @@ -1,19 +1,19 @@ -package mineplex.game.clans.clans.worldevent.event.slimeking.ability; +package mineplex.minecraft.game.core.boss.slimeking.ability; import java.util.LinkedList; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.minecraft.game.core.boss.slimeking.creature.SlimeCreature; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.game.clans.clans.worldevent.event.slimeking.creature.SlimeCreature; - public class SlamAbility extends SlimeAbility { private int _findAttempts; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/SlimeAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/SlimeAbility.java similarity index 80% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/SlimeAbility.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/SlimeAbility.java index e53101499..f18021878 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/ability/SlimeAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/SlimeAbility.java @@ -1,6 +1,6 @@ -package mineplex.game.clans.clans.worldevent.event.slimeking.ability; +package mineplex.minecraft.game.core.boss.slimeking.ability; -import mineplex.game.clans.clans.worldevent.event.slimeking.creature.SlimeCreature; +import mineplex.minecraft.game.core.boss.slimeking.creature.SlimeCreature; public abstract class SlimeAbility { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/creature/SlimeCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/creature/SlimeCreature.java similarity index 65% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/creature/SlimeCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/creature/SlimeCreature.java index 6cbe06773..068f20380 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/slimeking/creature/SlimeCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/creature/SlimeCreature.java @@ -1,4 +1,15 @@ -package mineplex.game.clans.clans.worldevent.event.slimeking.creature; +package mineplex.minecraft.game.core.boss.slimeking.creature; + +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; +import mineplex.minecraft.game.core.boss.slimeking.ability.AbsorbAbility; +import mineplex.minecraft.game.core.boss.slimeking.ability.LeapAbility; +import mineplex.minecraft.game.core.boss.slimeking.ability.RocketAbility; +import mineplex.minecraft.game.core.boss.slimeking.ability.SlamAbility; +import mineplex.minecraft.game.core.boss.slimeking.ability.SlimeAbility; import org.bukkit.Location; import org.bukkit.entity.MagmaCube; @@ -6,16 +17,6 @@ import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.SlimeSplitEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.creature.EventCreature; -import mineplex.game.clans.clans.worldevent.event.slimeking.SlimeBoss; -import mineplex.game.clans.clans.worldevent.event.slimeking.ability.AbsorbAbility; -import mineplex.game.clans.clans.worldevent.event.slimeking.ability.LeapAbility; -import mineplex.game.clans.clans.worldevent.event.slimeking.ability.RocketAbility; -import mineplex.game.clans.clans.worldevent.event.slimeking.ability.SlamAbility; -import mineplex.game.clans.clans.worldevent.event.slimeking.ability.SlimeAbility; - public class SlimeCreature extends EventCreature { private SlimeBoss _boss; @@ -44,6 +45,11 @@ public class SlimeCreature extends EventCreature getEntity().setSize(_size); } + public ProjectileManager getProjectileManager() + { + return _boss.getProjectileManager(); + } + @EventHandler public void abilityTick(UpdateEvent event) { @@ -75,10 +81,10 @@ public class SlimeCreature extends EventCreature } // Disable Enrage -// if (!_enraged && _ticksLived >= _enrageTicks) -// { -// setEnraged(true); -// } + // if (!_enraged && _ticksLived >= _enrageTicks) + // { + // setEnraged(true); + // } _currentAbility.tick(); } @@ -90,17 +96,17 @@ public class SlimeCreature extends EventCreature event.setCancelled(true); } -// @EventHandler -// public void target(EntityTargetEvent event) -// { -// if (event.getEntity().equals(getEntity())) -// { -// Bukkit.broadcastMessage("Target Event"); -// Player player = UtilPlayer.getRandomTarget(getEntity().getLocation(), 30); -// Bukkit.broadcastMessage("Targetting: " + player); -// event.setTarget(player); -// } -// } + // @EventHandler + // public void target(EntityTargetEvent event) + // { + // if (event.getEntity().equals(getEntity())) + // { + // Bukkit.broadcastMessage("Target Event"); + // Player player = UtilPlayer.getRandomTarget(getEntity().getLocation(), 30); + // Bukkit.broadcastMessage("Targetting: " + player); + // event.setTarget(player); + // } + // } public void setEnraged(boolean enraged) { 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 724cb41f7..19d71b994 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 @@ -40,6 +40,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -248,34 +249,34 @@ public class DamageManager extends MiniPlugin { 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) @@ -318,8 +319,10 @@ public class DamageManager extends MiniPlugin } } } - - DisplayDamage(event); + + // TODO: What is this required for? Players with books in regular games are spammed. Is it meant for debugging? + // TODO: Temporarily commenting out + //DisplayDamage(event); } private void Damage(CustomDamageEvent event) @@ -388,10 +391,11 @@ public class DamageManager extends MiniPlugin 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); - } + double vel = 0.2 + trajectory.length() * 0.8; + UtilAction.velocity(event.GetDamageeEntity(), trajectory, vel, + false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true); + } } catch (IllegalAccessException e) { @@ -411,7 +415,7 @@ public class DamageManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (!UtilGear.isMat(player.getItemInHand(), Material.BOOK)) + if (!UtilGear.isMat(player.getItemInHand(), Material.COMMAND)) continue; UtilPlayer.message(player, " "); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java index 4cdf04c68..636cca24a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java @@ -8,15 +8,6 @@ import java.util.Iterator; import java.util.List; import java.util.Random; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - import mineplex.core.explosion.ExplosionEvent; import mineplex.minecraft.game.core.damage.DamageManager; import net.minecraft.server.v1_7_R4.AxisAlignedBB; @@ -34,9 +25,18 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutExplosion; import net.minecraft.server.v1_7_R4.Vec3D; import net.minecraft.server.v1_7_R4.World; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + public class CustomExplosion extends Explosion { - private Player _owner; + private org.bukkit.entity.LivingEntity _owner; private boolean _damageOwner; private int _i = 16; private World _world; @@ -142,7 +142,7 @@ public class CustomExplosion extends Explosion return this; } - public CustomExplosion setPlayer(Player player, boolean damageExplosionOwner) + public CustomExplosion setPlayer(org.bukkit.entity.LivingEntity player, boolean damageExplosionOwner) { _owner = player; _damageOwner = damageExplosionOwner; @@ -319,7 +319,7 @@ public class CustomExplosion extends Explosion } } - ExplosionEvent event = _owner == null ? new ExplosionEvent(blockList) : new ExplosionEvent(blockList, _owner); + ExplosionEvent event = _owner == null || !(_owner instanceof Player) ? new ExplosionEvent(blockList) : new ExplosionEvent(blockList, (Player) _owner); this._world.getServer().getPluginManager().callEvent(event); this.blocks.clear(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/mechanics/PistonJump.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/mechanics/PistonJump.java index 1a23e9669..72080881d 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/mechanics/PistonJump.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/mechanics/PistonJump.java @@ -6,6 +6,7 @@ import java.util.HashSet; import mineplex.core.MiniPlugin; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilTime; import org.bukkit.Material; @@ -54,8 +55,7 @@ public class PistonJump extends MiniPlugin //Vector Vector vec = new Vector(0,1.2,0); - player.setVelocity(vec); - player.setFallDistance(0); + UtilAction.velocity(player, vec); } final Block block = below; diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java index 018d69ae1..d87fafe61 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java @@ -1,5 +1,7 @@ package mineplex.serverdata; +import java.util.concurrent.ConcurrentHashMap; + import mineplex.serverdata.servers.ConnectionData; import mineplex.serverdata.servers.ServerManager; import redis.clients.jedis.Jedis; @@ -15,17 +17,20 @@ import com.google.gson.GsonBuilder; * @author Ty * */ -public class Utility +public class Utility { // The Gson instance used to serialize/deserialize objects in JSON form. private static Gson _gson = new GsonBuilder().create(); public static Gson getGson() { return _gson; } - + + // map of all instantiated connection pools, distinguished by their ip:port combination + private static final ConcurrentHashMap _pools = new ConcurrentHashMap(); + // Public static jedis pool for interacting with central default jedis repo. private static JedisPool _masterPool; private static JedisPool _slavePool; - + /** * @param object - the (non-null) object to serialize * @return the serialized form of {@code object}. @@ -34,7 +39,7 @@ public class Utility { return _gson.toJson(object); } - + /** * @param serializedData - the serialized data to be deserialized * @param type - the resulting class type of the object to be deserialized @@ -46,7 +51,7 @@ public class Utility return _gson.fromJson(serializedData, type); } - + /** * @param delimiter - the delimiter character used to separate the concatenated elements * @param elements - the set of string elements to be concatenated and returned. @@ -56,15 +61,15 @@ public class Utility { int length = elements.length; String result = length > 0 ? elements[0] : new String(); - + for (int i = 1; i < length; i++) { result += delimiter + elements[i]; } - + return result; } - + /** * @return the current timestamp (in seconds) fetched from the central jedis repository * for synced timestamps. @@ -74,7 +79,7 @@ public class Utility long currentTime = 0; JedisPool pool = getPool(false); Jedis jedis = pool.getResource(); - + try { currentTime = Long.parseLong(jedis.time().get(0)); @@ -92,10 +97,10 @@ public class Utility pool.returnResource(jedis); } } - + return currentTime; } - + /** * @return the current timestamp (in milliseconds) fetched from the central jedis repository * for synced timestamps. @@ -123,22 +128,35 @@ public class Utility pool.returnResource(jedis); } } - + return currentTime * 1000; } - + /** * @param connData - the connection data specifying the database to be connected to. * @return a newly instantiated {@link JedisPool} connected to the provided {@link ConnectionData} repository. */ public static JedisPool generatePool(ConnectionData connData) { - JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); - jedisPoolConfig.setMaxWaitMillis(1000); - jedisPoolConfig.setMinIdle(5); - return new JedisPool(jedisPoolConfig, connData.getHost(), connData.getPort()); + String key = getConnKey(connData); + JedisPool pool = _pools.get(key); + if (pool == null) + { + JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); + jedisPoolConfig.setMaxWaitMillis(1000); + jedisPoolConfig.setMinIdle(5); + jedisPoolConfig.setTestOnBorrow(true); + + jedisPoolConfig.setMaxTotal(20); + jedisPoolConfig.setBlockWhenExhausted(true); + + pool = new JedisPool(jedisPoolConfig, connData.getHost(), connData.getPort()); + _pools.put(key, pool); + } + + return pool; } - + /** * @param writeable - whether or not the Jedis connections returned should be writeable to. * @return a globally available {@link JedisPool} @@ -151,7 +169,7 @@ public class Utility { _masterPool = generatePool(ServerManager.getMasterConnection()); } - + return _masterPool; } else @@ -159,11 +177,17 @@ public class Utility if (_slavePool == null) { ConnectionData slave = ServerManager.getSlaveConnection(); - + _slavePool = generatePool(slave); } - + return _slavePool; } } + + private static String getConnKey(ConnectionData connData) + { + return connData.getHost() + ":" + connData.getPort(); + } + } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java index 509006ca0..5cb4d9072 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerStatus.java @@ -25,9 +25,11 @@ public class PlayerStatus implements Data /** * Unique identifying String ID associated with this {@link PlayerStatus}. + * + * Use the lowercase name so we can have case-insensitive lookup */ public String getDataId() { - return _name; + return _name.toLowerCase(); } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java index 40d36f875..0aa8a16e7 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java @@ -57,6 +57,12 @@ public class ServerGroup private boolean _staffOnly; private String _resourcePack = ""; + private String _npcName = ""; + private String _portalBottomCornerLocation = ""; + private String _portalTopCornerLocation = ""; + + private String _teamServerKey = ""; + private Region _region; private Set _servers; @@ -101,6 +107,10 @@ public class ServerGroup _resourcePack = data.containsKey("resourcePack") ? data.get("resourcePack") : ""; _host = data.get("host"); _region = data.containsKey("region") ? Region.valueOf(data.get("region")) : Region.ALL; + _teamServerKey = data.containsKey("teamServerKey") ? data.get("teamServerKey") : ""; + _portalBottomCornerLocation = data.containsKey("portalBottomCornerLocation") ? data.get("portalBottomCornerLocation") : ""; + _portalTopCornerLocation = data.containsKey("portalTopCornerLocation") ? data.get("portalTopCornerLocation") : ""; + _npcName = data.containsKey("npcName") ? data.get("npcName") : ""; if (serverStatuses != null) parseServers(serverStatuses); @@ -109,7 +119,8 @@ public class ServerGroup public ServerGroup(String name, String prefix, String host, int ram, int cpu, int totalServers, int joinable, int portSection, boolean arcade, String worldZip, String plugin, String configPath , int minPlayers, int maxPlayers, boolean pvp, boolean tournament, boolean tournamentPoints, String games, String serverType, boolean noCheat, boolean worldEdit, boolean teamRejoin , boolean teamAutoJoin, boolean teamForceBalance, boolean gameAutoStart, boolean gameTimeout, boolean rewardGems, boolean rewardItems, boolean rewardStats - , boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region) + , boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region + , String teamServerKey, String portalBottomCornerLocation, String portalTopCornerLocation, String npcName) { _name = name; _prefix = prefix; @@ -148,6 +159,17 @@ public class ServerGroup _whitelist = whitelist; _resourcePack = resourcePack; _region = region; + _teamServerKey = teamServerKey; + _portalBottomCornerLocation = portalBottomCornerLocation; + _portalTopCornerLocation = portalTopCornerLocation; + _npcName = npcName; + } + + public ServerGroup(String name, String npcName, String prefix) + { + _name = name; + _npcName = npcName; + _prefix = prefix; } public String getName() { return _name; } @@ -196,6 +218,12 @@ public class ServerGroup public String getResourcePack() { return _resourcePack; } public Region getRegion() { return _region; } + public String getTeamServerKey() { return _teamServerKey; } + + public String getServerNpcName() { return _npcName; } + public String getPortalBottomCornerLocation() { return _portalBottomCornerLocation; } + public String getPortalTopCornerLocation() { return _portalTopCornerLocation; } + public Set getServers() { return _servers; } public int getServerCount() @@ -350,6 +378,10 @@ public class ServerGroup _dataMap.put("resourcePack", _resourcePack); _dataMap.put("host", _host); _dataMap.put("region", _region.name()); + _dataMap.put("teamServerKey", _teamServerKey); + _dataMap.put("portalBottomCornerLocation", _portalBottomCornerLocation); + _dataMap.put("portalTopCornerLocation", _portalTopCornerLocation); + _dataMap.put("npcName", _npcName); } return _dataMap; diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisConfig.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisConfig.java index cd841fc6f..913db74ef 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisConfig.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisConfig.java @@ -16,7 +16,7 @@ public class RedisConfig // The connections managed by this configuration private List _connections; - + /** * Class constructor * @param connections diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java index 1c173ae09..1c40dab73 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/servers/ServerManager.java @@ -20,15 +20,16 @@ import mineplex.serverdata.servers.ConnectionData.ConnectionType; * */ public class ServerManager -{ +{ public static final String SERVER_STATUS_LABEL = "ServerStatus"; // Label differentiating ServerStatus related servers + private static final String DEFAULT_CONFIG = "redis-config.dat"; // Configuration determining connection information private static RedisConfig _config; // The cached repository instances private static Map repositories = new HashMap(); - + /** * @param host - the host url used to connect to the database * @param port - the port to connect to the repository @@ -74,7 +75,7 @@ public class ServerManager public static ConnectionData getConnection(boolean writeable, String name) { - return getConfig().getConnection(writeable, name); + return getConfig(DEFAULT_CONFIG).getConnection(writeable, name); } /** @@ -89,44 +90,48 @@ public class ServerManager /** * @return the {@link RedisConfig} associated with this manager, providing appropriate connections. */ - public static RedisConfig getConfig() + public static RedisConfig getConfig(String fileName) { if (_config == null) - { - try - { - File configFile = new File("redis-config.dat"); - - if (configFile.exists()) - { - List connections = new ArrayList(); - List lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset()); - - for (String line : lines) - { - ConnectionData connection = deserializeConnection(line); - connections.add(connection); - - } - - _config = new RedisConfig(connections); - } - else - { - log("redis-config.dat not found at " + configFile.toPath().toString()); - _config = new RedisConfig(); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - log("---Unable To Parse Redis Configuration File---"); - } - - } - + _config = loadConfig(fileName); + return _config; } + + public static RedisConfig loadConfig(String fileName) + { + try + { + File configFile = new File(fileName); + + if (configFile.exists()) + { + List connections = new ArrayList(); + List lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset()); + + for (String line : lines) + { + ConnectionData connection = deserializeConnection(line); + connections.add(connection); + + } + + return new RedisConfig(connections); + } + else + { + log(fileName + " not found at " + configFile.toPath().toString()); + return new RedisConfig(); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + log("---Unable To Parse Redis Configuration File---"); + } + + return null; + } /** * @param line - the serialized line representing a valid {@link ConnectionData} object. diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 7af04e53f..a67bbdd6d 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -170,9 +170,26 @@ public class ServerMonitor log("Saved Dedicated Server Stats."); _historyRepository.saveServerGroupStats((int)totalCPU, (int)totalRAM, _serverGroupMap.values()); log("Saved ServerGroup Stats."); - //_historyRepository.saveNetworkStats(usedCpuPercent, usedRamPercent, availableCPU, availableRAM, _region); + _historyRepository.saveNetworkStats(usedCpuPercent, usedRamPercent, availableCPU, availableRAM, _region); log("Saved Network Stats."); + if (_count == 0) + { + for (Iterator groupStatusIterator = _serverGroups.iterator(); groupStatusIterator.hasNext();) + { + ServerGroup groupStatus = groupStatusIterator.next(); + + if (groupStatus.getServerType().equalsIgnoreCase("Player")) + { + _repository.removeServerGroup(groupStatus); + _serverGroupMap.remove(groupStatus); + groupStatusIterator.remove(); + + System.out.println("Removed MPS : " + groupStatus.getName()); + } + } + } + for (ServerGroup groupStatus : _serverGroups) { NautHashMap serverMap = new NautHashMap(); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 37b54b75b..f349df29e 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -83,11 +83,12 @@ public class StaffServer extends JavaPlugin ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "Cherdy8s")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("80f40f29-4d66-4355-a32f-01a65af2a14c"), "rl6")); - + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("2d5fd31b-0aa5-41db-a62d-a4611a24349a"), "ishh")); + ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java index 87d3749a7..36c62ffe5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -33,7 +33,7 @@ public class GemHunterCommand extends CommandBase else if (amount == 8) tempExp = 220000; - final int experience = tempExp; + final long experience = tempExp; Plugin.getClientManager().loadClientByName(playerName, new Runnable() { diff --git a/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml b/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml new file mode 100644 index 000000000..c5e840788 --- /dev/null +++ b/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Mineplex.Votifier/plugin.yml b/Plugins/Mineplex.Votifier/plugin.yml new file mode 100644 index 000000000..75a40f893 --- /dev/null +++ b/Plugins/Mineplex.Votifier/plugin.yml @@ -0,0 +1,3 @@ +name: MineplexVotifier +main: mineplex.votifier.Votifier +version: 0.1 \ No newline at end of file diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java new file mode 100644 index 000000000..f3fd02c9a --- /dev/null +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java @@ -0,0 +1,34 @@ +package mineplex.votifier; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.command.CommandCenter; +import mineplex.core.donation.DonationManager; + +/** + * Created by shaun on 15-08-05. + */ +public class Votifier extends JavaPlugin +{ + private String WEB_CONFIG = "webServer"; + + @Override + public void onEnable() + { + getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); + getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); + saveConfig(); + + String webServerAddress = getConfig().getString(WEB_CONFIG); + + CommandCenter.Initialize(this); + CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); + DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); + BonusManager bonusManager = new BonusManager(this, clientManager, donationManager); + + + VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager); + } +} diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java new file mode 100644 index 000000000..19a3c37b3 --- /dev/null +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -0,0 +1,283 @@ +package mineplex.votifier; + +import java.sql.Date; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import com.vexsoftware.votifier.model.Vote; +import com.vexsoftware.votifier.model.VotifierEvent; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.bonuses.BonusClientData; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.Pair; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.database.DBPool; +import mineplex.core.donation.DonationManager; +import mineplex.core.bonuses.redis.VotifierCommand; +import mineplex.database.Tables; +import mineplex.database.tables.records.BonusRecord; +import mineplex.serverdata.Region; +import mineplex.serverdata.Utility; +import mineplex.serverdata.commands.ServerCommand; +import mineplex.serverdata.data.PlayerStatus; +import mineplex.serverdata.redis.RedisConfig; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ServerManager; +import org.jooq.DSLContext; +import org.jooq.Record1; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.exceptions.JedisConnectionException; + +/** + * Created by shaun on 15-08-05. + */ +public class VotifierManager extends MiniPlugin +{ + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private BonusManager _bonusManager; + + private RedisConfig _usConfig; + private RedisConfig _euConfig; + private RedisDataRepository _usPlayerRepo; + private RedisDataRepository _euPlayerRepo; + private JedisPool _usWritePool; + private JedisPool _euWritePool; + + public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager) + { + super("Votifier", plugin); + + _clientManager = clientManager; + _donationManager = donationManager; + _bonusManager = bonusManager; + + _usConfig = ServerManager.loadConfig("us-redis.dat"); + _euConfig = ServerManager.loadConfig("eu-redis.dat"); + + _usPlayerRepo = new RedisDataRepository(_usConfig.getConnection(true, "DefaultConnection"), + _usConfig.getConnection(false, "DefaultConnection"), Region.US, PlayerStatus.class, "playerStatus"); + _euPlayerRepo = new RedisDataRepository(_euConfig.getConnection(true, "DefaultConnection"), + _euConfig.getConnection(false, "DefaultConnection"), Region.EU, PlayerStatus.class, "playerStatus"); + + _usWritePool = Utility.generatePool(_usConfig.getConnection(true, "DefaultConnection")); + _euWritePool = Utility.generatePool(_euConfig.getConnection(true, "DefaultConnection")); + } + + @EventHandler + public void handleVote(VotifierEvent event) + { + final Vote vote = event.getVote(); + final String playerName = vote.getUsername(); + + System.out.println("New Vote: " + playerName); + + runAsync(new Runnable() + { + @Override + public void run() + { + UUID uuid = UUIDFetcher.getUUIDOf(playerName); + if (uuid == null) + { + System.out.println("Failed to load UUID of " + playerName + " from UUIDFetcher. Trying with database"); + uuid = _clientManager.loadUUIDFromDB(playerName); + + if (uuid == null) + { + System.out.println("Failed to load UUID from database. Giving up on " + playerName); + } + } + + String lowerPlayerName = playerName.toLowerCase(); + final PlayerStatus usStatus = _usPlayerRepo.getElement(lowerPlayerName); + final PlayerStatus euStatus = _euPlayerRepo.getElement(lowerPlayerName); + + System.out.println("Loaded " + playerName + " with uuid " + uuid); + System.out.println("Attempting to award bonus"); + final UUID finalUuid = uuid; + awardBonus(playerName, finalUuid, new Callback() + { + @Override + public void run(final Integer gems) + { + runSync(new Runnable() + { + @Override + public void run() + { + if (usStatus != null) + { + System.out.println("Found " + playerName + " on US " + usStatus.getServer()); + notifyServer(playerName, gems, Region.US, usStatus.getServer()); + } + + if (euStatus != null) + { + System.out.println("Found " + playerName + " on EU " + euStatus.getServer()); + notifyServer(playerName, gems, Region.EU, euStatus.getServer()); + } + } + }); + } + }); + } + }); + System.out.println(); + System.out.println(); + +// UUID uuid = _clientManager.loadUUIDFromDB(playerName); +// if (uuid != null) +// { +// System.out.println("Found UUID:" + uuid.toString()); +// if (playerName.equalsIgnoreCase("Phinary")) +// { +// System.out.println("award bonus"); +// awardBonus(uuid); +// } +// } +// else +// { +// System.out.println("Failed to load UUID for player: " + playerName); +// } + +// PlayerStatus usStatus = _usPlayerRepo.getElement(playerName); +// if (usStatus != null) +// { +// System.out.println("Found on US Server: " + usStatus.getServer()); +// writePool = _usWritePool; +// serverName = usStatus.getServer(); +// } +// +// PlayerStatus euStatus = _euPlayerRepo.getElement(playerName); +// if (euStatus != null) +// { +// System.out.println("Found on EU Server: " + euStatus.getServer()); +// writePool = _euWritePool; +// serverName = euStatus.getServer(); +// } + + // Currently we just notify all servers, and the server with the player on it can deal with it +// notifyServer(playerName, true); + } + + private void notifyServer(String playerName, int gems, Region region, String targetServer) + { + JedisPool writePool = region == Region.EU ? _euWritePool : _usWritePool; + + VotifierCommand command = new VotifierCommand(playerName, gems, targetServer); + publishCommand(command, writePool); + } + + private void awardBonus(final String playerName, final UUID uuid, final Callback onComplete) + { + DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + + Record1 idRecord = create.select(Tables.accounts.id).from(Tables.accounts).where(Tables.accounts.uuid.eq(uuid.toString())).fetchOne(); + if (idRecord != null) + { + final int accountId = idRecord.value1(); + final BonusRecord client = _bonusManager.getRepository().loadRecord(playerName, accountId); + + final BonusAmount amount = _bonusManager.getVoteBonusAmount(client.getVoteStreak()); + + _bonusManager.getRepository().attemptVoteBonus(accountId, new Callback>() + { + @Override + public void run(Pair pair) + { + if (pair.getLeft()) + { + // Reward Amount + if (amount.getTickets() > 0) + client.setTickets(client.getTickets() + amount.getTickets()); + + if (amount.getTotalGems() > 0) + { + _donationManager.RewardGems(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + System.out.println("Gave " + amount.getGems() + " gems to " + playerName); + else + System.out.println("Failed to give " + amount.getGems() + " gems to " + playerName); + } + }, "Votifier", playerName, uuid, amount.getTotalGems()); + } + + if (amount.getTotalCoins() > 0) + { + _donationManager.RewardCoins(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + System.out.println("Gave " + amount.getGems() + " coins to " + playerName); + else + System.out.println("Failed to give " + amount.getGems() + " coins to " + playerName); + } + }, "Votifier", playerName, accountId, amount.getTotalCoins()); + } + + // Check if we need to reset vote streak + _bonusManager.updateVoteStreak(client); + client.setVotetime(pair.getRight()); + + // Update Streak + _bonusManager.incrementVoteStreak(client); + + client.store(); + System.out.println("Awarded carl ticket to " + playerName); + onComplete.run(amount.getTotalGems()); + } + else + { + System.out.println(playerName + " attempted to vote, vote bonus returned false!"); + } + } + }); + } + } + + private void publishCommand(final ServerCommand serverCommand, final JedisPool writePool) + { + new Thread(new Runnable() + { + public void run() + { + Jedis jedis = writePool.getResource(); + + try + { + String commandType = serverCommand.getClass().getSimpleName(); + String serializedCommand = Utility.serialize(serverCommand); + jedis.publish("commands.server" + ":" + commandType, serializedCommand); + } + catch (JedisConnectionException exception) + { + exception.printStackTrace(); + writePool.returnBrokenResource(jedis); + jedis = null; + } + finally + { + if (writePool != null) + { + writePool.returnResource(jedis); + } + } + } + }).start(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index b61c92d36..d38023f34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -4,6 +4,7 @@ import java.io.File; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import org.omg.CORBA._PolicyStub; import net.minecraft.server.v1_7_R4.BiomeBase; import net.minecraft.server.v1_7_R4.MinecraftServer; @@ -24,6 +25,9 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.friend.FriendManager; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.give.Give; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; @@ -37,6 +41,7 @@ import mineplex.core.mount.MountManager; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -48,10 +53,12 @@ import mineplex.core.status.ServerStatusManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; +import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; +import nautilus.game.arcade.game.Game.GameState; public class Arcade extends JavaPlugin { @@ -86,10 +93,14 @@ public class Arcade extends JavaPlugin _clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(_clientManager); + ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); VisibilityManager.Initialize(this); Give.Initialize(this); + + //Velocity Fix + new VelocityFix(this); _donationManager = new DonationManager(this, _clientManager, webServerAddress); @@ -107,7 +118,8 @@ public class Arcade extends JavaPlugin DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); - _damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, null); + NpcManager npcmanager = new NpcManager(this, creature); + _damageManager = new DamageManager(this, new CombatManager(this), npcmanager, disguiseManager, null); Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); @@ -129,12 +141,15 @@ public class Arcade extends JavaPlugin InventoryManager inventoryManager = new InventoryManager(this, _clientManager); PetManager petManager = new PetManager(this, _clientManager, _donationManager, disguiseManager, creature, blockRestore, webServerAddress); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); - GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager); + GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null); cosmeticManager.setInterfaceSlot(7); + cosmeticManager.disableTeamArmor(); + //Arcade Manager - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress); + PollManager pollManager = new PollManager(this, _clientManager, _donationManager); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager); new MemoryFix(this); new CustomTagFix(this, packetHandler); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 7e8b5243e..5f0c7e6fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1,5 +1,6 @@ package nautilus.game.arcade; +import java.awt.Event; import java.io.File; import java.util.ArrayList; import java.util.HashSet; @@ -31,6 +32,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; import com.google.common.base.Objects; @@ -40,6 +42,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; +import mineplex.core.bonuses.BonusManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.ClickEvent; @@ -47,6 +50,7 @@ import mineplex.core.common.jsonchat.JsonMessage; 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.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; @@ -59,11 +63,15 @@ import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; import mineplex.core.explosion.Explosion; +import mineplex.core.gadget.gadgets.OutfitTeam; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.movement.Movement; import mineplex.core.notifier.NotificationManager; +import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; @@ -71,6 +79,7 @@ import mineplex.core.packethandler.PacketPlayResourcePackStatus; import mineplex.core.packethandler.PacketPlayResourcePackStatus.EnumResourcePackStatus; import mineplex.core.party.PartyManager; import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -103,12 +112,13 @@ import nautilus.game.arcade.addons.TeamArmorAddon; import nautilus.game.arcade.command.DisguiseCommand; import nautilus.game.arcade.command.GameCommand; import nautilus.game.arcade.command.WriteCommand; -import nautilus.game.arcade.command.YoutubeCommand; +import nautilus.game.arcade.command.KitUnlockCommand; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameServerConfig; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.event.EventModule; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.managers.GameAchievementManager; import nautilus.game.arcade.managers.GameChatManager; @@ -142,6 +152,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private Creature _creature; private DamageManager _damageManager; private Explosion _explosionManager; + private EventModule _eventManager; private Fire _fire; private ProjectileManager _projectileManager; @@ -204,7 +215,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, - CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress) + CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager) { super("Game Manager", plugin); @@ -220,7 +231,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.ChampionsTDM) + || serverConfig.GameList.contains(GameType.BossBattles)) { _conditionManager = new SkillConditionManager(plugin); } @@ -256,6 +268,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _cosmeticManager = cosmeticManager; _portal = portal; _petManager = petManager; + _eventManager = new EventModule(this, getPlugin()); // Shop _arcadeShop = new ArcadeShop(this, clientManager, donationManager); @@ -287,6 +300,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation new NotificationManager(getPlugin(), clientManager); + new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager); + //Champions Modules _energy = new Energy(plugin); @@ -407,7 +422,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { addCommand(new GameCommand(this)); addCommand(new WriteCommand(this)); - addCommand(new YoutubeCommand(this)); + addCommand(new KitUnlockCommand(this)); addCommand(new DisguiseCommand(this)); } @@ -561,6 +576,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _gameWorldManager; } + public EventModule GetEventModule() + { + return _eventManager; + } + public PreferencesManager getPreferences() { return _preferencesManager; @@ -652,7 +672,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation return; } - if (!GetServerConfig().PublicServer) + if (!GetServerConfig().PublicServer || GetServerConfig().PlayerServerWhitelist) { event.setMotd(ChatColor.GRAY + "Private"); return; @@ -817,6 +837,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation event.disallow(PlayerLoginEvent.Result.KICK_OTHER, C.Bold + "Server has reached max capacity for gameplay purposes."); return; } + else if (_gameHostManager.isEventServer() && Bukkit.getServer().getOnlinePlayers().size() >= 128) + { + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, C.Bold + "Server has reached max capacity for gameplay purposes."); + return; + } event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -828,6 +853,21 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } + @EventHandler(priority = EventPriority.LOW) + public void AdminOP(PlayerJoinEvent event) + { + // Give developers operator on their servers + boolean testServer = _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); + + if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.OWNER) + || (testServer && (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER) || _clientManager.Get(event.getPlayer()).GetRank() == Rank.JNR_DEV)) + || eventTestServer && _clientManager.Get(event.getPlayer()).GetRank().Has(Rank.JNR_DEV)) + event.getPlayer().setOp(true); + else + event.getPlayer().setOp(false); + } + public boolean IsAlive(Player player) { if (_game == null) @@ -840,6 +880,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation { player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); + player.setFlySpeed(0.1F); + UtilInv.Clear(player); ((CraftEntity) player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0)); @@ -871,6 +913,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation //Remove all conditions GetCondition().EndCondition(player, null, null); + for (PotionEffect potion : player.getActivePotionEffects()) + player.removePotionEffect(potion.getType()); HubClock(player); @@ -1207,21 +1251,21 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _game != null && _game.InProgress(); } - public boolean isYoutuber(Player player) + public boolean hasKitsUnlocked(Player player) { return _youtube.contains(player); } - public void setYoutuber(Player caller) + public void toggleUnlockKits(Player caller) { if (_youtube.remove(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "YouTube Mode Disabled: " + ChatColor.RESET + "Kits Locked"); + UtilPlayer.message(caller, C.cRed + C.Bold + "Celebrity Mode Disabled: " + ChatColor.RESET + "Kits Locked"); } else { _youtube.add(caller); - UtilPlayer.message(caller, C.cGreen + C.Bold + "YouTube Mode Enabled: " + ChatColor.RESET + "All Kits Unlocked"); + UtilPlayer.message(caller, C.cGreen + C.Bold + "Celebrity Mode Enabled: " + ChatColor.RESET + "All Kits Unlocked"); } } @@ -1249,7 +1293,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public void toggleChampionsModules(GameType gameType) { - boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM; + boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM || gameType == GameType.BossBattles; if (_enabled == isChamps) { @@ -1302,7 +1346,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation player.teleport(GetGame().GetSpectatorLocation()); //Set Spec State - player.setVelocity(new Vector(0,1,0)); + UtilAction.velocity(player, new Vector(0,1,0)); player.setAllowFlight(true); player.setFlying(true); player.setFlySpeed(0.1f); 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 fe73d8673..064bae164 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -5,6 +5,7 @@ import mineplex.core.game.GameDisplay; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; +import nautilus.game.arcade.game.games.bossbattles.BossBattles; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.build.Build; import nautilus.game.arcade.game.games.cards.Cards; @@ -26,6 +27,7 @@ import nautilus.game.arcade.game.games.halloween.Halloween; import nautilus.game.arcade.game.games.hideseek.HideSeek; import nautilus.game.arcade.game.games.holeinwall.HoleInTheWall; import nautilus.game.arcade.game.games.horsecharge.Horse; +import nautilus.game.arcade.game.games.lobbers.BombLobbers; import nautilus.game.arcade.game.games.micro.Micro; import nautilus.game.arcade.game.games.milkcow.MilkCow; import nautilus.game.arcade.game.games.minestrike.MineStrike; @@ -37,10 +39,11 @@ import nautilus.game.arcade.game.games.quiver.QuiverTeams; import nautilus.game.arcade.game.games.runner.Runner; import nautilus.game.arcade.game.games.searchanddestroy.SearchAndDestroy; import nautilus.game.arcade.game.games.sheep.SheepGame; -import nautilus.game.arcade.game.games.skywars.Skywars; -import nautilus.game.arcade.game.games.smash.SuperSmash; +import nautilus.game.arcade.game.games.skywars.SoloSkywars; +import nautilus.game.arcade.game.games.skywars.TeamSkywars; +import nautilus.game.arcade.game.games.smash.SoloSuperSmash; import nautilus.game.arcade.game.games.smash.SuperSmashDominate; -import nautilus.game.arcade.game.games.smash.SuperSmashTeam; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.game.games.snake.Snake; import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins; import nautilus.game.arcade.game.games.snowfight.SnowFight; @@ -48,8 +51,8 @@ import nautilus.game.arcade.game.games.spleef.Spleef; import nautilus.game.arcade.game.games.spleef.SpleefTeams; import nautilus.game.arcade.game.games.squidshooter.SquidShooter; import nautilus.game.arcade.game.games.stacker.Stacker; -import nautilus.game.arcade.game.games.survivalgames.SurvivalGames; -import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesTeams; +import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; +import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames; import nautilus.game.arcade.game.games.tug.Tug; import nautilus.game.arcade.game.games.turfforts.TurfForts; import nautilus.game.arcade.game.games.uhc.UHC; @@ -64,12 +67,13 @@ public enum GameType //Mini BaconBrawl(BaconBrawl.class, GameDisplay.BaconBrawl), Barbarians(Barbarians.class, GameDisplay.Barbarians), + BossBattles(BossBattles.class, GameDisplay.BossBattles), Bridge(Bridge.class, GameDisplay.Bridge), CastleSiege(CastleSiege.class, GameDisplay.CastleSiege), ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate), //ChampionsMOBA(ChampionsMOBA.class, "Champions MOBA", "Champions", Material.SKULL_ITEM, (byte)0, GameCategory.CHAMPIONS, 7), ChampionsTDM(ChampionsTDM.class, GameDisplay.ChampionsTDM), - Christmas(Christmas.class, GameDisplay.Christmas), + Christmas(Christmas.class, GameDisplay.Christmas, "http://chivebox.com/file/c/xmas.zip", true), DeathTag(DeathTag.class, GameDisplay.DeathTag), DragonEscape(DragonEscape.class, GameDisplay.DragonEscape), DragonEscapeTeams(DragonEscapeTeams.class, GameDisplay.DragonEscapeTeams), @@ -80,10 +84,11 @@ public enum GameType Evolution(Evolution.class, GameDisplay.Evolution), //FlappyBird(FlappyBird.class, "Flappy Bird", Material.FEATHER, (byte)0, GameCategory.ARCADE, 17), Gravity(Gravity.class, GameDisplay.Gravity), - Halloween(Halloween.class, GameDisplay.Halloween), + Halloween(Halloween.class, GameDisplay.Halloween, "http://chivebox.com/file/c/hh.zip", true), HideSeek(HideSeek.class, GameDisplay.HideSeek), HoleInTheWall(HoleInTheWall.class, GameDisplay.HoleInTheWall), Horse(Horse.class, GameDisplay.Horse), + Lobbers(BombLobbers.class, GameDisplay.Lobbers), Micro(Micro.class, GameDisplay.Micro), MilkCow(MilkCow.class, GameDisplay.MilkCow), MineStrike(MineStrike.class, GameDisplay.MineStrike, "http://chivebox.com/file/c/assets.zip", true),// Temp set to CHAMPIONS to fix UI bug @@ -96,9 +101,9 @@ public enum GameType SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy), Sheep(SheepGame.class, GameDisplay.Sheep), - Smash(SuperSmash.class, GameDisplay.Smash), + Smash(SoloSuperSmash.class, GameDisplay.Smash), SmashDomination(SuperSmashDominate.class, GameDisplay.SmashDomination), - SmashTeams(SuperSmashTeam.class, GameDisplay.SmashTeams), + SmashTeams(TeamSuperSmash.class, GameDisplay.SmashTeams, new GameType[]{GameType.Smash}, false), Snake(Snake.class, GameDisplay.Snake), SneakyAssassins(SneakyAssassins.class, GameDisplay.SneakyAssassins), SnowFight(SnowFight.class, GameDisplay.SnowFight), @@ -106,23 +111,35 @@ public enum GameType SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams), SquidShooter(SquidShooter.class, GameDisplay.SquidShooter), Stacker(Stacker.class, GameDisplay.Stacker), - SurvivalGames(SurvivalGames.class, GameDisplay.SurvivalGames), - SurvivalGamesTeams(SurvivalGamesTeams.class, GameDisplay.SurvivalGamesTeams), + SurvivalGames(SoloSurvivalGames.class, GameDisplay.SurvivalGames), + SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false), Tug(Tug.class, GameDisplay.Tug), TurfWars(TurfForts.class, GameDisplay.TurfWars), UHC(UHC.class, GameDisplay.UHC), WitherAssault(WitherGame.class, GameDisplay.WitherAssault), - Wizards(Wizards.class, GameDisplay.Barbarians.Wizards, "http://chivebox.com/file/c/ResWizards.zip", true), + Wizards(Wizards.class, GameDisplay.Wizards, "http://chivebox.com/file/c/ResWizards.zip", true), ZombieSurvival(ZombieSurvival.class, GameDisplay.ZombieSurvival), - Build(Build.class, GameDisplay.Build), Cards(Cards.class, GameDisplay.Cards), - Skywars(Skywars.class, GameDisplay.Skywars), + Skywars(SoloSkywars.class, GameDisplay.Skywars), + SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false), - Event(EventGame.class, GameDisplay.Event); + Event(EventGame.class, GameDisplay.Event, new GameType[]{ + GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, + GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, + GameType.DeathTag, GameType.DragonEscape, GameType.DragonEscapeTeams, GameType.DragonRiders, GameType.Dragons, + GameType.Draw, GameType.Evolution, GameType.Gravity, GameType.Halloween, GameType.HideSeek, + GameType.HoleInTheWall, GameType.Horse, GameType.Micro, GameType.MilkCow, GameType.MineStrike, GameType.MineWare, + GameType.OldMineWare, GameType.Paintball, GameType.Quiver, GameType.QuiverTeams, GameType.Runner, GameType.SearchAndDestroy, + GameType.Sheep, GameType.Skywars, GameType.SkywarsTeams, GameType.Smash, GameType.SmashDomination, GameType.SmashTeams, + GameType.Snake, GameType.SneakyAssassins, GameType.SnowFight, GameType.Spleef, GameType.SpleefTeams, GameType.SquidShooter, + GameType.Stacker, GameType.SurvivalGames, GameType.SurvivalGamesTeams, GameType.Tug, GameType.TurfWars, GameType.UHC, + GameType.WitherAssault, GameType.Wizards, GameType.ZombieSurvival}, true); GameDisplay _display; boolean _enforceResourcePack; + GameType[] _mapSource; + boolean _ownMaps; String _resourcePack; Class _gameClass; @@ -131,17 +148,29 @@ public enum GameType GameType(Class gameClass, GameDisplay display) { - this(gameClass, display, null, false); + this(gameClass, display, null, false, null, true); } GameType(Class gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack) + { + this(gameClass, display, resourcePackUrl, enforceResourcePack, null, true); + } + + GameType(Class gameClass, GameDisplay display, GameType[] mapSource, boolean ownMap) + { + this(gameClass, display, null, false, mapSource, ownMap); + } + + GameType(Class gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps) { _display = display; _gameClass = gameClass; _resourcePack = resourcePackUrl; _enforceResourcePack = enforceResourcePack; + _mapSource = mapSource; + _ownMaps = ownMaps; } - + public Class getGameClass() { return _gameClass; @@ -156,6 +185,16 @@ public enum GameType { return _resourcePack; } + + public GameType[] getMapSource() + { + return _mapSource; + } + + public boolean ownMaps() + { + return _ownMaps; + } public String GetName() { @@ -181,4 +220,10 @@ public enum GameType { return _display.getGameCategory(); } + + public String GetKitGameName() + { + return _display.getKitGameName(); + } + } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/SoupAddon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/SoupAddon.java index 92d5576ef..4174f64ff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/SoupAddon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/SoupAddon.java @@ -40,6 +40,9 @@ public class SoupAddon extends MiniPlugin Player player = event.getPlayer(); + if (!Manager.GetGame().IsAlive(player)) + return; + if (!UtilGear.isMat(player.getItemInHand(), Material.MUSHROOM_SOUP)) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index 8e1e5dc51..7c32ed36a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -1,61 +1,374 @@ package nautilus.game.arcade.command; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; +import java.lang.reflect.Field; +import java.util.UUID; -import nautilus.game.arcade.ArcadeManager; -import net.minecraft.util.com.mojang.authlib.GameProfile; +import mineplex.core.NCPDataManFix; +import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation; +import net.minecraft.util.com.mojang.authlib.GameProfile; -public class DisguiseCommand extends CommandBase +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.scoreboard.Team; + +public class DisguiseCommand extends CommandBase implements Listener { - public DisguiseCommand(ArcadeManager plugin) + + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + + public DisguiseCommand(ArcadeManager plugin) + { + super(plugin, Rank.JNR_DEV, new Rank[] + { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + new NCPDataManFix(); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if(args == null) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); + if(!Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); + + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + team.removePlayer(caller); + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + if(args != null && args.length > 1) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + return; } - @Override - public void Execute(final Player caller, final String[] args) + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() { - if (args.length == 0) + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); - return; + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + for(Player other : UtilServer.getPlayers()) { - @Override - public void run() + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.Has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0], true); + + Plugin.getCosmeticManager().getGadgetManager().RemoveItem(caller); + + Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); + } + + @EventHandler + public void updateDisguises(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; + + for(Player other : UtilServer.getPlayers()) + { + try + { + if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) + { + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + } + if(other.getScoreboard().getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) + { + if(other.getScoreboard() + .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .getPlayers().contains(player)) { - try - { - final GameProfile profile = new ProfileLoader(UUIDFetcher.getUUIDOf(args[0]).toString(), args[0]).loadProfile(); - - Bukkit.getServer().getScheduler().runTask(Plugin.getPlugin(), new Runnable() - { - public void run() - { - DisguisePlayer playerDisguise = new DisguisePlayer(caller, profile); - Plugin.GetDisguise().disguise(playerDisguise); - - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); - } - }); - } - catch (Exception e) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - }} - ); + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .removePlayer(player); + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).getDisguisedRank().Name + + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); + } + } + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); } + } + + public void changeName(final Player player, String changedName, boolean skin) + { + try + { + GameProfile gameProfile = ((CraftPlayer) player).getProfile(); + + Field name = GameProfile.class.getDeclaredField("name"); + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); + + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName, true); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler + public void onPlayerLeftClick(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(player)) + { + EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + human.world.broadcastEntityEffect(human, (byte) 0); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java index ec1eb238f..76e4edb1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java @@ -12,7 +12,7 @@ public class GameCommand extends MultiCommandBase { public GameCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD, Rank.JNR_DEV}, "game"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.MAPLEAD, Rank.JNR_DEV}, "game"); AddCommand(new StartCommand(Plugin)); AddCommand(new StopCommand(Plugin)); @@ -25,7 +25,7 @@ public class GameCommand extends MultiCommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List:")); UtilPlayer.message(caller, F.help("/game start", "Start the current game", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/game stop", "Stop the current game", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/game set (Map)", "Set the current game or next game", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/game set (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN)); UtilPlayer.message(caller, F.main("Tip", "Use TAB for games/maps!")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/YoutubeCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java similarity index 61% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/YoutubeCommand.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java index 454b19375..cae387d71 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/YoutubeCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java @@ -6,16 +6,16 @@ import nautilus.game.arcade.ArcadeManager; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -public class YoutubeCommand extends CommandBase +public class KitUnlockCommand extends CommandBase { - public YoutubeCommand(ArcadeManager plugin) + public KitUnlockCommand(ArcadeManager plugin) { - super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, new String[] {"youtube", "twitch"}); + super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"}); } @Override public void Execute(Player caller, String[] args) { - Plugin.setYoutuber(caller); + Plugin.toggleUnlockKits(caller); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java index 7db88b496..d6958a663 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java @@ -18,7 +18,7 @@ public class SetCommand extends CommandBase { public SetCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD, Rank.JNR_DEV}, "set"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.MAPLEAD, Rank.JNR_DEV}, "set"); } @Override @@ -29,16 +29,31 @@ public class SetCommand extends CommandBase if (args == null || args.length == 0) { - caller.sendMessage(F.help("/game set (Map)", "Set the current game or next game", Rank.ADMIN)); + caller.sendMessage(F.help("/game set (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN)); return; } String game = args[0].toLowerCase(); - if (args.length > 1) + if (args.length >= 2) { - Plugin.GetGameCreationManager().MapPref = args[1]; - UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + args[1]); + String map = ""; + String source = ""; + if(args.length == 3) + { + Plugin.GetGameCreationManager().MapSource = args[1]; + Plugin.GetGameCreationManager().MapPref = args[2]; + source = args[1]; + map = args[2]; + } + else + { + Plugin.GetGameCreationManager().MapSource = args[0]; + Plugin.GetGameCreationManager().MapPref = args[1]; + source = args[0]; + map = args[1]; + } + UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + source + ":" + map); } //Parse Game diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java index b78521dc9..7a7a0dd43 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java @@ -12,7 +12,7 @@ public class StartCommand extends CommandBase { public StartCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD, Rank.JNR_DEV}, "start"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.MAPLEAD, Rank.JNR_DEV}, "start"); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java index 1718baec5..386d3867d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java @@ -11,7 +11,7 @@ public class WriteCommand extends CommandBase { public WriteCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, "write"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "write"); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index abe4d740c..075c2afdb 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 @@ -1,5 +1,6 @@ package nautilus.game.arcade.game; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -13,6 +14,8 @@ import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; import org.bukkit.entity.Player; @@ -55,6 +58,8 @@ import nautilus.game.arcade.managers.GameLobbyManager; import nautilus.game.arcade.scoreboard.GameScoreboard; import nautilus.game.arcade.stats.*; import nautilus.game.arcade.world.WorldData; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.util.com.mojang.authlib.GameProfile; public abstract class Game implements Listener { @@ -86,7 +91,7 @@ public abstract class Game implements Listener protected String[] _gameDesc; //Map - private ArrayList _files; + private HashMap> _files; //State private GameState _gameState = GameState.Loading; @@ -193,8 +198,6 @@ public abstract class Game implements Listener public int HungerSet = -1; public int HealthSet = -1; - public int SpawnDistanceRequirement = 1; - public boolean PrepareFreeze = true; private double _itemMergeRadius = 0; @@ -211,6 +214,11 @@ public abstract class Game implements Listener public int TickPerTeleport = 1; + public int FillTeamsInOrderToCount = -1; + + public boolean SpawnNearAllies = false; + public boolean SpawnNearEnemies = false; + public boolean StrictAntiHack = false; public boolean DisableKillCommand = true; @@ -258,6 +266,9 @@ public abstract class Game implements Listener public boolean CanAddStats = true; public boolean CanGiveLoot = true; + public boolean HideTeamSheep = false; + public boolean ReplaceTeamsWithKits = false; + public boolean VersionRequire1_8 = false; public ArrayList GemBoosters = new ArrayList(); @@ -281,16 +292,30 @@ public abstract class Game implements Listener Scoreboard = new GameScoreboard(this); //Map Select - _files = Manager.LoadFiles(GetName()); + _files = new HashMap>(); + for(GameType type : GetWorldHostNames()) + { + _files.put(type, Manager.LoadFiles(type.GetName())); + } if (Manager.GetGameCreationManager().MapPref != null) { - ArrayList matches = new ArrayList(); - for (String cur : _files) + System.out.println("Map Preference: " + Manager.GetGameCreationManager().MapPref); + + HashMap> matches = new HashMap>(); + for (GameType game : _files.keySet()) { - if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase())) + ArrayList list = new ArrayList(); + for(String cur : _files.get(game)) { - matches.add(cur); - System.out.print("Map Preference: " + cur); + if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase())) + { + if(game.GetName().toLowerCase().contains(Manager.GetGameCreationManager().MapSource.toLowerCase())) + { + list.add(cur); + System.out.print("Map Preference: " + cur); + matches.put(game, list); + } + } } } @@ -298,6 +323,11 @@ public abstract class Game implements Listener _files = matches; Manager.GetGameCreationManager().MapPref = null; + Manager.GetGameCreationManager().MapSource = null; + } + else + { + System.out.println("Map Preference: None"); } WorldData = new WorldData(this); @@ -314,14 +344,6 @@ public abstract class Game implements Listener new GamesPlayedStatTracker(this) ); - if (gameType != GameType.UHC) - { - registerStatTrackers( - new TeamDeathsStatTracker(this), - new TeamKillsStatTracker(this) - ); - } - Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); System.out.println("Loading " + GetName() + "..."); @@ -332,7 +354,7 @@ public abstract class Game implements Listener _kits = kits; } - public ArrayList GetFiles() + public HashMap> GetFiles() { return _files; } @@ -341,6 +363,60 @@ public abstract class Game implements Listener { return _gameType.GetName(); } + + public GameType[] GetWorldHostNames() + { + GameType[] mapSource = new GameType[]{GetType()}; + if(GetType().getMapSource() != null) + { + if(GetType().ownMaps()) + { + int i = 1; + mapSource = new GameType[GetType().getMapSource().length + 1]; + for(GameType type : GetType().getMapSource()) + { + mapSource[i] = type; + i++; + } + mapSource[0] = GetType(); + } + else + { + mapSource = GetType().getMapSource(); + } + } + return mapSource; + } + + public String GetGameNamebyMap(String game, String map) + { + for(GameType type : _files.keySet()) + { + if(type.GetName().toLowerCase().contains(game.toLowerCase())) + { + for(String string : _files.get(type)) + { + if(string.toLowerCase().contains(map.toLowerCase())) + { + return type.GetName(); + } + } + } + } + return null; + } + + public GameType GetGameByMapList(ArrayList maps) + { + for(GameType game : _files.keySet()) + { + if(maps.equals(_files.get(game))) + { + return game; + } + } + return null; + } public String GetMode() { @@ -465,9 +541,6 @@ public abstract class Game implements Listener //Add GetTeamList().add(team); - //Set Spawn Data - team.SetSpawnRequirement(this.SpawnDistanceRequirement); - System.out.println("Created Team: " + team.GetName()); } @@ -549,6 +622,17 @@ public abstract class Game implements Listener public GameTeam ChooseTeam(Player player) { + if (FillTeamsInOrderToCount != -1) + { + for (int i = 0; i < _teamList.size(); i++) + { + if (_teamList.get(i).GetSize() < FillTeamsInOrderToCount) + { + return _teamList.get(i); + } + } + } + GameTeam team = null; //Random Team @@ -592,7 +676,7 @@ public abstract class Game implements Listener { if (!countAmount && gems < 1) gems = 1; - + if (GetGems(player).containsKey(reason) && multipleAllowed) { GetGems(player).get(reason).AddGems(gems); @@ -1365,4 +1449,5 @@ public abstract class Game implements Listener //End SetState(GameState.End); } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameServerConfig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameServerConfig.java index 3ea703536..0e1e2ac03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameServerConfig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameServerConfig.java @@ -36,6 +36,8 @@ public class GameServerConfig public boolean PlayerKickIdle = true; public boolean PublicServer = true; + + public boolean PlayerServerWhitelist = false; public boolean IsValid() { 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 c465dbf1d..a4adccbd5 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 @@ -5,8 +5,10 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import mineplex.core.account.CoreClient; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -60,19 +62,19 @@ public class GameTeam private HashMap _players = new HashMap(); private ArrayList _spawns; - + private Creature _teamEntity = null; private HashSet _kitRestrict = new HashSet(); - private int _spawnDistance = 0; - private boolean _visible = true; + private boolean _displayTag; + //Records order players go out in protected ArrayList _places = new ArrayList(); - public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) + public GameTeam(Game host, String name, ChatColor color, ArrayList spawns, boolean tags) { Host = host; @@ -80,6 +82,12 @@ public class GameTeam _name = name; _color = color; _spawns = spawns; + _displayTag = tags; + } + + public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) + { + this(host, name, color, spawns, false); } public String GetName() @@ -99,40 +107,48 @@ public class GameTeam public Location GetSpawn() { - // ArrayList valid = new ArrayList(); - - Location best = null; - double bestDist = 0; - - for (Location loc : _spawns) + //Keep allies together + if (!Host.IsLive() && Host.SpawnNearAllies) { - double closestPlayer = -1; - - for (Player player : Host.GetPlayers(true)) + //Find Location Nearest Ally + Location loc = UtilAlg.getLocationNearPlayers(_spawns, GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; + + //No allies existed spawned yet + + //Spawn near enemies (used for SG) + if (Host.SpawnNearEnemies) { - double playerDist = UtilMath.offsetSquared(player.getLocation(), loc); - - if (closestPlayer == -1 || playerDist < closestPlayer) - closestPlayer = playerDist; + loc = UtilAlg.getLocationNearPlayers(_spawns, Host.GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; } - - if (best == null || closestPlayer > bestDist) + //Spawn away from enemies + else { - best = loc; - bestDist = closestPlayer; - } - - // if (closestPlayer > _spawnDistance * _spawnDistance) - // { - // valid.add(loc); - // } + loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); + if (loc != null) + return loc; + } + } + else + { + //Spawn near players + if (Host.SpawnNearEnemies) + { + Location loc = UtilAlg.getLocationNearPlayers(_spawns, Host.GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; + } + //Spawn away from players + else + { + Location loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); + if (loc != null) + return loc; + } } - - // if (valid.size() > 0) - // valid.get(UtilMath.r(valid.size())); - - if (best != null) - return best; return _spawns.get(UtilMath.r(_spawns.size())); } @@ -149,7 +165,14 @@ public class GameTeam public void DisbandTeam() { for (Player player : _players.keySet()) + { + for(Player other : UtilServer.getPlayers()) + { + other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name + _name.toUpperCase()).removePlayer(player); + other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player); + } UtilPlayer.message(player, F.main("Team", _color + C.Bold + _displayName + " Team was disbanded.")); + } _players.clear(); } @@ -333,11 +356,6 @@ public class GameTeam _spawns = spawns; } - public void SetSpawnRequirement(int value) - { - _spawnDistance = value; - } - public void SetVisible(boolean b) { _visible = b; @@ -347,6 +365,16 @@ public class GameTeam { return _visible; } + + public void setDisplayTag(boolean b) + { + _displayTag = b; + } + + public boolean GetDisplaytag() + { + return _displayTag; + } public void SetRespawnTime(double i) { @@ -390,6 +418,4 @@ public class GameTeam return _places; } - - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java new file mode 100644 index 000000000..130bcb33a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.game.games.bossbattles; + +import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; +import nautilus.game.arcade.game.games.bossbattles.displays.BossDisplay; +import nautilus.game.arcade.game.games.bossbattles.displays.IronWizardDisplay; +import nautilus.game.arcade.game.games.bossbattles.displays.SlimeKingDisplay; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public enum BattleBoss +{ + GOLEM(GolemBoss.class, IronWizardDisplay.class, new ItemStack( + Material.IRON_BLOCK)), + + SLIME(SlimeBoss.class, SlimeKingDisplay.class, new ItemStack( + Material.EMERALD_BLOCK)); + + private Class _bossClass; + private ItemStack _bossHead; + private Class _bossDisplay; + + private BattleBoss(Class bossClass, + Class displayClass, ItemStack bossHead) + { + _bossClass = bossClass; + _bossHead = bossHead; + _bossDisplay = displayClass; + } + + public Class getBoss() + { + return _bossClass; + } + + public Class getBossDisplay() + { + return _bossDisplay; + } + + public ItemStack getItem() + { + return _bossHead; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java new file mode 100644 index 000000000..884916234 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java @@ -0,0 +1,295 @@ +package nautilus.game.arcade.game.games.bossbattles; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.bossbattles.displays.BossDisplay; +import nautilus.game.arcade.game.games.champions.kits.KitAssassin; +import nautilus.game.arcade.game.games.champions.kits.KitBrute; +import nautilus.game.arcade.game.games.champions.kits.KitKnight; +import nautilus.game.arcade.game.games.champions.kits.KitMage; +import nautilus.game.arcade.game.games.champions.kits.KitRanger; +import nautilus.game.arcade.kit.Kit; + +public class BossBattles extends TeamGame +{ + private WorldEvent _currentBoss; + private BattleBoss _chosenBoss = BattleBoss.values()[UtilMath.r(BattleBoss + .values().length)]; + private ArrayList _displays = new ArrayList(); + + public BossBattles(ArcadeManager manager) + { + super(manager, GameType.BossBattles, new Kit[] + { + new KitBrute(manager), new KitRanger(manager), + new KitKnight(manager), new KitMage(manager), + new KitAssassin(manager), + }, new String[] + { + "Fight some bosses" + }); + } + + @Override + public boolean isInsideMap(Player player) + { + return true; + } + + @EventHandler + public void checkBossIsDead(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + if (_currentBoss == null) + { + return; + } + + if (GetPlayers(true).isEmpty()) + { + _currentBoss.cancel(); + } + + if (_currentBoss.getState() != EventState.COMPLETE + && _currentBoss.getState() != EventState.CANCELLED) + { + return; + } + + endCurrentBoss(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 0 || _currentBoss == null + || _currentBoss.getState() == EventState.CANCELLED + || _currentBoss.getState() == EventState.COMPLETE) + { + endCurrentBoss(); + + super.EndCheck(); + } + } + + private void endCurrentBoss() + { + if (_currentBoss == null) + { + return; + } + + CreatureAllowOverride = false; + + HandlerList.unregisterAll(_currentBoss); + + // If the event was cancelled, we don't need to run a cleanup + if (_currentBoss.getState() == EventState.COMPLETE) + _currentBoss.cleanup(); + + _currentBoss = null; + Damage = false; + + SpectatorSpawn = UtilWorld.averageLocation(GetTeamList().get(0) + .GetSpawns()); + + for (Player player : GetPlayers(false)) + { + if (!IsAlive(player)) + { + RespawnPlayer(player); + } + else + { + player.teleport(GetTeamList().get(0).GetSpawn()); + } + } + } + + public void setPicked(Player player, BattleBoss battleBoss) + { + _chosenBoss = battleBoss; + + Announce(C.cGold + C.Bold + player.getName() + " has chosen the boss " + + battleBoss.name() + "!"); + } + + @EventHandler + public void onGameOver(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live + || event.GetState() == GameState.Prepare) + { + return; + } + + if (_currentBoss == null) + { + return; + } + + endCurrentBoss(); + } + + @EventHandler + public void onGameLoadingOver(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Recruit) + { + return; + } + + for (BossDisplay display : _displays) + { + HandlerList.unregisterAll(display); + } + + _displays.clear(); + } + + @EventHandler + public void onGamePrepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + { + return; + } + + int i = 0; + ArrayList locations = UtilShapes.getPointsInCircle( + new Location(UtilWorld.getWorld("world"), 0, 104, 0), + BattleBoss.values().length, 5); + + for (BattleBoss boss : BattleBoss.values()) + { + try + { + Location loc = locations.get(i).clone(); + + loc.setDirection(UtilAlg.getTrajectory(loc, Manager.GetLobby() + .GetSpawn())); + + Constructor constructor = boss + .getBossDisplay().getConstructor(BossBattles.class, + BattleBoss.class, Location.class); + + BossDisplay bossDisplay = constructor.newInstance(this, + BattleBoss.values()[i], loc); + + Bukkit.getPluginManager().registerEvents(bossDisplay, + getArcadeManager().getPlugin()); + + bossDisplay.start(); + + System.out.print("Registered " + + bossDisplay.getClass().getSimpleName()); + } + catch (Exception e) + { + e.printStackTrace(); + } + + i++; + } + } + + @EventHandler + public void onGameStarted(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + setNewBoss(_chosenBoss); + } + + @EventHandler + public void onGameLive(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + CreatureAllowOverride = true; + + _currentBoss.start(); + + Bukkit.getPluginManager().registerEvents(_currentBoss, + getArcadeManager().getPlugin()); + + CreatureAllowOverride = false; + } + + public WorldEvent createInstance(Class clazz, Location centerLocation) + { + WorldEvent worldEvent = null; + + try + { + for (Constructor con : clazz.getConstructors()) + { + if (clazz != SlimeBoss.class) + { + worldEvent = (WorldEvent) con.newInstance( + getArcadeManager().GetDamage(), getArcadeManager() + .GetBlockRestore(), getArcadeManager() + .GetCondition(), centerLocation); + } + else + { + worldEvent = (WorldEvent) con.newInstance( + getArcadeManager().GetDamage(), getArcadeManager() + .GetBlockRestore(), getArcadeManager() + .GetCondition(), getArcadeManager() + .GetProjectile(), centerLocation); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + + return worldEvent; + } + + private void setNewBoss(BattleBoss boss) + { + _currentBoss = createInstance(boss.getBoss(), new Location( + WorldData.World, 0, 6, 0)); + + _currentBoss.setInstantSchematic(true); + + _currentBoss.loadMap(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/BossDisplay.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/BossDisplay.java new file mode 100644 index 000000000..a342d93ce --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/BossDisplay.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.bossbattles.displays; + +import nautilus.game.arcade.game.games.bossbattles.BattleBoss; +import nautilus.game.arcade.game.games.bossbattles.BossBattles; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +public abstract class BossDisplay implements Listener +{ + private Location _bossLocation; + protected BossBattles Plugin; + private BattleBoss _boss; + + public BossDisplay(BossBattles plugin, BattleBoss boss, Location location) + { + Plugin = plugin; + _boss = boss; + _bossLocation = location; + } + + public Location getLocation() + { + return _bossLocation; + } + + public void setChosen(Player player) + { + Plugin.setPicked(player, _boss); + } + + public abstract void removeBoss(); + + public abstract void start(); + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/IronWizardDisplay.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/IronWizardDisplay.java new file mode 100644 index 000000000..33d72e1d2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/IronWizardDisplay.java @@ -0,0 +1,53 @@ +package nautilus.game.arcade.game.games.bossbattles.displays; + +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.games.bossbattles.BattleBoss; +import nautilus.game.arcade.game.games.bossbattles.BossBattles; + +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.IronGolem; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEntityEvent; + +public class IronWizardDisplay extends BossDisplay +{ + private IronGolem _golem; + + public IronWizardDisplay(BossBattles plugin, BattleBoss boss, + Location location) + { + super(plugin, boss, location); + } + + @EventHandler + public void onInteract(PlayerInteractEntityEvent event) + { + if (!event.getRightClicked().equals(_golem)) + { + return; + } + + setChosen(event.getPlayer()); + } + + @Override + public void removeBoss() + { + _golem.remove(); + } + + @Override + public void start() + { + Plugin.CreatureAllowOverride = true; + + _golem = (IronGolem) getLocation().getWorld().spawnEntity( + getLocation(), EntityType.IRON_GOLEM); + _golem.teleport(getLocation()); + UtilEnt.Vegetate(_golem); + + Plugin.CreatureAllowOverride = false; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/SlimeKingDisplay.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/SlimeKingDisplay.java new file mode 100644 index 000000000..277a537f2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/SlimeKingDisplay.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.games.bossbattles.displays; + +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.games.bossbattles.BattleBoss; +import nautilus.game.arcade.game.games.bossbattles.BossBattles; + +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEntityEvent; + +public class SlimeKingDisplay extends BossDisplay +{ + private Slime _slime; + + public SlimeKingDisplay(BossBattles plugin, BattleBoss boss, + Location location) + { + super(plugin, boss, location); + } + + @EventHandler + public void onInteract(PlayerInteractEntityEvent event) + { + if (!event.getRightClicked().equals(_slime)) + { + return; + } + + setChosen(event.getPlayer()); + } + + @Override + public void removeBoss() + { + _slime.remove(); + } + + @Override + public void start() + { + Plugin.CreatureAllowOverride = true; + + _slime = (Slime) getLocation().getWorld().spawnEntity(getLocation(), + EntityType.SLIME); + _slime.setSize(4); + + _slime.teleport(getLocation()); + + UtilEnt.Vegetate(_slime); + + Plugin.CreatureAllowOverride = false; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 52f199735..f839c7539 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -45,6 +45,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; 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; @@ -176,6 +177,8 @@ public class Bridge extends TeamGame implements OreObsfucation ItemPickup = true; InventoryClick = true; + + AnnounceStay = false; PrivateBlocks = true; BlockBreak = true; @@ -1178,7 +1181,7 @@ public class Bridge extends TeamGame implements OreObsfucation UtilPlayer.message(event.getPlayer(), F.main("Game", "Cannot place blocks in liquids until Bridge is down.")); - event.getPlayer().setVelocity(new Vector(0,-0.5,0)); + UtilAction.velocity(event.getPlayer(), new Vector(0, -0.5, 0)); event.setCancelled(true); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBeserker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBeserker.java index 133f27aaf..fa56f9ce2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBeserker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBeserker.java @@ -20,7 +20,7 @@ public class KitBeserker extends Kit new String[] { - "Agile warrior trained in the ways axe combat." + "Agile warrior trained in the ways of axe combat." }, new Perk[] 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 1d7ee11d3..92ead83b8 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 @@ -67,6 +67,7 @@ import mineplex.core.common.Rank; 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.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -707,7 +708,7 @@ public class Build extends SoloGame event.setTo(event.getFrom()); //Velocity - event.getPlayer().setVelocity(UtilAlg.getTrajectory(event.getTo(), data.Spawn)); + UtilAction.velocity(event.getPlayer(), UtilAlg.getTrajectory(event.getTo(), data.Spawn)); } } 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 4069df70f..a8306e7d1 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 @@ -98,7 +98,15 @@ public class BuildData return false; } - Particles.put(Player.getEyeLocation().add(Player.getLocation().getDirection()), particleType); + Location toPlace = Player.getEyeLocation().add(Player.getLocation().getDirection()); + + if (!inBuildArea(toPlace.getBlock())) + { + UtilPlayer.message(Player, F.main("Game", "You cannot place particles outside your plot!")); + return false; + } + + Particles.put(toPlace, particleType); UtilPlayer.message(Player, F.main("Game", "You placed " + particleType.getFriendlyName() + "!")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index a07dd540d..c6a53e65b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -74,6 +74,8 @@ import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.stats.BloodThirstyStatTracker; import nautilus.game.arcade.stats.KingDamageStatTracker; import nautilus.game.arcade.stats.KingSlayerStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; import nautilus.game.arcade.stats.WinAsTeamStatTracker; public class CastleSiege extends TeamGame @@ -212,7 +214,10 @@ public class CastleSiege extends TeamGame new WinAsTeamStatTracker(this, notRedTeam, "ForTheKing"), new KingSlayerStatTracker(this), new BloodThirstyStatTracker(this), - new KingDamageStatTracker(this) + new KingDamageStatTracker(this), + + new TeamDeathsStatTracker(this), + new TeamKillsStatTracker(this) ); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java index cc96c5dad..1ff47bd80 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java @@ -6,12 +6,17 @@ import java.util.HashMap; + import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; @@ -127,6 +132,29 @@ public class Domination extends TeamGame team.SetColor(ChatColor.BLUE); } + @EventHandler(priority = EventPriority.HIGHEST) + public void blockliquidFlow(BlockPhysicsEvent event) + { + Material matOfBlock = event.getBlock().getType(); + + if (matOfBlock == Material.STATIONARY_WATER || matOfBlock == Material.SAND || matOfBlock == Material.GRAVEL || matOfBlock == Material.STATIONARY_LAVA) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onTNTExplode(EntityExplodeEvent event) + { + if (!IsLive()) + return; + + if (event.getEntityType() == EntityType.PRIMED_TNT) + { + event.setCancelled(true); + } + } + @EventHandler public void Updates(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java index 4ea0687be..1e26628f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java @@ -5,11 +5,15 @@ import java.util.HashMap; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.scoreboard.Objective; @@ -95,6 +99,29 @@ public class TeamDeathmatch extends TeamGame } } + @EventHandler(priority = EventPriority.HIGHEST) + public void blockliquidFlow(BlockPhysicsEvent event) + { + Material matOfBlock = event.getBlock().getType(); + + if (matOfBlock == Material.STATIONARY_WATER || matOfBlock == Material.SAND || matOfBlock == Material.GRAVEL || matOfBlock == Material.STATIONARY_LAVA) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onTNTExplode(EntityExplodeEvent event) + { + if (!IsLive()) + return; + + if (event.getEntityType() == EntityType.PRIMED_TNT) + { + event.setCancelled(true); + } + } + @EventHandler public void PlayerKillAward(CombatDeathEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index d8b32a7eb..39a48e223 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -33,6 +33,7 @@ import org.bukkit.util.Vector; 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.UtilBlock; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilFirework; @@ -520,8 +521,7 @@ public class DragonEscape extends SoloGame //Teleport player.teleport(target.getLocation().add(0, 0.5, 0)); - player.setVelocity(new Vector(0,0,0)); - player.setFallDistance(0); + UtilAction.zeroVelocity(player); //Record _warpTime.put(player, System.currentTimeMillis()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java index 9460a9d67..e03d66bb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java @@ -26,6 +26,7 @@ import org.bukkit.util.Vector; 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.UtilBlock; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; @@ -540,8 +541,7 @@ public class DragonEscapeTeams extends TeamGame //Teleport player.teleport(target.getLocation().add(0, 0.5, 0)); - player.setVelocity(new Vector(0,0,0)); - player.setFallDistance(0); + UtilAction.zeroVelocity(player); //Record _warpTime.put(player, System.currentTimeMillis()); 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 37211beec..05d1c8508 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -1,48 +1,9 @@ package nautilus.game.arcade.game.games.event; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Arrays; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.Sound; -import org.bukkit.World; -import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; -import org.bukkit.entity.Ageable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Villager; -import org.bukkit.entity.Wolf; -import org.bukkit.entity.Zombie; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.entity.Villager.Profession; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -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; @@ -50,34 +11,45 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; -import mineplex.core.creature.event.CreatureKillEntitiesEvent; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.event.GadgetActivateEvent; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.give.Give; -import mineplex.core.mount.Mount; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; -import nautilus.game.arcade.game.games.event.kits.*; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.event.kits.KitPlayer; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; -public class EventGame extends SoloGame +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; +import org.bukkit.inventory.ItemStack; + +public class EventGame extends Game { private GameHostManager _mps; @@ -169,1276 +141,6 @@ public class EventGame extends SoloGame player.setGameMode(GameMode.SURVIVAL); } - //Help - 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")); - 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", "")); - } - - private void commandHelpSettings(Player player) - { - UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;")); - UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage")); - UtilPlayer.message(player, F.value("/e damage pvp", "Toggles PvP Damage")); - UtilPlayer.message(player, F.value("/e damage pve", "Toggles PvE Damage")); - UtilPlayer.message(player, F.value("/e damage pve", "Toggles EvP Damage")); - UtilPlayer.message(player, F.value("/e damage fall", "Toggles Fall Damage")); - UtilPlayer.message(player, F.value("/e health <-1 to 20>", "Locks Players Health")); - UtilPlayer.message(player, F.value("/e hunger <-1 to 20>", "Locks Players Hunger")); - UtilPlayer.message(player, F.value("/e item drop", "Toggles Item Drop")); - UtilPlayer.message(player, F.value("/e item pickup", "Toggles Item Pickup")); - UtilPlayer.message(player, F.value("/e blockplace", "Toggles Block Placing (On/Off)")); - UtilPlayer.message(player, F.value("/e blockplace whitelist ", "")); - UtilPlayer.message(player, F.value("/e blockplace blacklist ", "")); - UtilPlayer.message(player, F.value("/e blockbreak", "Toggles Block Breaking (On/Off)")); - UtilPlayer.message(player, F.value("/e blockbreak whitelist ", "")); - UtilPlayer.message(player, F.value("/e blockbreak blacklist ", "")); - UtilPlayer.message(player, F.value("/e time <-1 to 24000>", "Sets World Time")); - } - - //Command Handler - @EventHandler(priority = EventPriority.LOWEST) - private void commandHandler(PlayerCommandPreprocessEvent event) - { - if (!InProgress()) - return; - - if (!event.getMessage().toLowerCase().startsWith("/e ")) - return; - - event.setCancelled(true); - - if (!_mps.isAdmin(event.getPlayer(), false)) - return; - - //Trim off /e and split to args - String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" "); - - if (args.length == 0 || args[0].equalsIgnoreCase("help")) - { - commandHelp(event.getPlayer()); - } - else if (args[0].equalsIgnoreCase("settings")) - { - if (args.length >= 2 && args[1].equalsIgnoreCase("list")) - listSettings(event.getPlayer()); - else - commandHelpSettings(event.getPlayer()); - } - - //XXX Commands - else if (args[0].equalsIgnoreCase("tp")) - { - commandTeleport(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("gadget")) - { - commandGadget(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("silence")) - { - commandSilence(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("admin")) - { - commandAdmin(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("gm")) - { - commandGamemode(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("radius")) - { - commandForcefieldRadius(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("doublejump")) - { - commandDoubleJump(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("scoreboard")) - { - commandScoreboard(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("whitelist")) - { - commandWhitelist(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("give")) - { - commandGive(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("effect")) - { - commandEffect(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("kit")) - { - commandKit(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("mob")) - { - if (args.length >= 2 && args[1].equalsIgnoreCase("kill")) - commandMobKill(event.getPlayer(), args); - else - commandMob(event.getPlayer(), args); - } - - - //XXX Settings - else if (event.getMessage().toLowerCase().equals("/e damage all")) - { - Damage = !Damage; - Announce(F.main("Event Settings", F.value("Damage All", F.tf(Damage)))); - } - else if (event.getMessage().toLowerCase().equals("/e damage pvp")) - { - DamagePvP = !DamagePvP; - Announce(F.main("Event Settings", F.value("Damage PvP", F.tf(DamagePvP)))); - } - else if (event.getMessage().toLowerCase().equals("/e damage pve")) - { - DamagePvE = !DamagePvE; - Announce(F.main("Event Settings", F.value("Damage PvE", F.tf(DamagePvE)))); - } - else if (event.getMessage().toLowerCase().equals("/e damage evp")) - { - DamageEvP = !DamageEvP; - Announce(F.main("Event Settings", F.value("Damage EvP", F.tf(DamageEvP)))); - } - else if (event.getMessage().toLowerCase().equals("/e damage fall")) - { - DamageFall = !DamageFall; - Announce(F.main("Event Settings", F.value("Damage Fall", F.tf(DamageFall)))); - } - else if (args[0].equalsIgnoreCase("health")) - { - commandHealth(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("hunger")) - { - commandHunger(event.getPlayer(), args); - } - else if (event.getMessage().toLowerCase().equals("/e item drop")) - { - ItemDrop = !ItemDrop; - Announce(F.main("Event Settings", F.value("Item Drop", F.tf(ItemDrop)))); - } - else if (event.getMessage().toLowerCase().equals("/e item pickup")) - { - ItemPickup = !ItemPickup; - Announce(F.main("Event Settings", F.value("Item Pickup", F.tf(ItemPickup)))); - } - else if (event.getMessage().toLowerCase().equals("/e blockplace")) - { - BlockPlace = !BlockPlace; - Announce(F.main("Event Settings", F.value("Block Place", F.tf(BlockPlace)))); - } - else if (args.length >= 4 && args[0].equalsIgnoreCase("blockplace") - && (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))) - { - commandBlockPlace(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2]); - } - else if (event.getMessage().toLowerCase().equals("/e blockbreak")) - { - BlockBreak = !BlockBreak; - Announce(F.main("Event Settings", F.value("Block Break", F.tf(BlockBreak)))); - } - else if (args.length >= 4 && args[0].equalsIgnoreCase("blockbreak") - && (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))) - { - commandBlockBreak(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2]); - } - else if (args[0].equalsIgnoreCase("time")) - { - commandTime(event.getPlayer(), args); - } - } - - private void listSettings(Player player) - { - UtilPlayer.message(player, F.value("Damage All", F.tf(Damage))); - UtilPlayer.message(player, F.value("Damage PvP", F.tf(DamagePvP))); - UtilPlayer.message(player, F.value("Damage PvE", F.tf(DamagePvE))); - UtilPlayer.message(player, F.value("Damage EvP", F.tf(DamageEvP))); - UtilPlayer.message(player, F.value("Damage Fall", F.tf(DamageFall))); - UtilPlayer.message(player, F.value("Health Set", HealthSet+"")); - UtilPlayer.message(player, F.value("Hunger Set", HungerSet+"")); - UtilPlayer.message(player, F.value("Item Pickup", F.tf(ItemPickup))); - UtilPlayer.message(player, F.value("Item Drop", F.tf(ItemDrop))); - UtilPlayer.message(player, F.value("Block Place", F.tf(BlockPlace))); - UtilPlayer.message(player, F.value("Block Place Whitelist", UtilText.listToString(BlockPlaceAllow, true))); - UtilPlayer.message(player, F.value("Block Place Blacklist", UtilText.listToString(BlockPlaceDeny, true))); - UtilPlayer.message(player, F.value("Block Break", F.tf(BlockPlace))); - UtilPlayer.message(player, F.value("Block Break Whitelist", UtilText.listToString(BlockBreakAllow, true))); - UtilPlayer.message(player, F.value("Block Break Blacklist", UtilText.listToString(BlockBreakDeny, true))); - UtilPlayer.message(player, F.value("Time Set", WorldTimeSet+"")); - } - - private void commandBlockPlace(Player player, String[] args, boolean whitelist, String command) - { - try - { - int blockId = Integer.parseInt(args[3]); - - if (whitelist) - { - if (command.equalsIgnoreCase("add")) - { - BlockPlaceAllow.add(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Added " + blockId))); - } - else if (command.equalsIgnoreCase("remove")) - { - BlockPlaceAllow.remove(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Removed " + blockId))); - } - else if (command.equalsIgnoreCase("clear")) - { - BlockPlaceAllow.clear(); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Cleared"))); - } - else if (command.equalsIgnoreCase("list")) - { - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", UtilText.listToString(BlockPlaceAllow, true)))); - } - } - else - { - if (command.equalsIgnoreCase("add")) - { - BlockPlaceDeny.add(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Added " + blockId))); - } - else if (command.equalsIgnoreCase("remove")) - { - BlockPlaceDeny.remove(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Removed " + blockId))); - } - else if (command.equalsIgnoreCase("clear")) - { - BlockPlaceDeny.clear(); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Cleared"))); - } - else if (command.equalsIgnoreCase("list")) - { - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", UtilText.listToString(BlockPlaceDeny, true)))); - } - } - - return; - } - catch (Exception e) - { - - } - - commandHelpSettings(player); - } - - private void commandBlockBreak(Player player, String[] args, boolean whitelist, String command) - { - try - { - int blockId = Integer.parseInt(args[3]); - - if (whitelist) - { - if (command.equalsIgnoreCase("add")) - { - BlockBreakAllow.add(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Added " + blockId))); - } - else if (command.equalsIgnoreCase("remove")) - { - BlockBreakAllow.remove(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Removed " + blockId))); - } - else if (command.equalsIgnoreCase("clear")) - { - BlockBreakAllow.clear(); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Cleared"))); - } - else if (command.equalsIgnoreCase("list")) - { - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", UtilText.listToString(BlockBreakAllow, true)))); - } - } - else - { - if (command.equalsIgnoreCase("add")) - { - BlockBreakDeny.add(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Added " + blockId))); - } - else if (command.equalsIgnoreCase("remove")) - { - BlockBreakDeny.remove(blockId); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Removed " + blockId))); - } - else if (command.equalsIgnoreCase("clear")) - { - BlockBreakDeny.clear(); - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Cleared"))); - } - else if (command.equalsIgnoreCase("list")) - { - UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", UtilText.listToString(BlockBreakDeny, true)))); - } - } - - return; - } - catch (Exception e) - { - - } - - commandHelpSettings(player); - } - - private void commandHealth(Player player, String[] args) - { - try - { - if (args.length >= 2) - { - int health = Integer.parseInt(args[1]); - - if (health <= 0) - health = -1; - if (health > 20) - health = 20; - - HealthSet = health; - - if (HealthSet == -1) - Announce(F.main("Event Settings", F.value("Health Set", "Disabled"))); - else - Announce(F.main("Event Settings", F.value("Health Set", HealthSet + ""))); - - return; - } - } - catch (Exception e) - { - - } - - commandHelpSettings(player); - } - - private void commandHunger(Player player, String[] args) - { - try - { - if (args.length >= 2) - { - int hunger = Integer.parseInt(args[1]); - - if (hunger <= 0) - hunger = -1; - if (hunger > 20) - hunger = 20; - - HungerSet = hunger; - - if (HungerSet == -1) - Announce(F.main("Event Settings", F.value("Hunger Set", "Disabled"))); - else - Announce(F.main("Event Settings", F.value("Hunger Set", HungerSet + ""))); - - return; - } - } - catch (Exception e) - { - - } - - commandHelpSettings(player); - } - - private void commandTime(Player player, String[] args) - { - try - { - if (args.length >= 2) - { - int time = Integer.parseInt(args[1]); - - if (time <= -1) - time = -1; - if (time > 24000) - time = 24000; - - WorldTimeSet = time; - - if (WorldTimeSet == -1) - Announce(F.main("Event Settings", F.value("Time Set", "Disabled"))); - else - Announce(F.main("Event Settings", F.value("Time Set", WorldTimeSet + ""))); - - return; - } - } - catch (Exception e) - { - - } - - commandHelpSettings(player); - } - - //Teleport Command (To, Here, All) - private void commandTeleport(Player player, String[] args) - { - if (args.length >= 3 && args[1].equalsIgnoreCase("here")) - { - if (args[2].equalsIgnoreCase("all")) - { - for (Player other : UtilServer.getPlayers()) - { - UtilPlayer.message(other, F.main("Event TP", player.getName() + " teleported everyone to self.")); - other.teleport(player); - } - - return; - } - - Player target = UtilPlayer.searchOnline(player, args[2], true); - if (target != null) - { - target.teleport(player); - UtilPlayer.message(target, F.main("Event TP", player.getName() + " teleported you to self.")); - UtilPlayer.message(player, F.main("Event TP", "Teleported " + target.getName() + " to you.")); - } - - return; - } - - if (args.length >= 2) - { - Player target = UtilPlayer.searchOnline(player, args[1], true); - if (target != null) - { - player.teleport(target); - UtilPlayer.message(player, F.main("Event TP", "Teleported to " + target.getName() + ".")); - } - - return; - } - - commandHelp(player); - } - - //Gadget Commands (Global & Individual) - private void commandGadget(Player player, String[] args) - { - if (args.length < 2) - { - _allowAllGadgets = !_allowAllGadgets; - - if (!_allowAllGadgets) - { - Manager.getCosmeticManager().getMountManager().DisableAll(); - Manager.getCosmeticManager().getGadgetManager().DisableAll(); - } - - 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()) - { - mounts += color + mount.GetName().replaceAll(" ", "") + " "; - color = (color == ChatColor.AQUA ? ChatColor.DARK_AQUA : ChatColor.AQUA); - } - UtilPlayer.message(player, mounts); - - return; - } - - if (args.length >= 2) - { - //Gadgets - for (GadgetType type : GadgetType.values()) - { - for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type)) - { - if (gadget.GetName().replaceAll(" ", "").equalsIgnoreCase(args[1])) - { - if (_gadgetWhitelist.remove(gadget)) - { - Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget", F.ed(false)))); - gadget.DisableForAll(); - } - else - { - Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget", F.ed(true)))); - _gadgetWhitelist.add(gadget); - } - - return; - } - } - } - - //Mounts - for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) - { - if (mount.GetName().replaceAll(" ", "").equalsIgnoreCase(args[1])) - { - if (_gadgetWhitelist.remove(mount)) - { - Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget", F.ed(false)))); - mount.DisableForAll(); - } - else - { - 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); - } - - //Silence - private void commandSilence(Player player, String[] args) - { - try - { - //Toggle - if (args.length == 1) - { - //Disable - if (Manager.GetChat().Silenced() != 0) - { - Manager.GetChat().Silence(0, true); - } - //Enable - else - { - Manager.GetChat().Silence(-1, true); - } - } - //Timer - else - { - long time = (long) (Double.valueOf(args[1]) * 3600000); - - Manager.GetChat().Silence(time, true); - } - } - catch (Exception e) - { - UtilPlayer.message(player, F.main("Chat", "Invalid Time Parameter.")); - } - } - - //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) - { - Player target = player; - - if (args.length >= 2) - { - Player newTarget = UtilPlayer.searchOnline(player, args[1], true); - if (newTarget != null) - target = newTarget; - else - return; - } - - if (target.getGameMode() == GameMode.CREATIVE) - target.setGameMode(GameMode.SURVIVAL); - else - target.setGameMode(GameMode.CREATIVE); - - UtilPlayer.message(player, F.main("Event GM", target.getName() + " Creative: " + F.tf(target.getGameMode() == GameMode.CREATIVE))); - } - - //Forcefield - private void commandForcefieldRadius(Player player, String[] args) - { - //Toggle - if (args.length >= 2) - { - try - { - int range = Integer.parseInt(args[1]); - - _forcefield.put(player.getName(), range); - - UtilPlayer.message(player, F.main("Forcefield", "Enabled with " + F.elem(range + "") + " radius.")); - } - catch (Exception e) - { - UtilPlayer.message(player, F.main("Forcefield", "Invalid Input.")); - } - } - else - { - _forcefield.remove(player.getName()); - UtilPlayer.message(player, F.main("Forcefield", "Disabled.")); - } - } - - //Give - private void commandGive(Player player, String[] args) - { - String[] newArgs = new String[args.length-1]; - - for (int i=0 ; i= 2) - { - //Line - int line = 0; - try - { - line = Integer.parseInt(args[1]); - } - catch (Exception e) - { - UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number.")); - return; - } - - if (line < 1 || line > 14) - { - UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number.")); - return; - } - - //Text - String lineText = ""; - - //Reset String - if (args.length <= 2) - for (int i=0 ; i= 2 && args[1].equalsIgnoreCase("clear")) - { - for (int i=0 ; i<_sideText.length ; i++) - { - String lineText = ""; - for (int j=0 ; j= 2) - { - if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("off")) - { - UtilServer.getServer().setWhitelist(args[1].equalsIgnoreCase("on")); - - Announce(F.main("Event Settings", F.value("Whitelist", F.tf(args[1].equalsIgnoreCase("on"))))); - return; - } - } - - //Add and Remove - if (args.length >= 3) - { - if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove")) - { - OfflinePlayer target = Bukkit.getOfflinePlayer(args[2]); - - if (args[1].equalsIgnoreCase("add")) - { - UtilServer.getServer().getWhitelistedPlayers().add(target); - UtilPlayer.message(player, F.main("Whitelist", "Added " + args[2] + " to the whitelist.")); - } - else - { - UtilServer.getServer().getWhitelistedPlayers().remove(target); - UtilPlayer.message(player, F.main("Whitelist", "Removed " + args[2] + " to the whitelist.")); - } - - return; - } - } - - commandHelp(player); - } - - //Mob - private void commandMob(Player caller, String[] args) - { - if (args.length == 1) - { - HashMap entMap = new HashMap(); - - int count = 0; - for (World world : UtilServer.getServer().getWorlds()) - { - for (Entity ent : world.getEntities()) - { - if (!entMap.containsKey(ent.getType())) - entMap.put(ent.getType(), 0); - - entMap.put(ent.getType(), 1 + entMap.get(ent.getType())); - count++; - } - } - - UtilPlayer.message(caller, F.main("Creature", "Listing Entities:")); - for (EntityType cur : entMap.keySet()) - { - UtilPlayer.message(caller, F.desc(UtilEnt.getName(cur), entMap.get(cur)+"")); - } - - UtilPlayer.message(caller, F.desc("Total", count+"")); - } - else - { - EntityType type = UtilEnt.searchEntity(caller, args[1], true); - - if (type == null) - return; - - UtilPlayer.message(caller, F.main("Creature", "Spawning Creature(s);")); - - //Store Args - HashSet argSet = new HashSet(); - for (int i = 2 ; i < args.length ; i++) - if (args[i].length() > 0) - argSet.add(args[i]); - - - //Search Count - int count = 1; - HashSet argHandle = new HashSet(); - for (String arg : argSet) - { - try - { - int newCount = Integer.parseInt(arg); - - if (newCount <= 0) - continue; - - //Set Count - count = newCount; - UtilPlayer.message(caller, F.desc("Amount", count+"")); - - //Flag Arg - argHandle.add(arg); - break; - } - catch (Exception e) - { - //None - } - } - for (String arg : argHandle) - argSet.remove(arg); - - //Spawn - HashSet entSet = new HashSet(); - for (int i = 0 ; i < count ; i++) - { - CreatureAllowOverride = true; - entSet.add(Manager.GetCreature().SpawnEntity(caller.getTargetBlock(null, 0).getLocation().add(0.5, 1, 0.5), type)); - CreatureAllowOverride = false; - } - - //Search Vars - for (String arg : argSet) - { - if (arg.length() == 0) - continue; - - //Baby - else if (arg.equalsIgnoreCase("baby") || arg.equalsIgnoreCase("b")) - { - for (Entity ent : entSet) - { - if (ent instanceof Ageable) - ((Ageable)ent).setBaby(); - else if (ent instanceof Zombie) - ((Zombie)ent).setBaby(true); - } - - UtilPlayer.message(caller, F.desc("Baby", "True")); - argHandle.add(arg); - } - - //Lock - else if (arg.equalsIgnoreCase("age") || arg.equalsIgnoreCase("lock")) - { - for (Entity ent : entSet) - if (ent instanceof Ageable) - { - ((Ageable)ent).setAgeLock(true); - UtilPlayer.message(caller, F.desc("Age", "False")); - } - - argHandle.add(arg); - } - - //Angry - else if (arg.equalsIgnoreCase("angry") || arg.equalsIgnoreCase("a")) - { - for (Entity ent : entSet) - if (ent instanceof Wolf) - ((Wolf)ent).setAngry(true); - - for (Entity ent : entSet) - if (ent instanceof Skeleton) - ((Skeleton)ent).setSkeletonType(SkeletonType.WITHER); - - UtilPlayer.message(caller, F.desc("Angry", "True")); - argHandle.add(arg); - } - - //Profession - else if (arg.toLowerCase().charAt(0) == 'p') - { - try - { - String prof = arg.substring(1, arg.length()); - - Profession profession = null; - for (Profession cur : Profession.values()) - if (cur.name().toLowerCase().contains(prof.toLowerCase())) - profession = cur; - - UtilPlayer.message(caller, F.desc("Profession", profession.name())); - - for (Entity ent : entSet) - if (ent instanceof Villager) - ((Villager)ent).setProfession(profession); - } - catch (Exception e) - { - UtilPlayer.message(caller, F.desc("Profession", "Invalid [" + arg + "] on " + type.name())); - } - argHandle.add(arg); - } - - //Size - else if (arg.toLowerCase().charAt(0) == 's') - { - try - { - String size = arg.substring(1, arg.length()); - - UtilPlayer.message(caller, F.desc("Size", Integer.parseInt(size)+"")); - - for (Entity ent : entSet) - if (ent instanceof Slime) - ((Slime)ent).setSize(Integer.parseInt(size)); - } - catch (Exception e) - { - UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name())); - } - argHandle.add(arg); - } - - else if (arg.toLowerCase().charAt(0) == 'n' && arg.length() > 1) - { - try - { - String name = ""; - - for (char c : arg.substring(1, arg.length()).toCharArray()) - { - if (c != '_') - name += c; - else - name += " "; - } - - for (Entity ent : entSet) - { - if (ent instanceof CraftLivingEntity) - { - CraftLivingEntity cEnt = (CraftLivingEntity)ent; - cEnt.setCustomName(name); - cEnt.setCustomNameVisible(true); - } - } - } - catch (Exception e) - { - UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name())); - } - argHandle.add(arg); - } - } - for (String arg : argHandle) - argSet.remove(arg); - - for (String arg : argSet) - UtilPlayer.message(caller, F.desc("Unhandled", arg)); - - //Inform - UtilPlayer.message(caller, F.main("Creature", "Spawned " + count + " " + UtilEnt.getName(type) + ".")); - } - } - - private void commandMobKill(Player caller, String[] args) - { - if (args.length < 3) - { - UtilPlayer.message(caller, F.main("Creature", "Missing Entity Type Parameter.")); - return; - } - - EntityType type = UtilEnt.searchEntity(caller, args[2], true); - - if (type == null && !args[2].equalsIgnoreCase("all")) - return; - - int count = 0; - List killList = new ArrayList(); - - for (World world : UtilServer.getServer().getWorlds()) - { - for (Entity ent : world.getEntities()) - { - if (ent.getType() == EntityType.PLAYER) - continue; - - if (type == null || ent.getType() == type) - { - killList.add(ent); - } - } - } - - CreatureKillEntitiesEvent event = new CreatureKillEntitiesEvent(killList); - UtilServer.getServer().getPluginManager().callEvent(event); - - for (Entity entity : event.GetEntities()) - { - entity.remove(); - count++; - } - - String target = "ALL"; - if (type != null) - target = UtilEnt.getName(type); - - UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed.")); - } - - private void commandKit(Player caller, String[] args) - { - if (args.length >= 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"))); - 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; - } - - commandHelp(caller); - } - - private void commandEffect(Player caller, String[] args) - { - //Clear - if (args.length >= 3 && args[2].equalsIgnoreCase("clear")) - { - //Get Targets - LinkedList targets = new LinkedList(); - - if (args[1].equalsIgnoreCase("all")) - { - for (Player cur : UtilServer.getPlayers()) - targets.add(cur); - } - else - { - targets = UtilPlayer.matchOnline(caller, args[1], true); - 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); - player.removePotionEffect(PotionEffectType.CONFUSION); - player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); - player.removePotionEffect(PotionEffectType.FAST_DIGGING); - player.removePotionEffect(PotionEffectType.FIRE_RESISTANCE); - player.removePotionEffect(PotionEffectType.HARM); - player.removePotionEffect(PotionEffectType.HEAL); - player.removePotionEffect(PotionEffectType.HEALTH_BOOST); - player.removePotionEffect(PotionEffectType.HUNGER); - player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE); - player.removePotionEffect(PotionEffectType.INVISIBILITY); - player.removePotionEffect(PotionEffectType.JUMP); - player.removePotionEffect(PotionEffectType.NIGHT_VISION); - player.removePotionEffect(PotionEffectType.POISON); - player.removePotionEffect(PotionEffectType.REGENERATION); - player.removePotionEffect(PotionEffectType.SATURATION); - player.removePotionEffect(PotionEffectType.SLOW); - player.removePotionEffect(PotionEffectType.SLOW_DIGGING); - player.removePotionEffect(PotionEffectType.SPEED); - player.removePotionEffect(PotionEffectType.WATER_BREATHING); - player.removePotionEffect(PotionEffectType.WEAKNESS); - player.removePotionEffect(PotionEffectType.WITHER); - } - - return; - } - - //Apply - if (args.length >= 5) - { - //Get Targets - LinkedList targets = new LinkedList(); - - if (args[1].equalsIgnoreCase("all")) - { - for (Player cur : UtilServer.getPlayers()) - targets.add(cur); - } - else - { - targets = UtilPlayer.matchOnline(caller, args[1], true); - if (targets.isEmpty()) - return; - } - - //Get Type - PotionEffectType type = PotionEffectType.getByName(args[2]); - if (type == null) - { - UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Type: " + args[2])); - UtilPlayer.message(caller, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect")); - return; - } - - //Get Multiplier - int mult = 0; - try - { - mult = Integer.parseInt(args[3]); - - if (mult <= 0) - mult = 0; - if (mult > 255) - mult = 255; - } - catch (Exception e) - { - UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Level: " + args[3])); - return; - } - - //Get Duration - int dur = 0; - try - { - dur = Integer.parseInt(args[4]); - - if (dur <= 0) - dur = 0; - } - catch (Exception e) - { - 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) { @@ -1685,4 +387,81 @@ public class EventGame extends SoloGame { event.getDrops().clear(); } + + public boolean isAllowGadget() + { + return _allowAllGadgets; + } + + public void setAllowGadget(boolean var) + { + _allowAllGadgets = var; + } + + public HashSet getGadgetWhitelist() + { + return _gadgetWhitelist; + } + + public boolean isDoubleJump() + { + return _doubleJump; + } + + public void setDoubleJump(boolean var) + { + _doubleJump = var; + } + + public NautHashMap getForcefieldList() + { + return _forcefield; + } + + public ItemStack[] getKitItems() + { + return _kitItems; + } + + public void setKitItems(ItemStack[] kit) + { + _kitItems = kit; + } + + public String[] getSideText() + { + return _sideText; + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return Arrays.asList(); + else + return Arrays.asList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + List losers = GetTeamList().get(0).GetPlayers(false); + + losers.removeAll(winners); + + return losers; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java new file mode 100644 index 000000000..83c0c0801 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -0,0 +1,1681 @@ +package nautilus.game.arcade.game.games.event; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.creature.event.CreatureKillEntitiesEvent; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.give.Give; +import mineplex.core.mount.Mount; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Slime; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Wolf; +import org.bukkit.entity.Zombie; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Villager.Profession; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class EventModule extends MiniPlugin +{ + + public ArcadeManager Manager; + + private NautHashMap _potionEffectsDuration = new NautHashMap<>(); + private NautHashMap _potionEffectsMult = new NautHashMap<>(); + + private boolean _mobGriefing = true; + + public EventModule(ArcadeManager manager, JavaPlugin plugin) + { + super("EventModule", plugin); + Manager = manager; + } + + @EventHandler + public void mobGriefing(EntityChangeBlockEvent event) + { + if(!_mobGriefing) + { + event.setCancelled(true); + } + } + + @EventHandler + public void setHostDebug(PlayerCommandPreprocessEvent event) + { + if (!event.getMessage().toLowerCase().startsWith("/sethost ")) + return; + + boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); + + if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true) + && !event.getPlayer().isOp() && + (!eventTestServer && !Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.SNR_MODERATOR, true))) + return; + + Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1]; + + event.getPlayer().sendMessage("Set host to: " + event.getMessage().split(" ")[1]); + + Manager.GetGameHostManager().setHost(Bukkit.getPlayerExact(Manager.GetServerConfig().HostName)); + if (Manager.GetGameHostManager().getHost() != null) + Manager.GetGameHostManager().setHostRank(Manager.GetClients().Get(Manager.GetGameHostManager().getHost()).GetRank()); + + Manager.GetGameHostManager().setDefaultConfig(); + + event.setCancelled(true); + } + + 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")); + 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", "")); + } + + private void commandHelpSettings(Player player) + { + UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;")); + UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage")); + UtilPlayer.message(player, F.value("/e damage pvp", "Toggles PvP Damage")); + UtilPlayer.message(player, F.value("/e damage pve", "Toggles PvE Damage")); + UtilPlayer.message(player, F.value("/e damage pve", "Toggles EvP Damage")); + UtilPlayer.message(player, F.value("/e damage fall", "Toggles Fall Damage")); + UtilPlayer.message(player, F.value("/e health <-1 to 20>", "Locks Players Health")); + UtilPlayer.message(player, F.value("/e hunger <-1 to 20>", "Locks Players Hunger")); + UtilPlayer.message(player, F.value("/e item drop", "Toggles Item Drop")); + UtilPlayer.message(player, F.value("/e item pickup", "Toggles Item Pickup")); + UtilPlayer.message(player, F.value("/e blockplacecreative", "Toggles Block Placing in Creative (On/Off)")); + UtilPlayer.message(player, F.value("/e blockbreakcreative", "Toggles Block Breaking in Creative (On/Off)")); + UtilPlayer.message(player, F.value("/e blockplace", "Toggles Block Placing (On/Off)")); + UtilPlayer.message(player, F.value("/e blockplace", "Toggles Block Placing (On/Off)")); + UtilPlayer.message(player, F.value("/e blockplace whitelist ", "")); + UtilPlayer.message(player, F.value("/e blockplace blacklist ", "")); + UtilPlayer.message(player, F.value("/e blockbreak", "Toggles Block Breaking (On/Off)")); + UtilPlayer.message(player, F.value("/e blockbreak whitelist ", "")); + UtilPlayer.message(player, F.value("/e blockbreak blacklist ", "")); + UtilPlayer.message(player, F.value("/e time <-1 to 24000>", "Sets World Time")); + //UtilPlayer.message(player, F.value("/e joiningame", "toggles Join In Process for games")); + //UtilPlayer.message(player, F.value("/e deathout", "toggles Deathout in games")); + //UtilPlayer.message(player, F.value("/e quitout", "toggles Quitout in games")); + UtilPlayer.message(player, F.value("/e mobgriefing", "toggles mobgriefing in games")); + } + + //Command Handler + @EventHandler(priority = EventPriority.LOWEST) + private void commandHandler(PlayerCommandPreprocessEvent event) + { + if (!Manager.GetGame().InProgress()) + return; + + if (!event.getMessage().toLowerCase().startsWith("/e ")) + return; + + boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); + + if(!Manager.GetGameHostManager().isEventServer() && !eventTestServer) + return; + + event.setCancelled(true); + + if (!Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) + return; + + //Trim off /e and split to args + String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" "); + + if (args.length == 0 || args[0].equalsIgnoreCase("help")) + { + commandHelp(event.getPlayer()); + } + else if (args[0].equalsIgnoreCase("settings")) + { + if (args.length >= 2 && args[1].equalsIgnoreCase("list")) + listSettings(event.getPlayer()); + else + commandHelpSettings(event.getPlayer()); + } + + //XXX Commands + else if (args[0].equalsIgnoreCase("tp")) + { + commandTeleport(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("gadget")) + { + commandGadget(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("silence")) + { + commandSilence(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("admin")) + { + commandAdmin(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("gm")) + { + commandGamemode(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("radius")) + { + commandForcefieldRadius(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("doublejump")) + { + commandDoubleJump(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("scoreboard")) + { + commandScoreboard(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("whitelist")) + { + commandWhitelist(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("give")) + { + commandGive(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("effect")) + { + commandEffect(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("kit")) + { + commandKit(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("mob")) + { + if (args.length >= 2 && args[1].equalsIgnoreCase("kill")) + commandMobKill(event.getPlayer(), args); + else + commandMob(event.getPlayer(), args); + } + + + //XXX Settings + else if (event.getMessage().toLowerCase().equals("/e damage all")) + { + Manager.GetGame().Damage = !Manager.GetGame().Damage; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Damage All", F.tf(Manager.GetGame().Damage)))); + } + else if (event.getMessage().toLowerCase().equals("/e damage pvp")) + { + Manager.GetGame().DamagePvP = !Manager.GetGame().DamagePvP; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Damage PvP", F.tf(Manager.GetGame().DamagePvP)))); + } + else if (event.getMessage().toLowerCase().equals("/e damage pve")) + { + Manager.GetGame().DamagePvE = !Manager.GetGame().DamagePvE; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Damage PvE", F.tf(Manager.GetGame().DamagePvE)))); + } + else if (event.getMessage().toLowerCase().equals("/e damage evp")) + { + Manager.GetGame().DamageEvP = !Manager.GetGame().DamageEvP; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Damage EvP", F.tf(Manager.GetGame().DamageEvP)))); + } + else if (event.getMessage().toLowerCase().equals("/e damage fall")) + { + Manager.GetGame().DamageFall = !Manager.GetGame().DamageFall; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Damage Fall", F.tf(Manager.GetGame().DamageFall)))); + } + else if (args[0].equalsIgnoreCase("health")) + { + commandHealth(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("hunger")) + { + commandHunger(event.getPlayer(), args); + } + else if (event.getMessage().toLowerCase().equals("/e item drop")) + { + Manager.GetGame().ItemDrop = !Manager.GetGame().ItemDrop; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Item Drop", F.tf(Manager.GetGame().ItemDrop)))); + } + else if (event.getMessage().toLowerCase().equals("/e item pickup")) + { + Manager.GetGame().ItemPickup = !Manager.GetGame().ItemPickup; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Item Pickup", F.tf(Manager.GetGame().ItemPickup)))); + } + else if (event.getMessage().toLowerCase().equals("/e blockplace")) + { + Manager.GetGame().BlockPlace = !Manager.GetGame().BlockPlace; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Block Place", F.tf(Manager.GetGame().BlockPlace)))); + } + else if (args.length >= 4 && args[0].equalsIgnoreCase("blockplace") + && (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))) + { + commandBlockPlace(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2]); + } + else if (event.getMessage().toLowerCase().equals("/e blockbreak")) + { + Manager.GetGame().BlockBreak = !Manager.GetGame().BlockBreak; + Manager.GetGame().Announce(F.main("Event Settings", F.value("Block Break", F.tf(Manager.GetGame().BlockBreak)))); + } + else if (args.length >= 4 && args[0].equalsIgnoreCase("blockbreak") + && (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))) + { + commandBlockBreak(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2]); + } + else if (args[0].equalsIgnoreCase("time")) + { + commandTime(event.getPlayer(), args); + } + /*else if(args[0].equalsIgnoreCase("joiningame")) + { + commandSpectators(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("deathout")) + { + commandDeathout(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("quitout")) + { + commandQuitOut(event.getPlayer(), args); + }*/ + else if(args[0].equalsIgnoreCase("blockplacecreative")) + { + commandBlockPlaceInCreative(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("blockbreakcreative")) + { + commandBlockBreakInCreative(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("mobgriefing")) + { + commandMobGriefing(event.getPlayer(), args); + } + } + + private void listSettings(Player player) + { + UtilPlayer.message(player, F.value("Damage All", F.tf(Manager.GetGame().Damage))); + UtilPlayer.message(player, F.value("Damage PvP", F.tf(Manager.GetGame().DamagePvP))); + UtilPlayer.message(player, F.value("Damage PvE", F.tf(Manager.GetGame().DamagePvE))); + UtilPlayer.message(player, F.value("Damage EvP", F.tf(Manager.GetGame().DamageEvP))); + UtilPlayer.message(player, F.value("Damage Fall", F.tf(Manager.GetGame().DamageFall))); + UtilPlayer.message(player, F.value("Health Set", Manager.GetGame().HealthSet+"")); + UtilPlayer.message(player, F.value("Hunger Set", Manager.GetGame().HungerSet+"")); + UtilPlayer.message(player, F.value("Item Pickup", F.tf(Manager.GetGame().ItemPickup))); + UtilPlayer.message(player, F.value("Item Drop", F.tf(Manager.GetGame().ItemDrop))); + UtilPlayer.message(player, F.value("Block Place Creative", F.tf(Manager.GetGame().BlockPlaceCreative))); + UtilPlayer.message(player, F.value("Block Break Creative", F.tf(Manager.GetGame().BlockBreakCreative))); + UtilPlayer.message(player, F.value("Block Place", F.tf(Manager.GetGame().BlockPlace))); + UtilPlayer.message(player, F.value("Block Place Whitelist", UtilText.listToString(Manager.GetGame().BlockPlaceAllow, true))); + UtilPlayer.message(player, F.value("Block Place Blacklist", UtilText.listToString(Manager.GetGame().BlockPlaceDeny, true))); + UtilPlayer.message(player, F.value("Block Break", F.tf(Manager.GetGame().BlockPlace))); + UtilPlayer.message(player, F.value("Block Break Whitelist", UtilText.listToString(Manager.GetGame().BlockBreakAllow, true))); + UtilPlayer.message(player, F.value("Block Break Blacklist", UtilText.listToString(Manager.GetGame().BlockBreakDeny, true))); + UtilPlayer.message(player, F.value("Time Set", Manager.GetGame().WorldTimeSet+"")); + UtilPlayer.message(player, F.value("Mob griefing", F.tf(_mobGriefing))); + } + + private void commandBlockBreakInCreative(Player player, String[] args) + { + Manager.GetGame().BlockBreakCreative = !Manager.GetGame().BlockBreakCreative; + + UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative))); + } + + private void commandBlockPlaceInCreative(Player player, String[] args) + { + Manager.GetGame().BlockPlaceCreative = !Manager.GetGame().BlockPlaceCreative; + + UtilPlayer.message(player, F.main("Settings", "BlockPlaceCreative: " + F.tf(Manager.GetGame().BlockPlaceCreative))); + } + + private void commandMobGriefing(Player player, String[] args) + { + _mobGriefing = !_mobGriefing; + + UtilPlayer.message(player, F.main("Settings", "Mob Griefing: " + F.tf(_mobGriefing))); + } + + private void commandBlockPlace(Player player, String[] args, boolean whitelist, String command) + { + try + { + int blockId = Integer.parseInt(args[3]); + + if (whitelist) + { + if (command.equalsIgnoreCase("add")) + { + Manager.GetGame().BlockPlaceAllow.add(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Added " + blockId))); + } + else if (command.equalsIgnoreCase("remove")) + { + Manager.GetGame().BlockPlaceAllow.remove(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Removed " + blockId))); + } + else if (command.equalsIgnoreCase("clear")) + { + Manager.GetGame().BlockPlaceAllow.clear(); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Cleared"))); + } + else if (command.equalsIgnoreCase("list")) + { + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", UtilText.listToString(Manager.GetGame().BlockPlaceAllow, true)))); + } + } + else + { + if (command.equalsIgnoreCase("add")) + { + Manager.GetGame().BlockPlaceDeny.add(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Added " + blockId))); + } + else if (command.equalsIgnoreCase("remove")) + { + Manager.GetGame().BlockPlaceDeny.remove(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Removed " + blockId))); + } + else if (command.equalsIgnoreCase("clear")) + { + Manager.GetGame().BlockPlaceDeny.clear(); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Cleared"))); + } + else if (command.equalsIgnoreCase("list")) + { + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", UtilText.listToString(Manager.GetGame().BlockPlaceDeny, true)))); + } + } + + return; + } + catch (Exception e) + { + + } + + commandHelpSettings(player); + } + + private void commandBlockBreak(Player player, String[] args, boolean whitelist, String command) + { + try + { + int blockId = Integer.parseInt(args[3]); + + if (whitelist) + { + if (command.equalsIgnoreCase("add")) + { + Manager.GetGame().BlockBreakAllow.add(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Added " + blockId))); + } + else if (command.equalsIgnoreCase("remove")) + { + Manager.GetGame().BlockBreakAllow.remove(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Removed " + blockId))); + } + else if (command.equalsIgnoreCase("clear")) + { + Manager.GetGame().BlockBreakAllow.clear(); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Cleared"))); + } + else if (command.equalsIgnoreCase("list")) + { + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", UtilText.listToString(Manager.GetGame().BlockBreakAllow, true)))); + } + } + else + { + if (command.equalsIgnoreCase("add")) + { + Manager.GetGame().BlockBreakDeny.add(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Added " + blockId))); + } + else if (command.equalsIgnoreCase("remove")) + { + Manager.GetGame().BlockBreakDeny.remove(blockId); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Removed " + blockId))); + } + else if (command.equalsIgnoreCase("clear")) + { + Manager.GetGame().BlockBreakDeny.clear(); + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Cleared"))); + } + else if (command.equalsIgnoreCase("list")) + { + UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", UtilText.listToString(Manager.GetGame().BlockBreakDeny, true)))); + } + } + + return; + } + catch (Exception e) + { + + } + + commandHelpSettings(player); + } + + private void commandHealth(Player player, String[] args) + { + try + { + if (args.length >= 2) + { + int health = Integer.parseInt(args[1]); + + if (health <= 0) + health = -1; + if (health > 20) + health = 20; + + Manager.GetGame().HealthSet = health; + + if (Manager.GetGame().HealthSet == -1) + Manager.GetGame().Announce(F.main("Event Settings", F.value("Health Set", "Disabled"))); + else + Manager.GetGame().Announce(F.main("Event Settings", F.value("Health Set", Manager.GetGame().HealthSet + ""))); + + return; + } + } + catch (Exception e) + { + + } + + commandHelpSettings(player); + } + + private void commandHunger(Player player, String[] args) + { + try + { + if (args.length >= 2) + { + int hunger = Integer.parseInt(args[1]); + + if (hunger <= 0) + hunger = -1; + if (hunger > 20) + hunger = 20; + + Manager.GetGame().HungerSet = hunger; + + if (Manager.GetGame().HungerSet == -1) + Manager.GetGame().Announce(F.main("Event Settings", F.value("Hunger Set", "Disabled"))); + else + Manager.GetGame().Announce(F.main("Event Settings", F.value("Hunger Set", Manager.GetGame().HungerSet + ""))); + + return; + } + } + catch (Exception e) + { + + } + + commandHelpSettings(player); + } + + private void commandTime(Player player, String[] args) + { + try + { + if (args.length >= 2) + { + int time = Integer.parseInt(args[1]); + + if (time <= -1) + time = -1; + if (time > 24000) + time = 24000; + + Manager.GetGame().WorldTimeSet = time; + + if (Manager.GetGame().WorldTimeSet == -1) + Manager.GetGame().Announce(F.main("Event Settings", F.value("Time Set", "Disabled"))); + else + Manager.GetGame().Announce(F.main("Event Settings", F.value("Time Set", Manager.GetGame().WorldTimeSet + ""))); + + return; + } + } + catch (Exception e) + { + + } + + commandHelpSettings(player); + } + + //Teleport Command (To, Here, All) + private void commandTeleport(Player player, String[] args) + { + if (args.length >= 3 && args[1].equalsIgnoreCase("here")) + { + if (args[2].equalsIgnoreCase("all")) + { + for (Player other : UtilServer.getPlayers()) + { + UtilPlayer.message(other, F.main("Event TP", player.getName() + " teleported everyone to self.")); + other.teleport(player); + } + + return; + } + + Player target = UtilPlayer.searchOnline(player, args[2], true); + if (target != null) + { + target.teleport(player); + UtilPlayer.message(target, F.main("Event TP", player.getName() + " teleported you to self.")); + UtilPlayer.message(player, F.main("Event TP", "Teleported " + target.getName() + " to you.")); + } + + return; + } + + if (args.length >= 2) + { + Player target = UtilPlayer.searchOnline(player, args[1], true); + if (target != null) + { + player.teleport(target); + UtilPlayer.message(player, F.main("Event TP", "Teleported to " + target.getName() + ".")); + } + + return; + } + + commandHelp(player); + } + + //Gadget Commands (Global & Individual) + private void commandGadget(Player player, String[] args) + { + if(!(Manager.GetGame() instanceof EventGame)) { + UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!")); + return; + } + + if (args.length < 2) + { + ((EventGame) Manager.GetGame()).setAllowGadget(!((EventGame) Manager.GetGame()).isAllowGadget()); + + if (!((EventGame) Manager.GetGame()).isAllowGadget()) + { + Manager.getCosmeticManager().getMountManager().DisableAll(); + Manager.getCosmeticManager().getGadgetManager().DisableAll(); + } + + Manager.GetGame().Announce(F.main("Inventory", F.value("Allow All Gadgets", F.ed(((EventGame) Manager.GetGame()).isAllowGadget())))); + return; + } + + if (args.length >= 2 && args[1].equalsIgnoreCase("clear")) + { + ((EventGame) Manager.GetGame()).getGadgetWhitelist().clear(); + Manager.GetGame().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()) + { + mounts += color + mount.GetName().replaceAll(" ", "") + " "; + color = (color == ChatColor.AQUA ? ChatColor.DARK_AQUA : ChatColor.AQUA); + } + UtilPlayer.message(player, mounts); + + return; + } + + if (args.length >= 2) + { + //Gadgets + for (GadgetType type : GadgetType.values()) + { + for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type)) + { + if (gadget.GetName().replaceAll(" ", "").equalsIgnoreCase(args[1])) + { + if (((EventGame) Manager.GetGame()).getGadgetWhitelist().remove(gadget)) + { + Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget", F.ed(false)))); + gadget.DisableForAll(); + } + else + { + Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget", F.ed(true)))); + ((EventGame) Manager.GetGame()).getGadgetWhitelist().add(gadget); + } + + return; + } + } + } + + //Mounts + for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) + { + if (mount.GetName().replaceAll(" ", "").equalsIgnoreCase(args[1])) + { + if (((EventGame) Manager.GetGame()).getGadgetWhitelist().remove(mount)) + { + Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget", F.ed(false)))); + mount.DisableForAll(); + } + else + { + Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget", F.ed(true)))); + ((EventGame) Manager.GetGame()).getGadgetWhitelist().add(mount); + } + + return; + } + } + + UtilPlayer.message(player, F.main("Inventory", args[1] + " is not a valid gadget.")); + + return; + } + + commandHelp(player); + } + + //Silence + private void commandSilence(Player player, String[] args) + { + try + { + //Toggle + if (args.length == 1) + { + //Disable + if (Manager.GetChat().Silenced() != 0) + { + Manager.GetChat().Silence(0, true); + } + //Enable + else + { + Manager.GetChat().Silence(-1, true); + } + } + //Timer + else + { + long time = (long) (Double.valueOf(args[1]) * 3600000); + + Manager.GetChat().Silence(time, true); + } + } + catch (Exception e) + { + UtilPlayer.message(player, F.main("Chat", "Invalid Time Parameter.")); + } + } + + //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) + { + Player target = player; + + if (args.length >= 2) + { + Player newTarget = UtilPlayer.searchOnline(player, args[1], true); + if (newTarget != null) + target = newTarget; + else + return; + } + + if (target.getGameMode() == GameMode.CREATIVE) + target.setGameMode(GameMode.SURVIVAL); + else + target.setGameMode(GameMode.CREATIVE); + + UtilPlayer.message(player, F.main("Event GM", target.getName() + " Creative: " + F.tf(target.getGameMode() == GameMode.CREATIVE))); + } + + //Forcefield + private void commandForcefieldRadius(Player player, String[] args) + { + + if(!(Manager.GetGame() instanceof EventGame)) { + UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable the forcefield in the Event game!")); + return; + } + + //Toggle + if (args.length >= 2) + { + try + { + int range = Integer.parseInt(args[1]); + + ((EventGame) Manager.GetGame()).getForcefieldList().put(player.getName(), range); + + UtilPlayer.message(player, F.main("Forcefield", "Enabled with " + F.elem(range + "") + " radius.")); + } + catch (Exception e) + { + UtilPlayer.message(player, F.main("Forcefield", "Invalid Input.")); + } + } + else + { + ((EventGame) Manager.GetGame()).getForcefieldList().remove(player.getName()); + UtilPlayer.message(player, F.main("Forcefield", "Disabled.")); + } + } + + //Give + private void commandGive(Player player, String[] args) + { + String[] newArgs = new String[args.length-1]; + + for (int i=0 ; i= 2) + { + //Line + int line = 0; + try + { + line = Integer.parseInt(args[1]); + } + catch (Exception e) + { + UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number.")); + return; + } + + if (line < 1 || line > 14) + { + UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number.")); + return; + } + + //Text + String lineText = ""; + + //Reset String + if (args.length <= 2) + for (int i=0 ; i= 2 && args[1].equalsIgnoreCase("clear")) + { + for (int i=0 ; i<((EventGame) Manager.GetGame()).getSideText().length ; i++) + { + String lineText = ""; + for (int j=0 ; j= 2) + { + if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("off")) + { + UtilServer.getServer().setWhitelist(args[1].equalsIgnoreCase("on")); + + Manager.GetGame().Announce(F.main("Event Settings", F.value("Whitelist", F.tf(args[1].equalsIgnoreCase("on"))))); + return; + } + } + + //Add and Remove + if (args.length >= 3) + { + if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove")) + { + OfflinePlayer target = Bukkit.getOfflinePlayer(args[2]); + + if (args[1].equalsIgnoreCase("add")) + { + UtilServer.getServer().getWhitelistedPlayers().add(target); + UtilPlayer.message(player, F.main("Whitelist", "Added " + args[2] + " to the whitelist.")); + } + else + { + UtilServer.getServer().getWhitelistedPlayers().remove(target); + UtilPlayer.message(player, F.main("Whitelist", "Removed " + args[2] + " to the whitelist.")); + } + + return; + } + } + + commandHelp(player); + } + + //Mob + private void commandMob(Player caller, String[] args) + { + if (args.length == 1) + { + HashMap entMap = new HashMap(); + + int count = 0; + for (World world : UtilServer.getServer().getWorlds()) + { + for (Entity ent : world.getEntities()) + { + if (!entMap.containsKey(ent.getType())) + entMap.put(ent.getType(), 0); + + entMap.put(ent.getType(), 1 + entMap.get(ent.getType())); + count++; + } + } + + UtilPlayer.message(caller, F.main("Creature", "Listing Entities:")); + for (EntityType cur : entMap.keySet()) + { + UtilPlayer.message(caller, F.desc(UtilEnt.getName(cur), entMap.get(cur)+"")); + } + + UtilPlayer.message(caller, F.desc("Total", count+"")); + } + else + { + EntityType type = UtilEnt.searchEntity(caller, args[1], true); + + if (type == null) + return; + + UtilPlayer.message(caller, F.main("Creature", "Spawning Creature(s);")); + + //Store Args + HashSet argSet = new HashSet(); + for (int i = 2 ; i < args.length ; i++) + if (args[i].length() > 0) + argSet.add(args[i]); + + + //Search Count + int count = 1; + HashSet argHandle = new HashSet(); + for (String arg : argSet) + { + try + { + int newCount = Integer.parseInt(arg); + + if (newCount <= 0) + continue; + + //Set Count + count = newCount; + UtilPlayer.message(caller, F.desc("Amount", count+"")); + + //Flag Arg + argHandle.add(arg); + break; + } + catch (Exception e) + { + //None + } + } + for (String arg : argHandle) + argSet.remove(arg); + + //Spawn + HashSet entSet = new HashSet(); + for (int i = 0 ; i < count ; i++) + { + Manager.GetGame().CreatureAllowOverride = true; + entSet.add(Manager.GetCreature().SpawnEntity(caller.getTargetBlock(null, 0).getLocation().add(0.5, 1, 0.5), type)); + Manager.GetGame().CreatureAllowOverride = false; + } + + //Search Vars + for (String arg : argSet) + { + if (arg.length() == 0) + continue; + + //Baby + else if (arg.equalsIgnoreCase("baby") || arg.equalsIgnoreCase("b")) + { + for (Entity ent : entSet) + { + if (ent instanceof Ageable) + ((Ageable)ent).setBaby(); + else if (ent instanceof Zombie) + ((Zombie)ent).setBaby(true); + } + + UtilPlayer.message(caller, F.desc("Baby", "True")); + argHandle.add(arg); + } + + //Lock + else if (arg.equalsIgnoreCase("age") || arg.equalsIgnoreCase("lock")) + { + for (Entity ent : entSet) + if (ent instanceof Ageable) + { + ((Ageable)ent).setAgeLock(true); + UtilPlayer.message(caller, F.desc("Age", "False")); + } + + argHandle.add(arg); + } + + //Angry + else if (arg.equalsIgnoreCase("angry") || arg.equalsIgnoreCase("a")) + { + for (Entity ent : entSet) + if (ent instanceof Wolf) + ((Wolf)ent).setAngry(true); + + for (Entity ent : entSet) + if (ent instanceof Skeleton) + ((Skeleton)ent).setSkeletonType(SkeletonType.WITHER); + + UtilPlayer.message(caller, F.desc("Angry", "True")); + argHandle.add(arg); + } + + //Profession + else if (arg.toLowerCase().charAt(0) == 'p') + { + try + { + String prof = arg.substring(1, arg.length()); + + Profession profession = null; + for (Profession cur : Profession.values()) + if (cur.name().toLowerCase().contains(prof.toLowerCase())) + profession = cur; + + UtilPlayer.message(caller, F.desc("Profession", profession.name())); + + for (Entity ent : entSet) + if (ent instanceof Villager) + ((Villager)ent).setProfession(profession); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.desc("Profession", "Invalid [" + arg + "] on " + type.name())); + } + argHandle.add(arg); + } + + //Size + else if (arg.toLowerCase().charAt(0) == 's') + { + try + { + String size = arg.substring(1, arg.length()); + + UtilPlayer.message(caller, F.desc("Size", Integer.parseInt(size)+"")); + + for (Entity ent : entSet) + if (ent instanceof Slime) + ((Slime)ent).setSize(Integer.parseInt(size)); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name())); + } + argHandle.add(arg); + } + + else if (arg.toLowerCase().charAt(0) == 'n' && arg.length() > 1) + { + try + { + String name = ""; + + for (char c : arg.substring(1, arg.length()).toCharArray()) + { + if (c != '_') + name += c; + else + name += " "; + } + + for (Entity ent : entSet) + { + if (ent instanceof CraftLivingEntity) + { + CraftLivingEntity cEnt = (CraftLivingEntity)ent; + cEnt.setCustomName(name); + cEnt.setCustomNameVisible(true); + } + } + } + catch (Exception e) + { + UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name())); + } + argHandle.add(arg); + } + else if (arg.toLowerCase().charAt(0) == 'h' && arg.length() > 1) + { + try + { + String health = ""; + + for (char c : arg.substring(1, arg.length()).toCharArray()) + { + if (c != '_') + health += c; + else + health += " "; + } + + double healthint = Double.parseDouble(health); + + for (Entity ent : entSet) + { + if (ent instanceof CraftLivingEntity) + { + CraftLivingEntity cEnt = (CraftLivingEntity)ent; + cEnt.setMaxHealth(healthint); + cEnt.setHealth(healthint); + } + } + } + catch (Exception e) + { + UtilPlayer.message(caller, F.desc("Health", "Invalid [" + arg + "] on " + type.name())); + } + argHandle.add(arg); + } + else if (arg.toLowerCase().charAt(0) == 'e' && arg.length() > 1) + { + try + { + String effect = ""; + + for (char c : arg.substring(1, arg.length()).toCharArray()) + { + if (c != '_') + effect += c; + else + effect += " "; + } + + PotionEffectType potionType = PotionEffectType.getByName(effect); + + if (potionType == null) + { + UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Type: " + args[2])); + UtilPlayer.message(caller, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect")); + return; + } + + for (Entity ent : entSet) + { + if (ent instanceof CraftLivingEntity) + { + CraftLivingEntity cEnt = (CraftLivingEntity)ent; + cEnt.addPotionEffect(new PotionEffect(potionType, Integer.MAX_VALUE, 0)); + } + } + } + catch (Exception e) + { + UtilPlayer.message(caller, F.desc("PotionEffect", "Invalid [" + arg + "] on " + type.name())); + } + argHandle.add(arg); + } + else if (arg.toLowerCase().charAt(0) == 'i' && arg.length() > 1) + { + try + { + String item = ""; + + for (char c : arg.substring(1, arg.length()).toCharArray()) + { + item += c; + } + + Material mat = Material.getMaterial(item); + + for (Entity ent : entSet) + { + if (ent instanceof CraftLivingEntity) + { + CraftLivingEntity cEnt = (CraftLivingEntity)ent; + cEnt.getEquipment().setItemInHand(new ItemStack(mat)); + } + } + } + catch (Exception e) + { + UtilPlayer.message(caller, F.desc("Item", "Invalid [" + arg + "] on " + type.name())); + } + argHandle.add(arg); + } + else if (arg.toLowerCase().charAt(0) == 'a' && arg.length() > 1) + { + try + { + String armor = ""; + + for (char c : arg.substring(1, arg.length()).toCharArray()) + { + if (c != '_') + armor += c; + else + armor += " "; + } + + ItemStack head = null; + ItemStack chest = null; + ItemStack leggings = null; + ItemStack boots = null; + + + if(armor.equalsIgnoreCase("leather")) + { + head = new ItemStack(Material.LEATHER_HELMET); + chest = new ItemStack(Material.LEATHER_CHESTPLATE); + leggings = new ItemStack(Material.LEATHER_LEGGINGS); + boots = new ItemStack(Material.LEATHER_BOOTS); + } + if(armor.equalsIgnoreCase("gold")) + { + head = new ItemStack(Material.GOLD_HELMET); + chest = new ItemStack(Material.GOLD_CHESTPLATE); + leggings = new ItemStack(Material.GOLD_LEGGINGS); + boots = new ItemStack(Material.GOLD_BOOTS); + } + if(armor.equalsIgnoreCase("chain")) + { + head = new ItemStack(Material.CHAINMAIL_HELMET); + chest = new ItemStack(Material.CHAINMAIL_CHESTPLATE); + leggings = new ItemStack(Material.CHAINMAIL_LEGGINGS); + boots = new ItemStack(Material.CHAINMAIL_BOOTS); + } + if(armor.equalsIgnoreCase("iron")) + { + head = new ItemStack(Material.IRON_HELMET); + chest = new ItemStack(Material.IRON_CHESTPLATE); + leggings = new ItemStack(Material.IRON_LEGGINGS); + boots = new ItemStack(Material.IRON_BOOTS); + } + if(armor.equalsIgnoreCase("diamond")) + { + head = new ItemStack(Material.DIAMOND_HELMET); + chest = new ItemStack(Material.DIAMOND_CHESTPLATE); + leggings = new ItemStack(Material.DIAMOND_LEGGINGS); + boots = new ItemStack(Material.DIAMOND_BOOTS); + } + + for (Entity ent : entSet) + { + if (ent instanceof CraftLivingEntity) + { + CraftLivingEntity cEnt = (CraftLivingEntity)ent; + cEnt.getEquipment().setHelmet(head); + cEnt.getEquipment().setChestplate(chest); + cEnt.getEquipment().setLeggings(leggings); + cEnt.getEquipment().setBoots(boots); + } + } + } + catch (Exception e) + { + UtilPlayer.message(caller, F.desc("Armor", "Invalid [" + arg + "] on " + type.name())); + } + argHandle.add(arg); + } + } + for (String arg : argHandle) + argSet.remove(arg); + + for (String arg : argSet) + UtilPlayer.message(caller, F.desc("Unhandled", arg)); + + //Inform + UtilPlayer.message(caller, F.main("Creature", "Spawned " + count + " " + UtilEnt.getName(type) + ".")); + } + } + + private void commandMobKill(Player caller, String[] args) + { + if (args.length < 3) + { + UtilPlayer.message(caller, F.main("Creature", "Missing Entity Type Parameter.")); + return; + } + + EntityType type = UtilEnt.searchEntity(caller, args[2], true); + + if (type == null && !args[2].equalsIgnoreCase("all")) + return; + + int count = 0; + List killList = new ArrayList(); + + for (World world : UtilServer.getServer().getWorlds()) + { + for (Entity ent : world.getEntities()) + { + if (ent.getType() == EntityType.PLAYER) + continue; + + if (type == null || ent.getType() == type) + { + killList.add(ent); + } + } + } + + CreatureKillEntitiesEvent event = new CreatureKillEntitiesEvent(killList); + UtilServer.getServer().getPluginManager().callEvent(event); + + for (Entity entity : event.GetEntities()) + { + entity.remove(); + count++; + } + + String target = "ALL"; + if (type != null) + target = UtilEnt.getName(type); + + UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed.")); + } + + private void commandKit(Player caller, String[] args) + { + + if(!(Manager.GetGame() instanceof EventGame)) { + UtilPlayer.message(caller, F.main("Inventory", "You can only enable/disable a Kit in the Event game!")); + return; + } + + if (args.length >= 2 && args[1].equalsIgnoreCase("apply")) + { + for (Player player : UtilServer.getPlayers()) + ((EventGame) Manager.GetGame()).giveItems(player); + + Manager.GetGame().Announce(F.main("Event Settings", F.value("Player Kit", "Applied to Players"))); + return; + } + + if (args.length >= 2 && args[1].equalsIgnoreCase("clear")) + { + ((EventGame) Manager.GetGame()).setKitItems(new ItemStack[6]); + Manager.GetGame().Announce(F.main("Event Settings", F.value("Player Kit", "Cleared Kit"))); + return; + } + + if (args.length >= 2 && args[1].equalsIgnoreCase("set")) + { + ((EventGame) Manager.GetGame()).setKitItems(new ItemStack[6]); + + for (int i=0 ; i<6 ; i++) + { + if (caller.getInventory().getItem(i) != null) + ((EventGame) Manager.GetGame()).getKitItems()[i] = caller.getInventory().getItem(i).clone(); + else + ((EventGame) Manager.GetGame()).getKitItems()[i] = null; + } + + Manager.GetGame().Announce(F.main("Event Settings", F.value("Player Kit", "Updated Items"))); + return; + } + + commandHelp(caller); + } + + private void commandEffect(Player caller, String[] args) + { + //Clear + if (args.length >= 3 && args[2].equalsIgnoreCase("clear")) + { + //Get Targets + LinkedList targets = new LinkedList(); + + if (args[1].equalsIgnoreCase("all")) + { + for (Player cur : UtilServer.getPlayers()) + targets.add(cur); + + _potionEffectsDuration.clear(); + _potionEffectsMult.clear(); + } + else + { + targets = UtilPlayer.matchOnline(caller, args[1], true); + 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); + player.removePotionEffect(PotionEffectType.CONFUSION); + player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); + player.removePotionEffect(PotionEffectType.FAST_DIGGING); + player.removePotionEffect(PotionEffectType.FIRE_RESISTANCE); + player.removePotionEffect(PotionEffectType.HARM); + player.removePotionEffect(PotionEffectType.HEAL); + player.removePotionEffect(PotionEffectType.HEALTH_BOOST); + player.removePotionEffect(PotionEffectType.HUNGER); + player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE); + player.removePotionEffect(PotionEffectType.INVISIBILITY); + player.removePotionEffect(PotionEffectType.JUMP); + player.removePotionEffect(PotionEffectType.NIGHT_VISION); + player.removePotionEffect(PotionEffectType.POISON); + player.removePotionEffect(PotionEffectType.REGENERATION); + player.removePotionEffect(PotionEffectType.SATURATION); + player.removePotionEffect(PotionEffectType.SLOW); + player.removePotionEffect(PotionEffectType.SLOW_DIGGING); + player.removePotionEffect(PotionEffectType.SPEED); + player.removePotionEffect(PotionEffectType.WATER_BREATHING); + player.removePotionEffect(PotionEffectType.WEAKNESS); + player.removePotionEffect(PotionEffectType.WITHER); + } + + return; + } + + //Apply + if (args.length >= 5) + { + + //Get Type + PotionEffectType type = PotionEffectType.getByName(args[2]); + if (type == null) + { + UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Type: " + args[2])); + UtilPlayer.message(caller, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect")); + return; + } + + //Get Multiplier + int mult = 0; + try + { + mult = Integer.parseInt(args[3]); + + if (mult <= 0) + mult = 0; + if (mult > 255) + mult = 255; + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Level: " + args[3])); + return; + } + + //Get Duration + int dur = 0; + try + { + dur = Integer.parseInt(args[4]); + + if (dur <= 0) + dur = 0; + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main("Effect", "Invalid Effect Duration: " + args[4])); + return; + } + + //Get Targets + LinkedList targets = new LinkedList(); + + if (args[1].equalsIgnoreCase("all")) + { + for (Player cur : UtilServer.getPlayers()) + targets.add(cur); + + _potionEffectsDuration.put(type, (long) (System.currentTimeMillis() + (dur * 1000))); + _potionEffectsMult.put(type, mult); + } + else + { + targets = UtilPlayer.matchOnline(caller, args[1], true); + if (targets.isEmpty()) + return; + } + + //Apply + PotionEffect effect = new PotionEffect(type, dur*20, mult); + for (Player cur : targets) + { + cur.addPotionEffect(effect); + } + + if (args[1].equalsIgnoreCase("all")) + Manager.GetGame().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 updatePotionEffects(UpdateEvent event) + { + if(event.getType() != UpdateType.SEC) + return; + + for(Player player : UtilServer.getPlayers()) + { + for(PotionEffectType effect : _potionEffectsDuration.keySet()) + { + player.addPotionEffect(new PotionEffect(effect, (int) (((_potionEffectsDuration.get(effect) - System.currentTimeMillis()) / 1000) * 20), _potionEffectsMult.get(effect))); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 3fb7a570f..338056822 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -74,8 +74,6 @@ public class Evolution extends SoloGame this.DeathOut = false; this.PrepareFreeze = false; - - this.SpawnDistanceRequirement = 16; _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Evolutions", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java index 509ebd349..917bf5f77 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilMath; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -15,6 +16,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.kit.Kit; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -225,7 +227,8 @@ public class HoleInTheWall extends SoloGame { wall.getKnockedPlayers().add(player.getUniqueId()); - player.setVelocity(_wallVector.clone().normalize().multiply(5).setY(0.3)); + + UtilAction.velocity(player, _wallVector.clone().normalize().multiply(5).setY(0.3)); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2, 1F); } /*Location toTeleport = player.getLocation(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java new file mode 100644 index 000000000..5a7f6a0de --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java @@ -0,0 +1,591 @@ +package nautilus.game.arcade.game.games.lobbers; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.explosion.ExplosionEvent; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.lobbers.events.TNTPreExplodeEvent; +import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent; +import nautilus.game.arcade.game.games.lobbers.kits.KitArmorer; +import nautilus.game.arcade.game.games.lobbers.kits.KitJumper; +import nautilus.game.arcade.game.games.lobbers.kits.KitPitcher; +import nautilus.game.arcade.game.games.lobbers.kits.KitWaller; +import nautilus.game.arcade.game.games.lobbers.trackers.Tracker6Kill; +import nautilus.game.arcade.game.games.lobbers.trackers.TrackerBlastProof; +import nautilus.game.arcade.game.games.lobbers.trackers.TrackerDirectHit; +import nautilus.game.arcade.game.games.lobbers.trackers.TrackerNoDamage; +import nautilus.game.arcade.game.games.lobbers.trackers.TrackerTNTThrown; +import nautilus.game.arcade.kit.Kit; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + +public class BombLobbers extends TeamGame implements IThrown +{ + /** + * @author Mysticate + * Created in July, 2015 + */ + + private NautHashMap _averageSpawns = new NautHashMap(); + + private NautHashMap _tnt = new NautHashMap(); + + private NautHashMap _kills = new NautHashMap(); + + @SuppressWarnings("unchecked") + public BombLobbers(ArcadeManager manager) + { + super(manager, GameType.Lobbers, new Kit[] + { + new KitJumper(manager), + new KitArmorer(manager), + new KitPitcher(manager), + new KitWaller(manager) + }, new String[] + { + "Fight against your enemies using", + "the power of explosives!", + "Left click TNT to throw at your enemy.", + "Last team alive wins!" + }); + DamageFall = true; + DamageEvP = true; + + WorldWaterDamage = 5; + + PrepareFreeze = false; + + TeamArmor = true; + TeamArmorHotbar = true; + + InventoryOpenChest = false; + InventoryOpenBlock = false; + + ItemDrop = false; + + BlockPlace = false; + + Manager.GetExplosion().SetLiquidDamage(false); + + HungerSet = 20; + + WorldTimeSet = 6000; + + registerStatTrackers(new Tracker6Kill(this), new TrackerBlastProof(this), new TrackerNoDamage(this), new TrackerTNTThrown(this), new TrackerDirectHit(this)); + } + + @EventHandler + public void setTime(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + if (WorldData.MapName.equalsIgnoreCase("Intergalactic")) + { + WorldTimeSet = 18000; + } + } + + public void addKill(Player player) + { + _kills.put(player, _kills.containsKey(player) ? _kills.get(player) + 1 : 1); + } + + public double getKills(Player player) + { + if (_kills.containsKey(player)) + { + return _kills.get(player); + } + else + { + _kills.put(player, 0.0); + return 0; + } + } + + @EventHandler + public void onKill(CombatDeathEvent event) + { + if (!IsLive()) + return; + + Player dead = UtilPlayer.searchExact(((Player) event.GetEvent().getEntity()).getName()); + + if (!IsAlive(dead)) + return; + + for (CombatComponent damager : event.GetLog().GetAttackers()) + { + Player killer = UtilPlayer.searchExact(damager.GetName()); + + if (killer == null || !killer.isOnline()) + continue; + + if (IsAlive(killer)) + { + if (event.GetLog().GetKiller() == damager) + { + addKill(killer); + } + } + } + } + + @EventHandler + public void loadTeamLocations(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live) + { + for (GameTeam team : _teamList) + { + _averageSpawns.put(team, UtilAlg.getAverageLocation(team.GetSpawns())); + } + } + } + + @EventHandler + public void disableFlying(GameStateChangeEvent event) + { + for (Player player : GetPlayers(true)) + { + player.setAllowFlight(false); + } + } + + @EventHandler + public void throwTNT(PlayerInteractEvent event) + { + if (event.getAction() == Action.PHYSICAL) + return; + + if (!IsLive()) + return; + + Player player = event.getPlayer(); + + if (!IsAlive(player)) + return; + + if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) + return; + + event.setCancelled(true); + + UtilInv.remove(player, Material.TNT, (byte) 0, 1); + UtilInv.Update(player); + + TNTPrimed tnt = (TNTPrimed) player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); + tnt.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), player.getUniqueId())); + tnt.setFuseTicks(60); + + UtilAction.velocity(tnt, player.getLocation().getDirection(), 2.0D, false, 0.0D, 0.1D, 10.0D, false); + + ArrayList canHit = new ArrayList(); + for (Player pos : GetPlayers(true)) + { + if (GetTeam(player).HasPlayer(pos)) + continue; + + canHit.add(pos); + } + + Manager.GetProjectile().AddThrow(tnt, player, this, -1L, true, false, true, .2F, canHit); + + Manager.getPlugin().getServer().getPluginManager().callEvent(new TNTThrowEvent(player, tnt)); + + _tnt.put(tnt, new BombToken(player)); + + AddGems(player, 0.5, "TNT Thrown", true, true); + } + + public Player getThrower(TNTPrimed tnt) + { + if (_tnt.get(tnt) == null) + return null; + + return UtilPlayer.searchExact(_tnt.get(tnt).Thrower); + } + + @EventHandler + public void onTNTExplode(ExplosionPrimeEvent event) + { + if (!IsLive()) + return; + + if (!(event.getEntity() instanceof TNTPrimed)) + return; + + TNTPrimed tnt = (TNTPrimed) event.getEntity(); + + if (!_tnt.containsKey(tnt)) + return; + + Player thrower = UtilPlayer.searchExact(_tnt.get(tnt).Thrower); + + if (thrower == null) + { + event.setCancelled(true); + + _tnt.remove(tnt); + + event.getEntity().remove(); + return; + } + + if (GetTeam(thrower) == getSide(tnt.getLocation())) + { + event.setCancelled(true); + + _tnt.remove(tnt); + + event.getEntity().remove(); + + return; + } + + TNTPreExplodeEvent preExplode = new TNTPreExplodeEvent(thrower, tnt); + Manager.getPlugin().getServer().getPluginManager().callEvent(preExplode); + + if (preExplode.isCancelled()) + { + event.setCancelled(true); + tnt.remove(); + } + else + { + for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14)) + { + Manager.GetCondition().Factory().Explosion("Throwing TNT", other, thrower, 50, 0.1, false, false); + } + } + + _tnt.remove(tnt); + } + + @EventHandler + public void updateTNT(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + NautHashMap toAdd = new NautHashMap(); + + Iterator> iterator = _tnt.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry tnt = iterator.next(); + + if (tnt.getKey() == null) + continue; + + if (!tnt.getKey().isValid()) + continue; + + BombToken token = tnt.getValue(); + Player thrower = UtilPlayer.searchExact(token.Thrower); + + if (thrower == null) + continue; + + if (!IsPlaying(thrower)) + continue; + + if (!token.Primed) + { + if (tnt.getKey().getFuseTicks() <= 20) + { + //Respawn + TNTPrimed newTNT = tnt.getKey().getWorld().spawn(tnt.getKey().getLocation(), TNTPrimed.class); + newTNT.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), thrower.getUniqueId())); + newTNT.setVelocity(tnt.getKey().getVelocity()); + newTNT.setFuseTicks(60); + + Manager.GetProjectile().AddThrow(newTNT, thrower, this, -1L, true, false, true, .2F); + + tnt.getKey().remove(); + + iterator.remove(); + toAdd.put(newTNT, token); + } + } + } + + //Prevent concurrent modification thigns + for (Entry entry : toAdd.entrySet()) + { + _tnt.put(entry.getKey(), entry.getValue()); + } + } + + @EventHandler + public void blockCollision(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + for (Entry tnt : _tnt.entrySet()) + { + if (tnt.getKey() == null) + continue; + + if (!tnt.getKey().isValid()) + continue; + + BombToken token = tnt.getValue(); + Player thrower = UtilPlayer.searchExact(token.Thrower); + + if (thrower == null) + continue; + + if (!IsPlaying(thrower)) + continue; + + if (!token.Primed) + { + //8+ insta explode + if (UtilTime.elapsed(token.Created, 8000)) + { + token.Primed = true; + tnt.getKey().setFuseTicks(0); + continue; + } + else if (UtilTime.elapsed(token.Created, 3000)) + { + for (Block block : UtilBlock.getSurrounding(tnt.getKey().getLocation().getBlock(), true)) + { + if (block.getType() != Material.AIR) + { + token.Primed = true; + tnt.getKey().setFuseTicks(0); + break; + } + } + } + } + } + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + for (Entry tnt : _tnt.entrySet()) + { + if (tnt.getKey() == null) + continue; + + if (!tnt.getKey().isValid()) + continue; + + if (UtilEnt.isGrounded(tnt.getKey()) || tnt.getKey().isOnGround()) + continue; + + BombToken token = tnt.getValue(); + Player thrower = UtilPlayer.searchExact(token.Thrower); + + if (thrower == null) + continue; + + if (!IsPlaying(thrower)) + continue; + + GameTeam team = GetTeam(thrower); + + if (team == null) + continue; + + //A is current + //B is previous + token.B = token.A; + token.A = tnt.getKey().getLocation(); + + if (token.A == null || token.B == null) + continue; + + //Adapted from static lazer code + double curRange = 0; + double distance = Math.abs(token.A.distance(token.B)); + + while (curRange <= distance) + { + Location newTarget = token.B.add(UtilAlg.getTrajectory(token.B, token.A).multiply(curRange)); +// Location newTarget = player.getEyeLocation().add(player.getLocation().getDirection().multiply(curRange)); + + //Progress Forwards + curRange += 0.2; + + if (team.GetColor() == ChatColor.AQUA) + { + for (int i = 0 ; i < 2 ; i++) + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget.clone().add(0.0, 0.5, 0.0), -1, 1, 1, 1, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + for (int i = 0 ; i < 2 ; i++) + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget.clone().add(0.0, 0.5, 0.0), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + + //UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget.clone().add(0.0, 0.6, 0.0), team.GetColorBase().getRed(), team.GetColorBase().getGreen(), team.GetColorBase().getBlue(), 1, 0, ViewDist.LONG, UtilServer.getPlayers()); + } + } + } + + @EventHandler + public void preventCheating(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + for (Player player : GetPlayers(true)) + { + if (GetTeam(player) != getSide(player.getLocation())) + { + player.damage(500); + UtilPlayer.message(player, F.main("Game", "You were killed for trying to cheat!")); + } + } + } + + @SuppressWarnings("deprecation") + @EventHandler + public void damageBlocks(ExplosionEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + Iterator iterator = event.GetBlocks().iterator(); + + while (iterator.hasNext()) + { + Block block = iterator.next(); + + //Stone + if (block.getType() == Material.STONE) + { + block.setType(Material.COBBLESTONE); + iterator.remove(); + continue; + } + + //Stone Brick + if (block.getType() == Material.SMOOTH_BRICK && block.getData() != 2) + { + block.setData((byte) 2); + iterator.remove(); + continue; + } + } + } + + private GameTeam getSide(Location entityLoc) + { + Location nearest = UtilAlg.findClosest(entityLoc, new ArrayList(_averageSpawns.values())); + for (Entry entry : _averageSpawns.entrySet()) + { + if (entry.getValue().equals(nearest)) + return entry.getKey(); + } + return null; + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (!(data.GetThrown() instanceof TNTPrimed)) + return; + + if (!(data.GetThrower() instanceof Player)) + return; + + if (!(target instanceof Player)) + return; + + if (GetTeam((Player) target) == GetTeam((Player) data.GetThrower())) + return; + + data.GetThrown().setVelocity(new Vector()); + + if (target != null) + UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown().getLocation(), target.getLocation()), .2, false, 0, 0.2, .4, true); + + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 10.0, false, false, false, "Throwing TNT", "Throwing TNT Direct Hit"); + + AddGems((Player) data.GetThrower(), 4.0, "Direct Hit", true, true); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + + } + + public void knockbackIncrease(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_EXPLOSION && event.GetCause() != DamageCause.BLOCK_EXPLOSION) + return; + + event.AddKnockback("Explosion", 1.7D); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombToken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombToken.java new file mode 100644 index 000000000..a7eb4efd7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombToken.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.lobbers; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class BombToken +{ + public final long Created; + public final String Thrower; + public Location A = null; + public Location B = null; + public boolean Primed = false; + + public BombToken(Player player) + { + Thrower = player.getName(); + + Created = System.currentTimeMillis(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/events/TNTPreExplodeEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/events/TNTPreExplodeEvent.java new file mode 100644 index 000000000..e79bc6f5c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/events/TNTPreExplodeEvent.java @@ -0,0 +1,52 @@ +package nautilus.game.arcade.game.games.lobbers.events; + +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class TNTPreExplodeEvent extends PlayerEvent implements Cancellable +{ + private static final HandlerList _handlers = new HandlerList(); + + private boolean _cancelled = false; + + private TNTPrimed _tnt; + + public TNTPreExplodeEvent(Player thrower, TNTPrimed tnt) + { + super(thrower); + + _tnt = tnt; + } + + public TNTPrimed getTNT() + { + return _tnt; + } + + @Override + public void setCancelled(boolean flag) + { + _cancelled = flag; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/events/TNTThrowEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/events/TNTThrowEvent.java new file mode 100644 index 000000000..b6bebee11 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/events/TNTThrowEvent.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.lobbers.events; + +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class TNTThrowEvent extends PlayerEvent +{ + private static final HandlerList _handlers = new HandlerList(); + + private TNTPrimed _tnt; + + public TNTThrowEvent(Player thrower, TNTPrimed tnt) + { + super(thrower); + + _tnt = tnt; + } + + public TNTPrimed getTNT() + { + return _tnt; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitArmorer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitArmorer.java new file mode 100644 index 000000000..f36b6e3aa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitArmorer.java @@ -0,0 +1,72 @@ +package nautilus.game.arcade.game.games.lobbers.kits; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDummy; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class KitArmorer extends Kit +{ + + public KitArmorer(ArcadeManager manager) + { + super(manager, "Armorer", KitAvailability.Gem, 2000, new String[] + { + C.cGray + "He uses his expert armor-making", + C.cGray + "skills to block excess damage!" + }, new Perk[] + { + new PerkDummy("Armorer", + new String[] + { + C.cGray + "Recieve " + C.cYellow + "Full Gold Armor" + }), + new PerkCraftman() + }, EntityType.ZOMBIE, + new ItemBuilder(Material.GOLD_HELMET).build()); + } + + @Override + public void ApplyKit(Player player) + { + UtilInv.Clear(player); + + for (Perk perk : GetPerks()) + perk.Apply(player); + + GiveItemsCall(player); + + player.getInventory().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setUnbreakable(true).build()); + + UtilInv.Update(player); + } + + @Override + public void SpawnCustom(LivingEntity entity) + { + entity.getEquipment().setChestplate(new ItemStack(Material.GOLD_CHESTPLATE)); + entity.getEquipment().setLeggings(new ItemStack(Material.GOLD_LEGGINGS)); + entity.getEquipment().setBoots(new ItemStack(Material.GOLD_BOOTS)); + } + + @Override + public void GiveItems(Player player) + { + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitJumper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitJumper.java new file mode 100644 index 000000000..eec22c8b8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitJumper.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.lobbers.kits; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkDummy; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class KitJumper extends Kit +{ + + public KitJumper(ArcadeManager manager) + { + super(manager, "Jumper", KitAvailability.Free, 0, new String[] + { + C.cGray + "Use your jumping abilities to leap away from trouble!" + }, new Perk[] + { + new PerkDoubleJump("Double Jump", 1.2, 1.2, false, 6000, true), + new PerkDummy("Feathered Boots", + new String[] + { + C.cGray + "You take no fall damage." + }), + new PerkCraftman() + }, EntityType.ZOMBIE, new ItemBuilder(Material.IRON_AXE).build()); + } + + @Override + public void GiveItems(Player player) + { + + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!(event.GetDamageeEntity() instanceof Player)) + return; + + if (!HasKit(event.GetDamageePlayer())) + return; + + if (event.GetCause() == DamageCause.FALL) + { + event.SetCancelled("Jumper no fall damage"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitMortar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitMortar.java new file mode 100644 index 000000000..52f24b832 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitMortar.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.lobbers.kits; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkMortar; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkMorterCraftman; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class KitMortar extends Kit +{ + public KitMortar(ArcadeManager manager) + { + super(manager, "Mortar", KitAvailability.Gem, 6000, new String[] + { + "He loves the big guns." + }, new Perk[] + { + new PerkMortar(), + new PerkCraftman(), + new PerkMorterCraftman() + }, EntityType.ZOMBIE, new ItemBuilder(Material.FIREBALL).build()); + } + + @Override + public void GiveItems(Player player) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitPitcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitPitcher.java new file mode 100644 index 000000000..b81bd916d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitPitcher.java @@ -0,0 +1,125 @@ +package nautilus.game.arcade.game.games.lobbers.kits; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDummy; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +public class KitPitcher extends Kit +{ + public KitPitcher(ArcadeManager manager) + { + super(manager, "Pitcher", KitAvailability.Gem, 4000, new String[] + { + C.cGray + "He can easily pitch the perfect", + C.cGray + "shot for any occasion." + }, new Perk[] + { + new PerkDummy("Pitcher", + new String[] + { + C.cYellow + "Left Click" + C.cGray + " lever to " + C.cGreen + "Decrease Velocity. " + C.cGray + "Minimum of 1.", + C.cYellow + "Right Click" + C.cGray + " lever to " + C.cGreen + "Increase Velocity. " + C.cGray + "Maximum of 3.", + }), + new PerkCraftman() + }, EntityType.ZOMBIE, + new ItemBuilder(Material.LEVER).build()); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(1, new ItemBuilder(Material.LEVER).setTitle(F.item("Velocity Selector")).setAmount(2).build()); + } + + @EventHandler + public void setFuse(TNTThrowEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!HasKit(event.getPlayer())) + return; + + ItemStack lever = event.getPlayer().getInventory().getItem(1); + + if (lever == null || lever.getType() == Material.AIR) + { + GiveItems(event.getPlayer()); + } + else + { + if (lever.getAmount() < 1 || lever.getAmount() > 3) + { + GiveItems(event.getPlayer()); + } + + UtilAction.velocity(event.getTNT(), event.getPlayer().getLocation().getDirection(), getVelocity(lever.getAmount()), false, 0.0D, 0.1D, 10.0D, false); + } + } + + @EventHandler + public void changeFuse(PlayerInteractEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!Manager.IsAlive(event.getPlayer())) + return; + + if (!HasKit(event.getPlayer())) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.LEVER, (byte) 0)) + return; + + int amount = event.getPlayer().getInventory().getItem(1).getAmount(); + + //Right + if (UtilEvent.isAction(event, ActionType.R)) + { + if (amount >= 3) + return; + + UtilInv.insert(event.getPlayer(), new ItemBuilder(Material.LEVER).setTitle(F.item("Velocity Selector")).build()); + UtilInv.Update(event.getPlayer()); + } + //Left + else if (UtilEvent.isAction(event, ActionType.L)) + { + if (amount <= 1) + return; + + UtilInv.remove(event.getPlayer(), Material.LEVER, (byte) 0, 1); + UtilInv.Update(event.getPlayer()); + } + } + + private double getVelocity(int amount) + { + if (amount == 1) + return 1.75; + + if (amount == 3) + return 2.25; + + return 2.0; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitWaller.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitWaller.java new file mode 100644 index 000000000..77dd9a950 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/KitWaller.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.lobbers.kits; + +import mineplex.core.achievement.Achievement; +import mineplex.core.common.util.F; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman; +import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkWaller; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class KitWaller extends Kit +{ + public KitWaller(ArcadeManager manager) + { + super(manager, "Waller", KitAvailability.Achievement, 0, new String[] + { + "When the times get tough,", + "build yourself a wall!" + }, new Perk[] + { + new PerkWaller(), + new PerkCraftman() + }, EntityType.ZOMBIE, + new ItemBuilder(Material.SMOOTH_BRICK).setUnbreakable(true).build()); + + this.setAchievementRequirements(new Achievement[] + { + Achievement.BOMB_LOBBERS_WINS, + Achievement.BOMB_LOBBERS_ULTIMATE_KILLER, + Achievement.BOMB_LOBBERS_SNIPER, + Achievement.BOMB_LOBBERS_PROFESSIONAL_LOBBER, + Achievement.BOMB_LOBBERS_EXPLOSION_PROOF, + Achievement.BOMB_LOBBERS_BLAST_PROOF + }); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(1, new ItemBuilder(Material.STONE_SPADE).setAmount(3).setTitle(F.item("Wall Builder")).build()); + } + +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkCraftman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkCraftman.java new file mode 100644 index 000000000..7e89b427f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkCraftman.java @@ -0,0 +1,74 @@ +package nautilus.game.arcade.game.games.lobbers.kits.perks; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class PerkCraftman extends Perk +{ + private Recharge _recharge; + + public PerkCraftman() + { + super("Craftman", new String[] + { + C.cGray + "Recieve 1 TNT every so often. Maximum of 3." + }, false); + + _recharge = Recharge.Instance; + } + + @EventHandler + public void give(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!Manager.GetGame().IsLive()) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!Kit.HasKit(player)) + continue; + //If game time is 56 seconds - 56000 + //8 - 1 + if (!_recharge.use(player, "Bomb Give", getRechargeTime(), false, false)) + continue; + + //Has 3 + if (UtilInv.contains(player, Material.TNT, (byte) 0, 3)) + continue; + + UtilInv.insert(player, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).build()); + } + } + + private long getRechargeTime() + { + long ingame = Manager.GetGame().getGameLiveTime(); + + if (ingame <= 20000) + return 8000; + + if (ingame <= 40000) + return 7000; + + if (ingame <= 60000) + return 6000; + + if (ingame <= 620000) + return 5000; + + return 4000; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkMortar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkMortar.java new file mode 100644 index 000000000..db295ff13 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkMortar.java @@ -0,0 +1,116 @@ +package nautilus.game.arcade.game.games.lobbers.kits.perks; + +import java.util.HashSet; +import java.util.Set; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import nautilus.game.arcade.game.games.lobbers.BombLobbers; +import nautilus.game.arcade.game.games.lobbers.events.TNTPreExplodeEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + +public class PerkMortar extends Perk +{ + private Set _scatter = new HashSet(); + + public PerkMortar() + { + super("Mortar", new String[] + { + C.cYellow + "Right Click" + C.cGray + " Fireball to " + C.cGreen + "Fire Mortar", + "Mortars will explode after " + C.cYellow + "2 Seconds", + "releasing 3 more TNT, each with a 3 second fuse.", + "Your TNT will not scatter if it is grounded." + }); + } + + @EventHandler + public void throwTNT(PlayerInteractEvent event) + { + if (event.getAction() == Action.PHYSICAL) + return; + + if (!Manager.GetGame().IsLive()) + return; + + if (!(Manager.GetGame() instanceof BombLobbers)) + return; + + BombLobbers l = (BombLobbers) Manager.GetGame(); + + Player player = event.getPlayer(); + + if (!Manager.IsAlive(player)) + return; + + if (!UtilInv.IsItem(player.getItemInHand(), Material.FIREBALL, (byte) 0)) + return; + + event.setCancelled(true); + + UtilInv.remove(player, Material.FIREBALL, (byte) 0, 1); + UtilInv.Update(player); + + TNTPrimed tnt = (TNTPrimed) player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); + tnt.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), player.getUniqueId())); + tnt.setFuseTicks(40); + + UtilAction.velocity(tnt, player.getLocation().getDirection(), 2.0D, false, 0.0D, 0.1D, 10.0D, false); + Manager.GetProjectile().AddThrow(tnt, player, l, -1L, true, false, false, .2F); + + player.playSound(player.getLocation(), Sound.CREEPER_HISS, 3.0F, 1.0F); + +// l.addThrower(player, tnt); + } + + @EventHandler + public void onExplode(TNTPreExplodeEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!Kit.HasKit(event.getPlayer())) + return; + + if (event.getTNT().isOnGround() || UtilEnt.isGrounded(event.getTNT())) + return; + + if (!(Manager.GetGame() instanceof BombLobbers)) + return; + + BombLobbers l = (BombLobbers) Manager.GetGame(); + + event.setCancelled(true); + + if (_scatter.contains(event.getTNT())) + { + _scatter.remove(event.getTNT()); + return; + } + + for (int i = -1 ; i < 2 ; i++) + { + TNTPrimed tnt = (TNTPrimed) event.getTNT().getWorld().spawn(event.getTNT().getLocation(), TNTPrimed.class); + tnt.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId())); + tnt.setFuseTicks(60); + + UtilAction.velocity(tnt, event.getTNT().getVelocity().add(new Vector(i / 5, 0, i / 5)).normalize(), 2.0D, false, 0.0D, 0.1D, 10.0D, false); + Manager.GetProjectile().AddThrow(tnt, event.getPlayer(), l, -1L, true, false, false, .2F); + +// l.addThrower(event.getPlayer(), tnt); + _scatter.add(tnt); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkMorterCraftman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkMorterCraftman.java new file mode 100644 index 000000000..9ea4ddd91 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkMorterCraftman.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.games.lobbers.kits.perks; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkMorterCraftman extends Perk +{ + private Recharge _recharge; + + public PerkMorterCraftman() + { + super("Morter Craftman", new String[] + { + "You will recieve 1 mortar every " + C.cYellow + "10 Seconds.", + "Maximum of 1." + }); + + _recharge = Recharge.Instance; + } + + @EventHandler + public void give(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!Manager.GetGame().IsLive()) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!Kit.HasKit(player)) + continue; + + if (!_recharge.use(player, "Mortar Give", 10000, false, false)) + continue; + + //Has 1 + if (UtilInv.contains(player, Material.FIREBALL, (byte) 0, 1)) + continue; + + UtilInv.insert(player, new ItemBuilder(Material.FIREBALL).setTitle(F.item("Mortar")).build()); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkWaller.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkWaller.java new file mode 100644 index 000000000..9f7802238 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/kits/perks/PerkWaller.java @@ -0,0 +1,119 @@ +package nautilus.game.arcade.game.games.lobbers.kits.perks; + +import java.util.HashSet; +import java.util.Set; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +public class PerkWaller extends Perk +{ + private BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; + + private Set _tnt = new HashSet(); + + private Set _wallBlocks = new HashSet(); + + public PerkWaller() + { + super("Waller", new String[] + { + C.cYellow + "Click Block" + C.cGray + " with shovel to " + C.cGreen + "Place Wall" + }); + } + + @EventHandler + public void onThrow(TNTThrowEvent event) + { + _tnt.add(event.getTNT()); + } + + @EventHandler + public void onExplode(EntityExplodeEvent event) + { + if (_tnt.contains(event.getEntity())) + { + _tnt.remove(event.getEntity()); + } + } + + @EventHandler + public void onPlace(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + return; + + if (!Manager.GetGame().IsLive()) + return; + + if (!Manager.IsAlive(event.getPlayer())) + return; + + if (!Kit.HasKit(event.getPlayer())) + return; + + if (!UtilInv.IsItem(event.getItem(), Material.STONE_SPADE, (byte) 0)) + return; + + UtilInv.remove(event.getPlayer(), Material.STONE_SPADE, (byte) 0, 1); + + _wallBlocks.addAll(buildWall(event.getClickedBlock().getLocation(), event.getPlayer().getLocation().getYaw())); + } + + @SuppressWarnings("deprecation") + private Set buildWall(final Location source, final float playerYaw) + { + BlockFace facing = getFace(playerYaw + 180F); + + Set allWallBlocks = new HashSet(); + Set baseWallBlocks = new HashSet(); + + Location centerWallBlock = source.getBlock().getRelative(facing).getRelative(BlockFace.UP).getLocation(); + + float leftYaw = playerYaw - 90; + float rightYaw = playerYaw + 90; + + BlockFace leftSide = getFace(leftYaw); + BlockFace rightSide = getFace(rightYaw); + + baseWallBlocks.add(centerWallBlock.getBlock().getRelative(leftSide).getRelative(leftSide).getLocation()); + baseWallBlocks.add(centerWallBlock.getBlock().getRelative(leftSide).getLocation()); + baseWallBlocks.add(centerWallBlock); + baseWallBlocks.add(centerWallBlock.getBlock().getRelative(rightSide).getLocation()); + baseWallBlocks.add(centerWallBlock.getBlock().getRelative(rightSide).getRelative(rightSide).getLocation()); + + for (Location base : baseWallBlocks) + { + for (int height = 0 ; height < 3 ; height++) + { + allWallBlocks.add(base.clone().add(0, height, 0)); + } + } + for (Location block : allWallBlocks) + { + block.getBlock().setType(Material.SMOOTH_BRICK); + block.getBlock().setData((byte) 0); + + block.getWorld().playEffect(block, Effect.STEP_SOUND, block.getBlock().getType()); + } + return allWallBlocks; + } + + private BlockFace getFace(float yaw) + { + return axis[Math.round(yaw / 90f) & 0x3]; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/Tracker6Kill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/Tracker6Kill.java new file mode 100644 index 000000000..571da0f45 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/Tracker6Kill.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.lobbers.trackers; + +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.lobbers.BombLobbers; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class Tracker6Kill extends StatTracker +{ + public Tracker6Kill(Game game) + { + super(game); + } + + @EventHandler + public void onEndgame(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + if (getGame() instanceof BombLobbers) + { + for (Player player : UtilServer.getPlayers()) + { + if (((BombLobbers) getGame()).getKills(player) >= 6.0) + { + addStat(player, "Killer", 1, true, false); + } + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerBlastProof.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerBlastProof.java new file mode 100644 index 000000000..af23a5b37 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerBlastProof.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.lobbers.trackers; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.lobbers.kits.KitArmorer; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class TrackerBlastProof extends StatTracker +{ + + public TrackerBlastProof(Game game) + { + super(game); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onGameEnd(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + if (getGame().getWinners() == null) + return; + + for (Player winner : getGame().getWinners()) + { + if (getGame().GetKit(winner) instanceof KitArmorer) + { + addStat(winner, "BlastProof", 1, false, false); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerDirectHit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerDirectHit.java new file mode 100644 index 000000000..82bfe2120 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerDirectHit.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.lobbers.trackers; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class TrackerDirectHit extends StatTracker +{ + public TrackerDirectHit(Game game) + { + super(game); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onKillDirectHit(CustomDamageEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.GetDamagerPlayer(true) == null) + return; + + Player damager = event.GetDamagerPlayer(true); + + if (!getGame().IsAlive(damager)) + return; + + if (event.GetReason() == null) + return; + + if (event.GetReason().toLowerCase().contains("direct hit")) + addStat(damager, "Direct Hit", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerNoDamage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerNoDamage.java new file mode 100644 index 000000000..4fd51143e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerNoDamage.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.games.lobbers.trackers; + +import java.util.HashSet; +import java.util.Set; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class TrackerNoDamage extends StatTracker +{ + private Set _damaged = new HashSet(); + + public TrackerNoDamage(Game game) + { + super(game); + } + + @EventHandler + public void onGameEnd(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + if (event.GetGame().getWinners() == null) + return; + + for (Player player : event.GetGame().getWinners()) + { + if (_damaged.contains(player.getName())) + continue; + + addStat(player, "JellySkin", 1, true, false); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onDamage(CustomDamageEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.GetDamageePlayer() == null || !event.GetDamageePlayer().isOnline()) + return; + + if (!_damaged.contains(event.GetDamageePlayer().getName())) + _damaged.add(event.GetDamageePlayer().getName()); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerTNTThrown.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerTNTThrown.java new file mode 100644 index 000000000..e8d7993c3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/trackers/TrackerTNTThrown.java @@ -0,0 +1,25 @@ +package nautilus.game.arcade.game.games.lobbers.trackers; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.event.EventHandler; + +public class TrackerTNTThrown extends StatTracker +{ + + public TrackerTNTThrown(Game game) + { + super(game); + } + + @EventHandler + public void onThrow(TNTThrowEvent event) + { + if (!getGame().IsLive()) + return; + + addStat(event.getPlayer(), "Thrown", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index e01db1c83..5359d0fa7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -4,6 +4,33 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; +import nautilus.game.arcade.game.games.milkcow.kits.KitCow; +import nautilus.game.arcade.game.games.milkcow.kits.KitFarmerJump; +import nautilus.game.arcade.game.games.milkcow.kits.KitSturdyFarmhand; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.NullKit; +import net.minecraft.server.v1_7_R4.EntityCreature; +import net.minecraft.server.v1_7_R4.Navigation; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -25,31 +52,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.visibility.VisibilityManager; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.milkcow.kits.*; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import net.minecraft.server.v1_7_R4.EntityCreature; -import net.minecraft.server.v1_7_R4.Navigation; - public class MilkCow extends SoloGame { private GameTeam _farmers; @@ -73,6 +75,7 @@ public class MilkCow extends SoloGame new Kit[] { new KitFarmerJump(manager), + new KitSturdyFarmhand(manager), new NullKit(manager), new KitCow(manager), }, @@ -112,7 +115,7 @@ public class MilkCow extends SoloGame { if (team.GetColor() == ChatColor.RED) { - if (kit.GetName().contains("Farmer")) + if (kit.GetName().contains("Farm")) team.GetRestrictedKits().add(kit); } else @@ -288,13 +291,17 @@ public class MilkCow extends SoloGame SetPlayerTeam(player, _cows, true); //Kit - Kit newKit = GetKits()[2]; + Kit newKit = GetKits()[3]; SetKit(player, newKit, false); newKit.ApplyKit(player); //Refresh VisibilityManager.Instance.refreshPlayerToAll(player); + + //Turn off flight + player.setAllowFlight(false); + player.setFlying(false); if (forced) { @@ -345,7 +352,9 @@ public class MilkCow extends SoloGame @EventHandler public void LoseMilk(PlayerDeathEvent event) { - SetScore(event.getEntity(), Math.max(0, GetScore(event.getEntity()) - 5)); + MilkRemoveEvent e = new MilkRemoveEvent(event.getEntity(), 5, RemoveType.DEATH); + Bukkit.getPluginManager().callEvent(e); + SetScore(event.getEntity(), Math.max(0, GetScore(event.getEntity()) - e.GetMilk())); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java new file mode 100644 index 000000000..5ac777588 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.milkcow; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class MilkRemoveEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private Player _player; + private int _milk; + private RemoveType _cause; + + public MilkRemoveEvent(Player player, int milk, RemoveType cause) + { + _player = player; + _milk = milk; + _cause = cause; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Player GetPlayer() + { + return _player; + } + + public int GetMilk() + { + return _milk; + } + + public RemoveType GetCause() + { + return _cause; + } + + public void SetMilk(int milk) + { + _milk = milk; + } + + public static enum RemoveType + { + FLING, DEATH; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java index d196e224f..68be2fd6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java @@ -33,7 +33,7 @@ public class KitCow extends AbbreviatedKit new PerkKnockbackMultiplier(4), new PerkCharge(), new PerkCowBomb(), - new PerkSeismicCow(), + new PerkSeismicCow("Body Slam"), }, EntityType.COW, null); @@ -67,7 +67,7 @@ public class KitCow extends AbbreviatedKit new String[] { ChatColor.RESET + "Charge with great power, flinging", - ChatColor.RESET + "filthy farmers out of your way!", + ChatColor.RESET + "filthy farmers out of your way, making them drop the milk in their buckets!", })); //Disguise diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java new file mode 100644 index 000000000..feeb802d1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java @@ -0,0 +1,51 @@ +package nautilus.game.arcade.game.games.milkcow.kits; + +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkIronSkin; +import nautilus.game.arcade.kit.perks.PerkNoSpillMilk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +public class KitSturdyFarmhand extends Kit +{ + public KitSturdyFarmhand(ArcadeManager manager) + { + super(manager, "Sturdy Farmhand", KitAvailability.Gem, 2000, + + new String[] + { + "Been working on the ranch so long, even a charging bull can't faze him!" + }, + + new Perk[] + { + new PerkNoSpillMilk(manager), + new PerkIronSkin(2), + }, + + EntityType.ZOMBIE, + new ItemStack(Material.IRON_SPADE)); + + } + + @EventHandler + public void FireItemResist(UpdateEvent event) + { + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BUCKET)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index a2fd82241..d1ae759c7 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 @@ -109,6 +109,8 @@ import nautilus.game.arcade.stats.KillFastStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.KillsWithConditionStatTracker; import nautilus.game.arcade.stats.MineStrikeLastAliveKillStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; import net.minecraft.server.v1_7_R4.EntityArrow; public class MineStrike extends TeamGame @@ -252,6 +254,8 @@ public class MineStrike extends TeamGame this.StrictAntiHack = true; + AnnounceStay = false; + this.HungerSet = 20; this.ItemDrop = true; @@ -292,7 +296,10 @@ public class MineStrike extends TeamGame new KillReasonStatTracker(this, "Backstab", "Assassination", false), new MineStrikeLastAliveKillStatTracker(this), new KillFastStatTracker(this, 4, 5, "KillingSpree"), - new KillsWithConditionStatTracker(this, "Blindfolded", ConditionType.BLINDNESS, "Flash Bang", 2) + new KillsWithConditionStatTracker(this, "Blindfolded", ConditionType.BLINDNESS, "Flash Bang", 2), + + new TeamDeathsStatTracker(this), + new TeamKillsStatTracker(this) ); } @@ -1278,7 +1285,7 @@ public class MineStrike extends TeamGame { Bukkit.getPluginManager().callEvent(new PlayerHeadshotEvent(bullet.Shooter, event.GetDamageePlayer())); - event.AddMod(bullet.Shooter.getName(), "Headshot", damage*2, true); + event.AddMod(bullet.Shooter.getName(), "Headshot", damage, true); //Wearing Helmet if (Armor.isArmor(event.GetDamageePlayer().getInventory().getHelmet()) || @@ -1304,7 +1311,7 @@ public class MineStrike extends TeamGame //Mini-Stun else { - event.GetDamageePlayer().setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(event.GetDamageeEntity()); } event.SetKnockback(false); @@ -1867,7 +1874,11 @@ public class MineStrike extends TeamGame ChatColor color = ChatColor.GRAY; if (winner != null) { - winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " has won the round!"; + if(winner.GetName().contains("Bombers")) { + winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " have won the round!"; + } else { + winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " has won the round!"; + } addScore(winner); drawScoreboard(); color = winner.GetColor(); @@ -1923,7 +1934,11 @@ public class MineStrike extends TeamGame Announce(color + "===================================", false); for (Player player : UtilServer.getPlayers()) + { player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + + Recharge.Instance.Reset(player, "reload"); + } UtilTextMiddle.display(null, winnerLine, 20, 120, 20); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java index 0a70ee22a..dfd1863e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -202,7 +202,7 @@ public class Gun extends StrikeItem else if (player.isSneaking() && _gunStats.getGunType() != GunType.SNIPER) cone = cone * 0.8; - System.out.println("Vision: " + player.hasPotionEffect(PotionEffectType.NIGHT_VISION)); + //System.out.println("Vision: " + player.hasPotionEffect(PotionEffectType.NIGHT_VISION)); //Sniper Zoomed if (!player.hasPotionEffect(PotionEffectType.NIGHT_VISION) && _gunStats.getScope() && UtilGear.isMat(player.getInventory().getHelmet(), Material.PUMPKIN)) @@ -223,7 +223,7 @@ public class Gun extends StrikeItem } } - System.out.println("Cone: " + cone); + //System.out.println("Cone: " + cone); return cone; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index 0b9f722fa..9fd11c832 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -34,6 +34,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -306,7 +307,7 @@ public class Paintball extends TeamGame ((CraftPlayer)player).getHandle().spectating = true; ((CraftPlayer)player).getHandle().k = false; - player.setVelocity(new Vector(0,1.2,0)); + UtilAction.velocity(player, new Vector(0,1.2,0)); _doubles.put(player, new PlayerCopy(this, player, GetTeam(player).GetColor())); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index bbd123b34..731d049e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -5,18 +5,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -32,12 +20,28 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.quiver.kits.*; +import nautilus.game.arcade.game.games.quiver.kits.KitBrawler; +import nautilus.game.arcade.game.games.quiver.kits.KitEnchanter; +import nautilus.game.arcade.game.games.quiver.kits.KitLeaper; +import nautilus.game.arcade.game.games.quiver.kits.KitNinja; +import nautilus.game.arcade.game.games.quiver.kits.KitSlamShot; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.SharpShooterStatTracker; import nautilus.game.arcade.stats.WinWithoutBowStatTracker; import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; + public class Quiver extends SoloGame { private ArrayList _ranks = new ArrayList(); @@ -56,7 +60,8 @@ public class Quiver extends SoloGame new KitLeaper(manager), new KitBrawler(manager), new KitEnchanter(manager), - new KitSlamShot(manager) + new KitSlamShot(manager), + new KitNinja(manager) }, new String[] @@ -72,9 +77,12 @@ public class Quiver extends SoloGame this.DamageSelf = false; this.DamageTeamSelf = true; this.PrepareFreeze = false; - this.SpawnDistanceRequirement = 16; this.BlockBreakAllow.add(102); this.BlockBreakAllow.add(20); + this.BlockBreakAllow.add(Material.STAINED_GLASS_PANE.getId()); + this.BlockBreakAllow.add(Material.STAINED_GLASS.getId()); + + this.DeathSpectateSecs = 1; _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Kills", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java index c4aecbae2..2d871d801 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java @@ -59,7 +59,6 @@ public class QuiverTeams extends TeamGame this.DamageSelf = false; this.DamageTeamSelf = false; this.PrepareFreeze = false; - this.SpawnDistanceRequirement = 24; this.BlockBreakAllow.add(102); this.BlockBreakAllow.add(20); this.BlockBreakAllow.add(18); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNinja.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNinja.java new file mode 100644 index 000000000..106360d21 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNinja.java @@ -0,0 +1,64 @@ +package nautilus.game.arcade.game.games.quiver.kits; + +import mineplex.core.achievement.Achievement; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkVanishing; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class KitNinja extends Kit +{ + public KitNinja(ArcadeManager manager) + { + super(manager, "Ninja", KitAvailability.Achievement, 0, new String[] + { + "You're a sneaky one, you!" + }, new Perk[] + { + new PerkVanishing() + }, EntityType.ZOMBIE, new ItemBuilder(Material.GOLD_SWORD).build()); + + this.setAchievementRequirements(new Achievement[] + { + Achievement.OITQ_SHARPSHOOTER, + Achievement.OITQ_WHATS_A_BOW, + Achievement.OITQ_WINS, + }); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(new ItemBuilder(Material.GOLD_SWORD).setUnbreakable(true).build()); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); + + if (Manager.GetGame().GetState() == GameState.Live) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow"))); + + final Player fPlayer = player; + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + UtilInv.Update(fPlayer); + } + }, 10); + } + } + + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java index 6acd3aea3..b248eb2d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java @@ -21,9 +21,8 @@ public class KitSlamShot extends Kit { public KitSlamShot(ArcadeManager manager) { - super(manager, "Slam Shooter", KitAvailability.Achievement, - - new String[] + super(manager, "Slam Shooter", KitAvailability.Gem, + 5000, new String[] { "Gets 2 arrows for killing slammed players!" }, @@ -33,21 +32,13 @@ public class KitSlamShot extends Kit new PerkSeismicSlamOITQ() }, EntityType.ZOMBIE, - new ItemStack(Material.IRON_SPADE)); - - this.setAchievementRequirements(new Achievement[] - { - Achievement.OITQ_PERFECTIONIST, - Achievement.OITQ_SHARPSHOOTER, - Achievement.OITQ_WHATS_A_BOW, - Achievement.OITQ_WINS, - }); + new ItemStack(Material.DIAMOND_SPADE)); } @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SPADE)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SPADE)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); if (Manager.GetGame().GetState() == GameState.Live) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index c64af6eaa..91a1f9c19 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -83,11 +83,13 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -95,7 +97,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @SuppressWarnings("deprecation") -public class Skywars extends SoloGame +public abstract class Skywars extends Game { //./parse 19 30 56 @@ -131,23 +133,22 @@ public class Skywars extends SoloGame private ChestLoot _middleBlock = new ChestLoot(); @SuppressWarnings("unchecked") - public Skywars(ArcadeManager manager) + public Skywars(ArcadeManager manager, GameType type, String[] description) { - super(manager, GameType.Skywars, new Kit[] + super(manager, type, new Kit[] { new KitChicken(manager), new KitMiner(manager), new KitMadScientist(manager), new KitDestructor(manager), - }, new String[] - { - "Free for all battle in the sky!", - "Craft or loot gear for combat", - "Last player alive wins!" - }); + }, description); PrepareFreeze = true; + + AnnounceStay = false; + + HideTeamSheep = true; CompassEnabled = true; @@ -162,8 +163,6 @@ public class Skywars extends SoloGame WorldTimeSet = 0; WorldBoundaryKill = false; - SpawnDistanceRequirement = 48; - DamageSelf = true; DamageTeamSelf = true; DamageEvP = true; @@ -965,6 +964,9 @@ public class Skywars extends SoloGame if (event.GetDamage() >= 1) return; + if(GetTeam(event.GetDamagerPlayer(true)) == GetTeam(event.GetDamageePlayer())) + return; + if (event.GetProjectile() instanceof Egg || event.GetProjectile() instanceof Snowball) { event.SetCancelled("Egg/Snowball"); @@ -982,7 +984,26 @@ public class Skywars extends SoloGame if (vel.getY() < 0.1) vel.setY(0.1); - event.GetDamageeEntity().setVelocity(vel); + UtilAction.velocity(event.GetDamageeEntity(), vel); + } + } + + @EventHandler + public void projectile(EntityDamageByEntityEvent event) + { + if(event.getDamager() instanceof Snowball || event.getDamager() instanceof Egg || event.getDamager() instanceof EnderPearl) + { + Projectile prj = (Projectile) event.getDamager(); + if(prj.getShooter() instanceof Player) + { + if(event.getEntity() instanceof Player) + { + if(GetTeam((Player) prj.getShooter()) == GetTeam((Player) event.getEntity())) + { + event.setCancelled(true); + } + } + } } } @@ -1196,63 +1217,6 @@ public class Skywars extends SoloGame _oreHider.BlockBreak(event); } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (GetTeamList().isEmpty()) - return; - - Scoreboard.Reset(); - - GameTeam team = GetTeamList().get(0); - - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); - if (team.GetPlayers(true).size() > 4) - { - Scoreboard.Write("" + team.GetPlayers(true).size()); - } - else - { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.Write(C.cWhite + player.getName()); - } - } - - if (IsLive()) - { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); - - Scoreboard.WriteBlank(); - Scoreboard.Write((_tntGen.active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); - Scoreboard.Write(_tntGen.getScoreboardInfo()); - - Scoreboard.WriteBlank(); - - if (UtilTime.elapsed(GetStateTime(), _crumbleTime)) - { - Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); - Scoreboard.Write("Active"); - } - else - { - Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); - Scoreboard.Write(UtilTime.convertString(_crumbleTime - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); - } - } - - - - Scoreboard.Draw(); - } - @EventHandler public void tntDamageAttribute(ExplosionPrimeEvent event) { @@ -1370,4 +1334,15 @@ public class Skywars extends SoloGame else return 12; } + + public TNTGenerator getTnTGen() + { + return this._tntGen; + } + + public long getCrumbleTime() + { + return this._crumbleTime; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java new file mode 100644 index 000000000..d5262599d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java @@ -0,0 +1,178 @@ +package nautilus.game.arcade.game.games.skywars; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.Game.GameState; + +public class SoloSkywars extends Skywars +{ + + private GameTeam _players; + + public SoloSkywars(ArcadeManager manager) + { + super(manager, GameType.Skywars, + new String[] + { + "Free for all battle in the sky!", + "Craft or loot gear for combat", + "Last player alive wins!" + }); + + this.DamageTeamSelf = true; + + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + _players.setDisplayName(C.cYellow + C.Bold + "Players"); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + GameTeam team = GetTeamList().get(0); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Players"); + if (team.GetPlayers(true).size() > 4) + { + Scoreboard.Write("" + team.GetPlayers(true).size()); + } + else + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(C.cWhite + player.getName()); + } + } + + if (IsLive()) + { + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + + Scoreboard.WriteBlank(); + + if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) + { + Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.Write("Active"); + } + else + { + Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + } + } + + + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 1) + { + ArrayList places = GetTeamList().get(0).GetPlacements(true); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return Arrays.asList(); + else + return Arrays.asList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + List losers = GetTeamList().get(0).GetPlayers(false); + + losers.removeAll(winners); + + return losers; + } + + @Override + public String GetMode() + { + return "Solo Mode"; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java new file mode 100644 index 000000000..7eb916b53 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -0,0 +1,478 @@ +package nautilus.game.arcade.game.games.skywars; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.Game.GameState; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class TeamSkywars extends Skywars +{ + + private NautHashMap _teamReqs = new NautHashMap(); + + public TeamSkywars(ArcadeManager manager) + { + super(manager, GameType.SkywarsTeams, + new String[] + { + "Free for all battle in the sky!", + "Craft or loot gear for combat", + "Last team alive wins!" + }); + + this.FillTeamsInOrderToCount = 2; + + this.SpawnNearAllies = true; + + this.DamageTeamSelf = false; + + this.DontAllowOverfill = true; + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + ArrayList initialSpawns = this.GetTeamList().get(0).GetSpawns(); + this.GetTeamList().clear(); + + ArrayList spawns = new ArrayList(); + + TeamColors color = TeamColors.DARK_AQUA; + + //Create 1 Team for each Spawn + int i = 0; + for(Location location : initialSpawns) + { + i++; + + spawns.add(location); + + addRelativeSpawns(spawns, location); + + //Got Spawns + color = getNextColor(color); + int e = 0; + for(GameTeam teams : GetTeamList()) + { + if(teams.GetColor() == color.getColor()) + { + e++; + if(getColorName(color.getColor()).length <= e) + { + e = 0; + } + } + } + GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true); + team.SetVisible(true); + GetTeamList().add(team); + } + } + + private void addRelativeSpawns(ArrayList spawns, Location location) + { + //Gather Extra Spawns + for(int x = -1; x <= 1; x++) + { + for(int z = -1; z <= 1; z++) + { + if(x != 0 && z != 0) + { + Location newSpawn = location.clone().add(x, 0, z); + + //Search Downward for Solid + while (UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)) && newSpawn.getY() > location.getY()-5) + { + newSpawn.subtract(0, 1, 0); + } + + //Move Up out of Solid + while (!UtilBlock.airFoliage(newSpawn.getBlock()) && newSpawn.getY() < location.getY()+5) + { + newSpawn.add(0, 1, 0); + } + + //On Solid, with 2 Air Above + if (UtilBlock.airFoliage(newSpawn.getBlock()) && + UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.UP)) && + !UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN))) + { + spawns.add(newSpawn); + } + } + } + } + } + + private enum TeamColors + { + + YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}), + GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}), + AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}), + RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}), + GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}), + LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}), + DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}), + DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}), + WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}), + BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}), + DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}), + DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}), + DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"}); + + private ChatColor color; + private String[] names; + + private TeamColors(ChatColor color, String[] names) + { + this.color = color; + this.names = names; + } + + public ChatColor getColor() + { + return color; + } + + public String[] getNames() + { + return names; + } + + } + + private String[] getColorName(ChatColor color) + { + for(TeamColors colors : TeamColors.values()) + { + if(colors.getColor() == color) + { + return colors.getNames(); + } + } + return null; + } + + private TeamColors getNextColor(TeamColors color) + { + for(TeamColors colors : TeamColors.values()) { + if(colors.ordinal() == color.ordinal() + 1) + { + return colors; + } + } + return TeamColors.YELLOW; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + + ArrayList alive = new ArrayList(); + for (GameTeam team : GetTeamList()) + { + if (team.IsTeamAlive()) + alive.add(team); + } + + if (GetPlayers(true).size() <= 4) + { + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(team.GetColor() + player.getName()); + } + } + } + else if (alive.size() <= 4) + { + for (GameTeam team : alive) + { + Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + } + } + else + { + Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + } + + if (IsLive()) + { + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + + Scoreboard.WriteBlank(); + + if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) + { + Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.Write("Active"); + } + else + { + Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + } + } + + + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (WinnerTeam == null) + return null; + + return WinnerTeam.GetPlayers(false); + } + + @Override + public List getLosers() + { + if (WinnerTeam == null) + return null; + + List players = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team != WinnerTeam) + players.addAll(team.GetPlayers(false)); + } + + return players; + } + + @Override + public boolean CanJoinTeam(GameTeam team) + { + return team.GetSize() < 2; + } + + @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; + + //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; + } + + @Override + public String GetMode() + { + return "Team Mode"; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java new file mode 100644 index 000000000..b9ba7a26b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -0,0 +1,162 @@ +package nautilus.game.arcade.game.games.smash; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.Game.GameState; + +public class SoloSuperSmash extends SuperSmash +{ + + private GameTeam _players; + + public SoloSuperSmash(ArcadeManager manager) + { + super(manager, GameType.Smash, new String[] + { + "Each player has 3 respawns", + "Attack to restore hunger!", + "Last player alive wins!" + }); + + this.DamageTeamSelf = true; + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + _players.setDisplayName(C.cYellow + C.Bold + "Players"); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //Wipe Last + Scoreboard.Reset(); + + if (GetPlayers(true).size() > 14) + { + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGreen + "Players Alive"); + Scoreboard.Write(GetPlayers(true).size() + " "); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cRed + "Players Dead"); + Scoreboard.Write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); + } + else + { + Scoreboard.WriteBlank(); + + //Write New + for (Player player : GetPlayers(true)) + { + int lives = GetLives(player); + + String out; + if (lives >= 4) out = C.cGreen + player.getName(); + else if (lives == 3) out = C.cYellow + player.getName(); + else if (lives == 2) out = C.cGold + player.getName(); + else if (lives == 1) out = C.cRed + player.getName(); + else if (lives == 0) out = C.cRed + player.getName(); + else + continue; + + Scoreboard.WriteOrdered("Lives", out, lives, true); + } + } + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 1) + { + ArrayList places = GetTeamList().get(0).GetPlacements(true); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return Arrays.asList(); + else + return Arrays.asList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + List losers = GetTeamList().get(0).GetPlayers(false); + + losers.removeAll(winners); + + return losers; + } + + @Override + public String GetMode() + { + return "Solo Mode"; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index 511f1095c..d4691b620 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -1,11 +1,59 @@ package nautilus.game.arcade.game.games.smash; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import mineplex.core.common.block.BlockData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.smash.kits.KitBlaze; +import nautilus.game.arcade.game.games.smash.kits.KitChicken; +import nautilus.game.arcade.game.games.smash.kits.KitCreeper; +import nautilus.game.arcade.game.games.smash.kits.KitEnderman; +import nautilus.game.arcade.game.games.smash.kits.KitGolem; +import nautilus.game.arcade.game.games.smash.kits.KitMagmaCube; +import nautilus.game.arcade.game.games.smash.kits.KitPig; +import nautilus.game.arcade.game.games.smash.kits.KitSheep; +import nautilus.game.arcade.game.games.smash.kits.KitSkeletalHorse; +import nautilus.game.arcade.game.games.smash.kits.KitSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitSkySquid; +import nautilus.game.arcade.game.games.smash.kits.KitSlime; +import nautilus.game.arcade.game.games.smash.kits.KitSnowman; +import nautilus.game.arcade.game.games.smash.kits.KitSpider; +import nautilus.game.arcade.game.games.smash.kits.KitWitch; +import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitWolf; +import nautilus.game.arcade.game.games.smash.kits.KitZombie; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.SmashKit; +import nautilus.game.arcade.stats.FreeKitWinStatTracker; +import nautilus.game.arcade.stats.KillFastStatTracker; +import nautilus.game.arcade.stats.OneVThreeStatTracker; +import nautilus.game.arcade.stats.RecoveryMasterStatTracker; +import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.FireworkEffect.Type; import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -16,43 +64,14 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.block.BlockData; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeFormat; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.smash.kits.*; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.stats.KillFastStatTracker; -import nautilus.game.arcade.stats.FreeKitWinStatTracker; -import nautilus.game.arcade.stats.OneVThreeStatTracker; -import nautilus.game.arcade.stats.RecoveryMasterStatTracker; -import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; - -public class SuperSmash extends SoloGame +public abstract class SuperSmash extends Game { private HashMap _lives = new HashMap(); @@ -63,9 +82,9 @@ public class SuperSmash extends SoloGame private HashSet _restoreBlock = new HashSet(); - public SuperSmash(ArcadeManager manager) + public SuperSmash(ArcadeManager manager, GameType type, String[] description) { - super(manager, GameType.Smash, + super(manager, type, new Kit[] { @@ -93,31 +112,23 @@ public class SuperSmash extends SoloGame new KitSheep(manager) - }, - - new String[] - { - "Each player has 3 respawns", - "Attack to restore hunger!", - "Last player alive wins!" - - }); + },description); this.DeathOut = false; - this.DamageTeamSelf = true; - this.CompassEnabled = true; this.DeathSpectateSecs = 4; - this.SpawnDistanceRequirement = 32; - this.WorldWaterDamage = 1000; - + + this.HideTeamSheep = true; + + this.ReplaceTeamsWithKits = true; + // Add stat table here // Example - //Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses"); + // Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses"); registerStatTrackers( new WinWithoutDyingStatTracker(this, "MLGPro"), @@ -149,7 +160,7 @@ public class SuperSmash extends SoloGame } } - private int GetLives(Player player) + public int GetLives(Player player) { if (!_lives.containsKey(player)) return 0; @@ -160,14 +171,14 @@ public class SuperSmash extends SoloGame return _lives.get(player); } - private boolean LoseLife(Player player) + public boolean LoseLife(Player player) { int lives = GetLives(player) - 1; if (lives > 0) { UtilPlayer.message(player, C.cRed + C.Bold + "You have died!"); - UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " lives left!"); + UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " " + (lives == 1 ? "life" : "lives") + " left!"); player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f, 0.5f); _lives.put(player, lives); @@ -183,51 +194,6 @@ public class SuperSmash extends SoloGame } } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - //Wipe Last - Scoreboard.Reset(); - - if (GetPlayers(true).size() > 14) - { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write(GetPlayers(true).size() + " "); - - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); - } - else - { - Scoreboard.WriteBlank(); - - //Write New - for (Player player : GetPlayers(true)) - { - int lives = GetLives(player); - - String out; - if (lives >= 4) out = C.cGreen + player.getName(); - else if (lives == 3) out = C.cYellow + player.getName(); - else if (lives == 2) out = C.cGold + player.getName(); - else if (lives == 1) out = C.cRed + player.getName(); - else if (lives == 0) out = C.cRed + player.getName(); - else - continue; - - Scoreboard.WriteOrdered("Lives", out, lives, true); - } - } - - Scoreboard.Draw(); - } - @EventHandler public void powerupSpawn(UpdateEvent event) { @@ -525,9 +491,4 @@ public class SuperSmash extends SoloGame int amount = Math.max(1, (int)(event.GetDamage()/2)); UtilPlayer.hunger(damager, amount); } - - public String GetMode() - { - return "Deathmatch"; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTeam.java deleted file mode 100644 index 4f4507bd3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTeam.java +++ /dev/null @@ -1,377 +0,0 @@ -package nautilus.game.arcade.game.games.smash; - -import java.util.HashMap; - -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEvent; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeFormat; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.smash.kits.*; -import nautilus.game.arcade.kit.Kit; - -public class SuperSmashTeam extends TeamGame -{ - private HashMap _lives = new HashMap(); - - public SuperSmashTeam(ArcadeManager manager) - { - super(manager, GameType.SmashTeams, - - new Kit[] - { - - new KitSkeleton(manager), - new KitGolem(manager), - new KitSpider(manager), - new KitSlime(manager), - - new KitCreeper(manager), - new KitEnderman(manager), - new KitSnowman(manager), - new KitWolf(manager), - - - new KitBlaze(manager), - new KitWitch(manager), - new KitChicken(manager), - new KitSkeletalHorse(manager), - new KitPig(manager), - new KitSkySquid(manager), - new KitWitherSkeleton(manager), - new KitMagmaCube(manager), - - new KitSheep(manager) - - }, - - new String[] - { - "Each player has 3 respawns", - "Attack to restore hunger!", - "Last player alive wins!" - - }); - - this.DeathOut = false; - - this.DamageTeamSelf = false; - - this.CompassEnabled = true; - - this.SpawnDistanceRequirement = 16; - - this.TeamArmorHotbar = true; - } - - @EventHandler(priority = EventPriority.HIGH) - public void GameStateChange(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - for (Player player : GetPlayers(true)) - _lives.put(player, 4); - } - - @EventHandler - public void PlayerOut(PlayerDeathEvent event) - { - if (!LoseLife(event.getEntity())) - { - this.SetPlayerState(event.getEntity(), PlayerState.OUT); - } - } - - private int GetLives(Player player) - { - if (!_lives.containsKey(player)) - return 0; - - if (!IsAlive(player)) - return 0; - - return _lives.get(player); - } - - private boolean LoseLife(Player player) - { - int lives = GetLives(player) - 1; - - if (lives > 0) - { - UtilPlayer.message(player, C.cRed + C.Bold + "You have died!"); - UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " lives left!"); - player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f, 0.5f); - - _lives.put(player, lives); - - return true; - } - else - { - UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game!"); - player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); - - return false; - } - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - //Wipe Last - Scoreboard.Reset(); - - if (GetPlayers(true).size() > 14) - { - for (GameTeam team : this.GetTeamList()) - { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetFormattedName()); - - int lives = 0; - for (Player player : team.GetPlayers(true)) - lives += GetLives(player); - - Scoreboard.Write(team.GetColor() + "" + lives + " Lives"); - } - } - else - { - Scoreboard.WriteBlank(); - - //Write New - for (Player player : GetPlayers(true)) - { - int lives = GetLives(player); - - if (lives <= 0) - continue; - - Scoreboard.WriteOrdered("Lives", GetTeam(player).GetColor() + player.getName(), lives, true); - } - } - - Scoreboard.Draw(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void FallDamage(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() == DamageCause.FALL) - event.SetCancelled("No Fall Damage"); - } - - @EventHandler(priority = EventPriority.HIGH) - public void Knockback(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetDamageePlayer() != null) - event.AddKnockback("Smash Knockback", 1 + 0.1 * (20 - event.GetDamageePlayer().getHealth())); - } - - @EventHandler(priority = EventPriority.HIGH) - public void ArenaWalls(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() == DamageCause.VOID || event.GetCause() == DamageCause.LAVA) - { - event.GetDamageeEntity().eject(); - event.GetDamageeEntity().leaveVehicle(); - - event.AddMod("Smash", "Super Smash Mobs", 5000, false); - } - } - - @EventHandler - public void HealthChange(EntityRegainHealthEvent event) - { - if (event.getRegainReason() == RegainReason.SATIATED) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void EntityDeath(EntityDeathEvent event) - { - event.getDrops().clear(); - } - - @Override - public void SetKit(Player player, Kit kit, boolean announce) - { - GameTeam team = GetTeam(player); - if (team != null) - { - if (!team.KitAllowed(kit)) - { - player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f); - UtilPlayer.message(player, F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") + ".")); - return; - } - } - - _playerKit.put(player, kit); - - if (announce) - { - player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f); - UtilPlayer.message(player, F.main("Kit", "You equipped " + F.elem(kit.GetFormattedName() + " Kit") + ".")); - kit.ApplyKit(player); - UtilInv.Update(player); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void AbilityDescription(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - Player player = event.getPlayer(); - - if (player.getItemInHand() == null) - return; - - if (player.getItemInHand().getItemMeta() == null) - return; - - if (player.getItemInHand().getItemMeta().getDisplayName() == null) - return; - - if (player.getItemInHand().getItemMeta().getLore() == null) - return; - - if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit) - return; - - for (int i=player.getItemInHand().getItemMeta().getLore().size() ; i<=7 ; i++) - UtilPlayer.message(player, " "); - - UtilPlayer.message(player, ArcadeFormat.Line); - - UtilPlayer.message(player, "§aAbility - §f§l" + player.getItemInHand().getItemMeta().getDisplayName()); - - //Perk Descs - for (String line : player.getItemInHand().getItemMeta().getLore()) - { - UtilPlayer.message(player, line); - } - - UtilPlayer.message(player, ArcadeFormat.Line); - - player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f); - - event.setCancelled(true); - } - - @Override - public double GetKillsGems(Player killer, Player killed, boolean assist) - { - return 4; - } - - @EventHandler - public void BlockFade(BlockFadeEvent event) - { - event.setCancelled(true); - } - - private int hungerTick = 0; - @EventHandler - public void Hunger(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - hungerTick = (hungerTick + 1)%6; - - for (Player player : GetPlayers(true)) - { - player.setSaturation(3f); - player.setExhaustion(0f); - - if (player.getFoodLevel() <= 0) - { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.STARVATION, 1, false, true, false, - "Starvation", GetName()); - - UtilPlayer.message(player, F.main("Game", "Attack other players to restore hunger!")); - } - - if (hungerTick == 0) - UtilPlayer.hunger(player, -1); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void HungerRestore(CustomDamageEvent event) - { - - if (event.IsCancelled()) - return; - - if (event.GetDamagerPlayer(true) == null) - return; - - if (event.GetDamageePlayer() == null) - return; - - if (GetTeam(event.GetDamageePlayer()) == null) - return; - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) - return; - - if (GetTeam(damager) == null) - return; - - if (GetTeam(damager).equals(GetTeam(event.GetDamageePlayer()))) - return; - - if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false)) - return; - - int amount = Math.max(1, (int)(event.GetDamage()/2)); - UtilPlayer.hunger(damager, amount); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java new file mode 100644 index 000000000..2ffd3f82d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -0,0 +1,426 @@ +package nautilus.game.arcade.game.games.smash; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class TeamSuperSmash extends SuperSmash +{ + + public boolean ForceTeamSize = true; + public int PlayersPerTeam = 2; + public int TeamCount = 0; + + private NautHashMap _teamReqs = new NautHashMap(); + + public TeamSuperSmash(ArcadeManager manager) + { + super(manager, GameType.SmashTeams, + new String[] + { + "Each player has 3 respawns", + "Attack to restore hunger!", + "Last team alive wins!" + }); + + this.PlayersPerTeam = 2; + this.FillTeamsInOrderToCount = 2; + + this.SpawnNearAllies = true; + this.DamageTeamSelf = false; + + this.TeamArmorHotbar = true; + + this.DontAllowOverfill = true; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + ArrayList alive = new ArrayList(); + for (GameTeam team : GetTeamList()) + { + if (team.IsTeamAlive()) + alive.add(team); + } + + //Wipe Last + Scoreboard.Reset(); + Scoreboard.WriteBlank(); + + if (GetPlayers(true).size() < 16) + { + + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + int lives = GetLives(player); + + Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + player.getName()); + } + } + } + else if (alive.size() < 16) + { + for (GameTeam team : alive) + { + int lives = 0; + + for (Player player : team.GetPlayers(true)) + { + lives += GetLives(player); + } + + Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + team.GetName()); + } + } + else + { + Scoreboard.Write(C.cYellow + C.Bold + "Teams Alive"); + Scoreboard.Write(C.cWhite + alive.size()); + } + + Scoreboard.Draw(); + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + ArrayList spawns = this.GetTeamList().get(0).GetSpawns(); + this.GetTeamList().clear(); + + TeamColors color = TeamColors.DARK_AQUA; + + if(!this.ForceTeamSize) + { + for(int i = 1; i <= this.TeamCount; i++) + { + color = getNextColor(color); + GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns); + team.SetVisible(true); + GetTeamList().add(team); + } + } + else + { + for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++) + { + color = getNextColor(color); + int e = 0; + for(GameTeam teams : GetTeamList()) + { + if(teams.GetColor() == color.getColor()) + { + e++; + if(getColorName(color.getColor()).length <= e) + { + e = 0; + } + } + } + GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true); + team.SetVisible(true); + GetTeamList().add(team); + } + } + } + + private enum TeamColors + { + + YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}), + GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}), + AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}), + RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}), + GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}), + LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}), + DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}), + DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}), + WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}), + BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}), + DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}), + DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}), + DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"}); + + private ChatColor color; + private String[] names; + + private TeamColors(ChatColor color, String[] names) + { + this.color = color; + this.names = names; + } + + public ChatColor getColor() + { + return color; + } + + public String[] getNames() + { + return names; + } + + } + + private String[] getColorName(ChatColor color) + { + for(TeamColors colors : TeamColors.values()) + { + if(colors.getColor() == color) + { + return colors.getNames(); + } + } + return null; + } + + private TeamColors getNextColor(TeamColors color) + { + for(TeamColors colors : TeamColors.values()) { + if(colors.ordinal() == color.ordinal() + 1) + { + return colors; + } + } + return TeamColors.YELLOW; + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (WinnerTeam == null) + return null; + + return WinnerTeam.GetPlayers(false); + } + + @Override + public List getLosers() + { + if (WinnerTeam == null) + return null; + + List players = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team != WinnerTeam) + players.addAll(team.GetPlayers(false)); + } + + return players; + } + + @Override + public boolean CanJoinTeam(GameTeam team) + { + return team.GetSize() < PlayersPerTeam; + } + + @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; + + //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; + } + + @Override + public String GetMode() + { + return "Team Mode"; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java index e66ed7509..91f27649c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java @@ -40,7 +40,7 @@ public class KitChicken extends SmashKit }, EntityType.CHICKEN, new ItemStack(Material.EGG), - "Airial Gunner", 20000, Sound.CHICKEN_HURT); + "Aerial Gunner", 20000, Sound.CHICKEN_HURT); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java index cbabc5f8f..06e392f7c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java @@ -76,7 +76,7 @@ public class KitSheep extends SmashKit { ChatColor.RESET + "Shear yourself and use the wool as", ChatColor.RESET + "an explosive device. You can Right-Click", - ChatColor.RESET + "as second time to solidify the bomb, and", + ChatColor.RESET + "a second time to solidify the bomb, and", ChatColor.RESET + "a third time to detonate it on command.", })); @@ -98,7 +98,7 @@ public class KitSheep extends SmashKit { ChatColor.RESET + "Release one Homing Sheeple towards every player.", ChatColor.RESET + "They will slowly home in on their target and", - ChatColor.RESET + "explode to deal devestating damage.", + ChatColor.RESET + "explode to deal devastating damage.", })); player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE)); 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 5343d64f2..a2e27f88e 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 @@ -1,58 +1,129 @@ package nautilus.game.arcade.game.games.snowfight; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilSound; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.explosion.ExplosionEvent; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.explosion.CustomExplosion; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.snowfight.kits.KitTactician; +import nautilus.game.arcade.game.games.snowfight.kits.KitMedic; +import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.SmashKit; +import net.minecraft.server.v1_7_R4.EntityFireball; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Effect; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFireball; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Fireball; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; -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; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; +import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array; public class SnowFight extends TeamGame { - public SnowFight(ArcadeManager manager) + + private HashMap _tiles; + private boolean _meteoroids; + private boolean _peace; + + public SnowFight(ArcadeManager manager) { super(manager, GameType.SnowFight, - new Kit[] + new Kit[] { - new NullKit(manager) + new KitSportsman(manager), + new KitTactician(manager), + new KitMedic(manager) }, - new String[] - { - "Just like... kill your enemies. with snow." - }); - + new String[] + { + "Just like... kill your enemies. with snow.", + "Be careful if you are on Ice your body will freeze" + }); + this.HungerSet = 20; + this.CompassEnabled = true; + this.CompassGiveItem = false; + this.TeamArmor = true; + this.TeamArmorHotbar = true; + this.BlockPlace = true; + this.BlockBreakAllow = new HashSet<>(Arrays.asList(Material.FENCE.getId())); + this._tiles = new HashMap(); + this._meteoroids = false; + this._peace = false; } - + @EventHandler + public void GameState(GameStateChangeEvent event) + { + if(event.GetState() != GameState.Live) + return; + + this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "15 seconds Peace Phase is starting!"); + } + @EventHandler public void Weather(UpdateEvent event) { @@ -69,6 +140,62 @@ public class SnowFight extends TeamGame world.setWeatherDuration(40); world.setTime(4000); } + + @EventHandler + public void IceDamage(UpdateEvent event) { + if(event.getType() != UpdateType.FAST) + return; + + if(!IsLive()) + return; + + for(Player player : GetPlayers(true)) + { + if(IsOnIce(player)) + { + Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, DamageCause.CUSTOM, 2.0D, false, true, true, "Ice", "Ice", false)); + } + } + + } + + @EventHandler + public void Meteor(UpdateEvent event) { + if(event.getType() != UpdateType.TWOSEC) + return; + + if(!IsLive()) + return; + + if(System.currentTimeMillis() <= getGameLiveTime() + (15 * 1000)) + return; + + if(!_peace) + { + for(Player player : GetPlayers(false)) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F); + UtilTextMiddle.display(C.cGold + C.Bold + "Peace Phase ended", "Kill your enemies", player); + } + this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "Peace Phase ended"); + _peace = true; + } + + if(System.currentTimeMillis() <= getGameLiveTime() + (195 * 1000)) + return; + + if(!_meteoroids) + { + for(Player player : GetPlayers(false)) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F); + UtilTextMiddle.display(C.cGold + C.Bold + "ICE METEOROIDS!!!", "Avoid the Ice Fields", player); + } + this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "METEOROIDS START FALLING!"); + _meteoroids = true; + } + makeMeteor(); + } @EventHandler public void BlockDamage(BlockDamageEvent event) @@ -84,97 +211,119 @@ public class SnowFight extends TeamGame if (!IsSnow(event.getBlock())) return; - - if (UtilInv.contains(player, Material.SNOW_BALL, (byte)0, 16)) + if (UtilInv.contains(player, Material.SNOW_BALL, (byte) 0, 16)) return; - //Item - UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); + // Item - //Snow Height + if (!_tiles.containsKey(player)) + { + _tiles.put(player, 0); + } + + if (GetKit(player) instanceof KitSportsman) + UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); + + + int tiles = _tiles.get(player); + _tiles.put(player, tiles + 1); + + if (!(GetKit(player) instanceof KitSportsman)) + { + if (_tiles.get(player) == 2) + { + UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); + _tiles.put(player, 0); + } + } + + // Snow Height SnowDecrease(event.getBlock(), 1); - //Effect - event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, 80); + // Effect + event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, 80); } -// @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); -// } + // @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); + // } -// 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) { @@ -184,30 +333,53 @@ public class SnowFight extends TeamGame if (!IsSnow(block)) return; - //Shuffle Up + // Shuffle Up while (IsSnow(block.getRelative(BlockFace.UP))) block = block.getRelative(BlockFace.UP); - //Snow Block - int snowLevel = 8; - if (block.getTypeId() == 78) + // Snow Block + int snowLevel = 8; + if (block.getTypeId() == 78) snowLevel = block.getData() + 1; - //Lower + // Lower if (height >= snowLevel) { - block.setTypeIdAndData(0, (byte)0, true); - SnowDecrease(block.getRelative(BlockFace.DOWN), height-snowLevel); + block.setTypeIdAndData(0, (byte) 0, true); + SnowDecrease(block.getRelative(BlockFace.DOWN), height - snowLevel); } else { - block.setTypeIdAndData(78, (byte)(snowLevel-height-1), true); + block.setTypeIdAndData(78, (byte) (snowLevel - height - 1), true); } } + + @EventHandler + public void HealthRegen(EntityRegainHealthEvent event) + { + if(event.getRegainReason() == RegainReason.SATIATED) + { + event.setAmount(1); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void GenerallDamage(CustomDamageEvent event) + { + if(event.GetCause() == DamageCause.ENTITY_ATTACK) + event.SetCancelled("No Melee"); + } @EventHandler(priority = EventPriority.HIGH) - public void SnowballDamage(CustomDamageEvent event) - { + public void SnowballEggDamage(CustomDamageEvent event) + { + + if(!_peace) + { + event.SetCancelled("Peace Phase"); + return; + } + if (event.IsCancelled()) return; @@ -215,20 +387,249 @@ public class SnowFight extends TeamGame return; Projectile proj = event.GetProjectile(); - if (proj == null) return; - - if (!(proj instanceof Snowball)) + if (proj == null) return; - - event.AddMod("Snowball", "Snowball", 3, true); + + if(proj instanceof Fireball) + return; + + if(proj instanceof Snowball) + event.AddMod("Snowball", "Snowball", 2, true); + event.SetIgnoreRate(true); + event.SetIgnoreArmor(true); - //Effect - proj.getWorld().playEffect(proj.getLocation(), Effect.STEP_SOUND, 80); + // Effect + proj.getWorld().playEffect(proj.getLocation(), Effect.STEP_SOUND, 80); + ((Player) proj.getShooter()).playSound(((Player) proj.getShooter()).getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); } private boolean IsSnow(Block block) { return block.getTypeId() == 78 || block.getTypeId() == 80; } + + private boolean IsOnIce(Player player) + { + return player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.ICE; + } + + + private void makeMeteor() + { + + Location loc = getEndgameLocation(); + + if (loc == null) + { + return; + } + + summonMeteor(loc, 20F); + + } + + private void summonMeteor(Location loc, float fireballSize) + { + Vector vector = new Vector(UtilMath.random.nextDouble() - 0.5D, 0.8, UtilMath.random.nextDouble() - 0.5D).normalize(); + + vector.multiply(40); + + loc.add((UtilMath.random.nextDouble() - 0.5) * 7, 0, (UtilMath.random.nextDouble() - 0.5) * 7); + + loc.add(vector); + + final FallingBlock fallingblock = loc.getWorld().spawnFallingBlock(loc, Material.ICE, (byte) 0); + + fallingblock.setMetadata("Meteor", new FixedMetadataValue(getArcadeManager().getPlugin(), fireballSize)); + + new BukkitRunnable() + { + int i; + + public void run() + { + if (fallingblock.isValid() && IsLive()) + { + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, fallingblock.getLocation(), 0.3F, 0.3F, 0.3F, 0, 3, + ViewDist.MAX, UtilServer.getPlayers()); + + if (i++ % 6 == 0) + { + fallingblock.getWorld().playSound(fallingblock.getLocation(), Sound.CAT_HISS, 1.3F, 0F); + } + } + else + { + cancel(); + } + } + }.runTaskTimer(getArcadeManager().getPlugin(), 0, 0); + + vector.normalize().multiply(-(0.04 + ((0.5 - 0.05) / 2))); + fallingblock.setFireTicks(9999); + } + + @EventHandler + public void MeteorHit(EntityChangeBlockEvent event) + { + Entity projectile = event.getEntity(); + + float size = 2.5F; + double damage = 2.5D; + + for(int i = 1; i <= 10; i++) + { + if(System.currentTimeMillis() >= getGameLiveTime() + (((30 * i) + 180) * 1000)) + { + size = 2.5F * i; + damage = 2.5D * i; + } + } + + if (projectile.hasMetadata("Meteor")) + { + + CustomExplosion explosion = new CustomExplosion(getArcadeManager().GetDamage(), getArcadeManager().GetExplosion(), + projectile.getLocation(), size, "Meteor"); + + explosion.setBlockExplosionSize(size); + explosion.setFallingBlockExplosion(false); + explosion.setDropItems(false); + explosion.setBlocksDamagedEqually(true); + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, projectile.getLocation(), 1.0F, 1.0F, 1.0F, 1, 3, ViewDist.MAX, UtilServer.getPlayers()); + for(Player player : UtilServer.getPlayers()) { + player.playSound(projectile.getLocation(), Sound.EXPLODE, 1, 1); + } + + boolean fall = true; + + for(Entity player : projectile.getNearbyEntities(size, size, size)) + { + if(player instanceof Player) + { + Player damagee = (Player) player; + Bukkit.getPluginManager().callEvent(new CustomDamageEvent(damagee, null, null, DamageCause.CUSTOM, damage, false, true, true, "Ice Meteoroid", "Ice Meteoroid", false)); + } + } + + for(Block block : UtilBlock.getInRadius(event.getEntity().getLocation(), size).keySet()) + { + if(block.getType() != Material.AIR) + { + block.setType(Material.ICE); + if(block.getRelative(BlockFace.DOWN).getType() == Material.AIR) + { + // to reduce lag + if(fall) + { + block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData()); + fall = false; + } + else + { + fall = true; + } + block.setType(Material.AIR); + } + } + } + + } + } + + private Location getEndgameLocation() + { + int chance = UtilMath.r(50) + 3; + int accuracy = Math.max((int) (chance - (0.0001 * chance)), 1); + + ArrayList players = GetPlayers(true); + + for (int a = 0; a < 50; a++) + { + Player player = players.get(UtilMath.r(players.size())); + + Location location = player.getLocation().add(UtilMath.r(accuracy * 2) - accuracy, 0, + UtilMath.r(accuracy * 2) - accuracy); + + location = WorldData.World.getHighestBlockAt(location).getLocation().add(0.5, 0, 0.5); + + if (location.getBlock().getType() == Material.AIR) + { + location.add(0, -1, 0); + } + + if (location.getBlockY() > 0 && location.getBlock().getType() != Material.AIR) + { + return location; + } + } + + return null; + } + + @EventHandler + public void Place(BlockPlaceEvent event) + { + if(event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.ICE + || event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.PACKED_ICE + || event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.FENCE) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cant place a Barrier here!")); + event.setCancelled(true); + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + if(GetPlayers(true).size() <= 8) + { + for (GameTeam team : this.GetTeamList()) + { + if (!team.IsTeamAlive()) + continue; + + for(Player player : team.GetPlayers(true)) + { + Scoreboard.Write(team.GetColor() + player.getName()); + } + + Scoreboard.WriteBlank(); + } + } + else + { + for (GameTeam team : this.GetTeamList()) + { + Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); + Scoreboard.Write(team.GetColor() + "Alive " + team.GetPlayers(true).size()); + Scoreboard.WriteBlank(); + } + } + + long time = 1000 * 195 - (System.currentTimeMillis() - this.GetStateTime()); + + if (time > 0) + { + Scoreboard.Write(C.cYellow + C.Bold + "Meteoroids:"); + if(IsLive()) + Scoreboard.Write(UtilTime.MakeStr(time, 0)); + } + else + { + Scoreboard.Write(C.cGold + C.Bold + "Meteoroids!"); + } + + Scoreboard.Draw(); + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java new file mode 100644 index 000000000..efebaf42e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java @@ -0,0 +1,140 @@ +package nautilus.game.arcade.game.games.snowfight.kits; + +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.PotionSplashEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; + +public class KitMedic extends Kit +{ + + public KitMedic(ArcadeManager manager) + { + super(manager, "Medic", KitAvailability.Free, + + new String[] + { + "To the rescue...!", + " ", + "Gets 1 Snowball every second tile.", + "Left-Click Snow to pick up Snowballs (Max. 16)", + "Right-Click Snowballs to throw them.", + " ", + "Gets 1 Healing Potion every 32 seconds [max. 1]", + "Slowness II when hit.", + " ", + "Supports all nearby allies with REGENERATION." + }, + + new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.POTION)); + + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } + + @EventHandler + public void Aura(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if (other.equals(player)) + continue; + + if (UtilMath.offset(player, other) > 4) + continue; + + if( Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other))) + Manager.GetCondition().Factory().Regen("Aura", other, player, 1.9, 0, false, false, false); + } + } + } + + @EventHandler + public void KitItems(UpdateEvent event) + { + if(!Manager.GetGame().IsLive()) + return; + + if (event.getType() == UpdateType.SLOWEST) + { + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + Potion potion = new Potion(PotionType.INSTANT_HEAL); + potion.setSplash(true); + player.getInventory().setItem(1, potion.toItemStack(1)); + } + } + } + + @EventHandler + public void Splash(PotionSplashEvent event) + { + if(event.getEntity().getShooter() instanceof Player) + { + if(!HasKit((Player) event.getEntity().getShooter())) + return; + + for(Entity entity : event.getAffectedEntities()) + { + if(entity instanceof Player) + { + Manager.GetCondition().Factory().Slow("Heal Potion", (Player)entity, (Player)event.getEntity().getShooter(), 5.0, 1, false, false, false, false); + } + } + + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java new file mode 100644 index 000000000..43bd655e3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java @@ -0,0 +1,92 @@ +package nautilus.game.arcade.game.games.snowfight.kits; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFallDamage; + +public class KitSportsman extends Kit +{ + + public KitSportsman(ArcadeManager manager) + { + super(manager, "Sportsman", KitAvailability.Free, + + new String[] + { + "Trained to be the fastest on snow and ice.", + "", + "Gets 1 Snowball every tile", + "Left-Click Snow to pick up Snowballs (Max. 16)", + "Right-Click Snowballs to throw them.", + "", + "Supports all nearby allies with SPEED." + }, + + new Perk[] + { + new PerkFallDamage(3) + }, + EntityType.SKELETON, + new ItemStack(Material.SNOW_BALL)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } + + @EventHandler + public void Aura(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if (other.equals(player)) + continue; + + if (UtilMath.offset(player, other) > 4) + continue; + + if( Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other))) + Manager.GetCondition().Factory().Speed("Aura", other, player, 1.9, 0, false, false, false); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java new file mode 100644 index 000000000..a0aec26c1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java @@ -0,0 +1,118 @@ +package nautilus.game.arcade.game.games.snowfight.kits; + +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFallDamage; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionType; + +public class KitTactician extends Kit +{ + + public KitTactician(ArcadeManager manager) + { + super(manager, "Tactician", KitAvailability.Free, + new String[] + { + "No Snowfight is complete without a tactical game!", + " ", + "Gets 1 Snowball every second tile.", + "Left-Click Snow to pick up Snowballs (Max. 16)", + "Right-Click Snowballs to throw them.", + " ", + "Gets 1 Barrier every 32 seconds [max. 2]", + "Place Barriers to improve your defense.", + "You cant place Barriers above Ice, Packed Ice or Fences.", + " ", + "Supports all nearby allies with RESISTANCE." + }, new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.FENCE)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(7, ItemStackFactory.Instance.CreateStack(Material.COMPASS.getId(), (byte) 0, 1, "§a§lTracking Compass")); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } + + @EventHandler + public void Aura(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if (other.equals(player)) + continue; + + if (UtilMath.offset(player, other) > 4) + continue; + + if( Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other))) + Manager.GetCondition().Factory().Protection("Aura", other, player, 1.9, 0, false, false, false); + } + } + } + + @EventHandler + public void KitItems(UpdateEvent event) + { + if(!Manager.GetGame().IsLive()) + return; + + if (event.getType() == UpdateType.SLOWEST) + { + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + continue; + + int amount = 0; + if (player.getInventory().getItem(1) != null && UtilInv.contains(player, Material.FENCE, (byte) 0, 1)) + amount = 2; + else + amount = 1; + player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.FENCE, (byte) 0, amount, "Barrier")); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java index 6716ac290..17eaf5a5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java @@ -172,17 +172,20 @@ public class Spleef extends SoloGame event.setCancelled(true); + if (event.getBlock().getType() == Material.BEDROCK) + return; + BlockFade(event.getBlock(), event.getPlayer(), false); //Snowball - if (GetKit(event.getPlayer()) instanceof KitSnowballer) + if (GetKit(event.getPlayer()) instanceof KitSnowballer && event.getBlock().getType() != Material.BEDROCK) if (!UtilInv.contains(event.getPlayer(), Material.SNOW_BALL, (byte)0, 16)) event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL)); } public void BlockFade(Block block, Player player, boolean slowDamage) { - if (block.getTypeId() == 7) + if (block.getType() == Material.BEDROCK || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) return; //Prevent Super Hunger from Bow diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/kits/KitSnowballer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/kits/KitSnowballer.java index 36cafe126..5e1ecc8d9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/kits/KitSnowballer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/kits/KitSnowballer.java @@ -21,7 +21,7 @@ public class KitSnowballer extends Kit new String[] { "Throw snowballs to break blocks!", - "Receives 2 Snowball when you punch blocks!" + "Receives 1 Snowball when you punch blocks!" }, new Perk[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java index c7334f60e..8842a3799 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java @@ -48,7 +48,6 @@ public class SquidShooter extends SoloGame this.DamageSelf = false; this.DamageTeamSelf = true; this.PrepareFreeze = false; - this.SpawnDistanceRequirement = 16; this.CompassEnabled = true; this.KitRegisterState = GameState.Prepare; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java new file mode 100644 index 000000000..8085bf2ed --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java @@ -0,0 +1,181 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.Game.GameState; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class SoloSurvivalGames extends SurvivalGames +{ + + private GameTeam _players; + + public SoloSurvivalGames(ArcadeManager manager) + { + super(manager, GameType.SurvivalGames, + new String[] + { + "Search for chests to find loot", + + "Slaughter your opponents", + + "Stay away from the borders!", + + "Last tribute alive wins!" + }); + + this.DamageTeamSelf = true; + + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + _players.setDisplayName(C.cYellow + C.Bold + "Players"); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + GameTeam team = GetTeamList().get(0); + + Scoreboard.Write(C.cGreen + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellow + C.Bold + "Tributes"); + if (team.GetPlayers(true).size() > 7) + { + Scoreboard.Write("" + team.GetPlayers(true).size()); + } + else + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(C.cWhite + player.getName()); + } + } + + Scoreboard.WriteBlank(); + + if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60) + { + Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.Write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + } + else if (this.getDeathMatchTime() > 0) + { + Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.Write(UtilTime.convertString( + Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); + } + else + { + Scoreboard.Write(C.cRed + C.Bold + "Game End"); + Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + } + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 1) + { + ArrayList places = GetTeamList().get(0).GetPlacements(true); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return Arrays.asList(); + else + return Arrays.asList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + List losers = GetTeamList().get(0).GetPlayers(false); + + losers.removeAll(winners); + + return losers; + } + + @Override + public String GetMode() + { + return "Solo Mode"; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 71d2e3f5c..a46a085de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -114,7 +114,7 @@ import net.minecraft.server.v1_7_R4.TileEntityChest; import net.minecraft.server.v1_7_R4.WorldServer; import net.minecraft.util.com.mojang.authlib.GameProfile; -public class SurvivalGames extends SoloGame +public abstract class SurvivalGames extends Game { // Chest loot private ChestLoot _baseLoot = new ChestLoot(true); @@ -168,9 +168,9 @@ public class SurvivalGames extends SoloGame */ private Field _ticksField; - public SurvivalGames(ArcadeManager manager) + public SurvivalGames(ArcadeManager manager, GameType type, String[] description) { - super(manager, GameType.SurvivalGames, + super(manager, type, new Kit[] { @@ -195,18 +195,7 @@ public class SurvivalGames extends SoloGame new KitBarbarian(manager), new KitHorseman(manager), - }, - - new String[] - { - "Search for chests to find loot", - - "Slaughter your opponents", - - "Stay away from the borders!", - - "Last tribute alive wins!" - }); + }, description); _help = new String[] { @@ -220,6 +209,12 @@ public class SurvivalGames extends SoloGame // Manager.GetAntiStack().SetEnabled(false); StrictAntiHack = true; + + AnnounceStay = false; + + HideTeamSheep = true; + + this.ReplaceTeamsWithKits = true; GameTimeout = 1500000; @@ -227,9 +222,7 @@ public class SurvivalGames extends SoloGame WorldTimeSet = 0; WorldBoundaryKill = false; - - SpawnDistanceRequirement = 48; - + DamageSelf = true; DamageTeamSelf = true; @@ -757,7 +750,8 @@ public class SurvivalGames extends SoloGame WorldTimeSet = 0; WorldData.World.setTime(15000); - GetTeamList().get(0).SpawnTeleport(false); + for (GameTeam team : GetTeamList()) + team.SpawnTeleport(false); _borderPositions.clear(); @@ -1683,62 +1677,6 @@ public class SurvivalGames extends SoloGame } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (GetTeamList().isEmpty()) - return; - - Scoreboard.Reset(); - - Scoreboard.WriteBlank(); - - GameTeam team = GetTeamList().get(0); - - Scoreboard.Write(C.cGreen + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(_secondsSinceStart * 1000, 0, TimeUnit.FIT)); - - Scoreboard.WriteBlank(); - - Scoreboard.Write(C.cYellow + C.Bold + "Tributes"); - if (team.GetPlayers(true).size() > 7) - { - Scoreboard.Write("" + team.GetPlayers(true).size()); - } - else - { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.Write(C.cWhite + player.getName()); - } - } - - Scoreboard.WriteBlank(); - - if (_chestRefillTime > 0 && _deathMatchTime > 60) - { - Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.Write(UtilTime.convertString(_chestRefillTime * 1000, 0, TimeUnit.FIT)); - } - else if (_deathMatchTime > 0) - { - Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.Write(UtilTime.convertString( - Math.min(_deathMatchTime, _deathMatchTeleported ? 10 : _deathMatchTime) * 1000, 0, TimeUnit.FIT)); - } - else - { - Scoreboard.Write(C.cRed + C.Bold + "Game End"); - Scoreboard.Write(UtilTime.convertString(Math.max(0, _gameEndTime) * 1000, 0, TimeUnit.FIT)); - } - - Scoreboard.Draw(); - } - private void setBorder() { _borderStartedMoving = System.currentTimeMillis(); @@ -2295,4 +2233,30 @@ public class SurvivalGames extends SoloGame } } } + + public int getSecondsSinceStart() + { + return this._secondsSinceStart; + } + + public int getChestRefillTime() + { + return this._chestRefillTime; + } + + public int getDeathMatchTime() + { + return this._deathMatchTime; + } + + public boolean isDeathMatchTeleported() + { + return this._deathMatchTeleported; + } + + public int getGameEndTime() + { + return this._gameEndTime; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java index 3d2e51099..f6385469e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java @@ -7,38 +7,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; -import org.bukkit.*; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.entity.Entity; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -52,9 +20,9 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -72,9 +40,56 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.survivalgames.kit.*; +import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher; +import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin; +import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler; +import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman; +import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight; +import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; + public class SurvivalGamesTeams extends TeamGame { private HashSet _openedChest = new HashSet(); @@ -114,7 +129,7 @@ public class SurvivalGamesTeams extends TeamGame public SurvivalGamesTeams(ArcadeManager manager) { - super(manager, GameType.SurvivalGamesTeams, + super(manager, GameType.SurvivalGames, new Kit[] { @@ -161,8 +176,9 @@ public class SurvivalGamesTeams extends TeamGame this.WorldTimeSet = 0; this.WorldBoundaryKill = false; - this.SpawnDistanceRequirement = 48; - + SpawnNearAllies = true; + SpawnNearEnemies = true; //This is to ensure theres no 'gaps' of 1 between teams, hence forcing a team to get split. + this.DamageSelf = true; this.DamageTeamSelf = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java new file mode 100644 index 000000000..e64d87f04 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -0,0 +1,448 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class TeamSurvivalGames extends SurvivalGames +{ + + public boolean ForceTeamSize = true; + public int PlayersPerTeam = 2; + public int TeamCount = 0; + + private NautHashMap _teamReqs = new NautHashMap(); + + public TeamSurvivalGames(ArcadeManager manager) + { + super(manager, GameType.SurvivalGamesTeams, + new String[] + { + "Search for chests to find loot", + "Slaughter your opponents", + "Stay away from the Deep Freeze!", + "Last team alive wins!" + }); + + this.PlayersPerTeam = 2; + this.FillTeamsInOrderToCount = 2; + + this.SpawnNearAllies = true; + this.SpawnNearEnemies = true; + + this.DamageTeamSelf = false; + + this.DontAllowOverfill = true; + + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + ArrayList spawns = this.GetTeamList().get(0).GetSpawns(); + this.GetTeamList().clear(); + + TeamColors color = TeamColors.DARK_AQUA; + + if(!this.ForceTeamSize) + { + for(int i = 1; i <= this.TeamCount; i++) + { + color = getNextColor(color); + GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns); + team.SetVisible(true); + GetTeamList().add(team); + } + } + else + { + for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++) + { + //Got Spawns + color = getNextColor(color); + int e = 0; + for(GameTeam teams : GetTeamList()) + { + if(teams.GetColor() == color.getColor()) + { + e++; + if(getColorName(color.getColor()).length <= e) + { + e = 0; + } + } + } + GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true); + team.SetVisible(true); + GetTeamList().add(team); + } + } + } + + private enum TeamColors + { + + YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}), + GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}), + AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}), + RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}), + GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}), + LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}), + DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}), + DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}), + WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}), + BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}), + DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}), + DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}), + DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"}); + + private ChatColor color; + private String[] names; + + private TeamColors(ChatColor color, String[] names) + { + this.color = color; + this.names = names; + } + + public ChatColor getColor() + { + return color; + } + + public String[] getNames() + { + return names; + } + + } + + private String[] getColorName(ChatColor color) + { + for(TeamColors colors : TeamColors.values()) + { + if(colors.getColor() == color) + { + return colors.getNames(); + } + } + return null; + } + + private TeamColors getNextColor(TeamColors color) + { + for(TeamColors colors : TeamColors.values()) { + if(colors.ordinal() == color.ordinal() + 1) + { + return colors; + } + } + return TeamColors.YELLOW; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cGreen + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + + ArrayList alive = new ArrayList(); + for (GameTeam team : GetTeamList()) + { + if (team.IsTeamAlive()) + alive.add(team); + } + + if (GetPlayers(true).size() <= 7) + { + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(team.GetColor() + player.getName()); + } + } + } + else if (alive.size() <= 7) + { + for (GameTeam team : alive) + { + Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + } + } + else + { + Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + } + + Scoreboard.WriteBlank(); + + if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60) + { + Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.Write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + } + else if (this.getDeathMatchTime() > 0) + { + Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.Write(UtilTime.convertString( + Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); + } + else + { + Scoreboard.Write(C.cRed + C.Bold + "Game End"); + Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + } + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (WinnerTeam == null) + return null; + + return WinnerTeam.GetPlayers(false); + } + + @Override + public List getLosers() + { + if (WinnerTeam == null) + return null; + + List players = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team != WinnerTeam) + players.addAll(team.GetPlayers(false)); + } + + return players; + } + + @Override + public boolean CanJoinTeam(GameTeam team) + { + return team.GetSize() < PlayersPerTeam; + } + + @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; + + //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; + } + + @Override + public String GetMode() + { + return "Team Mode"; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index a4c514cb3..3e4b5c774 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -4,33 +4,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; - -import net.minecraft.server.v1_7_R4.EntityArrow; -import net.minecraft.server.v1_7_R4.Item; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -57,6 +30,31 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.BehindEnemyLinesStatTracker; import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker; +import net.minecraft.server.v1_7_R4.EntityArrow; +import net.minecraft.server.v1_7_R4.Item; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; public class TurfForts extends TeamGame { @@ -115,6 +113,7 @@ public class TurfForts extends TeamGame new Kit[] { + new KitMarksman(manager), new KitInfiltrator(manager), new KitShredder(manager), @@ -126,6 +125,7 @@ public class TurfForts extends TeamGame "", "Each kill advances your turf forwards.", "Take over all the turf to win!" + }); this.StrictAntiHack = true; @@ -269,7 +269,7 @@ public class TurfForts extends TeamGame EndCheck(); } } - + @EventHandler public void BowCancel(EntityShootBowEvent event) { @@ -281,13 +281,21 @@ public class TurfForts extends TeamGame ((Player) event.getEntity()).updateInventory(); } } + + @EventHandler + public void BlockBreak(BlockBreakEvent event) + { + if (event.isCancelled()) // this statement might save just a small amount of time + return; + + if(getArcadeManager().isSpectator(event.getPlayer())) event.setCancelled(true); + } - @EventHandler(ignoreCancelled = true) + @EventHandler public void BlockPlace(BlockPlaceEvent event) { - //Remoeved and replaced by ignoreCancelled = true - //if (event.isCancelled()) - // return; + if (event.isCancelled()) + return; GameTeam team = GetTeam(event.getPlayer()); if (team == null) @@ -326,7 +334,6 @@ public class TurfForts extends TeamGame event.setCancelled(true); return; } - } @EventHandler @@ -334,7 +341,7 @@ public class TurfForts extends TeamGame { if (event.getEntity().getShooter() == null) return; - + if (!(event.getEntity() instanceof Arrow)) return; @@ -350,7 +357,6 @@ public class TurfForts extends TeamGame Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { - public void run() { try @@ -370,22 +376,21 @@ public class TurfForts extends TeamGame int z = fieldZ.getInt(entityArrow); Block block = arrow.getWorld().getBlockAt(x, y, z); - + if (block.getTypeId() == 35) { - if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */) + if (block.getData() == 14 && team.GetColor() != ChatColor.RED) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); } - else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */) + else if (block.getData() == 3 && team.GetColor() != ChatColor.AQUA) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); } - + Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); - - - block.setType(Material.AIR); + + block.breakNaturally(); } arrow.remove(); @@ -660,8 +665,7 @@ public class TurfForts extends TeamGame } } } - - /* + @EventHandler public void ItemRemoval(UpdateEvent event) { @@ -680,37 +684,7 @@ public class TurfForts extends TeamGame ent.remove(); } } - */ - - //Added by TheMineBench. - @EventHandler - public void blockBreak(BlockBreakEvent event) { - - Block block = event.getBlock(); - - GameTeam team = GetTeam(event.getPlayer()); - GameTeam otherTeam = GetOtherTeam(team); - if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); - event.setCancelled(true); - return; - } - - } - - public GameTeam GetOtherTeam(GameTeam team) { - return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); - } - - @EventHandler - public void onItem(ItemSpawnEvent e) { - if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) { - e.setCancelled(true); - } - } - @Override public void EndCheck() { @@ -740,7 +714,7 @@ public class TurfForts extends TeamGame if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - + //End SetState(GameState.End); } @@ -749,4 +723,4 @@ public class TurfForts extends TeamGame { return _enemyTurf.get(player); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index bbadc974a..9175d6350 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -136,7 +136,11 @@ public class UHC extends TeamGame "Borders shrink over time", "Last player/team alive wins!" }); + this.HideTeamSheep = true; + this.StrictAntiHack = true; + + AnnounceStay = false; this.GameTimeout = 10800000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index e2ab3b724..cf672d0e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -1,39 +1,28 @@ package nautilus.game.arcade.game.games.wither; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.EntityEffect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.ThrownPotion; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - +import mineplex.core.common.block.BlockData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.block.BlockData; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -42,13 +31,55 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.paintball.PlayerCopy; -import nautilus.game.arcade.game.games.wither.kit.*; +import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent; +import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher; +import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic; +import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor; +import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.kit.perks.data.IBlockRestorer; +import nautilus.game.arcade.stats.BloodThirstyStatTracker; +import nautilus.game.arcade.stats.KingDamageStatTracker; +import nautilus.game.arcade.stats.KingSlayerStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; +import nautilus.game.arcade.stats.WinAsTeamStatTracker; +import nautilus.game.arcade.stats.WitherAssaultReviveTracker; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; public class WitherGame extends TeamGame implements IBlockRestorer { @@ -56,76 +87,86 @@ public class WitherGame extends TeamGame implements IBlockRestorer private GameTeam _withers; private double _witherFactor = 2.5; - + private int _yLimit = 0; - + private int _maxY; + private long _gameTime = 300000; - + private HashMap _doubles = new HashMap(); - -// private int _livesPerPlayer = 3; -// private HashMap _lives = new HashMap(); - + + // private int _livesPerPlayer = 3; + // private HashMap _lives = new HashMap(); + private HashSet _blocks = new HashSet(); + private ArrayList _locationsOfBlocks = new ArrayList(); + public WitherGame(ArcadeManager manager) { super(manager, GameType.WitherAssault, - new Kit[] - { + new Kit[] + { new KitHumanArcher(manager), - //new KitHumanBuilder(manager), - //new KitHumanRunner(manager), - new NullKit(manager), - new NullKit(manager), + new KitHumanMedic(manager), + new KitHumanEditor(manager), new NullKit(manager), new KitWitherMinion(manager), - //new KitWitherWeb(manager), - //new KitWitherWeb(manager), - }, + }, + + new String[] + { - new String[] - { - C.cGreen + "Humans" + C.cWhite + " Run and hide from the Withers", C.cGreen + "Humans" + C.cWhite + " Revive your dead allies!", C.cGreen + "Humans" + C.cWhite + " Win by surviving for 5 minutes", " ", C.cRed + "Withers" + C.cWhite + " Moves very slowly when near ground", C.cRed + "Withers" + C.cWhite + " Kill all the Humans within 5 Minutes", - }); - + }); + this.DeathOut = true; this.DamageTeamSelf = false; this.DamageSelf = false; this.DeathSpectateSecs = 4; this.HungerSet = 20; this.WorldBoundaryKill = false; + this.CompassEnabled = false; - this.CompassEnabled = true; - this.CompassGiveItem = false; - + //Customizing for the Editor kit + this.BlockBreak = true; + this.BlockPlace = true; + this.ItemPickup = true; + this.KitRegisterState = GameState.Prepare; - + this.TeamArmor = true; this.TeamArmorHotbar = false; + + _help = new String[] + { + "Blocks placed by an Editor can be passed by other humans by " + C.cDGreen + "Right-clicking the block", + "Withers are too powerful to be killed. Hiding is the only option!", + "Medics are a valuable asset. Stick with them and keep them safe!", + + }; - _help = new String[] - { - C.cRed + C.Bold + "This game is still under development!", - - }; + + registerStatTrackers( + new TeamDeathsStatTracker(this), + new TeamKillsStatTracker(this) + ); } @Override - public void ParseData() + public void ParseData() { _yLimit = WorldData.GetDataLocs("RED").get(0).getBlockY(); } - + @EventHandler - public void teamSetup(GameStateChangeEvent event) + public void teamSetup(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) return; @@ -139,7 +180,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer _withers = team; _withers.SetName("Withers"); _withers.SetColor(ChatColor.RED); - + if (!kit.GetName().contains("Wither")) team.GetRestrictedKits().add(kit); } @@ -148,7 +189,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer _runners = team; _runners.SetName("Humans"); _runners.SetColor(ChatColor.GREEN); - + if (kit.GetName().contains("Wither")) team.GetRestrictedKits().add(kit); } @@ -165,95 +206,281 @@ public class WitherGame extends TeamGame implements IBlockRestorer if (event.getType() != UpdateType.FAST) return; - //Not Enough Players + // Not Enough Players if (_runners.GetPlayers(true).size() < 2) return; - //Enough Withers - if (_withers.GetPlayers(true).size() * _witherFactor >= _runners.GetPlayers(true).size()) + // Enough Withers + if (_withers.GetPlayers(true).size() * _witherFactor >= _runners + .GetPlayers(true).size()) return; - - + Player player = UtilAlg.Random(_runners.GetPlayers(true)); setWither(player, true); } +// @EventHandler +// public void assignCompassOnStart(GameStateChangeEvent event) +// { +// if (event.GetState() != GameState.Live) +// return; +// +// for (Player players : _withers.GetPlayers(true)) +// { +// ItemStack compass = new ItemBuilder(Material.COMPASS, 1).build(); +// +// ItemMeta im = compass.getItemMeta(); +// im.setLore(new ArrayList(Arrays.asList( +// F.item("A compass that trigger"), +// F.item("your ability to track humans!")))); +// im.setDisplayName(F.name("Scent Trigger")); +// +// compass.setItemMeta(im); +// +// players.getInventory().setItem(7, compass); +// } +// } + + // Cancel wither shooting in waiting lobby + @EventHandler + public void onWitherSkullFire(ProjectileLaunchEvent event) + { + if (GetState() == GameState.Recruit || GetState() == GameState.Prepare) + { + Projectile proj = event.getEntity(); + WitherSkull ws = (WitherSkull) proj; + + if (ws.getShooter() instanceof Wither) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void handleCustomBlockPlace(BlockPlaceEvent event) + { + if(!IsLive()) + { + return; + } + if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor")) + { + event.setCancelled(true); + return; + } + + _maxY = GetTeamList().get(1).GetSpawn().getBlockY() - 4; + if(event.getBlock().getLocation().getBlockY() < _maxY) + { + event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); + event.setCancelled(true); + return; + } + + _locationsOfBlocks.add(event.getBlock().getLocation()); + } + + @EventHandler + public void handleCustomBlockbreak(BlockBreakEvent event) + { + if(!IsLive()) + { + return; + } + if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor")) + { + event.setCancelled(true); + return; + } + + Location blockLocation = event.getBlock().getLocation(); + _maxY = GetTeamList().get(1).GetSpawn().getBlockY() - 3; + if(blockLocation.add(0,1,0).getBlock().getType() == Material.AIR) + { + for(Player humans: _runners.GetPlayers(true)) + { + if(IsAlive(humans)) + { + if(humans.getLocation().add(0,-1,0).getBlock().equals(event.getBlock())) + { + if(humans.getName() != event.getPlayer().getName()) + { + event.setCancelled(true); + return; + } + } + } + } + } + + if(blockLocation.getBlockY() < _maxY) + { + event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); + event.setCancelled(true); + return; + } + } + + @EventHandler + public void handleCustomItemPickup(PlayerPickupItemEvent event) + { + if(!IsLive()) + { + return; + } + if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor")) + { + event.setCancelled(true); + return; + } + } + + //On Player interact with a placed block by Editor + @EventHandler + public void onPlayerInteract(final PlayerInteractEvent event) + { + if(!IsLive()) + { + return; + } + if(!IsAlive(event.getPlayer())) + { + return; + } + if(GetTeam(event.getPlayer()).GetColor() == ChatColor.RED) + { + return; + } + if(event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + Block clickedBlock = event.getClickedBlock(); + + if(_locationsOfBlocks.contains(clickedBlock.getLocation())) + { + new BukkitRunnable() + { + + @Override + public void run() + { + if(!(event.getPlayer().getItemInHand().getType().isBlock()) || event.getPlayer().getItemInHand().getType() == Material.AIR) + { + UtilParticle.PlayParticle(ParticleType.FLAME, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); + Manager.GetBlockRestore().add(event.getClickedBlock(), 0, event.getClickedBlock().getData(), 2000); + } + } + }.runTaskLater(Manager.getPlugin(), 5); + } + } + } + public void setWither(Player player, boolean forced) { -// _lives.remove(player); - + // _lives.remove(player); + SetPlayerTeam(player, _withers, true); - - //Kit - Kit newKit = GetKits()[4]; + + // Kit + Kit newKit = GetKits()[GetKits().length-1]; SetKit(player, newKit, false); newKit.ApplyKit(player); - + player.teleport(_withers.GetSpawn()); if (forced) { AddGems(player, 10, "Forced Wither", false, false); - Announce(F.main("Game", F.elem(_withers.GetColor() + player.getName()) + " has become a " + - F.elem(_withers.GetColor() + newKit.GetName()) + ".")); + Announce(F.main( + "Game", + F.elem(_withers.GetColor() + player.getName()) + + " has become a " + + F.elem(_withers.GetColor() + newKit.GetName()) + + ".")); player.getWorld().strikeLightningEffect(player.getLocation()); } } - -// @EventHandler -// public void playerLoseLife(final PlayerDeathOutEvent event) -// { -// Player player = event.GetPlayer(); -// -// if (_lives.containsKey(player)) -// { -// int lives = _lives.get(player); -// -// if (lives <= 1) -// return; -// -// _lives.put(player, lives - 1); -// -// UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + C.Bold + lives + " Lives Remaining") + ".")); -// -// event.setCancelled(true); -// } -// } - + + // @EventHandler + // public void playerLoseLife(final PlayerDeathOutEvent event) + // { + // Player player = event.GetPlayer(); + // + // if (_lives.containsKey(player)) + // { + // int lives = _lives.get(player); + // + // if (lives <= 1) + // return; + // + // _lives.put(player, lives - 1); + // + // UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + + // C.Bold + lives + " Lives Remaining") + ".")); + // + // event.setCancelled(true); + // } + // } + @EventHandler public void gameStart(GameStateChangeEvent event) { if (event.GetState() != GameState.Live) return; - - UtilTextMiddle.display(C.cGreen + "Humans Hiding", "15 Seconds until Assault", 10, 80, 10); - + + UtilTextMiddle.display(C.cGreen + "Humans Hiding", + "15 Seconds until Assault", 10, 80, 10); + for (Player player : _withers.GetPlayers(true)) { - Manager.GetCondition().Factory().Blind("Game Start", player, null, 15, 0, false, false, false); + Manager.GetCondition() + .Factory() + .Blind("Game Start", player, null, 15, 0, false, false, + false); } } -// @EventHandler -// public void playerLivesDisplay(PlayerKitGiveEvent event) -// { -// if (!_runners.HasPlayer(event.GetPlayer())) -// return; -// -// //Player Lives -// if (!_lives.containsKey(event.GetPlayer())) -// _lives.put(event.GetPlayer(), _livesPerPlayer); -// -// int lives = _lives.get(event.GetPlayer()); -// -// if (lives <= 0) -// return; -// -// event.GetPlayer().getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, lives, C.cGreen + C.Bold + lives + " Lives Remaining")); -// } + @EventHandler + public void removeUselessPlayerCopies(UpdateEvent event) + { + if(event.getType() != UpdateType.TWOSEC) + return; + + for(Player players: _doubles.keySet()) + { + if(!players.isOnline()) + { + PlayerCopy pc = _doubles.get(players); + pc.GetEntity().remove(); + _doubles.remove(players); + } + } + + } + + // @EventHandler + // public void playerLivesDisplay(PlayerKitGiveEvent event) + // { + // if (!_runners.HasPlayer(event.GetPlayer())) + // return; + // + // //Player Lives + // if (!_lives.containsKey(event.GetPlayer())) + // _lives.put(event.GetPlayer(), _livesPerPlayer); + // + // int lives = _lives.get(event.GetPlayer()); + // + // if (lives <= 0) + // return; + // + // event.GetPlayer().getInventory().setItem(8, + // ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, lives, + // C.cGreen + C.Bold + lives + " Lives Remaining")); + // } @Override public void EndCheck() @@ -261,23 +488,24 @@ public class WitherGame extends TeamGame implements IBlockRestorer if (!IsLive()) return; - //Players Quit - if (GetPlayers(true).size() < 2) + // Players Quit + if (GetPlayers(true).size() < 1) { SetState(GameState.End); + _locationsOfBlocks.clear(); } - + GameTeam winner = null; - - //Wither Win + + // Wither Win if (UtilTime.elapsed(this.GetStateTime(), _gameTime)) winner = _runners; - - //Runner Win + + // Runner Win if (_runners.GetPlayers(true).isEmpty()) winner = _withers; - - //Set Win + + // Set Win if (winner != null) { AnnounceEnd(winner); @@ -295,8 +523,9 @@ public class WitherGame extends TeamGame implements IBlockRestorer AddGems(player, 10, "Participation", false, false); } - //End + // End SetState(GameState.End); + _locationsOfBlocks.clear(); } } @@ -306,33 +535,40 @@ public class WitherGame extends TeamGame implements IBlockRestorer { if (!InProgress()) return; - + if (event.getType() != UpdateType.FAST) return; - -// int lives = 0; -// for (int i : _lives.values()) -// lives += i; - //Wipe Last + // int lives = 0; + // for (int i : _lives.values()) + // lives += i; + + // Wipe Last Scoreboard.Reset(); - + Scoreboard.WriteBlank(); Scoreboard.Write(_runners.GetColor() + C.Bold + _runners.GetName()); - Scoreboard.Write(_runners.GetColor() + "" + _runners.GetPlayers(true).size() + " Players"); - + Scoreboard.Write(_runners.GetColor() + "" + + _runners.GetPlayers(true).size() + " Players"); + Scoreboard.WriteBlank(); Scoreboard.Write(_withers.GetColor() + C.Bold + _withers.GetName()); - Scoreboard.Write(_withers.GetColor() + "" + _withers.GetPlayers(true).size() + " Players"); - -// Scoreboard.WriteBlank(); -// Scoreboard.Write(C.cYellow + C.Bold + "Humans Alive"); -// Scoreboard.Write(lives + " / " + (_lives.size() * _livesPerPlayer)); - + Scoreboard.Write(_withers.GetColor() + "" + + _withers.GetPlayers(true).size() + " Players"); + + // Scoreboard.WriteBlank(); + // Scoreboard.Write(C.cYellow + C.Bold + "Humans Alive"); + // Scoreboard.Write(lives + " / " + (_lives.size() * _livesPerPlayer)); + Scoreboard.WriteBlank(); Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _gameTime - (System.currentTimeMillis() - this.GetStateTime())), 1)); - + Scoreboard.Write(UtilTime.MakeStr( + Math.max( + 0, + _gameTime + - (System.currentTimeMillis() - this + .GetStateTime())), 1)); + Scoreboard.Draw(); } @@ -344,7 +580,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer return _runners; } - + @Override public boolean CanJoinTeam(GameTeam team) { @@ -352,42 +588,57 @@ public class WitherGame extends TeamGame implements IBlockRestorer { return team.GetSize() < getRequiredWithers(); } - + return team.GetSize() < GetPlayers(true).size() - getRequiredWithers(); } - + public int getRequiredWithers() { - return (int)(GetPlayers(true).size()/_witherFactor); + return (int) (GetPlayers(true).size() / _witherFactor); } - + @EventHandler public void witherMovement(UpdateEvent event) { if (!IsLive()) return; - + if (event.getType() != UpdateType.FASTER) return; - + + Location _spawn = GetTeamList().get(1).GetSpawn(); for (Player player : _withers.GetPlayers(true)) { ArrayList collisions = new ArrayList(); + + // Fly Speed - //Fly Speed - double speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006; - - if (speed > 0.16) + double distanceToGround = player.getLocation().distance(new Location(_spawn.getWorld(), player.getLocation().getX(), _spawn.getY(), player.getLocation().getZ())); + double speed; + + if (distanceToGround < 8) + { speed = 0.16; - - if (speed < 0.016) + } + else + { + speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006; + } + + if (distanceToGround < 4) + { speed = 0.016; - - player.setFlySpeed((float)speed); - - - //Bump - for (Block block : UtilBlock.getInRadius(player.getLocation().add(0, 0.5, 0), 1.5d).keySet()) + } + else + { + speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006; + } + + player.setFlySpeed((float) speed); + + // Bump + for (Block block : UtilBlock.getInRadius( + player.getLocation().add(0, 0.5, 0), 1.5d).keySet()) { if (!UtilBlock.airFoliage(block)) { @@ -395,15 +646,17 @@ public class WitherGame extends TeamGame implements IBlockRestorer } } - Vector vec = UtilAlg.getAverageBump(player.getLocation(), collisions); - + Vector vec = UtilAlg.getAverageBump(player.getLocation(), + collisions); + if (vec == null) continue; - + UtilAction.velocity(player, vec, 0.6, false, 0, 0.4, 10, true); - -// if (player.getLocation().getY() < _yLimit + 6) -// UtilAction.velocity(player, new Vector(0, 1, 0), 0.6, false, 0, 0, 10, true); + + // if (player.getLocation().getY() < _yLimit + 6) + // UtilAction.velocity(player, new Vector(0, 1, 0), 0.6, false, 0, + // 0, 10, true); } } @@ -411,139 +664,153 @@ public class WitherGame extends TeamGame implements IBlockRestorer public void addBlocks(Set blocks) { Iterator blockIter = blocks.iterator(); - + while (blockIter.hasNext()) { Block block = blockIter.next(); - - if (block.getType() == Material.BEDROCK || block.getType() == Material.IRON_BLOCK) + + if (block.getType() == Material.BEDROCK + || block.getType() == Material.IRON_BLOCK) blockIter.remove(); - + else if (!isInsideMap(block.getLocation())) blockIter.remove(); - -// else if (UtilAlg.inBoundingBox(block.getLocation(), _safeA, _safeB) || UtilAlg.inBoundingBox(block.getLocation(), _spawnA, _spawnB)) -// blockIter.remove(); + + // else if (UtilAlg.inBoundingBox(block.getLocation(), _safeA, + // _safeB) || UtilAlg.inBoundingBox(block.getLocation(), _spawnA, + // _spawnB)) + // blockIter.remove(); } - + for (Block block : blocks) _blocks.add(new BlockData(block)); } - + @Override public void restoreBlock(Location loc, double radius) { Iterator dataIt = _blocks.iterator(); - + while (dataIt.hasNext()) { BlockData data = dataIt.next(); - - double dist = UtilMath.offset(loc, data.Block.getLocation().add(0.5, 0.5, 0.5)); - + + double dist = UtilMath.offset(loc, + data.Block.getLocation().add(0.5, 0.5, 0.5)); + if (dist < radius) { - Manager.GetBlockRestore().add(data.Block, 0, (byte) 0, data.Material.getId(), data.Data, (long) (6000 * (dist / radius))); + Manager.GetBlockRestore().add(data.Block, 0, (byte) 0, + data.Material.getId(), data.Data, + (long) (6000 * (dist / radius))); dataIt.remove(); } } } -// @EventHandler -// public void cleanLives(PlayerQuitEvent event) -// { -// _lives.remove(event.getPlayer()); -// } - -// @EventHandler -// public void livesUpdate(UpdateEvent event) -// { -// if (!IsLive()) -// return; -// -// if (event.getType() != UpdateType.FASTER) -// return; -// -// Iterator playerIter = _lives.keySet().iterator(); -// -// while (playerIter.hasNext()) -// { -// Player player = playerIter.next(); -// -// if (!player.isOnline() || !_runners.HasPlayer(player)) -// playerIter.remove(); -// } -// } - + // @EventHandler + // public void cleanLives(PlayerQuitEvent event) + // { + // _lives.remove(event.getPlayer()); + // } + + // @EventHandler + // public void livesUpdate(UpdateEvent event) + // { + // if (!IsLive()) + // return; + // + // if (event.getType() != UpdateType.FASTER) + // return; + // + // Iterator playerIter = _lives.keySet().iterator(); + // + // while (playerIter.hasNext()) + // { + // Player player = playerIter.next(); + // + // if (!player.isOnline() || !_runners.HasPlayer(player)) + // playerIter.remove(); + // } + // } + @EventHandler public void arrowDamage(CustomDamageEvent event) { if (event.GetProjectile() == null) return; - + event.AddMult(GetName(), "Arrow Mod", 0.75, false); - } - + } + @EventHandler(priority = EventPriority.HIGHEST) public void damageOut(CustomDamageEvent event) { if (event.IsCancelled()) return; - + if (event.GetDamageePlayer() == null) return; - + if (event.GetDamage() < event.GetDamageePlayer().getHealth()) return; - + event.SetCancelled("Fake Death"); - + event.GetDamageePlayer().playEffect(EntityEffect.HURT); - + playerOut(event.GetDamageePlayer()); - + if (event.GetDamagerPlayer(true) != null) { - AddGems(event.GetDamagerPlayer(true), 2, "Humans Stunned", true, true); - - Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen + event.GetDamageePlayer().getName() + C.cGray + " was killed by " + C.cRed + event.GetDamagerPlayer(true).getName() + C.cGray + "."); + AddGems(event.GetDamagerPlayer(true), 2, "Humans Stunned", true, + true); + + Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen + + event.GetDamageePlayer().getName() + C.cGray + + " was killed by " + C.cRed + + event.GetDamagerPlayer(true).getName() + C.cGray + "."); } else { - Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen + event.GetDamageePlayer().getName() + C.cGray + " was killed."); + Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen + + event.GetDamageePlayer().getName() + C.cGray + + " was killed."); } } - + public void playerOut(Player player) { - //State + // State SetPlayerState(player, PlayerState.OUT); player.setHealth(20); - + player.setFlySpeed(0.1f); - //Conditions - Manager.GetCondition().Factory().Blind("Hit", player, player, 1.5, 0, false, false, false); - Manager.GetCondition().Factory().Cloak("Hit", player, player, 9999, false, false); + // Conditions + Manager.GetCondition().Factory() + .Blind("Hit", player, player, 1.5, 0, false, false, false); + Manager.GetCondition().Factory() + .Cloak("Hit", player, player, 9999, false, false); - //Settings + // Settings player.setAllowFlight(true); player.setFlying(true); - ((CraftPlayer)player).getHandle().spectating = true; - ((CraftPlayer)player).getHandle().k = false; + ((CraftPlayer) player).getHandle().spectating = true; + ((CraftPlayer) player).getHandle().k = false; - player.setVelocity(new Vector(0,1.2,0)); + player.setVelocity(new Vector(0, 1.2, 0)); _doubles.put(player, new PlayerCopy(this, player, ChatColor.YELLOW)); } - public void playerIn(final Player player, final LivingEntity copy) + public void playerIn(final Player player, final LivingEntity copy, Player revivedBy) { - //State + // State SetPlayerState(player, PlayerState.IN); player.setHealth(20); - //Teleport + // Teleport if (copy != null) { Location loc = player.getLocation(); @@ -553,43 +820,56 @@ public class WitherGame extends TeamGame implements IBlockRestorer player.teleport(loc); } - //Settings + // Settings player.setAllowFlight(false); player.setFlying(false); - ((CraftPlayer)player).getHandle().spectating = false; - ((CraftPlayer)player).getHandle().k = true; - - //Items + ((CraftPlayer) player).getHandle().spectating = false; + ((CraftPlayer) player).getHandle().k = true; + + // Items player.getInventory().remove(Material.WATCH); player.getInventory().remove(Material.COMPASS); - //Inform - UtilPlayer.message(player, F.main("Game", "You have been revived!")); + // Inform + if(revivedBy != null) + { + UtilPlayer.message(player, F.main("Game", "You have been revived by " + C.cGold + revivedBy.getName())); + } + else + { + UtilPlayer.message(player, F.main("Game", "You have been revived!")); + } - //Delayed Visibility + // Delayed Visibility if (copy != null) { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - //Remove Invis - if (IsAlive(player)) - Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, null); + UtilServer + .getServer() + .getScheduler() + .scheduleSyncDelayedTask(Manager.getPlugin(), + new Runnable() + { + public void run() + { + // Remove Invis + if (IsAlive(player)) + Manager.GetCondition().EndCondition( + player, ConditionType.CLOAK, + null); - //Remove Copy - copy.remove(); - } - }, 4); + // Remove Copy + copy.remove(); + } + }, 4); } } - + @EventHandler public void revive(ProjectileHitEvent event) { if (!IsLive()) return; - + if (!(event.getEntity() instanceof ThrownPotion)) return; @@ -599,12 +879,13 @@ public class WitherGame extends TeamGame implements IBlockRestorer if (!(event.getEntity().getShooter() instanceof Player)) return; - Player thrower = (Player)event.getEntity().getShooter(); + Player thrower = (Player) event.getEntity().getShooter(); GameTeam throwerTeam = GetTeam(thrower); - if (throwerTeam == null) return; + if (throwerTeam == null) + return; - //Revive + // Revive a copy Iterator copyIterator = _doubles.values().iterator(); while (copyIterator.hasNext()) { @@ -614,39 +895,43 @@ public class WitherGame extends TeamGame implements IBlockRestorer if (otherTeam == null || !otherTeam.equals(throwerTeam)) continue; - if (UtilMath.offset(copy.GetEntity().getLocation().add(0,1,0), event.getEntity().getLocation()) > 3) + if (UtilMath.offset(copy.GetEntity().getLocation().add(0, 1, 0), + event.getEntity().getLocation()) > 3) continue; - playerIn(copy.GetPlayer(), copy.GetEntity()); + playerIn(copy.GetPlayer(), copy.GetEntity(), thrower); copyIterator.remove(); AddGems(thrower, 3, "Revived Ally", true, true); + + Bukkit.getPluginManager().callEvent(new HumanReviveEvent(thrower, copy.GetPlayer())); } - //Revive - for (Player player : GetPlayers(true)) - { - GameTeam otherTeam = GetTeam(player); - if (otherTeam == null || !otherTeam.equals(throwerTeam)) - continue; - - if (UtilMath.offset(player.getLocation().add(0,1,0), event.getEntity().getLocation()) > 3) - continue; - - playerIn(player, null); - } + // Revive a player +// for (Player player : GetPlayers(true)) +// { +// GameTeam otherTeam = GetTeam(player); +// if (otherTeam == null || !otherTeam.equals(throwerTeam)) +// continue; +// +// if (UtilMath.offset(player.getLocation().add(0, 1, 0), event +// .getEntity().getLocation()) > 3) +// continue; +// +// playerIn(player, null, thrower); +// } } - + @EventHandler public void removePotionEffect(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - + for (Player player : GetPlayers(true)) player.removePotionEffect(PotionEffectType.WATER_BREATHING); } - + @EventHandler public void skeletonDamage(CustomDamageEvent event) { @@ -659,7 +944,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer } } } - + @EventHandler public void skeletonCombust(EntityCombustEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/events/HumanReviveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/events/HumanReviveEvent.java new file mode 100644 index 000000000..6cc0be5e6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/events/HumanReviveEvent.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.wither.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class HumanReviveEvent extends PlayerEvent +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private final Player _revivedPlayer; + + public HumanReviveEvent(Player who, Player revivedPlayer) + { + super(who); + + _revivedPlayer = revivedPlayer; + } + + public Player getRevivedPlayer() + { + return _revivedPlayer; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java index 5fb97dbe3..bfdbbb8ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java @@ -24,22 +24,20 @@ public class KitHumanArcher extends Kit { public KitHumanArcher(ArcadeManager manager) { - super(manager, "Human Archer", KitAvailability.Free, + super(manager, "Human Archer", KitAvailability.Free, - new String[] - { - "" - }, + new String[] + { + "" + }, - new Perk[] - { + new Perk[] + { new PerkDoubleJump("Double Jump", 1.2, 1, true, 4000, true), new PerkWitherArrowBlind(6), new PerkFletcher(4, 4, true), - - }, - EntityType.ZOMBIE, - null); + + }, EntityType.ZOMBIE, null); } @@ -48,20 +46,20 @@ public class KitHumanArcher extends Kit { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); - - ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 - PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); + + ItemStack potion = new ItemStack(Material.POTION, 2, (short) 16429); // 16422 + PotionMeta potionMeta = (PotionMeta) potion.getItemMeta(); potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion"); potion.setItemMeta(potionMeta); player.getInventory().addItem(potion); - + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); } - + @Override - public void SpawnCustom(LivingEntity ent) + public void SpawnCustom(LivingEntity ent) { - + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanEditor.java new file mode 100644 index 000000000..25c0098b1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanEditor.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.wither.kit; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; + +public class KitHumanEditor extends Kit +{ + public KitHumanEditor(ArcadeManager manager) + { + super(manager, "Human Editor", KitAvailability.Gem, 5000, + new String[] + { + " ", "Can " + C.cYellow + "Edit " + C.cGray + "the terrain to they and their comrade's benefits", " " + }, + new Perk[] + { + new PerkDoubleJump("Double Jump", 1, 0.8, true, 6000, true), + }, + EntityType.ZOMBIE, new ItemStack(Material.STONE_PICKAXE)); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_PICKAXE)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SPADE)); + + ItemStack potion = new ItemStack(Material.POTION, 2, (short) 16429); // 16422 + PotionMeta potionMeta = (PotionMeta) potion.getItemMeta(); + potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion"); + potion.setItemMeta(potionMeta); + player.getInventory().addItem(potion); + + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanBuilder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanMedic.java similarity index 86% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanBuilder.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanMedic.java index d6c168aa4..095fcbb97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanBuilder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanMedic.java @@ -18,12 +18,13 @@ import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkBlockRestorer; import nautilus.game.arcade.kit.perks.PerkDoubleJump; import nautilus.game.arcade.kit.perks.PerkIronShell; +import nautilus.game.arcade.kit.perks.PerkWitherMedicRefill; -public class KitHumanBuilder extends Kit +public class KitHumanMedic extends Kit { - public KitHumanBuilder(ArcadeManager manager) + public KitHumanMedic(ArcadeManager manager) { - super(manager, "Human Builder", KitAvailability.Free, + super(manager, "Human Medic", KitAvailability.Gem, 2000, new String[] { @@ -33,7 +34,7 @@ public class KitHumanBuilder extends Kit new Perk[] { new PerkDoubleJump("Double Jump", 1, 0.8, true, 6000, true), - new PerkIronShell(), + new PerkWitherMedicRefill(45, 1), new PerkBlockRestorer() }, EntityType.ZOMBIE, @@ -45,7 +46,9 @@ public class KitHumanBuilder extends Kit public void GiveItems(Player player) { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SPADE)); + + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); @@ -53,8 +56,6 @@ public class KitHumanBuilder extends Kit potion.setItemMeta(potionMeta); player.getInventory().addItem(potion); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java index 72a3e93de..92c03e455 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java @@ -26,57 +26,60 @@ public class KitWitherMinion extends Kit { public KitWitherMinion(ArcadeManager manager) { - super(manager, "Wither", KitAvailability.Free, + super(manager, "Wither", KitAvailability.Free, - new String[] - { - "" - }, + new String[] + { + "" + }, - new Perk[] - { - new PerkWitherArrows(), - new PerkWitherAttack(), - new PerkWitherMinion() - }, - EntityType.WITHER, - null); + new Perk[] + { + new PerkWitherArrows(), new PerkWitherAttack(), + new PerkWitherMinion(), new PerkWitherCompassScent() + }, EntityType.WITHER, null); } - -// @Override -// public void SpawnCustom(LivingEntity ent) -// { -// ent.setMaxHealth(300); -// ent.setHealth(300); -// -// DisguiseWither disguise = new DisguiseWither(ent); -// disguise.SetName(C.cYellow + "Wither"); -// disguise.SetCustomNameVisible(true); -// Manager.GetDisguise().disguise(disguise); -// } - - + + // @Override + // public void SpawnCustom(LivingEntity ent) + // { + // ent.setMaxHealth(300); + // ent.setHealth(300); + // + // DisguiseWither disguise = new DisguiseWither(ent); + // disguise.SetName(C.cYellow + "Wither"); + // disguise.SetCustomNameVisible(true); + // Manager.GetDisguise().disguise(disguise); + // } @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, - C.cYellow + C.Bold + "Left-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Wither Skull")); - - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, - C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Skeletal Minions")); - - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.COMPASS, (byte)0, 1, - C.cYellow + C.Bold + "Human Finder X-9000")); + public void GiveItems(Player player) + { + player.getInventory().addItem( + ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, + (byte) 0, 1, C.cYellow + C.Bold + "Left-Click" + + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + + "Wither Skull")); - //Disguise + player.getInventory().addItem( + ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, + (byte) 0, 1, C.cYellow + C.Bold + "Right-Click" + + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + + "Skeletal Minions")); + + player.getInventory().addItem( + ItemStackFactory.Instance + .CreateStack(Material.COMPASS, (byte) 0, 1, C.cYellow + + C.Bold + "Human Finder X-9000")); + + // Disguise DisguiseWither disguise = new DisguiseWither(player); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); + if (Manager.GetGame().GetTeam(player) != null) + disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + + player.getName()); + else disguise.setName(player.getName()); disguise.setCustomNameVisible(true); Manager.GetDisguise().disguise(disguise); @@ -87,25 +90,25 @@ public class KitWitherMinion extends Kit { if (event.IsCancelled()) return; - + Player player = event.GetDamageePlayer(); if (player == null) return; - + if (HasKit(player)) event.SetCancelled("Wither Immunity"); } - + @EventHandler(priority = EventPriority.LOWEST) public void witherMeleeCancel(CustomDamageEvent event) { if (event.IsCancelled()) return; - + Player player = event.GetDamagerPlayer(true); if (player == null) return; - + if (!HasKit(player)) return; @@ -120,7 +123,7 @@ public class KitWitherMinion extends Kit { if (event.getType() != UpdateType.TICK) return; - + for (Player player : UtilServer.getPlayers()) { if (!HasKit(player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index f68614c57..01de44716 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -155,6 +155,7 @@ public class Wizards extends SoloGame _wizard = new WizardSpellMenu("Wizard Spell Menu", getArcadeManager().getPlugin(), this); + AnnounceStay = false; BlockBreak = true; BlockPlace = true; ItemPickup = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java new file mode 100644 index 000000000..a56b7e67e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java @@ -0,0 +1,45 @@ +package nautilus.game.arcade.gui.privateServer.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.gui.privateServer.PrivateServerShop; + +/** + * Created by WilliamTiger. + * All the code and any API's associated with it + * are not to be used anywhere else without written + * consent of William Burns. 2015. + * 08/07/2015 + */ +public class ChooseMapButton implements IButton +{ + private ArcadeManager _arcadeManager; + private PrivateServerShop _privateServerShop; + private GameType _gameType; + private String _map; + + public ChooseMapButton(ArcadeManager arcadeManager, PrivateServerShop privateServerShop, GameType gameType, String map) + { + _arcadeManager = arcadeManager; + _privateServerShop = privateServerShop; + _gameType = gameType; + _map = map; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _arcadeManager.GetGameCreationManager().MapSource = _gameType.GetName(); + if(_gameType.getMapSource() != null) + _arcadeManager.GetGameCreationManager().MapSource = _gameType.getMapSource()[0].GetName(); + + _arcadeManager.GetGameCreationManager().MapPref = _map; + _arcadeManager.GetGame().setGame(_gameType, player, true); + player.closeInventory(); + return; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/GameVotingButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/GameVotingButton.java new file mode 100644 index 000000000..a3193d8f1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/GameVotingButton.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.gui.privateServer.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.privateServer.PrivateServerShop; +import nautilus.game.arcade.gui.privateServer.page.GameVotingPage; + +/** + * Created by WilliamTiger. + * All the code and any API's associated with it + * are not to be used anywhere else without written + * consent of William Burns. 2015. + * 24/07/15 + */ +public class GameVotingButton implements IButton +{ + private ArcadeManager _arcadeManager; + private PrivateServerShop _shop; + + public GameVotingButton(ArcadeManager arcadeManager, PrivateServerShop shop) + { + _shop = shop; + _arcadeManager = arcadeManager; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _shop.openPageForPlayer(player, new GameVotingPage(_arcadeManager, _shop, player)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/WhitelistButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/WhitelistButton.java new file mode 100644 index 000000000..30a48c15e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/WhitelistButton.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.gui.privateServer.button; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.privateServer.PrivateServerShop; +import nautilus.game.arcade.gui.privateServer.page.WhitelistedPage; + +/** + * Created by WilliamTiger. + * All the code and any API's associated with it + * are not to be used anywhere else without written + * consent of William Burns. 2015. + * 29/07/15 + */ +public class WhitelistButton implements IButton +{ + private ArcadeManager _arcadeManager; + private PrivateServerShop _shop; + + public WhitelistButton(ArcadeManager arcadeManager, PrivateServerShop shop) + { + _shop = shop; + _arcadeManager = arcadeManager; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/BasePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/BasePage.java index f0bdac9d9..fe3555ce8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/BasePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/BasePage.java @@ -44,6 +44,18 @@ public abstract class BasePage extends ShopPageBase enabledGames = getPlugin().GetServerConfig().GameList; + //Old code I'm not removing in-case the old style is wanted. - William + /* int arcadeSlot = 9; int classicSlot = 13; int survivalSlot = 15; @@ -64,13 +68,40 @@ public class EditRotationPage extends BasePage addGameButton(slot, type, enabledGames.contains(type)); } + */ + + ArrayList allowedCats = new ArrayList(); + allowedCats.add(GameCategory.ARCADE); + allowedCats.add(GameCategory.CLASSICS); + allowedCats.add(GameCategory.SURVIVAL); + allowedCats.add(GameCategory.CHAMPIONS); + allowedCats.add(GameCategory.EXTRA); + allowedCats.add(GameCategory.TEAM_VARIANT); + + int gameSlot = 9; + for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) + { + if (!allowedCats.contains(cat)) + continue; + + for (GameType type : _manager.getGames(getPlayer()).get(cat)) + { + addGameButton(gameSlot, type, enabledGames.contains(type)); + gameSlot++; + } + } } private void addGameButton(int slot, final GameType type, boolean enabled) { - String titleString = ChatColor.RESET + (enabled ? C.cGreen : C.cRed) + ChatColor.BOLD + type.GetLobbyName(); + String titleString = ChatColor.RESET + (enabled ? C.cGreen : C.cRed) + ChatColor.BOLD + type.GetName(); String infoString = ChatColor.RESET + C.cGray + (enabled ? "Click to Disable" : "Click to Enable"); - ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), titleString, new String[]{infoString}, 1, false, false); + String[] lore = new String[]{infoString}; + if (_manager.hasWarning().contains(type)) + { + lore = new String[]{infoString, "§1", "§c§lWARNING: §fThis game was rejected!"}; + } + ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), titleString, lore, 1, false, false); int itemCount = enabled ? 1 : 0; addButtonFakeCount(slot, shopItem, new IButton() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java new file mode 100644 index 000000000..323630e5e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java @@ -0,0 +1,218 @@ +package nautilus.game.arcade.gui.privateServer.page; + +import java.util.ArrayList; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.game.GameCategory; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.gui.privateServer.PrivateServerShop; + +/** + * Created by WilliamTiger. + * All the code and any API's associated with it + * are not to be used anywhere else without written + * consent of William Burns. 2015. + * 24/07/15 + */ +public class GameVotingPage extends BasePage +{ + public GameVotingPage(ArcadeManager plugin, PrivateServerShop shop, Player player) + { + super(plugin, shop, "Game Voting Menu", player, 54); + buildPage(); + } + + @Override + protected void buildPage() + { + boolean host = getPlugin().GetGameHostManager().isHost(getPlayer()); + + if (host) + { + addBackButton(4); + addStartVoteButton(0); + addEndVoteButton(8); + addPickHighestButton(1); + } + else + { + addCloseButton(4); + } + + ArrayList allowedCats = new ArrayList(); + allowedCats.add(GameCategory.ARCADE); + allowedCats.add(GameCategory.CLASSICS); + allowedCats.add(GameCategory.SURVIVAL); + allowedCats.add(GameCategory.CHAMPIONS); + allowedCats.add(GameCategory.EXTRA); + allowedCats.add(GameCategory.TEAM_VARIANT); + + int gameSlot = 9; + for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) + { + if (!allowedCats.contains(cat)) + continue; + + for (GameType type : _manager.getGames(getPlayer()).get(cat)) + { + addGameButton(gameSlot, type); + gameSlot++; + } + } + } + + private void addPickHighestButton(int slot) + { + ShopItem item = new ShopItem(Material.DIAMOND_BLOCK, (byte)0, "§b§lSelect Highest Voted Game", new String[]{"§7Game: §e" + getHighestVoted().GetName()}, 1, false, false); + addButton(slot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (!_manager.isHost(player)) //Double Check... + return; + + _manager.setVoteInProgress(false); + getPlugin().GetGame().setGame(getHighestVoted(), player, true); + } + }); + } + + private GameType getHighestVoted() + { + GameType highest = GameType.Skywars; + int highestVotes = getVotes(GameType.Skywars); + for (GameType cur : _manager.getVotes().values()) + { + if (getVotes(cur) > highestVotes) + { + highestVotes = getVotes(cur); + highest = cur; + } + } + return highest; + } + + private int getVotes(GameType type) + { + int i = 0; + for (GameType cur : _manager.getVotes().values()) + { + if (cur.equals(type)) + i++; + } + return i; + } + + private void addCloseButton(int slot) + { + ShopItem item = new ShopItem(Material.BED, (byte)0, "§cClose Menu", new String[]{}, 1, false, false); + addButton(slot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + player.closeInventory(); + } + }); + } + + private void addEndVoteButton(int slot) + { + ShopItem item = new ShopItem(Material.REDSTONE_BLOCK, (byte)0, "§c§lEnd Vote", new String[]{}, 1, false, false); + addButton(slot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (!_manager.isHost(player)) //Double Check... + return; + + getPlugin().GetGameHostManager().setVoteInProgress(false); + for (Player p : UtilServer.getPlayers()) + { + UtilPlayer.message(p, F.main("Vote", "The vote has ended!")); + } + refresh(); + } + }); + } + + private void addStartVoteButton(int slot) + { + String warning = "§c§lWARNING: §fThis will reset current votes!"; + ShopItem item = new ShopItem(Material.EMERALD_BLOCK, (byte)0, "Start Vote", new String[]{warning}, 1, false, false); + addButton(slot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (!_manager.isHost(player)) //Double Check... + return; + + getPlugin().GetGameHostManager().setVoteInProgress(true); + getPlugin().GetGameHostManager().getVotes().clear(); + for (Player p : UtilServer.getPlayers()) + { + UtilPlayer.message(p, F.main("Vote", "A vote has started! Use " + F.skill("/vote") + " to vote.")); + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1F, 1F); + } + refresh(); + } + }); + } + + private void addGameButton(int slot, final GameType type) + { + String click = "§7Click to vote for this Game Type"; + int votes = 0; + for (GameType cur : getPlugin().GetGameHostManager().getVotes().values()) + { + if (cur.equals(type)) + votes++; + } + String curVotes = "§7Votes: §e" + votes; + String[] lore = new String[]{click, curVotes}; + if (_manager.hasWarning().contains(type)) + { + lore = new String[]{click, curVotes, "§1", "§c§lWARNING: §fThis game was rejected!"}; + } + ShopItem item = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetName(), new String[]{click, curVotes}, 1, false, false); + if (votes >= 1) + { + addButton(slot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getPlugin().GetGameHostManager().getVotes().put(player.getName(), type); + refresh(); + } + }); + return; + } + else + { + addButtonFakeCount(slot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getPlugin().GetGameHostManager().getVotes().put(player.getName(), type); + refresh(); + } + }, votes); + return; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java index 5afc072b6..26adc68ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.button.BanButton; import nautilus.game.arcade.gui.privateServer.button.EditRotationButton; +import nautilus.game.arcade.gui.privateServer.button.GameVotingButton; import nautilus.game.arcade.gui.privateServer.button.GiveAdminButton; import nautilus.game.arcade.gui.privateServer.button.KillButton; import nautilus.game.arcade.gui.privateServer.button.PlayerHeadButton; @@ -25,12 +26,13 @@ import nautilus.game.arcade.gui.privateServer.button.OptionsButton; import nautilus.game.arcade.gui.privateServer.button.StartGameButton; import nautilus.game.arcade.gui.privateServer.button.StopGameButton; import nautilus.game.arcade.gui.privateServer.button.UnbanButton; +import nautilus.game.arcade.gui.privateServer.button.WhitelistButton; public class MenuPage extends BasePage { public MenuPage(ArcadeManager plugin, PrivateServerShop shop, Player player) { - super(plugin, shop, "Private Server Menu", player, 9*3); + super(plugin, shop, "Private Server Menu", player, 9*4); buildPage(); } @@ -87,14 +89,20 @@ public class MenuPage extends BasePage if (host) { GiveAdminButton giveAdminButton = new GiveAdminButton(getPlugin(), getShop()); - addButton(4 + 9, new ShopItem(Material.DIAMOND_SWORD, "Give Admin", new String[]{}, 1, false), giveAdminButton); + addButton(4 + 9, new ShopItem(Material.DIAMOND_SWORD, "Give Co-Host", new String[]{}, 1, false), giveAdminButton); RemoveAdminButton removeAdminButton = new RemoveAdminButton(getPlugin(), getShop()); - addButton(4 + 18, new ShopItem(Material.GOLD_SWORD, "Remove Admin", new String[]{}, 1, false), removeAdminButton); + addButton(4 + 18, new ShopItem(Material.GOLD_SWORD, "Remove Co-Host", new String[]{}, 1, false), removeAdminButton); KillButton killButton = new KillButton(getPlugin()); addButton(8 + 18, new ShopItem(Material.TNT, "Kill Private Server", new String[]{ChatColor.RESET + C.cGray + "Shift-Right Click to Kill Private Server"}, 1, false), killButton); + + GameVotingButton votingButton = new GameVotingButton(getPlugin(), getShop()); + addButton(3 + 27, new ShopItem(Material.BOOKSHELF, "Game Voting", new String[]{}, 1, false), votingButton); + + WhitelistButton whitelistButton = new WhitelistButton(getPlugin(), getShop()); + addButton(5 + 27, new ShopItem(Material.PAPER, "Whitelisted Players", new String[]{}, 1, false), whitelistButton); } OptionsButton optionsButton = new OptionsButton(getPlugin(), getShop()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java index 9247d2831..e68206e2f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java @@ -43,7 +43,7 @@ public class OptionsPage extends BasePage } }); - buildPreference(13, Material.PAPER, "Enforce Whitelist (Coming Soon)", false, new IButton() + buildPreference(13, Material.PAPER, "Enforce Whitelist", _config.PlayerServerWhitelist, new IButton() { @Override public void onClick(Player player, ClickType clickType) @@ -116,12 +116,19 @@ public class OptionsPage extends BasePage private void toggleWhitelist() { - // TODO CHISSPIE + _config.PlayerServerWhitelist = !_config.PlayerServerWhitelist; + if (_config.PlayerServerWhitelist == true) + _config.PublicServer = false; refresh(); } private void togglePublic() { + if (_config.PlayerServerWhitelist==true) + { + _config.PublicServer = false; + return; + } _config.PublicServer = !_config.PublicServer; refresh(); } @@ -138,6 +145,14 @@ public class OptionsPage extends BasePage ChatColor.RED + " ", ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") }; + if (name.equalsIgnoreCase("Enforce Whitelist")) + { + description = new String[] { + "" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"), + ChatColor.RED + " ", + ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable"), "", "§7Use §a/whitelist §e" }; + } + addButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); addButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte) 10 : (byte) 8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java index a7a872155..c2f6f2817 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java @@ -1,5 +1,9 @@ package nautilus.game.arcade.gui.privateServer.page; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -13,9 +17,20 @@ import nautilus.game.arcade.gui.privateServer.PrivateServerShop; public abstract class PlayerPage extends BasePage { + private List _players; + private boolean useOtherList; + public PlayerPage(ArcadeManager plugin, PrivateServerShop shop, String pageName, Player player) { super(plugin, shop, pageName, player); + useOtherList = false; + } + + public PlayerPage(ArcadeManager plugin, PrivateServerShop shop, String pageName, Player player, List players) + { + super(plugin, shop, pageName, player); + useOtherList = true; + _players = players; } @Override @@ -23,7 +38,20 @@ public abstract class PlayerPage extends BasePage { addBackButton(4); - Player[] players = UtilServer.getPlayers(); + List players = new ArrayList<>(); + if (useOtherList) + { + players = new ArrayList<>(); + for (String s : _players) + { + players.add(Bukkit.getPlayer(s)); + } + } + else + { + for (Player p : UtilServer.getPlayers()) + players.add(p); + } int slot = 9; for (Player player : players) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java index b8ca9a28e..b17e0009e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java @@ -1,10 +1,14 @@ package nautilus.game.arcade.gui.privateServer.page; +import java.util.ArrayList; +import java.util.List; + import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import mineplex.core.common.util.C; +import mineplex.core.game.GameCategory; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import nautilus.game.arcade.ArcadeManager; @@ -24,6 +28,8 @@ public class SetGamePage extends BasePage { addBackButton(4); + //Old code I'm not removing in-case you want the old style - William. + /* int arcadeSlot = 9; int classicSlot = 13; int survivalSlot = 15; @@ -58,19 +64,59 @@ public class SetGamePage extends BasePage addGameButton(slot, type); } + */ + + ArrayList allowedCats = new ArrayList(); + allowedCats.add(GameCategory.ARCADE); + allowedCats.add(GameCategory.CLASSICS); + allowedCats.add(GameCategory.SURVIVAL); + allowedCats.add(GameCategory.CHAMPIONS); + allowedCats.add(GameCategory.EXTRA); + allowedCats.add(GameCategory.TEAM_VARIANT); + + int gameSlot = 9; + for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) + { + if (!allowedCats.contains(cat)) + continue; + + for (GameType type : _manager.getGames(getPlayer()).get(cat)) + { + addGameButton(gameSlot, type); + gameSlot++; + } + } } private void addGameButton(int slot, final GameType type) { - String infoString = ChatColor.RESET + C.cGray + "Click to make this next Game Type"; - ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetLobbyName(), new String[]{infoString}, 1, false, false); + String infoString = ChatColor.RESET + C.cGray + "Make this next Game Type"; + String space = "§1"; + String left = ChatColor.YELLOW + "Left-Click " + C.cGray + "for a §fRandom Map§7."; + String right = ChatColor.YELLOW + "Right-Click " + C.cGray + "to §fChoose Map§7."; + String[] normLore = new String[]{infoString, space, left, right}; + if (_manager.hasWarning().contains(type)) + { + normLore = new String[]{infoString, space, left, right, "§2", "§c§lWARNING: §fThis game was rejected!"}; + } + ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetName(), normLore, 1, false, false); addButton(slot, shopItem, new IButton() { @Override public void onClick(Player player, ClickType clickType) { - getPlugin().GetGame().setGame(type, player, true); - player.closeInventory(); + if (clickType == ClickType.LEFT) + { + getPlugin().GetGame().setGame(type, player, true); + player.closeInventory(); + return; + } + else if (clickType == ClickType.RIGHT) + { + getShop().openPageForPlayer(player, new ChooseMapPage(getPlugin(), getShop(), player, type)); + return; + } + } }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java new file mode 100644 index 000000000..101ba9a18 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.gui.privateServer.page; + +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.shop.item.IButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.privateServer.PrivateServerShop; + +/** + * Created by WilliamTiger. + * All the code and any API's associated with it + * are not to be used anywhere else without written + * consent of William Burns. 2015. + * 29/07/15 + */ +public class WhitelistedPage extends BasePage +{ + public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player) + { + super(plugin, shop, "Whitelisted Players", player); + buildPage(); + } + + @Override + protected void buildPage() + { + addBackButton(4); + + int slot = 9; + for (final String s : getPlugin().GetGameHostManager().getWhitelist()) + { + ItemStack head = getPlayerHead(s, C.cGreen + C.Bold + s, new String[]{C.cGray + "Click to un-whitelist player"}); + final int i = slot; + addButton(slot, head, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getPlugin().GetGameHostManager().getWhitelist().remove(s); + removeButton(i); + getPlayer().sendMessage(F.main("Whitelist", "§e" + s + " §7is no longer whitelisted.")); + if (Bukkit.getPlayer(s)!=null) + getPlugin().GetPortal().sendToHub(Bukkit.getPlayer(s), "You are no longer whitelisted."); + } + }); + + slot++; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index 8327bcb7e..e23422a01 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -220,8 +220,8 @@ public abstract class Kit implements Listener return _achivementCategory; } - public boolean isYoutuber(Player player) + public boolean hasKitsUnlocked(Player player) { - return Manager.isYoutuber(player); + return Manager.hasKitsUnlocked(player); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java index 1919303f2..ed6346329 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java @@ -2,16 +2,17 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.kit.Perk; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + public class PerkArcticAura extends Perk { public PerkArcticAura() @@ -32,7 +33,10 @@ public class PerkArcticAura extends Perk { if (!Kit.HasKit(player)) continue; - + + if (((CraftPlayer) player).getHandle().spectating) + continue; + double range = 5*player.getExp(); //Blocks diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java index cdc508084..fb8b77d58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java @@ -14,13 +14,13 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.util.Vector; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import nautilus.game.arcade.kit.Perk; public class PerkBlizzard extends Perk @@ -108,8 +108,9 @@ public class PerkBlizzard extends Perk if (damagee == null) return; event.SetCancelled("Blizzard"); - damagee.setVelocity(proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); + UtilAction.velocity(damagee, proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); + //Damage Event if (damagee instanceof Player) if (Recharge.Instance.use((Player)damagee, GetName(), 200, false, false)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneRush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneRush.java index e802a911b..d04a88096 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneRush.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneRush.java @@ -162,7 +162,7 @@ public class PerkBoneRush extends SmashPerk implements IThrown DamageCause.CUSTOM, damage, false, true, false, UtilEnt.getName(data.GetThrower()), reason); - target.setVelocity(data.GetThrown().getVelocity()); + UtilAction.velocity(target, data.GetThrown().getVelocity()); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java index 1f4242400..3e4fbdfc3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java @@ -2,23 +2,29 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Cow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import nautilus.game.arcade.kit.Perk; - public class PerkCharge extends Perk { public PerkCharge() @@ -74,6 +80,19 @@ public class PerkCharge extends Perk //Sound player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 0.75f, 1f); + + if (cur instanceof Player) + { + MilkRemoveEvent e = new MilkRemoveEvent((Player)cur, 1, RemoveType.FLING); + Bukkit.getPluginManager().callEvent(e); + ItemStack bucket = e.GetPlayer().getInventory().getItem(0); + if ((bucket.getType() == Material.MILK_BUCKET) && e.GetMilk() >= 0) + { + bucket.setType(Material.BUCKET); + e.GetPlayer().getInventory().setItem(0, bucket); + } + UtilInv.Update(e.GetPlayer()); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java index 4e1c99624..5a97d8a8f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java @@ -1,40 +1,42 @@ package nautilus.game.arcade.kit.perks; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseCreeper; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.SmashPerk; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + public class PerkCreeperExplode extends SmashPerk { private HashMap _active = new HashMap(); @@ -105,7 +107,7 @@ public class PerkCreeperExplode extends SmashPerk double elapsed = (System.currentTimeMillis() - _active.get(player))/1000d; //Idle in Air - player.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(player); //Sound player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, (float)(0.5 + elapsed), (float)(0.5 + elapsed)); @@ -144,7 +146,15 @@ public class PerkCreeperExplode extends SmashPerk player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, (float)(2 + Math.random()*4), (float)(Math.random() + 0.2)); //Blocks - Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(player.getLocation(), 12).keySet(), player.getLocation(), false); + Collection blocks = UtilBlock.getInRadius(player.getLocation(), 12).keySet(); + Iterator iter = blocks.iterator(); + + while (iter.hasNext()) { + Block b = iter.next(); + + if(b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA || b.getType() == Material.BEDROCK) iter.remove();; + } + Manager.GetExplosion().BlockExplosion(blocks, player.getLocation(), false); //Remove Spawns Iterator spawnIterator = Manager.GetGame().GetTeam(player).GetSpawns().iterator(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java index 4ceaaee33..51883a447 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java @@ -145,7 +145,7 @@ public class PerkDeathsGrasp extends Perk UtilAction.velocity(damagee, UtilAlg.getTrajectory(damagee, damager), 1.8, false, 0, 1, 1.8, true); - damager.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(damager); damager.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_HURT, 1f, 0.7f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java index 45a67cde4..96311faab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java @@ -89,8 +89,8 @@ public class PerkDestructor extends Perk { if (event.isCancelled()) return; - - if (!UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.ENDER_PEARL, (byte) 0)) + + if (!UtilInv.IsItem(event.getItemDrop().getItemStack(), "Seismic Charge", Material.ENDER_PEARL, (byte) 0)) return; //Cancel diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDisruptor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDisruptor.java index 71f774580..844c49551 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDisruptor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDisruptor.java @@ -16,6 +16,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; @@ -126,7 +127,7 @@ public class PerkDisruptor extends Perk _tntMap.remove(event.getItem()); event.getItem().remove(); - event.getPlayer().setVelocity(new Vector(0,0.5,0)); + UtilAction.velocity(event.getPlayer(), new Vector(0, 0.5, 0)); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.EXPLODE, 1f, 2f); event.getPlayer().playEffect(EntityEffect.HURT); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDummy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDummy.java new file mode 100644 index 000000000..aaf8c8bc9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDummy.java @@ -0,0 +1,13 @@ +package nautilus.game.arcade.kit.perks; + +import nautilus.game.arcade.kit.Perk; + +public class PerkDummy extends Perk +{ + + public PerkDummy(String name, String[] perkDesc) + { + super(name, perkDesc); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEggGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEggGun.java index 8530d4b8f..727a2bfc2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEggGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEggGun.java @@ -14,6 +14,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; @@ -130,6 +131,6 @@ public class PerkEggGun extends SmashPerk DamageCause.PROJECTILE, 1, true, true, false, UtilEnt.getName((LivingEntity)egg.getShooter()), GetName()); - event.GetDamageeEntity().setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(event.GetDamageeEntity()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java index c8c2946a3..2907433d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java @@ -17,6 +17,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; @@ -101,7 +102,7 @@ public class PerkFirefly extends SmashPerk //Teleport if (!UtilTime.elapsed(data.Time, 1500) && !superActive) { - data.Player.setVelocity(new Vector(0,0,0));//.teleport(data.Location); + UtilAction.zeroVelocity(data.Player); data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.2f, 0.6f); data.Location = data.Player.getLocation(); @@ -115,8 +116,7 @@ public class PerkFirefly extends SmashPerk //Velocity else if (!UtilTime.elapsed(data.Time, 2500) || superActive) { - data.Player.setVelocity(data.Player.getLocation().getDirection().multiply(superActive ? 0.9 : 0.7).add(new Vector(0,0.15,0))); - //data.Player.setVelocity(data.Location.getDirection().multiply(0.7).add(new Vector(0,0.1,0))); + UtilAction.velocity(data.Player, data.Player.getLocation().getDirection().multiply(superActive ? 0.9 : 0.7).add(new Vector(0,0.15,0))); data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.6f, 1.2f); if (_tick == 0) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java index fd0222205..041bae71c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java @@ -13,6 +13,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -123,7 +124,7 @@ public class PerkFlameDash extends Perk vel.normalize(); vel.setY(0.05); - data.Player.setVelocity(vel); + UtilAction.velocity(data.Player, vel); //Sound data.Player.getWorld().playSound(data.Player.getLocation(), Sound.FIZZ, 0.6f, 1.2f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java index 5c17248c1..9db75a2b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java @@ -100,7 +100,7 @@ public class PerkFlameSlam extends Perk Vector vel = player.getLocation().getDirection(); vel.setY(0); UtilAlg.Normalize(vel); - player.setVelocity(vel.multiply(0.8)); + UtilAction.velocity(player, vel.multiply(0.8)); //Particle UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 5, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFleshArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFleshArrow.java index 5039514ff..e0eb24ebd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFleshArrow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFleshArrow.java @@ -92,7 +92,7 @@ public class PerkFleshArrow extends SmashPerk Manager.GetCondition().Factory().Slow(GetName(), ent, event.GetDamagerEntity(true), 4, 3, false, false, false, false); - ent.setVelocity(new Vector(0,-0.5,0)); + UtilAction.velocity(ent, new Vector(0,-0.5,0)); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java index c49b80976..1db766c34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java @@ -13,6 +13,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -59,7 +60,7 @@ public class PerkIcePath extends Perk if (!Recharge.Instance.use(player, GetName(), 12000, true, true)) return; - player.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(player); player.teleport(player.getLocation().add(0, 0.75, 0)); _data.add(new IcePathData(player)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java index e91dc9742..23134ec56 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java @@ -14,7 +14,7 @@ public class PerkMammoth extends Perk { super("Mammoth", new String[] { - C.cGray + "Take 50% knockback and deal 150% knockback", + C.cGray + "Take 75% knockback and deal 125% knockback", }); } @@ -30,7 +30,7 @@ public class PerkMammoth extends Perk if (!Kit.HasKit(damager)) return; - event.AddKnockback(GetName(), 1.5d); + event.AddKnockback(GetName(), 1.25d); } @EventHandler(priority = EventPriority.HIGH) @@ -45,6 +45,6 @@ public class PerkMammoth extends Perk if (!Kit.HasKit(damagee)) return; - event.AddKnockback(GetName(), 0.5d); + event.AddKnockback(GetName(), 0.75d); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java index e3d65cd81..3844440ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java @@ -131,7 +131,10 @@ public class PerkNeedler extends SmashPerk DamageCause.THORNS, 1.1, true, true, false, damager.getName(), GetName()); - Manager.GetCondition().Factory().Poison(GetName(), event.GetDamageeEntity(), damager, 2, 0, false, false, false); + if(!Manager.GetGame().GetTeam(event.GetDamageePlayer()).equals(Manager.GetGame().GetTeam(damager))) + { + Manager.GetCondition().Factory().Poison(GetName(), event.GetDamageeEntity(), damager, 2, 0, false, false, false); + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java new file mode 100644 index 000000000..5752294ee --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.kit.perks; + +import mineplex.core.common.util.C; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent; +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class PerkNoSpillMilk extends Perk +{ + + public PerkNoSpillMilk(ArcadeManager manager) + { + super("Steady Hands", new String[] + { + C.cGray + "Lose less milk when you die", + C.cGray + "Don't lose your bucket of milk when cows run into you", + }); + } + + @EventHandler + public void onLoseMilk(MilkRemoveEvent event) + { + Player player = event.GetPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (event.GetCause() == RemoveType.DEATH) + { + if (event.GetMilk() > 3) + event.SetMilk(3); + } + + if (event.GetCause() == RemoveType.FLING) + { + event.SetMilk(-1); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java index 31a29a28c..f259ca0a2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java @@ -32,6 +32,14 @@ public class PerkSeismicCow extends Perk { private HashMap _live = new HashMap(); + public PerkSeismicCow(String displayName) + { + super(displayName, new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Shovel to " + C.cGreen + "Seismic Slam" + }); + } + public PerkSeismicCow() { super("Seismic Slam", new String[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java index 9309e6cf4..f3ee858f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java @@ -2,6 +2,19 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -11,23 +24,10 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; - public class PerkSeismicSlam extends Perk { private HashMap _live = new HashMap(); @@ -39,6 +39,21 @@ public class PerkSeismicSlam extends Perk C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam" }); } + + @EventHandler + public void deactivateDeath(PlayerDeathEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!Kit.HasKit(event.getEntity())) + return; + + if (_live.containsKey(event.getEntity())) + { + _live.remove(event.getEntity()); + } + } @EventHandler public void Leap(PlayerInteractEvent event) @@ -109,6 +124,9 @@ public class PerkSeismicSlam extends Perk if (cur.equals(player)) continue; + if (cur instanceof Player && !Manager.IsAlive((Player) cur)) + continue; + //Damage Event Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, damage * targets.get(cur) + 0.5, true, true, false, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java index 8e7ee1331..eea416543 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java @@ -28,7 +28,7 @@ public class PerkSheepHoming extends SmashPerk public PerkSheepHoming() { - super("Homing Sheepiles", new String[] + super("Homing Sheeples", new String[] { }, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java index 8a52c396c..029ef5bf4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java @@ -132,7 +132,7 @@ public class PerkSnowTurret extends SmashPerk if (damagee.equals(_snowball.get(proj))) return; - damagee.setVelocity(proj.getVelocity().multiply(0.3).add(new Vector(0, 0.3, 0))); + UtilAction.velocity(damagee, proj.getVelocity().multiply(0.3).add(new Vector(0, 0.3, 0))); //Damage Event if (!(damagee instanceof LivingEntity)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java index 5106fa728..f2e8b18b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java @@ -73,7 +73,7 @@ public class PerkSpiderLeap extends Perk { if (!UtilBlock.airFoliage(block) && !block.isLiquid()) { - player.setVelocity(new Vector(0,0.2,0)); + UtilAction.velocity(player, new Vector(0, 0.2, 0)); if (!_secondJump.contains(player)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTakedown.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTakedown.java index 4d181426d..040155793 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTakedown.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTakedown.java @@ -112,7 +112,7 @@ public class PerkTakedown extends Perk DamageCause.CUSTOM, 8, true, true, false, damager.getName(), GetName()); - damager.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(damager); //Inform UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(GetName()) + ".")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVanishing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVanishing.java new file mode 100644 index 000000000..9ceb3c76c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVanishing.java @@ -0,0 +1,107 @@ +package nautilus.game.arcade.kit.perks; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class PerkVanishing extends Perk +{ + public PerkVanishing() + { + super("Vanishing Act", new String[] + { + "Become invisible for 1.2 seconds each kill.", + "Attacking with melee removes invisibility." + }); + } + + @EventHandler + public void kill(CombatDeathEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + +// //If it's an arrow kill (OITQ) +// if (!event.GetLog().GetKiller().GetReason().toLowerCase().contains("instagib")) +// return; + + if (!event.GetLog().GetKiller().IsPlayer()) + return; + + Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + + if (killer == null) + return; + + if (!Manager.IsAlive(killer)) + return; + + if (!Kit.HasKit(killer)) + return; + + Manager.GetCondition().Factory().Cloak("Vanishing Act", killer, null, 1.2, false, true); + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, killer.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + + killer.getWorld().playSound(killer.getLocation(), Sound.FIZZ, 1f, 2f); + } + + @EventHandler + public void remove(CustomDamageEvent event) + { + if (event.isCancelled()) + return; + + if (!Manager.GetGame().IsLive()) + return; + + //Arrow damage, ignore it! + if (event.GetDamage() > 10) + return; + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null) + return; + + if (!Manager.IsAlive(damager)) + return; + + if (!Kit.HasKit(damager)) + return; + + Manager.GetCondition().EndCondition(damager, ConditionType.CLOAK, null); + } + +// @EventHandler +// public void remove(UpdateEvent event) +// { +// if (event.getType() != UpdateType.TICK) +// return; +// +// if (!Manager.GetGame().IsLive()) +// return; +// +// for (Player player : Manager.GetGame().GetPlayers(true)) +// { +// if (!Kit.HasKit(player)) +// continue; +// +// if (!UtilPlayer.isChargingBow(player)) +// continue; +// +// if (Manager.GetCondition().IsCloaked(player)) +// Manager.GetCondition().Clean(player); +// } +// } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java index f16829832..e4e6173cb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java @@ -100,7 +100,7 @@ public class PerkWebShot extends SmashPerk implements IThrown DamageCause.PROJECTILE, 6, false, false, false, UtilEnt.getName(data.GetThrower()), GetName()); - target.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(target); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java index 06a5c5b47..8609bcaac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java @@ -2,42 +2,21 @@ package nautilus.game.arcade.kit.perks; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.WitherSkull; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -45,6 +24,19 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.data.IBlockRestorer; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerInteractEvent; + public class PerkWitherAttack extends Perk { private ArrayList _active = new ArrayList(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherCompassScent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherCompassScent.java new file mode 100644 index 000000000..2326d1380 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherCompassScent.java @@ -0,0 +1,169 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.Hologram.HologramTarget; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +public class PerkWitherCompassScent extends Perk +{ + public PerkWitherCompassScent() + { + super("Smell Humans", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with a compass to use " + C.cGreen + "Wither Scent" + }); + } + + @EventHandler + public void compassRightClick(PlayerInteractEvent event) + { + if(event.isCancelled()) + return; + + if(!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.COMPASS)) + return; + + if(!Kit.HasKit(event.getPlayer())) + return; + + if (!Recharge.Instance.use(event.getPlayer(), GetName(), 30*1000, true, true)) + return; + + event.setCancelled(true); + Player player = event.getPlayer(); + + // Code from Wizards changed to WitherGame: + Location loc = player.getEyeLocation().subtract(0, 1, 0); + + final ArrayList colors = new ArrayList(); + + for (int x = -1; x <= 1; x++) + { + + for (int y = -1; y <= 1; y++) + { + + for (int z = -1; z <= 1; z++) + { + colors.add(new Integer[] + { + x, y, z + }); + } + } + } + + Collections.shuffle(colors); + + for (Player enemy : Manager.GetGame().GetPlayers(true)) + { + if (enemy == player) + { + continue; + } + + if(Manager.GetGame().GetTeam(enemy).GetName().contentEquals("Withers")) + { + continue; + } + + final double playerDist = Math.min(7, UtilMath.offset(enemy, player)); + + final Vector traj = UtilAlg.getTrajectory(player.getLocation(), enemy.getEyeLocation()).multiply(0.1); + + final Hologram hologram = new Hologram(Manager.GetGame().getArcadeManager().getHologramManager(), loc.clone().add(0, 0.3, 0) + .add(traj.clone().normalize().multiply(playerDist)), enemy.getName()); + + hologram.setHologramTarget(HologramTarget.WHITELIST); + hologram.addPlayer(player); + + hologram.start(); + + final Location location = loc.clone(); + final Integer[] ints = colors.remove(0); + + new BukkitRunnable() + { + int dist; + int tick; + HashMap locations = new HashMap(); + + public void run() + { + tick++; + + Iterator> itel = locations.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if ((entry.getValue() + tick) % 3 == 0) + { + // Colored redstone dust + UtilParticle.PlayParticle(ParticleType.RED_DUST, entry.getKey(), ints[0], ints[1], ints[2], 1, 0, + ViewDist.LONG, UtilServer.getPlayers()); + } + + if (entry.getValue() < tick) + { + itel.remove(); + } + } + + if (dist <= playerDist * 10) + { + for (int a = 0; a < 2; a++) + { + // Colored redstone dust + UtilParticle.PlayParticle(ParticleType.RED_DUST, location, ints[0], ints[1], ints[2], 1, 0, + ViewDist.LONG, UtilServer.getPlayers()); + + locations.put(location.clone(), tick + 50); + + location.add(traj); + dist++; + } + } + else if (locations.isEmpty()) + { + hologram.stop(); + cancel(); + } + } + }.runTaskTimer(Manager.GetGame().getArcadeManager().getPlugin(), 0, 0); + } + + player.playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1); + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherMedicRefill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherMedicRefill.java new file mode 100644 index 000000000..06a140e6c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherMedicRefill.java @@ -0,0 +1,73 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkWitherMedicRefill extends Perk +{ + private int _max = 0; + private int _time = 0; + + public PerkWitherMedicRefill(int timeInSeconds, int max) + { + super("Healing Hands", new String[] + { + C.cGray + "Receive 1 healing bottle every " + timeInSeconds + " seconds if you're inventory is clearned from a bottle.", + }); + + this._time = timeInSeconds; + this._max = max; + + } + + @EventHandler + public void bottleRefill(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (Manager.isSpectator(player)) + continue; + + if (!Kit.HasKit(player)) + continue; + + if (!Manager.GetGame().IsAlive(player)) + continue; + + if (!Recharge.Instance.use(player, GetName(), _time * 1000, false, false)) + continue; + + //Add + ItemStack potion = new ItemStack(Material.POTION, 1, (short)16429); // 16422 + PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); + potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion"); + potion.setItemMeta(potionMeta); + + if (UtilInv.contains(player, "Revival Potion", Material.POTION, potion.getData().getData(), _max)) + continue; + + player.getInventory().addItem(potion); + + player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 2f, 1f); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherMinion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherMinion.java index d58ec59ad..c0131bc41 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherMinion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherMinion.java @@ -76,7 +76,7 @@ public class PerkWitherMinion extends Perk Manager.GetGame().CreatureAllowOverride = true; - for (int i=0 ; i<3 ; i++) + for (int i=0 ; i<2 ; i++) { Skeleton skel = player.getWorld().spawn(player.getEyeLocation(), Skeleton.class); _ents.add(skel); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java index 8877ef3a5..57a79f2f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java @@ -152,7 +152,7 @@ public class PerkWolf extends SmashPerk _tackle.put(wolf, damagee); wolf.setVelocity(new Vector(0,-0.6,0)); - damagee.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(damagee); //Damage Manager.GetDamage().NewDamageEvent(damagee, damager, null, @@ -190,7 +190,7 @@ public class PerkWolf extends SmashPerk if (UtilMath.offset(wolf, ent) < 2.5) { Manager.GetCondition().Factory().Slow("Cub Table", ent, wolf, 0.9, 1, false, false, false, false); - ent.setVelocity(new Vector(0,-0.3,0)); + UtilAction.velocity(ent, new Vector(0,-0.3,0)); } //Move @@ -305,7 +305,7 @@ public class PerkWolf extends SmashPerk public void StrikeHit(Player damager, LivingEntity damagee) { - damager.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(damager); //Remove Tackle Iterator wolfIterator = _tackle.keySet().iterator(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPack.java index 384ba20bb..b0255ff8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPack.java @@ -538,7 +538,7 @@ public class PerkWolfPack extends Perk public void TackleHit(Player damager, LivingEntity damagee) { - damager.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(damager); Manager.GetDamage().NewDamageEvent(damagee, damager, null, DamageCause.CUSTOM, 7, false, true, false, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieBile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieBile.java index 47835d469..57ef2dc4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieBile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieBile.java @@ -3,17 +3,6 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; import java.util.Iterator; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -30,6 +19,18 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.SmashPerk; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + public class PerkZombieBile extends SmashPerk implements IThrown { private HashMap _active = new HashMap(); @@ -70,6 +71,21 @@ public class PerkZombieBile extends SmashPerk implements IThrown UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } + @EventHandler + public void deactivateDeath(PlayerDeathEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!Kit.HasKit(event.getEntity())) + return; + + if (_active.containsKey(event.getEntity())) + { + _active.remove(event.getEntity()); + } + } + @EventHandler public void update(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index 0f8f37712..5f949845c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -2,14 +2,14 @@ package nautilus.game.arcade.managers; import java.util.Iterator; +import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.party.Party; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -56,6 +56,18 @@ public class GameChatManager implements Listener dead = C.cGray + "Dead "; Rank rank = Manager.GetClients().Get(sender).GetRank(); + String disguiseTag = ""; + if(Manager.GetClients().Get(sender).isDisguised()) + { + CoreClient cc = Manager.GetClients().Get(sender); + rank = cc.getDisguisedRank(); + + if(!cc.GetRank().Has(Rank.JNR_DEV)) + { + disguiseTag = ChatColor.BLACK + " "; + } + } + boolean ownsUltra = false; if (Manager.GetGame() != null) @@ -77,10 +89,10 @@ public class GameChatManager implements Listener } else if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) { - if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event) - rankStr = C.cDGreen + C.Bold + "Event Admin "; + if (Manager.GetGameHostManager().isEventServer()) + rankStr = C.cDGreen + C.Bold + "Event Co-Host "; else - rankStr = C.cDGreen + C.Bold + "MPS Admin "; + rankStr = C.cDGreen + C.Bold + "MPS Co-Host "; } else { @@ -110,7 +122,7 @@ public class GameChatManager implements Listener } //Base Format - event.setFormat(dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s"); + event.setFormat(disguiseTag + dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s"); //Public/Private (Not If Player Dead) if (Manager.GetGame() != null && Manager.GetGame().GetState() == GameState.Live) @@ -126,13 +138,13 @@ public class GameChatManager implements Listener if (event.getMessage().charAt(0) == '@') { event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(disguiseTag + C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); } //All Chat else { globalMessage = true; - event.setFormat(dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(disguiseTag + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); } } 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 401309e95..1e51b1d42 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 @@ -37,6 +37,7 @@ public class GameCreationManager implements Listener private ArrayList _lastGames = new ArrayList(); public String MapPref = null; + public String MapSource = null; public GameCreationManager(ArcadeManager manager) { @@ -166,6 +167,9 @@ public class GameCreationManager implements Listener HashMap pastTeams = null; + System.out.println(_nextGame == null ? "Next Game = null" : "Next Game = " + _nextGame.GetName()); + System.out.println(MapPref == null ? "Map Pref = null" : "Map Pref = " + MapPref); + //Chosen Game if (_nextGame != null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index cf954185b..46e4a9f65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -696,7 +696,7 @@ public class GameFlagManager implements Listener public void run() { player.setFireTicks(0); - player.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(player); } }, 0); } @@ -721,8 +721,17 @@ public class GameFlagManager implements Listener UtilAction.velocity(player, new Vector(0,0,0), 1, true, 0.4, 0, 1, true); - UtilPlayer.message(player, C.cWhite + C.Bold + "You will respawn in " + time + " seconds..."); - UtilTextMiddle.display(null, "Respawning in " + time + " seconds...", 5, 40, 5, player); + if (!game.IsAlive(player)) + { + Manager.addSpectator(player, true); + return; + } + + if (time > 3) + { + UtilPlayer.message(player, C.cWhite + C.Bold + "You will respawn in " + time + " seconds..."); + UtilTextMiddle.display(null, "Respawning in " + time + " seconds...", 5, 40, 5, player); + } Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { @@ -732,14 +741,14 @@ public class GameFlagManager implements Listener if (game.IsAlive(player)) { game.RespawnPlayer(player); - } + } else { Manager.addSpectator(player, true); } player.setFireTicks(0); - player.setVelocity(new Vector(0,0,0)); + UtilAction.zeroVelocity(player); } }, (int)(time * 20d)); } @@ -1101,16 +1110,13 @@ public class GameFlagManager implements Listener if (event.getType() != UpdateType.SEC) return; - - if (Manager.GetGame().GetType() == GameType.MineStrike) - return; - + for (Player player : UtilServer.getPlayers()) { if (Manager.IsAlive(player)) continue; - if (Recharge.Instance.use(player, "Dont Quit Message", 30000, false, false)) + if (Recharge.Instance.use(player, "Dont Quit Message", 300000, false, false)) { UtilPlayer.message(player, " "); UtilPlayer.message(player, C.cWhite + C.Bold + "You are out of the game, but " + C.cGold + C.Bold + "DON'T QUIT" + C.cWhite + C.Bold + "!"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 121d7d44b..53f8173c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -1,7 +1,9 @@ package nautilus.game.arcade.managers; +import java.lang.reflect.Field; import java.util.HashMap; +import mineplex.core.account.event.GetClientEvent; import mineplex.core.achievement.Achievement; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -18,8 +20,12 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.util.com.mojang.authlib.GameProfile; import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -117,9 +123,6 @@ public class GameGemManager implements Listener @EventHandler(priority = EventPriority.MONITOR) public void GameStateChange(GameStateChangeEvent event) { - if (!Manager.IsRewardGems()) - return; - if (event.GetState() != GameState.Dead) return; @@ -129,12 +132,12 @@ public class GameGemManager implements Listener public void RewardGems(Game game, Player player, boolean give) { - if (!Manager.IsRewardGems()) - return; - //Inform Gems AnnounceGems(game, player, game.GetPlayerGems().get(player), give); + if (!Manager.IsRewardGems()) + return; + //Give Gems if (give) GiveGems(game, player, game.GetPlayerGems().remove(player), game.GemMultiplier); @@ -145,7 +148,7 @@ public class GameGemManager implements Listener if (!Manager.IsRewardGems()) return; - if (gems == null) + if (gems == null) return; int earned = 0; @@ -159,6 +162,14 @@ public class GameGemManager implements Listener earned = (int) (earned * gameMult); int total = earned; + + String oldName = player.getName(); + + if(Manager.GetClients().Get(player).getDisguisedAs() != null) + { + changeName(player, Manager.GetClients().Get(player).GetPlayerName()); + System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName()); + } //Gem Boooster if (game.GemBoosterEnabled) @@ -167,14 +178,14 @@ public class GameGemManager implements Listener //Gem Finder if (game.GemHunterEnabled) { - int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); + int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { total += (int)(earned * (gemFinder * 0.25)); } } - if (DoubleGem && game.GemDoubleEnabled) + if (DoubleGem && game.GemDoubleEnabled && UtilPlayer.is1_8(player)) total += earned; Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), total); @@ -182,14 +193,36 @@ public class GameGemManager implements Listener //Stats Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total); Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total); + + if(Manager.GetClients().Get(player).getDisguisedAs() != null) + { + changeName(player, oldName); + } + } - public void AnnounceGems(Game game, Player player, HashMap gems, boolean give) + private void changeName(Player player, String newName) + { + try + { + Field name = GameProfile.class.getDeclaredField("name"); + Field declaredProfile = EntityHuman.class.getDeclaredField("i"); + declaredProfile.setAccessible(true); + GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity)((CraftPlayer) player)).getHandle()); + + name.setAccessible(true); + name.set(gameProfile, newName); + name.setAccessible(false); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void AnnounceGems(Game game, Player player, HashMap gems, boolean give) { - if (!Manager.IsRewardGems()) - return; - - if (gems == null) + if (gems == null) return; player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); @@ -197,7 +230,7 @@ public class GameGemManager implements Listener UtilPlayer.message(player, ""); UtilPlayer.message(player, ArcadeFormat.Line); - UtilPlayer.message(player, "§f§lGems Earned"); + UtilPlayer.message(player, Manager.IsRewardGems() ? "§f§lGems Earned" : "§f§lGame Stats"); UtilPlayer.message(player, ""); int earnedGems = 0; @@ -215,9 +248,22 @@ public class GameGemManager implements Listener if (amount > 0) amountStr = amount + " "; - UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(gemCount * game.GemMultiplier) + " Gems") + " for " + F.elem(amountStr + type)); + String out = ""; + if (Manager.IsRewardGems()) + out += F.elem(C.cGreen + "+" + (int)(gemCount * game.GemMultiplier) + " Gems") + " for "; + out += F.elem(amountStr + type); + + UtilPlayer.message(player, out); } + if (!Manager.IsRewardGems()) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, ArcadeFormat.Line); + return; + } + + earnedGems = (int) (earnedGems * game.GemMultiplier); int totalGems = earnedGems; @@ -225,7 +271,7 @@ public class GameGemManager implements Listener //Gem Booster if (game.GetGemBoostAmount() > 0 && game.GemBoosterEnabled) { - UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " + + UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " + F.elem(game.GemBoosters.size() + " Gem Boosters " + C.cGreen + "+" + (int)(game.GetGemBoostAmount()*100) + "%")); totalGems += earnedGems * game.GetGemBoostAmount(); @@ -237,7 +283,7 @@ public class GameGemManager implements Listener int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { - UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " + + UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " + F.elem("Gem Hunter " + gemFinder + C.cGreen + " +" + (gemFinder*25) + "%")); totalGems += earnedGems * (gemFinder * 0.25); @@ -245,9 +291,9 @@ public class GameGemManager implements Listener } //Double Gem - if (DoubleGem && game.GemDoubleEnabled) + if (DoubleGem && game.GemDoubleEnabled && UtilPlayer.is1_8(player)) { - UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Bonus")); + UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend")); totalGems += earnedGems; } @@ -256,7 +302,7 @@ public class GameGemManager implements Listener UtilPlayer.message(player, ""); if (give) { - UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + + UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).GetGems() + totalGems) + " Gems")); } else @@ -265,8 +311,8 @@ public class GameGemManager implements Listener UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed.")); } - UtilPlayer.message(player, ArcadeFormat.Line); + UtilPlayer.message(player, ArcadeFormat.Line); } -} +} \ No newline at end of file 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 ccb1c54ae..a5f9fab74 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 @@ -10,7 +10,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; +import mineplex.core.game.GameCategory; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -18,6 +20,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; +import nautilus.game.arcade.gui.privateServer.page.GameVotingPage; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -32,6 +35,7 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; @@ -44,6 +48,7 @@ public class GameHostManager implements Listener ArcadeManager Manager; private Player _host; + private String _hostName; private Rank _hostRank; private long _serverStartTime = System.currentTimeMillis(); private long _serverExpireTime = 21600000; @@ -61,6 +66,10 @@ public class GameHostManager implements Listener private boolean _isEventServer = false; private HashMap _permissionMap = new HashMap(); + + private boolean _voteInProgress = false; + private HashMap _votes = new HashMap(); + private int _voteNotificationStage = 1; public GameHostManager(ArcadeManager manager) { @@ -84,6 +93,7 @@ public class GameHostManager implements Listener ultraGames.add(GameType.SneakyAssassins); ultraGames.add(GameType.TurfWars); ultraGames.add(GameType.Spleef); + ultraGames.add(GameType.Lobbers); //Hero Games heroGames.add(GameType.ChampionsDominate); @@ -100,19 +110,28 @@ public class GameHostManager implements Listener legendGames.add(GameType.Build); legendGames.add(GameType.UHC); legendGames.add(GameType.MineStrike); - legendGames.add(GameType.SnowFight); - legendGames.add(GameType.Gravity); - legendGames.add(GameType.Barbarians); - legendGames.add(GameType.OldMineWare); - legendGames.add(GameType.SmashDomination); legendGames.add(GameType.Skywars); - // Team variants + // Team variants - Currently being remade. + /* legendGames.add(GameType.DragonEscapeTeams); legendGames.add(GameType.DragonsTeams); legendGames.add(GameType.QuiverTeams); legendGames.add(GameType.SmashTeams); legendGames.add(GameType.SpleefTeams); legendGames.add(GameType.SurvivalGamesTeams); + */ + //Rejected / Other + legendGames.add(GameType.Evolution); + legendGames.add(GameType.MilkCow); + legendGames.add(GameType.SearchAndDestroy); + legendGames.add(GameType.ZombieSurvival); + legendGames.add(GameType.SurvivalGamesTeams); + legendGames.add(GameType.SkywarsTeams); + legendGames.add(GameType.SmashTeams); + legendGames.add(GameType.SnowFight); + legendGames.add(GameType.Gravity); + legendGames.add(GameType.Barbarians); + legendGames.add(GameType.SmashDomination); //Config Defaults if (Manager.GetHost() != null && Manager.GetHost().length() > 0) @@ -121,6 +140,16 @@ public class GameHostManager implements Listener } } + public ArrayList hasWarning() + { + ArrayList games = new ArrayList<>(); + games.add(GameType.Evolution); + games.add(GameType.MilkCow); + games.add(GameType.SearchAndDestroy); + games.add(GameType.ZombieSurvival); + return games; + } + @EventHandler public void updateHost(UpdateEvent event) { @@ -151,6 +180,44 @@ public class GameHostManager implements Listener } } + @EventHandler + public void voteNotification(UpdateEvent e) + { + if (e.getType() != UpdateType.FAST) + return; + + if (!_voteInProgress) + return; + + if (_voteNotificationStage == 1) + { + UtilTextBottom.display(C.cYellow + C.Bold + "Type " + C.cGold + C.Bold + "/vote" + C.cYellow + C.Bold + " to vote for next game", UtilServer.getPlayers()); + _voteNotificationStage++; + return; + } + else if (_voteNotificationStage == 2) + { + UtilTextBottom.display(C.cGold + C.Bold + "Type " + C.cYellow + C.Bold + "/vote" + C.cGold + C.Bold + " to vote for next game", UtilServer.getPlayers()); + _voteNotificationStage = 1; + return; + } + } + + @EventHandler + public void whitelistJoin(PlayerLoginEvent event) + { + Player p = event.getPlayer(); + if (Manager.GetServerConfig().PlayerServerWhitelist){ + if (!getWhitelist().contains(p.getName())){ + if ((Manager.GetHost() != null) && (Manager.GetHost().equalsIgnoreCase(p.getName()))) + { + return; + } + event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted."); + } + } + } + @EventHandler public void adminJoin(PlayerJoinEvent event) { @@ -163,6 +230,10 @@ public class GameHostManager implements Listener _hostRank = Manager.GetClients().Get(_host).GetRank(); System.out.println("Game Host Joined."); + //Limit player count! + if (Manager.GetServerConfig().MaxPlayers > getMaxPlayerCap()) + Manager.GetServerConfig().MaxPlayers = getMaxPlayerCap(); + if (isEventServer()) worldeditPermissionSet(event.getPlayer(), true); } @@ -295,19 +366,96 @@ public class GameHostManager implements Listener { return _adminList; } + + @EventHandler + public void getAdmin(PlayerCommandPreprocessEvent event) + { + if (!event.getMessage().equalsIgnoreCase("/getadmin")) + return; + + event.setCancelled(true); + + if (!isPrivateServer()) + return; + + if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true) && !event.getPlayer().isOp()) + return; + + giveAdmin(event.getPlayer()); + } + + @EventHandler + public void broadcastCommand(PlayerCommandPreprocessEvent event) + { + if (!event.getMessage().toLowerCase().startsWith("/bc")) + return; + + if (!isPrivateServer()) + return; + + if (!isAdmin(event.getPlayer(), true)) + { + event.getPlayer().sendMessage(F.main("Broadcast", "Only MPS admins can use this command.")); + event.setCancelled(true); + return; + } + + event.setCancelled(true); + + if (event.getMessage().split(" ").length < 2) + { + event.getPlayer().sendMessage(F.main("Broadcast", "/bc ")); + return; + } + + String msg = ""; + for (int i = 1; i < event.getMessage().split(" ").length; i++) + { + msg += event.getMessage().split(" ")[i] + " "; + } + msg = msg.trim(); + + Bukkit.broadcastMessage(C.cDGreen + C.Bold + event.getPlayer().getName() + " " + C.cGreen + msg); + } + + @EventHandler + public void voteCommand(PlayerCommandPreprocessEvent event) + { + if (!event.getMessage().toLowerCase().startsWith("/vote")) + return; + + if (!isPrivateServer()) + { + UtilPlayer.message(event.getPlayer(), F.main("Vote", "This command is only available on private servers.")); + event.setCancelled(true); + return; + } + + if (!_voteInProgress) + { + UtilPlayer.message(event.getPlayer(), F.main("Vote", "There is no vote in progress.")); + event.setCancelled(true); + return; + } + + event.setCancelled(true); + _shop.openPageForPlayer(event.getPlayer(), new GameVotingPage(Manager, _shop, event.getPlayer())); + return; + } @EventHandler public void menuCommand(PlayerCommandPreprocessEvent event) { + if (!event.getMessage().toLowerCase().startsWith("/menu")) + return; + if (!isPrivateServer()) return; if (!isAdmin(event.getPlayer(), true)) return; - if (!event.getMessage().toLowerCase().startsWith("/menu")) - return; - + event.setCancelled(true); openMenu(event.getPlayer()); } @@ -353,8 +501,13 @@ public class GameHostManager implements Listener if (_host == null || !event.getPlayer().equals(_host)) return; - if (!event.getMessage().toLowerCase().startsWith("/whitelist ")) + if (!event.getMessage().toLowerCase().startsWith("/whitelist")) return; + + if (!isPrivateServer()) + return; + + event.setCancelled(true); String[] args = event.getMessage().split(" "); @@ -364,7 +517,7 @@ public class GameHostManager implements Listener if (_whitelist.add(name)) { - UtilPlayer.message(event.getPlayer(), F.main("Host", "Added " + F.elem(name) + " to the whitelist.")); + UtilPlayer.message(event.getPlayer(), F.main("Host", "Added " + F.elem(args[i]) + " to the whitelist.")); } } } @@ -449,6 +602,24 @@ public class GameHostManager implements Listener return games; } + public HashMap> getGames(Player p) + { + HashMap> games = new HashMap>(); + for (GameCategory cat : GameCategory.values()) + { + ArrayList types = new ArrayList<>(); + for (GameType type : getAvailableGames(p)) + { + if (type.getGameCategory().equals(cat)) + { + types.add(type); + } + } + games.put(cat, types); + } + return games; + } + public void ban(Player player) { _blacklist.add(player.getName()); @@ -475,7 +646,7 @@ public class GameHostManager implements Listener { _adminList.add(player.getName()); _onlineAdmins.add(player); - UtilPlayer.message(player, F.main("Server", "You were given admin privileges.")); + UtilPlayer.message(player, F.main("Server", "You were given Co-Host privileges.")); if (isEventServer()) worldeditPermissionSet(player, true); @@ -493,7 +664,7 @@ public class GameHostManager implements Listener { player.closeInventory(); } - UtilPlayer.message(player, F.main("Server", "Your admin privileges were removed.")); + UtilPlayer.message(player, F.main("Server", "Your Co-Host privileges were removed.")); player.setGameMode(GameMode.SURVIVAL); @@ -533,29 +704,7 @@ public class GameHostManager implements Listener else return 4; } - - @EventHandler - public void setHostDebug(PlayerCommandPreprocessEvent event) - { - if (!event.getPlayer().isOp()) - return; - if (!event.getMessage().toLowerCase().startsWith("/sethost ")) - return; - - Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1]; - - event.getPlayer().sendMessage("Set host to: " + event.getMessage().split(" ")[1]); - - _host = Bukkit.getPlayerExact(Manager.GetServerConfig().HostName); - if (_host != null) - _hostRank = Manager.GetClients().Get(_host).GetRank(); - - setDefaultConfig(); - - event.setCancelled(true); - } - @EventHandler public void setEventGame(PlayerCommandPreprocessEvent event) { @@ -568,57 +717,66 @@ public class GameHostManager implements Listener if (!event.getMessage().toLowerCase().startsWith("/e set ") && !event.getMessage().toLowerCase().equals("/e set")) return; + Player caller = event.getPlayer(); String[] args = event.getMessage().split(" "); - //Parse Game - if (args.length >= 3) - { - ArrayList matches = new ArrayList(); - for (GameType type : GameType.values()) - { - if (type.toString().toLowerCase().equals(args[2])) - { - matches.clear(); - matches.add(type); - break; - } - - if (type.toString().toLowerCase().contains(args[2])) - { - matches.add(type); - } - } - - if (matches.size() == 0) - { - event.getPlayer().sendMessage("No results for: " + args[2]); - return; - } - - if (matches.size() > 1) - { - event.getPlayer().sendMessage("Matched multiple games;"); - for (GameType cur : matches) - event.getPlayer().sendMessage(cur.toString()); - return; - } - - GameType type = matches.get(0); - Manager.GetGame().setGame(type, event.getPlayer(), true); - } - else - { - Manager.GetGame().setGame(GameType.Event, event.getPlayer(), true); - } + String game = args[2].toLowerCase(); - - //Map Pref if (args.length >= 4) { - Manager.GetGameCreationManager().MapPref = args[3]; - UtilPlayer.message(event.getPlayer(), C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + args[2]); + String map = ""; + String source = ""; + if(args.length == 5) + { + Manager.GetGameCreationManager().MapSource = args[3]; + Manager.GetGameCreationManager().MapPref = args[4]; + source = args[3]; + map = args[4]; + } + else + { + Manager.GetGameCreationManager().MapSource = args[2]; + Manager.GetGameCreationManager().MapPref = args[3]; + source = args[2]; + map = args[3]; + } + UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + source + ":" + map); } + //Parse Game + ArrayList matches = new ArrayList<>(); + for (GameType type : GameType.values()) + { + if (type.toString().toLowerCase().equals(game)) + { + matches.clear(); + matches.add(type); + break; + } + + if (type.toString().toLowerCase().contains(game)) + { + matches.add(type); + } + } + + if (matches.size() == 0) + { + caller.sendMessage("No results for: " + game); + return; + } + + if (matches.size() > 1) + { + caller.sendMessage("Matched multiple games;"); + for (GameType cur : matches) + caller.sendMessage(cur.toString()); + return; + } + + GameType type = matches.get(0); + Manager.GetGame().setGame(type, event.getPlayer(), true); + event.setCancelled(true); } @@ -648,4 +806,40 @@ public class GameHostManager implements Listener { _isEventServer = var; } + + public HashMap getVotes() + { + return _votes; + } + + public void setVoteInProgress(boolean voteInProgress) + { + _voteInProgress = voteInProgress; + } + + public boolean isVoteInProgress() + { + return _voteInProgress; + } + + public Rank getHostRank() + { + return _hostRank; + } + + public void setHostRank(Rank rank) + { + _hostRank = rank; + } + + public Player getHost() + { + return _host; + } + + public void setHost(Player player) + { + _host = player; + } + } 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 89bf6ada6..a13d6f1b9 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 @@ -185,13 +185,20 @@ public class GameLobbyManager implements Listener, IPacketHandler { for (GameTeam team : Manager.GetGame().GetTeamList()) { - if (rank == Rank.ALL) + if(team.GetDisplaytag()) { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); + scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); } - else + else { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " " + team.GetColor()); + if (rank == Rank.ALL) + { + scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); + } + else + { + scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " " + team.GetColor()); + } } } } @@ -323,7 +330,7 @@ public class GameLobbyManager implements Listener, IPacketHandler _teamBlocks.clear(); //Smash - if (game.GetType() == GameType.Smash || game.GetType() == GameType.SurvivalGames) + if (game.HideTeamSheep) { //Text WriteTeamLine("Select", 0, 159, (byte)15); @@ -332,60 +339,9 @@ public class GameLobbyManager implements Listener, IPacketHandler CreateScoreboards(); return; } - - //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 || game.GetTeamList().size() < 6) + if ((game.GetKits().length > 1 || game.GetTeamList().size() < 6) && game.GetType() != GameType.SurvivalGamesTeams) { //Display ArrayList teams = new ArrayList(); @@ -558,7 +514,7 @@ public class GameLobbyManager implements Listener, IPacketHandler } //Smash - if (game.GetType() == GameType.Smash || game.GetType() == GameType.SurvivalGames) + if (game.ReplaceTeamsWithKits) { // WriteKitLine("Free", 0, 159, (byte)15); // WriteKitLine("Kits", 1, 159, (byte)4); @@ -911,9 +867,9 @@ public class GameLobbyManager implements Listener, IPacketHandler WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte)14); if (game.GetMode() == null) - WriteGameLine(" ", 1, 159, (byte)14); + WriteGameLine(" ", 1, 159, (byte)1); else - WriteGameLine(game.GetMode(), 1, 159, (byte)14); + WriteGameLine(game.GetMode(), 1, 159, (byte)1); DisplayWaiting(); CreateKits(game); @@ -1024,7 +980,14 @@ public class GameLobbyManager implements Listener, IPacketHandler kitName = kitName.substring(0, 16); // Remove old - entry.getValue().resetScores(C.cGray + C.Bold + "Kit"); + //entry.getValue().resetScores(teamColor + C.Bold + "Kit"); + for(String string : entry.getValue().getEntries()) + { + if(string.endsWith("Kit")) + { + entry.getValue().resetScores(string); + } + } entry.getValue().resetScores(_kitMap.get(entry.getKey()) + ""); // Set new @@ -1099,10 +1062,10 @@ public class GameLobbyManager implements Listener, IPacketHandler } if (ent.GetKit().GetAvailability() == KitAvailability.Free || //Free - Manager.isYoutuber(player) || //YouTube + Manager.hasKitsUnlocked(player) || //YouTube (ent.GetKit().GetAvailability() == KitAvailability.Achievement && Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement - donor.OwnsUnknownPackage(Manager.GetGame().GetName() + " " + ent.GetKit().GetName()) || //Green + donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + ent.GetKit().GetName()) || //Green Manager.GetClients().Get(player).GetRank().Has(Rank.MAPDEV) || //STAFF donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) Manager.GetServerConfig().Tournament) //Tournament diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java index 08fc48275..e018a834d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java @@ -50,12 +50,12 @@ public class GameLootManager implements Listener Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - _rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, + _rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(), 100, 250, 500, 1000, 1500, 2500, 6000, 12000, - false); + false, false); //Chest _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Old Chest", "Old Chest", 1, 1, 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 7122ad16c..8123bdef5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; import java.util.Iterator; +import mineplex.core.bonuses.event.CarlSpinnerEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; @@ -224,7 +225,10 @@ public class GameManager implements Listener { if (game instanceof UHC && !((UHC)game).isMapLoaded()) return; - + + if (Manager.GetGameHostManager().isPrivateServer() && Manager.GetGameHostManager().isVoteInProgress()) + return; + //Disabling Cosmetics if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0 && game.GadgetsDisabled) { @@ -687,4 +691,18 @@ public class GameManager implements Listener { event.GetGame().EndCheck(); } + + @EventHandler + public void carlSpinnerCancel(CarlSpinnerEvent event) + { + Game game = Manager.GetGame(); + if (game == null) return; + + if (game.GetCountdown() > 0 || game.GetState() != GameState.Recruit) + { + UtilPlayer.message(event.getPlayer(), F.main("Carl", "You can't use my spinner at the moment!")); + event.setCancelled(true); + } + + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 0c28bab88..d1417d420 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -177,18 +177,18 @@ public class GamePlayerManager implements Listener Player player = event.getPlayer(); + GameTeam team = Manager.GetLobby().GetClickedTeam(event.getRightClicked()); + + if (team == null) + return; + //Observer if (Manager.IsObserver(player)) { UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); return; } - - GameTeam team = Manager.GetLobby().GetClickedTeam(event.getRightClicked()); - - if (team == null) - return; - + TeamClick(player, team); } @@ -198,20 +198,20 @@ public class GamePlayerManager implements Listener Player player = event.GetDamagerPlayer(false); if (player == null) return; - //Observer - if (Manager.IsObserver(player)) - { - UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); - return; - } - LivingEntity target = event.GetDamageeEntity(); GameTeam team = Manager.GetLobby().GetClickedTeam(target); if (team == null) return; - + + //Observer + if (Manager.IsObserver(player)) + { + UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); + return; + } + TeamClick(player, team); } @@ -265,6 +265,13 @@ public class GamePlayerManager implements Listener Player player = event.getPlayer(); + + + Kit kit = Manager.GetLobby().GetClickedKit(event.getRightClicked()); + + if (kit == null) + return; + //Observer if (Manager.IsObserver(player) || Manager.isSpectator(player)) { @@ -272,11 +279,6 @@ public class GamePlayerManager implements Listener return; } - Kit kit = Manager.GetLobby().GetClickedKit(event.getRightClicked()); - - if (kit == null) - return; - KitClick(player, kit, event.getRightClicked()); event.setCancelled(true); @@ -294,12 +296,7 @@ public class GamePlayerManager implements Listener Player player = event.GetDamagerPlayer(false); if (player == null) return; - //Observer - if (Manager.IsObserver(player) || Manager.isSpectator(player)) - { - UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); - return; - } + LivingEntity target = event.GetDamageeEntity(); @@ -307,7 +304,14 @@ public class GamePlayerManager implements Listener if (kit == null) return; - + + //Observer + if (Manager.IsObserver(player) || Manager.isSpectator(player)) + { + UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); + return; + } + KitClick(player, kit, target); } @@ -325,12 +329,12 @@ public class GamePlayerManager implements Listener if (kit.GetAvailability() == KitAvailability.Free || //Free - Manager.isYoutuber(player) || //YouTube + Manager.hasKitsUnlocked(player) || //YouTube (kit.GetAvailability() == KitAvailability.Achievement && //Achievement Manager.GetAchievement().hasCategory(player, kit.getAchievementRequirement())) || - donor.OwnsUnknownPackage(Manager.GetGame().GetName() + " " + kit.GetName()) || //Green + donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + kit.GetName()) || //Green Manager.GetClients().Get(player).GetRank().Has(Rank.MAPDEV) || //STAFF @@ -340,7 +344,7 @@ public class GamePlayerManager implements Listener { Manager.GetGame().SetKit(player, kit, true); } - else if (kit.GetAvailability() == KitAvailability.Gem && donor.GetBalance(CurrencyType.Gems) > kit.GetCost()) + else if (kit.GetAvailability() == KitAvailability.Gem && donor.GetBalance(CurrencyType.Gems) >= kit.GetCost()) { Manager.GetShop().openPageForPlayer(player, new ConfirmationPage( Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new Runnable() @@ -353,7 +357,7 @@ public class GamePlayerManager implements Listener ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entity.getEntityId(), ((CraftEntity) entity).getHandle().getDataWatcher(), true)); } } - }, null, new KitPackage(Manager.GetGame().GetName(), kit), CurrencyType.Gems, player)); + }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(), kit), CurrencyType.Gems, player)); } else if (kit.GetAvailability() == KitAvailability.Achievement) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index cc1f81e1e..f855f9ffc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -68,6 +68,10 @@ public class GameStatManager implements Listener for (String stat : event.GetGame().GetStats().get(player).keySet()) { int value = event.GetGame().GetStats().get(player).get(stat); + + if (value <= 0) + continue; + Manager.GetStatsManager().incrementStat(player, stat, value); // Leaderboard hook for logging appropriate stat events diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index 0f3b42080..3167c4976 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -124,7 +124,14 @@ public class GameScoreboard for (GameTeam team : Game.GetTeamList()) { System.out.println("Scoreboard Team: " + team.GetName().toUpperCase()); - _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); + if(team.GetDisplaytag()) + { + _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); + } + else + { + _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); + } } /* diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java index 7b10cb9b1..2322950cb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java @@ -1,12 +1,12 @@ package nautilus.game.arcade.stats; -import mineplex.core.common.util.*; -import mineplex.minecraft.game.core.combat.event.*; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.bridge.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; -import org.bukkit.event.entity.*; +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.games.bridge.Bridge; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; public class BridgesSniperStatTracker extends StatTracker { @@ -18,7 +18,7 @@ public class BridgesSniperStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { - if (getGame().GetState() != Game.GameState.Live) + if (!getGame().IsLive()) return; if (getGame().isBridgesDown()) @@ -31,6 +31,7 @@ public class BridgesSniperStatTracker extends StatTracker return; Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (killer == null) return; @@ -41,13 +42,16 @@ public class BridgesSniperStatTracker extends StatTracker return; Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); + if (player == null) return; if (player == killer) return; - - if ("Archery".equals(event.GetLog().GetLastDamager().GetLastDamageSource())) + + if (event.GetLog().GetLastDamager().GetLastDamageSource().contains("Archery")) + { addStat(killer, "Sniper", 1, true, false); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java index 471cd5da0..2975b101b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java @@ -1,8 +1,15 @@ package nautilus.game.arcade.stats; -import mineplex.minecraft.game.classcombat.Skill.Mage.*; -import nautilus.game.arcade.game.*; -import org.bukkit.event.*; +import java.util.ArrayList; +import java.util.List; + +import mineplex.minecraft.game.classcombat.Skill.Mage.LightningOrb.LightningOrbEvent; +import nautilus.game.arcade.game.Game; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; public class ElectrocutionStatTracker extends StatTracker { @@ -12,12 +19,24 @@ public class ElectrocutionStatTracker extends StatTracker } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onLightningOrb(LightningOrb.LightningOrbEvent event) + public void onLightningOrb(LightningOrbEvent event) { if (getGame().GetState() != Game.GameState.Live) return; - - if (event.getStruck().size() >= 4) + + List viable = new ArrayList(); + + for (LivingEntity en : event.getStruck()) + { + if (en instanceof Player) + { + viable.add((Player) en); + } + } + + if (viable.size() >= 4) + { addStat(event.getPlayer(), "MassElectrocution", 1, true, false); + } } } 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 17677ad64..1ecd74283 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 @@ -42,7 +42,7 @@ public class ExperienceStatTracker extends StatTracker if (!event.GetGame().Manager.IsRewardStats() || !event.GetGame().Manager.IsRewardAchievements()) return; - if (_startTime == -1) + if (_startTime <= 0) return; if (event.GetState() == Game.GameState.End) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java index 901982794..10f9893b6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java @@ -1,12 +1,18 @@ package nautilus.game.arcade.stats; -import nautilus.game.arcade.game.*; -import nautilus.game.arcade.game.games.survivalgames.*; -import org.bukkit.event.*; +import java.util.HashSet; +import java.util.Set; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; + +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; public class FirstSupplyDropOpenStatTracker extends StatTracker { - private boolean first = true; + private Set _opened = new HashSet(); public FirstSupplyDropOpenStatTracker(Game game) { @@ -19,11 +25,11 @@ public class FirstSupplyDropOpenStatTracker extends StatTracker if (getGame().GetState() != Game.GameState.Live) return; - if (first) - { - addStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false); + if (_opened.contains(event.getChest())) + return; + + _opened.add(event.getChest()); - first = false; - } + addStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java index 135888975..d1df0b6f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java @@ -4,15 +4,14 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndead; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; public class LastStandStatTracker extends StatTracker { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java index 8edaaac79..d22e2e515 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java @@ -18,7 +18,7 @@ public class TheLongestShotStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { - if (getGame().GetState() != Game.GameState.Live) + if (!getGame().IsLive()) return; if (event.GetLog().GetKiller() == null) @@ -38,13 +38,16 @@ public class TheLongestShotStatTracker extends StatTracker return; Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); - if (player == null) + + if (player == null || !player.isOnline()) return; - if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains("Longshot")) + if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().toLowerCase().contains("longshot")) { - if (killer.getLocation().distanceSquared(player.getLocation()) >= 64 * 64) + if (killer.getLocation().distance(player.getLocation()) >= 64) + { addStat(killer, "TheLongestShot", 1, false, false); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java index 49b448e66..5f9f990f6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java @@ -3,20 +3,19 @@ package nautilus.game.arcade.stats; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.UUID; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + public class WinWithoutDyingStatTracker extends StatTracker { - private final Set _hasDied = new HashSet<>(); + private final Set _hasDied = new HashSet(); private final String _stat; public WinWithoutDyingStatTracker(Game game, String stat) @@ -29,7 +28,7 @@ public class WinWithoutDyingStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { - if (getGame().GetState() != Game.GameState.Live) + if (!getGame().IsLive()) return; if (event.GetLog().GetPlayer() == null) @@ -39,13 +38,14 @@ public class WinWithoutDyingStatTracker extends StatTracker return; Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); - if (player == null) + if (player == null || !player.isOnline()) + { return; - - _hasDied.add(player.getUniqueId()); + } + _hasDied.add(player.getUniqueId().toString()); } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onGameStateChange(GameStateChangeEvent event) { if (event.GetState() == Game.GameState.End) @@ -56,8 +56,10 @@ public class WinWithoutDyingStatTracker extends StatTracker { for (Player winner : winners) { - if (!_hasDied.contains(winner.getUniqueId())) - addStat(winner, getStat(), 1, true, false); + if (!_hasDied.contains(winner.getUniqueId().toString())) + { + addStat(winner, _stat, 1, true, false); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutOpeningChestStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutOpeningChestStatTracker.java index 90d61b653..3a9459092 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutOpeningChestStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutOpeningChestStatTracker.java @@ -3,24 +3,22 @@ package nautilus.game.arcade.stats; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.UUID; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.skywars.events.PlayerOpenChestEvent; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerInteractEvent; public class WinWithoutOpeningChestStatTracker extends StatTracker { - - private final Set _openChest = new HashSet<>(); + private final Set _openChest = new HashSet(); public WinWithoutOpeningChestStatTracker(Game game) { @@ -28,14 +26,18 @@ public class WinWithoutOpeningChestStatTracker extends StatTracker } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void onOpenChest(PlayerInteractEvent event) { - if (event.getAction() == Action.RIGHT_CLICK_BLOCK) + if (event.isCancelled()) + { + return; + } + if (UtilEvent.isAction(event, ActionType.R_BLOCK)) { if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) { - _openChest.add(event.getPlayer().getUniqueId()); + _openChest.add(event.getPlayer().getUniqueId().toString()); } } } @@ -44,10 +46,12 @@ public class WinWithoutOpeningChestStatTracker extends StatTracker public void onBreakChest(BlockBreakEvent event) { if (event.getBlock().getType() == Material.CHEST) - _openChest.add(event.getPlayer().getUniqueId()); + { + _openChest.add(event.getPlayer().getUniqueId().toString()); + } } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onGameStateChange(GameStateChangeEvent event) { if (event.GetState() == Game.GameState.End) @@ -58,8 +62,10 @@ public class WinWithoutOpeningChestStatTracker extends StatTracker { for (Player winner : winners) { - if (!_openChest.contains(winner.getUniqueId())) + if (!_openChest.contains(winner.getUniqueId().toString())) + { addStat(winner, "NoChest", 1, true, false); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java index b6c850159..5f2626d06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java @@ -1,19 +1,23 @@ package nautilus.game.arcade.stats; -import mineplex.core.updater.*; -import mineplex.core.updater.event.*; -import nautilus.game.arcade.events.*; -import nautilus.game.arcade.game.*; -import org.bukkit.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; -import org.bukkit.inventory.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; -import java.util.*; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; public class WinWithoutWearingArmorStatTracker extends StatTracker { - private final Set _armorWearers = new HashSet<>(); + private final Set _wearing = new HashSet(); public WinWithoutWearingArmorStatTracker(Game game) { @@ -26,19 +30,20 @@ public class WinWithoutWearingArmorStatTracker extends StatTracker if (getGame().GetState() != Game.GameState.Live) return; - if (event.getType() == UpdateType.FAST) + if (event.getType() == UpdateType.TICK) { for (Player player : getGame().GetPlayers(true)) { - if (_armorWearers.contains(player.getUniqueId())) + if (_wearing.contains(player.getUniqueId().toString())) + { continue; + } for (ItemStack armor : player.getInventory().getArmorContents()) { if (armor != null && armor.getType() != Material.AIR) { - _armorWearers.add(player.getUniqueId()); - + _wearing.add(player.getUniqueId().toString()); break; } } @@ -46,7 +51,7 @@ public class WinWithoutWearingArmorStatTracker extends StatTracker } } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onGameStateChange(GameStateChangeEvent event) { if (event.GetState() == Game.GameState.End) @@ -57,8 +62,10 @@ public class WinWithoutWearingArmorStatTracker extends StatTracker { for (Player winner : winners) { - if (!_armorWearers.contains(winner.getUniqueId())) + if (!_wearing.contains(winner.getUniqueId().toString())) + { addStat(winner, "NoArmor", 1, true, false); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WitherAssaultReviveTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WitherAssaultReviveTracker.java new file mode 100644 index 000000000..d2e52bbd1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WitherAssaultReviveTracker.java @@ -0,0 +1,25 @@ +package nautilus.game.arcade.stats; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class WitherAssaultReviveTracker extends StatTracker +{ + public WitherAssaultReviveTracker(Game game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(HumanReviveEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + addStat(event.getPlayer(), "WitherHeal", 1, false, false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index 1f2a1c78c..1bb5955e0 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 @@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.WorldUtil; import mineplex.core.common.util.ZipUtil; import mineplex.core.timing.TimingManager; +import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.uhc.UHC; import net.minecraft.server.v1_7_R4.ChunkPreLoadEvent; @@ -50,6 +51,8 @@ public class WorldData public String MapName = "Null"; public String MapAuthor = "Null"; + public GameType Game = null; + public HashMap> SpawnLocs = new HashMap>(); private HashMap> DataLocs = new HashMap>(); private HashMap> CustomLocs = new HashMap>(); @@ -67,6 +70,7 @@ public class WorldData public void Initialize() { final WorldData worldData = this; + GetFile(); UtilServer.getServer().getScheduler().runTaskAsynchronously(Host.Manager.getPlugin(), new Runnable() { @@ -121,18 +125,50 @@ public class WorldData }); } + protected GameType GetGame() + { + return Game; + } + protected String GetFile() { if (File == null) { - File = Host.GetFiles().get(UtilMath.r(Host.GetFiles().size())); + GameType game = null; + int gameRandom = UtilMath.r(Host.GetFiles().size()); + int i = 0; + for(GameType type : Host.GetFiles().keySet()) + { + if(i == gameRandom) + { + game = type; + break; + } + i++; + } + Game = game; + int map = UtilMath.r(Host.GetFiles().get(game).size()); + File = Host.GetFiles().get(game).get(map); //Don't allow repeat maps. if (Host.GetFiles().size() > 1) { while (File.equals(Host.Manager.GetGameCreationManager().GetLastMap())) { - File = Host.GetFiles().get(UtilMath.r(Host.GetFiles().size())); + GameType _game = null; + int _gameRandom = UtilMath.r(Host.GetFiles().size()); + int _i = 0; + for(GameType _type : Host.GetFiles().keySet()) + { + if(_i == _gameRandom) + { + _game = _type; + break; + } + _i++; + } + int _map = UtilMath.r(Host.GetFiles().get(game).size()); + File = Host.GetFiles().get(_game).get(_map); } } } @@ -144,9 +180,10 @@ public class WorldData public String GetFolder() { - if (Folder == null) - Folder = "Game" + Id + "_" + Host.GetName() + "_" + GetFile(); - + if (Folder == null) + { + Folder = "Game" + Id + "_" + GetGame().GetName() + "_" + GetFile(); + } return Folder; } @@ -160,7 +197,7 @@ public class WorldData TimingManager.stop("UnzipWorld creating folders"); TimingManager.start("UnzipWorld UnzipToDirectory"); - ZipUtil.UnzipToDirectory("../../update/maps/" + Host.GetName() + "/" + GetFile() + ".zip", folder); + ZipUtil.UnzipToDirectory("../../update/maps/" + GetGame().GetName() + "/" + GetFile() + ".zip", folder); TimingManager.stop("UnzipWorld UnzipToDirectory"); } @@ -523,4 +560,5 @@ public class WorldData { return _dataEntries.get(key); } + } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/loot/ChestLoot.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/loot/ChestLoot.php new file mode 100644 index 000000000..fb5f728b1 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/loot/ChestLoot.php @@ -0,0 +1,61 @@ +totalLoot = 0; + } + + function addItem($id, $chance, $size, $name) + { + $this->addLoot(new RandomItem(new Item($id, 0, 1, $name), $chance, $size, $size)); + } + + function addItemFull($id, $chance, $min, $max, $name) + { + $this->addLoot(new RandomItem(new Item($id, 0, 1, $name), $chance, $min, $max)); + } + + function addLoot($ri) + { + array_push($this->randomItems, $ri); + $this->totalLoot += $ri->getChance(); + } + + function getLoot() + { + $num = UtilMath::random($this->totalLoot); + + foreach ($this->randomItems as $ri) + { + if ($ri instanceof RandomItem) + { + $num -= $ri->getChance(); + + if ($num < 0) + { + return $ri->getItem(); + } + } + } + + return null; + } + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/loot/RandomItem.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/loot/RandomItem.php new file mode 100644 index 000000000..ab6db2bf3 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/loot/RandomItem.php @@ -0,0 +1,39 @@ +chance = $chance; + $this->item = $item; + $this->min = $min; + $this->max = $max; + } + + function getChance() + { + return $this->chance; + } + + function getItem() + { + return new Item($this->item->getId(), 0, UtilMath::randBetween($this->min, $this->max), $this->item->getName()); + } + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php index f0e613b8a..e948a761e 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php @@ -295,7 +295,7 @@ class WorldComponent implements Listener, BenchTask //This will return a UID for the game public function getNewGameId() { - return rand(0, 999999); //Make this acutally unique + return rand(0, 999999); //Make this actually unique } public function isWorldReady() diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/ChestComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/ChestComponent.php index 278baceb0..f877ff456 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/ChestComponent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/ChestComponent.php @@ -1,7 +1,7 @@ arena = $arena; $this->worldComponent = $worldComponent; Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); - //Don't to game start stuff here cause there might be other components not enabled yet + + $this->loot = new ChestLoot(); + + //Food + $this->loot->addItemFull(Item::BAKED_POTATO, 30, 1, 3, "Baked Potato"); + $this->loot->addItemFull(Item::COOKED_BEEF, 30, 1, 2, "Steak"); + $this->loot->addItemFull(Item::COOKED_CHICKEN, 30, 1, 2, "Cooked Chicken"); + $this->loot->addItemFull(Item::CARROT, 30, 1, 3, "Carrot"); + $this->loot->addItemFull(Item::MUSHROOM_STEW, 15, 1, 1, "Mushroom Stew"); + $this->loot->addItemFull(Item::WHEAT, 30, 1, 6, "Wheat"); + $this->loot->addItemFull(Item::APPLE, 30, 1, 4, "Apple"); + $this->loot->addItemFull(Item::RAW_PORKCHOP, 30, 1, 4, "Pork"); + + //Weapons + $this->loot->addItem(Item::WOODEN_AXE, 80, 1, "Wooden Axe"); + $this->loot->addItem(Item::WOODEN_SWORD, 70, 1, "Wooden Sword"); + $this->loot->addItem(Item::STONE_AXE, 60, 1, "Stone Axe"); + $this->loot->addItem(Item::STONE_SWORD, 30, 1, "Stone Sword"); + + //Leather Armour + $this->loot->addItem(Item::LEATHER_BOOTS, 30, 1, "Leather Boots"); + $this->loot->addItem(Item::LEATHER_CAP, 30, 1, "Leather Cap"); + $this->loot->addItem(Item::LEATHER_PANTS, 30, 1, "Leather Pants"); + $this->loot->addItem(Item::LEATHER_TUNIC, 30, 1, "Leather Boots"); + + //Gold Armour + $this->loot->addItem(Item::GOLD_CHESTPLATE, 25, 1, ""); + $this->loot->addItem(Item::GOLD_LEGGINGS, 25, 1, ""); + $this->loot->addItem(Item::GOLD_BOOTS, 25, 1, ""); + $this->loot->addItem(Item::GOLD_HELMET, 25, 1, ""); + + //Chain Armour + $this->loot->addItem(Item::CHAIN_BOOTS, 20, 1, ""); + $this->loot->addItem(Item::CHAIN_CHESTPLATE, 20, 1, ""); + $this->loot->addItem(Item::CHAIN_LEGGINGS, 20, 1, ""); + $this->loot->addItem(Item::CHAIN_HELMET, 20, 1, ""); + + //Throwable + $this->loot->addItem(Item::BOW, 20, 1, ""); + $this->loot->addItemFull(Item::ARROW, 20, 1, 3, ""); + $this->loot->addItemFull(Item::SNOWBALL, 30, 1, 2, ""); + $this->loot->addItemFull(Item::EGG, 30, 1, 2, ""); + + //Misc + $this->loot->addItem(Item::COMPASS, 20, 1, ""); + $this->loot->addItemFull(Item::STICK, 30, 1, 2, ""); + $this->loot->addItem(Item::FLINT, 30, 1, 2, ""); + $this->loot->addItem(Item::FEATHER, 30, 1, 2, ""); + $this->loot->addItem(Item::GOLD_INGOT, 20, 1, ""); } function onStart(ArenaStartEvent $event) @@ -52,6 +105,31 @@ class ChestComponent implements Listener { return; //Called after the world is loaded + + foreach ($this->worldComponent->getData("54") as $loc) + { + $block = $loc->getLevel()->getBlock($loc); + if ($block instanceof Chest) + { + $inv = $block->getInventory(); + + $items = 2; + if (UtilMath::random(100) > 50) + ++$items; + if (UtilMath::random(100) > 65) + ++$items; + if (UtilMath::random(100) > 80) + ++$items; + if (UtilMath::random(100) > 95) + ++$items; + + for ($i = 0; $i < $items; $i++) + { + $chosenItem = $this->loot->getLoot(); + $inv->setItem(UtilMath::random(27), $chosenItem); + } + } + } } function onStateChange(GameStateChangeEvent $event) diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilMath.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilMath.php new file mode 100644 index 000000000..39b45f71c --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilMath.php @@ -0,0 +1,33 @@ +