Merge remote-tracking branch 'refs/remotes/origin/develop' into update/uhc-moppletop
This commit is contained in:
commit
142cf4dd93
4
Plugins/Mineplex.ClansGenerator/plugin.yml
Normal file
4
Plugins/Mineplex.ClansGenerator/plugin.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: ClansGenerator
|
||||
main: mineplex.clansgenerator.ClansGenerator
|
||||
version: 1.0
|
||||
author: Alex
|
23
Plugins/Mineplex.ClansGenerator/pom.xml
Normal file
23
Plugins/Mineplex.ClansGenerator/pom.xml
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>mineplex-plugin</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<relativePath>../plugin.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>ClansGenerator</name>
|
||||
<artifactId>mineplex-clansgenerator</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mineplex-core-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -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();
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -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}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,13 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
=======
|
||||
import net.minecraft.server.v1_8_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_8_R3.NBTTagLong;
|
||||
|
||||
>>>>>>> refs/remotes/origin/develop
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -24,8 +30,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
|
||||
{
|
||||
@ -1218,6 +1222,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<String> 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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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"},
|
||||
|
@ -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<Block, BlockRestoreData> _blocks = new HashMap<Block, BlockRestoreData>();
|
||||
@ -98,6 +100,21 @@ public class BlockRestore extends MiniPlugin
|
||||
for (Block cur : toRemove)
|
||||
_blocks.remove(cur);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void expireUnload(ChunkUnloadEvent event)
|
||||
{
|
||||
Iterator<Entry<Block, BlockRestoreData>> iterator = _blocks.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entry<Block, BlockRestoreData> entry = iterator.next();
|
||||
if (entry.getKey().getChunk().equals(event.getChunk()))
|
||||
{
|
||||
entry.getValue().restore();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean restore(Block block)
|
||||
{
|
||||
|
@ -677,8 +677,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> 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++;
|
||||
@ -839,7 +839,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> 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()))
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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") + "!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 + "=============================================");
|
||||
}
|
||||
|
@ -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<SnapshotMessage> getMessagesInvolving(int accountId, Collection<Integer> pmIdWhitelist)
|
||||
public Set<SnapshotMessage> getMessagesInvolving(int accountId, Collection<Integer> 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<Integer> pmExclusions)
|
||||
private boolean includeMessage(SnapshotMessage message, Collection<Integer> 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<SnapshotMetadata> saveReportSnapshot(Report report, Collection<SnapshotMessage> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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<SnapshotMetadata> saveReportSnapshot(Report report, Collection<SnapshotMessage> 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<SnapshotMetadata> saveSnapshot(Collection<SnapshotMessage> 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<SnapshotMetadata> 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<List<Integer>> getUserSnapshots(int creatorId)
|
||||
{
|
||||
CompletableFuture<List<Integer>> 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<Integer> 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<SnapshotMessage> messages, Connection connection) throws SQLException
|
||||
public CompletableFuture<Void> insertMessages(int snapshotId, Collection<SnapshotMessage> 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<Void> insertMessage(int snapshotId, SnapshotMessage message)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
CompletableFuture<Void> 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
|
||||
|
@ -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<SnapshotPlugin>
|
||||
{
|
||||
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<SnapshotMessage> 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)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.chatsnap.command;
|
||||
package mineplex.core.chatsnap.redis;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -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())
|
||||
{
|
@ -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<String, ICommand> Commands;
|
||||
private final List<String> 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<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
package mineplex.core.cosmetic.ui;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import mineplex.core.pet.Pet;
|
||||
|
||||
public class PetSorter implements Comparator<Pet>
|
||||
{
|
||||
public int compare(Pet a, Pet b)
|
||||
{
|
||||
if (a.getPetType().getTypeId() < b.getPetType().getTypeId())
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -53,7 +53,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
|
||||
slot++;
|
||||
|
||||
if (slot == 26 || slot == 35)
|
||||
if (slot == 17 || slot == 26)
|
||||
slot += 2;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -29,7 +29,7 @@ public class HatPage extends GadgetPage
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int slot = 19;
|
||||
int slot = 10;
|
||||
|
||||
List<Gadget> 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()
|
||||
|
@ -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<CosmeticManager, CosmeticShop>
|
||||
|
||||
int petOwned = 0;
|
||||
int petMax = 0;
|
||||
for (Pet pet : getPlugin().getPetManager().getFactory().GetPets())
|
||||
for (PetType type : PetType.values())
|
||||
{
|
||||
Map<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
|
||||
if (pets != null && pets.containsKey(pet.getPetType()))
|
||||
Map<PetType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
|
||||
if (pets != null && pets.containsKey(type))
|
||||
{
|
||||
petOwned++;
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -39,15 +39,15 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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<CosmeticManager, CosmeticShop>
|
||||
|
||||
protected void buildPage()
|
||||
{
|
||||
int slot = 19;
|
||||
|
||||
List<Pet> pets = new ArrayList<Pet>(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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
|
||||
//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<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
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<String> itemLore = new ArrayList<String>();
|
||||
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
|| 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<CosmeticManager, CosmeticShop>
|
||||
});
|
||||
}
|
||||
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
getPlugin().getPetManager().removePet(player, true);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
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<CosmeticManager, CosmeticShop>
|
||||
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()));
|
||||
|
@ -29,7 +29,7 @@ public class TauntPage extends GadgetPage
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int slot = 19;
|
||||
int slot = 10;
|
||||
|
||||
List<Gadget> 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()
|
||||
|
@ -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()
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityAgeable;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public abstract class DisguiseAgeable extends DisguiseCreature
|
||||
{
|
||||
public DisguiseAgeable(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseAgeable(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
public abstract class DisguiseAmbient extends DisguiseInsentient
|
||||
{
|
||||
public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entityType, entity, clazz);
|
||||
super(entityType, entity);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public abstract class DisguiseAnimal extends DisguiseAgeable
|
||||
{
|
||||
public DisguiseAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import org.bukkit.entity.EntityType;
|
||||
public class DisguiseAnimalBase extends DisguiseAnimal
|
||||
{
|
||||
|
||||
public DisguiseAnimalBase(EntityType entityType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseAnimalBase(EntityType entityType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entityType, entity, clazz);
|
||||
super(entityType, entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class DisguiseArmorStand extends DisguiseInsentient
|
||||
{
|
||||
public DisguiseArmorStand(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.ARMOR_STAND, entity, EntityArmorStand.class);
|
||||
super(EntityType.ARMOR_STAND, entity);
|
||||
|
||||
DataWatcher.a(10, (byte) 0, EntityArmorStand.META_ARMOR_OPTION, (byte) 0);
|
||||
|
||||
|
@ -1,13 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.common.DummyEntity;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher;
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
@ -18,17 +12,18 @@ import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_8_R3.WorldServer;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DisguiseBase
|
||||
{
|
||||
private final Map<Class<? extends net.minecraft.server.v1_8_R3.Entity>,net.minecraft.server.v1_8_R3.Entity> dummyEntities = new HashMap<>();
|
||||
private WeakReference<Entity> _entity = new WeakReference<>(null);
|
||||
|
||||
protected DataWatcher DataWatcher;
|
||||
@ -42,7 +37,7 @@ public abstract class DisguiseBase
|
||||
*/
|
||||
private boolean _hideIfNotDisguised = false;
|
||||
|
||||
public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> entityClazz)
|
||||
public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
@ -53,18 +48,7 @@ public abstract class DisguiseBase
|
||||
|
||||
setEntity(entity);
|
||||
|
||||
DataWatcher = new DataWatcher(dummyEntities.computeIfAbsent(entityClazz, clazz ->
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor<? extends net.minecraft.server.v1_8_R3.Entity> constructor = clazz.getDeclaredConstructor(net.minecraft.server.v1_8_R3.World.class);
|
||||
return constructor.newInstance((net.minecraft.server.v1_8_R3.World)null);
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
DataWatcher = new DataWatcher(new DummyEntity(null));
|
||||
|
||||
DataWatcher.a(0, (byte) 0, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0);
|
||||
DataWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 300);
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseBat extends DisguiseCreature
|
||||
{
|
||||
public DisguiseBat(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.BAT, entity, EntityBat.class);
|
||||
super(EntityType.BAT, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 0), EntityBat.META_UPSIDEDOWN, (byte) 0);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseBlaze extends DisguiseMonster
|
||||
{
|
||||
public DisguiseBlaze(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.BLAZE, entity, EntityBlaze.class);
|
||||
super(EntityType.BLAZE, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 0), EntityBlaze.META_FIRE, (byte) 0);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityFallingBlock;
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
|
||||
@ -17,7 +16,7 @@ public class DisguiseBlock extends DisguiseBase
|
||||
|
||||
public DisguiseBlock(org.bukkit.entity.Entity entity, int blockId, int blockData)
|
||||
{
|
||||
super(EntityType.FALLING_BLOCK, entity, EntityFallingBlock.class);
|
||||
super(EntityType.FALLING_BLOCK, entity);
|
||||
|
||||
_blockId = blockId;
|
||||
_blockData = blockData;
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseCat extends DisguiseTameableAnimal
|
||||
{
|
||||
public DisguiseCat(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.OCELOT, entity, EntityOcelot.class);
|
||||
super(EntityType.OCELOT, entity);
|
||||
|
||||
DataWatcher.a(18, Byte.valueOf((byte) 0), EntityOcelot.META_TYPE, 0);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityCaveSpider;
|
||||
import net.minecraft.server.v1_8_R3.EntitySpider;
|
||||
|
||||
public class DisguiseCaveSpider extends DisguiseMonster
|
||||
@ -10,7 +9,7 @@ public class DisguiseCaveSpider extends DisguiseMonster
|
||||
|
||||
public DisguiseCaveSpider(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.CAVE_SPIDER, entity, EntityCaveSpider.class);
|
||||
super(EntityType.CAVE_SPIDER, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0);
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityChicken;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseChicken extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseChicken(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.CHICKEN, entity, EntityChicken.class);
|
||||
super(EntityType.CHICKEN, entity);
|
||||
}
|
||||
|
||||
public String getHurtSound()
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityCow;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseCow extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseCow(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.COW, entity, EntityCow.class);
|
||||
super(EntityType.COW, entity);
|
||||
}
|
||||
|
||||
public String getHurtSound()
|
||||
|
@ -3,14 +3,13 @@ package mineplex.core.disguise.disguises;
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public abstract class DisguiseCreature extends DisguiseInsentient
|
||||
{
|
||||
public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> entityClazz)
|
||||
public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, entityClazz);
|
||||
super(disguiseType, entity);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseCreeper extends DisguiseMonster
|
||||
{
|
||||
public DisguiseCreeper(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.CREEPER, entity, EntityCreeper.class);
|
||||
super(EntityType.CREEPER, entity);
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte) -1), EntityCreeper.META_FUSE_STATE, -1);
|
||||
DataWatcher.a(17, Byte.valueOf((byte) 0), EntityCreeper.META_POWERED, false);
|
||||
|
@ -19,7 +19,7 @@ public class DisguiseEnderman extends DisguiseMonster
|
||||
{
|
||||
public DisguiseEnderman(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.ENDERMAN, entity, EntityEnderman.class);
|
||||
super(EntityType.ENDERMAN, entity);
|
||||
|
||||
DataWatcher.a(16, new Short((short) 0), EntityEnderman.META_BLOCK, Optional.<IBlockData> absent());
|
||||
DataWatcher.a(17, new Byte((byte) 0), EntityEnderman.META_BLOCK, Optional.<IBlockData> absent());
|
||||
|
@ -1,11 +1,11 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public abstract class DisguiseGolem extends DisguiseCreature
|
||||
{
|
||||
public DisguiseGolem(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseGolem(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityGuardian;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import net.minecraft.server.v1_8_R3.EntityGuardian;
|
||||
|
||||
public class DisguiseGuardian extends DisguiseCreature
|
||||
{
|
||||
public DisguiseGuardian(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.GUARDIAN, entity, EntityGuardian.class);
|
||||
super(EntityType.GUARDIAN, entity);
|
||||
DataWatcher.a(16, 0, EntityGuardian.META_ELDER, (byte) 0);
|
||||
DataWatcher.a(17, 0, EntityGuardian.META_TARGET, 0);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class DisguiseHorse extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseHorse(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.HORSE, entity, EntityHorse.class);
|
||||
super(EntityType.HORSE, entity);
|
||||
|
||||
DataWatcher.a(16, Integer.valueOf(0), EntityHorse.META_HORSE_STATE, (byte) 0);
|
||||
DataWatcher.a(19, Byte.valueOf((byte) 0), EntityHorse.META_TYPE, 0);
|
||||
|
@ -3,13 +3,11 @@ package mineplex.core.disguise.disguises;
|
||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import mineplex.core.common.DummyEntity;
|
||||
|
||||
public abstract class DisguiseHuman extends DisguiseLiving
|
||||
{
|
||||
public DisguiseHuman(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, DummyEntity.class);
|
||||
super(disguiseType, entity);
|
||||
|
||||
byte skin = 0;
|
||||
skin |= (1 << 0); //Enable Cape
|
||||
|
@ -1,19 +1,18 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import mineplex.core.common.*;
|
||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
{
|
||||
private boolean _showArmor;
|
||||
|
||||
public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(3, Byte.valueOf((byte) 0), EntityInsentient.META_CUSTOMNAME_VISIBLE, false);
|
||||
DataWatcher.a(2, "", EntityInsentient.META_CUSTOMNAME, "");
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseIronGolem extends DisguiseGolem
|
||||
{
|
||||
public DisguiseIronGolem(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.IRON_GOLEM, entity, EntityIronGolem.class);
|
||||
super(EntityType.IRON_GOLEM, entity);
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte) 0), EntityIronGolem.META_PLAYER_CREATED, (byte) 0);
|
||||
}
|
||||
|
@ -3,24 +3,24 @@ package mineplex.core.disguise.disguises;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityLiving;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityLiving;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
||||
|
||||
public abstract class DisguiseLiving extends DisguiseBase
|
||||
{
|
||||
private static Random _random = new Random();
|
||||
private boolean _invisible;
|
||||
private ItemStack[] _equipment = new ItemStack[5];
|
||||
|
||||
public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(6, Float.valueOf(1.0F), EntityLiving.META_HEALTH, 1F);
|
||||
DataWatcher.a(7, Integer.valueOf(0), EntityLiving.META_POTION_COLOR, 0);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityMagmaCube;
|
||||
import net.minecraft.server.v1_8_R3.EntitySlime;
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
@ -11,7 +10,7 @@ public class DisguiseMagmaCube extends DisguiseInsentient
|
||||
{
|
||||
public DisguiseMagmaCube(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.MAGMA_CUBE, entity, EntityMagmaCube.class);
|
||||
super(EntityType.MAGMA_CUBE, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import org.bukkit.entity.*;
|
||||
|
||||
public abstract class DisguiseMonster extends DisguiseCreature
|
||||
{
|
||||
public DisguiseMonster(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseMonster(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityMushroomCow;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseMooshroom extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseMooshroom(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.MUSHROOM_COW, entity, EntityMushroomCow.class);
|
||||
super(EntityType.MUSHROOM_COW, entity);
|
||||
}
|
||||
|
||||
public String getHurtSound()
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityPig;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguisePig extends DisguiseAnimal
|
||||
{
|
||||
public DisguisePig(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.PIG, entity, EntityPig.class);
|
||||
super(EntityType.PIG, entity);
|
||||
}
|
||||
|
||||
public String getHurtSound()
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityPigZombie;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguisePigZombie extends DisguiseZombie
|
||||
{
|
||||
public DisguisePigZombie(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.PIG_ZOMBIE, entity, EntityPigZombie.class);
|
||||
super(EntityType.PIG_ZOMBIE, entity);
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
|
@ -1,18 +1,18 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityRabbit;
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class DisguiseRabbit extends DisguiseAnimal
|
||||
{
|
||||
|
||||
public DisguiseRabbit(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.RABBIT, entity, EntityRabbit.class);
|
||||
super(EntityType.RABBIT, entity);
|
||||
|
||||
DataWatcher.a(18, Byte.valueOf((byte) 0), EntityRabbit.META_TYPE, 0);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class DisguiseSheep extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseSheep(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.SHEEP, entity, EntitySheep.class);
|
||||
super(EntityType.SHEEP, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 0), EntitySheep.META_WOOL_STATE, (byte) 0);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class DisguiseSkeleton extends DisguiseMonster
|
||||
{
|
||||
public DisguiseSkeleton(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.SKELETON, entity, EntitySkeleton.class);
|
||||
super(EntityType.SKELETON, entity);
|
||||
|
||||
DataWatcher.a(13, Byte.valueOf((byte) 0), EntitySkeleton.META_TYPE, 0);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class DisguiseSlime extends DisguiseInsentient
|
||||
{
|
||||
public DisguiseSlime(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.SLIME, entity, EntitySlime.class);
|
||||
super(EntityType.SLIME, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1);
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntitySnowman;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseSnowman extends DisguiseGolem
|
||||
{
|
||||
public DisguiseSnowman(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.SNOWMAN, entity, EntitySnowman.class);
|
||||
super(EntityType.SNOWMAN, entity);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseSpider extends DisguiseMonster
|
||||
{
|
||||
public DisguiseSpider(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.SPIDER, entity, EntitySpider.class);
|
||||
super(EntityType.SPIDER, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0);
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntitySquid;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseSquid extends DisguiseMonster
|
||||
{
|
||||
public DisguiseSquid(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.SQUID, entity, EntitySquid.class);
|
||||
super(EntityType.SQUID, entity);
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
|
@ -10,9 +10,9 @@ import com.google.common.base.Optional;
|
||||
|
||||
public abstract class DisguiseTameableAnimal extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte) 0), EntityTameableAnimal.META_SITTING_TAMED, (byte) 0);
|
||||
DataWatcher.a(17, "", EntityTameableAnimal.META_OWNER, Optional.<UUID> absent());
|
||||
|
@ -1,15 +1,12 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityVillager;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseVillager extends DisguiseAgeable
|
||||
{
|
||||
public DisguiseVillager(Entity entity)
|
||||
{
|
||||
super(EntityType.VILLAGER, entity, EntityVillager.class);
|
||||
super(EntityType.VILLAGER, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseWitch extends DisguiseMonster
|
||||
{
|
||||
public DisguiseWitch(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.WITCH, entity, EntityWitch.class);
|
||||
super(EntityType.WITCH, entity);
|
||||
|
||||
DataWatcher.a(21, Byte.valueOf((byte) 0), EntityWitch.META_AGGRESSIVE, false);
|
||||
}
|
||||
|
@ -3,12 +3,15 @@ package mineplex.core.disguise.disguises;
|
||||
import net.minecraft.server.v1_8_R3.EntityWither;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
public class DisguiseWither extends DisguiseMonster
|
||||
{
|
||||
public DisguiseWither(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.WITHER, entity, EntityWither.class);
|
||||
super(EntityType.WITHER, entity);
|
||||
|
||||
DataWatcher.a(17, new Integer(0), EntityWither.META_INVUL_TIME, 0);
|
||||
DataWatcher.a(18, new Integer(0), EntityWither.META_TARGET_1, 0);
|
||||
|
@ -8,7 +8,7 @@ public class DisguiseWolf extends DisguiseTameableAnimal
|
||||
{
|
||||
public DisguiseWolf(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.WOLF, entity, EntityWolf.class);
|
||||
super(EntityType.WOLF, entity);
|
||||
|
||||
DataWatcher.a(18, new Float(20F), EntityWolf.META_WOLF_HEALTH, 20F);
|
||||
DataWatcher.a(19, new Byte((byte) 0), EntityWolf.META_BEGGING, false);
|
||||
|
@ -8,12 +8,12 @@ public class DisguiseZombie extends DisguiseMonster
|
||||
{
|
||||
public DisguiseZombie(Entity entity)
|
||||
{
|
||||
this(EntityType.ZOMBIE, entity, EntityZombie.class);
|
||||
this(EntityType.ZOMBIE, entity);
|
||||
}
|
||||
|
||||
public DisguiseZombie(EntityType disguiseType, Entity entity, Class<? extends net.minecraft.server.v1_8_R3.Entity> clazz)
|
||||
public DisguiseZombie(EntityType disguiseType, Entity entity)
|
||||
{
|
||||
super(disguiseType, entity, clazz);
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(12, Byte.valueOf((byte) 0), EntityZombie.META_CHILD, false);
|
||||
DataWatcher.a(13, Byte.valueOf((byte) 0), EntityZombie.META_VILLAGER, false);
|
||||
|
@ -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));
|
||||
|
@ -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<GadgetManager>
|
||||
{
|
||||
|
@ -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<GadgetManager>
|
||||
{
|
||||
@ -106,11 +106,10 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
@ -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<GadgetManager>
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<GadgetManager>
|
||||
{
|
||||
@ -111,11 +111,11 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<RewardData>()
|
||||
|
@ -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;
|
||||
|
@ -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<UUID, Integer> _playerColors = new HashMap<>();
|
||||
private Map<Player, Long> _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<Map.Entry<Player, Long>> iterator = _flying.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Map.Entry<Player, Long> 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))
|
||||
|
@ -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<Item, SantaPresent> _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<Item> 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);
|
||||
}
|
||||
}
|
@ -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<Player, Sleigh> _sleighs = new HashMap<>();
|
||||
private Map<SleighDirection, Schematic> _schematics = new HashMap<>();
|
||||
|
||||
private List<SleighPosition> _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<SleighPosition> 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<Map.Entry<Player, Sleigh>> iterator = _sleighs.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Map.Entry<Player, Sleigh> entry = iterator.next();
|
||||
Sleigh sleigh = entry.getValue();
|
||||
if (!sleigh.update())
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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<Arrow> _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!"));
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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<Location, Material> _oldBlockMaterials = new HashMap<>();
|
||||
private Map<Location, Byte> _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<Location, Material> 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();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user