diff --git a/Plugins/Mineplex.ClansGenerator/plugin.yml b/Plugins/Mineplex.ClansGenerator/plugin.yml new file mode 100644 index 000000000..c04a38071 --- /dev/null +++ b/Plugins/Mineplex.ClansGenerator/plugin.yml @@ -0,0 +1,4 @@ +name: ClansGenerator +main: mineplex.clansgenerator.ClansGenerator +version: 1.0 +author: Alex \ No newline at end of file diff --git a/Plugins/Mineplex.ClansGenerator/pom.xml b/Plugins/Mineplex.ClansGenerator/pom.xml new file mode 100644 index 000000000..655d4d4c6 --- /dev/null +++ b/Plugins/Mineplex.ClansGenerator/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + ClansGenerator + mineplex-clansgenerator + + + + ${project.groupId} + mineplex-core-common + ${project.version} + + + diff --git a/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java b/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java new file mode 100644 index 000000000..fbab3adc7 --- /dev/null +++ b/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java @@ -0,0 +1,176 @@ +package mineplex.clansgenerator; + +import java.io.File; +import java.io.IOException; +import java.util.concurrent.ThreadLocalRandom; + +import org.apache.commons.io.FileUtils; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.WorldCreator; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result; +import org.bukkit.event.world.ChunkPopulateEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.WatchdogThread; + +import net.minecraft.server.v1_8_R3.BiomeBase; + +public class ClansGenerator extends JavaPlugin implements Runnable, Listener +{ + private static final int MIN_X = -100; + private static final int MIN_Z = -100; + private static final int MAX_X = 100; + private static final int MAX_Z = 100; + + private File _root; + private File _outputDir; + private boolean _debug = false; + + public void onEnable() + { + _root = new File("."); + if (!_root.exists()) + { + getLogger().severe("Root folder does not exist. Aborting"); + getServer().shutdown(); + return; + } + _outputDir = new File(_root, "output"); + if (new File(_root, "DEBUG.dat").exists()) + { + _debug = true; + } + if (!_outputDir.exists()) + { + if (_debug) + { + getLogger().info("Creating map output directory!"); + } + _outputDir.mkdir(); + } + BiomeBase.getBiomes()[BiomeBase.OCEAN.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.PLAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.DESERT.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.EXTREME_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FOREST.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.TAIGA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.SWAMPLAND.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.RIVER.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.HELL.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.SKY.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FROZEN_OCEAN.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FROZEN_RIVER.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.ICE_PLAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.ICE_MOUNTAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.MUSHROOM_ISLAND.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.MUSHROOM_SHORE.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.BEACH.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.DESERT_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FOREST_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.TAIGA_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.SMALL_MOUNTAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.JUNGLE.id] = BiomeBase.EXTREME_HILLS; + BiomeBase.getBiomes()[BiomeBase.JUNGLE_HILLS.id] = BiomeBase.EXTREME_HILLS; + BiomeBase.getBiomes()[BiomeBase.JUNGLE_EDGE.id] = BiomeBase.EXTREME_HILLS; + BiomeBase.getBiomes()[BiomeBase.DEEP_OCEAN.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.STONE_BEACH.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.COLD_BEACH.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.BIRCH_FOREST.id] = BiomeBase.BIRCH_FOREST; + BiomeBase.getBiomes()[BiomeBase.BIRCH_FOREST_HILLS.id] = BiomeBase.BIRCH_FOREST_HILLS; + BiomeBase.getBiomes()[BiomeBase.ROOFED_FOREST.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.COLD_TAIGA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.COLD_TAIGA_HILLS.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MEGA_TAIGA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MEGA_TAIGA_HILLS.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.EXTREME_HILLS_PLUS.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.SAVANNA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.SAVANNA_PLATEAU.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MESA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MESA_PLATEAU_F.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MESA_PLATEAU.id] = BiomeBase.FOREST; + WatchdogThread.doStop(); + getServer().getScheduler().runTaskTimer(this, this, 20L, 100L); + getServer().getPluginManager().registerEvents(this, this); + } + + @EventHandler + public void onPopulate(ChunkPopulateEvent event) + { + Block block; + for (int x = 0; x < 16; x++) + { + for (int y = 1; y < 128; y++) + { + for (int z = 0; z < 16; z++) + { + block = event.getChunk().getBlock(x, y, z); + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.MOB_SPAWNER) + { + block.setType(Material.AIR); + if (_debug) + { + getLogger().info("Removing dungeon pieces"); + } + } + } + } + } + } + + @EventHandler + public void onJoin(AsyncPlayerPreLoginEvent event) + { + event.setLoginResult(Result.KICK_OTHER); + event.setKickMessage("Shoo, go away"); + } + + public void run() + { + int nextFileId = 0; + for (int existingFiles = 0; new File(_outputDir, "Clans_Map_" + existingFiles).exists(); existingFiles++) + { + nextFileId++; + } + + getLogger().info("Generating world id " + nextFileId); + World world = (new WorldCreator("Clans_Map_" + nextFileId)).environment(Environment.NORMAL).generateStructures(false).seed(ThreadLocalRandom.current().nextLong()).createWorld(); + world.setKeepSpawnInMemory(false); + for (int x = MIN_X; x <= MAX_X; x++) + { + getLogger().info("Generating chunks for x coord " + x); + for (int z = MIN_Z; z <= MAX_Z; z++) + { + world.getChunkAt(x, z).load(true); + } + } + + for (int x = MIN_X; x <= MAX_X; x++) + { + getLogger().info("Unloading chunks for x coord " + x); + for (int z = MIN_Z; z <= MAX_Z; z++) + { + world.getChunkAt(x, z).unload(true, false); + } + } + + getLogger().info("Unloading and saving world"); + Bukkit.unloadWorld(world, true); + getLogger().info("Finished unloading and saving world"); + try + { + FileUtils.moveDirectoryToDirectory(new File(_root, "Clans_Map_" + nextFileId), _outputDir, false); + } + catch (IOException e) + { + e.printStackTrace(); + } + getLogger().info("Finished generating world id " + nextFileId); + getServer().shutdown(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index 00a28781d..201f36c2f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -304,11 +304,11 @@ public class UtilBlock blockUseSet.add((byte) Material.JUNGLE_FENCE_GATE.getId()); blockUseSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId()); blockUseSet.add((byte) Material.ACACIA_FENCE_GATE.getId()); - blockUseSet.add((byte) Material.SPRUCE_FENCE.getId()); - blockUseSet.add((byte) Material.BIRCH_FENCE.getId()); - blockUseSet.add((byte) Material.JUNGLE_FENCE.getId()); - blockUseSet.add((byte) Material.DARK_OAK_FENCE.getId()); - blockUseSet.add((byte) Material.ACACIA_FENCE.getId()); + blockUseSet.add((byte) Material.SPRUCE_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.BIRCH_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.JUNGLE_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.ACACIA_FENCE_GATE.getId()); blockUseSet.add((byte) Material.SPRUCE_DOOR.getId()); blockUseSet.add((byte) Material.BIRCH_DOOR.getId()); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java index b2c99338c..0242d205c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java @@ -524,5 +524,33 @@ public class UtilBlockText {0,1,0,0}, {1,1,1,1} }); + + alphabet.put(':', new int[][] + { + {0}, + {1}, + {0}, + {1}, + {0} + }); + + alphabet.put('=', new int[][] + { + {0,0,0}, + {1,1,1}, + {0,0,0}, + {1,1,1}, + {0,0,0} + }); + + // THIS IS A SINGLE SPACE + alphabet.put('|', new int[][] + { + {0}, + {0}, + {0}, + {0}, + {0} + }); } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java index ec8b4ae5e..f10851755 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java @@ -114,4 +114,22 @@ public class UtilFirework playFirework(location, FireworkEffect.builder().withColor(Color.RED).withColor(Color.BLUE) .withColor(Color.WHITE).withFade(Color.RED).withFade(Color.BLUE).withFade(Color.WHITE).build()); } + + public static FireworkEffect getRandomFireworkEffect(boolean fade, int maxColors, int maxFade) + { + FireworkEffect.Builder builder = FireworkEffect.builder().with(Type.values()[UtilMath.r(Type.values().length)]) + .withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))).flicker(UtilMath.random.nextBoolean()).trail(UtilMath.random.nextBoolean()); + if (fade) + { + for (int i = 0; i < maxFade; i++) + { + builder.withFade(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))); + } + } + for (int i = 0; i < maxColors; i++) + { + builder.withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))); + } + return builder.build(); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 68a0a4493..6869beb84 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -9,6 +9,9 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.NBTTagLong; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -22,8 +25,6 @@ import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import mineplex.core.common.structs.ItemContainer; -import net.minecraft.server.v1_8_R3.NBTTagCompound; -import net.minecraft.server.v1_8_R3.NBTTagLong; public class UtilItem { @@ -1216,6 +1217,27 @@ public class UtilItem return ent; } + public static ItemStack getVersionSpecificItem(Player player, UtilPlayer.PlayerVersion requiredVersion, ItemStack base) + { + if (UtilPlayer.getPlayerVersion(player).compare(requiredVersion)) + { + return base; + } + else + { + ItemStack barrier = new ItemStack(Material.BARRIER); + ItemMeta meta = barrier.getItemMeta(); + meta.setDisplayName(base.getItemMeta().getDisplayName()); + List lore = new ArrayList<>(); + lore.addAll(base.getItemMeta().getLore()); + lore.add(" "); + lore.add(C.cRedB + "REQUIRES VERSION " + requiredVersion.getFriendlyName() + "+!"); + meta.setLore(lore); + barrier.setItemMeta(meta); + return barrier; + } + } + public static double getAttackDamage(Material type) { return ItemDamage.get(type); 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 5f7e00ddc..930bf299a 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 @@ -3,6 +3,7 @@ package mineplex.core.common.util; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -10,8 +11,21 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.Set; import java.util.UUID; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EntityTracker; +import net.minecraft.server.v1_8_R3.EntityTrackerEntry; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; +import net.minecraft.server.v1_8_R3.PlayerConnection; +import net.minecraft.server.v1_8_R3.WorldBorder; + import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -33,18 +47,6 @@ import org.bukkit.util.Vector; import mineplex.core.common.MinecraftVersion; import mineplex.core.common.events.PlayerMessageEvent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ClickEvent.Action; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTracker; -import net.minecraft.server.v1_8_R3.EntityTrackerEntry; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; -import net.minecraft.server.v1_8_R3.PlayerConnection; -import net.minecraft.server.v1_8_R3.WorldBorder; -import java.util.*; public class UtilPlayer { @@ -1124,4 +1126,49 @@ public class UtilPlayer { return (playerUUID.hashCode() & 1) == 1; } + + public static PlayerVersion getPlayerVersion(Player player) + { + int playerVersion = ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion(); + if (playerVersion >= 210) + { + return PlayerVersion._1_10; + } + else if (playerVersion >= 107) + { + return PlayerVersion._1_9; + } + return PlayerVersion._1_8; + } + + public enum PlayerVersion + { + _1_8(47, "1.8"), + _1_9(107, "1.9"), + _1_10(210, "1.10"); + + private int _version; + private String _friendlyName; + + PlayerVersion(int version, String friendlyName) + { + _version = version; + _friendlyName = friendlyName; + } + + public int getVersion() + { + return _version; + } + + public String getFriendlyName() + { + return _friendlyName; + } + + public boolean compare(PlayerVersion versionToCompare) + { + return versionToCompare.getVersion() >= getVersion(); + } + } } 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 8a2d3d371..c151fcf84 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 @@ -1,6 +1,12 @@ package mineplex.core.common.util; import javax.imageio.ImageIO; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; @@ -764,4 +770,35 @@ public class UtilText } return stringBuilder.toString(); } + + /** + * Creates an image based on a string + * Removed from EffectLib + * @param font The font that is used + * @param s The string + * @return A buffered image containing the text + */ + public static BufferedImage stringToBufferedImage(Font font, String s) { + BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); + Graphics g = img.getGraphics(); + g.setFont(font); + + FontRenderContext frc = g.getFontMetrics().getFontRenderContext(); + Rectangle2D rect = font.getStringBounds(s, frc); + g.dispose(); + + img = new BufferedImage((int) Math.ceil(rect.getWidth()), (int) Math.ceil(rect.getHeight()), BufferedImage.TYPE_4BYTE_ABGR); + g = img.getGraphics(); + g.setColor(Color.black); + g.setFont(font); + + FontMetrics fm = g.getFontMetrics(); + int x = 0; + int y = fm.getAscent(); + + g.drawString(s, x, y); + g.dispose(); + + return img; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 67e0e00fb..8372203e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -9,16 +9,6 @@ import java.util.Map.Entry; import java.util.Set; import java.util.UUID; -import mineplex.core.common.DummyEntity; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.event.CustomTagEvent; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketVerifier; -import mineplex.core.packethandler.PacketInfo; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.Entity; @@ -42,10 +32,19 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.common.DummyEntity; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.event.CustomTagEvent; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.packethandler.PacketVerifier; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class CustomTagFix extends MiniPlugin implements IPacketHandler { private Map> _entityMap = new HashMap<>(); @@ -524,9 +523,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler } else { - PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(); - entityMetadata.a = entityIds[0]; - entityMetadata.b = watcher.c(); + PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityIds[0], watcher, true); packetList.bypassProcess(entityMetadata); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 32e54d2bb..7dbe9d5fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -44,6 +44,13 @@ public enum Achievement new int[]{10}, AchievementCategory.HOLIDAY), + GLOBAL_CHICKEN_CHASER_2016("2016 Chicken Chaser", 4000, + new String[]{"Global.Thanksgiving Chickens 2016"}, + new String[]{"Catch 200 Thanksgiving Chickens,", + "during Thanksgiving 2016!"}, + new int[]{200}, + AchievementCategory.HOLIDAY), + //Bridges BRIDGES_WINS("Bridge Champion", 600, new String[]{"The Bridges.Wins"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java index bea07b8e5..664a742de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java @@ -5,12 +5,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; - -import mineplex.core.MiniPlugin; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; +import java.util.Map.Entry; import org.bukkit.Effect; import org.bukkit.Location; @@ -22,8 +17,15 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class BlockRestore extends MiniPlugin { private HashMap _blocks = new HashMap(); @@ -98,6 +100,21 @@ public class BlockRestore extends MiniPlugin for (Block cur : toRemove) _blocks.remove(cur); } + + @EventHandler + public void expireUnload(ChunkUnloadEvent event) + { + Iterator> iterator = _blocks.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + if (entry.getKey().getChunk().equals(event.getChunk())) + { + entry.getValue().restore(); + iterator.remove(); + } + } + } public boolean restore(Block block) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index d609f656b..3ab6b1292 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -1,5 +1,37 @@ 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.LinkedList; +import java.util.Queue; +import java.util.TimeZone; +import java.util.UUID; + +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityCreeper; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +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.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -47,36 +79,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.youtube.YoutubeManager; import mineplex.database.Tables; import mineplex.serverdata.database.DBPool; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.EntityCreeper; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -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.PlayerInteractAtEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.jooq.SQLDialect; -import org.jooq.impl.DSL; - -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.LinkedList; -import java.util.Queue; -import java.util.TimeZone; -import java.util.UUID; public class BonusManager extends MiniClientPlugin implements ILoginProcessor { @@ -675,8 +677,8 @@ public class BonusManager extends MiniClientPlugin implements I BonusClientData client = Get(player); int availableRewards = 0; - - if (_playWireManager.canRedeem(player)) availableRewards++; + + if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() == -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++; if (_youtubeManager.canYoutube(player)) availableRewards++; if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; @@ -719,9 +721,7 @@ public class BonusManager extends MiniClientPlugin implements I watcher.a(0, (byte) 0, EntityCreeper.META_ENTITYDATA, (byte) 0); watcher.a(1, (short) 300, EntityCreeper.META_AIR, 0); watcher.a(17, (byte) 1, EntityCreeper.META_POWERED, true); - PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); - packet.a = _carlNpc.getEntity().getEntityId(); - packet.b = watcher.c(); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(_carlNpc.getEntity().getEntityId(), watcher, true); UtilPlayer.sendPacket(player, packet); } @@ -736,9 +736,7 @@ public class BonusManager extends MiniClientPlugin implements I // Charged DataWatcher watcher = new DataWatcher(null); watcher.a(17, (byte) 0, EntityCreeper.META_POWERED, false); - PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); - packet.a = _carlNpc.getEntity().getEntityId(); - packet.b = watcher.c(); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(_carlNpc.getEntity().getEntityId(), watcher, true); UtilPlayer.sendPacket(player, packet); } @@ -841,7 +839,7 @@ public class BonusManager extends MiniClientPlugin implements I { if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) { - if(_pollManager.hasPoll(player) || _playWireManager.canRedeem(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) + if(_pollManager.hasPoll(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() == -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) { if(_showCarl.containsKey(player.getName())) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java index a427b793b..ae4c59806 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java @@ -1,14 +1,15 @@ package mineplex.core.bonuses.gui.buttons; +import org.bukkit.Material; +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.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.playwire.PlayWireManager; import mineplex.core.recharge.Recharge; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; /** * @@ -20,11 +21,11 @@ public class PlayWireButton implements GuiItem .setTitle(C.cGreen + C.Bold + "Watch an Ad!") .addLore( C.cWhite + "You have already redeemed your", - C.cWhite + "rewards for watching the Ad!", + C.cWhite + "rewards for watching the Ads!", " ", - C.cWhite + "You can watch it again, but you won't earn any shards!", + C.cWhite + "You can watch some more, but you won't earn any rewards!", " ", - C.cWhite + "You can watch the Ad once every hour.", + C.cWhite + "You can watch 5 Ads every 24 hours.", " ", C.cWhite + "Ads help us keep Mineplex awesome", C.cRedB + "Be sure to have your AdBlocker disabled!", @@ -36,11 +37,10 @@ public class PlayWireButton implements GuiItem private static final ItemStack ENABLED_ICON = new ItemBuilder(Material.TRIPWIRE_HOOK) .setTitle(C.cGreen + C.Bold + "Watch an Ad!") .addLore( - C.cYellow + "Earn a 100 Shard Reward", - C.cYellow + "and 1 Carl Spin Ticket", + C.cYellow + "Earn 1 Carl Spin Ticket", C.cWhite + "by checking out our partner's Advertisement", " ", - C.cWhite + "You can watch the Ad once every hour.", + C.cWhite + "You can watch 5 Ads every 24 hours.", " ", C.cWhite + "Ads help us keep Mineplex awesome", C.cRedB + "Be sure to have your AdBlocker disabled!", @@ -61,7 +61,11 @@ public class PlayWireButton implements GuiItem @Override public ItemStack getObject() { - return _manager.canRedeem(_player) ? ENABLED_ICON : DISABLED_ICON; + if (_manager.Get(_player) == null || _manager.Get(_player).getAccountId() == -1) + { + return DISABLED_ICON; + } + return _manager.canRedeemTickets(_manager.Get(_player)) ? ENABLED_ICON : DISABLED_ICON; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index c9eb2cd78..2d231cdd3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -11,6 +11,12 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +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 mineplex.core.bonuses.BonusManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -22,11 +28,6 @@ import mineplex.core.powerplayclub.PowerPlayClubRepository; import mineplex.core.powerplayclub.PowerPlayClubRewards; import mineplex.core.powerplayclub.PowerPlayData; import mineplex.core.shop.item.ShopItem; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; public class PowerPlayClubButton implements GuiItem { @@ -77,7 +78,7 @@ public class PowerPlayClubButton implements GuiItem } else { - UtilPlayer.message(_player, F.main("Power Play Club", "You have no months left! Buy more months at " + C.cAqua + "www.mineplex.com/shop" + C.Reset + "!")); + UtilPlayer.message(_player, F.main("Power Play Club", "You have no months left! Buy more months at " + F.greenElem("www.mineplex.com/shop") + "!")); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java index 477fa382d..cab491f83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java @@ -85,8 +85,8 @@ public class YoutubeButton implements GuiItem UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); UtilPlayer.message(_player, ""); - new JsonMessage(" " + C.Bold + "Click to Open in Web Browser and " + message).click(ClickEvent.OPEN_URL, "https://www.youtube.com/embed/RW3sOmkiEG-A?list=UU1MtBclG_aHPd0nLmUupCKg&controls=0&showinfo=0&autoplay=1").sendToPlayer(_player); - new JsonMessage( " " + C.cGreen + C.Line + "http://youtube.com/mineplexgamesofficial").click(ClickEvent.OPEN_URL, "https://www.youtube.com/embed/RW3sOmkiEG-A?list=UU1MtBclG_aHPd0nLmUupCKg&controls=0&showinfo=0&autoplay=1").sendToPlayer(_player); + new JsonMessage(" " + C.Bold + "Click to Open in Web Browser and " + message).click(ClickEvent.OPEN_URL, "http://file.mineplex.com/ads.php").sendToPlayer(_player); + new JsonMessage( " " + C.cGreen + C.Line + "http://youtube.com/mineplexgamesofficial").click(ClickEvent.OPEN_URL, "http://file.mineplex.com/ads.php").sendToPlayer(_player); UtilPlayer.message(_player, ""); UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java index 7f063cf6a..aea72eb29 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java @@ -20,6 +20,8 @@ import mineplex.core.report.data.Report; */ public class SnapshotManager { + public static final int MAX_SNAPSHOTS = 5; + // There aren't any List or Set caching implementations // For an easy work around, we store values as the Key // For the value we just use some dummy object @@ -38,7 +40,7 @@ public class SnapshotManager _snapshotRepository = snapshotRepository; } - public SnapshotRepository getSnapshotRepository() + public SnapshotRepository getRepository() { return _snapshotRepository; } @@ -74,21 +76,21 @@ public class SnapshotManager * Does not include PMs unless sender or receiver is in the exclusions collection. * * @param accountId the account to search for messages involved in - * @param pmIdWhitelist a list of account ids of which to include PMs of + * @param pmWhitelistIds a list of account ids of which to include PMs of * @return the messages that the account is involved in */ - public Set getMessagesInvolving(int accountId, Collection pmIdWhitelist) + public Set getMessagesInvolving(int accountId, Collection pmWhitelistIds) { return getMessagesInvolving(accountId).stream() - .filter(message -> includeMessage(message, pmIdWhitelist)) + .filter(message -> includeMessage(message, pmWhitelistIds)) .collect(Collectors.toCollection(TreeSet::new)); } - private boolean includeMessage(SnapshotMessage message, Collection pmExclusions) + private boolean includeMessage(SnapshotMessage message, Collection pmWhitelistIds) { return message.getType() != MessageType.PM || - pmExclusions.contains(message.getSenderId()) || - !Collections.disjoint(message.getRecipientIds(), pmExclusions); + pmWhitelistIds.contains(message.getSenderId()) || + !Collections.disjoint(message.getRecipientIds(), pmWhitelistIds); } /** @@ -134,18 +136,19 @@ public class SnapshotManager public CompletableFuture saveReportSnapshot(Report report, Collection messages) { - return _snapshotRepository - .saveReportSnapshot(report, messages) - .whenComplete((snapshotMetadata, throwable) -> - { - if (throwable == null) - { - report.setSnapshotMetadata(snapshotMetadata); - } - else - { - _javaPlugin.getLogger().log(Level.SEVERE, "Error whilst saving snapshot.", throwable); - } - }); + SnapshotMetadata snapshotMetadata = report.getSnapshotMetadata().orElseThrow(() -> + new IllegalStateException("Report does not have associated snapshot.")); + + return _snapshotRepository.insertMessages(snapshotMetadata.getId(), messages).whenComplete(((aVoid, throwable) -> + { + if (throwable == null) + { + report.setSnapshotMetadata(snapshotMetadata); + } + else + { + _javaPlugin.getLogger().log(Level.SEVERE, "Error whilst saving snapshot.", throwable); + } + })).thenApply(aVoid -> snapshotMetadata); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java index 774e9d962..7aaba16a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java @@ -11,6 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.chatsnap.command.ChatSnapCommand; import mineplex.core.message.PrivateMessageEvent; /** @@ -36,7 +37,7 @@ public class SnapshotPlugin extends MiniPlugin @Override public void addCommands() { - + addCommand(new ChatSnapCommand(this)); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java index e832cd8b6..261f081f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java @@ -6,15 +6,16 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; +import java.util.ArrayList; import java.util.Base64; import java.util.Collection; +import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.logging.Level; import java.util.logging.Logger; import mineplex.core.common.util.UtilTime; -import mineplex.core.report.data.Report; import mineplex.serverdata.database.DBPool; /** @@ -65,13 +66,14 @@ public class SnapshotRepository return token; } - private static final String INSERT_SNAPSHOT = "INSERT INTO snapshots (token, creator) VALUES (?, ?);"; + private static final String INSERT_SNAPSHOT = "INSERT INTO snapshots (token, creatorId) VALUES (?, ?);"; private static final String INSERT_MESSAGE = "INSERT INTO snapshotMessages (senderId, `server`, `time`, message, snapshotType) VALUES (?, ?, ?, ?, ?);"; private static final String INSERT_MESSAGE_RECIPIENT = "INSERT INTO snapshotRecipients (messageId, recipientId) VALUES (?, ?);"; private static final String INSERT_MESSAGE_MAPPING = "INSERT INTO snapshotMessageMap (snapshotId, messageId) VALUES (?, ?);"; private static final String GET_ID_FROM_TOKEN = "SELECT snapshots.id FROM snapshots WHERE snapshots.token = ?;"; - private static final String GET_METADATA = "SELECT token, creator FROM snapshots WHERE id = ?;"; + private static final String GET_METADATA = "SELECT token, creatorId FROM snapshots WHERE id = ?;"; private static final String SET_TOKEN = "UPDATE snapshots SET token = ? WHERE id = ?;"; + private static final String GET_USER_SNAPSHOTS = "SELECT snapshots.id FROM snapshots WHERE snapshots.creatorId = ?;"; private final String _serverName; private final Logger _logger; @@ -82,42 +84,6 @@ public class SnapshotRepository _logger = logger; } - public CompletableFuture saveReportSnapshot(Report report, Collection messages) - { - return CompletableFuture.supplyAsync(() -> - { - try (Connection connection = DBPool.getAccount().getConnection()) - { - SnapshotMetadata snapshotMetadata = report.getSnapshotMetadata().orElseThrow(() -> - new IllegalStateException("Report does not have associated snapshot.")); - - insertMessages(snapshotMetadata.getId(), messages, connection); - return snapshotMetadata; - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - }); - } - - public CompletableFuture saveSnapshot(Collection messages) - { - return CompletableFuture.supplyAsync(() -> - { - try (Connection connection = DBPool.getAccount().getConnection()) - { - SnapshotMetadata snapshotMetadata = createSnapshot(connection, null); - insertMessages(snapshotMetadata.getId(), messages, connection); - return snapshotMetadata; - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - }); - } - public CompletableFuture createSnapshot(Integer creatorAccountId) { return CompletableFuture.supplyAsync(() -> @@ -218,7 +184,7 @@ public class SnapshotRepository setToken(connection, snapshotId, token); } - Integer creatorId = resultSet.getInt("creator"); + Integer creatorId = resultSet.getInt("creatorId"); if (resultSet.wasNull()) creatorId = null; return new SnapshotMetadata(snapshotId, token, creatorId); @@ -244,6 +210,40 @@ public class SnapshotRepository return future; } + public CompletableFuture> getUserSnapshots(int creatorId) + { + CompletableFuture> future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_SNAPSHOTS); + preparedStatement.setInt(1, creatorId); + + ResultSet resultSet = preparedStatement.executeQuery(); + List snapshotIds = new ArrayList<>(); + + while (resultSet.next()) + { + snapshotIds.add(resultSet.getInt("id")); + } + + return snapshotIds; + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error getting snapshots for user " + creatorId + "."); + return new ArrayList<>(); + }); + + return future; + } + private void setToken(Connection connection, int snapshotId, String token) throws SQLException { try (PreparedStatement setTokenStatement = connection.prepareStatement(SET_TOKEN)) @@ -254,36 +254,9 @@ public class SnapshotRepository } } - private void insertMessages(int snapshotId, Collection messages, Connection connection) throws SQLException + public CompletableFuture insertMessages(int snapshotId, Collection messages) { - try (PreparedStatement insertSnapshotStatement = connection.prepareStatement(INSERT_MESSAGE, new String[]{"id"})) - { - try (PreparedStatement insertRecipientStatement = connection.prepareStatement(INSERT_MESSAGE_RECIPIENT)) - { - try (PreparedStatement insertMappingStatement = connection.prepareStatement(INSERT_MESSAGE_MAPPING)) - { - for (SnapshotMessage message : messages) - { - try - { - insertMessage(insertSnapshotStatement, insertRecipientStatement, insertMappingStatement, snapshotId, message); - } - catch (Exception e) - { - _logger.log(Level.SEVERE, "Error inserting snapshot message.", e); - } - } - - insertRecipientStatement.executeBatch(); - insertMappingStatement.executeBatch(); - } - } - } - } - - public CompletableFuture insertMessage(int snapshotId, SnapshotMessage message) - { - return CompletableFuture.supplyAsync(() -> + CompletableFuture future = CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { @@ -293,7 +266,21 @@ public class SnapshotRepository { try (PreparedStatement insertMappingStatement = connection.prepareStatement(INSERT_MESSAGE_MAPPING)) { - insertMessage(insertSnapshotStatement, insertRecipientStatement, insertMappingStatement, snapshotId, message); + for (SnapshotMessage message : messages) + { + try + { + insertMessage(insertSnapshotStatement, insertRecipientStatement, insertMappingStatement, snapshotId, message); + } + catch (Exception e) + { + _logger.log(Level.SEVERE, "Error inserting snapshot message.", e); + } + } + + insertRecipientStatement.executeBatch(); + insertMappingStatement.executeBatch(); + return null; } } } @@ -302,9 +289,15 @@ public class SnapshotRepository { throw new RuntimeException(e); } + }); + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error whilst inserting messages into snapshot.", throwable); return null; }); + + return future; } private void insertMessage(PreparedStatement insertSnapshotStatement, PreparedStatement insertRecipientStatement, PreparedStatement insertMappingStatement, int snapshotId, SnapshotMessage message) throws SQLException diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java new file mode 100644 index 000000000..1c085c647 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java @@ -0,0 +1,71 @@ +package mineplex.core.chatsnap.command; + +import java.util.Set; + +import org.bukkit.entity.Player; + +import mineplex.core.chatsnap.SnapshotManager; +import mineplex.core.chatsnap.SnapshotMessage; +import mineplex.core.chatsnap.SnapshotPlugin; +import mineplex.core.chatsnap.SnapshotRepository; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +/** + * A command which when executed will create a chat log which will be viewable online. + */ +public class ChatSnapCommand extends CommandBase +{ + public ChatSnapCommand(SnapshotPlugin plugin) + { + super(plugin, Rank.TITAN, "chatsnap"); + } + + @Override + public void Execute(Player player, String[] args) + { + if (args == null || args.length == 0) + { + SnapshotManager manager = Plugin.getSnapshotManager(); + SnapshotRepository repository = manager.getRepository(); + int accountId = _commandCenter.GetClientManager().getAccountId(player); + + Plugin.getSnapshotManager().getRepository().getUserSnapshots(accountId).thenAccept(snapshotIds -> + { + if (snapshotIds.size() < SnapshotManager.MAX_SNAPSHOTS) + { + Set messages = manager.getMessagesInvolving(accountId); + + repository.createSnapshot(accountId).thenAccept(snapshotMetadata -> + { + String token = snapshotMetadata.getToken().orElseThrow(() -> + new IllegalStateException("Snapshot doesn't have a token.")); + + repository.insertMessages(snapshotMetadata.getId(), messages).join(); + + UtilPlayer.message(player, F.main(Plugin.getName(), "Snapshot successfully created.")); + + new JsonMessage(F.main(Plugin.getName(), "Your snapshot token is: ")) + .extra(F.elem(token)) + .click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(token)) + .sendToPlayer(player); + }); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), + C.cRed + "Cannot create snapshot, you have reached the limit.")); + } + }); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed))); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsCommand.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsCommand.java index d34a6ebb1..0c11fc2d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.chatsnap.command; +package mineplex.core.chatsnap.redis; import java.util.Set; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsHandler.java rename to Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java index a499a7332..b6668041c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java @@ -1,4 +1,4 @@ -package mineplex.core.chatsnap.command; +package mineplex.core.chatsnap.redis; import java.util.Set; import mineplex.core.chatsnap.SnapshotMessage; @@ -35,7 +35,7 @@ public class PushSnapshotsHandler implements CommandCallback if (messages.size() > 0) { - _reportManager.getReportRepository().getReport(reportId).thenAccept(reportOptional -> + _reportManager.getRepository().getReport(reportId).thenAccept(reportOptional -> { if (reportOptional.isPresent()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index db7597b9d..92301a0e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -2,6 +2,7 @@ package mineplex.core.command; import com.google.common.collect.Lists; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -21,8 +22,8 @@ public class CommandCenter implements Listener protected JavaPlugin Plugin; protected CoreClientManager ClientManager; protected static NautHashMap Commands; - private final List BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit"); - private final String MESSAGE = C.cRed + "I''m sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."; + private final List BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit", "about", "?", "help"); + private final String MESSAGE = C.cRed + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."; public static void Initialize(JavaPlugin plugin) { @@ -59,13 +60,6 @@ public class CommandCenter implements Listener args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" "); } - if(BLOCKED_COMMANDS.contains(commandName.toLowerCase())) - { - event.setCancelled(true); - event.getPlayer().sendMessage(MESSAGE); - return; - } - ICommand command = Commands.get(commandName.toLowerCase()); if (command != null) @@ -84,6 +78,14 @@ public class CommandCenter implements Listener command.SetAliasUsed(commandName.toLowerCase()); command.Execute(event.getPlayer(), args); } + return; + } + + if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER))) + { + event.setCancelled(true); + event.getPlayer().sendMessage(MESSAGE); + return; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/PetSorter.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/PetSorter.java deleted file mode 100644 index 64de96efc..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/PetSorter.java +++ /dev/null @@ -1,16 +0,0 @@ -package mineplex.core.cosmetic.ui; - -import java.util.Comparator; - -import mineplex.core.pet.Pet; - -public class PetSorter implements Comparator -{ - public int compare(Pet a, Pet b) - { - if (a.getPetType().getTypeId() < b.getPetType().getTypeId()) - return -1; - - return 1; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java index 6578303c7..331fa43b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java @@ -3,23 +3,23 @@ package mineplex.core.cosmetic.ui.button; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.pet.Pet; import mineplex.core.cosmetic.ui.page.PetPage; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; public class PetButton implements IButton { - private Pet _pet; + private PetType _petType; private PetPage _page; - public PetButton(Pet pet, PetPage page) + public PetButton(PetType pet, PetPage page) { - _pet = pet; + _petType = pet; _page = page; } public void onClick(Player player, ClickType clickType) { - _page.purchasePet(player, _pet); + _page.purchasePet(player, _petType); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java index 82cad1f70..631d92c20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java @@ -1,11 +1,10 @@ package mineplex.core.cosmetic.ui.button; -import org.bukkit.entity.Creature; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import mineplex.core.cosmetic.ui.page.PetPage; -import mineplex.core.pet.Pet; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; public class RenamePetButton implements IButton @@ -21,7 +20,7 @@ public class RenamePetButton implements IButton public void onClick(Player player, ClickType clickType) { _page.playAcceptSound(player); - Creature currentPet = _page.getPlugin().getPetManager().getActivePet(player.getName()); - _page.renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false); + PetType currentType = _page.getPlugin().getPetManager().getActivePetType(player.getName()); + _page.renamePet(player, currentType, false); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java index 61539e368..310b5843c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java @@ -5,15 +5,15 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.PetPage; -import mineplex.core.pet.Pet; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; public class ActivatePetButton implements IButton { - private Pet _pet; + private PetType _pet; private PetPage _page; - public ActivatePetButton(Pet pet, PetPage page) + public ActivatePetButton(PetType pet, PetPage page) { _pet = pet; _page = page; @@ -23,7 +23,7 @@ public class ActivatePetButton implements IButton public void onClick(Player player, ClickType clickType) { _page.playAcceptSound(player); - _page.getPlugin().getPetManager().addPetOwner(player, _pet.getPetType(), player.getLocation()); + _page.getPlugin().getPetManager().addPetOwner(player, _pet, player.getLocation()); _page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java index 52c877e7d..80db4bcd6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java @@ -26,7 +26,7 @@ public class ArrowTrailPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ARROW_TRAIL)) { @@ -37,8 +37,8 @@ public class ArrowTrailPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java index 6eebd5515..4d7b0276c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java @@ -1,5 +1,9 @@ package mineplex.core.cosmetic.ui.page; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; @@ -9,9 +13,6 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; public class BalloonsPage extends GadgetPage { @@ -24,7 +25,7 @@ public class BalloonsPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.BALLOON)) { @@ -35,10 +36,8 @@ public class BalloonsPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; - if(slot == 35) - slot = 37; + if (slot == 17 || slot == 26) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java index 22a203051..07dbee136 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java @@ -26,7 +26,7 @@ public class DeathEffectPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.DEATH)) { @@ -37,8 +37,8 @@ public class DeathEffectPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java index 9e7ab7349..f9748cb06 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java @@ -26,7 +26,7 @@ public class DoubleJumpPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.DOUBLE_JUMP)) { @@ -37,8 +37,8 @@ public class DoubleJumpPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() 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 bd55b33f0..b699559ff 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 @@ -53,7 +53,7 @@ public class GadgetPage extends ShopPageBase protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM)) { @@ -67,7 +67,7 @@ public class GadgetPage extends ShopPageBase slot++; - if (slot == 26 || slot == 35) + if (slot == 17 || slot == 26) slot += 2; } @@ -165,7 +165,7 @@ public class GadgetPage extends ShopPageBase } else { - itemLore.add(C.cBlue + "Found in Power Play Club"); + itemLore.add(C.cBlue + "Bonus Item Unlocked with Power Play Club"); } } @@ -355,7 +355,25 @@ public class GadgetPage extends ShopPageBase } } - addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new ActivateGadgetButton(gadget, this)); + /*if (gadget instanceof MorphStray) + { + gadgetItemStack = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, gadgetItemStack); + }*/ + + IButton iButton = new ActivateGadgetButton(gadget, this); + + /*if (gadgetItemStack.getData().getItemType().equals(Material.BARRIER)) + { + iButton = null; + } + else + { + // Does not set the item stack yet + //gadgetItemStack.setType(Material.getMaterial(440)); + }*/ + + + addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), iButton); } } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java index c37e4dc9c..37f472616 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java @@ -29,7 +29,7 @@ public class HatPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; List list = getPlugin().getGadgetManager().getGadgets(GadgetType.HAT); if(list != null) @@ -42,8 +42,8 @@ public class HatPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() 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 4ab38eae7..90e02e269 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 @@ -25,13 +25,12 @@ import mineplex.core.donation.DonationManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; -import mineplex.core.pet.Pet; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; import org.bukkit.Material; import org.bukkit.entity.Creature; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -122,10 +121,10 @@ public class Menu extends ShopPageBase int petOwned = 0; int petMax = 0; - for (Pet pet : getPlugin().getPetManager().getFactory().GetPets()) + for (PetType type : PetType.values()) { - Map pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); - if (pets != null && pets.containsKey(pet.getPetType())) + Map pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); + if (pets != null && pets.containsKey(type)) { petOwned++; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java index 291921cd4..682140891 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java @@ -1,5 +1,9 @@ package mineplex.core.cosmetic.ui.page; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; @@ -10,9 +14,6 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; public class MorphPage extends GadgetPage { @@ -24,7 +25,7 @@ public class MorphPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.MORPH)) { @@ -35,11 +36,9 @@ public class MorphPage extends GadgetPage addGlow(slot); slot++; - - if (slot == 26) - slot = 28; - if (slot == 35) - slot = 37; + + if (slot == 17 || slot == 26 || slot == 35) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 86638709d..24d260e4a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -39,15 +39,15 @@ public class MountPage extends ShopPageBase protected void buildPage() { - int slot = 19; + int slot = 10; for (Mount mount : getPlugin().getMountManager().getMounts()) { addMount(mount, slot); slot++; - if (slot == 26) - slot = 28; + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 7acb6a46c..54ff244d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java @@ -26,7 +26,7 @@ public class MusicPage extends GadgetPage protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.MUSIC_DISC)) { @@ -34,8 +34,8 @@ public class MusicPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java index 479841a09..0bd0885c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java @@ -24,7 +24,7 @@ public class ParticlePage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.PARTICLE)) { @@ -35,10 +35,8 @@ public class ParticlePage extends GadgetPage slot++; - if (slot == 26) - slot = 28; - if(slot == 35) - slot = 37; + if (slot == 17 || slot == 26) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index 30bd7bf8c..cf903bc21 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -1,7 +1,9 @@ package mineplex.core.cosmetic.ui.page; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import net.minecraft.server.v1_8_R3.Blocks; @@ -25,14 +27,13 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.PetSorter; import mineplex.core.cosmetic.ui.button.PetButton; import mineplex.core.cosmetic.ui.button.RenamePetButton; import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton; import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton; import mineplex.core.donation.DonationManager; -import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.AnvilContainer; @@ -49,87 +50,91 @@ public class PetPage extends ShopPageBase protected void buildPage() { - int slot = 19; - - List pets = new ArrayList(getPlugin().getPetManager().getFactory().GetPets()); - - Collections.sort(pets, new PetSorter()); - - for (Pet pet : pets) + int slot = 10; + + PetType[] pets = PetType.values(); + Arrays.sort(pets, Comparator.comparing(type -> type.getEntityType().getTypeId())); + + for (PetType pet : pets) { List itemLore = new ArrayList(); itemLore.add(C.cBlack); - if (pet.getLore() != null) + if (pet.getLore().isPresent()) { - Collections.addAll(itemLore, UtilText.splitLineToArray(C.cGray + pet.getLore(), LineFormat.LORE)); + Collections.addAll(itemLore, UtilText.splitLineToArray(C.cGray + pet.getLore().get(), LineFormat.LORE)); } else { itemLore.add(C.cGray + "Your very own " + pet.getName() + "!"); } //Chest Unlocks - if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType())) + if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet)) { - if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -1) + if (pet.getPrice() == -1) { //Nothing } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) + else if (pet.getPrice() == -2 || pet.getPrice() > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -3) + else if (pet.getPrice() == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -4) + else if (pet.getPrice() == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Earned by defeating the Pumpkin King"); itemLore.add(C.cBlue + "in the 2014 Christmas Chaos Event."); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -5) + else if (pet.getPrice() == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -8) + else if (pet.getPrice() == -8) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Pumpkin's Revenge"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -9) + else if (pet.getPrice() == -9) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Haunted Chests"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -14) + else if (pet.getPrice() == -14) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in Power Play Club"); + } + else if (pet.getPrice() == -14) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Power Play Club"); } //Rank Unlocks - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -10) + else if (pet.getPrice() == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -11) + else if (pet.getPrice() == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -12) + else if (pet.getPrice() == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -13) + else if (pet.getPrice() == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); @@ -137,21 +142,21 @@ public class PetPage extends ShopPageBase } //Owned - if (getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType())) + if (getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet)) { - String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet.getPetType()); + String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet); if (petName == null) { petName = pet.getName(); } - if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() == pet.getPetType()) + if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePetType(getPlayer().getName()) == pet) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Disable"); - addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(), - pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")", + addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getEntityType().getTypeId(), + pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager())); addGlow(slot); @@ -160,56 +165,76 @@ public class PetPage extends ShopPageBase { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Enable"); + /* + ItemStack petItem = ItemStackFactory.Instance.CreateStack(pet.getMaterial(), pet.getData(), 1, + pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore); + + IButton iButton = new ActivatePetButton(pet, this); + + if (pet.equals(PetType.SHULKER)) + { + petItem = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, petItem); + if (petItem.getType().equals(Material.BARRIER)) + { + iButton = null; + } + else + { + // Does not set the item stack yet + //petItem.setType(Material.getMaterial(201)); + } + }*/ - addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(), - pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")", + addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getEntityType().getTypeId(), + pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this)); + //addButton(slot, new ShopItem(petItem, false, false), iButton); } } //Not Owned else { - if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) + if (pet.getPrice() > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getPrice() + " Treasure Shards"); } - if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD)) + if (pet.getPrice() > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getPrice()) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); - addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this)); + addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this)); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) + else if (pet.getPrice() > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } else { - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } } slot++; - - if (slot == 26) - slot = 28; + + if (slot == 17 || slot == 26) + slot += 2; } slot = 49; - for (PetExtra petExtra : getPlugin().getPetManager().getFactory().GetPetExtras()) + for (PetExtra petExtra : PetExtra.values()) { List itemLore = new ArrayList(); if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) { itemLore.add(C.cWhite + "You must have an active pet to use this!"); - getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); + getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); } // Silverfish = Wither disguised // Villager = Elf @@ -218,7 +243,7 @@ public class PetPage extends ShopPageBase || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.ZOMBIE) { - addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(GlobalCurrency.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); + addButton(slot, new ShopItem(petExtra.getMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getPrice(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); } slot++; @@ -233,12 +258,12 @@ public class PetPage extends ShopPageBase }); } - public void purchasePet(final Player player, final Pet pet) + public void purchasePet(final Player player, final PetType petType) { - renamePet(player, pet, true); + renamePet(player, petType, true); } - public void renamePet(Player player, Pet pet, boolean petPurchase) + public void renamePet(Player player, PetType pet, boolean petPurchase) { playAcceptSound(player); @@ -260,4 +285,4 @@ public class PetPage extends ShopPageBase getPlugin().getPetManager().removePet(player, true); refresh(); } -} \ No newline at end of file +} 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 0a5c568fa..49756c42f 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 @@ -1,9 +1,14 @@ package mineplex.core.cosmetic.ui.page; +import net.minecraft.server.v1_8_R3.ItemStack; +import net.minecraft.server.v1_8_R3.Items; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + import mineplex.cache.player.PlayerCache; import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; @@ -11,31 +16,26 @@ import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.CloseButton; import mineplex.core.cosmetic.ui.button.SelectTagButton; import mineplex.core.donation.DonationManager; -import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; +import mineplex.core.pet.PetType; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.page.ShopPageBase; -import net.minecraft.server.v1_8_R3.ItemStack; -import net.minecraft.server.v1_8_R3.Items; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; public class PetTagPage extends ShopPageBase { private String _tagName = "Pet Tag"; - private Pet _pet; + private PetType _petType; private boolean _petPurchase; - public PetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase) + public PetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, PetType petType, boolean petPurchase) { super(plugin, shop, clientManager, donationManager, name, player, 3); - _pet = pet; + _petType = petType; _petPurchase = petPurchase; buildPage(); @@ -84,7 +84,7 @@ public class PetTagPage extends ShopPageBase return; } - if (_tagName.equalsIgnoreCase("ULTRA")) + if (_tagName.toLowerCase().contains("ultra")) { UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + _tagName + " is a restricted name.")); playDenySound(getPlayer()); @@ -92,11 +92,16 @@ public class PetTagPage extends ShopPageBase getShop().openPageForPlayer(getPlayer(), new PetPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Pets", getPlayer())); return; } - - PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100); - final SalesPackageBase salesPackage = _petPurchase ? _pet : tag; - - _pet.setDisplayName(C.cGreen + "Purchase " + _tagName); + + final SalesPackageBase salesPackage; + if (_petPurchase) + { + salesPackage = _petType.toSalesPackage(_tagName); + + } else + { + salesPackage = PetExtra.NAME_TAG.toSalesPackage("Rename " + _petType.getName() + " to " + _tagName); + } getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(_player, this, new SalesPackageProcessor(_player, GlobalCurrency.TREASURE_SHARD, salesPackage, _donationManager, () -> { @@ -108,8 +113,7 @@ public class PetTagPage extends ShopPageBase token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId(); token.Name = getPlayer().getName(); - token.PetType = _pet.getPetType().toString(); - token.PetId = _pet.getPetType().ordinal(); + token.PetType = _petType.toString(); token.PetName = _tagName; PetToken petToken = new PetToken(); @@ -118,7 +122,7 @@ public class PetTagPage extends ShopPageBase if (_petPurchase) { getPlugin().getPetManager().getRepository().AddPet(token); - getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType()); + getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _petType); } else { @@ -126,7 +130,7 @@ public class PetTagPage extends ShopPageBase getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName); } - getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName); + getPlugin().getPetManager().Get(getPlayer()).getPets().put(_petType, token.PetName); getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer())); }), salesPackage.buildIcon())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java index 1ff5531fc..3db625e5d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java @@ -29,7 +29,7 @@ public class TauntPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; List list = getPlugin().getGadgetManager().getGadgets(GadgetType.TAUNT); if(list != null) @@ -43,7 +43,7 @@ public class TauntPage extends GadgetPage slot++; if (slot == 26) - slot = 28; + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index 74b50f0ea..3236de2fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -26,7 +26,7 @@ public class WinEffectPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT)) { @@ -37,8 +37,8 @@ public class WinEffectPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierPage.java index beeeba200..3b513420a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierPage.java @@ -2,8 +2,6 @@ package mineplex.core.cosmetic.ui.page.gamemodifiers; import java.util.List; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.cosmetic.ui.page.Menu; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,6 +12,8 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.page.GadgetPage; +import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.types.GameModifierGadget; @@ -32,7 +32,7 @@ public class GameModifierPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (GameModifierType type : GameModifierType.values()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java index 8049beb5d..7e7dc50c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java @@ -1,24 +1,24 @@ package mineplex.core.cosmetic.ui.page.gamemodifiers; -import mineplex.core.cosmetic.ui.page.GadgetPage; +import java.util.List; + 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.ItemMeta; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.page.GadgetPage; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; import mineplex.core.gadget.types.GameModifierGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.List; public class GameModifierSubPage extends GadgetPage { @@ -38,7 +38,7 @@ public class GameModifierSubPage extends GadgetPage { if(_type == null) return; - int slot = 19; + int slot = 10; if (_type.hasKits()) { @@ -78,7 +78,7 @@ public class GameModifierSubPage extends GadgetPage slot++; - if(slot%9 == 8) slot += 2; + if(slot % 9 == 8) slot += 2; } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java index 77590aa93..ec71a2f5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java @@ -1,5 +1,9 @@ package mineplex.core.cosmetic.ui.page.gamemodifiers; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; @@ -12,9 +16,6 @@ import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; import mineplex.core.gadget.types.GameModifierGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; public class KitGameModifierPage extends GadgetPage { @@ -36,7 +37,7 @@ public class KitGameModifierPage extends GadgetPage { if(_type == null) return; - int slot = 19; + int slot = 10; for (GameModifierGadget gadget : getPlugin().getGadgetManager().getGameModifiers(_kitType)) { @@ -52,7 +53,7 @@ public class KitGameModifierPage extends GadgetPage slot++; - if(slot%9 == 8) slot += 2; + if(slot % 9 == 8) slot += 2; } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java index faf8929e2..33e0ed950 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java @@ -10,6 +10,7 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Ageable; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Guardian; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; @@ -163,6 +164,16 @@ public class MobCommand extends MultiCommandBase UtilPlayer.message(caller, F.desc("Angry", "True")); argHandle.add(arg); } + + else if (arg.equalsIgnoreCase("elder")) + { + for (Entity ent : entSet) + if (ent instanceof Guardian) + ((Guardian)ent).setElder(true); + + UtilPlayer.message(caller, F.desc("Elder", "True")); + argHandle.add(arg); + } //Profession else if (arg.toLowerCase().charAt(0) == 'p') diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 419576874..78086823e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -114,6 +114,7 @@ import mineplex.core.gadget.gadgets.morph.MorphCow; import mineplex.core.gadget.gadgets.morph.MorphCreeper; import mineplex.core.gadget.gadgets.morph.MorphEnderman; import mineplex.core.gadget.gadgets.morph.MorphGrimReaper; +import mineplex.core.gadget.gadgets.morph.MorphMetalMan; import mineplex.core.gadget.gadgets.morph.MorphPig; import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing; import mineplex.core.gadget.gadgets.morph.MorphSlime; @@ -366,10 +367,11 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphSquid(this)); addGadget(new MorphWitch(this)); addGadget(new MorphGrimReaper(this)); + addGadget(new MorphMetalMan(this)); addGadget(new MorphTurkey(this)); - // Hidden in this update - //addGadget(new MorphSleigh(this)); - //addGadget(new MorphMetalMan(this)); + // Not in this update + //addGadget(new MorphStray(this)); + //addGadget(new MorphSanta(this)); // Particles addGadget(new ParticleFoot(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java index 4f7a4df5c..c2d289d9c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java @@ -1,6 +1,7 @@ package mineplex.core.gadget.commands; -import mineplex.core.account.CoreClient; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -8,7 +9,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; -import org.bukkit.entity.Player; public class AmmoCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java index e726517a2..e81367341 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.commands; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -10,10 +13,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; -import mineplex.core.pet.Pet; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; +import mineplex.core.pet.PetType; public class LockCosmeticsCommand extends CommandBase { @@ -106,11 +106,10 @@ public class LockCosmeticsCommand extends CommandBase private void removePets(Player caller) { int removed = 0; - for (Pet pet : _plugin.getPetManager().getFactory().GetPets()) + for (PetType pet : PetType.values()) { - if (_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType())) + if (_plugin.getPetManager().Get(caller).getPets().remove(pet) != null) { - _plugin.getPetManager().Get(caller).getPets().remove(pet.getPetType()); removed++; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java deleted file mode 100644 index b8af63074..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java +++ /dev/null @@ -1,85 +0,0 @@ -package mineplex.core.gadget.commands; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.EulerAngle; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilServer; -import mineplex.core.gadget.GadgetManager; - -public class ReindeerTestCommand extends CommandBase -{ - - private GadgetManager _plugin; - private Horse _horse; - private ArmorStand _armorStand; - - public ReindeerTestCommand(GadgetManager plugin) - { - super(plugin, Rank.JNR_DEV, "reindeer"); - _plugin = plugin; - } - - @Override - public void Execute(Player caller, String[] args) - { - if (_horse == null) - { - Location testHorse = new Location(caller.getWorld(), 8.5, 71, 0.5, 0, 0); - testHorse.setYaw(180); - Horse horse = testHorse.getWorld().spawn(testHorse, Horse.class); - horse.setVariant(Horse.Variant.HORSE); - horse.setColor(Horse.Color.BROWN); - horse.setStyle(Horse.Style.NONE); - - UtilEnt.Vegetate(horse, true); - UtilEnt.ghost(horse, true, false); - - /** - * South - * .4 1 .6 - * .2 1 .7 - * 0 4 0 - * 0 2 0 - * - * North - */ - - Location hornALoc = horse.getLocation().clone().add(-.3, 1, -.5); - Location hornBLoc = horse.getLocation().clone().add(-.25, 1, -.6); - - ArmorStand hornA = hornALoc.getWorld().spawn(hornALoc, ArmorStand.class); - hornA.setVisible(false); - hornA.setGravity(false); - hornA.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH)); - hornA.setRightArmPose(new EulerAngle(0, 4, 0)); - - ArmorStand hornB = hornBLoc.getWorld().spawn(hornBLoc, ArmorStand.class); - hornB.setVisible(false); - hornB.setGravity(false); - hornB.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH)); - hornB.setRightArmPose(new EulerAngle(0, 2, 0)); - - _horse = horse; - - Bukkit.getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), new Runnable() - { - @Override - public void run() - { - Location location = _horse.getLocation(); - location.setYaw(180); - _horse.teleport(location); - } - }, 1l, 1l); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java index f1867e009..3f4c0ea3d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.commands; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -10,10 +13,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; -import mineplex.core.pet.Pet; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; +import mineplex.core.pet.PetType; public class UnlockCosmeticsCommand extends CommandBase { @@ -111,11 +111,11 @@ public class UnlockCosmeticsCommand extends CommandBase private void addPets(Player caller) { int added = 0; - for (Pet pet : _plugin.getPetManager().getFactory().GetPets()) + for (PetType pet : PetType.values()) { - if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType())) + if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet)) { - _plugin.getPetManager().Get(caller).getPets().put(pet.getPetType(), pet.getName()); + _plugin.getPetManager().Get(caller).getPets().put(pet, pet.getName()); added++; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java index 8e6d2bd51..cdc26c768 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java @@ -6,7 +6,7 @@ import mineplex.core.common.util.UtilText; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect; +import mineplex.core.particleeffects.BabyFireworkEffect; import mineplex.core.gadget.types.ArrowEffectGadget; import org.bukkit.ChatColor; import org.bukkit.Color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java index ebe2d8083..8534e02e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.item; -import mineplex.core.gadget.gadgets.hat.HatType; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; @@ -19,16 +18,18 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.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.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; import mineplex.core.gadget.gadgets.Ammo; +import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; import mineplex.core.gadget.types.ItemGadget; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.pet.PetType; import mineplex.core.recharge.Recharge; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; @@ -130,7 +131,7 @@ public class ItemCoal extends ItemGadget Manager.getPetManager(), Manager.getInventoryManager(), Manager.getDonationManager(), - "Coal Apparition", "Coal Apparition", EntityType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0); + "Coal Apparition", "Coal Apparition", PetType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0); if (reward.canGiveReward(player)) reward.giveReward(null, player, new Callback() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java index 6586967cd..44c761772 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java @@ -105,6 +105,8 @@ public class MorphGrimReaper extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); + player.setFlying(false); + player.setAllowFlight(false); _flying.remove(player); _flyReady.remove(player); _soulManager.resetSouls(player); @@ -189,7 +191,7 @@ public class MorphGrimReaper extends MorphGadget private void setFlying(Player player, boolean flying, boolean isFast) { - if (flying) + if (flying && isActive(player)) { if (UtilPlayer.isSpectator(player)) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java index fbed219e4..06838168e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java @@ -2,15 +2,21 @@ package mineplex.core.gadget.gadgets.morph; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.UUID; 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.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; import com.mojang.authlib.GameProfile; @@ -18,29 +24,39 @@ import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.gadgets.particle.unrelated.MetalManEffect; import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.particleeffects.MetalManEffect; import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; public class MorphMetalMan extends MorphGadget { private Map _playerColors = new HashMap<>(); + private Map _flying = new HashMap<>(); + + private static final int FLY_TIME = 15; public MorphMetalMan(GadgetManager manager) { super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{ C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods", "", - C.cWhite + "Left-click to shoot laser beam" + C.cWhite + "Left-click to shoot laser beam", + C.cWhite + "Sneak to hover" }, LineFormat.LORE), -14, Material.IRON_INGOT, (byte) 0); } @@ -57,6 +73,8 @@ public class MorphMetalMan extends MorphGadget DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); disguisePlayer.showInTabList(true, 0); UtilMorph.disguise(player, disguisePlayer, Manager); + + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1, true, false)); } @Override @@ -65,6 +83,21 @@ public class MorphMetalMan extends MorphGadget removeArmor(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + if (_playerColors.containsKey(player.getUniqueId())) + { + _playerColors.remove(player.getUniqueId()); + } + + if (_flying.containsKey(player)) + { + _flying.remove(player); + } + + player.setFlying(false); + player.setAllowFlight(false); + + player.removePotionEffect(PotionEffectType.SLOW); } @EventHandler @@ -81,7 +114,7 @@ public class MorphMetalMan extends MorphGadget if (player.getItemInHand().getType() != Material.AIR) return; - if (!Recharge.Instance.use(player, getName(), 5000, true, false, "Cosmetics")) + if (!Recharge.Instance.use(player, "Metal Man Missile", 5000, true, false, "Cosmetics")) return; // Creates colored laser @@ -114,6 +147,61 @@ public class MorphMetalMan extends MorphGadget metalManEffect.start(); } + @EventHandler + public void onSneak(PlayerToggleSneakEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (!event.isSneaking()) + return; + + if (_flying.containsKey(event.getPlayer())) + return; + + Player player = event.getPlayer(); + + if (!Recharge.Instance.use(player, "Metal Man Fly", 45000, true, false, "Cosmetics")) + return; + + UtilAction.velocity(player, new Vector(0, 1, 0)); + player.teleport(player.getLocation().add(0, 1, 0)); + player.playSound(player.getLocation(), Sound.WITHER_SHOOT, 1, 1); + _flying.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator> iterator = _flying.entrySet().iterator(); + while (iterator.hasNext()) + { + Map.Entry entry = iterator.next(); + Player player = entry.getKey(); + if (!isActive(player)) + { + iterator.remove(); + continue; + } + long started = entry.getValue(); + if (UtilTime.elapsed(started, 15000)) + { + player.setFlying(false); + player.setAllowFlight(false); + iterator.remove(); + continue; + } + player.setAllowFlight(true); + player.setFlying(true); + int filledBars = (int) ((started + 15000 - System.currentTimeMillis()) / 1000); + UtilTextBottom.displayProgress("Flying", "", 15, filledBars, player); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, player.getLocation(), 0, 0, 0, 0, 5, UtilParticle.ViewDist.NORMAL); + } + } + public void increaseColor(UUID uuid) { if (_playerColors.containsKey(uuid)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSanta.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSanta.java new file mode 100644 index 000000000..42d46a0a1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSanta.java @@ -0,0 +1,281 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.time.Month; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; + +import com.mojang.authlib.GameProfile; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilFirework; +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.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.SantaPresent; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; + +public class MorphSanta extends MorphGadget +{ + + private HashMap _items = new HashMap<>(); + + private static final int SHARD_CHARGE = 50; + + public MorphSanta(GadgetManager manager) + { + super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.SANTA.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + // PRESENT + + @EventHandler + public void throwPresent(PlayerInteractEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (!UtilEvent.isAction(event, UtilEvent.ActionType.L)) + return; + + Player player = event.getPlayer(); + + int type = 0; + + if (UtilMath.random(0.1, 1.1) > 0.76) + { + type = 1; + } + + if (player.getItemInHand().getType() != Material.AIR) + return; + + //if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics")) + //return; + + if (type == 0) + { + int shards = UtilMath.rRange(250, 500); + + if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) < shards + SHARD_CHARGE) + { + UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards.")); + return; + } + + Item present = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), + SkinData.PRESENT.getSkull("Present " + System.currentTimeMillis(), new ArrayList<>())); + UtilAction.velocity(present, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false); + + Manager.getDonationManager().RewardCoinsLater(this.getName() + " Present Hide", player, -(shards + SHARD_CHARGE)); + + present.setPickupDelay(40); + + _items.put(present, new SantaPresent(player.getName(), SantaPresent.PresentType.PRESENT, shards)); + + //Announce + Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() + + ChatColor.RESET + C.Bold + " hid a " + + C.cRed + C.Bold + "Christmas Present" + + ChatColor.RESET + C.Bold + " worth " + + C.cRed + C.Bold + shards + " Shards"); + + for (Player other : UtilServer.getPlayers()) + other.playSound(other.getLocation(), Sound.BLAZE_HIT, 1.5f, 1.5f); + } + else + { + ItemStack coalStack = ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0, 1, "Hidden Coal" + System.currentTimeMillis()); + Item coal = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), coalStack); + UtilAction.velocity(coal, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false); + + int coals = UtilMath.rRange(1, 3); + + coal.setPickupDelay(40); + + _items.put(coal, new SantaPresent(player.getName(), SantaPresent.PresentType.COAL, coals)); + + //Announce + Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() + + ChatColor.RESET + C.Bold + " hid a " + + C.cRed + C.Bold + "Christmas Coal" + + ChatColor.RESET + C.Bold + " worth " + + C.cRed + C.Bold + coals + " Coal Ammo"); + + for (Player other : UtilServer.getPlayers()) + other.playSound(other.getLocation(), Sound.DIG_SNOW, 1.5f, 1.5f); + } + } + + @EventHandler + public void presentPickup(PlayerPickupItemEvent event) + { + if (_items.containsKey(event.getItem()) && !_items.get(event.getItem()).getThrower().equals(event.getPlayer().getName())) + { + SantaPresent santaPresent = _items.get(event.getItem()); + + _items.remove(event.getItem()); + + event.setCancelled(true); + event.getItem().remove(); + + int presentsLeft = 0, coalsLeft = 0; + for (SantaPresent present : _items.values()) + { + if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + presentsLeft++; + } + else if (present.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + coalsLeft++; + } + } + + if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + Manager.getDonationManager().RewardCoinsLater(getName() + " Present Pickup", event.getPlayer(), santaPresent.getAmmo()); + + //Announce + Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() + + ChatColor.RESET + C.Bold + " found a " + + C.cGold + C.Bold + "Christmas Present" + + ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!"); + } + else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + // Gives coals + Manager.getInventoryManager().addItemToInventory(event.getPlayer(), "Coal", santaPresent.getAmmo()); + + //Announce + Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() + + ChatColor.RESET + C.Bold + " found a " + + C.cGold + C.Bold + "Christmas Coal" + + ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!"); + } + + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 0.75f); + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 1.25f); + + UtilFirework.playFirework(event.getItem().getLocation(), FireworkEffect.Type.BURST, Color.RED, true, true); + } + } + + @EventHandler + public void presentClean(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + Iterator presentIter = _items.keySet().iterator(); + + while (presentIter.hasNext()) + { + Item presentItem = presentIter.next(); + + if (!presentItem.isValid() || presentItem.getTicksLived() > 24000) + { + SantaPresent santaPresent = _items.get(presentItem); + + presentItem.remove(); + presentIter.remove(); + + //Announce + if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + int presentsLeft = 0; + for (SantaPresent present : _items.values()) + { + if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + presentsLeft++; + } + } + Bukkit.broadcastMessage( + ChatColor.RESET + C.Bold + "No one found a " + + C.cGold + C.Bold + "Christmas Present" + + ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!"); + } + else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + int coalsLeft = 0; + for (SantaPresent present : _items.values()) + { + if (present.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + coalsLeft++; + } + } + Bukkit.broadcastMessage( + ChatColor.RESET + C.Bold + "No one found a " + + C.cGold + C.Bold + "Christmas Coal" + + ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!"); + } + } + else + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, presentItem.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1, + UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + @EventHandler + public void presentDespawnCancel(ItemDespawnEvent event) + { + if (_items.containsKey(event.getEntity())) + event.setCancelled(true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java deleted file mode 100644 index 9f6bb794c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java +++ /dev/null @@ -1,238 +0,0 @@ -package mineplex.core.gadget.gadgets.morph; - -import java.io.File; -import java.io.IOException; -import java.time.Month; -import java.time.YearMonth; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.vehicle.VehicleExitEvent; - -import mineplex.core.common.block.schematic.Schematic; -import mineplex.core.common.block.schematic.UtilSchematic; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.sleigh.Sleigh; -import mineplex.core.gadget.gadgets.morph.managers.sleigh.SleighPosition; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class MorphSleigh extends MorphGadget -{ - - /** - * Directions of the Sleigh, with the correct coord for the player to be teleported and the schematic name - */ - public enum SleighDirection - { - NORTH("SleighMorphNorth.schematic", 0.5, 4.5), - SOUTH("SleighMorphSouth.schematic", 0.5, 1.5), - EAST("SleighMorphEast.schematic", 1.5, 1.5), - WEST("SleighMorphWest.schematic", 4.5, 1.5); - - private String _schematic; - private double _fixedX; - private double _fixedZ; - - SleighDirection(String schematic, double fixedX, double fixedZ) - { - _schematic = schematic; - _fixedX = fixedX; - _fixedZ = fixedZ; - } - - public String getSchematic() - { - return _schematic; - } - - public double getFixedX() - { - return _fixedX; - } - - public double getFixedZ() - { - return _fixedZ; - } - - } - - private Map _sleighs = new HashMap<>(); - private Map _schematics = new HashMap<>(); - - private List _positions = new ArrayList<>(); - - private Long _rightClickStart = null; - - public MorphSleigh(GadgetManager manager) - { - super(manager, "Sleigh Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER)); - // Loads sleigh schematics - for (SleighDirection sleighDirection : SleighDirection.values()) - { - try - { - Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + sleighDirection.getSchematic())); - _schematics.put(sleighDirection, schematic); - } catch (IOException e) - { - e.printStackTrace(); - } - } - buildPositions(); - } - - @Override - public void enableCustom(Player player, boolean message) - { - applyArmor(player, message); - - // TODO DISGUISE - } - - @Override - public void disableCustom(Player player, boolean message) - { - removeArmor(player); - - // TODO UNDISGUISE - if (_sleighs.containsKey(player)) - { - _sleighs.get(player).stopEffect(); - _sleighs.remove(player); - } - } - - /** - * Activates the sleigh effect when left-clicking - * This will be changed in the next releases - * @param event - */ - @EventHandler - public void activateSleigh(PlayerInteractEvent event) - { - if (!isActive(event.getPlayer())) - return; - - if (!UtilEvent.isAction(event, UtilEvent.ActionType.L)) - return; - - Player player = event.getPlayer(); - - if (player.getItemInHand().getType() != Material.AIR) - return; - - //if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics")) - //return; - - List freePositions = _positions.stream().filter(position -> !position.isUsed()).collect(Collectors.toList()); - - if (freePositions.size() == 0) - { - UtilPlayer.message(player, F.main("Sleigh Ride", "There are too many sleighs in the sky right now! Please wait a minute and try again!")); - return; - } - - int randomPosition = UtilMath.random.nextInt(freePositions.size()); - SleighPosition position = freePositions.get(randomPosition); - position.setUsed(true); - SleighDirection direction = position.getDirection(); - Schematic schematic = _schematics.get(direction); - if (schematic == null) - { - try - { - schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/SleighMorph.schematic")); - Location fixYaw = player.getLocation().clone(); - fixYaw.setYaw(90); - player.teleport(fixYaw); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - Sleigh sleigh = new Sleigh(player, schematic, position); - sleigh.startEffect(); - _sleighs.put(player, sleigh); - } - - /** - * Stops player from leaving the sleigh if it's activte - * @param event - */ - @EventHandler - public void onLeaveVehicle(VehicleExitEvent event) - { - if (event.getExited() instanceof Player) - { - Player player = (Player) event.getExited(); - if (isActive(player)) - { - event.setCancelled(true); - } - } - } - - /** - * Creates positions in the hub map - * TODO add arcade positions - */ - private void buildPositions() - { - _positions.add(new SleighPosition(-11, 143, -30, SleighDirection.SOUTH, -9.5, 145.5, -28.5)); - _positions.add(new SleighPosition(57, 109, -150, SleighDirection.SOUTH, 58.5, 111.5, -148.5)); - _positions.add(new SleighPosition(141, 101, 80, SleighDirection.NORTH, 142.5, 103.5, 84.5)); - _positions.add(new SleighPosition(-12, 88, 85, SleighDirection.NORTH, -10.5, 90.5, 89.5)); - _positions.add(new SleighPosition(-95, 90, 70, SleighDirection.NORTH, -93.5, 92.5, 74.5)); - _positions.add(new SleighPosition(-105, 115, -80, SleighDirection.EAST, -103.5, 117.5, -78.5)); - _positions.add(new SleighPosition(-135, 97, -8, SleighDirection.EAST, -133.5, 99.5, -6.5)); - _positions.add(new SleighPosition(-45, 97, 15, SleighDirection.EAST, -43.5, 99.5, 16.5)); - _positions.add(new SleighPosition(136, 116, 85, SleighDirection.WEST, 140.5, 118.5, 86.5)); - } - - /** - * Removes sleighs if they run out of time, or moves them if they still have time - * @param event - */ - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() == UpdateType.FASTER) - { - _sleighs.values().forEach(Sleigh::playSound); - } - - if (event.getType() != UpdateType.TICK) - return; - - Iterator> iterator = _sleighs.entrySet().iterator(); - while (iterator.hasNext()) - { - Map.Entry entry = iterator.next(); - Sleigh sleigh = entry.getValue(); - if (!sleigh.update()) - { - iterator.remove(); - } - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java new file mode 100644 index 000000000..a2fecafb5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java @@ -0,0 +1,128 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseSquid; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemStackFactory; + +/** + * THIS MORPH IS 1.9+ ONLY + */ +public class MorphStray extends MorphGadget +{ + + private List _strayArrows = new ArrayList<>(); + private ItemStack _arrow; + + public MorphStray(GadgetManager manager) + { + super(manager, "Stray Morph", UtilText.splitLinesToArray(new String[]{ + C.cGray + "Even though it's a stray your mom probably won't let you keep this puppy.", + "", + C.cWhite + "Gains an arrow every 5 seconds with EXTREME knockback." + }, LineFormat.LORE), + 0, Material.BARRIER, (byte) 0); + _arrow = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Stray Arrow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + // TODO CHECK IF LOBBY IS 1.9+ + applyArmor(player, message); + DisguiseSquid disguiseSquid = new DisguiseSquid(player); + UtilMorph.disguise(player, disguiseSquid, Manager); + + // Gives bow and arrow + ItemStack bow = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte) 0, 1, C.cGreen + "Stray Bow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE)); + player.getInventory().setItem(2, bow); + player.getInventory().setItem(17, _arrow); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + // Removes bow and arrow + player.getInventory().setItem(2, new ItemStack(Material.AIR)); + player.getInventory().setItem(17, new ItemStack(Material.AIR)); + } + + @EventHandler + public void onShoot(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + return; + + if (!(event.getProjectile() instanceof Arrow)) + return; + + Player player = (Player) event.getEntity(); + + if (!isActive(player)) + return; + + _strayArrows.add((Arrow) event.getProjectile()); + + Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + player.getInventory().setItem(17, _arrow); + } + }, 3 * 20L); + } + + @EventHandler + public void onArrowHitPlayer(EntityDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Arrow)) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) + return; + + Arrow arrow = (Arrow) event.getDamager(); + Player player = (Player) event.getEntity(); + + if (!_strayArrows.contains(arrow)) + return; + + _strayArrows.remove(arrow); + + Player shooter = (Player) arrow.getShooter(); + arrow.remove(); + + if (shooter.getUniqueId().equals(player.getUniqueId())) + return; + + player.setVelocity(player.getVelocity().multiply(-15).setY(15)); + UtilPlayer.message(player, F.main("Stray Arrow", "You were hit with a " + F.greenElem("Stray Arrow") + " from " + F.name(shooter.getName()) + " and got knocked back!")); + UtilPlayer.message(shooter, F.main("Stray Arrow", "You hit " + F.name(player.getName()) + " with the " + F.greenElem("Stray Arrow") + " and they got knocked back!")); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java index ce6598a5d..a30b400fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java @@ -5,7 +5,7 @@ import java.util.Map; import java.util.Set; import mineplex.core.common.util.UtilServer; -import mineplex.core.gadget.gadgets.particle.unrelated.WitchParticleEffect; +import mineplex.core.particleeffects.WitchParticleEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Bat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/SantaPresent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/SantaPresent.java new file mode 100644 index 000000000..5a05ad30c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/SantaPresent.java @@ -0,0 +1,38 @@ +package mineplex.core.gadget.gadgets.morph.managers; + +public class SantaPresent +{ + + public enum PresentType + { + PRESENT, + COAL + } + + private final String _thrower; + private final PresentType _presentType; + private final int _ammo; + + public SantaPresent(String thrower, PresentType presentType, int ammo) + { + _thrower = thrower; + _presentType = presentType; + _ammo = ammo; + } + + public String getThrower() + { + return _thrower; + } + + public PresentType getPresentType() + { + return _presentType; + } + + public int getAmmo() + { + return _ammo; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java deleted file mode 100644 index 07a32faaf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java +++ /dev/null @@ -1,187 +0,0 @@ -package mineplex.core.gadget.gadgets.morph.managers.sleigh; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; - -import mineplex.core.common.block.schematic.Schematic; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.gadget.gadgets.morph.MorphSleigh; - -/** - * Creates the sleigh effect for the Sleigh Morph - */ -public class Sleigh -{ - - private Map _oldBlockMaterials = new HashMap<>(); - private Map _oldBlockDatas = new HashMap<>(); - - private Player _player; - private Location _originalLocation; - private Schematic _schematic; - private SleighPosition _sleighPosition; - private Arrow _arrow; - private float _yaw; - - private int _moves = 0; - - public Sleigh(Player player, Schematic schematic, SleighPosition sleighPosition) - { - _player = player; - _schematic = schematic; - _sleighPosition = sleighPosition; - _yaw = (sleighPosition.getDirection() == MorphSleigh.SleighDirection.SOUTH) ? 0f : - (sleighPosition.getDirection() == MorphSleigh.SleighDirection.NORTH) ? 180f : - (sleighPosition.getDirection() == MorphSleigh.SleighDirection.WEST) ? 90f : -90f; - } - - /** - * Starts the sleigh effect - */ - public void startEffect() - { - _originalLocation = _player.getLocation().clone(); - Location origin = new Location(_originalLocation.getWorld(), _sleighPosition.getX(), - _sleighPosition.getY(), _sleighPosition.getZ()); - try - { - pasteSchematic(origin, 0, 0); - } catch (IOException e) - { - e.printStackTrace(); - } - } - - /** - * Stops the sleigh effect - */ - public void stopEffect() - { - restoreBlocks(); - _arrow.remove(); - _player.teleport(_originalLocation.clone().add(0, 5, 0)); - _sleighPosition.setUsed(false); - } - - /** - * Pastes the schematic for the sleigh - * @param origin The location where the sleigh schematic will be placed - * @param playerX The X coord where player will be teleported - * @param playerZ The Z coord where player will be teleported - * @throws IOException - */ - private void pasteSchematic(Location origin, int playerX, int playerZ) throws IOException - { - restoreBlocks(); - short width = _schematic.getWidth(); - short height = _schematic.getHeight(); - short length = _schematic.getLength(); - for (short x = 0; x < width; x++) - { - for (short y = 0; y < height; y++) - { - for (short z = 0; z < length; z++) - { - Location location = origin.clone().add(x, y, z); - _oldBlockMaterials.put(location, location.getBlock().getType()); - _oldBlockDatas.put(location, location.getBlock().getData()); - } - } - } - _schematic.paste(origin); - Location playerLoc = new Location(_originalLocation.getWorld(), _sleighPosition.getPlayerX() + playerX, - _sleighPosition.getPlayerY(), _sleighPosition.getPlayerZ() + playerZ); - // Spawns arrow so it looks like player is sitting on the sleigh - if (_arrow != null) - { - _arrow.remove(); - } - _arrow = playerLoc.getWorld().spawn(playerLoc, Arrow.class); - UtilEnt.ghost(_arrow, true, true); - playerLoc.setYaw(_yaw); - playerLoc.setPitch(0.0f); - _player.teleport(playerLoc); - _arrow.setPassenger(_player); - } - - /** - * Updates sleigh to look like its moving - * @return true if the sleigh was moved, false if the time is over (3 seconds) - */ - public boolean update() - { - _moves++; - int x = 0, z = 0; - switch (_sleighPosition.getDirection()) - { - case NORTH: - z = -1 * _moves; - break; - case SOUTH: - z = _moves; - break; - case WEST: - x = -1 * _moves; - break; - case EAST: - x = _moves; - } - Location newOrigin = new Location(_originalLocation.getWorld(), _sleighPosition.getX() + x, - _sleighPosition.getY(), _sleighPosition.getZ() + z); - restoreBlocks(); - UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, _player.getLocation(), 0f, 0f, 0f, 0.6f, 100, - UtilParticle.ViewDist.LONGER, UtilServer.getPlayers()); - try - { - pasteSchematic(newOrigin, x, z); - } catch (IOException e) - { - e.printStackTrace(); - } - if (_moves >= 20 * 3) - { - stopEffect(); - return false; - } - return true; - } - - /** - * Plays sleigh sound to the player - */ - public void playSound() - { - _player.playSound(_player.getLocation(), Sound.ORB_PICKUP, 1f, 1f); - } - - /** - * Restores the blocks that were changed from pasting the schematic - */ - private void restoreBlocks() - { - for (Map.Entry entry : _oldBlockMaterials.entrySet()) - { - Location location = entry.getKey(); - Material material = entry.getValue(); - byte data = 0; - if (_oldBlockDatas.containsKey(location)) - { - data = _oldBlockDatas.get(location); - } - location.getBlock().setType(material); - location.getBlock().setData(data); - } - _oldBlockMaterials.clear(); - _oldBlockDatas.clear(); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java deleted file mode 100644 index f8d76bd3d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java +++ /dev/null @@ -1,76 +0,0 @@ -package mineplex.core.gadget.gadgets.morph.managers.sleigh; - -import mineplex.core.gadget.gadgets.morph.MorphSleigh; - -/** - * Handles positions from Sleigh and player, and the direction of the sleigh and player - */ -public class SleighPosition -{ - - private int _x; - private int _y; - private int _z; - private MorphSleigh.SleighDirection _direction; - private double _playerX; - private double _playerY; - private double _playerZ; - private boolean _used; - - public SleighPosition(int x, int y, int z, MorphSleigh.SleighDirection direction, double playerX, double playerY, double playerZ) - { - _x = x; - _y = y; - _z = z; - _direction = direction; - _playerX = playerX; - _playerY = playerY; - _playerZ = playerZ; - _used = false; - } - - public int getX() - { - return _x; - } - - public int getY() - { - return _y; - } - - public int getZ() - { - return _z; - } - - public MorphSleigh.SleighDirection getDirection() - { - return _direction; - } - - public double getPlayerX() - { - return _playerX; - } - - public double getPlayerY() - { - return _playerY; - } - - public double getPlayerZ() - { - return _playerZ; - } - - public void setUsed(boolean used) - { - _used = used; - } - - public boolean isUsed() - { - return _used; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java index 65b2525cf..4b639156c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java @@ -7,7 +7,7 @@ import java.util.UUID; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.particle.unrelated.FreedomFireworkEffect; +import mineplex.core.particleeffects.FreedomFireworkEffect; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.event.UpdateEvent; import org.bukkit.ChatColor; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java index ffd1e29be..49aaa7bbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java @@ -3,16 +3,6 @@ package mineplex.core.gadget.gadgets.wineffect; import java.util.ArrayList; import java.util.List; -import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.*; -import mineplex.core.common.util.particles.ColoredParticle; -import mineplex.core.common.util.particles.DustSpellColor; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect; -import mineplex.core.gadget.types.WinEffectGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -22,6 +12,26 @@ import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilSkull; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.particleeffects.BabyFireworkEffect; +import mineplex.core.gadget.types.WinEffectGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; + public class WinEffectHalloween extends WinEffectGadget { @@ -119,10 +129,9 @@ public class WinEffectHalloween extends WinEffectGadget private void spawnSkeleton() { - Skeleton skeleton = getBaseLocation().getWorld().spawn(getBaseLocation(), Skeleton.class); + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(getBaseLocation()); skeleton.setCustomName(getRank(_player) + _player.getName()); skeleton.setCustomNameVisible(true); - skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER); skeleton.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); UtilEnt.ghost(skeleton, true, false); UtilEnt.Vegetate(skeleton); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index b06707ed2..f873ea35c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -1,14 +1,12 @@ package mineplex.core.hologram; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.EntityArmorStand; import net.minecraft.server.v1_8_R3.Packet; @@ -18,6 +16,14 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; + public class Hologram { public enum HologramTarget { @@ -481,12 +487,6 @@ public class Hologram { // Send update metadata packets Integer entityId = _entityIds.get(i); - PacketPlayOutEntityMetadata metadata1_8 = new PacketPlayOutEntityMetadata(); - PacketPlayOutEntityMetadata metadata1_9 = new PacketPlayOutEntityMetadata(); - - metadata1_8.a = entityId; - metadata1_9.a = entityId; - DataWatcher watcher1_8 = new DataWatcher(null); DataWatcher watcher1_9 = new DataWatcher(null); @@ -504,11 +504,9 @@ public class Hologram { watcher1_9.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); } } - metadata1_8.b = watcher1_8.c(); - metadata1_9.b = watcher1_9.c(); - packets1_8.add(metadata1_8); - packets1_9.add(metadata1_9); + packets1_8.add(new PacketPlayOutEntityMetadata(entityId, watcher1_8, true)); + packets1_9.add(new PacketPlayOutEntityMetadata(entityId, watcher1_9, true)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java index dec383adb..5f6453616 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java @@ -5,15 +5,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Map.Entry; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilTime; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; @@ -30,14 +23,20 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; + public class ItemStackFactory extends MiniPlugin { public static ItemStackFactory Instance; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java index 05a85e24d..f383958b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java @@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; public class HorseMount extends Mount> { @@ -103,13 +104,12 @@ public class HorseMount extends Mount> //Remove other mounts Manager.DeregisterAll(player); - - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + + Horse horse = UtilVariant.spawnHorse(player.getLocation(), _variant); horse.setAdult(); horse.setAgeLock(true); horse.setColor(_color); horse.setStyle(_style); - horse.setVariant(_variant); horse.setOwner(player); horse.setMaxDomestication(1); horse.setJumpStrength(_jump); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java index 68b439005..6c8382210 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java @@ -28,6 +28,7 @@ import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; public class MountChicken extends HorseMount { @@ -61,12 +62,11 @@ public class MountChicken extends HorseMount //Remove other mounts Manager.DeregisterAll(player); - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + Horse horse = UtilVariant.spawnHorse(player.getLocation(), _variant); horse.setAdult(); horse.setAgeLock(true); horse.setColor(_color); horse.setStyle(_style); - horse.setVariant(_variant); horse.setOwner(player); horse.setMaxDomestication(1); horse.setJumpStrength(_jump); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java index 5f8c2d498..e270d9f36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java @@ -3,10 +3,9 @@ package mineplex.core.mount.types; import java.util.*; import java.util.List; -import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.gadgets.particle.unrelated.FreedomTrailEffect; +import mineplex.core.particleeffects.FreedomTrailEffect; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; import mineplex.core.mount.SingleEntityMountData; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java index 90b7ab87c..3962bf332 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java @@ -35,6 +35,7 @@ import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; public class MountSpider extends HorseMount { @@ -76,7 +77,7 @@ public class MountSpider extends HorseMount //Remove other mounts Manager.DeregisterAll(player); - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + Horse horse = UtilVariant.spawnHorse(player.getLocation(), _variant); horse.setAdult(); horse.setAgeLock(true); horse.setColor(_color); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/BabyFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/BabyFireworkEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java index 69714b83d..d0fdbc78e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/BabyFireworkEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java @@ -1,14 +1,15 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import java.util.Random; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.common.util.particles.NormalParticle; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; public class BabyFireworkEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/Effect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java similarity index 80% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/Effect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java index b819c0e56..818d75c63 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/Effect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -11,6 +11,7 @@ public abstract class Effect public EffectLocation _effectLocation; public EffectLocation _targetLocation; protected JavaPlugin _javaPlugin; + private boolean _running = false; public Effect(int ticks, EffectLocation effectLocation, JavaPlugin javaPlugin) { @@ -29,6 +30,8 @@ public abstract class Effect public void start() { + onStart(); + _running = true; _task = Bukkit.getScheduler().scheduleSyncRepeatingTask(_javaPlugin, new Runnable() { @Override @@ -42,9 +45,15 @@ public abstract class Effect public void stop() { + _running = false; Bukkit.getScheduler().cancelTask(_task); + onStop(); } + public void onStart(){}; + + public void onStop(){}; + private void update() { _ticks++; @@ -52,6 +61,11 @@ public abstract class Effect Bukkit.getScheduler().cancelTask(_task); } + public boolean isRunning() + { + return _running; + } + public abstract void runEffect(); public void setTargetLocation(EffectLocation effectLocation) @@ -64,4 +78,9 @@ public abstract class Effect return _targetLocation; } + public EffectLocation getEffectLocation() + { + return _effectLocation; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/EffectLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/EffectLocation.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/EffectLocation.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/EffectLocation.java index 81ab19200..7cb36a401 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/EffectLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/EffectLocation.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import org.bukkit.Location; import org.bukkit.entity.Entity; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomFireworkEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java index cc63e8fae..8ea666184 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomFireworkEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import org.bukkit.Color; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomTrailEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomTrailEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java index 2a0be19fa..86f55dfa1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomTrailEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java @@ -1,13 +1,15 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.entity.Entity; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; -import org.bukkit.*; -import org.bukkit.entity.Entity; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; public class FreedomTrailEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/HalloweenSmashedEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/HalloweenSmashedEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java index c8ab96a6f..f99fe1ad8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/HalloweenSmashedEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java @@ -1,10 +1,11 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; -import mineplex.core.common.util.UtilFirework; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.common.util.UtilFirework; + public class HalloweenSmashedEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java similarity index 66% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java index b60de7ee9..bb5615b72 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java @@ -1,18 +1,24 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; -import java.awt.*; import java.util.HashMap; +import java.util.HashSet; -import mineplex.core.common.util.*; -import mineplex.core.common.util.particles.ColoredParticle; -import mineplex.core.common.util.particles.DustSpellColor; import org.bukkit.Color; -import mineplex.core.gadget.types.Gadget; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; 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.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.types.Gadget; + public class MetalManEffect extends Effect { @@ -23,20 +29,28 @@ public class MetalManEffect extends Effect private Location _fixedLoc; private Gadget _gadget; private Player _player; + private int _totalCount = 0; + private boolean _forceStop = false; public MetalManEffect(Location location, Location target, int color, Gadget gadget, Player player) { - super(-1, new EffectLocation(location), gadget.Manager.getPlugin()); + super(-1, new EffectLocation(player), gadget.Manager.getPlugin()); _color = color; _gadget = gadget; _player = player; setTargetLocation(new EffectLocation(target)); } + @Override + public void onStart() + { + _player.getWorld().playSound(_player.getLocation(), Sound.PISTON_RETRACT, 1f, 1f); + } + @Override public void runEffect() { - Location location = _effectLocation.getFixedLocation().clone(); + Location location = _effectLocation.getFixedLocation().clone().add(0, 1, 0); if (_vector == null) { Location targetLoc = getTargetLocation().getFixedLocation().clone(); @@ -54,21 +68,41 @@ public class MetalManEffect extends Effect coloredParticle.setLocation(_fixedLoc); coloredParticle.display(UtilParticle.ViewDist.LONG); } - if (_fixedLoc.getBlock().getType() != Material.AIR || _count == 1000) + if (_fixedLoc.getBlock().getType() != Material.AIR ) { - explode(); + stop(); + } + else if (_count >= 1000) + { + _forceStop = true; + stop(); } _count += 5; } - private void explode() + @Override + public void onStop() { - this.stop(); + if (!_forceStop) + { + _count = 0; + _vector = null; + HashSet ignore = new HashSet(); + ignore.add(Material.AIR); + Location loc = _player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5); + _effectLocation = new EffectLocation(_player); + setTargetLocation(new EffectLocation(loc)); + _totalCount++; + if (_totalCount != 3) + { + start(); + } + } // Creates the explosion and knockback players Location loc = _fixedLoc; loc.getWorld().createExplosion(loc, 0f); UtilParticle.PlayParticle(UtilParticle.ParticleType.EXPLODE, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); - HashMap players = UtilPlayer.getInRadius(loc, 5d); + HashMap players = UtilPlayer.getInRadius(loc, 9d); for (Player ent : players.keySet()) { if (_gadget.Manager.collideEvent(_player, _gadget, ent)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java new file mode 100644 index 000000000..f9ea7e172 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java @@ -0,0 +1,155 @@ +package mineplex.core.particleeffects; + +public class NewYearEffect //extends Effect +{ + + /*private static final int SECONDS_IN_A_MINUTE = 60; + + private final Location _ballLocation, _clockLocation, _timerLocation, _timerLocationTen; + + private int _seconds = 90; + private Collection _blocks = new ArrayList<>(); + private List _schematics = new ArrayList<>(); + private boolean _placed = false; + private int _currentRun = 0; + + public NewYearEffect(JavaPlugin plugin, Location location) + { + super(-1, new EffectLocation(location), plugin, 10); + _ballLocation = new Location(location.clone().getWorld(), 0, 71, 38); + _clockLocation = _ballLocation.clone().add(-12, 0, -15); + _timerLocation = _clockLocation.clone().add(19, 7, 0); + _timerLocationTen = _timerLocation.clone().add(1, 0, 0); + try + { + for (int i = 0; i <= 10; i++) + { + Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearBall" + i + ".schematic")); + _schematics.add(i, schematic); + } + Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearClock.schematic")); + _schematics.add(11, schematic); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + public void runEffect() + { + if (!_placed) + { + pasteSchematic(10, true); + _placed = true; + } + + if (_seconds == -60) + { + stop(); + return; + } + + if (_seconds == 0) + { + List fireworkLocations = new ArrayList<>(); + List fixedFireworkLocations = new ArrayList<>(); + int[][] fireworkCoords = new int[][] + { + {0, 77, -37}, + {-6, 71, 17}, + {6, 71, 17}, + {12, 71, 7}, + {-12, 71, 7}, + {5, 71, 92}, + {-7, 71, 92}, + {-9, 103, 37}, + {13, 107, 40} + }; + fireworkLocations.addAll(Arrays.asList(fireworkCoords)); + int[][] fixedFireworkCoords = new int[][] + { + {0, 80, 0}, + {0, 80, -32}, + {6, 80, -26}, + {-6, 80, -26} + }; + fixedFireworkLocations.addAll(Arrays.asList(fixedFireworkCoords)); + NewYearFireworkEffect newYearFireworkEffect = new NewYearFireworkEffect(_javaPlugin, fireworkLocations, fixedFireworkLocations, getEffectLocation().getFixedLocation().getWorld()); + newYearFireworkEffect.start(); + } + + if (_currentRun % 2 != 0 && _seconds >= 0) + { + //Format seconds + int totalMinutes = 0, totalSeconds = 0, placeholder; + placeholder = _seconds; + if (_seconds > SECONDS_IN_A_MINUTE) + { + while (placeholder > SECONDS_IN_A_MINUTE) + { + totalMinutes++; + placeholder -= SECONDS_IN_A_MINUTE; + } + } + totalSeconds = placeholder; + String formatted = String.format("%02d:%02d", totalMinutes, totalSeconds); + if (_seconds <= 10) + { + formatted = "| " + _seconds + " |"; + pasteSchematic(_seconds, false); + } + updateTimer(formatted, (byte) 0); + _seconds--; + } + else if (_seconds >= 0 && _seconds <= 10) + { + updateTimer("| " + _seconds + " |", (byte) 14); + } + else if (_currentRun % 2 != 0 && _seconds < 0) + { + updateTimer("2017!", (byte) 0); + _seconds--; + } + else if (_seconds < 0) + { + updateTimer("2017!", (byte) 14); + } + + _currentRun++; + } + + @Override + public void onStop() + { + _blocks.forEach(b -> b.setType(Material.AIR)); + _blocks.clear(); + updateTimer("2017!", (byte) 14); + } + + private void pasteSchematic(int second, boolean pasteClock) + { + Schematic schematic = _schematics.get(second); + if (schematic != null) + { + schematic.paste(_ballLocation, false, true); + + if (pasteClock) + { + Schematic clockSchematic = _schematics.get(11); + clockSchematic.paste(_clockLocation); + } + } + } + + private void updateTimer(String time, byte color) + { + // Clears previous blocks + _blocks.forEach(b -> b.setType(Material.AIR)); + + Collection blocks = UtilBlockText.MakeText(time, (_seconds <= 10 && _seconds >= 0) ? _timerLocationTen : _timerLocation, BlockFace.WEST, Material.STAINED_CLAY.getId(), color, UtilBlockText.TextAlign.LEFT, false); + _blocks = blocks; + }*/ + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearFireworkEffect.java new file mode 100644 index 000000000..86da70fd4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearFireworkEffect.java @@ -0,0 +1,46 @@ +package mineplex.core.particleeffects; + +public class NewYearFireworkEffect //extends Effect +{ + + /*private static final int MAX_TICKS = 1200; + + private List _locations = new ArrayList<>(); + private List _fixedLocations = new ArrayList<>(); + private int _ticks = 0; + + public NewYearFireworkEffect(JavaPlugin plugin, List locations, List fixedLocations, World world) + { + super(-1, null, plugin, 5); + for (int[] locCoords : locations) + { + _locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2])); + } + for (int[] locCoords : fixedLocations) + { + _locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2])); + } + } + + @Override + public void runEffect() + { + for (int i = 0; i < 5; i++) + { + int r = UtilMath.random.nextInt(_locations.size() - 1); + Location location = _locations.get(r); + UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2), + new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1); + } + for (Location location : _fixedLocations) + { + UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2), + new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1); + } + _ticks += 5; + if (_ticks >= MAX_TICKS) + { + stop(); + } + }*/ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java new file mode 100644 index 000000000..aca62fb56 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java @@ -0,0 +1,87 @@ +package mineplex.core.particleeffects; + +import java.awt.*; +import java.awt.image.BufferedImage; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; + +public class TextEffect extends Effect +{ + + private static final double IMAGE_SIZE = 0.2; + + private String _text; + private Font _font; + private boolean _realtime; + private boolean _invert; + private BufferedImage _bufferedImage; + + private ColoredParticle _coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.GREEN), null); + + public TextEffect(JavaPlugin plugin, int ticks, String text, Location location, boolean realtime, boolean invert) throws Exception + { + super(ticks, new EffectLocation(location), plugin); + _text = text; + _font = new Font("Tahoma", Font.PLAIN, 16); + _realtime = realtime; + _invert = invert; + } + + public void setText(String text) + { + if (!_realtime) + return; + + _text = text; + } + + @Override + public void runEffect() + { + if (_text == null || _font == null) + { + stop(); + return; + } + if (_bufferedImage == null || _realtime) + { + _bufferedImage = UtilText.stringToBufferedImage(_font, _text); + } + int color = 0; + for (int y = 0; y < _bufferedImage.getHeight(); y++) + { + for (int x = 0; x < _bufferedImage.getWidth(); x++) + { + color = _bufferedImage.getRGB(x, y); + if (!_invert && java.awt.Color.black.getRGB() != color) + continue; + else if (_invert && java.awt.Color.black.getRGB() == color) + continue; + + Vector vector = new Vector((float) _bufferedImage.getWidth() / 2 - x, (float) _bufferedImage.getHeight() / 2 - y, 0).multiply(IMAGE_SIZE); + vector = rotateAroundAxisY(vector, -_effectLocation.getFixedLocation().getYaw() * (Math.PI / 180)); + _coloredParticle.setLocation(_effectLocation.getFixedLocation().clone().add(vector)); + _coloredParticle.display(); + } + } + } + + private Vector rotateAroundAxisY(Vector v, double angle) + { + double x, z, cos, sin; + cos = Math.cos(angle); + sin = Math.sin(angle); + x = v.getX() * cos + v.getZ() * sin; + z = v.getX() * -sin + v.getZ() * cos; + return v.setX(x).setZ(z); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/WitchParticleEffect.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/WitchParticleEffect.java index 4b36d4de1..f53da0be7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/WitchParticleEffect.java @@ -1,9 +1,10 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; + +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; -import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; public class WitchParticleEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java deleted file mode 100644 index 7ea9aebe7..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java +++ /dev/null @@ -1,57 +0,0 @@ -package mineplex.core.pet; - -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.pet.repository.token.PetSalesToken; -import mineplex.core.shop.item.SalesPackageBase; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; - -public class Pet extends SalesPackageBase -{ - private String _name; - private EntityType _petType; - private String _lore = null; - - public Pet(String name, EntityType petType, int cost) - { - super(name, Material.MONSTER_EGG, (byte)petType.getTypeId(), new String[] {}); - - _name = name; - _petType = petType; - CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); - - KnownPackage = false; - } - - public Pet(String name, EntityType petType, int cost, String lore) - { - super(name, Material.MONSTER_EGG, (byte)petType.getTypeId(), new String[] {}); - - _name = name; - _petType = petType; - CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); - _lore = lore; - - KnownPackage = false; - } - - public EntityType getPetType() - { - return _petType; - } - - public void update(PetSalesToken petToken) - { - _name = petToken.Name; - } - - public String getPetName() - { - return _name; - } - - public String getLore() - { - return _lore; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java index f33ed7e5c..45da43cdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java @@ -1,33 +1,28 @@ package mineplex.core.pet; -import org.bukkit.entity.EntityType; - -import mineplex.core.common.util.NautHashMap; -import mineplex.core.pet.repository.token.ClientPetToken; -import mineplex.core.pet.repository.token.PetToken; - import java.util.HashMap; import java.util.Map; +import mineplex.core.pet.repository.token.ClientPetToken; +import mineplex.core.pet.repository.token.PetToken; + public class PetClient { - private Map _pets = new HashMap<>(); + private Map _pets = new HashMap<>(); private int _petNameTagCount; public void load(ClientPetToken token) { for (PetToken petToken : token.Pets) { - if (petToken.PetName == null) - petToken.PetName = Enum.valueOf(EntityType.class, petToken.PetType).getName(); - - _pets.put(Enum.valueOf(EntityType.class, petToken.PetType), petToken.PetName); + PetType type = PetType.valueOf(petToken.PetType); + _pets.put(type, petToken.PetName != null ? petToken.PetName : type.getName()); } _petNameTagCount = Math.max(0, token.PetNameTagCount); } - public Map getPets() + public Map getPets() { return _pets; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java index ca38ba1a9..90d0c08b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java @@ -1,30 +1,22 @@ package mineplex.core.pet; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.pet.repository.token.PetExtraToken; -import mineplex.core.shop.item.SalesPackageBase; import org.bukkit.Material; -public class PetExtra extends SalesPackageBase +import mineplex.core.pet.sales.PetExtraSalesPackage; + +public enum PetExtra { - private String _name; - private Material _material; - - public PetExtra(String name, Material material, int cost) + NAME_TAG("Name Tag", Material.NAME_TAG, 100) + ; + private final String _name; + private final Material _material; + private final int _price; + + PetExtra(String name, Material material, int price) { - super(name, material, (byte)0, new String[] { }); - _name = name; _material = material; - CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); - - KnownPackage = false; - OneTimePurchaseOnly = false; - } - - public void Update(PetExtraToken token) - { - + _price = price; } public String getName() @@ -32,8 +24,18 @@ public class PetExtra extends SalesPackageBase return _name; } - public Material GetMaterial() + public Material getMaterial() { return _material; } + + public int getPrice() + { + return _price; + } + + public PetExtraSalesPackage toSalesPackage(String text) + { + return new PetExtraSalesPackage(text, _material, _price); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java deleted file mode 100644 index 66565261e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -package mineplex.core.pet; - -import java.util.Collection; - -import org.bukkit.Material; -import org.bukkit.entity.EntityType; - -import mineplex.core.common.util.NautHashMap; -import mineplex.core.pet.repository.PetRepository; -import mineplex.core.pet.types.Elf; -import mineplex.core.pet.types.PetCoalApparition; -import mineplex.core.pet.types.Pumpkin; - -public class PetFactory -{ - private PetRepository _repository; - private NautHashMap _pets; - private NautHashMap _petExtras; - - public PetFactory(PetRepository repository) - { - _repository = repository; - _pets = new NautHashMap<>(); - _petExtras = new NautHashMap<>(); - - CreatePets(); - CreatePetExtras(); - } - - private void CreatePets() - { - _pets.put(EntityType.ZOMBIE, new Pumpkin()); - _pets.put(EntityType.PIG_ZOMBIE, new PetCoalApparition()); - _pets.put(EntityType.VILLAGER, new Elf()); - _pets.put(EntityType.PIG, new Pet("Pig", EntityType.PIG, 5000)); - _pets.put(EntityType.SHEEP, new Pet("Sheep", EntityType.SHEEP, 3000)); - _pets.put(EntityType.COW, new Pet("Cow", EntityType.COW, 2000)); - _pets.put(EntityType.CHICKEN, new Pet("Chicken", EntityType.CHICKEN, 7000)); - _pets.put(EntityType.WOLF, new Pet("Dog", EntityType.WOLF, 8000)); - _pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000)); - _pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000)); - _pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -12)); - _pets.put(EntityType.SKELETON, new Pet("Guardian", EntityType.SKELETON, -13)); - _pets.put(EntityType.RABBIT, new Pet("Baby Zombie", EntityType.RABBIT, -9, "They're so cute - until a pack of them chases down your family and eats them.")); - _pets.put(EntityType.BLAZE, new Pet("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?")); - } - - private void CreatePetExtras() - { - _petExtras.put(Material.SIGN, new PetExtra("Name Tag", Material.NAME_TAG, 100)); - } - - public Collection GetPets() - { - return _pets.values(); - } - - public Collection GetPetExtras() - { - return _petExtras.values(); - } - - public Collection GetPetExtraBySalesId(int salesId) - { - return _petExtras.values(); - } - - public Pet getPet(EntityType type) - { - return _pets.get(type); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 028fee9fd..58c17bea5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -1,37 +1,33 @@ package mineplex.core.pet; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import java.util.Map.Entry; +import java.util.UUID; -import com.google.gson.Gson; -import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.event.ClientWebResponseEvent; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.Rank; -import mineplex.core.common.shape.ShapeWings; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguiseChicken; -import mineplex.core.disguise.disguises.DisguiseGuardian; -import mineplex.core.disguise.disguises.DisguiseWither; -import mineplex.core.disguise.disguises.DisguiseZombie; -import mineplex.core.donation.DonationManager; -import mineplex.core.events.AddConditionEvent; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.pet.repository.PetRepository; -import mineplex.core.pet.repository.token.ClientPetTokenWrapper; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_8_R3.EntityCreature; import net.minecraft.server.v1_8_R3.NavigationAbstract; -import org.bukkit.*; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.SkullType; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPigZombie; -import org.bukkit.entity.*; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Blaze; +import org.bukkit.entity.Creature; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; +import org.bukkit.entity.Rabbit; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; @@ -45,6 +41,35 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import com.google.gson.Gson; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.ClientWebResponseEvent; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.Rank; +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.NautHashMap; +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.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.disguise.disguises.DisguiseZombie; +import mineplex.core.donation.DonationManager; +import mineplex.core.events.AddConditionEvent; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.pet.repository.PetRepository; +import mineplex.core.pet.repository.token.ClientPetTokenWrapper; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class PetManager extends MiniClientPlugin { private static Object _petOwnerSynch = new Object(); @@ -53,13 +78,13 @@ public class PetManager extends MiniClientPlugin private DisguiseManager _disguiseManager; private mineplex.core.creature.Creature _creatureModule; private PetRepository _repository; - private PetFactory _petFactory; private BlockRestore _blockRestore; - + + private Map _activePetOwnerTypes = new HashMap<>(); private NautHashMap _activePetOwners; private NautHashMap _failedAttempts; - private NautHashMap _petOwnerQueue = new NautHashMap(); + private Map _petOwnerQueue = new HashMap<>(); private NautHashMap _petRenameQueue = new NautHashMap(); private DonationManager _donationManager; private CoreClientManager _clientManager; @@ -78,7 +103,6 @@ public class PetManager extends MiniClientPlugin _creatureModule = creatureModule; _disguiseManager = disguiseManager; _repository = new PetRepository(plugin, webAddress); - _petFactory = new PetFactory(_repository); _blockRestore = restore; _donationManager = donationManager; _clientManager = clientManager; @@ -88,11 +112,11 @@ public class PetManager extends MiniClientPlugin _failedAttempts = new NautHashMap(); } - public void addPetOwnerToQueue(String playerName, EntityType entityType) + public void addPetOwnerToQueue(String playerName, PetType petType) { synchronized (_petOwnerSynch) { - _petOwnerQueue.put(playerName, entityType); + _petOwnerQueue.put(playerName, petType); } } @@ -150,31 +174,32 @@ public class PetManager extends MiniClientPlugin if (rank.has(Rank.LEGEND)) { - if (!Get(p).getPets().containsKey(EntityType.WITHER)) - Get(p).getPets().put(EntityType.WITHER, "Widder"); + if (!Get(p).getPets().containsKey(PetType.WITHER)) + Get(p).getPets().put(PetType.WITHER, "Widder"); } if (rank.has(Rank.TITAN)) { - if (!Get(p).getPets().containsKey(EntityType.SKELETON)) - Get(p).getPets().put(EntityType.SKELETON, "Guardian"); + if (!Get(p).getPets().containsKey(PetType.SKELETON)) + Get(p).getPets().put(PetType.SKELETON, "Guardian"); } } - public void addPetOwner(Player player, EntityType entityType, Location location) + public void addPetOwner(Player player, PetType petType, Location location) { - if (_activePetOwners.containsKey(player.getName())) + if (_activePetOwnerTypes.containsKey(player.getName())) { - if (_activePetOwners.get(player.getName()).getType() != entityType) + if (_activePetOwnerTypes.get(player.getName()) != petType) { removePet(player, true); } else return; } - + Creature pet; - + EntityType entityType = petType.getEntityType(); + //Wither Spawn if (entityType == EntityType.WITHER) { @@ -200,14 +225,14 @@ public class PetManager extends MiniClientPlugin //Default Spawn else { - pet = (Creature)_creatureModule.SpawnEntity(location, entityType); + pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType()); } //Named Pet - if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0) + if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0) { //pet.setCustomNameVisible(true); - pet.setCustomName(Get(player).getPets().get(entityType)); + pet.setCustomName(Get(player).getPets().get(petType)); } if (pet instanceof Zombie) @@ -281,7 +306,8 @@ public class PetManager extends MiniClientPlugin GrimReaperPetManager grimReaperPetManager = new GrimReaperPetManager(player, (Blaze) pet); _grimReaperMorphs.put((Blaze) pet, grimReaperPetManager); } - + + _activePetOwnerTypes.put(player.getName(), petType); _activePetOwners.put(player.getName(), pet); _failedAttempts.put(player.getName(), 0); @@ -318,6 +344,7 @@ public class PetManager extends MiniClientPlugin if (removeOwner) { + _activePetOwnerTypes.remove(player.getName()); _activePetOwners.remove(player.getName()); } } @@ -504,11 +531,6 @@ public class PetManager extends MiniClientPlugin return new PetClient(); } - public PetFactory getFactory() - { - return _petFactory; - } - public PetRepository getRepository() { return _repository; @@ -516,7 +538,12 @@ public class PetManager extends MiniClientPlugin public boolean hasActivePet(String name) { - return _activePetOwners.containsKey(name); + return _activePetOwnerTypes.containsKey(name); + } + + public PetType getActivePetType(String name) + { + return _activePetOwnerTypes.get(name); } public Creature getActivePet(String name) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java new file mode 100644 index 000000000..4072f41c1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java @@ -0,0 +1,104 @@ +package mineplex.core.pet; + +import java.util.Optional; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +import mineplex.core.pet.sales.PetSalesPackage; + +public enum PetType +{ + // These pets are named by EntityType for historic reasons -- the enum + // name() is stored by MSSQL to determine pet ownership. Future pet names + // can be made more accurate. + ZOMBIE("Pumpling", EntityType.ZOMBIE, -5), // Pumpling + PIG_ZOMBIE("Coal Apparition", EntityType.PIG_ZOMBIE, -1), + VILLAGER("Christmas Elf", EntityType.VILLAGER, -4), + PIG("Pig", EntityType.PIG, 5000), + SHEEP("Sheep", EntityType.SHEEP, 3000), + COW("Cow", EntityType.COW, 2000), + CHICKEN("Chicken", EntityType.CHICKEN, 7000), + WOLF("Dog", EntityType.WOLF, 8000), + OCELOT("Cat", EntityType.OCELOT, 6000), + MUSHROOM_COW("Mooshroom", EntityType.MUSHROOM_COW, 5000), + WITHER("Widder", EntityType.WITHER, -12), + SKELETON("Guardian", EntityType.SKELETON, -13), + RABBIT("Baby Zombie", EntityType.RABBIT, -9, "They're so cute - until a pack of them chases down your family and eats them."), + BLAZE("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?"), + // TODO CHECK IF LOBBY IS 1.9+ + // Not in this update + //SHULKER("Shulker Pet", EntityType.BAT, 0, "Is it a turtle or an alien? Either way its shot can be really UPLIFTING.") + ; + private final String _name; + private final EntityType _entityType; + private final int _price; + private final Optional _lore; + private final Material _material; + private final byte _data; + + PetType(String name, EntityType entityType, int price) + { + _name = name; + _entityType = entityType; + _price = price; + _lore = Optional.empty(); + _material = Material.MONSTER_EGG; + _data = (byte) entityType.getTypeId(); + } + + PetType(String name, EntityType entityType, int price, String lore) + { + _name = name; + _entityType = entityType; + _price = price; + _lore = Optional.of(lore); + _material = Material.MONSTER_EGG; + _data = (byte) entityType.getTypeId(); + } + + PetType(String name, EntityType entityType, int price, String lore, Material material, byte data) + { + _name = name; + _entityType = entityType; + _price = price; + _lore = Optional.of(lore); + _material = material; + _data = data; + } + + public String getName() + { + return _name; + } + + public EntityType getEntityType() + { + return _entityType; + } + + public int getPrice() + { + return _price; + } + + public Optional getLore() + { + return _lore; + } + + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public PetSalesPackage toSalesPackage(String tagName) + { + return new PetSalesPackage(this, tagName); + } +} 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 e607bd0c3..9dc141afb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -2,19 +2,16 @@ package mineplex.core.pet.repository; import java.util.List; -import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import com.google.gson.reflect.TypeToken; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnVarChar; +import mineplex.core.database.MinecraftRepository; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetExtraToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; +import mineplex.serverdata.database.DBPool; public class PetRepository extends MinecraftRepository { @@ -30,37 +27,11 @@ public class PetRepository extends MinecraftRepository public void AddPet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/AddPet").Execute(token); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - if (token.PetId == 0 || token.AccountId == 0) - return; - - 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(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/RemovePet").Execute(token); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - if (token.PetId == 0 || token.AccountId == 0) - return; - - executeUpdate("DELETE FROM accountPets WHERE petId = ? AND accountId = ?;" - , new ColumnInt("petId", token.PetId) - , new ColumnInt("accountId", token.AccountId)); - } - }); } public List GetPetExtras(List petExtraTokens) @@ -71,26 +42,6 @@ public class PetRepository extends MinecraftRepository public void UpdatePet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - if (token.PetId == 0 || token.AccountId == 0) - return; - - 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)); - } - } - }); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetExtraSalesPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetExtraSalesPackage.java new file mode 100644 index 000000000..206e64a8f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetExtraSalesPackage.java @@ -0,0 +1,19 @@ +package mineplex.core.pet.sales; + +import org.bukkit.Material; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.shop.item.SalesPackageBase; + +public class PetExtraSalesPackage extends SalesPackageBase +{ + + public PetExtraSalesPackage(String name, Material material, int price) + { + super(name, material, (byte)0, new String[0]); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, price); + + KnownPackage = false; + OneTimePurchaseOnly = false; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetSalesPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetSalesPackage.java new file mode 100644 index 000000000..2189e1469 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetSalesPackage.java @@ -0,0 +1,22 @@ +package mineplex.core.pet.sales; + +import org.bukkit.Material; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.pet.PetType; +import mineplex.core.shop.item.SalesPackageBase; + +public class PetSalesPackage extends SalesPackageBase +{ + + @SuppressWarnings("deprecation") + public PetSalesPackage(PetType type, String tagName) + { + super(type.getName(), Material.MONSTER_EGG, (byte)type.getEntityType().getTypeId(), new String[0]); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, type.getPrice()); + KnownPackage = false; + + setDisplayName(C.cGreen + "Purchase " + tagName); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Elf.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Elf.java deleted file mode 100644 index 9f3e3c3ee..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Elf.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.pet.types; - -import org.bukkit.entity.EntityType; - -import mineplex.core.pet.Pet; - -public class Elf extends Pet -{ - public Elf() - { - super("Christmas Elf", EntityType.VILLAGER, -4); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/PetCoalApparition.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/PetCoalApparition.java deleted file mode 100644 index 7d787f744..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/PetCoalApparition.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.pet.types; - -import org.bukkit.entity.EntityType; - -import mineplex.core.pet.Pet; - -public class PetCoalApparition extends Pet -{ - public PetCoalApparition() - { - super("Coal Apparition", EntityType.PIG_ZOMBIE, -1); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java deleted file mode 100644 index a2f3acc17..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java +++ /dev/null @@ -1,13 +0,0 @@ -package mineplex.core.pet.types; - -import org.bukkit.entity.EntityType; - -import mineplex.core.pet.Pet; - -public class Pumpkin extends Pet -{ - public Pumpkin() - { - super("Pumpling", EntityType.ZOMBIE, -5); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java index 109131f5e..c5513684e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java @@ -1,53 +1,40 @@ package mineplex.core.playwire; -import mineplex.core.common.util.UtilTime.TimeUnit; - -/** - * - */ public class PlayWireClientData { + private int _accountId; + private int _ticketsRemaining; + private long _ticketRefresh; - private long _redeemTime; - private int _streak; - - public PlayWireClientData(long date) + public PlayWireClientData(int accountId, int ticketsRemaining, long ticketRefresh) { - _redeemTime = date; - long curr = System.currentTimeMillis(); - - if (_redeemTime <= 0) - { - _streak = 0; - } + _accountId = accountId; + _ticketsRemaining = ticketsRemaining; + _ticketRefresh = ticketRefresh; } - - public long getRedeemTime() + + public int getAccountId() { - return _redeemTime; + return _accountId; } - - public void setRedeemTime(long date) + + public int getTicketsRemaining() { - long old = _redeemTime; - _redeemTime = date; - - if (_redeemTime - old > TimeUnit.DAYS.getMilliseconds() * 2) - { - _streak = 0; - } else - { - setStreak(getStreak() + 1); - } + return _ticketsRemaining; } - - public int getStreak() + + public long getTicketRefresh() { - return _streak; + return _ticketRefresh; } - - public void setStreak(int streak) + + public void setTicketsRemaining(int ticketsRemaining) { - _streak = streak; + _ticketsRemaining = ticketsRemaining; } -} + + public void setTicketRefresh(long ticketRefresh) + { + _ticketRefresh = ticketRefresh; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java index 631ffc7ec..017b3a0d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java @@ -4,10 +4,13 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; @@ -16,72 +19,100 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.bonuses.BonusManager; 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.donation.DonationManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.treasure.TreasureType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.database.DBPool; -/** - * - */ public class PlayWireManager extends MiniDbClientPlugin { - - private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds(); + private static final int MAX_TICKETS_PER_PERIOD = 5; + private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds() * 24; private static final int REWARD_MESSAGE_DELAY_SECONDS = 10; private final CoreClientManager _clientManager; - private final DonationManager _donationManager; private final PlayWireRepository _repository; - public PlayWireManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + public PlayWireManager(JavaPlugin plugin, CoreClientManager clientManager) { super("PlayWire", plugin, clientManager); _clientManager = clientManager; - _donationManager = donationManager; _repository = new PlayWireRepository(this); getPlugin().getCommand("playwire").setExecutor(new PlayWireCommand(this)); } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + final Map update = new HashMap<>(); + Bukkit.getOnlinePlayers().stream().filter(player -> Get(player) != null && Get(player).getAccountId() != -1 && Get(player).getTicketRefresh() != -1 && Get(player).getTicketRefresh() < System.currentTimeMillis()).forEach(player -> + { + PlayWireClientData data = Get(player); + data.setTicketRefresh(-1); + data.setTicketsRemaining(MAX_TICKETS_PER_PERIOD); + update.put(data, player); + }); + + if (!update.isEmpty()) + { + runAsync(() -> + { + update.entrySet().forEach(entry -> + { + PlayWireClientData data = entry.getKey(); + _repository.attemptPlayWire(data, () -> + { + UtilPlayer.message(entry.getValue(), F.main("Carl", "Your Ad Ticketssssss have refresssshed! Come ssssee me for ssssome " + F.elem("Spin Tickets") + "!")); + }, false); + }); + + update.clear(); + }); + } + } @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT `redeemed`, `streak` FROM `play_wire` WHERE `accountId`=" + accountId + ";"; + return "SELECT ticketsRemaining, ticketRefresh FROM play_wire WHERE accountId=" + accountId + ";"; } - public boolean canRedeem(Player player) + public boolean canRedeemTickets(PlayWireClientData data) { - PlayWireClientData data = Get(player); long now = System.currentTimeMillis(); - - return data == null || data.getRedeemTime() == -1 || (now - data.getRedeemTime()) > COOL_DOWN; + + return data == null || (data.getTicketRefresh() < now || data.getTicketRefresh() == -1) || data.getTicketsRemaining() > 0; } public void attemptRedeem(Player player) { - if (!canRedeem(player)) + final PlayWireClientData client = Get(player); + if (client == null || client.getAccountId() == -1) { - player.sendMessage(ResponseType.UNCOUNTED.getMessage()); + player.sendMessage(ResponseType.UNFILLED.getMessage()); return; } - - PlayWireClientData client = Get(player); - client.setRedeemTime(System.currentTimeMillis()); - if(client.getStreak() == 7) + if (!canRedeemTickets(client)) { - // - Managers.get(InventoryManager.class).addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 1); - } else if(client.getStreak() == 14) - { - Managers.get(InventoryManager.class).addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 1); - client.setStreak(0); + player.sendMessage(ResponseType.UNCOUNTED.getMessage(UtilTime.MakeStr(client.getTicketRefresh() - System.currentTimeMillis()))); + return; } - - _repository.attemptPlayWire(player, client, () -> + + if (client.getTicketsRemaining() >= MAX_TICKETS_PER_PERIOD) + { + client.setTicketRefresh(System.currentTimeMillis() + COOL_DOWN); + } + client.setTicketsRemaining(Math.max(client.getTicketsRemaining() - 1, 0)); + + _repository.attemptPlayWireAsync(client, () -> { - _donationManager.RewardCoinsLater("Watching Ad", player, 100); final int accountId = _clientManager.Get(player).getAccountId(); final Callback ticketCallback = new Callback() { @@ -118,7 +149,7 @@ public class PlayWireManager extends MiniDbClientPlugin } }); Managers.get(BonusManager.class).addPendingExplosion(player, player.getName()); - Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage()), REWARD_MESSAGE_DELAY_SECONDS * 20L); + Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage(client.getTicketsRemaining() + "")), REWARD_MESSAGE_DELAY_SECONDS * 20L); }); } @@ -135,6 +166,11 @@ public class PlayWireManager extends MiniDbClientPlugin getPlugin().getLogger().severe("PLAY WIRE PLAYER NOT FOUND ERROR: PlayerName: " + target); return; } + + if (response == ResponseType.UNCOUNTED) + { + response = ResponseType.UNFILLED; + } if (response == ResponseType.COUNTED) { @@ -151,18 +187,20 @@ public class PlayWireManager extends MiniDbClientPlugin boolean hasRow = resultSet.next(); if (hasRow) { - PlayWireClientData client = new PlayWireClientData(resultSet.getLong(1)); - client.setStreak(resultSet.getInt(2)); + PlayWireClientData client = new PlayWireClientData(accountId, resultSet.getInt("ticketsRemaining"), resultSet.getLong("ticketRefresh")); Set(uuid, client); - } else + } + else { - Set(uuid, new PlayWireClientData(-1)); + PlayWireClientData client = new PlayWireClientData(accountId, MAX_TICKETS_PER_PERIOD, -1L); + Set(uuid, client); + _repository.attemptPlayWire(client, null, false); } } @Override protected PlayWireClientData addPlayer(UUID uuid) { - return new PlayWireClientData(-1); + return new PlayWireClientData(-1, -1, -1); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java index 0b138e4d9..cb97496bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java @@ -1,20 +1,14 @@ package mineplex.core.playwire; -import mineplex.serverdata.database.DBPool; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -/** - * Totally original code I wrote, did not copy it from YouTubeRepo, no sir. - */ +import mineplex.serverdata.database.DBPool; + public class PlayWireRepository { - - private static final String INSERT_LAST_REDEEMED = "INSERT INTO `play_wire` VALUES(?,?,?) ON DUPLICATE KEY UPDATE `redeemed` = ?, `streak` = ?"; + private static final String INSERT_LAST_REDEEMED = "INSERT INTO play_wire (accountId, ticketsRemaining, ticketRefresh) VALUES (?,?,?) ON DUPLICATE KEY UPDATE ticketsRemaining=VALUES(ticketsRemaining), ticketRefresh=VALUES(ticketRefresh)"; private final PlayWireManager _manager; @@ -22,31 +16,46 @@ public class PlayWireRepository { _manager = manager; } - - public void attemptPlayWire(Player player, PlayWireClientData client, Runnable runnable) + + public void attemptPlayWire(final PlayWireClientData client, final Runnable runnable, boolean forceAsync) { - int accountId = _manager.getClientManager().Get(player).getAccountId(); - - Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), () -> + if (client.getAccountId() == -1) + { + return; + } + Runnable doSQL = () -> { try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement statement = connection.prepareStatement(INSERT_LAST_REDEEMED); - statement.setInt(1, accountId); - statement.setLong(2, client.getRedeemTime()); - statement.setInt(3, client.getStreak()); - statement.setLong(4, client.getRedeemTime()); - statement.setInt(5, client.getStreak()); + statement.setInt(1, client.getAccountId()); + statement.setInt(2, client.getTicketsRemaining()); + statement.setLong(3, client.getTicketRefresh()); statement.executeUpdate(); - - runnable.run(); - } catch (SQLException e) + + if (runnable != null) + { + _manager.runSync(runnable); + } + } + catch (SQLException e) { e.printStackTrace(); } - }); + }; + if (forceAsync) + { + _manager.runAsync(doSQL); + } + else + { + doSQL.run(); + } } - -} + public void attemptPlayWireAsync(final PlayWireClientData client, final Runnable runnable) + { + attemptPlayWire(client, runnable, false); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java index e35d18c62..25f51ff47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java @@ -7,11 +7,10 @@ import mineplex.core.common.util.F; */ public enum ResponseType { - - COUNTED(F.main("Carl", "Rewarded " + F.elem("100 Treasure Shards") + " and " + F.elem("1 Carl Spin Ticket") + " for watching the Ad")), - UNCOUNTED(F.main("Carl", "You already watched the Ad within the past hour!")), + COUNTED(F.main("Carl", "Rewarded " + F.elem("1 Carl Spin Ticket") + " for watching the Ad! You have " + F.elem("%elem%") + " tickets remaining for the current 24 hour period!")), + UNCOUNTED(F.main("Carl", "You already received your " + F.elem("5 Carl Spin Tickets") + " for the current 24 hour period! Your available tickets will refresh in " + F.elem("%elem%") + "!")), BLOCKED(F.main("Carl", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")), - UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it sorted ASAP.")),; + UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it ssssorted ASAP. Try again in a few minutessss!")),; private String _message; @@ -20,9 +19,16 @@ public enum ResponseType _message = message; } - public String getMessage() + public String getMessage(String... elements) { - return _message; + String message = _message; + if (elements.length > 0) + { + for (int i = 0; i < elements.length; i++) + { + message = message.replaceFirst("%elem%", elements[i]); + } + } + return message; } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java index 195856061..37fbeb41d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java @@ -1,9 +1,22 @@ package mineplex.core.powerplayclub; -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.ILoginProcessor; -import mineplex.core.donation.DonationManager; -import mineplex.serverdata.database.DBPool; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -12,13 +25,10 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import java.sql.*; -import java.sql.Date; -import java.time.LocalDate; -import java.time.YearMonth; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.donation.DonationManager; +import mineplex.serverdata.database.DBPool; public class PowerPlayClubRepository implements Listener { // Data loaded by the first ILoginProcessor, waiting for the second @@ -29,6 +39,8 @@ public class PowerPlayClubRepository implements Listener { // giving a player his/her rewards. private final Map _cachedPlayerData = new HashMap<>(); + private final Set _yearlySubscriptions = new HashSet<>(); + private final CoreClientManager _clientManager; private final DonationManager _donationManager; @@ -74,6 +86,10 @@ public class PowerPlayClubRepository implements Listener { LocalDate date = resultSet.getDate("startDate").toLocalDate(); PowerPlayData.SubscriptionDuration duration = PowerPlayData.SubscriptionDuration.valueOf(resultSet.getString("duration").toUpperCase()); subscriptions.add(new PowerPlayData.Subscription(date, duration)); + if (duration.equals(PowerPlayData.SubscriptionDuration.YEAR)) + { + _yearlySubscriptions.add(uuid); + } } // Now that we have the claims from the first processor and subscriptions from this one, combine them @@ -97,6 +113,9 @@ public class PowerPlayClubRepository implements Listener { PowerPlayClubRewards.rewardsForMonths(cached.getUsableCosmeticMonths()).stream() .map(PowerPlayClubRewards.PowerPlayClubItem::getPrize) .forEach(_donationManager.Get(player)::AddUnknownSalesPackagesOwned); + + // Gives Metal Man for anyone subscribed + _donationManager.Get(player).AddUnknownSalesPackagesOwned("Metal Man Morph"); } @EventHandler @@ -104,6 +123,7 @@ public class PowerPlayClubRepository implements Listener { { _stageOneDataClaims.remove(event.getPlayer().getUniqueId()); // Just in case. _cachedPlayerData.remove(event.getPlayer().getUniqueId()); + _yearlySubscriptions.remove(event.getPlayer().getUniqueId()); } public CompletableFuture addSubscription(int accountId, LocalDate date, String duration) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index ca98268ad..15a9d01ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -65,7 +65,8 @@ public class PreferencesManager extends MiniPlugin implements ILoginProcessor { Player player = event.getPlayer(); int accountId = _clientManager.getAccountId(player); - _repository.saveUserPreferences(_preferences.remove(accountId)); + UserPreferences p = _preferences.remove(accountId); + if (p != null) _repository.saveUserPreferences(p); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java new file mode 100644 index 000000000..7e043c09b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java @@ -0,0 +1,26 @@ +package mineplex.core.punish.Command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.punish.Punish; + +public class RulesCommand extends CommandBase +{ + + private static final String RULES_MESSAGE = "The rules can be found here:" + C.cGreen + " www.mineplex.com/rules"; + + public RulesCommand(Punish plugin) + { + super(plugin, Rank.ALL, "rules"); + } + + @Override + public void Execute(Player caller, String[] args) + { + caller.sendMessage(F.main("Rules", RULES_MESSAGE)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 69fcedb27..4575de030 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -30,6 +30,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.punish.Command.PunishCommand; +import mineplex.core.punish.Command.RulesCommand; import mineplex.core.punish.Tokens.PunishClientToken; import mineplex.core.punish.Tokens.PunishmentToken; import mineplex.core.updater.UpdateType; @@ -62,6 +63,7 @@ public class Punish extends MiniPlugin public void addCommands() { addCommand(new PunishCommand(this)); + addCommand(new RulesCommand(this)); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/LightFlicker.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/LightFlicker.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/LightFlicker.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/LightFlicker.java index dbebdb828..fad5a7d74 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/LightFlicker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/LightFlicker.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway; +package mineplex.core.rankGiveaway; import java.util.Random; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/GiveawayMessageHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/GiveawayMessageHandler.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java index 3afc7c3c1..557b227e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/GiveawayMessageHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import org.bukkit.Bukkit; import org.bukkit.Sound; @@ -10,7 +10,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.titangiveaway.LightFlicker; +import mineplex.core.rankGiveaway.LightFlicker; import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.ServerCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayHandler.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayHandler.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayHandler.java index 0c99ada73..93901991a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayHandler.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import org.bukkit.Sound; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayMessage.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayMessage.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayMessage.java index beb3e7276..c0bf3901a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayMessage.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import mineplex.serverdata.commands.ServerCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanGiveawayMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanGiveawayMessage.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanGiveawayMessage.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanGiveawayMessage.java index c2f39792c..44b12872f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanGiveawayMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanGiveawayMessage.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import mineplex.serverdata.commands.ServerCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayAnimation.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java index 2a5e70db6..1ce6c4b8d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java @@ -1,11 +1,4 @@ -package mineplex.core.titangiveaway; - -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +package mineplex.core.rankGiveaway.titangiveaway; import org.bukkit.Bukkit; import org.bukkit.Color; @@ -18,6 +11,12 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class TitanGiveawayAnimation implements Listener { private Location _location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayManager.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java index 46a13f688..93fe89cab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway; +package mineplex.core.rankGiveaway.titangiveaway; import java.util.Random; @@ -10,17 +10,17 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.status.ServerStatusManager; -import mineplex.core.titangiveaway.redis.GiveawayMessageHandler; -import mineplex.core.titangiveaway.redis.TitanChestGiveawayHandler; -import mineplex.core.titangiveaway.redis.TitanChestGiveawayMessage; -import mineplex.core.titangiveaway.redis.TitanGiveawayMessage; +import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler; +import mineplex.core.rankGiveaway.redis.TitanChestGiveawayHandler; +import mineplex.core.rankGiveaway.redis.TitanChestGiveawayMessage; +import mineplex.core.rankGiveaway.redis.TitanGiveawayMessage; import mineplex.serverdata.Region; import mineplex.serverdata.commands.ServerCommandManager; public class TitanGiveawayManager extends MiniPlugin { + private static final double RANK_FIND_CHANCE = 0.001; -// private static final double RANK_FIND_CHANCE = 1; private TitanGiveawayRepository _repository; private CoreClientManager _clientManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java index 29c0d6a88..a9157e562 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway; +package mineplex.core.rankGiveaway.titangiveaway; import java.sql.CallableStatement; import java.sql.Connection; @@ -8,7 +8,6 @@ import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.Region; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java index f8d4974ba..bee2d6181 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java @@ -38,7 +38,7 @@ public class ReportHandlerTask extends BukkitRunnable private CompletableFuture> getReport() { - return _reportManager.getReportRepository().getReport(_reportId); + return _reportManager.getRepository().getReport(_reportId); } public void start(JavaPlugin plugin) @@ -70,7 +70,7 @@ public class ReportHandlerTask extends BukkitRunnable { if (isActive) { - _reportManager.getReportRepository().getAccountName(report.getSuspectId()) + _reportManager.getRepository().getAccountName(report.getSuspectId()) .thenAccept(suspectName -> { String prefix = F.main(ReportManager.getReportPrefix(reportId), ""); @@ -121,7 +121,7 @@ public class ReportHandlerTask extends BukkitRunnable int handlerId = handlerIdOptional.get(); JsonMessage finalJsonMessage = jsonMessage; - _reportManager.getReportRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> + _reportManager.getRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> { if (handlerUUID != null) { @@ -165,7 +165,7 @@ public class ReportHandlerTask extends BukkitRunnable for (ReportMessage reportMessage : reportMessages) { // this is blocking, but that's okay as it will only be called asynchronously - String reporterName = _reportManager.getReportRepository().getAccountName(reportMessage.getReporterId()).join(); + String reporterName = _reportManager.getRepository().getAccountName(reportMessage.getReporterId()).join(); // triple backslashes so this translates to valid JSON output[count++] = String.format("%4$s(%d%4$s) %s%s%s - \\\"%s%s%4$s\\\"", count, C.cGold, reporterName, C.cGray, C.cPurple, reportMessage.getMessage()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 69002af2b..ed08e2d49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -20,8 +20,8 @@ import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotMetadata; -import mineplex.core.chatsnap.command.PushSnapshotsCommand; -import mineplex.core.chatsnap.command.PushSnapshotsHandler; +import mineplex.core.chatsnap.redis.PushSnapshotsCommand; +import mineplex.core.chatsnap.redis.PushSnapshotsHandler; import mineplex.core.command.CommandCenter; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; @@ -34,6 +34,7 @@ import mineplex.core.portal.Portal; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; import mineplex.core.punish.PunishClient; +import mineplex.core.report.data.metrics.ReportMetricsRepository; import mineplex.core.report.redis.HandlerNotification; import mineplex.core.report.data.Report; import mineplex.core.report.data.ReportMessage; @@ -41,6 +42,7 @@ import mineplex.core.report.data.ReportUser; import mineplex.core.report.data.ReportUserRepository; import mineplex.core.report.data.ReportRepository; import mineplex.core.report.redis.ReportersNotification; +import mineplex.serverdata.Region; import mineplex.serverdata.commands.ServerCommandManager; import static com.google.common.base.Preconditions.checkNotNull; @@ -52,32 +54,36 @@ public class ReportManager private static final String NAME = "Report"; private static final int INITIAL_PRIORITY = 15; private static final int ABUSE_BAN_THRESHOLD = 3; + public static final int MAXIMUM_REPORTS = 5; private final JavaPlugin _plugin; private final SnapshotManager _snapshotManager; private final CoreClientManager _clientManager; private final IncognitoManager _incognitoManager; private final Punish _punish; + private final Region _region; private final String _serverName; private final int _serverWeight; private final ReportRepository _reportRepository; - private final ReportUserRepository _reportUserRepository; + private final ReportUserRepository _userRepository; + private final ReportMetricsRepository _metricsRepository; public ReportManager(JavaPlugin plugin, SnapshotManager snapshotManager, CoreClientManager clientManager, - IncognitoManager incognitoManager, Punish punish, String serverName, int serverWeight) + IncognitoManager incognitoManager, Punish punish, Region region, String serverName, int serverWeight) { _plugin = plugin; _snapshotManager = snapshotManager; _clientManager = clientManager; _incognitoManager = incognitoManager; _punish = punish; + _region = region; _serverName = serverName; _serverWeight = serverWeight; - _reportRepository = new ReportRepository(this, _plugin.getLogger()); - - _reportUserRepository = new ReportUserRepository(plugin); + _reportRepository = new ReportRepository(this, region, _plugin.getLogger()); + _userRepository = new ReportUserRepository(plugin); + _metricsRepository = new ReportMetricsRepository(_plugin.getLogger()); ServerCommandManager commandManager = ServerCommandManager.getInstance(); ReportRedisManager notificationCallback = new ReportRedisManager(this, _serverName); @@ -93,15 +99,35 @@ public class ReportManager } /** - * Gets the {@link ReportRepository} we are using. + * Gets the {@link ReportRepository} this instance is using. * * @return the repository */ - public ReportRepository getReportRepository() + public ReportRepository getRepository() { return _reportRepository; } + /** + * Gets the {@link ReportUserRepository} this instance is using. + * + * @return the repository + */ + public ReportUserRepository getUserRepository() + { + return _userRepository; + } + + /** + * Gets the {@link ReportMetricsRepository} this instance is using. + * + * @return the repository + */ + public ReportMetricsRepository getMetricsRepository() + { + return _metricsRepository; + } + /** * Creates a new report or adds to an existing one. * @@ -149,7 +175,7 @@ public class ReportManager // create snapshot id ahead of time if (category == ReportCategory.CHAT_ABUSE) { - SnapshotMetadata snapshotMetadata = _snapshotManager.getSnapshotRepository().createSnapshot(null).join(); + SnapshotMetadata snapshotMetadata = _snapshotManager.getRepository().createSnapshot(null).join(); report.setSnapshotMetadata(snapshotMetadata); } @@ -168,12 +194,12 @@ public class ReportManager reportOptional.orElseGet(() -> { _plugin.getLogger().log(Level.WARNING, "Report #%d couldn't be fetched, opening new report."); - return new Report(suspectId, category); + return new Report(suspectId, category, _region); })); } else { - return CompletableFuture.completedFuture(new Report(suspectId, category)); + return CompletableFuture.completedFuture(new Report(suspectId, category, _region)); } }); } @@ -219,15 +245,18 @@ public class ReportManager new ReportHandlerTask(this, reportId).start(_plugin); }); - if (!_incognitoManager.Get(reportHandler).Status) + if (report.getCategory() != ReportCategory.CHAT_ABUSE) { - _incognitoManager.toggle(reportHandler); - } + if (!_incognitoManager.Get(reportHandler).Status) + { + _incognitoManager.toggle(reportHandler); + } - String lastServer = report.getLatestMessage().getServer(); - if (!_serverName.equals(lastServer)) - { - Portal.transferPlayer(reportHandler.getName(), lastServer); + String lastServer = report.getLatestMessage().getServer(); + if (!_serverName.equals(lastServer)) + { + Portal.transferPlayer(reportHandler.getName(), lastServer); + } } reportHandler.sendMessage( @@ -314,12 +343,10 @@ public class ReportManager } jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason))); - new ReportersNotification(ids, jsonMessage).publish(); + _reportRepository.clearCache(reportId); }); }); - - _reportRepository.clearCache(reportId); } catch (Throwable throwable) { @@ -446,7 +473,7 @@ public class ReportManager */ public CompletableFuture isActiveReport(long reportId) { - return getReportRepository().getReport(reportId).thenCompose(reportOptional -> + return getRepository().getReport(reportId).thenCompose(reportOptional -> { if (reportOptional.isPresent()) { @@ -546,26 +573,41 @@ public class ReportManager .thenApply(UtilCollections::unboxPresent) .thenApply(reports -> { - Report report = null; int size = reports.size(); - if (size == 1) + if (size == 0) { - report = reports.get(0); + return Optional.empty(); } - else if (size > 1) + else if (size == 1) + { + return Optional.of(reports.get(0)); + } + else { throw new IllegalStateException("Account is handling multiple reports."); } - - return Optional.ofNullable(report); }); - future.exceptionally(throwable -> Optional.empty()); + future.exceptionally(throwable -> + { + _plugin.getLogger().log(Level.SEVERE, "Error whilst fetching report being handled by: " + accountId + "."); + return Optional.empty(); + }); return future; } + public CompletableFuture> getOpenReports(int reporterId) + { + return _reportRepository.getOpenReports(reporterId) + .thenApply(reportIds -> + reportIds.stream().map(_reportRepository::getReport).collect(Collectors.toList())) + .thenCompose(UtilFuture::sequence) + .thenApply(UtilCollections::unboxPresent) + .thenCompose(reports -> UtilFuture.filter(reports, this::isActiveReport)); + } + /** * Calculates the priority of a report. * This takes many parameters into account including: @@ -587,7 +629,7 @@ public class ReportManager for (Map.Entry entry : report.getMessages().entrySet()) { int accountId = entry.getKey(); - ReportUser user = _reportUserRepository.getUser(accountId).join(); + ReportUser user = _userRepository.getUser(accountId).join(); int categoryReputation = user.getReputation(report.getCategory()); ReportMessage message = entry.getValue(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java index 7f960f1a7..a37718c7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java @@ -10,24 +10,25 @@ import mineplex.core.report.command.ReportCloseCommand; import mineplex.core.report.command.ReportCommand; import mineplex.core.report.command.ReportHandleCommand; import mineplex.core.report.command.ReportInfoCommand; -import mineplex.core.report.command.ReportStatsCommand; +import mineplex.core.report.command.ReportHistoryCommand; +import mineplex.core.report.command.ReportMetricsCommand; /** * Main class for this module, handles initialization and disabling of the module. */ public class ReportPlugin extends MiniPlugin { - private final ReportManager _reportManager; + private final ReportManager _manager; - public ReportPlugin(JavaPlugin plugin, ReportManager reportManager) + public ReportPlugin(JavaPlugin plugin, ReportManager manager) { super("Report", plugin); - _reportManager = reportManager; + _manager = manager; } - public ReportManager getReportManager() + public ReportManager getManager() { - return _reportManager; + return _manager; } @Override @@ -36,19 +37,20 @@ public class ReportPlugin extends MiniPlugin addCommand(new ReportCommand(this)); addCommand(new ReportHandleCommand(this)); addCommand(new ReportCloseCommand(this)); - addCommand(new ReportStatsCommand(this)); + addCommand(new ReportHistoryCommand(this)); addCommand(new ReportInfoCommand(this)); + addCommand(new ReportMetricsCommand(this)); } @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { - _reportManager.onPlayerJoin(e.getPlayer()); + _manager.onPlayerJoin(e.getPlayer()); } @EventHandler public void onPlayerQuit(PlayerQuitEvent e) { - _reportManager.onPlayerQuit(e.getPlayer()); + _manager.onPlayerQuit(e.getPlayer()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java index 4b4e1afa3..757f82501 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java @@ -33,13 +33,13 @@ public class ReportRedisManager implements CommandCallback { HandlerNotification reportNotification = (HandlerNotification) command; - _reportManager.getReportRepository().getReport(reportNotification.getReportId()).thenAccept(report -> + _reportManager.getRepository().getReport(reportNotification.getReportId()).thenAccept(report -> { if (report != null) { int handlerId = reportNotification.getHandlerId(); - _reportManager.getReportRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> + _reportManager.getRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> { if (handlerUUID != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java index af2cb3e8b..e54b5e780 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java @@ -7,23 +7,23 @@ import org.apache.commons.lang3.text.WordUtils; */ public enum ReportResultType { - ACCEPTED(0, false), - DENIED(1, false), - ABUSIVE(2, true), - EXPIRED(3, true); + ACCEPTED((short) 0, false), + DENIED((short) 1, false), + ABUSIVE((short) 2, true), + EXPIRED((short) 3, true); - private final int _id; + private final short _id; private final boolean _globalStat; private final String _name; - ReportResultType(int id, boolean globalStat) + ReportResultType(short id, boolean globalStat) { _id = id; _globalStat = globalStat; _name = WordUtils.capitalizeFully(name().replace('_', ' ')); } - public int getId() + public short getId() { return _id; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java index cea670742..35c6fef1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java @@ -35,7 +35,7 @@ public class ReportCloseCommand extends CommandBase else { String reason = F.combine(args, 0, null, false); - ReportManager reportManager = Plugin.getReportManager(); + ReportManager reportManager = Plugin.getManager(); reportManager.getReportHandling(player).whenComplete((reportOptional, throwable) -> { @@ -45,7 +45,7 @@ public class ReportCloseCommand extends CommandBase { Report report = reportOptional.get(); - reportManager.getReportRepository().getAccountName(report.getSuspectId()).thenCompose(BukkitFuture.accept(suspectName -> + reportManager.getRepository().getAccountName(report.getSuspectId()).thenCompose(BukkitFuture.accept(suspectName -> { ReportResultPage reportResultPage = new ReportResultPage(Plugin, report, player, suspectName, reason); reportResultPage.openInventory(); // report is closed when player selects the result diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java index ac1e5ec34..89be81d30 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java @@ -1,5 +1,7 @@ package mineplex.core.report.command; +import java.util.logging.Level; + import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; @@ -35,7 +37,7 @@ public class ReportCommand extends CommandBase } else { - ReportManager reportManager = Plugin.getReportManager(); + ReportManager reportManager = Plugin.getManager(); boolean canReport = reportManager.canReport(reporter); if (canReport) @@ -51,34 +53,55 @@ public class ReportCommand extends CommandBase Player suspect = UtilPlayer.searchOnline(reporter, playerName, false); String reason = F.combine(args, 1, null, false); - if (suspect != null) + reportManager.getOpenReports(reporterId).whenComplete((reports, throwable) -> { - // allow developer (iKeirNez) to report himself (for easy testing reasons) - if (suspect == reporter && !reportManager.isDevMode(reporter.getUniqueId())) + if (throwable == null) { - UtilPlayer.message(reporter, F.main(Plugin.getName(), C.cRed + "You cannot report yourself.")); - } - else - { - CoreClient suspectClient = clientManager.Get(suspect); - new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); - } - } - else - { - clientManager.loadClientByName(playerName, suspectClient -> - { - if (suspectClient != null) + if (reports.size() < ReportManager.MAXIMUM_REPORTS) { - new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + if (suspect != null) + { + // allow developer (iKeirNez) to report himself (for easy testing reasons) + if (suspect == reporter && !reportManager.isDevMode(reporter.getUniqueId())) + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "You cannot report yourself.")); + } + else + { + CoreClient suspectClient = clientManager.Get(suspect); + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + } + } + else + { + clientManager.loadClientByName(playerName, suspectClient -> + { + if (suspectClient != null) + { + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + } + else + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "Unable to find player '" + playerName + "'!")); + } + }); + } } else { - UtilPlayer.message(reporter, F.main(Plugin.getName(), C.cRed + "Unable to find player '" - + playerName + "'!")); + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "Cannot create report, you have reached the limit.")); } - }); - } + } + else + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "An error occurred, please try again.")); + Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst fetching open reports.", throwable); + } + }); } } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java similarity index 84% rename from Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java index e02de3ae1..98a7b6abe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java @@ -18,11 +18,11 @@ import mineplex.core.report.ReportRole; /** * A staff command for viewing report related statistics of a player. */ -public class ReportStatsCommand extends CommandBase +public class ReportHistoryCommand extends CommandBase { - public ReportStatsCommand(ReportPlugin reportPlugin) + public ReportHistoryCommand(ReportPlugin reportPlugin) { - super(reportPlugin, Rank.MODERATOR, "reportstats", "rs"); + super(reportPlugin, Rank.MODERATOR, "reporthistory", "rhis"); } @Override @@ -32,15 +32,15 @@ public class ReportStatsCommand extends CommandBase { String playerName = args[0]; - Plugin.getReportManager().getReportRepository().getAccountId(playerName).thenAccept(accountIdOptional -> + Plugin.getManager().getRepository().getAccountId(playerName).thenAccept(accountIdOptional -> { if (accountIdOptional.isPresent()) { int accountId = accountIdOptional.get(); - Plugin.getReportManager().getReportRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> + Plugin.getManager().getRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> { - UtilPlayer.message(player, F.main(Plugin.getName(), "Report Statistics for " + F.elem(playerName))); + UtilPlayer.message(player, F.main(Plugin.getName(), "Report History for " + F.elem(playerName))); for (ReportRole role : ReportRole.values()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java index 4f5b92b46..894d03847 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java @@ -42,8 +42,8 @@ public class ReportInfoCommand extends CommandBase { long reportId = Long.parseLong(args[0]); - ReportManager reportManager = Plugin.getReportManager(); - ReportRepository repository = reportManager.getReportRepository(); + ReportManager reportManager = Plugin.getManager(); + ReportRepository repository = reportManager.getRepository(); repository.getReport(reportId).thenAccept(reportOptional -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java new file mode 100644 index 000000000..5a061ea61 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -0,0 +1,123 @@ +package mineplex.core.report.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.BukkitFuture; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.report.ReportPlugin; +import mineplex.core.report.data.metrics.ReportMetrics; + +/** + * Displays various report-related metrics on a player. + */ +public class ReportMetricsCommand extends CommandBase +{ + private static final String PREFIX = "Report Metrics"; + private static final int MAX_DAYS = 30; + + public ReportMetricsCommand(ReportPlugin plugin) + { + super(plugin, Rank.MODERATOR, "reportmetrics"); + } + + @Override + public void Execute(Player player, String[] args) + { + if (args.length > 0 && args.length <= 2) + { + Integer days = parseDaysArgument(player, args[0]); + + if (days != null) + { + if (args.length >= 2) // has target argument + { + String targetName = args[1]; + + Plugin.getManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional -> + { + if (targetIdOptional.isPresent()) + { + int targetId = targetIdOptional.get(); + displayUserMetrics(player, targetName, targetId, days); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Player not found.")); + } + }); + } + else // display global metrics + { + UtilPlayer.message(player, F.main("Report Metrics", F.elem("Global Metrics") + " (" + F.elem(days + " days") + ")")); + displayGlobalMetrics(player, days); + } + } + } + else + { + UtilPlayer.message(player, + F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + + F.elem("/" + _aliasUsed + " [player]"))); + } + } + + public Integer parseDaysArgument(Player sender, String daysString) + { + Integer days; + + try + { + days = Integer.parseInt(daysString); + } + catch (NumberFormatException e) + { + UtilPlayer.message(sender, F.main(PREFIX, F.elem(daysString) + C.cRed + " is not a valid integer.")); + return null; + } + + if (days > MAX_DAYS) + { + UtilPlayer.message(sender, F.main(PREFIX, + C.cRed + "Cannot view metrics for longer than " + F.elem(MAX_DAYS + " days") + C.cRed + ".")); + + return null; + } + + return days; + } + + public void displayGlobalMetrics(Player player, int days) + { + Plugin.getManager().getMetricsRepository().getGlobalMetrics(days).thenCompose( + BukkitFuture.accept(globalMetrics -> + { + UtilPlayer.message(player, F.main("Report Metrics", "Submitted: " + F.elem(globalMetrics.getSubmitted()))); + UtilPlayer.message(player, F.main("Report Metrics", "Expired: " + F.elem(globalMetrics.getExpired()))); + displayMetrics(player, globalMetrics); + })); + } + + public void displayUserMetrics(Player player, String targetName, int targetId, int days) + { + Plugin.getManager().getMetricsRepository().getUserMetrics(targetId, days).thenCompose( + BukkitFuture.accept(userMetrics -> + { + UtilPlayer.message(player, + F.main("Report Metrics", + F.elem(targetName) + " (" + F.elem(days + " days") + ")")); + + displayMetrics(player, userMetrics); + })); + } + + public void displayMetrics(Player player, ReportMetrics reportMetrics) + { + UtilPlayer.message(player, F.main("Report Metrics", "Accepted: " + F.elem(reportMetrics.getAccepted()))); + UtilPlayer.message(player, F.main("Report Metrics", "Denied: " + F.elem(reportMetrics.getDenied()))); + UtilPlayer.message(player, F.main("Report Metrics", "Flagged Abusive: " + F.elem(reportMetrics.getFlagged()))); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java index 6fd4af9f6..8bb8ed8a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java @@ -10,6 +10,7 @@ import mineplex.core.report.ReportCategory; import mineplex.core.report.ReportHandlerTask; import mineplex.core.report.ReportResult; import mineplex.core.report.ReportTeam; +import mineplex.serverdata.Region; /** * Holds data for a Report. @@ -19,6 +20,7 @@ public class Report protected Long _reportId; private final int _suspectId; private final ReportCategory _category; + private final Region _region; // set of player account ids and the reason they reported this player private final Map _reportMessages = new HashMap<>(); private Integer _handlerId = null; @@ -28,16 +30,17 @@ public class Report private ReportHandlerTask _handlerTask = null; - public Report(int suspectId, ReportCategory category) + public Report(int suspectId, ReportCategory category, Region region) { - this(null, suspectId, category); + this(null, suspectId, category, region); } - protected Report(Long reportId, int suspectId, ReportCategory category) + protected Report(Long reportId, int suspectId, ReportCategory category, Region region) { _reportId = reportId; _suspectId = suspectId; _category = category; + _region = region; } public Optional getId() @@ -55,6 +58,11 @@ public class Report return _category; } + public Optional getRegion() + { + return Optional.ofNullable(_region); + } + public Map getMessages() { return _reportMessages; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index 57f553921..fb1e6ffb6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -38,6 +38,7 @@ import mineplex.core.report.ReportResult; import mineplex.core.report.ReportResultType; import mineplex.core.report.ReportRole; import mineplex.core.report.ReportTeam; +import mineplex.serverdata.Region; import mineplex.serverdata.database.DBPool; import org.apache.commons.lang3.StringUtils; @@ -46,8 +47,8 @@ import org.apache.commons.lang3.StringUtils; */ public class ReportRepository { - private static final String INSERT_REPORT = "INSERT INTO reports (suspectId, categoryId, snapshotId, assignedTeam)\n" + - "VALUES (?, ?, ?, ?);"; + private static final String INSERT_REPORT = "INSERT INTO reports (suspectId, categoryId, snapshotId, assignedTeam, region)\n" + + "VALUES (?, ?, ?, ?, ?);"; private static final String UPDATE_REPORT = "UPDATE reports SET snapshotId = ?, assignedTeam = ? WHERE id = ?;"; @@ -79,6 +80,7 @@ public class ReportRepository " LEFT JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + " LEFT JOIN reportReasons ON reports.id = reportReasons.reportId\n" + "WHERE reports.categoryId = ?\n" + + " AND (reports.region IS NULL OR reports.region = ?)\n" + " AND reportResults.reportId IS NULL\n" + " /* Bypass for testing purposes or check player isn't suspect */\n" + " AND (? IS TRUE OR reports.suspectId != ?)\n" + @@ -92,23 +94,32 @@ public class ReportRepository " /* Bypass for testing purposes or check player isn't a reporter */\n" + " AND (? IS TRUE OR SUM(IF(reportReasons.reporterId != ?, 1, 0)) = COUNT(reportReasons.reporterId));"; - private static final String GET_ONGOING_REPORT = "SELECT reports.id FROM reports" + - " LEFT JOIN reportResults ON reports.id = reportResults.reportId" + - " WHERE reportResults.reportId IS NULL" + - " AND reports.suspectId = ?;"; + private static final String GET_ONGOING_REPORT = "SELECT reports.id FROM reports\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reports.suspectId = ?\n" + + " AND (reports.region IS NULL OR reports.region = ?);"; - private static final String GET_ONGOING_REPORT_CATEGORY = "SELECT reports.id FROM reports" + - " LEFT JOIN reportResults ON reports.id = reportResults.reportId" + - " WHERE reportResults.reportId IS NULL" + - " AND reports.suspectId = ?" + - " AND reports.categoryId = ?;"; + private static final String GET_ONGOING_REPORT_CATEGORY = "SELECT reports.id FROM reports\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reports.suspectId = ?\n" + + " AND reports.categoryId = ?\n" + + " AND (reports.region IS NULL OR reports.region = ?);"; - private static final String GET_REPORTS_HANDLING = "SELECT reports.id FROM reports" + - " LEFT JOIN reportResults ON reports.id = reportResults.reportId" + - " INNER JOIN reportHandlers ON reports.id = reportHandlers.reportId" + - " AND reportHandlers.aborted IS FALSE" + - " WHERE reportResults.reportId IS NULL" + - " AND reportHandlers.handlerId = ?;"; + private static final String GET_REPORTS_HANDLING = "SELECT reports.id FROM reports\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + " INNER JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reportHandlers.handlerId = ?\n" + + " AND reportHandlers.aborted IS FALSE\n" + + " AND (reports.region IS NULL OR reports.region = ?);"; + + private static final String GET_USER_OPEN_REPORTS = "SELECT reports.id FROM reports\n" + + " INNER JOIN reportReasons ON reports.id = reportReasons.reportId\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reportReasons.reporterId = ?;"; private static final String GET_USER_RESULT_COUNT = "SELECT COUNT(reports.id) AS resultCount" + " FROM reports, reportReasons, reportResults" + @@ -117,16 +128,23 @@ public class ReportRepository " AND reportReasons.reporterId = ?" + " AND reportResults.resultId = ?;"; - private static final String GET_ACCOUNT_NAME = "SELECT id, `name` FROM accounts" + - " WHERE id = ?" + - " LIMIT 1;"; + // We order by lastLogin in the below queries to resolve cases whereby two account + // entries exist with the same name (online and offline mode versions), to get + // around this, we simply picked the one that logged in most recently + + private static final String GET_ACCOUNT_ID = "SELECT id, `name` FROM accounts\n" + + "WHERE `name` = ?\n" + + "ORDER BY lastLogin DESC\n" + + "LIMIT 1;"; + + private static final String GET_ACCOUNT_NAME = "SELECT id, `name` FROM accounts\n" + + "WHERE id = ?\n" + + "ORDER BY lastLogin DESC\n" + + "LIMIT 1;"; private static final String GET_ACCOUNT_UUID = "SELECT id, uuid FROM accounts" + " WHERE id IN (%s);"; - private static final String GET_ACCOUNT_ID = "SELECT id, `name` FROM accounts\n" + - "WHERE `name` = ?;"; - /** STATISTICS **/ private static final String STATISTICS_GET_REPORTS_MADE = "SELECT reports.id FROM reports, reportReasons\n" + @@ -142,6 +160,7 @@ public class ReportRepository "WHERE reports.suspectId = ?;"; private final ReportManager _reportManager; + private final Region _region; private final Logger _logger; private final Cache _cachedReports = CacheBuilder.newBuilder() @@ -149,20 +168,21 @@ public class ReportRepository .expireAfterAccess(5, TimeUnit.MINUTES) .build(); - public ReportRepository(ReportManager reportManager, Logger logger) + public ReportRepository(ReportManager reportManager, Region region, Logger logger) { _reportManager = reportManager; + _region = region; _logger = logger; } /** * Gets the ids of unhandled reports that the supplied user is allowed to handle. * - * @param accountId the id of the account carrying out the search + * @param handlerId the id of the account carrying out the search * @param devMode if true, allows various restrictions to be bypassed * @return the ids of unhandled reports the supplied account is allowed to handle */ - public CompletableFuture> getUnhandledReports(int accountId, ReportCategory category, boolean devMode) + public CompletableFuture> getUnhandledReports(int handlerId, ReportCategory category, boolean devMode) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -172,12 +192,13 @@ public class ReportRepository { PreparedStatement preparedStatement = connection.prepareStatement(GET_UNHANDLED_REPORTS); preparedStatement.setShort(1, category.getId()); - preparedStatement.setBoolean(2, devMode); - preparedStatement.setInt(3, accountId); - preparedStatement.setInt(4, accountId); - preparedStatement.setInt(5, accountId); - preparedStatement.setBoolean(6, devMode); - preparedStatement.setInt(7, accountId); + preparedStatement.setString(2, _region.name()); + preparedStatement.setBoolean(3, devMode); + preparedStatement.setInt(4, handlerId); + preparedStatement.setInt(5, handlerId); + preparedStatement.setInt(6, handlerId); + preparedStatement.setBoolean(7, devMode); + preparedStatement.setInt(8, handlerId); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -204,10 +225,10 @@ public class ReportRepository /** * Gets a list containing the ids of reports the account is handling - * @param accountId the id of the account + * @param handlerId the id of the account * @return a list containing the ids of reports being handled */ - public CompletableFuture> getReportsHandling(int accountId) + public CompletableFuture> getReportsHandling(int handlerId) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -216,7 +237,8 @@ public class ReportRepository try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement preparedStatement = connection.prepareStatement(GET_REPORTS_HANDLING); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, handlerId); + preparedStatement.setString(2, _region.name()); ResultSet resultSet = preparedStatement.executeQuery(); @@ -255,14 +277,22 @@ public class ReportRepository for (long reportId : reportIds) { - preparedStatement.setLong(1, reportId); - ResultSet resultSet = preparedStatement.executeQuery(); - Report report = loadReport(connection, resultSet); + Report report = _cachedReports.getIfPresent(reportId); - if (report != null) + if (report == null) { - reports.add(report); + preparedStatement.setLong(1, reportId); + ResultSet resultSet = preparedStatement.executeQuery(); + + report = loadReport(connection, resultSet); + + if (report == null) + { + continue; + } } + + reports.add(report); } return reports; @@ -333,13 +363,15 @@ public class ReportRepository long reportId = resultSet.getLong("id"); int suspectId = resultSet.getInt("suspectId"); ReportCategory reportCategory = ReportCategory.getById(resultSet.getInt("categoryId")); + String regionName = resultSet.getString("region"); + Region region = !resultSet.wasNull() ? Region.valueOf(regionName) : null; - Report report = new Report(reportId, suspectId, reportCategory); + Report report = new Report(reportId, suspectId, reportCategory, region); int snapshotId = resultSet.getInt("snapshotId"); if (!resultSet.wasNull()) { - SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getSnapshotRepository() + SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getRepository() .getSnapshotMetadata(snapshotId).join(); report.setSnapshotMetadata(snapshotMetadata); @@ -392,7 +424,7 @@ public class ReportRepository return null; } - public CompletableFuture> getOngoingReports(int accountId) + public CompletableFuture> getOngoingReports(int suspectId) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -400,7 +432,8 @@ public class ReportRepository { List reports = new ArrayList<>(); PreparedStatement preparedStatement = connection.prepareStatement(GET_ONGOING_REPORT); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, suspectId); + preparedStatement.setString(2, _region.name()); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -436,22 +469,23 @@ public class ReportRepository future.exceptionally(throwable -> { - _logger.log(Level.SEVERE, "Error getting ongoing report for account: " + accountId + ".", throwable); + _logger.log(Level.SEVERE, "Error getting ongoing report for account: " + suspectId + ".", throwable); return null; }); return future; } - public CompletableFuture> getOngoingReports(int accountId, ReportCategory category) + public CompletableFuture> getOngoingReports(int suspectId, ReportCategory category) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement preparedStatement = connection.prepareStatement(GET_ONGOING_REPORT_CATEGORY); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, suspectId); preparedStatement.setInt(2, category.getId()); + preparedStatement.setString(3, _region.name()); ResultSet resultSet = preparedStatement.executeQuery(); List reports = new ArrayList<>(); @@ -470,13 +504,39 @@ public class ReportRepository future.exceptionally(throwable -> { - _logger.log(Level.SEVERE, "Error fetching ongoing report for account: " + accountId + ", category: " + category + ".", throwable); + _logger.log(Level.SEVERE, "Error fetching ongoing report for account: " + suspectId + ", category: " + category + ".", throwable); return new ArrayList<>(); }); return future; } + public CompletableFuture> getOpenReports(int reporterId) + { + return CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_OPEN_REPORTS); + preparedStatement.setInt(1, reporterId); + + ResultSet resultSet = preparedStatement.executeQuery(); + List reports = new ArrayList<>(); + + while (resultSet.next()) + { + reports.add(resultSet.getLong("id")); + } + + return reports; + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + } + private Set getReportReasons(Connection connection, long reportId) { Set reportMessages = new HashSet<>(); @@ -507,13 +567,13 @@ public class ReportRepository return reportMessages; } - public CompletableFuture getResultCount(int accountId, ReportResultType resultType) + public CompletableFuture getResultCount(int reporterId, ReportResultType resultType) { CompletableFuture future = CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_RESULT_COUNT); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, reporterId); preparedStatement.setInt(2, resultType.getId()); ResultSet resultSet = preparedStatement.executeQuery(); @@ -532,7 +592,7 @@ public class ReportRepository future.exceptionally(throwable -> { - _logger.log(Level.SEVERE, "Error fetching result count for account: " + accountId + ", type: " + resultType + ".", throwable); + _logger.log(Level.SEVERE, "Error fetching result count for account: " + reporterId + ", type: " + resultType + ".", throwable); return 0; }); @@ -546,6 +606,7 @@ public class ReportRepository try (Connection connection = DBPool.getAccount().getConnection()) { Optional reportIdOptional = report.getId(); + Optional regionOptional = report.getRegion(); Optional snapshotIdOptional = report.getSnapshotMetadata().map(SnapshotMetadata::getId); Optional teamOptional = report.getAssignedTeam(); long reportId; @@ -603,6 +664,15 @@ public class ReportRepository insertReportStatement.setNull(4, Types.TINYINT); } + if (regionOptional.isPresent()) + { + insertReportStatement.setString(5, regionOptional.get().name()); + } + else + { + insertReportStatement.setNull(5, Types.VARCHAR); + } + insertReportStatement.executeUpdate(); ResultSet resultSet = insertReportStatement.getGeneratedKeys(); @@ -618,6 +688,8 @@ public class ReportRepository } } + _cachedReports.put(reportId, report); // cache the report + PreparedStatement setReportMessageStatement = connection.prepareStatement(SET_REPORT_MESSAGE); for (Map.Entry entry : report.getMessages().entrySet()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportGlobalMetrics.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportGlobalMetrics.java new file mode 100644 index 000000000..c81056a83 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportGlobalMetrics.java @@ -0,0 +1,37 @@ +package mineplex.core.report.data.metrics; + +/** + * Extends the standard report metrics class to hold global-scope metrics. + */ +public class ReportGlobalMetrics extends ReportMetrics +{ + private final long _submitted; + private final long _expired; + + public ReportGlobalMetrics(long submitted, long expired, long accepted, long denied, long flagged) + { + super(accepted, denied, flagged); + _submitted = submitted; + _expired = expired; + } + + /** + * Gets the amount of reports submitted. + * + * @return the amount + */ + public long getSubmitted() + { + return _submitted; + } + + /** + * Gets the amount of reports expired. + * + * @return the amount + */ + public long getExpired() + { + return _expired; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetrics.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetrics.java new file mode 100644 index 000000000..16314b2a1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetrics.java @@ -0,0 +1,48 @@ +package mineplex.core.report.data.metrics; + +/** + * Holds report-related metrics which can be applied to a user or global scope. + */ +public class ReportMetrics +{ + private final long _accepted; + private final long _denied; + private final long _flagged; + + public ReportMetrics(long accepted, long denied, long flagged) + { + _accepted = accepted; + _denied = denied; + _flagged = flagged; + } + + /** + * Gets the amount of reports accepted. + * + * @return the amount + */ + public long getAccepted() + { + return _accepted; + } + + /** + * Gets the amount of reports denied. + * + * @return the amount + */ + public long getDenied() + { + return _denied; + } + + /** + * Gets the amount of reports flagged (marked as spam). + * + * @return the amount + */ + public long getFlagged() + { + return _flagged; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetricsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetricsRepository.java new file mode 100644 index 000000000..884f1a378 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetricsRepository.java @@ -0,0 +1,156 @@ +package mineplex.core.report.data.metrics; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; +import java.util.logging.Logger; + +import mineplex.core.report.ReportResultType; +import mineplex.serverdata.database.DBPool; + +/** + * Handles all fetching of report-related metrics. + */ +public class ReportMetricsRepository +{ + private static final String GET_GLOBAL_SUBMITTED = "SELECT COUNT(DISTINCT reportReasons.reportId) AS submitted FROM reportReasons\n" + + " WHERE reportReasons.time BETWEEN NOW() - INTERVAL ? DAY AND NOW();"; + + private static final String GET_GLOBAL_RESULT = "SELECT COUNT(reportResults.reportId) AS amount FROM reportResults\n" + + " WHERE reportResults.resultId = ?\n" + + " AND reportResults.closedTime BETWEEN NOW() - INTERVAL ? DAY AND NOW();"; + + private static final String GET_USER_RESULT = "SELECT COUNT(reportResults.reportId) AS amount FROM reportResults\n" + + " LEFT JOIN reportHandlers ON reportResults.reportId = reportHandlers.reportId AND reportHandlers.aborted IS FALSE\n" + + " WHERE reportHandlers.handlerId = ?\n" + + " AND reportResults.resultId = ?\n" + + " AND reportResults.closedTime BETWEEN NOW() - INTERVAL ? DAY AND NOW();"; + + private final Logger _logger; + + public ReportMetricsRepository(Logger logger) + { + _logger = logger; + } + + public CompletableFuture getGlobalMetrics(int days) + { + CompletableFuture future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + long submitted = getGlobalSubmitted(connection, days); + + try (PreparedStatement preparedStatement = connection.prepareStatement(GET_GLOBAL_RESULT)) + { + long expired = getGlobalResult(preparedStatement, ReportResultType.EXPIRED, days); + long accepted = getGlobalResult(preparedStatement, ReportResultType.ACCEPTED, days); + long denied = getGlobalResult(preparedStatement, ReportResultType.DENIED, days); + long flagged = getGlobalResult(preparedStatement, ReportResultType.ABUSIVE, days); + + return new ReportGlobalMetrics(submitted, expired, accepted, denied, flagged); + } + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error fetching global metrics.", throwable); + return null; + }); + + return future; + } + + private long getGlobalSubmitted(Connection connection, int days) throws SQLException + { + PreparedStatement preparedStatement = connection.prepareStatement(GET_GLOBAL_SUBMITTED); + preparedStatement.setInt(1, days); + + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + if (resultSet.next()) + { + return resultSet.getLong("submitted"); + } + else + { + return 0; + } + } + } + + private long getGlobalResult(PreparedStatement preparedStatement, ReportResultType resultType, int days) throws SQLException + { + preparedStatement.setShort(1, resultType.getId()); + preparedStatement.setInt(2, days); + + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + if (resultSet.next()) + { + return resultSet.getLong("amount"); + } + else + { + return 0; + } + } + } + + public CompletableFuture getUserMetrics(int accountId, int days) + { + CompletableFuture future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + try (PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_RESULT)) + { + long accepted = getUserResult(preparedStatement, accountId, ReportResultType.ACCEPTED, days); + long denied = getUserResult(preparedStatement, accountId, ReportResultType.DENIED, days); + long flagged = getUserResult(preparedStatement, accountId, ReportResultType.ABUSIVE, days); + + return new ReportMetrics(accepted, denied, flagged); + } + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error fetching user metrics.", throwable); + return null; + }); + + return future; + } + + private long getUserResult(PreparedStatement preparedStatement, int accountId, ReportResultType resultType, int days) throws SQLException + { + preparedStatement.setInt(1, accountId); + preparedStatement.setShort(2, resultType.getId()); + preparedStatement.setInt(3, days); + + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + if (resultSet.next()) + { + return resultSet.getLong("amount"); + } + else + { + return 0; + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java index 4ee980e93..4dd452f64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java @@ -69,7 +69,7 @@ public class ReportCreatePage extends SimpleGui implements ReportCategoryCallba private boolean hasSentMessage(int accountId) { - SnapshotManager snapshotManager = _plugin.getReportManager().getSnapshotManager(); + SnapshotManager snapshotManager = _plugin.getManager().getSnapshotManager(); int suspectId = _suspect.getAccountId(); List suspectMessages = snapshotManager.getMessagesFrom(accountId).stream() .filter(message -> message.getSenderId() == suspectId || message.getRecipientIds().contains(suspectId)) @@ -80,7 +80,7 @@ public class ReportCreatePage extends SimpleGui implements ReportCategoryCallba private void createReport(ReportCategory category) { - _plugin.getReportManager().createReport(_reporterId, _suspect.getAccountId(), category, _reason) + _plugin.getManager().createReport(_reporterId, _suspect.getAccountId(), category, _reason) .thenAccept(report -> { boolean error = true; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java index 830085fa5..c8f2238e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java @@ -56,8 +56,8 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac public void handleReport(ReportCategory category) { - ReportManager reportManager = _plugin.getReportManager(); - ReportRepository reportRepository = reportManager.getReportRepository(); + ReportManager reportManager = _plugin.getManager(); + ReportRepository reportRepository = reportManager.getRepository(); reportManager.isHandlingReport(_handler).whenComplete((handlingReport, throwable) -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java index 113e4b728..92b1f6abe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java @@ -31,7 +31,7 @@ public class ReportResultPage extends SimpleGui { super(plugin.getPlugin(), reportCloser, "Close Report", 9 * 4); _plugin = plugin; - _reportManager = plugin.getReportManager(); + _reportManager = plugin.getManager(); _report = report; _suspectName = suspectName; _reason = reason; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index ee76e8f53..b5a0f5b35 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Random; import org.bukkit.Material; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -129,8 +128,8 @@ import mineplex.core.mount.types.MountSpider; import mineplex.core.mount.types.MountUndead; import mineplex.core.mount.types.MountValentinesSheep; import mineplex.core.mount.types.MountZombie; -import mineplex.core.pet.Pet; import mineplex.core.pet.PetManager; +import mineplex.core.pet.PetType; import mineplex.core.reward.RewardPool.Type; import mineplex.core.reward.rewards.ChestReward; import mineplex.core.reward.rewards.GameAmplifierReward; @@ -242,13 +241,13 @@ public class RewardManager addInventoryReward(Type.NORMAL, getGadget(ItemTNT.class), rarity, 250, 0, 20, 40); //Pets - addPetReward(Type.NORMAL, EntityType.CHICKEN, rarity, 143); - addPetReward(Type.NORMAL, EntityType.COW, rarity, 500); - addPetReward(Type.NORMAL, EntityType.MUSHROOM_COW, rarity, 200); - addPetReward(Type.NORMAL, EntityType.OCELOT, rarity, 167); - addPetReward(Type.NORMAL, EntityType.PIG, rarity, 200); - addPetReward(Type.NORMAL, EntityType.SHEEP, rarity, 333); - addPetReward(Type.NORMAL, EntityType.WOLF, rarity, 125); + addPetReward(Type.NORMAL, PetType.CHICKEN, rarity, 143); + addPetReward(Type.NORMAL, PetType.COW, rarity, 500); + addPetReward(Type.NORMAL, PetType.MUSHROOM_COW, rarity, 200); + addPetReward(Type.NORMAL, PetType.OCELOT, rarity, 167); + addPetReward(Type.NORMAL, PetType.PIG, rarity, 200); + addPetReward(Type.NORMAL, PetType.SHEEP, rarity, 333); + addPetReward(Type.NORMAL, PetType.WOLF, rarity, 125); //Music Discs @@ -543,12 +542,12 @@ public class RewardManager addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5); addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50); - // OMEGA - addPetReward(Type.OMEGA, EntityType.VILLAGER, rarity, 1); - addPetReward(Type.OMEGA, EntityType.ZOMBIE, rarity, 10); - addPetReward(Type.OMEGA, EntityType.PIG_ZOMBIE, rarity, 1); - addPetReward(Type.OMEGA, EntityType.RABBIT, rarity, 10); - addPetReward(Type.OMEGA, EntityType.BLAZE, rarity, 2); + // Omega items + addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1); + addPetReward(Type.OMEGA, PetType.ZOMBIE, rarity, 10); + addPetReward(Type.OMEGA, PetType.PIG_ZOMBIE, rarity, 1); + addPetReward(Type.OMEGA, PetType.BLAZE, rarity, 2); + addPetReward(Type.OMEGA, PetType.RABBIT, rarity, 10); addGadget(Type.OMEGA, getGadget(MorphBunny.class), rarity, 1); addGadget(Type.OMEGA, getGadget(MorphUncleSam.class), rarity, 5); @@ -608,17 +607,17 @@ public class RewardManager addHat(Type.OMEGA, HatType.GRINCH, rarity, 25); // HAUNTED - addPetReward(Type.HAUNTED, EntityType.RABBIT, rarity, 100); - addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25); + addPetReward(Type.HAUNTED, PetType.RABBIT, rarity, 100); + addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25); addGadget(Type.HAUNTED, getGadget(WinEffectHalloween.class), rarity, 50); - addMount(Type.HAUNTED, getMount(MountNightmareSteed.class), rarity, 60); + addMount(Type.HAUNTED, getMount(MountNightmareSteed.class), rarity, 60); //TRICK OR TREAT - addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0)); + addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0)); addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0)); - addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25); - addPetReward(Type.TRICK_OR_TREAT, EntityType.ZOMBIE, rarity, 10); - addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5); + addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25); + addPetReward(Type.TRICK_OR_TREAT, PetType.ZOMBIE, rarity, 10); + addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5); } public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight) @@ -731,16 +730,15 @@ public class RewardManager return reward; } - public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight) + public PetReward addPetReward(Type type, PetType petType, RewardRarity rarity, int weight) { - return addPetReward(type, entityType, rarity, weight, getShards(rarity)); + return addPetReward(type, petType, rarity, weight, getShards(rarity)); } - public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight, int shards) + public PetReward addPetReward(Type type, PetType petType, RewardRarity rarity, int weight, int shards) { - Pet pet = _petManager.getFactory().getPet(entityType); - PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, - pet.getName() + " Pet", pet.getName(), entityType, rarity, weight, shards); + PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, + petType.getName() + " Pet", petType.getName(), petType, rarity, weight, shards); addReward(type, reward); return reward; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java index f869a2d5f..19f500c87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java @@ -1,7 +1,6 @@ package mineplex.core.reward.rewards; import org.bukkit.Material; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -9,6 +8,7 @@ import mineplex.cache.player.PlayerCache; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; +import mineplex.core.pet.PetType; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; import mineplex.core.reward.RewardData; @@ -22,15 +22,15 @@ public class PetReward extends UnknownPackageReward { private InventoryManager _inventoryManager; private PetManager _petManager; - private EntityType _petEntity; + private PetType _petType; - public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, EntityType petEntity, RewardRarity rarity, int weight, int shardValue) + public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, PetType petType, RewardRarity rarity, int weight, int shardValue) { - super(donationManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petEntity.getTypeId()), rarity, weight, shardValue); + super(donationManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petType.getEntityType().getTypeId()), rarity, weight, shardValue); _petManager = petManager; _inventoryManager = inventoryManager; - _petEntity = petEntity; + _petType = petType; } @Override @@ -44,16 +44,16 @@ public class PetReward extends UnknownPackageReward token.AccountId = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); token.Name = player.getName(); - token.PetType = _petEntity.toString(); + token.PetType = _petType.toString(); token.PetName = getPackageName(); PetToken petToken = new PetToken(); petToken.PetType = token.PetType; _petManager.getRepository().AddPet(token); - _petManager.Get(player).getPets().put(_petEntity, token.PetName); + _petManager.Get(player).getPets().put(_petType, token.PetName); - _inventoryManager.addItemToInventory(player, _petEntity.toString(), 1); + _inventoryManager.addItemToInventory(player, _petType.toString(), 1); return getFakeRewardData(player); } @@ -67,6 +67,6 @@ public class PetReward extends UnknownPackageReward return false; } - return !_petManager.Get(player).getPets().containsKey(_petEntity); + return !_petManager.Get(player).getPets().containsKey(_petType); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java index ec53f2357..7f1a8c525 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java @@ -1,13 +1,5 @@ package mineplex.core.shop.page; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilInv; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.item.IButton; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom; @@ -19,6 +11,15 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilInv; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.item.IButton; + public abstract class ShopPageBase> extends CraftInventoryCustom implements Listener { protected PluginType _plugin; @@ -87,11 +88,22 @@ public abstract class ShopPageBaseimplements IRelati private BannerManager _bannerManager; private AmplifierManager _amplifierManager; + private SafeLog _safeLog; + public ClassManager getClassManager() { return _classManager; @@ -317,7 +319,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Required managers to be initialized new Spawn(plugin, this); new NPCManager(this, _hologramManager); - new SafeLog(plugin, this); + _safeLog = new SafeLog(plugin, this); _observerManager = new ObserverManager(plugin, _condition, this); new ClanEnergyTracker(plugin, this); @@ -1208,6 +1210,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _bannerManager.onDisable(); _amplifierManager.onDisable(); _netherManager.onDisable(); + _safeLog.onDisable(); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index 5b225e410..b1c63970f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -289,6 +288,13 @@ public class ClansUtility public boolean isSafe(Location loc) { + if (_clansManager.getNetherManager().getNetherWorld().equals(loc.getWorld())) + { + if (_clansManager.getNetherManager().isInSpawn(loc)) + { + return true; + } + } // Fix for PC-279 // Do not change to getChunk // PlayerList#updatePlayers -> iterator -> PlayerVelocityEvent -> getChunk -> loadChunk -> loadPersistentEntities -> addTracker -> ITERATE ON SAME SET @@ -769,6 +775,11 @@ public class ClansUtility return false; } + if (_clansManager.getNetherManager().isInNether(caller)) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory while in " + F.clansNether("The Nether") + "!")); + } + if (!ClansManager.isClaimable(caller.getLocation())) { UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java index c33511639..9248f8605 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java @@ -1,6 +1,7 @@ package mineplex.game.clans.clans.ban; -import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.column.ColumnInt; @@ -92,17 +93,11 @@ public class ClansBanRepository extends MinecraftRepository }); } - /** - * @deprecated This invokes a mojang UUID query and should be replaced. - * It's called infrequently enough (i.e., only when a moderator - * invokes /cban), so not entirely pressing. - */ - @Deprecated public CompletableFuture> loadClient(String name) { // Yes, this is garbage. // Yes, it would be better implemented in a functional language. - return CompletableFuture.supplyAsync(() -> UUIDFetcher.getUUIDOf(name)) + return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)) .thenCompose(uuid -> { if (uuid == null) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java index e43c9f130..6cca5d188 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java @@ -16,7 +16,6 @@ public class ClansBanCommand extends CommandBase super(plugin, Rank.CMOD, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); } - @SuppressWarnings("deprecation") @Override public void Execute(final Player caller, String[] args) { @@ -43,7 +42,7 @@ public class ClansBanCommand extends CommandBase { if (!maybeClient.isPresent()) { - UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + " " + playerName); + UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName); } else { new ClansBanShop(Plugin, playerName, maybeClient.get(), finalReason).attemptShopOpen(caller); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java index 815897c4e..fd8c2554d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -12,6 +12,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.spawn.Spawn; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -245,15 +246,13 @@ public class BossNetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); - ClansManager.getInstance().runSyncLater(() -> - { - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); - }, 20); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index a14a74b58..13ea3c37d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.nether; import java.util.Comparator; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -66,15 +67,20 @@ public class NetherManager extends MiniPlugin private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build(); + private static final int SPAWN_MIN_X = 30; + private static final int SPAWN_MIN_Z = 99; + private static final int SPAWN_MAX_X = 56; + private static final int SPAWN_MAX_Z = 115; + private PortalRepository _repo; private NetherMinibossManager _miniboss; private World _netherWorld; private List _portals = Lists.newArrayList(); public List BossPortals = Lists.newArrayList(); private List _returnPortals = Lists.newArrayList(); - public HashMap InNether = new HashMap<>(); - public HashMap OverworldOrigins = new HashMap<>(); - public HashMap Claiming = new HashMap<>(); + public Map InNether = new HashMap<>(); + public Map OverworldOrigins = new HashMap<>(); + public Map Claiming = new HashMap<>(); public NetherManager(ClansManager manager) { @@ -148,6 +154,26 @@ public class NetherManager extends MiniPlugin return player.getWorld().equals(_netherWorld); } + /** + * Checks if a location is inside Nether Spawn + * @param loc The location to check + * @return true if the location is inside the Nether Spawn + */ + public boolean isInSpawn(Location loc) + { + if (loc.getWorld().equals(getNetherWorld())) + { + if (loc.getBlockX() >= SPAWN_MIN_X && loc.getBlockX() <= SPAWN_MAX_X) + { + if (loc.getBlockZ() >= SPAWN_MIN_Z && loc.getBlockZ() <= SPAWN_MAX_Z) + { + return true; + } + } + } + return false; + } + /** * Gets the place a player will exit the nether * @param player The player to check @@ -181,6 +207,11 @@ public class NetherManager extends MiniPlugin return null; } + public List getReturnPortals() + { + return _returnPortals; + } + /** * Loads a nether portal into the manager * @param portal The portal to load @@ -387,6 +418,7 @@ public class NetherManager extends MiniPlugin OverworldOrigins.remove(event.getPlayer()); event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().getCombatManager().Get(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); }, 1); } @@ -413,6 +445,7 @@ public class NetherManager extends MiniPlugin player.teleport(getReturnLocation(player)); OverworldOrigins.remove(player); player.removePotionEffect(PotionEffectType.NIGHT_VISION); + ClansManager.getInstance().getCombatManager().Get(player).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!")); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index 2e3ea55d4..daf5ca438 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.clans.ClansManager; import org.bukkit.Bukkit; @@ -256,15 +257,13 @@ public class NetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); - ClansManager.getInstance().runSyncLater(() -> - { - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); - }, 20); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index 5f28115a4..3909e69c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -4,12 +4,6 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.nether.NetherManager; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -21,6 +15,13 @@ import org.bukkit.event.world.ChunkUnloadEvent; import com.google.common.collect.Lists; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.nether.NetherManager; +import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent; + /** * Manager to handle miniboss spawning in the nether */ @@ -31,6 +32,7 @@ public class NetherMinibossManager implements Listener private HashMap _spawns = new HashMap<>(); private long _lastSpawned; private boolean _allowSpawn = false; + private boolean _allowSpawnEvent = false; public NetherMinibossManager(NetherManager manager) { @@ -83,12 +85,21 @@ public class NetherMinibossManager implements Listener _allowSpawn = false; } + @EventHandler + public void onAllowSpawn(ClassCombatCreatureAllowSpawnEvent event) + { + if (event.getWorldName().equalsIgnoreCase(_manager.getNetherWorld().getName())) + { + _allowSpawnEvent = event.getAllowed(); + } + } + @EventHandler public void onSpawnNormal(EntitySpawnEvent event) { if (event.getEntity() instanceof LivingEntity && _manager.getNetherWorld().equals(event.getLocation().getWorld())) { - if (!_allowSpawn) + if (!_allowSpawn && !_allowSpawnEvent) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java index 72ce7c439..d2a4e938c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -34,7 +34,7 @@ import org.bukkit.potion.PotionEffectType; public class ArcherMiniboss extends NetherMiniBoss { private static final int BARBED_LEVEL = 1; - private static final double RUNE_DROP_CHANCE = .1; + private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_DIAMOND_DROPS = 5; public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index 45133db1c..6ff341b58 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -31,7 +31,7 @@ public class GhastMiniboss extends NetherMiniBoss private static final long MAIN_FIREBALL_COOLDOWN = 5000; private static final long FIREBALL_LAUNCH_RATE = 500; private static final int FIREBALLS_PER_USE = 5; - private static final double RUNE_DROP_CHANCE = .1; + private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_DIAMOND_DROPS = 5; private static final double MAX_TARGET_RANGE = 25; private long _lastFireballUse; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java index df682506a..248c9bf64 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -32,7 +32,7 @@ import org.bukkit.potion.PotionEffectType; */ public class WarriorMiniboss extends NetherMiniBoss { - private static final double RUNE_DROP_CHANCE = .1; + private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_DIAMOND_DROPS = 5; private static final double LEAP_CHANCE = .9; private static final double LEAP_MIN_DIST = 3; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 3fb06b2f0..b5e11e8a1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -52,6 +52,10 @@ public class ScoreboardElementPlayer implements ScoreboardElement if (_clansManager.getNetherManager().isInNether(player)) { regionString = C.cClansNether + "The Nether"; + if (_clansManager.getClanUtility().isSafe(player.getLocation())) + { + regionString = C.cClansNether + "Nether Spawn"; + } } output.add(regionString); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index d3c8049af..0b1630995 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.siege.weapon.projectile; import java.util.HashMap; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -44,7 +43,7 @@ public class Crater { List blocks = Lists.newArrayList(); List noRepeats = Lists.newArrayList(); - for (Block block : UtilBlock.getExplosionBlocks(_origin, 2.6f, false)) + for (Block block : UtilBlock.getInRadius(_origin, 3).keySet()) { String locID = block.getLocation().getX() + " " + block.getLocation().getY() + " " + block.getLocation().getZ(); if (noRepeats.contains(locID)) @@ -55,7 +54,7 @@ public class Crater { noRepeats.add(locID); } - if (block.getType() == Material.AIR || block.isLiquid()) + if (block.getType() == Material.AIR || block.isLiquid() || block.getType() == Material.BEDROCK) { continue; } @@ -82,7 +81,7 @@ public class Crater UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _origin, null, 0, 1, ViewDist.NORMAL); for (Block block : event.getBlocks()) { - if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE || block.getType() == Material.BED_BLOCK) { block.breakNaturally(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java index a305dfd20..75cd73e49 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java @@ -74,7 +74,7 @@ public abstract class WeaponProjectile implements Listener boolean moving = Math.abs(_projectileEntity.getVelocity().getX()) > 0.01 || Math.abs(_projectileEntity.getVelocity().getZ()) > 0.01; // Some rough collision detection. Not perfect, but the best I could conjure up myself. - if (!moving && !UtilBlock.boundless(_projectileEntity.getLocation(), 2)) + if ((!moving && !UtilBlock.boundless(_projectileEntity.getLocation(), 2)) || (_projectileEntity instanceof TNTPrimed && _projectileEntity.getTicksLived() >= 80)) { SiegeWeaponExplodeEvent newEvent = UtilServer.CallEvent(new SiegeWeaponExplodeEvent(_weapon, this)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 378b50478..d8b89874e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -21,7 +21,7 @@ import com.google.common.collect.Lists; public class EventTerrainFinder { - private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(3, TimeUnit.HOURS, TimeUnit.MILLISECONDS); + private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(2, TimeUnit.HOURS, TimeUnit.MILLISECONDS); private ClansManager _clansManager; public EventTerrainFinder(ClansManager clansManager) @@ -135,18 +135,14 @@ public class EventTerrainFinder */ private static enum EventLocation { - NORTH_1("world", -495, 73, -1028), - NORTH_2("world", 197, 66, -1018), - NORTH_3("world", 948, 72, -959), - EAST_1("world", 1109, 66, -753), - EAST_2("world", 1141, 68, 31), - EAST_3("world", 1044, 71, 603), - SOUTH_1("world", 690, 71, 895), - SOUTH_2("world", 144, 66, 1012), - SOUTH_3("world", -1093, 72, 895), - WEST_1("world", -937, 71, 559), - WEST_2("world", -1092, 67, -9), - WEST_3("world", -969, 72, -441); + ONE("world", -662, 64, -1108), + TWO("world", 738, 64, -986), + THREE("world", 1180, 64, -435), + FOUR("world", 995, 64, 550), + FIVE("world", 375, 64, 1142), + SIX("world", -479, 64, 975), + SEVEN("world", -1140, 64, 449), + EIGHT("world", -1014, 64, -342); private String _world; private double _x, _y, _z; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java index abeabf652..fe96c7d1e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java @@ -12,7 +12,7 @@ import mineplex.core.common.util.UtilPlayer; public class CustomRecipes implements Listener { - private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED }; + private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED, Material.BOAT, Material.HOPPER, Material.HOPPER_MINECART }; @EventHandler public void onPlayerCraftItem(CraftItemEvent event) @@ -43,4 +43,4 @@ public class CustomRecipes implements Listener { UtilPlayer.message(player, F.main("Recipes", message)); } -} +} \ No newline at end of file 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 2c7a971f1..cafa0fe65 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 @@ -80,6 +80,8 @@ import org.bukkit.plugin.java.JavaPlugin; public class Gameplay extends MiniPlugin { + private static final int MAX_BUILD_HEIGHT = 120; + private static final int MIN_CHEST_HEIGHT = 30; private ClansManager _clansManager; private BlockRestore _blockRestore; private DamageManager _damageManager; @@ -230,19 +232,27 @@ public class Gameplay extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void MaxHeight(BlockPlaceEvent event) { - if (event.getBlock().getLocation().getBlockY() > 100) + if (event.getBlock().getLocation().getBlockY() > MAX_BUILD_HEIGHT) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high.")); event.setCancelled(true); - } else if(event.getBlock().getLocation().getBlockY() == 99 && event.getBlock().getType().name().contains("DOOR") && !event.getBlock().getType().equals(Material.TRAP_DOOR)) { + } + else if(event.getBlock().getLocation().getBlockY() == (MAX_BUILD_HEIGHT - 1) && event.getBlock().getType().name().contains("DOOR") && event.getBlock().getType() != Material.TRAP_DOOR && event.getBlock().getType() != Material.IRON_TRAPDOOR) + { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high.")); event.setCancelled(true); } + + if (event.getBlock().getLocation().getBlockY() < MIN_CHEST_HEIGHT && (event.getBlock().getType() == Material.CHEST || event.getBlock().getType() == Material.TRAPPED_CHEST)) + { + event.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOWEST) - public void GrowTree(StructureGrowEvent event) { - event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > 100).forEach(blockState -> blockState.setType(Material.AIR) ); + public void GrowTree(StructureGrowEvent event) + { + event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > MAX_BUILD_HEIGHT).forEach(blockState -> blockState.setType(Material.AIR) ); } /** diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index db6fa935f..154ac45b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -41,11 +41,17 @@ public class SafeLog extends MiniPlugin new File(clansManager.UserDataDir).mkdir(); } + @Override + public void disable() + { + NPCManager.getInstance().disable(); + } + public void onPlayerQuit(Player player) { boolean isSafeLog = false; - if (_clansManager.getClanUtility().isSafe(player.getLocation())) + if (_clansManager.getClanUtility().isSafe(player)) { isSafeLog = true; } 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 aa702ebfd..0c72d609f 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 @@ -32,7 +32,7 @@ public abstract class AttackAttribute extends ItemAttribute { if(event.IsCancelled() || event.isCancelled()) return; _attackCount++; - System.out.println("Attack count " + _attackCount + " - " + _attackLimit); +// System.out.println("Attack count " + _attackCount + " - " + _attackLimit); if (_attackCount >= _attackLimit) { _attackCount = 0; 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 index 9e9596b05..d339abe72 100644 --- 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 @@ -5,17 +5,20 @@ import org.bukkit.entity.Player; 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; // A.K.A Conquering for Armor -public class ConqueringArmorAttribute extends FlatReductionAttribute +public class ConqueringArmorAttribute extends ItemAttribute { - private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d); - private static ReductionConfig config = new ReductionConfig(); + private static ValueDistribution reductionGen = generateDistribution(2.5d, 6.25d); + private double _reduction; public ConqueringArmorAttribute() { - super(AttributeType.SUFFIX, reductionGen, config); + super(AttributeType.SUFFIX); + _reduction = reductionGen.generateValue() / 100; } @Override @@ -23,14 +26,30 @@ public class ConqueringArmorAttribute extends FlatReductionAttribute { return "Conquering"; } + + @Override + public void onAttacked(CustomDamageEvent event) + { + DamageCause cause = event.GetCause(); + Entity attacker = event.GetDamagerEntity(true); + + if (reducesDamage(cause, attacker)) + { + event.AddMult("Conquering Armor", new String(), 1 - _reduction, false); +// System.out.println("Reduced damage by " + reduction); + } + else + { +// System.out.println("Armor doesn't reduce " + cause); + } + } @Override public String getDescription() { - return String.format("-%.1f damage taken from mobs & bosses", getFlatReduction()); + return String.format("%.1f%% damage taken from mobs & bosses", (1 - _reduction) * 100); } - @Override public boolean reducesDamage(DamageCause cause, Entity attacker) { return !(attacker instanceof Player); // Reduces damage from all entities 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 c7362f417..764c44d11 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 @@ -36,7 +36,7 @@ public abstract class ReductionAttribute extends ItemAttribute double damage = event.GetDamage(); double reduction = getDamageReduction(damage); event.AddMod("Reduction Armor", -reduction); - System.out.println("Reduced damage by " + reduction); +// System.out.println("Reduced damage by " + reduction); } else { 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 daa299754..c8bcfb635 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 @@ -33,6 +33,10 @@ public class ScorchingAttribute extends AttackAttribute @Override public void triggerAttack(Entity attacker, Entity defender) { + if (isTeammate(attacker, defender)) + { + return; + } defender.setFireTicks((int) (_fireDuration * 20)); } 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 bc0a56ec8..02c7744b7 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 @@ -9,7 +9,7 @@ import org.bukkit.entity.Player; public class ConqueringAttribute extends DamageAttribute { - private static ValueDistribution damageGen = generateDistribution(1.0d, 6.0d); + private static ValueDistribution damageGen = generateDistribution(1.0d, 4.0d); public ConqueringAttribute() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java index 9072d0dfe..70837d017 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java @@ -1,13 +1,19 @@ package mineplex.game.clans.items.rares; +import java.util.HashSet; + import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -35,6 +41,7 @@ public class RunedPickaxe extends RareItem { UtilServer.RegisterEvents(new Listener() { + @SuppressWarnings("deprecation") @EventHandler public void update(UpdateEvent event) { @@ -65,6 +72,11 @@ public class RunedPickaxe extends RareItem pick._enabled = false; } + + if (!pick._enabled) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 20 * 2, 100)); + } }); } @@ -105,6 +117,31 @@ public class RunedPickaxe extends RareItem event.getPlayer().playSound(event.getBlock().getLocation(), Sound.LAVA_POP, 1.f, 1.f); } } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void blockDamage(BlockBreakEvent event) + { + PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer()); + + if (!(gear.getWeapon() instanceof RunedPickaxe)) + { + return; + } + + RunedPickaxe pick = (RunedPickaxe) gear.getWeapon(); + + if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) + return; + + if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) + return; + + if (!pick._enabled) + { + event.setCancelled(true); + event.getBlock().breakNaturally(); + } + } }); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index 2800434cb..23d5fd391 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -14,9 +14,13 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.portal.Portal; +import mineplex.core.slack.SlackAPI; +import mineplex.core.slack.SlackMessage; +import mineplex.core.slack.SlackTeam; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class RestartManager extends MiniPlugin { @@ -26,10 +30,16 @@ public class RestartManager extends MiniPlugin private Long _restartTime = -1L; private boolean _restarting; + private final String _serverName; + private final boolean _testServer; + public RestartManager(JavaPlugin plugin) { super("Restart Manager", plugin); + _serverName = plugin.getConfig().getString("serverstatus.name"); + _testServer = plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + if (inRestartZone(Calendar.HOUR_OF_DAY)) { _restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - Calendar.HOUR_OF_DAY, TimeUnit.HOURS, TimeUnit.MILLISECONDS); @@ -44,6 +54,11 @@ public class RestartManager extends MiniPlugin _warnings.add(10000L); _warnings.add(5000L); addCommand(new RestartCommand(this)); + + if (!_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has started up!"), true); + } } private boolean inRestartZone(int hour) @@ -51,7 +66,7 @@ public class RestartManager extends MiniPlugin return hour >= 0 && hour < MAX_RESTART_TIME; //12 am = 0 } - private boolean tryRestart() + private boolean tryRestartTime() { if (!inRestartZone(Calendar.HOUR_OF_DAY) || System.currentTimeMillis() < _restartUnlock) { @@ -73,6 +88,18 @@ public class RestartManager extends MiniPlugin return true; } + private boolean tryRestartTps() + { + boolean restart = MinecraftServer.getServer().recentTps[0] <= 12; + + if (restart && !_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has scheduled an immediate restart due to low TPS!"), true); + } + + return restart; + } + public void restart() { Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!")); @@ -107,12 +134,19 @@ public class RestartManager extends MiniPlugin { _restarting = true; Portal.getInstance().sendAllPlayers("ClansHub"); - runSyncLater(() -> {Bukkit.shutdown();}, 120L); + runSyncLater(() -> + { + if (!_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " is now restarting!"), true); + } + Bukkit.shutdown(); + }, 120L); } } else { - if (tryRestart()) + if (tryRestartTime() || tryRestartTps()) { restart(); } 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 5c57ef602..979b9743e 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 @@ -314,6 +314,10 @@ public class Spawn extends MiniPlugin for (LivingEntity entity : getSpawnWorld().getLivingEntities()) { + if (entity.hasMetadata("CombatLogNPC")) + { + continue; + } if (entity instanceof Monster) { Monster monster = (Monster) entity; @@ -456,7 +460,7 @@ public class Spawn extends MiniPlugin public static Location getWestTown() { - return new Location(getSpawnWorld(), -440.91, 65, 23.08); + return new Location(getSpawnWorld(), -440.91, 67, 23.08); } public static Location getWestTownCenter() @@ -466,7 +470,7 @@ public class Spawn extends MiniPlugin public static Location getEastTown() { - return new Location(getSpawnWorld(), 440.91, 65, -23.08); + return new Location(getSpawnWorld(), 440.91, 72, -23.08); } public static Location getEastTownCenter() diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 6272f6477..bb78c2da8 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -45,7 +45,7 @@ import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.thank.ThankManager; -import mineplex.core.titangiveaway.TitanGiveawayManager; +import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 138afe4b1..44ce0a05f 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -190,7 +190,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager); + PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager); _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); World world = _spawn.getWorld(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 56a6af3ae..0b2ed154d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,5 +1,10 @@ package mineplex.hub; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.CustomTagFix; import mineplex.core.PacketsInteractionFix; import mineplex.core.account.CoreClientManager; @@ -56,7 +61,7 @@ import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.thank.ThankManager; -import mineplex.core.titangiveaway.TitanGiveawayManager; +import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; @@ -75,10 +80,6 @@ import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; import static mineplex.core.Managers.require; @@ -187,7 +188,7 @@ public class Hub extends JavaPlugin implements IRelation //new Replay(this, packetHandler); SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); - ReportManager reportManager = new ReportManager(this, snapshotManager, clientManager, incognito, punish, serverStatusManager.getCurrentServerName(), 3); + ReportManager reportManager = new ReportManager(this, snapshotManager, clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 3); new SnapshotPlugin(this, snapshotManager, clientManager); new ReportPlugin(this, reportManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index fdba4cb6c..50eb8abc6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -218,7 +218,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager); + PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager); _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java index 90806d135..d1ba19b1f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java @@ -3,24 +3,25 @@ package mineplex.hub.modules; import java.util.ArrayList; import java.util.HashMap; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.hub.HubManager; -import mineplex.hub.commands.HorseSpawn; - import org.bukkit.Material; import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.utils.UtilVariant; +import mineplex.hub.HubManager; +import mineplex.hub.commands.HorseSpawn; + public class AdminMountManager extends MiniPlugin { private HubManager Manager; @@ -291,12 +292,11 @@ public class AdminMountManager extends MiniPlugin Horse horse = _mounts.remove(caller); if (horse != null) horse.remove(); - horse = caller.getWorld().spawn(caller.getLocation(), Horse.class); + horse = UtilVariant.spawnHorse(caller.getLocation(), var); horse.setAdult(); horse.setAgeLock(true); horse.setColor(Color.DARK_BROWN); horse.setStyle(Style.WHITE_DOTS); - horse.setVariant(var); horse.setOwner(caller); horse.setMaxDomestication(1); horse.setJumpStrength(1); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index 1d8a19f78..0d83153c4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -20,7 +20,6 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.Snowman; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -50,6 +49,7 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; import mineplex.hub.HubManager; import mineplex.hub.HubType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -130,11 +130,14 @@ public class WorldManager extends MiniPlugin //Spawn if (Manager.Type == HubType.Halloween) { - Skeleton ent = loc.getWorld().spawn(loc, Skeleton.class); - + final Skeleton ent; if (Math.random() > 0.5) { - ent.setSkeletonType(SkeletonType.WITHER); + ent = UtilVariant.spawnWitherSkeleton(loc); + + } else + { + ent = loc.getWorld().spawn(loc, Skeleton.class); } ent.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java index 8c7fe10d2..43b9624ec 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java @@ -90,7 +90,7 @@ public class Illusion extends SkillActive public void Skill(Player player, int level) { //Spawn - ClassCombatCreatureAllowSpawnEvent enableEvent = new ClassCombatCreatureAllowSpawnEvent(true); + ClassCombatCreatureAllowSpawnEvent enableEvent = new ClassCombatCreatureAllowSpawnEvent(player.getWorld().getName(), true); UtilServer.getServer().getPluginManager().callEvent(enableEvent); Skeleton skel = player.getWorld().spawn(player.getLocation(), Skeleton.class); @@ -101,7 +101,7 @@ public class Illusion extends SkillActive skel.setMaxHealth(14); skel.setHealth(14); - ClassCombatCreatureAllowSpawnEvent disableEvent = new ClassCombatCreatureAllowSpawnEvent(false); + ClassCombatCreatureAllowSpawnEvent disableEvent = new ClassCombatCreatureAllowSpawnEvent(player.getWorld().getName(), false); UtilServer.getServer().getPluginManager().callEvent(disableEvent); skel.getEquipment().setHelmet(player.getInventory().getHelmet()); 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 3422b690b..931426de1 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 @@ -3,6 +3,7 @@ package mineplex.minecraft.game.classcombat.Skill.Brute; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -20,6 +21,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -63,7 +65,9 @@ public class BlockToss extends SkillCharge implements IThrown Material.BURNING_FURNACE, Material.WORKBENCH, Material.WATER, + Material.STATIONARY_WATER, Material.LAVA, + Material.STATIONARY_LAVA, Material.STONE_PLATE, Material.WOOD_PLATE, Material.GOLD_PLATE, @@ -428,6 +432,23 @@ public class BlockToss extends SkillCharge implements IThrown if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1) event.setCancelled(true); } + + @EventHandler + public void expireUnload(ChunkUnloadEvent event) + { + Iterator> iterator = _falling.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + FallingBlock key = entry.getKey(); + + if (key.getLocation().getChunk().equals(event.getChunk())) + { + key.remove(); + iterator.remove(); + } + } + } @Override public void Reset(Player player) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java index 97ccfe772..227857266 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java @@ -7,12 +7,19 @@ public class ClassCombatCreatureAllowSpawnEvent extends Event { private static final HandlerList handlers = new HandlerList(); + private String _worldName; private boolean _allow; - public ClassCombatCreatureAllowSpawnEvent(boolean allow) + public ClassCombatCreatureAllowSpawnEvent(String worldName, boolean allow) { + _worldName = worldName; _allow = allow; } + + public String getWorldName() + { + return _worldName; + } public HandlerList getHandlers() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java index 3f58ac483..4366c95b1 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java @@ -2,13 +2,6 @@ package mineplex.minecraft.game.core.boss.snake; import java.util.UUID; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.EntityArmorStand; import net.minecraft.server.v1_8_R3.Packet; @@ -19,6 +12,14 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.Vector3f; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; + public class SnakeSegment { private int _entityId = UtilEnt.getNewEntityId(); @@ -107,10 +108,7 @@ public class SnakeSegment watcher.a(15, new Vector3f(0, 0, 0), EntityArmorStand.META_LEFT_LEG_POSE, new Vector3f(0, 0, 0)); watcher.a(16, new Vector3f(0, 0, 0), EntityArmorStand.META_RIGHT_LEG_POSE, new Vector3f(0, 0, 0)); - PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(); - - meta.a = getId(); - meta.b = watcher.c(); + PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(getId(), watcher, true); return new Packet[] { diff --git a/Plugins/Mineplex.ReportSite/sql/upgrade.sql b/Plugins/Mineplex.ReportSite/sql/1-upgrade.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/upgrade.sql rename to Plugins/Mineplex.ReportSite/sql/1-upgrade.sql diff --git a/Plugins/Mineplex.ReportSite/sql/after-upgrade.sql b/Plugins/Mineplex.ReportSite/sql/2-after-upgrade.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/after-upgrade.sql rename to Plugins/Mineplex.ReportSite/sql/2-after-upgrade.sql diff --git a/Plugins/Mineplex.ReportSite/sql/hotfix.sql b/Plugins/Mineplex.ReportSite/sql/3-hotfix.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/hotfix.sql rename to Plugins/Mineplex.ReportSite/sql/3-hotfix.sql diff --git a/Plugins/Mineplex.ReportSite/sql/snapshot-tokens.sql b/Plugins/Mineplex.ReportSite/sql/4-snapshot-tokens.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/snapshot-tokens.sql rename to Plugins/Mineplex.ReportSite/sql/4-snapshot-tokens.sql diff --git a/Plugins/Mineplex.ReportSite/sql/5-region-lock.sql b/Plugins/Mineplex.ReportSite/sql/5-region-lock.sql new file mode 100644 index 000000000..33260ef6b --- /dev/null +++ b/Plugins/Mineplex.ReportSite/sql/5-region-lock.sql @@ -0,0 +1,3 @@ +ALTER TABLE Account.reports ADD region VARCHAR(5) NULL; +ALTER TABLE Account.reports + MODIFY COLUMN region VARCHAR(5) AFTER categoryId; \ No newline at end of file diff --git a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql new file mode 100644 index 000000000..b0a634722 --- /dev/null +++ b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql @@ -0,0 +1,71 @@ +-- RENAME COLUMN `creator` to `creatorId` +ALTER TABLE Account.snapshots CHANGE creator creatorId INT(11); + +-- STORE DATETIME SNAPSHOT CREATED (CLEANUP PURPOSES) +ALTER TABLE Account.snapshots ADD created DATETIME DEFAULT NOW() NOT NULL; +ALTER TABLE Account.snapshots + MODIFY COLUMN creatorId INT(11) AFTER created; + +-- CASCADE HANDLERS TABLE +ALTER TABLE Account.reportHandlers DROP FOREIGN KEY reportHandlers_reports_id_fk; +ALTER TABLE Account.reportHandlers + ADD CONSTRAINT reportHandlers_reports_id_fk +FOREIGN KEY (reportId) REFERENCES reports (id) ON DELETE CASCADE; + +-- CASCADE REASONS/REPORTERS TABLE +ALTER TABLE Account.reportReasons DROP FOREIGN KEY reportReasons_reports_id_fk; +ALTER TABLE Account.reportReasons + ADD CONSTRAINT reportReasons_reports_id_fk +FOREIGN KEY (reportId) REFERENCES reports (id) ON DELETE CASCADE; + +-- CASCADE RESULTS TABLE +ALTER TABLE Account.reportResults DROP FOREIGN KEY reportResults_reports_id_fk; +ALTER TABLE Account.reportResults + ADD CONSTRAINT reportResults_reports_id_fk +FOREIGN KEY (reportId) REFERENCES reports (id) ON DELETE CASCADE; + +-- CASCADE SNAPSHOT MESSAGE MAP +ALTER TABLE Account.snapshotMessageMap DROP FOREIGN KEY snapshotMessageMap_snapshots_id_fk; +ALTER TABLE Account.snapshotMessageMap + ADD CONSTRAINT snapshotMessageMap_snapshots_id_fk +FOREIGN KEY (snapshotId) REFERENCES snapshots (id) ON DELETE CASCADE; +ALTER TABLE Account.snapshotMessageMap DROP FOREIGN KEY snapshotMessageMap_snapshotMessages_id_fk; +ALTER TABLE Account.snapshotMessageMap + ADD CONSTRAINT snapshotMessageMap_snapshotMessages_id_fk +FOREIGN KEY (messageId) REFERENCES snapshotMessages (id) ON DELETE CASCADE; + +-- CASCADE SNAPSHOT RECIPIENTS TABLE +ALTER TABLE Account.snapshotRecipients DROP FOREIGN KEY snapshotRecipients_snapshotMessages_id_fk; +ALTER TABLE Account.snapshotRecipients + ADD CONSTRAINT snapshotRecipients_snapshotMessages_id_fk +FOREIGN KEY (messageId) REFERENCES snapshotMessages (id) ON DELETE CASCADE; + +-- CREATE CLEANUP TASK +DELIMITER // + +-- CREATE EVENT TO RUN EVERY DAY AT 00:00 +CREATE EVENT `report_cleanup` + ON SCHEDULE + EVERY 1 DAY + -- FORCE TASK TO RUN AT 00:00 DAILY + STARTS (TIMESTAMP(CURRENT_DATE) + INTERVAL 1 DAY) + ON COMPLETION PRESERVE + COMMENT 'Cleans up old report and snapshot data.' +DO BEGIN + -- DELETE REPORTS (AND ASSOCIATED SNAPSHOT IF ANY) CLOSED > 30 DAYS AGO + DELETE reports, snapshots FROM reports + LEFT JOIN reportResults ON reports.id = reportResults.reportId + LEFT JOIN snapshots ON reports.snapshotId = snapshots.id + WHERE reportResults.closedTime NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW(); + + -- DELETE SNAPSHOTS NOT LINKED TO REPORT AND OLDER THAN 30 DAYS + DELETE snapshots FROM snapshots + LEFT JOIN reports ON snapshots.id = reports.snapshotId + WHERE reports.id IS NULL + AND snapshots.created NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW(); + + -- DELETE ORPHANED SNAPSHOT MESSAGES + DELETE snapshotMessages FROM snapshotMessages + LEFT JOIN snapshotMessageMap ON snapshotMessages.id = snapshotMessageMap.messageId + WHERE snapshotMessageMap.snapshotId IS NULL; +END// \ No newline at end of file diff --git a/Plugins/Mineplex.ReportSite/view.php b/Plugins/Mineplex.ReportSite/view.php index c039365a8..09fe80a32 100644 --- a/Plugins/Mineplex.ReportSite/view.php +++ b/Plugins/Mineplex.ReportSite/view.php @@ -1,5 +1,4 @@ prepare('SELECT id FROM snapshots WHERE token = ?;'); - $statement->bind_param('s', $token); // TODO: correct data type + $statement->bind_param('s', $token); $statement->execute(); $statement->bind_result($snapshotId); $statement->store_result(); @@ -286,13 +285,11 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id } /** - * @param Snapshot $snapshot * @param Report $report * @return User[] */ - function getInvolvedUsers($snapshot, $report) + function getInvolvedUsers($report) { - $involvedUsers = $snapshot->getPlayers(); $involvedUsers[$report->getSuspect()->getId()] = $report->getSuspect(); foreach ($report->getReporters() as $reporterReason) { @@ -384,6 +381,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id $validToken = isset($_GET['token']); $errorMsg = ""; + $title = 'Report & Snapshot System'; $token = null; $expanded = null; $report = null; @@ -401,15 +399,16 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id $snapshot = getSnapshot($snapshotId); $messages = $snapshot->getMessages(); $reportId = getSnapshotReportId($snapshotId); + $report = null; if ($reportId) { $report = getReport($reportId); + $title = "Report #$reportId"; } else { - $validToken = false; - $errorMsg = 'Associated report not found.'; // TODO: Allow snapshots without reports in future + $title = "Snapshot #$snapshotId"; } } else @@ -428,13 +427,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id - <?php if ($validToken): ?> - Report #<?= $report->getId() ?> - <?php else: ?> - Report System - <?php endif; ?> - - · Mineplex + <?= $title ?> · Mineplex @@ -471,7 +464,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id

- Report #getId() ?> +


@@ -481,21 +474,23 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
getReporters() as $reporterReason) + if ($report != null) { - $reporterUsernames[count($reporterUsernames)] = $reporterReason->getUser()->getUsername(); + $involvedUsers = getInvolvedUsers($report); + } + else + { + $involvedUsers = array(); } - $involvedUsers = getInvolvedUsers($snapshot, $report); - - $reportCreationTime = $report->getTimeCreated(); - $age = approximateHumanInterval($reportCreationTime->diff(new DateTime('now', $reportCreationTime->getTimezone()))); + foreach ($snapshot->getPlayers() as $player) + { + $involvedUsers[$player->getId()] = $player; + } if($displayAmount == 0): ?> No chat log available for this report. @@ -517,7 +512,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id - getSender()->getUsername() ?> + getSender()->getUsername() ?>  -> getRecipients()[0]->getUsername() ?> @@ -540,39 +535,51 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
-

   Information

-
-
-
- - -
+ +

   Information

+
+
+
+ getReporters() as $reporterReason) + { + $reporterUsernames[count($reporterUsernames)] = $reporterReason->getUser()->getUsername(); + } - - getCategory()] ?> -
+ $reportCreationTime = $report->getTimeCreated(); + $age = approximateHumanInterval($reportCreationTime->diff(new DateTime('now', $reportCreationTime->getTimezone()))); + ?> + + +
- - Reported by -
+ + getCategory()] ?> +
- - Suspect is getSuspect()->getUsername() ?> -
+ + Reported by +
- - - getHandler() != null): ?> - Staff Member assigned is getHandler()->getUsername() ?> - - No Staff Member assigned - - -
+ + Suspect is getSuspect()->getUsername() ?> +
+ + + + getHandler() != null): ?> + Staff Member assigned is getHandler()->getUsername() ?> + + No Staff Member assigned + + +
+
-
-
- +
+

   Users


diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index aed398e97..1edf932ea 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -9,7 +9,7 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; -import mineplex.core.pet.PetFactory; +import mineplex.core.pet.PetType; import mineplex.core.pet.repository.PetRepository; import mineplex.core.powerplayclub.PowerPlayClubRepository; import mineplex.core.stats.StatsManager; @@ -45,8 +45,7 @@ public class SalesPackageManager extends MiniPlugin private StatsManager _statsManager; private PowerPlayClubRepository _powerPlayRepo; private PetRepository _petRepo; - private PetFactory _petFactory; - + private NautHashMap _salesPackages = new NautHashMap(); public SalesPackageManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, StatsManager statsManager, PowerPlayClubRepository powerPlayRepo) @@ -60,8 +59,7 @@ public class SalesPackageManager extends MiniPlugin _powerPlayRepo = powerPlayRepo; _petRepo = new PetRepository(plugin, plugin.getConfig().getString("webServer")); - _petFactory = new PetFactory(_petRepo); - + //Strutt20 asked me to remove some of the stuff from the menu AddSalesPackage(new Coins(this, 5000)); @@ -95,9 +93,9 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new HauntedChest(this)); AddSalesPackage(new TrickOrTreatChest(this)); - for (mineplex.core.pet.Pet pet : _petFactory.GetPets()) + for (PetType petType : PetType.values()) { - AddSalesPackage(new Pet(this, pet.getName(), pet.getPetType())); + AddSalesPackage(new Pet(this, petType.getName(), petType)); } } @@ -137,11 +135,6 @@ public class SalesPackageManager extends MiniPlugin { return _petRepo; } - - public PetFactory getPetFactory() - { - return _petFactory; - } public void help(Player player) { diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java index 69c5d6aac..4fcca75da 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java @@ -2,7 +2,6 @@ package mineplex.staffServer.salespackage.command; import java.util.UUID; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import com.google.gson.Gson; @@ -11,8 +10,8 @@ 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.pet.Pet; import mineplex.core.pet.PetClient; +import mineplex.core.pet.PetType; import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.staffServer.salespackage.SalesPackageManager; @@ -33,13 +32,13 @@ public class PetCommand extends CommandBase final String playerName = args[0]; int petId = Integer.parseInt(args[1]); - if ((petId < 0 || petId >= EntityType.values().length) || Plugin.getPetFactory().getPet(EntityType.values()[petId]) == null) + if (petId < 0 || petId >= PetType.values().length) { caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Pet Type.")); return; } - final EntityType petType = EntityType.values()[petId]; + final PetType petType = PetType.values()[petId]; Plugin.getClientManager().loadClientByName(playerName, client -> { @@ -57,12 +56,11 @@ public class PetCommand extends CommandBase } else { - Pet pet = Plugin.getPetFactory().getPet(petType); PetChangeToken token = new PetChangeToken(); token.AccountId = client.getAccountId(); token.Name = playerName; token.PetType = petType.toString(); - token.PetName = pet.getName(); + token.PetName = petType.getName(); Plugin.getPetRepo().AddPet(token); Plugin.getInventoryManager().addItemToInventoryForOffline(success -> diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java index add8d52ae..86a15bca4 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java @@ -1,16 +1,16 @@ package mineplex.staffServer.salespackage.salespackages; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import mineplex.core.pet.PetType; import mineplex.staffServer.salespackage.SalesPackageManager; public class Pet extends SalesPackageBase { private String _petName; - private EntityType _petType; + private PetType _petType; - public Pet(SalesPackageManager manager, String petName, EntityType petType) + public Pet(SalesPackageManager manager, String petName, PetType petType) { super(manager, "1 " + petName + " Pet"); _petName = petName; 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 2a9f9b518..422862f46 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -161,7 +161,7 @@ public class Arcade extends JavaPlugin new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); - ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getCurrentServerName(), 1); + ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1); new SnapshotPlugin(this, snapshotManager, _clientManager); new ReportPlugin(this, reportManager); 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 76f7a3669..4c4272685 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -14,7 +14,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -91,8 +90,6 @@ import mineplex.core.progression.KitProgressionManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.resourcepack.ResourcePackManager; -import mineplex.core.reward.RewardRarity; -import mineplex.core.reward.rewards.PetReward; import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.sponsorbranding.BrandingManager; @@ -102,7 +99,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.thank.ThankManager; import mineplex.core.timing.TimingManager; -import mineplex.core.titangiveaway.TitanGiveawayManager; +import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.valentines.ValentinesGiftManager; import mineplex.core.youtube.YoutubeManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -154,6 +151,7 @@ import nautilus.game.arcade.managers.GameStatManager; import nautilus.game.arcade.managers.GameTestingManager; import nautilus.game.arcade.managers.GameTournamentManager; import nautilus.game.arcade.managers.GameWorldManager; +import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; import nautilus.game.arcade.managers.NextBestGameManager; @@ -190,6 +188,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation //Champions Modules private boolean _enabled = true; + private Boolean _registered = null; private ClassManager _classManager; private SkillFactory _skillFactory; private ItemFactory _itemFactory; @@ -335,7 +334,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation new GameStatManager(this); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager); + PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager); _bonusManager = new BonusManager(plugin, _gameLobbyManager.getCarl(), playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager); new GameLootManager(this, petManager, _bonusManager.getRewardManager()); @@ -345,9 +344,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); - - //new HolidayManager(this, titanGiveaway); - IsHolidayEnabled = false; + + new HolidayManager(this, titanGiveaway); + IsHolidayEnabled = true; new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); new GameTestingManager(this); @@ -1707,56 +1706,45 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _idleManager; } - public void rewardPet(Player player, String pet, EntityType type) - { - if (!player.isOnline()) - return; - - PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, pet, pet, type, RewardRarity.OTHER, 0, 0); - - if (reward.canGiveReward(player)) - reward.giveReward(null, player, data -> - { - - }); - } - public void enableChampionsModules() { - _classManager.setEnabled(true); - _classShopManager.registerSelf(); - _skillFactory.registerSelf(); - _itemFactory.registerSelf(); - _energy.registerSelf(); - _eloManager.registerSelf(); + if (_registered == null || !_registered) + { + _classManager.setEnabled(true); + _classShopManager.registerSelf(); + _skillFactory.registerSelf(); + _itemFactory.registerSelf(); + _energy.registerSelf(); + _eloManager.registerSelf(); - //Class Shop - _plugin.getServer().getPluginManager().registerEvents(_classShop, _plugin); + //Class Shop + _plugin.getServer().getPluginManager().registerEvents(_classShop, _plugin); + + _registered = true; + } } public void disableChampionsModules() { - _classManager.setEnabled(false); - _classShopManager.deregisterSelf(); - _skillFactory.deregisterSelf(); - _itemFactory.deregisterSelf(); - _energy.deregisterSelf(); - _eloManager.deregisterSelf(); + if (_registered != null && _registered) + { + _classManager.setEnabled(false); + _classShopManager.deregisterSelf(); + _skillFactory.deregisterSelf(); + _itemFactory.deregisterSelf(); + _energy.deregisterSelf(); + _eloManager.deregisterSelf(); - //Class Shop - HandlerList.unregisterAll(_classShop); + //Class Shop + HandlerList.unregisterAll(_classShop); + _registered = false; + } } public void toggleChampionsModules(GameType gameType) { boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM || gameType == GameType.ChampionsCTF || gameType == GameType.BossBattles; - if (_enabled == isChamps) - { - System.out.println("----------Champions Modules are still " + isChamps); - return; - } - System.out.println("----------Champions Modules set to " + isChamps); _enabled = isChamps; 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 153a260f0..430870814 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 @@ -362,6 +362,9 @@ public abstract class Game implements Listener public boolean TeamMode = false; public boolean TeamPerSpawn = false; + + // Used for "%player% is your teammate" + public boolean ShowTeammateMessage = false; public boolean ForceTeamSize = true; public int PlayersPerTeam = 2; 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 e9dba2596..7a8bffcce 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 @@ -1,5 +1,43 @@ package nautilus.game.arcade.game.games.castlesiege; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.EntityEffect; +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.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -18,6 +56,7 @@ 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.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -38,44 +77,6 @@ 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 org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.EntityEffect; -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.entity.Creature; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Horse.Style; -import org.bukkit.entity.Horse.Variant; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; public class CastleSiege extends TeamGame { @@ -329,7 +330,6 @@ public class CastleSiege extends TeamGame horse.setAgeLock(true); horse.setColor(org.bukkit.entity.Horse.Color.BLACK); horse.setStyle(Style.BLACK_DOTS); - horse.setVariant(Variant.HORSE); horse.setMaxDomestication(1); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java index 1397465e1..75aca805b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java @@ -2,30 +2,30 @@ package nautilus.game.arcade.game.games.christmas.content; import java.util.ArrayList; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilTime; -import nautilus.game.arcade.game.games.christmas.ChristmasAudio; -import nautilus.game.arcade.game.games.christmas.parts.Part5; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.utils.UtilVariant; + +import nautilus.game.arcade.game.games.christmas.ChristmasAudio; +import nautilus.game.arcade.game.games.christmas.parts.Part5; + public class PumpkinKing { private Part5 Host; @@ -45,12 +45,11 @@ public class PumpkinKing _grid = grid; Host.Host.CreatureAllowOverride = true; - _ent = loc.getWorld().spawn(loc, Skeleton.class); + _ent = UtilVariant.spawnWitherSkeleton(loc); Host.Host.CreatureAllowOverride = false; UtilEnt.Vegetate(_ent); UtilEnt.ghost(_ent, true, false); - _ent.setSkeletonType(SkeletonType.WITHER); _ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); _ent.getEquipment().setItemInHand(new ItemStack(Material.TNT)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java index 26b282b57..146402ed2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java @@ -23,6 +23,7 @@ import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.christmas.Christmas; import nautilus.game.arcade.game.games.christmas.ChristmasAudio; @@ -180,15 +181,14 @@ public class Part4 extends Part Location loc = UtilAlg.Random(_mobSpawns); Host.CreatureAllowOverride = true; - Zombie ent = loc.getWorld().spawn(loc, Zombie.class); + Zombie ent = UtilVariant.spawnZombieVillager(loc); Host.CreatureAllowOverride = false; ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_PICKAXE)); ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); - ent.setVillager(true); - + ent.setCustomName("Evil Elf " + UtilMath.randomElement(_evilElfNames)); ent.setHealth(9); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java index 4fef083cc..2240ee244 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java @@ -12,7 +12,6 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -23,6 +22,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.Pair; import mineplex.core.common.animation.AnimationPoint; import mineplex.core.common.animation.Animator; import mineplex.core.common.animation.AnimatorFactory; @@ -33,12 +33,12 @@ 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.pet.PetType; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import javafx.util.Pair; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -139,8 +139,8 @@ public class Halloween2016 extends Halloween _lockAllPlayers = null; for(Entry> e : _playerPreLockData.entrySet()) { - e.getKey().teleport(e.getValue().getKey()); - e.getKey().setGameMode(e.getValue().getValue()); + e.getKey().teleport(e.getValue().getLeft()); + e.getKey().setGameMode(e.getValue().getRight()); if(IsAlive(e.getKey())) { UtilPlayer.showForAll(e.getKey()); @@ -171,7 +171,7 @@ public class Halloween2016 extends Halloween { if(!_playerPreLockData.containsKey(p)) { - _playerPreLockData.put(p, new Pair(p.getLocation(), p.getGameMode())); + _playerPreLockData.put(p, Pair.create(p.getLocation(), p.getGameMode())); p.setGameMode(GameMode.SPECTATOR); } p.teleport(_lockAllPlayers); @@ -682,7 +682,7 @@ public class Halloween2016 extends Halloween if (!player.isOnline()) continue; - PetReward pr = new PetReward(Manager.getCosmeticManager().getPetManager(), Manager.getInventoryManager(), Manager.GetDonation(), "Grim Reaper", "Grim Reaper", EntityType.BLAZE, RewardRarity.OTHER, 0, 0); + PetReward pr = new PetReward(Manager.getCosmeticManager().getPetManager(), Manager.getInventoryManager(), Manager.GetDonation(), "Grim Reaper", "Grim Reaper", PetType.BLAZE, RewardRarity.OTHER, 0, 0); if (pr.canGiveReward(player)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index ebaff1a07..acbdded52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -1,17 +1,8 @@ package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilTime.TimeUnit; -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.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.minecraftleague.tracker.GrabSkullEvent; -import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; +import java.util.List; +import java.util.Random; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.FireworkEffect.Type; @@ -19,8 +10,10 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; -import org.bukkit.entity.*; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -37,8 +30,31 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import java.util.List; -import java.util.Random; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +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.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.minecraftleague.tracker.GrabSkullEvent; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; public class WitherMinionManager implements Listener { @@ -105,9 +121,8 @@ public class WitherMinionManager implements Listener else chosen = _spawns.get(_lastUsed); _host.Host.CreatureAllowOverride = true; - Entity e = _host.Manager.GetCreature().SpawnEntity(chosen, EntityType.SKELETON); _host.Host.CreatureAllowOverride = false; - ((Skeleton)e).setSkeletonType(SkeletonType.WITHER); + Skeleton e = UtilVariant.spawnWitherSkeleton(chosen); _entity = (Skeleton)e; UtilEnt.ghost(e, true, false); UtilEnt.Vegetate(e); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java index 6f1f84cdb..f1c95bec8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java @@ -41,6 +41,7 @@ public class TeamSkyfall extends Skyfall DontAllowOverfill = true; TeamMode = true; + ShowTeammateMessage = true; HideTeamSheep = true; 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 index 74ed0a76a..ead56b27c 100644 --- 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 @@ -67,6 +67,7 @@ public class TeamSkywars extends Skywars TeamMode = true; TeamPerSpawn = true; + ShowTeammateMessage = true; registerModule(new TeamModule()); } 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 index c6414d5fd..d142b1471 100644 --- 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 @@ -6,18 +6,15 @@ import java.util.List; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.scheduler.BukkitRunnable; import mineplex.core.common.Pair; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -40,12 +37,12 @@ public class TeamSuperSmash extends SuperSmash SpawnNearAllies = true; DamageTeamSelf = false; - TeamArmorHotbar = true; - DontAllowOverfill = true; TeamMode = true; - + TeamArmorHotbar = true; + ShowTeammateMessage = true; + registerModule(new TeamModule()); registerStatTrackers(new WinWithoutDyingStatTracker(this, "MLGPro"), new FreeKitWinStatTracker(this), new OneVThreeStatTracker(this), new KillFastStatTracker(this, 3, 10, "TripleKill"), @@ -99,55 +96,6 @@ public class TeamSuperSmash extends SuperSmash Scoreboard.draw(); } - - @Override - @EventHandler - public void gameStart(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - { - return; - } - - super.gameStart(event); - - new BukkitRunnable() - { - - @Override - public void run() - { - for (Player player : GetPlayers(true)) - { - GameTeam team = GetTeam(player); - Player bestTeamMember = null; - - if (team == null) - { - continue; - } - - for (Player teamMember : team.GetPlayers(true)) - { - if (player.equals(teamMember)) - { - continue; - } - - bestTeamMember = teamMember; - } - - if (bestTeamMember == null) - { - UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player); - return; - } - - UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player); - } - } - }.runTaskLater(Manager.getPlugin(), 40); - } @EventHandler public void onCustomDamage(CustomDamageEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java index 6bcd59057..0872b37ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java @@ -14,6 +14,8 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseHorse; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.utils.UtilVariant; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; @@ -110,10 +112,8 @@ public class KitSkeletalHorse extends SmashKit @Override public Entity SpawnEntity(Location loc) { - Horse horse = (Horse) super.SpawnEntity(loc); - - horse.setVariant(Variant.SKELETON_HORSE); - + Horse horse = UtilVariant.spawnHorse(loc, Variant.SKELETON_HORSE); + return horse; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java index bdc668038..348241aab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java @@ -11,7 +11,6 @@ import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityTargetEvent; @@ -29,7 +28,9 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkWitherImage extends SmashPerk @@ -91,10 +92,9 @@ public class PerkWitherImage extends SmashPerk // Spawn Manager.GetGame().CreatureAllowOverride = true; - Skeleton skel = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Skeleton.class); Manager.GetGame().CreatureAllowOverride = false; - skel.setSkeletonType(SkeletonType.WITHER); + Skeleton skel = UtilVariant.spawnWitherSkeleton(player.getEyeLocation().add(player.getLocation().getDirection())); skel.getEquipment().setItemInHand(player.getItemInHand()); skel.setMaxHealth(20); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java index f6c6b1820..229a38aef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -48,6 +48,7 @@ public class TeamSurvivalGames extends SurvivalGames DontAllowOverfill = true; TeamMode = true; + ShowTeammateMessage = true; registerModule(new TeamModule()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java index 22eb53950..051a3e8d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java @@ -1,16 +1,8 @@ package nautilus.game.arcade.kit.perks; -import mineplex.core.common.Rank; -import mineplex.core.common.util.*; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.kit.Perk; +import java.util.HashMap; +import java.util.Iterator; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -25,8 +17,25 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.ItemStack; -import java.util.HashMap; -import java.util.Iterator; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.kit.Perk; public class PerkHorsePet extends Perk { @@ -53,39 +62,40 @@ public class PerkHorsePet extends Perk return; Manager.GetGame().CreatureAllowOverride = true; - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); Manager.GetGame().CreatureAllowOverride = false; - horse.setAdult(); - horse.setAgeLock(true); - horse.setColor(Color.BROWN); - horse.setStyle(Style.NONE); KitModifier kitModifier = getHorseType(player); + final Horse.Variant variant; if (kitModifier != null) { switch (getHorseType(player)) { case Survival_Games_Horseman_Mule: - horse.setVariant(Variant.MULE); + variant = Variant.MULE; break; case Survival_Games_Horseman_Skeleton_Horse: - horse.setVariant(Variant.SKELETON_HORSE); + variant = Variant.SKELETON_HORSE; break; case Survival_Games_Horseman_Zombie_Horse: - horse.setVariant(Variant.UNDEAD_HORSE); + variant = Variant.UNDEAD_HORSE; break; case Survival_Games_Horseman_Donkey: - horse.setVariant(Variant.DONKEY); + variant = Variant.DONKEY; break; default: - horse.setVariant(Variant.HORSE); + variant = Variant.HORSE; break; } } else { - horse.setVariant(Variant.HORSE); + variant = Variant.HORSE; } + Horse horse = UtilVariant.spawnHorse(player.getLocation(), variant); + horse.setAdult(); + horse.setAgeLock(true); + horse.setColor(Color.BROWN); + horse.setStyle(Style.NONE); horse.setOwner(player); horse.setMaxDomestication(1); horse.setJumpStrength(1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java index 4e7075481..af6651b66 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java @@ -1,18 +1,13 @@ package nautilus.game.arcade.kit.perks; -import mineplex.core.common.Rank; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguiseZombie; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + import net.minecraft.server.v1_8_R3.EntityCreature; import net.minecraft.server.v1_8_R3.NavigationAbstract; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -30,10 +25,23 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.disguise.disguises.DisguiseZombie; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; public class PerkSkeletons extends Perk { @@ -100,9 +108,47 @@ public class PerkSkeletons extends Perk Player killed = (Player) event.GetEvent().getEntity(); Manager.GetGame().CreatureAllowOverride = true; - Skeleton skel = killer.getWorld().spawn(killed.getLocation(), Skeleton.class); Manager.GetGame().CreatureAllowOverride = false; + + KitModifier kitModifier = getSkeletonType(killer); + final Skeleton.SkeletonType type; + if (kitModifier != null) + { + switch (kitModifier) + { + case Survival_Games_Necromancer_Wither_Skeleton: + type = Skeleton.SkeletonType.WITHER; + break; + case Survival_Games_Necromancer_Zombie: + type = Skeleton.SkeletonType.NORMAL; + break; + default: + type = Skeleton.SkeletonType.NORMAL; + break; + } + } + else + { + type = Skeleton.SkeletonType.NORMAL; + } + + final Skeleton skel; + if (type == Skeleton.SkeletonType.NORMAL) + { + skel = killer.getWorld().spawn(killed.getLocation(), Skeleton.class); + + } else + { + skel = UtilVariant.spawnWitherSkeleton(killed.getLocation()); + } + + if (kitModifier != null && kitModifier == KitModifier.Survival_Games_Necromancer_Zombie) + { + DisguiseZombie disguiseZombie = new DisguiseZombie(skel); + Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseZombie); + } + UtilEnt.removeGoalSelectors(skel); skel.setMaxHealth(30); @@ -126,29 +172,6 @@ public class PerkSkeletons extends Perk skel.getEquipment().setLeggingsDropChance(1f); skel.getEquipment().setBootsDropChance(1f); - KitModifier kitModifier = getSkeletonType(killer); - if (kitModifier != null) - { - switch (kitModifier) - { - case Survival_Games_Necromancer_Wither_Skeleton: - skel.setSkeletonType(Skeleton.SkeletonType.WITHER); - break; - case Survival_Games_Necromancer_Zombie: - skel.setSkeletonType(Skeleton.SkeletonType.NORMAL); - DisguiseZombie disguiseZombie = new DisguiseZombie(skel); - Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseZombie); - break; - default: - skel.setSkeletonType(Skeleton.SkeletonType.NORMAL); - break; - } - } - else - { - skel.setSkeletonType(Skeleton.SkeletonType.NORMAL); - } - if (_name) { skel.setCustomName("Skeletal " + UtilEnt.getName(event.GetEvent().getEntity())); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java index 4914d7264..065bfb462 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java @@ -1,8 +1,43 @@ package nautilus.game.arcade.kit.perks; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import net.minecraft.server.v1_8_R3.EntityCreature; +import net.minecraft.server.v1_8_R3.NavigationAbstract; + +import org.bukkit.DyeColor; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; + import mineplex.core.common.Rank; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguiseAnimalBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.SpigotUtil; +import mineplex.core.common.util.UtilAction; +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.disguise.disguises.DisguiseGuardian; import mineplex.core.disguise.disguises.DisguiseSquid; import mineplex.core.gadget.GadgetManager; @@ -12,28 +47,8 @@ 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 net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; -import org.bukkit.DyeColor; -import org.bukkit.EntityEffect; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf; -import org.bukkit.entity.*; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; +import nautilus.game.arcade.kit.Perk; public class PerkWolfPet extends Perk { @@ -382,8 +397,8 @@ public class PerkWolfPet extends Perk Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseSquid); return; } - DisguiseAnimalBase disguiseAnimal = new DisguiseAnimalBase(entityType, wolf); - Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseAnimal); + /*DisguiseAnimalBase disguiseAnimal = new DisguiseAnimalBase(entityType, wolf); // TODO: what does this even do? + Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseAnimal);*/ } } 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 efa539be2..d75c0f38f 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 @@ -6,6 +6,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.party.PartyManager; import mineplex.core.recharge.Recharge; @@ -16,6 +17,7 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; @@ -44,10 +46,13 @@ import java.util.ArrayList; public class GamePlayerManager implements Listener { ArcadeManager Manager; + + private static final int TEAMMATE_MESSAGE_DELAY = 40; + private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000; private static final int VIEW_DISTANCE_BLOCK_VALUE = 8; private long _lastVisibilityRefresh = 0; - + public GamePlayerManager(ArcadeManager manager) { Manager = manager; @@ -418,4 +423,54 @@ public class GamePlayerManager implements Listener player.teleport(target); } } + + @EventHandler + public void sendTeammateDetails(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + Game game = Manager.GetGame(); + + if (!game.ShowTeammateMessage || game.GetTeamList().size() == 1) + { + return; + } + + Manager.runSyncLater(() -> { + + for (Player player : game.GetPlayers(true)) + { + GameTeam team = game.GetTeam(player); + Player bestTeamMember = null; + + if (team == null) + { + continue; + } + + for (Player teamMember : team.GetPlayers(true)) + { + if (player.equals(teamMember)) + { + continue; + } + + bestTeamMember = teamMember; + } + + if (bestTeamMember == null) + { + UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player); + return; + } + + UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player); + } + + }, TEAMMATE_MESSAGE_DELAY); + } + } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index c7b572244..3aa7d7131 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -4,45 +4,69 @@ import java.util.EnumMap; import java.util.HashSet; import java.util.Iterator; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.gadget.gadgets.particle.unrelated.HalloweenSmashedEffect; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.reward.RewardPool; -import mineplex.core.reward.RewardRarity; -import mineplex.core.titangiveaway.TitanGiveawayManager; -import mineplex.core.treasure.TreasureType; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; -import org.bukkit.*; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.FireworkEffect; +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_8_R3.util.CraftMagicNumbers; +import org.bukkit.entity.Chicken; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.util.Vector; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.particleeffects.HalloweenSmashedEffect; +import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; +import mineplex.core.reward.RewardPool; +import mineplex.core.reward.RewardRarity; +import mineplex.core.treasure.TreasureType; +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.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.managers.events.SpecialEntityDeathEvent; + public class HolidayManager implements Listener { public enum HolidayType { - Christmas(Material.CHEST, "Present", Sound.CAT_MEOW), - Halloween(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY), - Easter(Material.CHEST, "Egg Basket", Sound.CAT_MEOW); + CHRISTMAS(Material.CHEST, "Present", Sound.CAT_MEOW), + HALLOWEEN(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY), + EASTER(Material.CHEST, "Egg Basket", Sound.CAT_MEOW), + THANKSGIVING(null, C.cGoldB + "Thanksgiving Chicken", null); private Material _blockType; private String _blockName; @@ -71,28 +95,31 @@ public class HolidayManager implements Listener } } - private HolidayType type = HolidayType.Halloween; - private String _statName = "Halloween 2016"; + private HolidayType _type = HolidayType.THANKSGIVING; + private String _statName = "Thanksgiving Chickens 2016"; - ArcadeManager Manager; + private ArcadeManager _arcadeManager; private TitanGiveawayManager _titanManager; - public HashSet _active = new HashSet(); + public HashSet _active = new HashSet<>(); + public HashSet _activeEntities = new HashSet<>(); - private HashSet _eggs = new HashSet(); + private HashSet _items = new HashSet<>(); - private HashSet _coins = new HashSet(); - private HashSet _gems = new HashSet(); + private HashSet _coins = new HashSet<>(); + private HashSet _gems = new HashSet<>(); private static final double CHEST_CHANCE = 0.001; + private static final double SPAWN_CHANCE = 0.01; + private static final double CHICKEN_DAMAGE = 0.5; public long _lastSpawn = System.currentTimeMillis(); private EnumMap _rewardPools; - public HolidayManager(ArcadeManager manager, TitanGiveawayManager titanManager) + public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager) { - Manager = manager; + _arcadeManager = arcadeManager; _titanManager = titanManager; _rewardPools = new EnumMap<>(RewardPool.Type.class); @@ -101,7 +128,7 @@ public class HolidayManager implements Listener _rewardPools.put(type, new RewardPool()); } - Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + _arcadeManager.getPluginManager().registerEvents(this, _arcadeManager.getPlugin()); } @EventHandler @@ -134,7 +161,7 @@ public class HolidayManager implements Listener continue; } - if (type == HolidayType.Halloween) + if (_type.equals(HolidayType.HALLOWEEN)) { UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4, ViewDist.LONG, UtilServer.getPlayers()); @@ -150,18 +177,18 @@ public class HolidayManager implements Listener } } } - else if (type == HolidayType.Easter) + else if (_type.equals(HolidayType.EASTER)) { UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, block.getLocation().add(0.5, 0.2, 0.5), 0.3f, 0.2f, 0.3f, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); if (Math.random() > 0.90) { - Item egg = block.getWorld().dropItem(block.getLocation().add(0.5, 0.8, 0.5), + Item egg = block.getWorld().dropItem(block.getLocation().add(0.5, 0.8, 0.5), ItemStackFactory.Instance.CreateStack(Material.EGG, (byte)0, 1, System.currentTimeMillis() + "Egg")); egg.setVelocity(new Vector((Math.random()-0.5)*0.3, Math.random()-0.4, (Math.random()-0.5)*0.3)); - _eggs.add(egg); + _items.add(egg); block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_EGG_POP, 0.25f + (float)Math.random() * 0.75f, 0.75f + (float)Math.random() * 0.5f); } @@ -171,12 +198,35 @@ public class HolidayManager implements Listener sendChestPackets(block); } } - else if (type == HolidayType.Christmas) + else if (_type.equals(HolidayType.CHRISTMAS)) { UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0, 3, ViewDist.LONG, UtilServer.getPlayers()); } } + + Iterator entityIterator = _activeEntities.iterator(); + + while (entityIterator.hasNext()) + { + org.bukkit.entity.Entity entity = entityIterator.next(); + + if (!(entity instanceof Chicken)) + { + specialEntityKill(null, entity); + entityIterator.remove(); + } + + if (_type.equals(HolidayType.THANKSGIVING)) + { + if (Math.random() > 0.90) + { + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, entity.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); + } + } + + } } @EventHandler @@ -185,25 +235,28 @@ public class HolidayManager implements Listener if (event.getType() != UpdateType.SEC) return; - if (Manager.GetGame() == null) + if (_arcadeManager.GetGame() == null) return; - if (Manager.GetGameHostManager().isPrivateServer()) + if (_arcadeManager.GetGameHostManager().isPrivateServer()) return; - Game game = Manager.GetGame(); + Game game = _arcadeManager.GetGame(); - int requirement = (int)((double)Manager.GetPlayerFull() * 0.5d); + int requirement = (int)((double) _arcadeManager.GetPlayerFull() * 0.5d); if (UtilServer.getPlayers().length < requirement) return; if (game.GetState() != GameState.Live) - return; + return; + + if (game.GetType().equals(GameType.UHC)) + return; if (!UtilTime.elapsed(_lastSpawn, 90000)) return; - if (Math.random() > 0.01) + if (Math.random() > SPAWN_CHANCE) return; int toDrop = Math.max(1, game.GetPlayers(false).size()/6); @@ -228,10 +281,26 @@ public class HolidayManager implements Listener return; } - block.setType(type.getBlockType()); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType()); + if (_type.getBlockType() == null && _type.equals(HolidayType.THANKSGIVING)) + { + // Spawns thanksgiving chicken + boolean oldValue = _arcadeManager.GetGame().CreatureAllowOverride; + _arcadeManager.GetGame().CreatureAllowOverride = true; + Chicken chicken = block.getWorld().spawn(block.getLocation().clone().add(.5, .5, .5), Chicken.class); + _arcadeManager.GetGame().CreatureAllowOverride = oldValue; + chicken.setAdult(); + chicken.setCustomName(_type.getBlockName()); + chicken.setCustomNameVisible(true); + chicken.setVelocity(chicken.getVelocity().multiply(15)); + block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_IDLE, 1f, 1f); + _activeEntities.add(chicken); + return; + } - if (type.getBlockType() == Material.CHEST) + block.setType(_type.getBlockType()); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _type.getBlockType()); + + if (_type.getBlockType() == Material.CHEST) { sendChestPackets(block); } @@ -299,12 +368,108 @@ public class HolidayManager implements Listener if (UtilPlayer.isSpectator(event.getPlayer())) return; - if (Manager.GetGame() != null && !Manager.GetGame().IsAlive(event.getPlayer())) + if (_arcadeManager.GetGame() != null && !_arcadeManager.GetGame().IsAlive(event.getPlayer())) return; specialBlockBreak(event.getPlayer(), event.getClickedBlock()); } + @EventHandler + public void specialEntityDeath(SpecialEntityDeathEvent event) + { + if (!_type.equals(HolidayType.THANKSGIVING)) + return; + + if (!(event.getEntity() instanceof Chicken)) + return; + + if (event.getKiller() == null) + return; + + Chicken chicken = (Chicken) event.getEntity(); + Player killer = event.getKiller(); + + if (_arcadeManager.GetGame() != null && !_arcadeManager.GetGame().IsAlive(killer)) + return; + + if (!_activeEntities.contains(chicken)) + return; + + _activeEntities.remove(chicken); + specialEntityKill(killer, chicken); + killer.getWorld().playSound(killer.getLocation(), Sound.CHICKEN_HURT, 1f, 1f); + } + + @EventHandler + public void specialEntityDamage(EntityDamageEvent event) + { + if (!(event.getEntity() instanceof Chicken)) + return; + + if (_arcadeManager.GetGame() == null) + return; + + Chicken chicken = (Chicken) event.getEntity(); + + if (!_activeEntities.contains(chicken)) + return; + + if (event.getCause().equals(EntityDamageEvent.DamageCause.VOID) || event.getCause().equals(EntityDamageEvent.DamageCause.LAVA) || + event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) + { + specialEntityKill(null, chicken); + _activeEntities.remove(chicken); + chicken.remove(); + } + + event.setCancelled(true); + } + + @EventHandler + public void specialEntityDamageByEntity(EntityDamageByEntityEvent event) + { + if (!(event.getEntity() instanceof Chicken)) + return; + + if (!(event.getDamager() instanceof Player)) + return; + + if (_arcadeManager.GetGame() == null) + return; + + if (UtilPlayer.isSpectator(event.getDamager())) + return; + + Chicken chicken = (Chicken) event.getEntity(); + + if (!_activeEntities.contains(chicken)) + return; + + if (chicken.getHealth() <= CHICKEN_DAMAGE) + { + SpecialEntityDeathEvent specialEntityDeathEvent = new SpecialEntityDeathEvent(chicken, (Player) event.getDamager()); + Bukkit.getPluginManager().callEvent(specialEntityDeathEvent); + chicken.remove(); + return; + } + + chicken.damage(CHICKEN_DAMAGE); + } + + @EventHandler + public void cancelSpecialEntityItemDrops(ItemSpawnEvent event) + { + Material material = event.getEntity().getItemStack().getType(); + if (material.equals(Material.FEATHER) || material.equals(Material.RAW_CHICKEN) || material.equals(Material.BONE)) + { + if (_items.contains(event.getEntity())) + return; + + event.getEntity().remove(); + event.setCancelled(true); + } + } + private void specialBlockBreak(Player player, final Block block) { if (!_active.contains(block)) @@ -312,12 +477,12 @@ public class HolidayManager implements Listener _active.remove(block); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType()); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _type.getBlockType()); block.setType(Material.AIR); - if (player != null && Manager.GetGame() != null) + if (player != null && _arcadeManager.GetGame() != null) { - Manager.GetGame().AddStat(player, _statName, 1, false, true); + _arcadeManager.GetGame().AddStat(player, _statName, 1, false, true); System.out.println("Recording Pumpkin Break for " + player.getName()); } @@ -373,7 +538,7 @@ public class HolidayManager implements Listener if (player != null) { - InventoryManager manager = Manager.getInventoryManager(); + InventoryManager manager = _arcadeManager.getInventoryManager(); double rand = UtilMath.random.nextDouble(); if (rand < CHEST_CHANCE) { @@ -384,7 +549,7 @@ public class HolidayManager implements Listener .withFade(Color.BLACK).flicker(true).build(); manager.addItemToInventory(player, "Haunted Chest", 1); HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation() - .add(.5, .5, .5), fireworkEffect, Manager.getPlugin()); + .add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin()); halloweenSmashedEffect.start(); } else @@ -394,14 +559,60 @@ public class HolidayManager implements Listener .withFade(Color.BLACK).flicker(true).build(); manager.addItemToInventory(player, "Omega Chest", 1); HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation() - .add(.5, .5, .5), fireworkEffect, Manager.getPlugin()); + .add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin()); halloweenSmashedEffect.start(); } } } //Effect - block.getWorld().playSound(block.getLocation(), type.getBlockSound(), 1f, 1f); + block.getWorld().playSound(block.getLocation(), _type.getBlockSound(), 1f, 1f); + } + + private void specialEntityKill(Player player, org.bukkit.entity.Entity entity) + { + if (player != null && _arcadeManager.GetGame() != null) + { + _arcadeManager.GetGame().AddStat(player, _statName, 1, false, true); + System.out.println("Recording Entity Killong for " + player.getName()); + } + + //Coins + for (int i=0 ; i < 4 + Math.random()*8 ; i++) + { + Item coin = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5), + ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte)0, 1, UtilMath.r(999999) + "Coin")); + + Vector vel = new Vector( + (Math.random() - 0.5) * 0.5, + 0.1 + Math.random() * 0.3, + (Math.random() - 0.5) * 0.5); + + coin.setVelocity(vel); + + coin.setPickupDelay(20); + + _coins.add(coin); + } + + //Gems + for (int i=0 ; i < 4 + Math.random()*8 ; i++) + { + Item gem = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5), + ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte)0, 1, UtilMath.r(999999) + "Gem")); + + Vector vel = new Vector( + (Math.random() - 0.5) * 0.5, + 0.1 + Math.random() * 0.3, + (Math.random() - 0.5) * 0.5); + + gem.setVelocity(vel); + + gem.setPickupDelay(20); + + _gems.add(gem); + } + } @EventHandler @@ -415,7 +626,7 @@ public class HolidayManager implements Listener event.setCancelled(true); event.getItem().remove(); - Manager.GetDonation().RewardCoinsLater(type + " Coins", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); + _arcadeManager.GetDonation().RewardCoinsLater(_type + " Coins", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f); } @@ -424,12 +635,12 @@ public class HolidayManager implements Listener event.setCancelled(true); event.getItem().remove(); - Manager.GetDonation().RewardGemsLater(type + " Gems", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); + _arcadeManager.GetDonation().RewardGemsLater(_type + " Gems", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f); } - else if (_eggs.contains(event.getItem())) + else if (_items.contains(event.getItem())) { event.setCancelled(true); } @@ -467,7 +678,7 @@ public class HolidayManager implements Listener } } - Iterator eggIterator = _eggs.iterator(); + Iterator eggIterator = _items.iterator(); while (eggIterator.hasNext()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/events/SpecialEntityDeathEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/events/SpecialEntityDeathEvent.java new file mode 100644 index 000000000..8f9a142c4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/events/SpecialEntityDeathEvent.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.managers.events; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class SpecialEntityDeathEvent extends Event +{ + + private static final HandlerList handlers = new HandlerList(); + + private Entity _entity; + private Player _killer; + + public SpecialEntityDeathEvent(Entity entity, Player killer) + { + _entity = entity; + _killer = killer; + } + + public Entity getEntity() + { + return _entity; + } + + public Player getKiller() + { + return _killer; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} diff --git a/Plugins/pom.xml b/Plugins/pom.xml index 905d6e24b..81118c0bf 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -29,6 +29,7 @@ Mineplex.Hub Mineplex.Hub.Clans Mineplex.MapParser + Mineplex.ClansGenerator Mineplex.Minecraft.Game.ClassCombat Mineplex.Minecraft.Game.Core Mineplex.ServerData