Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java
This commit is contained in:
Shaun Bennett 2016-09-03 00:57:22 -04:00
commit 17409d0bd2
142 changed files with 8932 additions and 1114 deletions

View File

@ -19,7 +19,33 @@
package com.java.sk89q.jnbt;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.NBTBase;
import net.minecraft.server.v1_8_R3.NBTTagByte;
import net.minecraft.server.v1_8_R3.NBTTagByteArray;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagDouble;
import net.minecraft.server.v1_8_R3.NBTTagEnd;
import net.minecraft.server.v1_8_R3.NBTTagFloat;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.NBTTagIntArray;
import net.minecraft.server.v1_8_R3.NBTTagList;
import net.minecraft.server.v1_8_R3.NBTTagLong;
import net.minecraft.server.v1_8_R3.NBTTagShort;
import net.minecraft.server.v1_8_R3.NBTTagString;
/**
* A class which contains NBT-related utility methods.
@ -166,5 +192,250 @@ public final class NBTUtils {
}
return expected.cast(tag);
}
public static byte[] toBytesCompressed(String name, CompoundTag tag)
{
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
try (NBTOutputStream nbtStream = new NBTOutputStream(new GZIPOutputStream(byteStream)))
{
nbtStream.writeNamedTag(name, tag);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
return byteStream.toByteArray();
}
public static NamedTag getFromBytesCompressed(byte[] bytes)
{
try (NBTInputStream stream = new NBTInputStream(new GZIPInputStream(new ByteArrayInputStream(bytes)));)
{
return stream.readNamedTag();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
public static NBTBase toNative(Tag tag) {
if (tag instanceof IntArrayTag) {
return toNative((IntArrayTag) tag);
} else if (tag instanceof ListTag) {
return toNative((ListTag) tag);
} else if (tag instanceof LongTag) {
return toNative((LongTag) tag);
} else if (tag instanceof StringTag) {
return toNative((StringTag) tag);
} else if (tag instanceof IntTag) {
return toNative((IntTag) tag);
} else if (tag instanceof ByteTag) {
return toNative((ByteTag) tag);
} else if (tag instanceof ByteArrayTag) {
return toNative((ByteArrayTag) tag);
} else if (tag instanceof CompoundTag) {
return toNative((CompoundTag) tag);
} else if (tag instanceof FloatTag) {
return toNative((FloatTag) tag);
} else if (tag instanceof ShortTag) {
return toNative((ShortTag) tag);
} else if (tag instanceof DoubleTag) {
return toNative((DoubleTag) tag);
} else {
throw new IllegalArgumentException("Can't convert tag of type " + tag.getClass().getCanonicalName());
}
}
public static NBTTagIntArray toNative(IntArrayTag tag) {
int[] value = tag.getValue();
return new NBTTagIntArray(Arrays.copyOf(value, value.length));
}
public static NBTTagList toNative(ListTag tag) {
NBTTagList list = new NBTTagList();
for (Tag child : tag.getValue()) {
if (child instanceof EndTag) {
continue;
}
list.add(toNative(child));
}
return list;
}
public static NBTTagLong toNative(LongTag tag) {
return new NBTTagLong(tag.getValue());
}
public static NBTTagString toNative(StringTag tag) {
return new NBTTagString(tag.getValue());
}
public static NBTTagInt toNative(IntTag tag) {
return new NBTTagInt(tag.getValue());
}
public static NBTTagByte toNative(ByteTag tag) {
return new NBTTagByte(tag.getValue());
}
public static NBTTagByteArray toNative(ByteArrayTag tag) {
byte[] value = tag.getValue();
return new NBTTagByteArray(Arrays.copyOf(value, value.length));
}
public static NBTTagCompound toNative(CompoundTag tag) {
NBTTagCompound compound = new NBTTagCompound();
for (Entry<String, Tag> child : tag.getValue().entrySet()) {
compound.set(child.getKey(), toNative(child.getValue()));
}
return compound;
}
public static NBTTagFloat toNative(FloatTag tag) {
return new NBTTagFloat(tag.getValue());
}
public static NBTTagShort toNative(ShortTag tag) {
return new NBTTagShort(tag.getValue());
}
public static NBTTagDouble toNative(DoubleTag tag) {
return new NBTTagDouble(tag.getValue());
}
public static Tag fromNative(NBTBase other) {
if (other instanceof NBTTagIntArray) {
return fromNative((NBTTagIntArray) other);
} else if (other instanceof NBTTagList) {
return fromNative((NBTTagList) other);
} else if (other instanceof NBTTagEnd) {
return fromNative((NBTTagEnd) other);
} else if (other instanceof NBTTagLong) {
return fromNative((NBTTagLong) other);
} else if (other instanceof NBTTagString) {
return fromNative((NBTTagString) other);
} else if (other instanceof NBTTagInt) {
return fromNative((NBTTagInt) other);
} else if (other instanceof NBTTagByte) {
return fromNative((NBTTagByte) other);
} else if (other instanceof NBTTagByteArray) {
return fromNative((NBTTagByteArray) other);
} else if (other instanceof NBTTagCompound) {
return fromNative((NBTTagCompound) other);
} else if (other instanceof NBTTagFloat) {
return fromNative((NBTTagFloat) other);
} else if (other instanceof NBTTagShort) {
return fromNative((NBTTagShort) other);
} else if (other instanceof NBTTagDouble) {
return fromNative((NBTTagDouble) other);
} else {
throw new IllegalArgumentException("Can't convert other of type " + other.getClass().getCanonicalName());
}
}
public static IntArrayTag fromNative(NBTTagIntArray other) {
int[] value = other.c();
return new IntArrayTag(Arrays.copyOf(value, value.length));
}
public static ListTag fromNative(NBTTagList other) {
other = (NBTTagList) other.clone();
List<Tag> list = new ArrayList<Tag>();
Class<? extends Tag> listClass = StringTag.class;
int size = other.size();
for (int i = 0; i < size; i++) {
Tag child = fromNative(other.a(0));
list.add(child);
listClass = child.getClass();
}
return new ListTag(listClass, list);
}
public static EndTag fromNative(NBTTagEnd other) {
return new EndTag();
}
public static LongTag fromNative(NBTTagLong other) {
return new LongTag(other.c());
}
public static StringTag fromNative(NBTTagString other) {
return new StringTag(other.a_());
}
public static IntTag fromNative(NBTTagInt other) {
return new IntTag(other.d());
}
public static ByteTag fromNative(NBTTagByte other) {
return new ByteTag(other.f());
}
public static ByteArrayTag fromNative(NBTTagByteArray other) {
byte[] value = other.c();
return new ByteArrayTag(Arrays.copyOf(value, value.length));
}
public static CompoundTag fromNative(NBTTagCompound other) {
@SuppressWarnings("unchecked") Collection<String> tags = other.c();
Map<String, Tag> map = new HashMap<String, Tag>();
for (String tagName : tags) {
map.put(tagName, fromNative(other.get(tagName)));
}
return new CompoundTag(map);
}
public static FloatTag fromNative(NBTTagFloat other) {
return new FloatTag(other.h());
}
public static ShortTag fromNative(NBTTagShort other) {
return new ShortTag(other.e());
}
public static DoubleTag fromNative(NBTTagDouble other) {
return new DoubleTag(other.g());
}
public static NBTTagList doubleArrayToList(double... doubles)
{
NBTTagList nbttaglist = new NBTTagList();
for(double d : doubles)
{
nbttaglist.add(new NBTTagDouble(d));
}
return nbttaglist;
}
public static Vector getVector(CompoundTag tag)
{
return new Vector(tag.asDouble("x"), tag.asDouble("y"), tag.asDouble("z"));
}
}

View File

@ -9,16 +9,20 @@ import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange.MultiBlockChangeInfo;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
/**
* An agent used to easily record and send multi-block update packets to players. The agent handles if the packet should be a
@ -85,13 +89,13 @@ public class MultiBlockUpdaterAgent
int chunkDist = Math.max(Math.abs(c.locX-x), Math.abs(c.locZ-z));
if(chunkDist > Bukkit.getViewDistance()) continue;
sendPacket(c, players);
sendPacket(c, p);
}
}
}
private void sendPacket(Chunk c, Collection<? extends Player> players)
private void sendPacket(Chunk c, Player...players)
{
List<BlockVector> list = _chunks.get(c);
@ -101,7 +105,7 @@ public class MultiBlockUpdaterAgent
{
for(Player p : players)
{
MapUtil.SendChunkForPlayer(c, p);
UtilPlayer.sendPacket(p, new PacketPlayOutMapChunk(c, true, 65535));
}
}
else
@ -121,6 +125,25 @@ public class MultiBlockUpdaterAgent
UtilPlayer.sendPacket(p, packet);
}
}
Packet<?>[] tileEntities = new Packet[c.tileEntities.size()];
int i = 0;
for(TileEntity te : c.tileEntities.values())
{
tileEntities[i++] = te.getUpdatePacket();
}
for(Player p : players)
{
UtilPlayer.sendPacket(p, tileEntities);
((WorldServer)c.world).getTracker().untrackPlayer(((CraftPlayer)p).getHandle());
}
Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () ->
{
for(Player p : players)
{
((WorldServer)c.world).getTracker().a(((CraftPlayer)p).getHandle(), c);
}
}, 5);
}
}

View File

@ -1,14 +1,34 @@
package mineplex.core.common.block.schematic;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import com.mysql.jdbc.Util;
import com.java.sk89q.jnbt.CompoundTag;
import com.java.sk89q.jnbt.DoubleTag;
import com.java.sk89q.jnbt.NBTUtils;
import com.java.sk89q.jnbt.Tag;
import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityTypes;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
public class Schematic
{
@ -18,8 +38,11 @@ public class Schematic
private final short[] _blocks;
private final byte[] _blockData;
private final Vector _weOffset;
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset)
private final Map<BlockVector, Map<String, Tag>> _tileEntities;
private final List<Tag> _entities;
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset, Map<BlockVector, Map<String, Tag>> tileEntities, List<Tag> entities)
{
_width = width;
_height = height;
@ -27,6 +50,18 @@ public class Schematic
_blocks = blocks;
_blockData = blockData;
_weOffset = worldEditOffset;
_tileEntities = tileEntities;
_entities = entities;
}
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset, Map<BlockVector, Map<String, Tag>> tileEntities)
{
this(width, height, length, blocks, blockData, worldEditOffset, tileEntities, new ArrayList<>());
}
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset)
{
this(width, height, length, blocks, blockData, worldEditOffset, new HashMap<>());
}
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData)
@ -34,29 +69,33 @@ public class Schematic
this(width, height, length, blocks, blockData, null);
}
public DataLocationMap paste(Location originLocation)
public SchematicData paste(Location originLocation)
{
return paste(originLocation, false);
}
public DataLocationMap paste(Location originLocation, boolean ignoreAir)
public SchematicData paste(Location originLocation, boolean ignoreAir)
{
return paste(originLocation, ignoreAir, false);
}
public DataLocationMap paste(Location originLocation, boolean ignoreAir, boolean worldEditOffset)
public SchematicData paste(Location originLocation, boolean ignoreAir, boolean worldEditOffset)
{
if(worldEditOffset && hasWorldEditOffset())
{
originLocation = originLocation.clone().add(_weOffset);
}
DataLocationMap locationMap = new DataLocationMap();
SchematicData output = new SchematicData(locationMap, originLocation.getWorld());
int startX = originLocation.getBlockX();
int startY = originLocation.getBlockY();
int startZ = originLocation.getBlockZ();
UtilBlock.startQuickRecording();
WorldServer nmsWorld = ((CraftWorld)originLocation.getWorld()).getHandle();
for (int x = 0; x < _width; x++)
{
@ -106,16 +145,63 @@ public class Schematic
continue;
}
}
UtilBlock.setQuick(originLocation.getWorld(), startX + x, startY + y, startZ + z, materialId, _blockData[index]);
BlockVector bv = new BlockVector(x,y,z);
output.getBlocksRaw().add(bv);
Map<String, Tag> map = _tileEntities.get(bv);
if(map != null)
{
TileEntity te = nmsWorld.getTileEntity(MapUtil.getBlockPos(bv.add(originLocation.toVector())));
if(te == null) continue;
CompoundTag weTag = new CompoundTag(map);
NBTTagCompound tag = NBTUtils.toNative(weTag);
tag.set("x", new NBTTagInt(tag.getInt("x") + startX));
tag.set("y", new NBTTagInt(tag.getInt("y") + startY));
tag.set("z", new NBTTagInt(tag.getInt("z") + startZ));
te.a(tag);
output.getTileEntitiesRaw().add(bv);
}
}
}
}
UtilBlock.stopQuickRecording();
for(Tag tag : _entities)
{
if(tag instanceof CompoundTag)
{
CompoundTag ctag = (CompoundTag) tag;
NBTTagCompound nmsTag = NBTUtils.toNative(ctag);
List<DoubleTag> list = ctag.getList("Pos", DoubleTag.class);
Vector pos = new Vector(list.get(0).getValue(), list.get(1).getValue(), list.get(2).getValue());
pos.add(originLocation.toVector());
UtilSchematic.setPosition(nmsTag, pos);
list = NBTUtils.fromNative(nmsTag).getList("Pos", DoubleTag.class);
Entity nmsEntity = EntityTypes.a(nmsTag, nmsWorld);
nmsWorld.addEntity(nmsEntity, SpawnReason.CUSTOM);
if(nmsEntity == null) continue;
output.getEntitiesRaw().add(nmsEntity.getBukkitEntity());
}
}
return locationMap;
return output;
}
/**
@ -174,6 +260,13 @@ public class Schematic
{
return _weOffset != null;
}
public Vector getWorldEditOffset()
{
if(!hasWorldEditOffset()) return null;
return _weOffset.clone();
}
public int getSize()
{
@ -187,7 +280,7 @@ public class Schematic
public boolean hasIndex(int index)
{
return index < _blocks.length;
return index < _blocks.length && index >= 0;
}
public Short getBlock(int x, int y, int z)
@ -240,6 +333,16 @@ public class Schematic
{
return _blockData;
}
public List<Tag> getEntities()
{
return _entities;
}
public Map<BlockVector, Map<String, Tag>> getTileEntities()
{
return _tileEntities;
}
@Override
public String toString()

View File

@ -0,0 +1,86 @@
package mineplex.core.common.block.schematic;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.util.BlockVector;
import mineplex.core.common.block.DataLocationMap;
/**
* Wrapper class for holding the output from pasting a schematic
*/
public class SchematicData
{
private final List<BlockVector> _blocks;
private final DataLocationMap _dataMap;
private final List<Entity> _entities;
private final List<BlockVector> _tileEntities;
private final World _world;
public SchematicData(DataLocationMap dataMap, World world)
{
_dataMap = dataMap;
_blocks = new ArrayList<>();
_tileEntities = new ArrayList<>();
_entities = new ArrayList<>();
_world = world;
}
/**
* @return Returns a list of blocks which has been edited by the schematic
*/
public List<BlockVector> getBlocks()
{
return new ArrayList<>(_blocks);
}
/**
* @return Returns the DataLocationMap which was utilized while pasting
*/
public DataLocationMap getDataLocationMap()
{
return _dataMap;
}
/**
* @return Returns a entities which was spawned by the schematic
*/
public List<Entity> getEntities()
{
return new ArrayList<>(_entities);
}
/**
* @return Returns a list of blocks who are tile entities which have been edited by the schematic. All the blocks in this list is also
* inside the {@link #getBlocks()} method
*/
public List<BlockVector> getTileEntities()
{
return new ArrayList<>(_tileEntities);
}
public World getWorld()
{
return _world;
}
List<BlockVector> getBlocksRaw()
{
return _blocks;
}
List<BlockVector> getTileEntitiesRaw()
{
return _tileEntities;
}
List<Entity> getEntitiesRaw()
{
return _entities;
}
}

View File

@ -1,27 +1,65 @@
package mineplex.core.common.block.schematic;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import com.java.sk89q.jnbt.ByteArrayTag;
import com.java.sk89q.jnbt.CompoundTag;
import com.java.sk89q.jnbt.IntTag;
import com.java.sk89q.jnbt.ListTag;
import com.java.sk89q.jnbt.NBTInputStream;
import com.java.sk89q.jnbt.NBTOutputStream;
import com.java.sk89q.jnbt.NBTUtils;
import com.java.sk89q.jnbt.NamedTag;
import com.java.sk89q.jnbt.ShortTag;
import com.java.sk89q.jnbt.StringTag;
import com.java.sk89q.jnbt.Tag;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
public class UtilSchematic
{
public static Schematic loadSchematic(File file) throws IOException
{
FileInputStream fis = new FileInputStream(file);
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(fis));
return loadSchematic(fis);
}
public static Schematic loadSchematic(byte[] bytes) throws IOException
{
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
return loadSchematic(bis);
}
public static Schematic loadSchematic(InputStream input) throws IOException
{
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(input));
NamedTag rootTag = nbtStream.readNamedTag();
nbtStream.close();
@ -35,9 +73,11 @@ public class UtilSchematic
short width = getChildTag(schematic, "Width", ShortTag.class).getValue();
short height = getChildTag(schematic, "Height", ShortTag.class).getValue();
short length = getChildTag(schematic, "Length", ShortTag.class).getValue();
byte[] blockId = getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
byte[] addId = new byte[0];
short[] blocks = new short[blockId.length];
short[] blocks = new short[blockId.length]; // Have to later combine IDs
byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
Vector weOffset = null;
@ -49,11 +89,14 @@ public class UtilSchematic
weOffset = new Vector(x, y, z);
}
// We support 4096 block IDs using the same method as vanilla Minecraft, where
// the highest 4 bits are stored in a separate byte array.
if (schematic.containsKey("AddBlocks"))
{
addId = getChildTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
}
// Combine the AddBlocks data with the first 8-bit block ID
for (int index = 0; index < blockId.length; index++)
{
if ((index >> 1) >= addId.length)
@ -66,9 +109,254 @@ public class UtilSchematic
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (blockId[index] & 0xFF));
}
}
// Need to pull out tile entities
List<Tag> tileEntities = getChildTag(schematic, "TileEntities", ListTag.class).getValue();
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
for (Tag tag : tileEntities)
{
if (!(tag instanceof CompoundTag)) {
continue;
}
CompoundTag t = (CompoundTag) tag;
int x = 0;
int y = 0;
int z = 0;
Map<String, Tag> values = new HashMap<>();
for (Map.Entry<String, Tag> entry : t.getValue().entrySet())
{
if (entry.getValue() instanceof IntTag)
{
if (entry.getKey().equals("x"))
{
x = ((IntTag) entry.getValue()).getValue();
} else if (entry.getKey().equals("y"))
{
y = ((IntTag) entry.getValue()).getValue();
} else if (entry.getKey().equals("z"))
{
z = ((IntTag) entry.getValue()).getValue();
}
}
values.put(entry.getKey(), entry.getValue());
}
BlockVector vec = new BlockVector(x, y, z);
tileEntitiesMap.put(vec, values);
}
List<Tag> entityTags = getChildTag(schematic, "Entities", ListTag.class).getValue();
return new Schematic(width, height, length, blocks, blockData, weOffset);
return new Schematic(width, height, length, blocks, blockData, weOffset, tileEntitiesMap, entityTags);
}
/**
* @param schematic The schematic you want to turn into bytes
* @return Returns a byte array of the schematic which may be used for saving the schematic to DB or file
*/
public static byte[] getBytes(Schematic schematic)
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
writeBytes(schematic, output);
return output.toByteArray();
}
/**
* @param schematic The scheamtic you want save somewhere
* @return Writes out this schematic on byte form
*/
public static void writeBytes(Schematic schematic, OutputStream output)
{
Map<String, Tag> map = new HashMap<>();
short width = schematic.getWidth();
short height = schematic.getHeight();
short length = schematic.getLength();
map.put("Width", new ShortTag(width));
map.put("Height", new ShortTag(height));
map.put("Length", new ShortTag(length));
if(schematic.hasWorldEditOffset())
{
Vector weOffset = schematic.getWorldEditOffset();
map.put("WEOffsetX", new IntTag(weOffset.getBlockX()));
map.put("WEOffsetY", new IntTag(weOffset.getBlockX()));
map.put("WEOffsetZ", new IntTag(weOffset.getBlockX()));
}
map.put("Materials", new StringTag("Alpha"));
short[] sBlocks = schematic.getBlocks();
Map<BlockVector, Map<String, Tag>> sTileEntities = schematic.getTileEntities();
byte[] blocks = new byte[sBlocks.length];
byte[] addBlocks = null;
byte[] blockData = schematic.getBlockData();
List<Tag> tileEntities = new ArrayList<Tag>();
for(int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
{
for(int z = 0; z < length; z++)
{
int index = y * width * length + z * width + x;
BlockVector bv = new BlockVector(x, y, z);
//Save 4096 IDs in an AddBlocks section
if(sBlocks[index] > 255)
{
if (addBlocks == null) { // Lazily create section
addBlocks = new byte[(blocks.length >> 1) + 1];
}
addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
addBlocks[index >> 1] & 0xF0 | (sBlocks[index] >> 8) & 0xF
: addBlocks[index >> 1] & 0xF | ((sBlocks[index] >> 8) & 0xF) << 4);
}
blocks[index] = (byte) sBlocks[index];
if(sTileEntities.get(bv) != null)
{
Map<String, Tag> values = new HashMap<>(sTileEntities.get(bv));
values.put("x", new IntTag(x));
values.put("y", new IntTag(y));
values.put("z", new IntTag(z));
CompoundTag tileEntityTag = new CompoundTag(values);
tileEntities.add(tileEntityTag);
}
}
}
}
map.put("Blocks", new ByteArrayTag(blocks));
map.put("Data", new ByteArrayTag(blockData));
map.put("TileEntities", new ListTag(CompoundTag.class, tileEntities));
if (addBlocks != null) {
map.put("AddBlocks", new ByteArrayTag(addBlocks));
}
// ====================================================================
// Entities
// ====================================================================
List<Tag> entities = schematic.getEntities();
map.put("Entities", new ListTag(CompoundTag.class, entities));
// ====================================================================
// Output
// ====================================================================
CompoundTag schematicTag = new CompoundTag(map);
try (NBTOutputStream outputStream = new NBTOutputStream(new GZIPOutputStream(output)))
{
outputStream.writeNamedTag("Schematic", schematicTag);
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static Schematic createSchematic(Location locA, Location locB)
{
return createSchematic(locA, locB, null);
}
public static Schematic createSchematic(Location locA, Location locB, Vector worldEditOffset)
{
World world = locA.getWorld();
Vector min = Vector.getMinimum(locA.toVector(), locB.toVector());
Vector max = Vector.getMaximum(locB.toVector(), locA.toVector());
short width = (short) (max.getBlockX()-min.getBlockX());
short height = (short) (max.getBlockY()-min.getBlockY());
short length = (short) (max.getBlockZ()-min.getBlockZ());
short[] blocks = new short[width*height*length];
byte[] blocksData = new byte[blocks.length];
WorldServer nmsWorld = ((CraftWorld)world).getHandle();
Map<BlockVector, Map<String, Tag>> tileEntities = new HashMap<>();
for(int x = min.getBlockX(); x < max.getBlockX(); x++)
{
for(int y = min.getBlockY(); y < max.getBlockY(); y++)
{
for(int z = min.getBlockZ(); z < max.getBlockZ(); z++)
{
int localX = x-min.getBlockX();
int localY = y-min.getBlockY();
int localZ = z-min.getBlockZ();
Block b = world.getBlockAt(x, y, z);
int index = localY * width * length + localZ * width + localX;
blocks[index] = (short) b.getTypeId();
blocksData[index] = b.getData();
BlockPosition bp = new BlockPosition(x, y, z);
TileEntity tileEntity = nmsWorld.getTileEntity(bp);
if(tileEntity == null) continue;
NBTTagCompound nmsTag = new NBTTagCompound();
tileEntity.b(nmsTag);
nmsTag.set("x", new NBTTagInt(localX));
nmsTag.set("y", new NBTTagInt(localY));
nmsTag.set("z", new NBTTagInt(localZ));
CompoundTag tag = NBTUtils.fromNative(nmsTag);
tileEntities.put(new BlockVector(localX, localY, localZ), tag.getValue());
}
}
}
List<Tag> entities = new ArrayList<>();
for(Entity e : world.getEntities())
{
if(e instanceof Player) continue;
if(e.getLocation().toVector().isInAABB(min, max))
{
net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity)e).getHandle();
NBTTagCompound nmsTag = new NBTTagCompound();
nmsEntity.c(nmsTag);
Vector diff = e.getLocation().subtract(min).toVector();
setPosition(nmsTag, diff);
nmsTag.remove("UUID");
nmsTag.remove("UUIDMost");
nmsTag.remove("UUIDLeast");
CompoundTag tag = NBTUtils.fromNative(nmsTag);
entities.add(tag);
}
}
return new Schematic(width, height, length, blocks, blocksData, worldEditOffset, tileEntities, entities);
}
@ -77,6 +365,11 @@ public class UtilSchematic
Tag tag = items.get(key);
return expected.cast(tag);
}
public static void setPosition(NBTTagCompound nbtTag, Vector pos)
{
nbtTag.set("Pos", NBTUtils.doubleArrayToList(pos.getX(), pos.getY(), pos.getZ()));
}
public static void main(String[] args) throws IOException
{

View File

@ -1,36 +1,22 @@
package mineplex.core.common.skin;
import java.lang.reflect.Field;
import java.util.Base64;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.authlib.minecraft.InsecureTextureException;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
import mineplex.core.common.util.UtilPlayer;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagList;
import net.minecraft.server.v1_8_R3.NBTTagString;
import org.bukkit.inventory.meta.SkullMeta;
public class SkinData
@ -69,6 +55,8 @@ public class SkinData
public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==", "NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6sVVOtHIoNA+S5q1Mb/Vjc3TJQxzqmx2FZOhJiIttFwYuo9WomQKBqrPMSJ9tpQig4wzoqldeeTjWC3dLz7JeX+gkzinryVjG7NNN9L5hXK5/BBxRcrtwmXJfUlSANyrd8RZW7mEUgU8yxlzdqTu0w7bZLjQNd4vciwoF3NelXDorMIIqiHTkuQesG91Njtu25VCUDK3nXbqEnZw2ZtxB5fT5G2Omm/vkNSRXc0P7iqchVowdYQcMlQUsp65xpkBbFS4LwjzDkYIfLmF++hePb8z72Gz77FxhO5sRLGreSH227McyL/0CtWNKm9ZZIfQtZZjEZTj9+eiJMCloCMg3yWa1VBOiLHzz0wY6gGklccIImPyXEg7E0dIK8qYseJMhmmBNZ8pDOkbUDp3mRlrQ2iyClgQkbuR63j79IBUaCxmsa3NnrAtaJklzd9mzkHXfMBh2XT7Gl8AhJS6JK5kCvip1rBBI8yjrsjE/E+lyJFIbC4rXxyMDGZWkcdrd7U4ZFYKiLHbzdFRqX+11qs9xO2BvomGXkATCzYmOf2kQ86R6rNN0+JfE4QpKzj2WWt3C8ky2qpuXZz29p0816E3/qseYtgg=");
public final static SkinData TEDDY_BEAR = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDkzOTE4MjYsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzQ0OTU4ZDdjNjlhZTQ4NGM2NWYzMTM0N2NkY2M5MmM2OWY1NDA2ODA1YjUzNjUyYTc1YThlZDc5OWRmNyJ9fX0=", "sNTRV9jTjLszUmyaqyEG7N8d5RM1jbwMSXi34S2EkVmIjWsowfSMnHRQqqgZfxcyqBM5I7MljtB84IeQWu4rqhyFrM9blWvtowjijFIOgKCs97q2sswv9iauU6ohvgTpgN5B0Q16MJmMIgZU8d8TATtEaIzq2eg6Ve1AJlNnW4huGNsoNfm8WdVU1tZmsYAwtVP/ryvhyj7mHyVF27m0Sm4fZRf/lHH5gEJYB4JHSAoEhjPIQOdkgRMJRrWGOfhhiGs3kEWmsRGfIPFo2ZJfcu+TFV2rd4Q+A1LmY8kimnzdKX3InXeKbk8qzcgqGNro4XFnSiHo1d6/B+N0JeYOTITYRQ6u24rNSUh5ezbG01iikVFCfrgb7UR6utoLK15F4/fmhpex+BJpmyZoXAqk08tZws/5wsIWQ1okrGcbBKWEHhw2ekUc82US21/W53vd657UBg7FuqM4FhkAqmsYPvYLMpNYxxmDJaI8uJyU7cnGFYyBaFlqUxfJUfcFTwWo10JO3yp5FjqeCQa7rFvfpsqw3w2mBpJmlZ5HRjfS5pmhk0QiY0TRfwZfFemkuZYnNbO82qLUm+6zTm0fbC90Swt8nNr/42ajzEoUjnL6VsERIXS5/fPwjftbQAC60ujy8yo66Sp3sSAALNg5zjM+Uizkq2f9Axc+kind22hp10M=");
public final static SkinData UNCLE_SAM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjYxODA0NjY4NTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYzM1YWRmZTQ3ODBjNmU2NTk4YTJlYzk2ZjdhZGQ5ZDc4NjljMjBlZjRmYjEyNjk2NmJhOGFlMDRlOWRhIn19fQ==", "NmJ+hXmvwQlYFYY7YVQWRr11yBbAfJP+jk11SQ91gUUtJJjb4v8RFbNu5UXNCKxYj3BPtldqshG1maNB0NWJRud7ZyAdHc0JMmR1vtHEge9Hhet4fLyyaZ9rZn4BvD9Guqgv9H/mZzUzrft9TIho0Qbu/U++lVsbZXC2GrJDDMyLnYr9C7f+FUnr0z4WvkNcg23SHBOYkOYT95NSdykIka3c3v+/HvSvuwOnMsfVxqLyCZLpo20vamBJ1uK1dmx2+TVGnUPlofFHRdOXOpJc+YmicJvrsQR6a9zlvnTbU4MYClMOKvjLe6aX5Af+n8Gw3oKcm0PuR8CPLyf9kjcmUF6XMiEXAWWJtCgvhCiFV5/mQQH3cQ1kqk4BDLUxMVhG5tzjKLoQQy39cFM32ee+QFjXlzy59meC8jgvPmOVU3GpJ32XWOtaXMCyeJrhz2QVKRLEr2KZgz8Pd8VrHARXVZsNYEasj8z0cHjgSJqTU9kD90CC+4YpvdyRBRqbNQig5KuGCqUHKgflsEsM7YrFRKP5As1LgqYQfqRAMmLSo47eW0onOwchC9wCqqisPlYSuDRt4Mun/KFGqYh1Sghn8/gzu49La8BpwlekjVEoPEcDaIIgnFzOvgmmgMANkoJ3PzhHoHMoXtObe3eSTi+eYp4qAQVzkTxfF3WXY2fui1M=");
public final static SkinData METAL_MAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0Njg3ODAyMzk2ODYsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9hNzc5YWEzYzk3OTc0Mzk1YTY3MTZkZmQ5MTI4YWM0N2E1MzdlMzljMzdmMGM0ZjZkZjQ1YjJmMGI4ZjVkMiJ9fX0=", "acwmrIdtzzkuntsvQqD+o9UYaI09xzQoPgRXFtvS1hvGgGRbApdG7YbQ3Itjg/8WUl0trAMMJa1IL8TlXaOwTeClOj6if3HW2lJ8yO7E+MXEJoDZcjkxVOK3322NRCBiPG+VbNCwHE7IvT8P4awExvV2nHLbCk7upawxK3oKfR5U+YEq/eLG/UCC1TAnHNLXE0mr+6ZtNut5qgz1u0Y+VNQKI/vdjVit1ttYeBjIWpSszhlP4bH8Iw3u3ZRuDqU4xSAWzj6Qhw9UYm2T3s2N9s2yW3wiagijUEq9stbaw97n3UCqBas58lTBy46w524lBvwbYC1U9jwxPxSUo6L6omhPKZSwgK/u2w4mELvfNI09A4C7RNThnz9wgrT0FPajjXYkt31Ba5qaP7HwcThQu02Bb3gmYfHfMvuDBt8xUk4lFyUuL+lwqUHXlKRkUPGVkDLDpmsnk+y4LvaymNHBBWpOyqpm8y1BTpux02GqCIgK7nHtsRNH3q3yHR1YyM0tc6PKXOst5ex1cGP654/Q0KEUSAvAV5ozj/q5izRlPJNiwu9zPqhfs8oWSBSo/Sfej6p7Fu9u0h0j/k0m86bfZObe2RsCEgBe8GSF35cyYRou0qTvk+00hEr+jpxeat0e9JHe163jI/Ew9XPeGd6eT8GTy4iyJM0O/y1MlsRjUec=");
public final static SkinData OMEGA_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzI1MTAzNzAwOTksInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS85MDM2MjNjMmRkMjdhNWM0Y2NlYzY5MWY3NjM0YTNkMzVkNTRiNDg0YjIzNTdhNWQ1ZWFmYmYwNTRkY2NlIn19fQ==", "cQty4zNF2QgzNuVOHTGGX5YVofApKr01KkQ70bO1n+I9nlkc9qqhcigA+uBYdw4THANFsTRwIrskgTS3TTmuaXYmMUoNnj7gr2Gp7D2t7L53QyJJhIw0hHNDvQucf19SOxhtR9FvW+xnh1JcgOTF3VZxIeRaN4bCtqkeFitCJwts4Z7SlDxB4EFZVsifM+gK4iel9YWYGNnZiQm48lxU+dMFd0cCa4L00ngBExQoWC8zbJc3K9LGdqI1YOMh3bCt81F4jcrPnDycxWwOTj/tBri4yeXK1htq5dAixHwq1EF86gQMnfeIIk6D/BREtVKoXK9K4lstYPHLFiBqkwpijArbC0sZp8s/j88NYUz9PgSJ2z/b5jhPChH2OkoGQOL0/QrxqUZUet+WHaIQtvFoqmcFRCKJQembgJGZV0X86XQxEEtevkNgXPigJVyQ5GVuDCeowRkMGfSadQCBsnmdOVZNshS60tBSDcbd2oWeQUJn1+OJkmz+OktbMbP4ttN6x3+MPMSZoGT1bc1BSRNFRYOBZuNz1zLWsHFRyNLaVS3ep/ktE+Rt5sbapo+r4GjrKGV7Unx6pbfoxcnMVxWZ9X/sMgztQdwYEQlnvAxGvCY/1ZIm3/izqB2zAgG7ZfWzKjU2P5VseKokMjHXrzZX9Uqtn0zpITEaG5HjUpRSaJg=");
// Comments this out for now, so it doesn't load the player profile
// A better way to do this would check for the properties when getting the skull or the skin
@ -78,11 +66,15 @@ public class SkinData
//public final static SkinData CHISS = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI5NjgyNDEsInByb2ZpbGVJZCI6IjFkMmJmZTYxN2ViZDQ0NWRiYTdkODM1NGEwZmZkMWVhIiwicHJvZmlsZU5hbWUiOiJDaGlzcyIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTg3MmNkMzRjY2IzMTIxYjRjNmEzOGFjM2JmOGVkM2UwMzk3YmQ2YTg4NDI4YjdhZmM2ZTUyNTI4NTVhMzQzIiwibWV0YWRhdGEiOnsibW9kZWwiOiJzbGltIn19fX0=", "hNTLRA2acZYx2dM90lnJN8FMK/ceD3+AxKNdD5FrXzxGtYL4C1Jr/vbTE0UosmwFP3wScNEW/fuDOjeZRjZHMJdvgDZMlMK/5KDhOY6sj/RS9RckztsgummSyjH/hdDn7TWWfhZLMbiia/K0VReI9eq2yD6zGQpvMlz5hB/5SX5YHWXvCah3TL4UzYSlSVDlwY/Q3sVuIZUr8m/LIXJwniJKLGo6tUgtiJd9eseOsbBpVjzCUtLD8A9WBe2/eODgmLfqEvXESIoDRG8vL2nPSXWma/YolYHIl32/i+ZxVD7dRRaXQFYSiLI24EtzX1pPhMjyaTLazP9abH43J6J31w02pKM7N/xTa62020L/YfRRKGT5lygEDb1NMoSpAjszPxah+Ra2/L+yUWEI8cMES6I4mIJ00tclPjWK01xhIn3tqg+y2gqsGHwPhu/7vmF5NirNfKFw0qciKNBfbCAF7ae+mkUKjmAPuvBUBqQb7BOcpNVWsCo/XvzmiZZYsf5P4Uwz8LqUK4uH6V/5dg7lY2Xg3+IUylsrDqLGFDI8iy/NdjIQMbuRadh4IDO6DcmxBri2Ax4JNBPBTnRezge8uq37MZcft/IXQgFWKB9RtidVEACaTOkRj27k+Ojnkki+j44k0wZB47hiXFUHMCHl3a0SVdQe15ZbVsQj/HAvAS0=");
//public final static SkinData DEFEK7 = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI3ODkwNTksInByb2ZpbGVJZCI6Ijg5ZDQ2M2Y3MjNlYzQ3MGE4MjQ0NDU3ZjBjOGQ4NjFjIiwicHJvZmlsZU5hbWUiOiJkZWZlazciLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2JmYWNjOWM4ZjhlY2E1OWU0NTE4MTUxZmE4OGFiMDZjOTFmNjM3OTE2NzJmMTRlNGYzODY3YTI2OTVlN2NmYmYifSwiQ0FQRSI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIyYjljNWVhNzYzYzg2ZmM1Y2FlYTMzZDgyYjBmYTY1YTdjMjI4ZmQzMjFiYTU0NzY2ZWE5NWEzZDBiOTc5MyJ9fX0=", "jBoRvkhQXz+nap8yJJIZ+4HClMItWODumeSOYjXytP3WWKHK0UMq0xC/keXsnmvo89lMRdRbknPt2ZX5Flgyjgr4Rt0KtDvpL/hG4BUsTWryUZZMKxdd6DkZXYRtTogLUfHeDYIz+cZQ0aXGMtvX/ZYTXJfMi6FYbIHY/qEEDnWhDX5y+SPpaJaZByPsvzi+qbfcFGnJ6nqi9ccyZYnYpnI2IVBM/yO/VRXWHxfqvJ0VVvv5KsGmVbko2Jxo0SDCxUL2UTH2+eol53FxhkkC+m2geC14k1zsZQLHDF3BgAG9+kFJ4UEoYRKF2Gy1FxeDCJtjYNdrYR8fdaUKRMcpBgEs+ZGe2U9EVVS/ZcBCjB7S+1Ne2bPzPFzTQPuBoMgggo1xbxBmQ5NyhYo4gwgj/xjSLIhb+5h7ioN1URfSRcfYdVv6RRO9l/u9l09jEom8y/jGRviefpEr+/e9iAl5Dd/6nzQgosBQja3NSfqYZmyuet2eI9zu61CObDTpR6yaCbNgBe/lWofRfULdpJpgjb4UNTBom3q82FcCiOe02OekGPw4+YlilhICBhajF5JzN8FKAdqI1osDcX3KuJgikYIW3voNaOP5YN3GXgilJNdou20KFC8ICq68HglgX7/0rLrWKIEoswnINIM6HcJbQuXncVPwQhV6K34Hlt/Na60=");
private Property _skinProperty;
private String _skinValue;
private String _skinSignature;
private Property _skinProperty = null;
public SkinData(String value, String signature)
{
_skinProperty = new Property("textures", value, signature);
_skinValue = value;
_skinSignature = signature;
//_skinProperty = new Property("textures", value, signature);
}
private SkinData(GameProfile profile)
@ -90,6 +82,11 @@ public class SkinData
_skinProperty = profile.getProperties().get("textures").iterator().next();
}
private void getSkinProperty()
{
_skinProperty = new Property("textures", _skinValue, _skinSignature);
}
public ItemStack getSkull()
{
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
@ -124,6 +121,10 @@ public class SkinData
public Property getProperty()
{
if (_skinProperty == null)
{
getSkinProperty();
}
return new Property(_skinProperty.getName(), _skinProperty.getValue(), _skinProperty.getSignature());
}
@ -168,4 +169,4 @@ public class SkinData
return null;
}
}
}

View File

@ -1,8 +1,9 @@
package mineplex.core.common.util;
import org.bukkit.ChatColor;
import mineplex.core.common.Rank;
import mineplex.core.common.currency.Currency;
import org.bukkit.ChatColor;
public class F
{
@ -27,6 +28,11 @@ public class F
return C.mGame + elem + C.mBody;
}
public static String color(String msg, String color)
{
return color + msg + C.mBody;
}
public static String ta(String message)
{
return C.cGreen + message + C.cWhite;
@ -197,7 +203,7 @@ public class F
return out;
}
public static String currency(Currency type, int amount)
{
return type.getString(amount) + ChatColor.RESET + C.mBody;
@ -223,4 +229,9 @@ public class F
return C.cClansNether + word + C.mBody;
}
public static String greenElem(String text)
{
return C.cGreen + text + ChatColor.RESET + C.mBody;
}
}

View File

@ -19,6 +19,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
@ -287,6 +288,16 @@ public class MapUtil
return true;
}
}
public static BlockPosition getBlockPos(Location loc)
{
return getBlockPos(loc.toVector());
}
public static BlockPosition getBlockPos(Vector v)
{
return getBlockPos(v.getBlockX(), v.getBlockY(), v.getBlockZ());
}
public static BlockPosition getBlockPos(int x, int y, int z)
{

View File

@ -606,10 +606,10 @@ public class UtilBlock
}
public static ArrayList<Block> getInBoundingBox(Location a, Location b, boolean ignoreAir) {
return getInBoundingBox(a, b, ignoreAir, false, true, true);
return getInBoundingBox(a, b, ignoreAir, false, false, false);
}
public static ArrayList<Block> getInBoundingBox(Location a, Location b, boolean ignoreAir, boolean hollow, boolean walls, boolean ceilfloor)
public static ArrayList<Block> getInBoundingBox(Location a, Location b, boolean ignoreAir, boolean hollow, boolean wallsOnly, boolean ceilfloorOnly)
{
ArrayList<Block> blocks = new ArrayList<Block>();
@ -626,26 +626,25 @@ public class UtilBlock
for (int y = ymin; y <= ymax; y++)
for (int z = zmin; z <= zmax; z++)
{
if(hollow)
if(hollow)
{
if(!(x == xmin || x == xmax || y == ymin || y == ymax || z == zmin || z == zmax)) continue;
}
if(!walls)
if(wallsOnly)
{
if(
(x == xmin || x == xmax) ||
(z == zmin || z == zmax)
(x != xmin && x != xmax) &&
(z != zmin && z != zmax)
)
{
continue;
}
}
if(!ceilfloor)
if(ceilfloorOnly)
{
if(y == ymin || y == ymax)
if(y != ymin && y != ymax)
{
continue;
}

View File

@ -0,0 +1,21 @@
package mineplex.core.antispam;
import mineplex.core.common.api.ApiResponse;
/**
* @author Shaun Bennett
*/
public class AntiSpamApiResponse extends ApiResponse
{
private boolean isShadowMuted;
public AntiSpamApiResponse()
{
}
public boolean isShadowMuted()
{
return isShadowMuted;
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.antispam;
import mineplex.core.MiniPlugin;
import mineplex.core.antispam.repository.AntiSpamRepository;
import mineplex.core.chat.IChatMessageFormatter;
import mineplex.core.status.ServerStatusManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -18,6 +19,8 @@ public class AntiSpamManager extends MiniPlugin
private final String _region;
private final AntiSpamRepository _repository;
private IChatMessageFormatter _messageFormatter;
public AntiSpamManager()
{
super("AntiSpam");
@ -38,6 +41,11 @@ public class AntiSpamManager extends MiniPlugin
}
}
public void setMessageFormatter(IChatMessageFormatter messageFormatter)
{
_messageFormatter = messageFormatter;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onChat(AsyncPlayerChatEvent event)
{
@ -48,7 +56,19 @@ public class AntiSpamManager extends MiniPlugin
String message = event.getMessage();
ChatPayload payload = new ChatPayload(player.getName(), player.getUniqueId().toString(), _region, _serverName, message, System.currentTimeMillis());
// Run our API call async to the chat message (prevents blocking chat message)
runAsync(() -> _repository.logMessage(_pluginName, payload));
AntiSpamApiResponse response = _repository.sendMessage(_pluginName, payload);
if (response != null) // can be null if the request times out
{
if (response.isShadowMuted())
{
event.setCancelled(true);
if (_messageFormatter != null)
{
String formattedMessage = String.format(_messageFormatter.getChatFormat(player, message).getFormat(), player.getName(), message);
event.getPlayer().sendMessage(formattedMessage);
}
}
}
}
}
}

View File

@ -1,6 +1,7 @@
package mineplex.core.antispam.repository;
import com.google.gson.Gson;
import mineplex.core.antispam.AntiSpamApiResponse;
import mineplex.core.antispam.ChatPayload;
import mineplex.core.common.api.ApiEndpoint;
import mineplex.core.common.api.ApiHost;
@ -19,8 +20,8 @@ public class AntiSpamRepository extends ApiEndpoint
super(ApiHost.ANTISPAM, "/chat");
}
public ApiResponse logMessage(String source, ChatPayload payload)
public AntiSpamApiResponse sendMessage(String source, ChatPayload payload)
{
return getWebCall().post("/" + source, ApiResponse.class, payload);
return getWebCall().post("/" + source, AntiSpamApiResponse.class, payload);
}
}

View File

@ -8,10 +8,12 @@ import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.bonuses.animations.AnimationCarl;
import mineplex.core.bonuses.commands.AnimationCommand;
import mineplex.core.bonuses.commands.GuiCommand;
import mineplex.core.bonuses.commands.PowerPlayCommand;
import mineplex.core.bonuses.commands.TicketCommand;
import mineplex.core.bonuses.event.CarlSpinnerEvent;
import mineplex.core.bonuses.gui.BonusGui;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
import mineplex.core.bonuses.redis.VoteHandler;
import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.common.Rank;
@ -30,6 +32,7 @@ import mineplex.core.npc.Npc;
import mineplex.core.npc.NpcManager;
import mineplex.core.pet.PetManager;
import mineplex.core.poll.PollManager;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.recharge.Recharge;
import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager;
@ -123,6 +126,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private StatsManager _statsManager;
private FacebookManager _facebookManager;
private YoutubeManager _youtubeManager;
private PowerPlayClubRepository _powerPlayClubRepository;
private ThankManager _thankManager;
public boolean _enabled;
private Npc _carlNpc;
@ -150,6 +154,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_repository = new BonusRepository(plugin, this, donationManager);
_clientManager = clientManager;
_donationManager = donationManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager);
System.out.print("VOTIFIER: ");
System.out.print("DONATION MANAGER - > " + _donationManager.toString());
_voteList = new ArrayList<String>();
_voteList.add("http://vote1.mineplex.com");
@ -173,6 +181,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_inventoryManager = inventoryManager;
_thankManager = thankManager;
if (gadgetManager == null)
{
System.out.print("GM NULL");
}
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, statsManager, gadgetManager);
_pollManager = pollManager;
@ -180,6 +193,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_facebookManager = facebookManager;
_youtubeManager = youtubeManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager);
_voteList = new ArrayList<String>();
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
@ -226,6 +241,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
addCommand(new GuiCommand(this));
addCommand(new AnimationCommand(this));
addCommand(new TicketCommand(this));
addCommand(new PowerPlayCommand(this));
}
// Just keeping things up-to-date
@ -508,7 +524,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
else
{
UtilPlayer.message(player, F.main("Carl", "There waa an error processing your request. Try again later"));
UtilPlayer.message(player, F.main("Carl", "There was an error processing your request. Try again later"));
}
}
});
@ -909,6 +925,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
if (!_facebookManager.hasRedeemed(player)) availableRewards++;
if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++;
if (PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) availableRewards++;
Hologram hologram;
@ -1091,7 +1108,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
{
if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player))
if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
{
if(_showCarl.containsKey(player.getName()))
{
@ -1199,4 +1216,19 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return _thankManager;
}
public DonationManager getDonationManager()
{
return _donationManager;
}
public PowerPlayClubRepository getPowerPlayClubRepository()
{
return _powerPlayClubRepository;
}
public InventoryManager getInventoryManager()
{
return _inventoryManager;
}
}

View File

@ -2,33 +2,25 @@ package mineplex.core.bonuses.animations;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.bonuses.powerplay.PowerPlayAnimation;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.animation.Animation;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -78,7 +70,7 @@ public class AnimationCarl extends Animation
}
}
if(!((String) _type).contentEquals("DAILY")&& !((String) _type).contentEquals("RANK")&& !((String) _type).contentEquals("POLL"))
if(!((String) _type).contentEquals("DAILY") && !((String) _type).contentEquals("RANK") && !((String) _type).contentEquals("POLL"))
{
Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64));
@ -130,6 +122,37 @@ public class AnimationCarl extends Animation
finish();
}
}
if (_type instanceof PowerPlayAnimation)
{
for (int i = 50; i < 65; i++)
{
// Gem amplifier
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
_items.add(gem);
Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
UtilAction.velocity(gem, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
// Omega chest
Item omega = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), SkinData.OMEGA_CHEST.getSkull());
_items.add(omega);
vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
UtilAction.velocity(omega, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
// Monthly items
PowerPlayAnimation powerPlayAnimation = (PowerPlayAnimation) _type;
for (ItemStack itemStack : powerPlayAnimation.getAnimationItems())
{
Item monthly = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), itemStack);
_items.add(monthly);
vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
UtilAction.velocity(monthly, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
}
}
finish();
}
}
@Override

View File

@ -0,0 +1,45 @@
package mineplex.core.bonuses.commands;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.time.LocalDate;
public class PowerPlayCommand extends CommandBase<BonusManager>
{
private BonusManager _bonusManager;
public PowerPlayCommand(BonusManager manager)
{
super(manager, Rank.JNR_DEV, "powerplay");
_bonusManager = manager;
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length < 1)
{
UtilPlayer.message(caller, F.main("Power Play Club", "Missing Args: " + F.elem("/powerplay <player>")));
return;
}
Player player = Bukkit.getPlayer(args[0]);
if (player == null) {
caller.sendMessage(ChatColor.RED + "Couldn't find player");
return;
}
_bonusManager.getPowerPlayClubRepository().Get(player).setSubscribed(true);
_bonusManager.getPowerPlayClubRepository().addSubscription(_bonusManager.getClientManager().Get(player).getAccountId(), LocalDate.now(), "month");
caller.sendMessage(ChatColor.GREEN + "Gave a month's subscription to " + player.getName());
}
}

View File

@ -37,7 +37,9 @@ public class BonusGui extends SimpleGui
setItem(25, new ClaimTipsButton(getPlugin(), player, this, manager, thankManager));
setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
setItem(29, new PowerPlayClubButton(player, manager));
setItem(33, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
}
@Override

View File

@ -0,0 +1,134 @@
package mineplex.core.bonuses.gui.buttons;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gui.GuiItem;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.powerplayclub.PowerPlayClubRewards;
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;
import java.util.ArrayList;
public class PowerPlayClubButton implements GuiItem
{
private ItemStack _item;
private Player _player;
private PowerPlayClubRepository _powerPlayClubRepository;
private InventoryManager _inventoryManager;
private BonusManager _bonusManager;
public PowerPlayClubButton(Player player, BonusManager manager)
{
_player = player;
_bonusManager = manager;
_powerPlayClubRepository = manager.getPowerPlayClubRepository();
_inventoryManager = manager.getInventoryManager();
}
@Override
public void setup()
{
setItem();
}
@Override
public void close()
{
}
@Override
public void click(ClickType clickType)
{
if (isAvailable() && !_bonusManager.getPowerPlayClubRepository().alreadyClaimed(_player))
{
_player.closeInventory();
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository);
}
else
{
_player.playSound(_player.getLocation(), Sound.ITEM_BREAK, 1, 10);
if (_powerPlayClubRepository.alreadyClaimed(_player))
{
UtilPlayer.message(_player, F.main("Power Play Club", "Already claimed!"));
}
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 + "!"));
}
}
}
@Override
public ItemStack getObject()
{
return _item;
}
private void setItem()
{
ArrayList<String> lore = new ArrayList<>();
Material material;
byte data = 0;
String itemName;
if (isAvailable())
{
material = Material.GOLD_INGOT;
itemName = C.cGreenB + "Power Play Club";
lore.add("");
lore.add(C.Reset + "Click to claim!");
}
else
{
material = Material.REDSTONE_BLOCK;
itemName = C.cRedB + "Power Play Club";
}
lore.add(C.cYellow + "Rewards");
lore.add(" " + C.cWhite + "2 Game Amplifiers");
lore.add(" " + C.cWhite + "1 Omega Chest");
for (PowerPlayClubRewards.PowerPlayClubItem prize : PowerPlayClubRewards.septemberItems())
{
lore.add(" " + C.cWhite + prize.getAmount() + " " + prize.getPrize());
}
//lore.add(" ");
//lore.add(C.cYellow + "Months left: " + C.cWhite + getMonthsLeft(true)); //TODO: figure this out
if (!isAvailable())
{
lore.add(" ");
if (_powerPlayClubRepository.alreadyClaimed(_player))
{
lore.add(C.cRed + "Already claimed!");
}
else
{
lore.add(C.cRed + "Get Power Play Club months at");
lore.add(C.cAqua + "mineplex.com/shop");
}
}
_item = new ShopItem(material, data, itemName, lore.toArray(new String[0]), 1, false, false);
}
private boolean isAvailable()
{
return _powerPlayClubRepository.canClaim(_player);
}
public static boolean isAvailable(Player player, PowerPlayClubRepository repo)
{
return repo.canClaim(player);
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.bonuses.powerplay;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class PowerPlayAnimation
{
private List<ItemStack> _animationItems;
private Player _player;
public PowerPlayAnimation(Player player, List<ItemStack> animationItems)
{
_animationItems = animationItems;
_player = player;
}
public List<ItemStack> getAnimationItems()
{
return _animationItems;
}
public Player getPlayer()
{
return _player;
}
}

View File

@ -122,7 +122,7 @@ public class Fountain implements GoalCounterListener
}
_hologram.setText(text.toArray(new String[text.size()]));
_schematicLoader.update(fillPercent);
//_schematicLoader.update(fillPercent);
}
else
{

View File

@ -6,13 +6,13 @@ import mineplex.core.brawl.fountain.command.FountainCommand;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.locations.LocationConstants;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.servers.ConnectionData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -48,7 +48,7 @@ public class FountainManager extends MiniPlugin
int goal = 70000000;//!new File("eu.dat").exists() ? 200000000 : 20000000;
_gemFountain = new Fountain(new ConnectionData("10.3.203.80", 6379, ConnectionData.ConnectionType.MASTER, "USRedis"),
new ConnectionData("10.3.203.80", 6377, ConnectionData.ConnectionType.SLAVE, "USRedis"), Region.ALL,
new Location(world, -25.5, 73, 19.5), new Location(world, -35.5, 69, 1.5),
LocationConstants.FOUNTAIN_LOCATION, LocationConstants.FOUNTAIN_SCHEMATIC,
C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager);
}

View File

@ -3,6 +3,7 @@ package mineplex.core.chat;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antispam.AntiSpamManager;
import mineplex.core.chat.command.BroadcastCommand;
import mineplex.core.chat.command.ChatSlowCommand;
import mineplex.core.chat.command.SilenceCommand;

View File

@ -0,0 +1,39 @@
package mineplex.core.chat;
/**
* The format for a chat message being sent by a player
*
* @author Shaun Bennett
*/
public class ChatFormat
{
private String _format;
private boolean _json;
public ChatFormat(String format, boolean json)
{
_format = format;
_json = json;
}
/**
* Get the string representing the chat format. This will be represented as a JSON string if {@link #isJson()},
* or should be in the standard Spigot chat format otherwise.
*
* @return A string representing how to format the chat message
*/
public String getFormat()
{
return _format;
}
/**
* Is this chat format a JSON string (should be sent to player as a json message)
*
* @return boolean representing if this chat format is in the json format
*/
public boolean isJson()
{
return _json;
}
}

View File

@ -0,0 +1,21 @@
package mineplex.core.chat;
import org.bukkit.entity.Player;
/**
* This is an interface that provides a method to format chat message.
* Needed for AntiSpam's shadow mute feature.
*
* @author Shaun Bennett
*/
public interface IChatMessageFormatter
{
/**
* Returns the proper format for the chat message to be sent
*
* @param player Player sending the message
* @param message The message the player is trying to send
* @return the format of the chat message,
*/
public ChatFormat getChatFormat(Player player, String message);
}

View File

@ -1,56 +1,25 @@
package mineplex.core.disguise.disguises;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager;
import mineplex.core.thread.ThreadPool;
import mineplex.core.utils.UtilGameProfile;
import net.minecraft.server.v1_8_R3.AttributeInstance;
import net.minecraft.server.v1_8_R3.AttributeMapServer;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.IInventory;
import net.minecraft.server.v1_8_R3.ITileEntityContainer;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MobEffect;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutAbilities;
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEffect;
import net.minecraft.server.v1_8_R3.PacketPlayOutExperience;
import net.minecraft.server.v1_8_R3.PacketPlayOutHeldItemSlot;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.server.v1_8_R3.PacketPlayOutPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes;
import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateHealth;
import net.minecraft.server.v1_8_R3.WorldSettings;
import org.bukkit.Bukkit;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.function.Supplier;
public class DisguisePlayer extends DisguiseHuman
{
@ -480,4 +449,4 @@ public class DisguisePlayer extends DisguiseHuman
}
return this._originalProfile.getId();
}
}
}

View File

@ -34,6 +34,7 @@ public class DonationManager extends MiniClientPlugin<Donor>
private NautHashMap<Player, NautHashMap<String, Integer>> _coinQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
private Queue<GiveDonorData> _coinAttemptQueue;
private final CoreClientManager _clientManager;
public DonationManager(JavaPlugin plugin, CoreClientManager clientManager, String webAddress)

View File

@ -1,12 +1,10 @@
package mineplex.core.gadget;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.Predicate;
import mineplex.core.gadget.event.PlayerToggleSwimEvent;
import mineplex.core.gadget.gadgets.morph.swim.SwimManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -26,11 +24,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.*;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.commands.AmmoCommand;
@ -83,6 +77,7 @@ import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStr
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
import mineplex.core.gadget.gadgets.hat.HatItem;
import mineplex.core.gadget.gadgets.hat.HatType;
import mineplex.core.gadget.gadgets.morph.*;
import mineplex.core.gadget.gadgets.item.ItemBatGun;
import mineplex.core.gadget.gadgets.item.ItemBow;
import mineplex.core.gadget.gadgets.item.ItemCoal;
@ -147,6 +142,9 @@ import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan;
import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood;
import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant;
import mineplex.core.gadget.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.suits.SetRaveSuit;
import mineplex.core.gadget.set.suits.SetSpaceSuit;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
@ -155,7 +153,6 @@ import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium;
import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian;
import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails;
import mineplex.core.gadget.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.SetCandyCane;
import mineplex.core.gadget.set.SetCupidsLove;
import mineplex.core.gadget.set.SetEmerald;
@ -168,8 +165,6 @@ import mineplex.core.gadget.set.SetShadow;
import mineplex.core.gadget.set.SetTitan;
import mineplex.core.gadget.set.SetVampire;
import mineplex.core.gadget.set.SetWisdom;
import mineplex.core.gadget.set.suits.SetRaveSuit;
import mineplex.core.gadget.set.suits.SetSpaceSuit;
import mineplex.core.gadget.types.ArrowEffectGadget;
import mineplex.core.gadget.types.DeathEffectGadget;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
@ -185,6 +180,7 @@ import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.gadget.types.WinEffectGadget;
import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager;
@ -209,6 +205,7 @@ public class GadgetManager extends MiniPlugin
private final PacketHandler _packetManager;
private final HologramManager _hologramManager;
private final OutfitWindUpSuitBoosterManager _boosterManager;
private final IncognitoManager _incognitoManager;
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
@ -226,9 +223,9 @@ public class GadgetManager extends MiniPlugin
private Set<Entity> _gadgetCollideWhitelist = new HashSet<>();
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager,
PacketHandler packetHandler, HologramManager hologramManager)
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager,
PacketHandler packetHandler, HologramManager hologramManager, IncognitoManager incognitoManager)
{
super("Gadget Manager", plugin);
@ -246,6 +243,7 @@ public class GadgetManager extends MiniPlugin
_hologramManager = hologramManager;
_userGadgetPersistence = new UserGadgetPersistence(this);
_boosterManager = new OutfitWindUpSuitBoosterManager(this);
_incognitoManager = incognitoManager;
createGadgets();
createSets();
@ -342,6 +340,9 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphTitan(this));
addGadget(new MorphSnowman(this));
addGadget(new MorphUncleSam(this));
addGadget(new MorphSquid(this));
// Not being added in this update!
//addGadget(new MorphMetalMan(this));
// Particles
addGadget(new ParticleFoot(this));
@ -1023,6 +1024,12 @@ public class GadgetManager extends MiniPlugin
{
if (!_gadgetsEnabled)
event.setCancelled(true);
Player player = event.getPlayer();
if (_incognitoManager.Get(player).Hidden && event.getGadget().getGadgetType() == GadgetType.PARTICLE)
{
event.setCancelled(true);
player.sendMessage(F.main("Cosmetics", "You cannot enable particles while vanished!"));
}
}
@EventHandler
@ -1122,4 +1129,27 @@ public class GadgetManager extends MiniPlugin
{
return _userGadgetPersistence;
}
@EventHandler
public void checkPlayerSwim(PlayerMoveEvent event)
{
Material material = event.getPlayer().getLocation().getBlock().getType();
UUID uuid = event.getPlayer().getUniqueId();
if (material == Material.WATER || material == Material.STATIONARY_WATER)
{
if (!SwimManager.isSwimming(uuid))
{
SwimManager.addPlayer(uuid);
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), true));
}
}
else
{
if (SwimManager.isSwimming(uuid))
{
SwimManager.removePlayer(uuid);
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), false));
}
}
}
}

View File

@ -9,11 +9,10 @@ import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.ClientInventory;
import mineplex.core.inventory.ClientItem;
import mineplex.core.inventory.data.Item;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class LockCosmeticsCommand extends CommandBase<GadgetManager>
@ -23,100 +22,107 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
public LockCosmeticsCommand(GadgetManager plugin)
{
super(plugin, Rank.JNR_DEV, new Rank[]{Rank.SNR_MODERATOR}, "lockCosmetics");
super(plugin, Rank.JNR_DEV, "lockCosmetics");
_plugin = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
// Removes all cosmetic types
if (args.length == 0)
{
lockCosmetics(null, caller);
}
// Removes specific type
else
{
String type = args[0];
if (type.equalsIgnoreCase("all"))
{
lockCosmetics(null, caller);
}
@Override
public void Execute(Player caller, String[] args)
{
// Adds all cosmetic types
if (args.length == 0)
{
removeCosmetics(null, caller);
}
// Adds specific type
else
{
String type = args[0];
if (type.equalsIgnoreCase("all"))
{
removeCosmetics(null, caller);
}
else if (type.equalsIgnoreCase("pet"))
{
lockPets(caller);
removePets(caller);
}
else if (type.equalsIgnoreCase("mount"))
{
lockMounts(caller);
removeMounts(caller);
}
else
{
GadgetType gadgetType = GadgetType.valueOf(type);
if (gadgetType == null)
{
UtilPlayer.message(caller, F.main("Cosmetics", "Invalid cosmetic type!"));
}
else
{
lockCosmetics(gadgetType, caller);
}
}
}
else
{
GadgetType gadgetType = GadgetType.valueOf(type);
if (gadgetType == null)
{
UtilPlayer.message(caller, F.main("Cosmetics", "Invalid cosmetic type!"));
}
else
{
removeCosmetics(gadgetType, caller);
}
}
}
}
}
private void lockCosmetics(GadgetType gadgetType, Player caller)
{
if (gadgetType == null)
{
for (GadgetType type : GadgetType.values())
{
lockCosmetics(type, caller);
}
lockMounts(caller);
lockPets(caller);
return;
}
private void removeCosmetics(GadgetType gadgetType, Player caller)
{
if (gadgetType == null)
{
for (GadgetType type : GadgetType.values())
{
if (type == GadgetType.ITEM)
continue;
removeCosmetics(type, caller);
}
removeMounts(caller);
removePets(caller);
return;
}
ClientInventory clientInventory = _plugin.getInventoryManager().Get(caller);
int removed = 0;
for (Gadget gadget : _plugin.getGadgets(gadgetType))
{
if (gadget.getGadgetType() == GadgetType.ITEM)
int amount = -1;
for (Gadget gadget : _plugin.getGadgets(gadgetType))
{
if (gadgetType == GadgetType.ITEM)
continue;
if (gadget.ownsGadget(caller))
{
Item clientItem = _plugin.getInventoryManager().getItem(gadget.getName());
if (clientItem == null)
continue;
_plugin.getInventoryManager().Get(caller).removeItem(new ClientItem(clientItem, 1));
removed++;
ClientItem clientItem = clientInventory.getClientItem(gadget.getName());
if (clientItem != null)
{
clientInventory.removeItem(clientItem);
removed++;
}
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name().toLowerCase()
.replace("_", " ") + "! (Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("item", removed) + ")"));
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name().toLowerCase()
.replace("_", " ") + " gadgets! (Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("item", removed) + ")"));
}
private void lockMounts(Player caller)
private void removeMounts(Player caller)
{
int removed = 0;
ClientInventory clientInventory = _plugin.getInventoryManager().Get(caller);
for (Mount<?> mount : _plugin.getMountManager().getMounts())
{
if (mount.hasMount(caller))
{
Item clientItem = _plugin.getInventoryManager().getItem(mount.getName());
if (clientItem == null)
continue;
_plugin.getInventoryManager().Get(caller).removeItem(new ClientItem(clientItem, 1));
removed++;
ClientItem clientItem = clientInventory.getClientItem(mount.getName());
if (clientItem != null)
{
clientInventory.removeItem(clientInventory.getClientItem(mount.getName()));
removed++;
}
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("mount", removed) + "!"));
}
private void lockPets(Player caller)
private void removePets(Player caller)
{
int removed = 0;
for (Pet pet : _plugin.getPetManager().getFactory().GetPets())
@ -130,4 +136,5 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("pet", removed) + "!"));
}
}

View File

@ -0,0 +1,41 @@
package mineplex.core.gadget.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerToggleSwimEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private boolean _swimming;
public PlayerToggleSwimEvent(Player player, boolean swimming)
{
_player = player;
_swimming = swimming;
}
public Player getPlayer()
{
return _player;
}
public boolean isSwimming()
{
return _swimming;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -56,7 +56,7 @@ public class MorphBat extends MorphGadget implements IThrown
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseBat disguise = new DisguiseBat(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -67,7 +67,7 @@ public class MorphBat extends MorphGadget implements IThrown
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.setAllowFlight(false);

View File

@ -39,7 +39,7 @@ public class MorphBlaze extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseBlaze disguise = new DisguiseBlaze(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -50,7 +50,7 @@ public class MorphBlaze extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}

View File

@ -48,7 +48,7 @@ public class MorphBlock extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
_active.put(player, new BlockForm(this, player, Material.EMERALD_BLOCK));
}
@ -56,7 +56,7 @@ public class MorphBlock extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
BlockForm form = _active.remove(player);

View File

@ -52,7 +52,7 @@ public class MorphBunny extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseRabbit disguise = new DisguiseRabbit(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -67,7 +67,7 @@ public class MorphBunny extends MorphGadget
public void disableCustom(Player player, boolean message)
{
_jumpCharge.remove(player);
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.removePotionEffect(PotionEffectType.SPEED);

View File

@ -45,7 +45,7 @@ public class MorphChicken extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseChicken disguise = new DisguiseChicken(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -56,7 +56,7 @@ public class MorphChicken extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.setAllowFlight(false);

View File

@ -33,7 +33,7 @@ public class MorphCow extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseCow disguise = new DisguiseCow(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -44,7 +44,7 @@ public class MorphCow extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}

View File

@ -47,7 +47,7 @@ public class MorphCreeper extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseCreeper disguise = new DisguiseCreeper(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -58,7 +58,7 @@ public class MorphCreeper extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}

View File

@ -44,7 +44,7 @@ public class MorphEnderman extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseEnderman disguise = new DisguiseEnderman(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -55,7 +55,7 @@ public class MorphEnderman extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.setAllowFlight(false);

View File

@ -0,0 +1,135 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.*;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.gadgets.particle.unrelated.MetalManEffect;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.utils.UtilGameProfile;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
public class MorphMetalMan extends MorphGadget
{
private Map<UUID, Integer> _playerColors = new HashMap<>();
public MorphMetalMan(GadgetManager manager)
{
super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE),
0, Material.IRON_INGOT, (byte) 0);
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
GameProfile gameProfile = UtilGameProfile.getGameProfile(player);
gameProfile.getProperties().clear();
gameProfile.getProperties().put("textures", SkinData.METAL_MAN.getProperty());
DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile);
disguisePlayer.showInTabList(true, 0);
Manager.getDisguiseManager().disguise(disguisePlayer);
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
@EventHandler
public void onPlayerClick(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!isActive(player))
return;
if (!UtilEvent.isAction(event, UtilEvent.ActionType.L))
return;
if (!Recharge.Instance.use(player, getName(), 1000, false, false, "Cosmetics"))
return;
// Creates colored laser
HashSet<Material> ignore = new HashSet<Material>();
ignore.add(Material.AIR);
Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, loc);
Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent);
// Checks to see if it's a valid location
if (gadgetSelectLocationEvent.isCancelled())
{
if (gadgetSelectLocationEvent.canShowMessage())
{
UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!"));
}
return;
}
// Creates the particle beam
int color = 0;
if (_playerColors.containsKey(player.getUniqueId()))
{
color = _playerColors.get(player.getUniqueId());
}
MetalManEffect metalManEffect = new MetalManEffect(player.getEyeLocation(), loc, color, Manager.getPlugin());
increaseColor(player.getUniqueId());
metalManEffect.start();
// Creates the explosion and knockback players
loc.getWorld().createExplosion(loc, 0f);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers());
HashMap<Player, Double> players = UtilPlayer.getInRadius(loc, 12d);
for (Player ent : players.keySet())
{
if (Manager.collideEvent(player, this, ent))
continue;
double mult = players.get(ent);
//Knockback
UtilAction.velocity(ent, UtilAlg.getTrajectory(loc, ent.getLocation()), 2 * mult, false, 0, 1 + 1 * mult, 10, true);
}
}
public void increaseColor(UUID uuid)
{
if (_playerColors.containsKey(uuid))
{
int color = _playerColors.get(uuid);
if (color == 0)
color = 1;
else
color = 0;
_playerColors.put(uuid, color);
}
else
{
_playerColors.put(uuid, 0);
}
}
}

View File

@ -46,7 +46,7 @@ public class MorphPig extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguisePig disguise = new DisguisePig(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -57,7 +57,7 @@ public class MorphPig extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}

View File

@ -30,7 +30,7 @@ public class MorphPumpkinKing extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseSkeleton disguise = new DisguiseSkeleton(player);
disguise.showArmor();
@ -48,7 +48,7 @@ public class MorphPumpkinKing extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.getInventory().setHelmet(null);
}

View File

@ -45,7 +45,7 @@ public class MorphSlime extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseSlime disguise = new DisguiseSlime(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -67,7 +67,7 @@ public class MorphSlime extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}

View File

@ -56,7 +56,7 @@ public class MorphSnowman extends MorphGadget
@Override
public void enableCustom(Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseSnowman disguise = new DisguiseSnowman(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -67,7 +67,7 @@ public class MorphSnowman extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}

View File

@ -0,0 +1,142 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.common.util.*;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.PlayerToggleSwimEvent;
import mineplex.core.gadget.gadgets.morph.swim.SwimManager;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class MorphSquid extends MorphGadget implements IThrown
{
public MorphSquid(GadgetManager manager)
{
super(manager, "Squid Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "It's more fun to be a squid than to eat one. They're really rubbery.",
C.blankLine,
C.cWhite + "Swim to enable Fast Swimming",
C.cWhite + "Sneak to shoot a fish above you"
}, LineFormat.LORE),
0, Material.INK_SACK, (byte) 0);
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
DisguiseSquid disguiseSquid = new DisguiseSquid(player);
disguiseSquid.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
Manager.getDisguiseManager().disguise(disguiseSquid);
onToggleSwim(new PlayerToggleSwimEvent(player, SwimManager.isSwimming(player.getUniqueId())));
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : UtilServer.getPlayers())
{
if (!isActive(player))
continue;
UtilParticle.PlayParticle(UtilParticle.ParticleType.WATER_WAKE, player.getLocation().clone().add(0, .5, 0), 0.01f, 0.01f, 0.01f,
0.001f, 1, UtilParticle.ViewDist.NORMAL);
}
}
@EventHandler
public void onToggleSwim(PlayerToggleSwimEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (event.isSwimming())
{
// Removes any costume player could be wearing
Manager.removeOutfit(event.getPlayer(), OutfitGadget.ArmorSlot.Boots);
// Adds enchanted boot
ItemStack enchantedBoot = new ItemStack(Material.DIAMOND_BOOTS, 1);
enchantedBoot.addEnchantment(Enchantment.DEPTH_STRIDER, 3);
event.getPlayer().getInventory().setBoots(enchantedBoot);
// Adds swiftness potion
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 3, true, true));
}
else
{
event.getPlayer().getInventory().setBoots(new ItemStack(Material.AIR));
event.getPlayer().removePotionEffect(PotionEffectType.SPEED);
}
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event)
{
Player player = event.getPlayer();
if (!player.isSneaking())
return;
if (!isActive(player))
return;
if (!Recharge.Instance.use(player, getName(), 1000, false, false, "Cosmetics"))
return;
Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),
ItemStackFactory.Instance.CreateStack(Material.RAW_FISH));
UtilAction.velocity(item, player.getLocation().getDirection(),
0.01, true, -0.3, 1.5, 10, false);
Manager.getProjectileManager().AddThrow(item, player, this, -1, true, true, true, true,
null, 1f, 1f, null, null, 0, UpdateType.TICK, 0.5f);
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
data.getThrown().remove();
}
@Override
public void Idle(ProjectileUser data)
{
data.getThrown().remove();
}
@Override
public void Expire(ProjectileUser data)
{
data.getThrown().remove();
}
}

View File

@ -60,7 +60,7 @@ public class MorphTitan extends MorphGadget
@Override
public void enableCustom(Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseGuardian disguise = new DisguiseGuardian(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -72,7 +72,7 @@ public class MorphTitan extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.setAllowFlight(false);

View File

@ -45,7 +45,7 @@ public class MorphUncleSam extends MorphGadget
@Override
public void enableCustom(Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
GameProfile profile = UtilGameProfile.getGameProfile(player);
profile.getProperties().clear();
@ -61,7 +61,7 @@ public class MorphUncleSam extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(this._disguises.remove(player.getUniqueId()));
}

View File

@ -48,7 +48,7 @@ public class MorphVillager extends MorphGadget implements IThrown
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
DisguiseVillager disguise = new DisguiseVillager(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
@ -59,7 +59,7 @@ public class MorphVillager extends MorphGadget implements IThrown
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
}

View File

@ -58,7 +58,7 @@ public class MorphWither extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
this.ApplyArmor(player, message);
this.applyArmor(player, message);
player.setMaxHealth(300);
player.setHealth(300);
@ -75,7 +75,7 @@ public class MorphWither extends MorphGadget
@Override
public void disableCustom(Player player, boolean message)
{
this.RemoveArmor(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.setAllowFlight(false);

View File

@ -0,0 +1,30 @@
package mineplex.core.gadget.gadgets.morph.swim;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class SwimManager
{
private static List<UUID> _swimming = new ArrayList<>();
public static void addPlayer(UUID uuid)
{
_swimming.add(uuid);
}
public static void removePlayer(UUID uuid)
{
if (_swimming.contains(uuid))
{
_swimming.remove(uuid);
}
}
public static boolean isSwimming(UUID uuid)
{
return _swimming.contains(uuid);
}
}

View File

@ -9,6 +9,7 @@ public abstract class Effect
public int _ticksToRun = 20, _ticks = 0, _task;
public long _delay = 1;
public EffectLocation _effectLocation;
public EffectLocation _targetLocation;
protected JavaPlugin _javaPlugin;
public Effect(int ticks, EffectLocation effectLocation, JavaPlugin javaPlugin)
@ -53,4 +54,14 @@ public abstract class Effect
public abstract void runEffect();
public void setTargetLocation(EffectLocation effectLocation)
{
_targetLocation = effectLocation;
}
public EffectLocation getTargetLocation()
{
return _targetLocation;
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
import java.awt.*;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class MetalManEffect extends Effect
{
private int _particles = 100;
private int _color;
private Vector _vector;
public MetalManEffect(Location location, Location target, int color, JavaPlugin javaPlugin)
{
super(20, new EffectLocation(location), javaPlugin);
_color = color;
setTargetLocation(new EffectLocation(target));
}
@Override
public void runEffect()
{
Location location = _effectLocation.getFixedLocation().clone();
if (_vector == null)
{
Location targetLoc = getTargetLocation().getFixedLocation().clone();
Vector link = targetLoc.toVector().subtract(location.toVector());
float length = (float) link.length();
link.normalize();
Vector vector = link.multiply(length / _particles);
_vector = vector;
}
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor((_color == 0) ? Color.YELLOW : Color.RED), _effectLocation.getLocation().clone());
Location loc = location.clone().subtract(_vector);
for (int i = 0; i < _particles; i++)
{
loc.add(_vector);
coloredParticle.setLocation(loc);
coloredParticle.display(UtilParticle.ViewDist.LONG);
}
}
}

View File

@ -16,7 +16,7 @@ public abstract class MorphGadget extends Gadget
super(manager, GadgetType.MORPH, name, desc, cost, mat, data);
}
public void ApplyArmor(Player player, boolean message)
public void applyArmor(Player player, boolean message)
{
Manager.removeGadgetType(player, GadgetType.MORPH, this);
@ -26,7 +26,7 @@ public abstract class MorphGadget extends Gadget
UtilPlayer.message(player, F.main("Gadget", "You morphed into " + F.elem(getName()) + "."));
}
public void RemoveArmor(Player player)
public void removeArmor(Player player)
{
if (_active.remove(player))
UtilPlayer.message(player, F.main("Gadget", "You unmorphed from " + F.elem(getName()) + "."));

View File

@ -61,6 +61,7 @@ public enum GameDisplay
ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49),
Build("Master Builders", Material.WOOD, (byte)0, GameCategory.CLASSICS, 50),
BuildMavericks("Mavericks Master Builders", Material.WOOD, (byte)3, GameCategory.CLASSICS, 63),
Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51),
Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52),
SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53),
@ -80,6 +81,8 @@ public enum GameDisplay
SpeedBuilders("Speed Builders", Material.QUARTZ_BLOCK, (byte) 0, GameCategory.CLASSICS, 60),
Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61),
Basketball("Hoops", Material.SLIME_BALL, (byte)0, GameCategory.EXTRA, 63),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999),

View File

@ -24,6 +24,10 @@ public class ClientInventory
if (Items.get(item.Item.Name).Count == 0)
Items.remove(item.Item.Name);
}
public ClientItem getClientItem(String name) {
return Items.containsKey(name) ? Items.get(name) : null;
}
public int getItemCount(String name)
{

View File

@ -0,0 +1,58 @@
package mineplex.core.locations;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
/**
* This class controls all "hard coded" locations that will be the same throughout the entire server
* regardless of whether or not it is on hub
*/
public class LocationConstants
{
private static final int CHEST_X = 31;
private static final int CHEST_Z = 23;
/**
* The number to be added to either the X or the Z for chest reset locations
*/
private static final int CHEST_ADD = 5;
public static final World WORLD = Bukkit.getWorld("world");
public static final Location HUB_SPAWN = new Location(WORLD, 0, 77, -32);
public static final Location[] CHEST_LOCATIONS = {
new Location(WORLD, 34, 72, -15),
new Location(WORLD, 23, 72, -31),
new Location(WORLD, -23, 72, -31),
new Location(WORLD, -34, 72, -15)
};
//new Location(world, -25.5, 73, 19.5), new Location(world, -35.5, 69, 1.5)
public static final Location FOUNTAIN_SCHEMATIC = new Location(WORLD, -35.5, 68, 1.5);
public static final Location FOUNTAIN_LOCATION = new Location(WORLD, -24.5, 72, 24.5);
public static Location getResetLocation(Location chestLocation)
{
int x = chestLocation.getBlockX();
int z = chestLocation.getBlockZ();
int absX = Math.abs(x);
int absZ = Math.abs(z);
if (absX == CHEST_X)
{
return chestLocation.clone().add(CHEST_ADD, 0, 0);
}
if (absZ == CHEST_Z)
{
return chestLocation.clone().add(0, 0, CHEST_ADD);
}
return chestLocation.clone().add(CHEST_ADD, 0, CHEST_ADD);
}
}

View File

@ -0,0 +1,188 @@
package mineplex.core.mavericks;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.util.Vector;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.SchematicData;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
/**
* Represents a display slot to display Mavericks Master Builders builds.
*/
public class DisplaySlot
{
private MavericksApprovedWrapper _data;
private Location _loc;
private ArrayList<Entity> _pastedEntities = new ArrayList<>();
private Map<Vector, ParticleType> _particles = null;
private List<Hologram> _holograms = new ArrayList<>();
/**
* @param loc The minimum corner of where the build will be pasted in.
*/
public DisplaySlot(Location loc, HologramManager hologramManager)
{
_loc = loc.clone();
for(int i = 0; i < 4; i++)
{
_holograms.add(new Hologram(hologramManager, _loc.clone(), "Built by ???", "Theme: ???"));
}
}
public MavericksApprovedWrapper getData()
{
return _data;
}
public void setData(MavericksApprovedWrapper data)
{
clearEntities();
for(Hologram h : _holograms)
h.stop();
Schematic schematic = data.getBuild().getSchematic();
Location a = _loc;
Location b = _loc.clone().add(schematic.getWidth(), schematic.getHeight(), schematic.getLength());
UtilBlock.startQuickRecording();
for(int x = a.getBlockX(); x < b.getX(); x++)
{
// Ignore the floor to keep the outer ring
for(int y = a.getBlockY() + 1; y < b.getY(); y++)
{
for(int z = a.getBlockZ(); z < b.getZ(); z++)
{
UtilBlock.setQuick(a.getWorld(), x, y, z, 0, (byte) 0);
}
}
}
SchematicData pasteData = schematic.paste(_loc, true, false);
for(Entity e : pasteData.getEntities())
{
if(e instanceof Item)
{
//Don't despawn
e.setTicksLived(32768);
//Prevent Pickup
((Item)e).setPickupDelay(32767);
}
else
{
UtilEnt.Vegetate(e, true);
UtilEnt.ghost(e, true, false);
}
_pastedEntities.add(e);
}
_particles = data.getBuild().getParticles();
boolean wasNull = _data == null;
_data = data;
//Only need to set locations first time after we get the data
if(wasNull)
{
setHologramLocations();
}
for(Hologram h : _holograms)
{
h.setText(
C.cGray + "Built by " + C.cYellow + C.Bold + _data.getBuild().getName(),
C.cGray + "Theme: " + C.cYellow + C.Bold + data.getBuild().getTheme());
h.start();
}
}
/**
* Send all the entities to nearby players. Should be called every 10 ticks.
*/
public void updateParticles()
{
if(_particles == null) return;
for(Entry<Vector, ParticleType> e : _particles.entrySet())
{
Location loc = _loc.clone().add(e.getKey());
ParticleType type = e.getValue();
int amount = 8;
if (type == ParticleType.HUGE_EXPLOSION ||
type == ParticleType.LARGE_EXPLODE ||
type == ParticleType.NOTE)
amount = 1;
UtilParticle.PlayParticleToAll(type, loc, 0.4f, 0.4f, 0.4f, 0, amount, ViewDist.LONG);
}
}
private void clearEntities()
{
for(Entity e : _pastedEntities)
{
e.remove();
}
_pastedEntities.clear();
}
/**
* @param e The entity you want to check.
* @return Returns true if this entity is spawned in by this display slot.
*/
public boolean isDisplaySlotEntity(Entity e)
{
return _pastedEntities.contains(e);
}
public boolean isInside(Location loc)
{
if(!_loc.getWorld().equals(loc.getWorld())) return false;
if(_data == null) return false;
Schematic s = _data.getBuild().getSchematic();
Location min = _loc.clone();
Location max = _loc.clone().add(s.getWidth(), s.getHeight(), s.getLength());
return UtilAlg.inBoundingBox(loc, min, max);
}
public void setHologramLocations()
{
if(_data == null) return;
Schematic s = _data.getBuild().getSchematic();
Location min = _loc.clone();
double height = 4;
_holograms.get(0).setLocation(min.clone().add(s.getWidth()/2.0, height, -1.5));
_holograms.get(1).setLocation(min.clone().add(s.getWidth()/2.0, height, s.getLength() + 1.5));
_holograms.get(2).setLocation(min.clone().add(-1.5, height, s.getLength()/2.0));
_holograms.get(3).setLocation(min.clone().add(s.getWidth() + 1.5, height, s.getLength()/2.0));
}
}

View File

@ -0,0 +1,176 @@
package mineplex.core.mavericks;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import mineplex.serverdata.database.DBPool;
/**
* Repository for Mavericks-MasterBuilders SQL game data
* -
* Table to back this repository may be created with:
*
*
CREATE TABLE mavericksMasterBuildersApproved (
buildId INT NOT NULL AUTO_INCREMENT,
ApproveDate INT NOT NULL,
ApprovedBy VARCHAR(36) NOT NULL DEFAULT '',
Display TINYINT(1) NOT NULL DEFAULT '1',
PRIMARY KEY (buildId),
CONSTRAINT account_id FOREIGN KEY (ApprovedBy) REFERENCES accounts (id) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT build_id FOREIGN KEY (BuildId) REFERENCES mavericksMasterBuildersBuilds (BuildId) ON DELETE NO ACTION ON UPDATE NO ACTION
)
*/
public class MavericksApprovedRepository
{
private static final String TABLE_APPROVED = "mavericksMasterBuildersApproved";
private static final String TABLE_BUILD = "mavericksMasterBuildersBuilds";
public CompletableFuture<Boolean> add(MavericksBuildWrapper data, UUID approvedBy)
{
return add(data, approvedBy, true);
}
public CompletableFuture<Boolean> add(MavericksBuildWrapper data, UUID approvedBy, boolean display)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
PreparedStatement stmt = conn.prepareStatement("REPLACE INTO " + TABLE_APPROVED + " (BuildId, ApprovedBy, Display) SELECT ?, accounts.id, ? FROM accounts WHERE uuid=?");
stmt.setLong(1, data.getBuildId());
stmt.setBoolean(2, display);
stmt.setString(3, approvedBy.toString());
return stmt.executeUpdate() > 0;
}
catch(SQLException e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
public CompletableFuture<List<MavericksApprovedWrapper>> getToDisplay(boolean onlyDisplay, int limit, int offset)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
String filter = onlyDisplay ? " WHERE Display=1 " : " ";
PreparedStatement stmt = conn.prepareStatement(
"SELECT " +
TABLE_APPROVED + ".BuildId, ApprovedDate," +
"(SELECT uuid FROM accounts WHERE accounts.id=ApprovedBy)," +
"Display, FirstDisplayed," +
"BuildTheme," +
"(SELECT uuid FROM accounts WHERE accounts.id=accountId)," +
"(SELECT name FROM accounts WHERE accounts.id=accountId)," +
"Points, Place, Date, Schematic, Particles, Reviewed " +
"FROM " + TABLE_APPROVED + " " +
"INNER JOIN " + TABLE_BUILD + " " +
"ON " + TABLE_APPROVED + ".BuildId = " + TABLE_BUILD + ".BuildId" +
filter +
"LIMIT " + limit + " OFFSET " + offset);
ResultSet set = stmt.executeQuery();
List<MavericksApprovedWrapper> list = new ArrayList<>();
while (set.next())
{
long buildId = set.getLong(1);
long approvedDate = set.getLong(2);
UUID approvedBy = UUID.fromString(set.getString(3));
boolean display = set.getBoolean(4);
Timestamp stamp = set.getTimestamp(1);
Long firstDisplayed = null;
if(!set.wasNull() && stamp != null) stamp.getTime();
String theme = set.getString(6);
UUID uuid = UUID.fromString(set.getString(7));
String lastName = set.getString(8);
int votes = set.getInt(9);
int place = set.getInt(10);
long dateStamp = set.getLong(11);
byte[] schematic = set.getBytes(12);
byte[] particles = set.getBytes(13);
boolean reviewed = set.getBoolean(14);
MavericksBuildWrapper build = new MavericksBuildWrapper(buildId, uuid, lastName, theme, votes, place, dateStamp, schematic, particles, reviewed);
MavericksApprovedWrapper approved = new MavericksApprovedWrapper(build, approvedDate, approvedBy, display, firstDisplayed);
list.add(approved);
}
return list;
}
catch (SQLException e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
public CompletableFuture<Boolean> setDisplay(boolean display, long... buildids)
{
if(buildids.length == 0) return null;
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
String where = "WHERE BuildId=?";
for(int i = 1; i < buildids.length; i++)
{
where += " OR BuildId=?";
}
PreparedStatement stmt = conn.prepareStatement("UPDATE " + TABLE_APPROVED + " SET Display=? " + where);
stmt.setBoolean(1, display);
for(int i = 0; i < buildids.length; i++)
{
stmt.setLong(2+i, buildids[i]);
}
return stmt.executeUpdate() > 0;
}
catch(SQLException e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
public CompletableFuture<Boolean> setDisplayDate(long buildid)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
PreparedStatement stmt = conn.prepareStatement("UPDATE " + TABLE_APPROVED + " SET FirstDisplayed=? WHERE BuildId=?");
// stmt.setDate(1, new Date(System.currentTimeMillis()));
stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
stmt.setLong(2, buildid);
return stmt.executeUpdate() > 0;
}
catch(Exception e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
}

View File

@ -0,0 +1,57 @@
package mineplex.core.mavericks;
import java.util.UUID;
/**
* A wrapper class to SQL data in the mavericksMasterBuildersApproved SQL table
*/
public class MavericksApprovedWrapper
{
private final MavericksBuildWrapper _build;
private final long _approvedDate;
private final UUID _approvedBy;
private final boolean _display;
private Long _firstDisplayed;
public MavericksApprovedWrapper(MavericksBuildWrapper build, long approvedDate, UUID approvedBy, boolean display, Long firstDisplayed)
{
_build = build;
_approvedDate = approvedDate;
_approvedBy = approvedBy;
_display = display;
_firstDisplayed = firstDisplayed;
}
public MavericksBuildWrapper getBuild()
{
return _build;
}
public long getApprovedDate()
{
return _approvedDate;
}
public UUID getApprovedBy()
{
return _approvedBy;
}
public Long getFirstDisplayed()
{
return _firstDisplayed;
}
public void setFirstDisplayed(Long firstDisplayed)
{
_firstDisplayed = firstDisplayed;
}
public boolean isDisplay()
{
return _display;
}
}

View File

@ -0,0 +1,133 @@
package mineplex.core.mavericks;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import mineplex.serverdata.database.DBPool;
/**
* Repository for Mavericks-MasterBuilders SQL game data
* -
* Table to back this repository may be created with
*
CREATE TABLE IF NOT EXISTS mavericksMasterBuildersBuilds (
accountId INT NOT NULL,
BuildTheme VARCHAR(255) NOT NULL,
Points DOUBLE NOT NULL,
Place INT NOT NULL,
Date BIGINT NOT NULL,
Schematic BLOB,
Reviewed TINYINT,
PRIMARY KEY (accountId,Date),
FOREIGN KEY (accountId) REFERENCES accounts(id) ON DELETE NO ACTION ON UPDATE NO ACTION
);
*/
public class MavericksBuildRepository
{
private static final String TABLE = "mavericksMasterBuildersBuilds";
public CompletableFuture<List<MavericksBuildWrapper>> getToReview(boolean onlyUnreviewed, int limit, int offset)
{
return getToReview(onlyUnreviewed, limit, offset, true);
}
public CompletableFuture<List<MavericksBuildWrapper>> getToReview(boolean onlyUnreviewed, int limit, int offset, boolean parseData)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
String filter = onlyUnreviewed ? "WHERE Reviewed=0 " : "";
PreparedStatement stmt = conn.prepareStatement("SELECT BuildId," +
"(SELECT uuid from accounts WHERE accounts.id=" + TABLE + ".accountId)," +
"(SELECT name from accounts WHERE accounts.id=" + TABLE + ".accountId)," +
"BuildTheme,Points,Place,Date,Schematic,Particles,Reviewed FROM " + TABLE + " " + filter +
" ORDER BY Points DESC LIMIT " + limit + " OFFSET " + offset);
ResultSet set = stmt.executeQuery();
List<MavericksBuildWrapper> list = new ArrayList<>();
while (set.next())
{
long buildId = set.getLong(1);
UUID uuid = UUID.fromString(set.getString(2));
String lastName = set.getString(3);
String theme = set.getString(4);
int votes = set.getInt(5);
int place = set.getInt(6);
long dateStamp = set.getLong(7);
byte[] schematic = set.getBytes(8);
byte[] particles = set.getBytes(9);
boolean reviewed = set.getBoolean(10);
MavericksBuildWrapper data = new MavericksBuildWrapper(buildId, uuid, lastName, theme, votes, place, dateStamp, schematic, particles, reviewed);
if(parseData)
{
data.getParticles();
data.getSchematic();
}
list.add(data);
}
return list;
}
catch (SQLException e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
public CompletableFuture<Boolean> setReviewed(long buildId, boolean reviewed)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
PreparedStatement stmt = conn.prepareStatement("UPDATE " + TABLE + " SET Reviewed=? WHERE BuildId=?");
stmt.setBoolean(1, reviewed);
stmt.setLong(2, buildId);
return stmt.executeUpdate() > 0;
}
catch(SQLException e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
public CompletableFuture<Boolean> add(MavericksBuildWrapper data)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
PreparedStatement stmt = conn.prepareStatement("REPLACE INTO " + TABLE + " (accountId, BuildTheme, Points, Place, Date, Schematic, Particles) SELECT accounts.id, ?, ?, ?, ?, ?, ? FROM accounts WHERE uuid=?");
stmt.setString(1, data.getTheme());
stmt.setDouble(2, data.getPoints());
stmt.setInt(3, data.getPlace());
stmt.setLong(4, data.getDateStamp());
stmt.setBytes(5, data.getSchematicBytes());
stmt.setBytes(6, data.getParticlesRaw());
stmt.setString(7, data.getUUID().toString());
return stmt.executeUpdate() > 0;
}
catch(SQLException e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
}

View File

@ -0,0 +1,176 @@
package mineplex.core.mavericks;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.util.Vector;
import com.java.sk89q.jnbt.CompoundTag;
import com.java.sk89q.jnbt.NBTUtils;
import com.java.sk89q.jnbt.Tag;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.UtilParticle.ParticleType;
/**
* A simple wrapper class for Mavericks-MasterBuilders SQL data
*/
public class MavericksBuildWrapper
{
private final long _buildId;
private final UUID _uuid;
private final String _theme;
private final double _points;
private final int _place;
private final long _dateStamp;
private final byte[] _schematic;
private Schematic _schematicCache;
private final byte[] _particles;
private Map<Vector, ParticleType> _particlesCache;
private boolean _reviewed;
private final String _name;
public MavericksBuildWrapper(long buildId, UUID uuid, String name, String theme, double points, int place, long dateStamp,
byte[] schematic, byte[] particles, boolean reviewed)
{
this._buildId = buildId;
this._uuid = uuid;
this._name = name;
this._theme = theme;
this._points = points;
this._place = place;
this._dateStamp = dateStamp;
this._schematic = schematic;
this._particles = particles;
this._reviewed = reviewed;
}
public MavericksBuildWrapper(long buildId, UUID uuid, String theme, double points, int place, long dateStamp,
byte[] schematic, byte[] particles, boolean reviewed)
{
this(buildId, uuid, null, theme, points, place, dateStamp, schematic, particles, reviewed);
}
public long getBuildId()
{
return _buildId;
}
public UUID getUUID()
{
return _uuid;
}
public String getName()
{
return _name;
}
public boolean hasNameSet()
{
return _name != null;
}
public String getTheme()
{
return _theme;
}
public double getPoints()
{
return _points;
}
public int getPlace()
{
return _place;
}
public long getDateStamp()
{
return _dateStamp;
}
public byte[] getSchematicBytes()
{
return _schematic;
}
public boolean isReviewed()
{
return _reviewed;
}
public void setReviewed(boolean reviewed)
{
_reviewed = reviewed;
}
public Schematic getSchematic()
{
if(_schematicCache != null) return _schematicCache;
try
{
return _schematicCache = UtilSchematic.loadSchematic(_schematic);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
public boolean hasParticles()
{
return _particles != null && _particles.length > 0;
}
public byte[] getParticlesRaw()
{
return _particles;
}
public Map<Vector, ParticleType> getParticles()
{
if(_particlesCache != null) return _particlesCache;
Map<Vector, ParticleType> map = new HashMap<>();
if(!hasParticles()) return map;
try
{
CompoundTag tag = (CompoundTag) NBTUtils.getFromBytesCompressed(_particles).getTag();
for(Entry<String, Tag> e : tag.getValue().entrySet())
{
CompoundTag parent = (CompoundTag) e.getValue();
Vector v = NBTUtils.getVector(parent);
ParticleType particle = ParticleType.valueOf(parent.getString("particle"));
while(map.containsKey(v)) v.add(new Vector(0.00000001, 0, 0));
map.put(v, particle);
}
}
catch (Exception e)
{
e.printStackTrace();
}
return _particlesCache = map;
}
@Override
public String toString()
{
return "MavericksBuildWrapper[uuid='" + _uuid + "',theme='" + _theme + "',points=" + _points + ",place=" + _place
+ ",date=" + _dateStamp + ",Schematic=ByteArray[" + _schematic.length + "]]";
}
}

View File

@ -27,7 +27,25 @@ public class Npc
_npcManager = npcManager;
_databaseRecord = databaseRecord;
_location = new Location(Bukkit.getWorld(getDatabaseRecord().getWorld()), getDatabaseRecord().getX(), getDatabaseRecord().getY(), getDatabaseRecord().getZ());
Double yaw = getDatabaseRecord().getYaw();
Double pitch = getDatabaseRecord().getPitch();
if(yaw == null)
{
yaw = 0d;
}
if(pitch == null)
{
pitch = 0d;
}
_location = new Location(Bukkit.getWorld(getDatabaseRecord().getWorld()),
getDatabaseRecord().getX(),
getDatabaseRecord().getY(),
getDatabaseRecord().getZ(),
yaw.floatValue(),
pitch.floatValue());
if (getDatabaseRecord().getInfo() == null)
_info = null;

View File

@ -264,6 +264,8 @@ public class NpcManager extends MiniPlugin
npcsRecord.setX(player.getLocation().getX());
npcsRecord.setY(player.getLocation().getY());
npcsRecord.setZ(player.getLocation().getZ());
npcsRecord.setYaw((double)player.getEyeLocation().getYaw());
npcsRecord.setPitch((double)player.getEyeLocation().getPitch());
npcsRecord.setRadius(radius);
npcsRecord.setEntityType(entityType.name());
npcsRecord.setAdult(adult);
@ -422,8 +424,6 @@ public class NpcManager extends MiniPlugin
if (npc.getFailedAttempts() >= 10 || npc.getDatabaseRecord().getRadius() == 0)
{
Location location = npc.getLocation();
location.setPitch(entity.getLocation().getPitch());
location.setYaw(entity.getLocation().getYaw());
entity.teleport(location);
entity.setVelocity(new Vector(0, 0, 0));
npc.setFailedAttempts(0);
@ -461,8 +461,6 @@ public class NpcManager extends MiniPlugin
if (!entity.isDead() && entity.isValid())
{
Location location = npc.getLocation();
location.setPitch(entity.getLocation().getPitch());
location.setYaw(entity.getLocation().getYaw());
entity.teleport(location);
entity.setVelocity(new Vector(0, 0, 0));

View File

@ -244,7 +244,7 @@ public class PartyRedisManager
{
player1.leaveVehicle();
player1.eject();
_plugin.getPortal().sendPlayerToServer(player1, server, true);
_plugin.getPortal().sendPlayer(player1, server);
});
_plugin.removeParty(party);
}

View File

@ -37,7 +37,7 @@ public class PartyInvitesMenu extends PartyMenu
private final int INV_SIZE = 54;
private final int SLOTS_PER_PAGE = 27;
private final int STARTING_SLOT = 18;
private final int STARTING_SLOT = 19;
private final int BACK_BUTTON_SLOT = 0;
private final int DENY_ALL_BUTTON_SLOW = 4;
private final int FILTER_BUTTON_SLOT = 8;

View File

@ -9,7 +9,6 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.event.PartySendToServerEvent;
import mineplex.core.portal.Commands.SendCommand;
@ -104,7 +103,6 @@ public class Portal extends MiniPlugin
Party party = event.getParty();
if(!party.getOwner().equalsIgnoreCase(player.getName()))
{
Lang.NOT_OWNER_SERVER.send(player);
return;
}
sendParty(party);
@ -215,7 +213,7 @@ public class Portal extends MiniPlugin
sendPlayerToServer(player, "Lobby");
}
private void sendPlayer(final Player player, String serverName)
public void sendPlayer(final Player player, String serverName)
{
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);

View File

@ -0,0 +1,26 @@
package mineplex.core.powerplayclub;
public class PPCPlayerData {
private boolean _subscribed;
private boolean _claimed;
public void setSubscribed(boolean subscribed)
{
_subscribed = subscribed;
}
public void setClaimed(boolean claimed)
{
_claimed = claimed;
}
public boolean hasClaimed()
{
return _claimed;
}
public boolean hasSubscribed()
{
return _subscribed;
}
}

View File

@ -0,0 +1,154 @@
package mineplex.core.powerplayclub;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.serverdata.database.DBPool;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.*;
import java.time.LocalDate;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
private final CoreClientManager _clientManager;
public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager) {
super("PowerPlayClubRepository", plugin);
_clientManager = clientManager;
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor() {
@Override
public String getName() {
return "PPC Claim Grabber";
}
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException {
PowerPlayClubRepository.this.Get(uuid).setClaimed(resultSet.next());
}
@Override
public String getQuery(int accountId, String uuid, String name) {
return "SELECT * FROM powerPlayClaims WHERE accountId = " + accountId + ";";
}
});
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor() {
@Override
public String getName() {
return "PPC Subscription Grabber";
}
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException {
PowerPlayClubRepository.this.Get(uuid).setSubscribed(resultSet.next());
}
@Override
public String getQuery(int accountId, String uuid, String name) {
return "SELECT * FROM powerPlaySubs WHERE accountId = " + accountId + ";";
}
});
}
public CompletableFuture<Void> addSubscription(int accountId, LocalDate date, String duration)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("INSERT INTO powerPlaySubs (accountId, startDate, duration) VALUES (?, ?, ?)");
statement.setInt(1, accountId);
statement.setDate(2, Date.valueOf(date));
statement.setString(3, duration);
statement.executeUpdate();
} catch (SQLException e)
{
e.printStackTrace();
}
return null;
});
}
public CompletableFuture<Boolean> attemptClaim(Player player)
{
int accountId = _clientManager.Get(player).getAccountId();
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
LocalDate date = LocalDate.now();
PreparedStatement statement = connection.prepareStatement("INSERT IGNORE INTO powerPlayClaims (accountId, claimMonth, claimYear) VALUES (?, ?, ?)");
statement.setInt(1, accountId);
statement.setInt(2, date.getMonthValue());
statement.setInt(3, date.getYear());
return statement.executeUpdate() == 1;
} catch (SQLException e)
{
e.printStackTrace();
}
return false;
});
}
public boolean alreadyClaimed(Player player)
{
return Get(player).hasClaimed();
}
public boolean canClaim(Player player)
{
return Get(player).hasSubscribed() && !Get(player).hasClaimed();
}
public CompletableFuture<Boolean> hasSubscription(int accountId)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlaySubs WHERE accountId = ?");
statement.setInt(1, accountId);
return statement.executeQuery().next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
});
}
public CompletableFuture<Boolean> hasClaimed(int accountId)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlayClaims WHERE accountId = ?");
statement.setInt(1, accountId);
return statement.executeQuery().next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
});
}
@Override
protected PPCPlayerData addPlayer(UUID uuid) {
return new PPCPlayerData();
}
}

View File

@ -0,0 +1,147 @@
package mineplex.core.powerplayclub;
import mineplex.core.common.util.BukkitFuture;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.data.Item;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.time.Month;
import java.time.Year;
import java.util.*;
public class PowerPlayClubRewards
{
private static final Map<RewardMonth, List<PowerPlayClubItem>> rewards = new HashMap<>();
static
{
setRewards(2016, Month.SEPTEMBER, new PowerPlayClubItem("Squid Morph", 1, new ItemStack(Material.INK_SACK)));
}
public static List<PowerPlayClubItem> septemberItems() // TODO: figure this out
{
return rewards.values().iterator().next();
}
private static void setRewards(int year, Month month, PowerPlayClubItem... items)
{
rewards.put(new RewardMonth(Year.of(year), month), Arrays.asList(items));
}
private static class RewardMonth
{
private final Year year;
private final Month month;
static RewardMonth of(Year year, Month month)
{
return new RewardMonth(year, month);
}
RewardMonth(Year year, Month month)
{
this.year = year;
this.month = month;
}
@Override
public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) return false;
RewardMonth that = (RewardMonth) obj;
return Objects.equals(this.year, that.year) && Objects.equals(this.month, that.month);
}
@Override
public int hashCode() {
return Objects.hash(year, month);
}
}
public static class PowerPlayClubItem
{
private final String _prize;
private final int _amount;
private final ItemStack _display;
public PowerPlayClubItem(String prize, int amount, ItemStack display)
{
_prize = prize;
_amount = amount;
_display = display;
}
public String getPrize()
{
return _prize;
}
public int getAmount()
{
return _amount;
}
public ItemStack getDisplay()
{
return _display;
}
}
public static void giveAllItems(Player player, InventoryManager manager, PowerPlayClubRepository repo)
{
UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription.."));
repo.attemptClaim(player).thenCompose(BukkitFuture.accept(success ->
{
if (!success)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
return;
}
repo.Get(player).setClaimed(true);
for (PowerPlayClubItem item : septemberItems()) // TODO: figure this out
{
Item fItem = manager.getItem(item.getPrize());
if (fItem == null)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
}
else
{
manager.addItemToInventory(player, fItem.Name, 1);
UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + F.elem(item.getPrize()) + "."));
}
}
Item gameAmplifier = manager.getItem("Game Booster");
if (gameAmplifier == null)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
}
else
{
manager.addItemToInventory(player, gameAmplifier.Name, 2);
UtilPlayer.message(player, F.main("Power Play Club", "You received 2x " + F.elem("Game Boosters") + "."));
}
Item omegaChest = manager.getItem("Omega Chest");
if (omegaChest == null)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
}
else
{
manager.addItemToInventory(player, omegaChest.Name, 1);
UtilPlayer.message(player, F.main("Power Play Club", "You received 1x " + F.elem("Omega Chest") + "."));
}
}));
}
}

View File

@ -38,9 +38,11 @@ public enum Preference
CLAN_TIPS(true, PreferenceCategory.MISC, Material.IRON_SWORD, "Show Clan Tips"),
HUB_MUSIC(true, PreferenceCategory.MISC, Material.NOTE_BLOCK, "Hub Music"),
//AUTO_JOIN_NEXT_GAME(true, PreferenceCategory.GAME_PLAY, Material.DIAMOND_SWORD, "Auto Join Next Game"),
//COUNTDOWN_ON_CLICK(true, PreferenceCategory.GAME_PLAY, Material.EMERALD, "Countdown to Join"),
AUTO_JOIN_NEXT_GAME(true, PreferenceCategory.GAME_PLAY, Material.DIAMOND_SWORD, "Auto Join Next Game", "Feel like playing again?", "Enable this, and when you're out", "a 15 second timer will start", "when it ends, it'll send you", "to another game!"),
DISABLE_WARNING(true, PreferenceCategory.GAME_PLAY, Material.BARRIER, "Disable Automatic Warning", "Know what you're doing?", "Disable this to not receive", "a message warning you about Auto-Join"),
COUNTDOWN_ON_CLICK(false, PreferenceCategory.GAME_PLAY, Material.WATCH, "Countdown to Join", "See that fancy text when you're out?", "If you click it, and this is enabled", "a 15 second time will countdown", "until you are sent to a new game"),
;
private static final Map<Integer, Preference> PREFERENCE_MAP = Maps.newHashMap();
private static final Map<PreferenceCategory, List<Preference>> PREFERENCES_BY_CATEGORY = Maps.newHashMap();

View File

@ -13,7 +13,7 @@ public enum PreferenceCategory
USER("User", Material.PAPER),
EXCLUSIVE("Exclusive", Material.DIAMOND),
//GAME_PLAY("Game Mechanic", Material.REDSTONE_COMPARATOR),
GAME_PLAY("Game Mechanic", Material.REDSTONE_COMPARATOR),
MISC("Miscellaneous", Material.COMPASS),
FRIEND("Friend", Material.CHEST),
;

View File

@ -21,15 +21,6 @@ public class PreferenceMainMenu extends Menu<PreferencesManager>
private final int INV_SIZE_MAX = 54;
private final int INV_SIZE_MIN = 45;
private final int[] SLOTS_MAX = {
20, 22, 24, 30, 32
};
private final int[] SLOTS_MIN = {
19, 21, 23, 25
};
public PreferenceMainMenu(PreferencesManager plugin)
{
super("My Preferences", plugin);
@ -50,7 +41,7 @@ public class PreferenceMainMenu extends Menu<PreferencesManager>
list.remove(PreferenceCategory.EXCLUSIVE);
}
int[] slots = UtilUI.getIndicesFor(list.size(), 1, 4, 1);
int[] slots = UtilUI.getIndicesFor(list.size(), 2, 4, 0);
int size = list.size();

View File

@ -1,5 +1,6 @@
package mineplex.core.preferences.ui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
@ -12,6 +13,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
*
*/
@ -32,15 +35,28 @@ public class PreferenceButton extends Button<PreferencesManager>
Material icon = preference.getIcon();
boolean head = icon == Material.SKULL_ITEM;
List<String> lore = Lists.newArrayList();
if(preference.getLore() != null)
{
lore.add(" ");
for(String s : preference.getLore())
{
lore.add(C.cGray + s);
}
}
_disabled = new ItemBuilder(preference.getIcon())
.setTitle(C.cRed + preference.getName())
.setLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable")
.addLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable")
.addLores(lore)
.setData(head ? (short) 3 : 0)
.build();
_enabled = new ItemBuilder(preference.getIcon())
.setTitle(C.cGreen + preference.getName())
.setLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable")
.addLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable")
.addLores(lore)
.setData(head ? (short) 3 : 0)
.build();

View File

@ -20,7 +20,7 @@ public class PlayerKitDataManager
public PlayerKit get(UUID uuid)
{
return _dataMapAccountUUID.getOrDefault(uuid, new PlayerKit(uuid));
return _dataMapAccountUUID.get(uuid);
}
public void add(PlayerKit playerKit)

View File

@ -10,6 +10,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.banner.CountryFlag;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane;
import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid;
import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald;
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
@ -31,6 +32,7 @@ import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst;
import mineplex.core.gadget.gadgets.death.shadow.DeathShadow;
import mineplex.core.gadget.gadgets.death.vampire.DeathBlood;
import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant;
import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane;
import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings;
import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald;
import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom;
@ -43,28 +45,8 @@ import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood;
import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
import mineplex.core.gadget.gadgets.hat.HatType;
import mineplex.core.gadget.gadgets.item.ItemBatGun;
import mineplex.core.gadget.gadgets.item.ItemBow;
import mineplex.core.gadget.gadgets.item.ItemCoal;
import mineplex.core.gadget.gadgets.item.ItemEtherealPearl;
import mineplex.core.gadget.gadgets.item.ItemFirework;
import mineplex.core.gadget.gadgets.item.ItemFleshHook;
import mineplex.core.gadget.gadgets.item.ItemFreezeCannon;
import mineplex.core.gadget.gadgets.item.ItemLovePotion;
import mineplex.core.gadget.gadgets.item.ItemMelonLauncher;
import mineplex.core.gadget.gadgets.item.ItemPaintballGun;
import mineplex.core.gadget.gadgets.item.ItemPartyPopper;
import mineplex.core.gadget.gadgets.item.ItemSnowball;
import mineplex.core.gadget.gadgets.item.ItemTNT;
import mineplex.core.gadget.gadgets.morph.MorphBat;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphSnowman;
import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
import mineplex.core.gadget.gadgets.morph.MorphVillager;
import mineplex.core.gadget.gadgets.item.*;
import mineplex.core.gadget.gadgets.morph.*;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitHelmet;
@ -73,13 +55,7 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitBoots;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel;
import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons;
import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal;
import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie;
import mineplex.core.gadget.gadgets.particle.ParticleYinYang;
import mineplex.core.gadget.gadgets.particle.*;
import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane;
import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart;
import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald;
@ -91,36 +67,19 @@ import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime;
import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood;
import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike;
import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian;
import mineplex.core.gadget.gadgets.wineffect.*;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.HatGadget;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.Mount;
import mineplex.core.mount.types.MountBabyReindeer;
import mineplex.core.mount.types.MountCart;
import mineplex.core.mount.types.MountFreedomHorse;
import mineplex.core.mount.types.MountFrost;
import mineplex.core.mount.types.MountMule;
import mineplex.core.mount.types.MountSlime;
import mineplex.core.mount.types.MountUndead;
import mineplex.core.mount.types.*;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.rewards.ExperienceReward;
import mineplex.core.reward.rewards.GemReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.RankReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
import mineplex.core.reward.rewards.*;
import mineplex.core.stats.StatsManager;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -179,395 +138,7 @@ public class RewardManager
addUncommon();
addRare();
addLegendary();
// addCommon(donationManager, inventoryManager, petManager, statsManager, commonValueMin, commonValueMax);
// addUncommon(donationManager, inventoryManager, petManager, statsManager, uncommonValueMin, uncommonValueMax);
// addRare(donationManager, inventoryManager, petManager, statsManager, rareValueMin, rareValueMax);
// addLegendary(donationManager, inventoryManager, petManager, statsManager, legendValueMin, legendValueMax);
}
/*
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.COMMON;
// Coins
if (_carlSpinner)
{
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 25, 0, rarity));
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 25, 0, rarity));
}
else
{
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 5, rarity));
}
//Increase Value
if (_doubleGadgetValue)
{
minValue *= 2;
maxValue *= 2;
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Cupid's Arrows", "Cupid's Arrows", 1, 5,
new ItemStack(Material.BOW, 1), rarity, 300, 0));
// Pets
addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Cow Pet", "Cow",
EntityType.COW, rarity, 50, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Sheep Pet", "Sheep",
EntityType.SHEEP, rarity, 50, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Mooshroom Pet", "Mooshroom",
EntityType.MUSHROOM_COW, rarity, 50, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Pig Pet", "Pig",
EntityType.PIG, rarity, 50, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Ocelot Pet", "Cat",
EntityType.OCELOT, rarity, 50, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Chicken Pet", "Chicken",
EntityType.CHICKEN, rarity, 50, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Wolf Pet", "Dog",
EntityType.WOLF, rarity, 50, _uncommonShards));
// Discs
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "13 Disc", "13 Disc",
new ItemStack(2256), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Cat Disc", "Cat Disc",
new ItemStack(2257), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Blocks Disc", "Blocks Disc",
new ItemStack(2258), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Chirp Disc", "Chirp Disc",
new ItemStack(2259), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Far Disc", "Far Disc",
new ItemStack(2260), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Mall Disc", "Mall Disc",
new ItemStack(2261), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Mellohi Disc", "Mellohi Disc",
new ItemStack(2262), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Stal Disc", "Stal Disc",
new ItemStack(2263), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Strad Disc", "Strad Disc",
new ItemStack(2264), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Ward Disc", "Ward Disc",
new ItemStack(2265), rarity, 10, _uncommonShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Wait Disc", "Wait Disc",
new ItemStack(2267), rarity, 10, _uncommonShards));
// Mounts
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Mule", "Mount Mule",
new ItemStack(Material.HAY_BLOCK), rarity, 4, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Minecart", "Minecart",
new ItemStack(Material.MINECART), rarity, 3, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Slime", "Slime Mount",
new ItemStack(Material.SLIME_BALL), rarity, 2, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Glacial Steed", "Glacial Steed",
new ItemStack(Material.SNOW_BALL), rarity, 1, _rareShards));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Coal", "Coal", 50, 100,
new ItemStack(Material.COAL), rarity, 10, 0));
addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Snowballs", "Snowball", 5, 20,
new ItemStack(Material.SNOW_BALL), rarity, 10, 0));
// Gadgets
addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun",
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
new ItemStack(Material.GOLD_BARDING), rarity, 10, 0));
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.FIREWORK), rarity, 10, 0));
addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.MELON_BLOCK), rarity, 10, 0));
addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook",
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
new ItemStack(Material.getMaterial(131)), rarity, 10, 0));
addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl",
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
new ItemStack(Material.ENDER_PEARL), rarity, 10, 0));
addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.IRON_BARDING), rarity, 10, 0));
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.TNT), rarity, 10, 0));
}
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.UNCOMMON;
// Coins
if (_carlSpinner)
{
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 1200, 0, rarity));
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1200, rarity));
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 1200, 0, rarity));
}
else
{
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
}
//Increase Value
if (_doubleGadgetValue)
{
minValue *= 2;
maxValue *= 2;
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Love Potion", "Love Potion", 1, 1,
new ItemStack(Material.POTION, 1), rarity, 100, 0));
addReward(RewardPool.Type.VALENTINES_GIFT, new TreasureShardReward(_clientManager, donationManager, 100, 200, 25, rarity));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Freeze Cannon", "Freeze Cannon", 5, 10,
new ItemStack(Material.ICE), rarity, 10, 0));
addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Party Popper", "Party Popper", 5, 10,
new ItemStack(Material.GOLDEN_CARROT), rarity, 10, 0));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "Present", "Present",
SkinData.PRESENT.getSkull(), rarity, 5, 100));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "Snowman Head", "Snowman Head",
SkinData.SNOWMAN.getSkull(), rarity, 5, 100));
// Gadgets
addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun",
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
new ItemStack(Material.GOLD_BARDING), rarity, 250, 0));
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.FIREWORK), rarity, 250, 0));
addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.MELON_BLOCK), rarity, 250, 0));
addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook",
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
new ItemStack(Material.getMaterial(131)), rarity, 250, 0));
addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl",
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
new ItemStack(Material.ENDER_PEARL), rarity, 250, 0));
addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.IRON_BARDING), rarity, 250, 0));
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.TNT), rarity, 250, 0));
// Pets
addReward(new PetReward(petManager, inventoryManager, donationManager, "Cow Pet", "Cow",
EntityType.COW, rarity, 500, _uncommonShards));
addReward(new PetReward(petManager, inventoryManager, donationManager, "Sheep Pet", "Sheep",
EntityType.SHEEP, rarity, 333, _uncommonShards));
addReward(new PetReward(petManager, inventoryManager, donationManager, "Mooshroom Pet", "Mooshroom",
EntityType.MUSHROOM_COW, rarity, 200, _uncommonShards));
addReward(new PetReward(petManager, inventoryManager, donationManager, "Pig Pet", "Pig",
EntityType.PIG, rarity, 200, _uncommonShards));
addReward(new PetReward(petManager, inventoryManager, donationManager, "Ocelot Pet", "Cat",
EntityType.OCELOT, rarity, 167, _uncommonShards));
addReward(new PetReward(petManager, inventoryManager, donationManager, "Chicken Pet", "Chicken",
EntityType.CHICKEN, rarity, 143, _uncommonShards));
addReward(new PetReward(petManager, inventoryManager, donationManager, "Wolf Pet", "Dog",
EntityType.WOLF, rarity, 125, _uncommonShards));
// Music Discs
addReward(new UnknownPackageReward(donationManager, "Music Disc", "13 Disc", "13 Disc",
new ItemStack(2256), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Cat Disc", "Cat Disc",
new ItemStack(2257), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Blocks Disc", "Blocks Disc",
new ItemStack(2258), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Chirp Disc", "Chirp Disc",
new ItemStack(2259), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Far Disc", "Far Disc",
new ItemStack(2260), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Mall Disc", "Mall Disc",
new ItemStack(2261), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Mellohi Disc", "Mellohi Disc",
new ItemStack(2262), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Stal Disc", "Stal Disc",
new ItemStack(2263), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Strad Disc", "Strad Disc",
new ItemStack(2264), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Ward Disc", "Ward Disc",
new ItemStack(2265), rarity, 25, _uncommonShards));
addReward(new UnknownPackageReward(donationManager, "Music Disc", "Wait Disc", "Wait Disc",
new ItemStack(2267), rarity, 25, _uncommonShards));
}
public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.RARE;
// Coins
if (_carlSpinner)
{
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 150, 0, rarity));
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 150, rarity));
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 150, 0, rarity));
}
else
{
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Companion Hat", "Companion",
SkinData.COMPANION_CUBE.getSkull(), rarity, 100, 0));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Lovestruck Hat", "Lovestruck",
SkinData.LOVESTRUCK.getSkull(), rarity, 100, 0));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Secret Package Hat", "Secret Package",
SkinData.SECRET_PACKAGE.getSkull(), rarity, 100, 0));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Teddy Bear Hat", "Teddy Bear",
SkinData.TEDDY_BEAR.getSkull(), rarity, 100, 0));
addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Love Potion", "Love Potion", 1, 1,
new ItemStack(Material.POTION, 1), rarity, 1, 0));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "Santa", "Santa",
SkinData.SANTA.getSkull(), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new PetReward(petManager, inventoryManager, donationManager, "Elf", "Christmas Elf",
EntityType.VILLAGER, rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Candy Cane Remains", "Candy Cane Remains",
new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Particles", "Crushed Candy Cane", "Crushed Candy Cane",
new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Arrow Effect", "Candy Cane Arrows", "Candy Cane Arrows",
new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Candy Cane Blast", "Candy Cane Blast",
new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
// Mounts
addReward(new UnknownPackageReward(donationManager, "Mount", "Mule", "Mount Mule",
new ItemStack(Material.HAY_BLOCK), rarity, 200, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Mount", "Minecart", "Minecart",
new ItemStack(Material.MINECART), rarity, 100, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Mount", "Slime", "Slime Mount",
new ItemStack(Material.SLIME_BALL), rarity, 67, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Mount", "Glacial Steed", "Glacial Steed",
new ItemStack(Material.SNOW_BALL), rarity, 50, _rareShards));
// Morphs
addReward(new UnknownPackageReward(donationManager, "Morph", "Cow", "Cow Morph",
new ItemStack(Material.LEATHER), rarity, 167, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Morph", "Villager", "Villager Morph",
new ItemStack(Material.EMERALD), rarity, 83, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Morph", "Chicken", "Chicken Morph",
new ItemStack(Material.FEATHER), rarity, 50, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Morph", "Enderman", "Enderman Morph",
new ItemStack(Material.ENDER_PEARL), rarity, 33, _rareShards));
// Costumes
addReward(new UnknownPackageReward(donationManager, "Costume", "Rave Hat", "Rave Hat",
new ItemStack(Material.LEATHER_HELMET), rarity, 30, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Costume", "Rave Shirt", "Rave Shirt",
new ItemStack(Material.LEATHER_CHESTPLATE), rarity, 30, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Costume", "Rave Pants", "Rave Pants",
new ItemStack(Material.LEATHER_LEGGINGS), rarity, 30, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Costume", "Rave Boots", "Rave Boots",
new ItemStack(Material.LEATHER_BOOTS), rarity, 30, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Costume", "Space Helmet", "Space Helmet",
new ItemStack(Material.GLASS), rarity, 50, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Costume", "Space Jacket", "Space Jacket",
new ItemStack(Material.GOLD_CHESTPLATE), rarity, 50, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Costume", "Space Pants", "Space Pants",
new ItemStack(Material.GOLD_LEGGINGS), rarity, 50, _rareShards));
addReward(new UnknownPackageReward(donationManager, "Costume", "Space Boots", "Space Boots",
new ItemStack(Material.GOLD_BOOTS), rarity, 50, _rareShards));
}
public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.LEGENDARY;
// Coins
if (_carlSpinner)
{
addReward(new GemReward(donationManager, (int)minValue, (int)maxValue, 10, 0, rarity));
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 10, rarity));
addReward(new ExperienceReward(statsManager, (int)minValue*5, (int)maxValue*5, 10, 0, rarity));
}
else
{
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
}
// Valentines
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Arrow Effect", "Arrows of Cupid", "Arrows of Cupid",
new ItemStack(Material.POTION), rarity, 100, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Death Effect", "Broken Hearted", "Broken Hearted",
new ItemStack(Material.POTION), rarity, 100, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Jump Effect", "Wings of Love", "Wings of Love",
new ItemStack(Material.POTION), rarity, 100, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Particles", "Heartfelt Halo", "Heartfelt Halo",
new ItemStack(Material.POTION), rarity, 100, _rareShards));
addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Love Potion", "Love Potion", 1, 1,
new ItemStack(Material.POTION, 1), rarity, 2, 0));
// Christmas
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "The Grinch", "The Grinch",
SkinData.THE_GRINCH.getSkull(), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Morph", "Olaf", "Olaf Morph",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Mount", "Glacial Steed", "Glacial Steed",
new ItemStack(Material.SADDLE), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Mount", "Baby Reindeer", "Baby Reindeer",
new ItemStack(Material.GOLDEN_CARROT), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Particles", "Wind of the Frost Lord", "Wind of the Frost Lord",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Arrow Effect", "Arrows of the Frost Lord", "Arrows of the Frost Lord",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Gust of the Frost Lord", "Gust of the Frost Lord",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Fall of the Frost Lord", "Fall of the Frost Lord",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
// Mounts
addReward(new UnknownPackageReward(donationManager, "Mount", "Infernal Horror", "Infernal Horror",
new ItemStack(Material.BONE), rarity, 33, _legendaryShards));
// Morphs
addReward(new UnknownPackageReward(donationManager, "Morph", "Bat", "Bat Morph",
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), rarity, 25, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Morph", "Block", "Block Morph",
new ItemStack(Material.EMERALD_BLOCK), rarity, 20, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Morph", "Big Larry", "Big Larry Morph",
new ItemStack(Material.SLIME_BALL), rarity, 10, _legendaryShards));
// Particles
addReward(new UnknownPackageReward(donationManager, "Particles", "Shadow Walk", "Shadow Walk",
new ItemStack(Material.LEATHER_BOOTS), rarity, 33, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Particles", "Enchanted", "Enchanted",
new ItemStack(Material.BOOK), rarity, 25, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Particles", "Flame Rings", "Flame Rings",
new ItemStack(Material.BLAZE_POWDER), rarity, 17, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Particles", "Rain Cloud", "Rain Cloud",
new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), rarity, 13, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Particles", "Blood Helix", "Blood Helix",
new ItemStack(Material.REDSTONE), rarity, 10, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Particles", "Green Rings", "Green Ring",
new ItemStack(Material.EMERALD), rarity, 8, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Particles", "Flame Fairy", "Flame Fairy",
new ItemStack(Material.APPLE), rarity, 4, _legendaryShards));
addReward(new UnknownPackageReward(donationManager, "Particles", "Heart", "I Heart You",
new ItemStack(Material.BLAZE_POWDER), rarity, 2, _legendaryShards));
}
*/
public void addCommon()
{
@ -642,6 +213,21 @@ public class RewardManager
// WINTER Gadgets
addHat(Type.WINTER_HOLIDAY, HatType.Present, rarity, 5);
addHat(Type.WINTER_HOLIDAY, HatType.Snowman, rarity, 5);
// Omega items
addMusicReward(Type.OMEGA, "Block Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Cat Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Chirp Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Far Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Mall Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Mellohi Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Stal Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Stard Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Wait Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Ward Disk", rarity, 25);
addHat(Type.OMEGA, HatType.Present, rarity, 5);
addHat(Type.OMEGA, HatType.Snowman, rarity, 5);
}
@ -737,6 +323,67 @@ public class RewardManager
addGadget(Type.FREEDOM, getGadget(DoubleJumpFreedom.class), rarity, 50);
addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 10);
addGadget(Type.FREEDOM, getGadget(DeathFreedom.class), rarity, 75);
// Omega Chest
addGadget(Type.OMEGA, getGadget(DoubleJumpFreedom.class), rarity, 5);
addGadget(Type.OMEGA, getGadget(DoubleJumpBlood.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(DoubleJumpFirecracker.class), rarity, 33);
addGadget(Type.OMEGA, getGadget(DoubleJumpEmerald.class), rarity, 25);
addGadget(Type.OMEGA, getGadget(DoubleJumpMusic.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(DoubleJumpShadow.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(DoubleJumpStorm.class), rarity, 30);
addGadget(Type.OMEGA, getGadget(DoubleJumpCandyCane.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(DeathFreedom.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(DeathStorm.class), rarity, 30);
addGadget(Type.OMEGA, getGadget(DeathBlood.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(DeathEmerald.class), rarity, 25);
addGadget(Type.OMEGA, getGadget(DeathMusic.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(DeathPinataBurst.class), rarity, 27);
addGadget(Type.OMEGA, getGadget(DeathShadow.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(DeathCandyCane.class), rarity, 25);
addGadget(Type.OMEGA, getGadget(ArrowTrailFreedom.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(ArrowTrailConfetti.class), rarity, 27);
addGadget(Type.OMEGA, getGadget(ArrowTrailBlood.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(ArrowTrailEmerald.class), rarity, 25);
addGadget(Type.OMEGA, getGadget(ArrowTrailMusic.class), rarity, 27);
addGadget(Type.OMEGA, getGadget(ArrowTrailStorm.class), rarity, 30);
addGadget(Type.OMEGA, getGadget(ArrowTrailShadow.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(ArrowTrailCandyCane.class), rarity, 10);
addHat(Type.OMEGA, HatType.Uncle_Sam, rarity, 25);
addHat(Type.OMEGA, HatType.Companion_Block, rarity, 15);
addHat(Type.OMEGA, HatType.Lovestruck, rarity, 20);
addHat(Type.OMEGA, HatType.Secret_Package, rarity, 25);
addHat(Type.OMEGA, HatType.Teddy_Bear, rarity, 25);
addHat(Type.OMEGA, HatType.Santa, rarity, 25);
addHat(Type.OMEGA, HatType.Rudolph, rarity, 25);
addHat(Type.OMEGA, HatType.Coal, rarity, 25);
addGadget(Type.OMEGA, getGadget(MorphChicken.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(MorphCow.class), rarity, 167);
addGadget(Type.OMEGA, getGadget(MorphEnderman.class), rarity, 33);
addGadget(Type.OMEGA, getGadget(MorphVillager.class), rarity, 83);
addGadget(Type.OMEGA, getGadget(WinEffectFlames.class), rarity, 100);
addGadget(Type.OMEGA, getGadget(WinEffectSnowTrails.class), rarity, 100);
addMount(Type.OMEGA, getMount(MountFrost.class), rarity, 50);
addMount(Type.OMEGA, getMount(MountCart.class), rarity, 100);
addMount(Type.OMEGA, getMount(MountMule.class), rarity, 200);
addMount(Type.OMEGA, getMount(MountSlime.class), rarity, 67);
addGadget(Type.OMEGA, getGadget(OutfitRaveSuitBoots.class), rarity, 30);
addGadget(Type.OMEGA, getGadget(OutfitRaveSuitChestplate.class), rarity, 30);
addGadget(Type.OMEGA, getGadget(OutfitRaveSuitLeggings.class), rarity, 30);
addGadget(Type.OMEGA, getGadget(OutfitRaveSuitHelmet.class), rarity, 30);
addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitBoots.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitChestplate.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitLeggings.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitHelmet.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(ParticleCandyCane.class), rarity, 25);
}
public void addLegendary()
@ -824,7 +471,65 @@ public class RewardManager
addMount(Type.FREEDOM, getMount(MountFreedomHorse.class), rarity, 1);
addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5);
addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50);
// Omega items
addPetReward(Type.OMEGA, EntityType.VILLAGER, rarity, 1);
addPetReward(Type.OMEGA, EntityType.ZOMBIE, rarity, 10);
addPetReward(Type.OMEGA, EntityType.PIG_ZOMBIE, rarity, 1);
addGadget(Type.OMEGA, getGadget(MorphBunny.class), rarity, 1);
addGadget(Type.OMEGA, getGadget(MorphUncleSam.class), rarity, 5);
addGadget(Type.OMEGA, getGadget(MorphPumpkinKing.class), rarity, 1);
addGadget(Type.OMEGA, getGadget(MorphBat.class), rarity, 25);
addGadget(Type.OMEGA, getGadget(MorphSlime.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(MorphBlock.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(MorphSnowman.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(ParticleFreedom.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(ParticleWingsAngel.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(ParticleBlood.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(ParticleWingsDemons.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(ParticleEnchant.class), rarity, 25);
addGadget(Type.OMEGA, getGadget(ParticleFairy.class), rarity, 4);
addGadget(Type.OMEGA, getGadget(ParticleFireRings.class), rarity, 17);
addGadget(Type.OMEGA, getGadget(ParticleEmerald.class), rarity, 8);
addGadget(Type.OMEGA, getGadget(ParticleHeart.class), rarity, 2);
addGadget(Type.OMEGA, getGadget(ParticleWingsInfernal.class), rarity, 4);
addGadget(Type.OMEGA, getGadget(ParticleMusic.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(ParticleWingsPixie.class), rarity, 4);
addGadget(Type.OMEGA, getGadget(ParticleRain.class), rarity, 13);
addGadget(Type.OMEGA, getGadget(ParticleFoot.class), rarity, 33);
addGadget(Type.OMEGA, getGadget(ParticleYinYang.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(ParticleCoalFumes.class), rarity, 1);
addGadget(Type.OMEGA, getGadget(ParticleFrostLord.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(ParticlePartyTime.class), rarity, 25);
addMount(Type.OMEGA, getMount(MountFreedomHorse.class), rarity, 1);
addMount(Type.OMEGA, getMount(MountZombie.class), rarity, 1);
addMount(Type.OMEGA, getMount(MountSpider.class), rarity, 1);
addMount(Type.OMEGA, getMount(MountUndead.class), rarity, 1);
addMount(Type.OMEGA, getMount(MountValentinesSheep.class), rarity, 33);
addMount(Type.OMEGA, getMount(MountBabyReindeer.class), rarity, 1);
addGadget(Type.OMEGA, getGadget(WinEffectBabyChicken.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(WinEffectLavaTrap.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(WinEffectRiseOfTheElderGuardian.class), rarity, 4);
addGadget(Type.OMEGA, getGadget(WinEffectLightningStrike.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(WinEffectMrPunchMan.class), rarity, 33);
addGadget(Type.OMEGA, getGadget(DeathEnchant.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(DeathCupidsBrokenHeart.class), rarity, 25);
addGadget(Type.OMEGA, getGadget(DeathFrostLord.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(DoubleJumpEnchant.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(DoubleJumpCupidsWings.class), rarity, 5);
addGadget(Type.OMEGA, getGadget(DoubleJumpFrostLord.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(ArrowTrailEnchant.class), rarity, 10);
addGadget(Type.OMEGA, getGadget(ArrowTrailFrostLord.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(ArrowTrailCupid.class), rarity, 15);
addHat(Type.OMEGA, HatType.Grinch, rarity, 25);
}
@ -890,7 +595,7 @@ public class RewardManager
addReward(type, reward);
return reward;
}
public UnknownPackageReward addGadget(RewardPool.Type type, Gadget gadget, RewardRarity rarity, int weight, int shards)
{
return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards);
@ -1023,9 +728,11 @@ public class RewardManager
if(pool == Type.NORMAL)
{
_rewardPools.get(Type.CARL_SPINNER).add(reward);
if(!(reward instanceof InventoryReward))
{
_rewardPools.get(Type.ILLUMINATED).add(reward);
}
}
_rewardPools.get(pool).add(reward);
}
@ -1033,7 +740,7 @@ public class RewardManager
public Reward[] getRewards(Player player, RewardPool.Type pool, RewardType type)
{
int amount = 4;
if(type == RewardType.IlluminatedChest || type == RewardType.FreedomChest) amount = 1;
if(type == RewardType.IlluminatedChest || type == RewardType.FreedomChest || type == RewardType.OmegaChest) amount = 1;
int currentReward = 0;
Reward[] rewards = new Reward[amount];

View File

@ -7,6 +7,8 @@ import java.util.List;
import mineplex.core.reward.rewards.GemReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
import org.bukkit.entity.Player;
/**
@ -53,6 +55,7 @@ public class RewardPool
VALENTINES_GIFT(false),
ILLUMINATED(false),
FREEDOM(false),
OMEGA(false),
CARL_SPINNER(true);
private boolean _useDuplicates;
@ -76,6 +79,21 @@ public class RewardPool
return false;
}
}
if (this == OMEGA)
{
if (reward instanceof InventoryReward || reward instanceof TreasureShardReward)
{
return false;
}
else if (reward instanceof UnknownPackageReward)
{
UnknownPackageReward unknownPackageReward = (UnknownPackageReward) reward;
if (unknownPackageReward.getHeader().equalsIgnoreCase("Game Modifiers"))
{
return false;
}
}
}
if (this == Type.CARL_SPINNER)
{
if (reward instanceof GemReward)

View File

@ -13,6 +13,7 @@ public enum RewardType
WinterChest( 0, 5, 18, 32),
IlluminatedChest( 0, 2, 16, 72),
FreedomChest( 0, 5, 18, 0),
OmegaChest( 0, 2, 16, 32),
ValentinesGift( 0, 7, 20, 20),
SpinnerFiller( 0.1, 1, 4, 20),

View File

@ -75,4 +75,9 @@ public class UnknownPackageReward extends Reward
}
return false;
}
public String getHeader()
{
return _header;
}
}

View File

@ -1,39 +1,29 @@
package mineplex.core.treasure;
import java.awt.*;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.*;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.*;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.treasure.animation.*;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.hologram.HologramManager;
import mineplex.core.reward.RankRewardData;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.reward.*;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.titangiveaway.redis.TitanChestGiveawayMessage;
import mineplex.core.treasure.animation.*;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
/**
* Created by Shaun on 8/27/2014.
@ -92,8 +82,9 @@ public class Treasure
_rewardType = rewardType;
_rewards = rewards;
_chestData = new ChestData[chestBlocks.length];
for (int i = 0; i < _chestData.length; i++)
int max = chestBlocks.length;
_chestData = new ChestData[max];
for (int i = 0; i < max; i++)
{
_chestData[i] = new ChestData(chestBlocks[i]);
}

View File

@ -1,14 +1,9 @@
package mineplex.core.treasure;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.*;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetBlockEvent;
@ -40,8 +35,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import java.util.List;
public class TreasureLocation implements Listener
{
private TreasureManager _treasureManager;
@ -132,7 +125,7 @@ public class TreasureLocation implements Listener
return;
}
if(treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.FREEDOM)
if(treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.FREEDOM || treasureType == TreasureType.OMEGA)
{
if(!_treasureManager.hasItemsToGivePlayer(treasureType.getRewardPool(), player))
{
@ -159,7 +152,10 @@ public class TreasureLocation implements Listener
if (treasureType != TreasureType.OLD)
{
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening " + UtilText.prefixPronoun(treasureType.getName())));
String pron = "a ";
if (treasureType == TreasureType.ANCIENT || treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.OMEGA)
pron = "an ";
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening " + pron + treasureType.getName()));
}
Treasure treasure = new Treasure(player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager);

View File

@ -1,5 +1,8 @@
package mineplex.core.treasure;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
@ -8,6 +11,7 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.locations.LocationConstants;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardManager;
@ -15,17 +19,12 @@ import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Shaun on 8/27/2014.
*/
@ -50,35 +49,14 @@ public class TreasureManager extends MiniPlugin
_statsManager = statsManager;
_rewardManager = rewardManager;
World world = Bukkit.getWorlds().get(0);
_treasureLocations = Lists.newArrayList();
_treasureLocations = new ArrayList<>();
for(Location location : LocationConstants.CHEST_LOCATIONS)
{
Block chestBlock = world.getBlockAt(-31, 73, -11);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, -26.5, 72, -11.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
Location resetLocation = LocationConstants.getResetLocation(location);
Block[] blocks = setup(location.getBlock());
{
Block chestBlock = world.getBlockAt(-22, 73, -34);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, -22.5, 72, -29.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
{
Block chestBlock = world.getBlockAt(22, 75, -34);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, 19.5, 74, -30.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
{
Block chestBlock = world.getBlockAt(31, 74, -11);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, 27.5, 73, -15.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, location.getBlock(), blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
for (TreasureLocation treasureLocation : _treasureLocations)

View File

@ -48,6 +48,13 @@ public enum TreasureStyle
ParticleType.RED_DUST,
Sound.FIZZ,
Sound.FIREWORK_TWINKLE2
),
OMEGA(
ParticleType.CRIT,
null,
ParticleType.CRIT,
Sound.FIRE,
Sound.FIREWORK_TWINKLE
);
private ParticleType _secondaryParticle;

View File

@ -18,7 +18,9 @@ public enum TreasureType
ILLUMINATED(C.cAqua + "Illuminated Treasure", "Illuminated Chest", "Illuminated", RewardType.IlluminatedChest, Material.CHEST, TreasureStyle.ILLUMINATED, RewardPool.Type.ILLUMINATED, true, 20000),
FREEDOM(C.cRed + "Freedom " + C.cBlue + "Treasure", "Freedom Treasure", "Freedom", RewardType.FreedomChest, Material.CHEST, TreasureStyle.FREEDOM, RewardPool.Type.FREEDOM, true, 35000);
FREEDOM(C.cRed + "Freedom " + C.cBlue + "Treasure", "Freedom Treasure", "Freedom", RewardType.FreedomChest, Material.CHEST, TreasureStyle.FREEDOM, RewardPool.Type.FREEDOM, true, 35000),
OMEGA(C.cAqua + "Omega Chest", "Omega Chest", "Omega", RewardType.OmegaChest, Material.ENDER_CHEST, TreasureStyle.OMEGA, RewardPool.Type.OMEGA, false, 50000);
private final String _name;
private final RewardType _rewardType;

View File

@ -2,16 +2,12 @@ package mineplex.core.treasure.animation;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
public class BlockChangeAnimation extends Animation
{
@ -74,6 +70,11 @@ public class BlockChangeAnimation extends Animation
mat = Material.WOOL;
data = 11;
}
else if (getTreasure().getTreasureType() == TreasureType.OMEGA)
{
mat = Material.ENDER_STONE;
data = 0;
}
else
continue;
@ -101,6 +102,11 @@ public class BlockChangeAnimation extends Animation
mat = Material.WOOL;
data = 14;
}
else if (getTreasure().getTreasureType() == TreasureType.OMEGA)
{
mat = Material.ENDER_STONE;
data = 0;
}
else
continue;
@ -133,6 +139,18 @@ public class BlockChangeAnimation extends Animation
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
{
for(Block c : _chests)
{
if(c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.ENDER_PORTAL_FRAME);
b.setData((byte) 0);
}
}
}
}
}

View File

@ -3,32 +3,22 @@ package mineplex.core.treasure.animation;
import java.awt.*;
import java.util.List;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.MathHelper;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.MathHelper;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
/**
* Created by Shaun on 8/29/2014.
@ -50,6 +40,8 @@ public class ChestSpawnAnimation extends Animation
private JavaPlugin _javaPlugin;
private int _babyFireworks = 0;
private int _circleAmount = 0;
public ChestSpawnAnimation(Treasure treasure, Block block, List<BlockInfo> chestBlockInfo, Block openingCenter, double radialOffset, JavaPlugin javaPlugin)
{
@ -164,6 +156,25 @@ public class ChestSpawnAnimation extends Animation
_babyFireworks++;
}
}
else if (getTreasure().getTreasureType() == TreasureType.OMEGA)
{
if (_circleAmount <= 15)
{
int particles = 50;
int radius = 1;
for (int i = 0; i < particles; i++)
{
double angle = (double) 2 * Math.PI * i / particles;
double x = Math.cos(angle) * radius;
double z = Math.sin(angle) * radius;
Location loc = _centerLocation.clone().add(x, .1 * _circleAmount, z);
UtilParticle.PlayParticleToAll(ParticleType.PORTAL, loc, null, 0, 2, ViewDist.NORMAL);
}
}
_circleAmount++;
}
//Spawn Chest
if (getTicks() >= ANIMATION_DURATION)
@ -172,6 +183,7 @@ public class ChestSpawnAnimation extends Animation
{
UtilBlock.setQuick(_block.getWorld(), _block.getX(), _block.getY(), _block.getZ(), 0, (byte) 0);
}
_chestBlockInfo.add(new BlockInfo(_block));
getTreasure().setBlock(_block, getTreasure().getTreasureType().getMaterial(), _direction);
_block.getLocation().getWorld().playSound(_centerLocation, getTreasure().getTreasureType().getStyle().getChestSpawnSound(), 0.5f, 1f);

View File

@ -2,7 +2,6 @@ package mineplex.core.treasure.gui;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.confirmation.ConfirmationPage;
@ -60,12 +59,12 @@ public class BuyChestButton implements IButton
return;
}
}
if (!_page.getPlugin().hasItemsToGivePlayer(TreasureType.ILLUMINATED.getRewardPool(), player)
&& _chestType == TreasureType.ILLUMINATED)
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)
&& (_chestType == TreasureType.ILLUMINATED || _chestType == TreasureType.OMEGA))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
SalesPackageBase salesPackage = new ChestPackage(_chestName, _chestMat, _chestCost);
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () ->
{

View File

@ -1,5 +1,8 @@
package mineplex.core.treasure.gui;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.skin.SkinData;
@ -27,9 +30,6 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
{
private TreasureLocation _treasureLocation;
@ -58,6 +58,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
int christmasCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.CHRISTMAS.getItemName());
int illuminatedCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ILLUMINATED.getItemName());
int freedomCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.FREEDOM.getItemName());
int omegaCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OMEGA.getItemName());
List<String> shardLore = new ArrayList<>();
shardLore.add(" ");
@ -176,13 +177,30 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
freedomLore.add(" ");
freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/7 Unlocked");
List<String> omegaLore = new ArrayList<>();
omegaLore.add(" ");
omegaLore.add(F.value("Omega Chests Owned", "" + omegaCount));
omegaLore.add(" ");
omegaLore.add(C.cGray + "The most powerful of all chests,");
omegaLore.add(C.cGray + "it is able to go back in time to find");
omegaLore.add(C.cGray + "loot that has been lost...");
omegaLore.add(" ");
if (omegaCount > 0)
omegaLore.add(ChatColor.RESET + C.cGreen + "Click to Open!");
else
{
}
ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false);
ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Old Treasure", basicLore.toArray(new String[0]), 0, false, false);
ShopItem heroic = new ShopItem(Material.TRAPPED_CHEST, C.cGold + C.Bold + "Ancient Treasure", heroicLore.toArray(new String[0]), 0, false, false);
ShopItem legendary = new ShopItem(Material.ENDER_CHEST, C.cRed + C.Bold + "Mythical Treasure", legendaryLore.toArray(new String[0]), 0, false, false);
ItemStack christmas = SkinData.PRESENT.getSkull(C.cDGreen + C.Bold + "Winter Holiday Treasure", christmasLore);
ItemStack illuminated = new ShopItem(Material.SEA_LANTERN, C.cDAqua + C.Bold + "Illuminated Treasure", illuminatedLore.toArray(new String[0]), 0, false, false);
ItemStack freedom = SkinData.FREEDOM_CHEST.getSkull(C.cRed + C.Bold + "Freedom " + C.cBlue + C.Bold + "Treasure", freedomLore);
ItemStack freedom = SkinData.FREEDOM_CHEST.getSkull(C.cRedB + "Freedom " + C.cBlueB + "Treasure", freedomLore);
//ShopItem omega = new ShopItem(Material.NETHER_STAR, C.cAquaB + "Omega Treasure", omegaLore.toArray(new String[0]), 0, false, false);
ItemStack omega = SkinData.OMEGA_CHEST.getSkull(C.cAquaB + "Omega Treasure", omegaLore);
addItem(40, shards);
@ -198,6 +216,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
addChest(20, basic, TreasureType.OLD, basicCount);
addChest(22, heroic, TreasureType.ANCIENT, heroicCount);
addChest(24, legendary, TreasureType.MYTHICAL, legendaryCount);
addChest(4, omega, TreasureType.OMEGA, omegaCount);
}
private void addChest(int slot, ItemStack item, TreasureType treasureType, int owned)

View File

@ -65,6 +65,16 @@ public class Npcs extends org.jooq.impl.TableImpl<mineplex.database.tables.recor
* The column <code>Account.npcs.z</code>.
*/
public final org.jooq.TableField<mineplex.database.tables.records.NpcsRecord, java.lang.Double> z = createField("z", org.jooq.impl.SQLDataType.FLOAT.nullable(false), this, "");
/**
* The column <code>Account.npcs.yaw</code>.
*/
public final org.jooq.TableField<mineplex.database.tables.records.NpcsRecord, java.lang.Double> yaw = createField("yaw", org.jooq.impl.SQLDataType.FLOAT.nullable(false).defaulted(true), this, "");
/**
* The column <code>Account.npcs.pitch</code>.
*/
public final org.jooq.TableField<mineplex.database.tables.records.NpcsRecord, java.lang.Double> pitch = createField("pitch", org.jooq.impl.SQLDataType.FLOAT.nullable(false).defaulted(true), this, "");
/**
* The column <code>Account.npcs.radius</code>.

View File

@ -14,7 +14,7 @@ package mineplex.database.tables.records;
comments = "This class is generated by jOOQ"
)
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.NpcsRecord> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record19<java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Integer> {
public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.NpcsRecord> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record21<java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Integer> {
private static final long serialVersionUID = -112578515;
@ -115,173 +115,201 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
public java.lang.Double getZ() {
return (java.lang.Double) getValue(6);
}
/**
* Setter for <code>Account.npcs.yaw</code>.
*/
public void setYaw(java.lang.Double value) {
setValue(7, value);
}
/**
* Getter for <code>Account.npcs.yaw</code>.
*/
public java.lang.Double getYaw() {
return (java.lang.Double) getValue(7);
}
/**
* Setter for <code>Account.npcs.pitch</code>.
*/
public void setPitch(java.lang.Double value) {
setValue(8, value);
}
/**
* Getter for <code>Account.npcs.pitch</code>.
*/
public java.lang.Double getPitch() {
return (java.lang.Double) getValue(8);
}
/**
* Setter for <code>Account.npcs.radius</code>.
*/
public void setRadius(java.lang.Double value) {
setValue(7, value);
setValue(9, value);
}
/**
* Getter for <code>Account.npcs.radius</code>.
*/
public java.lang.Double getRadius() {
return (java.lang.Double) getValue(7);
return (java.lang.Double) getValue(9);
}
/**
* Setter for <code>Account.npcs.entityType</code>.
*/
public void setEntityType(java.lang.String value) {
setValue(8, value);
setValue(10, value);
}
/**
* Getter for <code>Account.npcs.entityType</code>.
*/
public java.lang.String getEntityType() {
return (java.lang.String) getValue(8);
return (java.lang.String) getValue(10);
}
/**
* Setter for <code>Account.npcs.entityMeta</code>.
*/
public void setEntityMeta(java.lang.String value) {
setValue(9, value);
setValue(11, value);
}
/**
* Getter for <code>Account.npcs.entityMeta</code>.
*/
public java.lang.String getEntityMeta() {
return (java.lang.String) getValue(9);
return (java.lang.String) getValue(11);
}
/**
* Setter for <code>Account.npcs.adult</code>.
*/
public void setAdult(java.lang.Boolean value) {
setValue(10, value);
setValue(12, value);
}
/**
* Getter for <code>Account.npcs.adult</code>.
*/
public java.lang.Boolean getAdult() {
return (java.lang.Boolean) getValue(10);
return (java.lang.Boolean) getValue(12);
}
/**
* Setter for <code>Account.npcs.helmet</code>.
*/
public void setHelmet(java.lang.String value) {
setValue(11, value);
setValue(13, value);
}
/**
* Getter for <code>Account.npcs.helmet</code>.
*/
public java.lang.String getHelmet() {
return (java.lang.String) getValue(11);
return (java.lang.String) getValue(13);
}
/**
* Setter for <code>Account.npcs.chestplate</code>.
*/
public void setChestplate(java.lang.String value) {
setValue(12, value);
setValue(14, value);
}
/**
* Getter for <code>Account.npcs.chestplate</code>.
*/
public java.lang.String getChestplate() {
return (java.lang.String) getValue(12);
return (java.lang.String) getValue(14);
}
/**
* Setter for <code>Account.npcs.leggings</code>.
*/
public void setLeggings(java.lang.String value) {
setValue(13, value);
setValue(15, value);
}
/**
* Getter for <code>Account.npcs.leggings</code>.
*/
public java.lang.String getLeggings() {
return (java.lang.String) getValue(13);
return (java.lang.String) getValue(15);
}
/**
* Setter for <code>Account.npcs.boots</code>.
*/
public void setBoots(java.lang.String value) {
setValue(14, value);
setValue(16, value);
}
/**
* Getter for <code>Account.npcs.boots</code>.
*/
public java.lang.String getBoots() {
return (java.lang.String) getValue(14);
return (java.lang.String) getValue(16);
}
/**
* Setter for <code>Account.npcs.inHand</code>.
*/
public void setInHand(java.lang.String value) {
setValue(15, value);
setValue(17, value);
}
/**
* Getter for <code>Account.npcs.inHand</code>.
*/
public java.lang.String getInHand() {
return (java.lang.String) getValue(15);
return (java.lang.String) getValue(17);
}
/**
* Setter for <code>Account.npcs.info</code>.
*/
public void setInfo(java.lang.String value) {
setValue(16, value);
setValue(18, value);
}
/**
* Getter for <code>Account.npcs.info</code>.
*/
public java.lang.String getInfo() {
return (java.lang.String) getValue(16);
return (java.lang.String) getValue(18);
}
/**
* Setter for <code>Account.npcs.infoRadius</code>.
*/
public void setInfoRadius(java.lang.Double value) {
setValue(17, value);
setValue(19, value);
}
/**
* Getter for <code>Account.npcs.infoRadius</code>.
*/
public java.lang.Double getInfoRadius() {
return (java.lang.Double) getValue(17);
return (java.lang.Double) getValue(19);
}
/**
* Setter for <code>Account.npcs.infoDelay</code>.
*/
public void setInfoDelay(java.lang.Integer value) {
setValue(18, value);
setValue(20, value);
}
/**
* Getter for <code>Account.npcs.infoDelay</code>.
*/
public java.lang.Integer getInfoDelay() {
return (java.lang.Integer) getValue(18);
return (java.lang.Integer) getValue(20);
}
// -------------------------------------------------------------------------
@ -304,16 +332,16 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Row19<java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Integer> fieldsRow() {
return (org.jooq.Row19) super.fieldsRow();
public org.jooq.Row21<java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Integer> fieldsRow() {
return (org.jooq.Row21) super.fieldsRow();
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Row19<java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Integer> valuesRow() {
return (org.jooq.Row19) super.valuesRow();
public org.jooq.Row21<java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Double, java.lang.Integer> valuesRow() {
return (org.jooq.Row21) super.valuesRow();
}
/**
@ -371,12 +399,28 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
public org.jooq.Field<java.lang.Double> field7() {
return mineplex.database.tables.Npcs.npcs.z;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Double> field8() {
return mineplex.database.tables.Npcs.npcs.yaw;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Double> field9() {
return mineplex.database.tables.Npcs.npcs.pitch;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Double> field10() {
return mineplex.database.tables.Npcs.npcs.radius;
}
@ -384,7 +428,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field9() {
public org.jooq.Field<java.lang.String> field11() {
return mineplex.database.tables.Npcs.npcs.entityType;
}
@ -392,7 +436,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field10() {
public org.jooq.Field<java.lang.String> field12() {
return mineplex.database.tables.Npcs.npcs.entityMeta;
}
@ -400,7 +444,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Boolean> field11() {
public org.jooq.Field<java.lang.Boolean> field13() {
return mineplex.database.tables.Npcs.npcs.adult;
}
@ -408,7 +452,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field12() {
public org.jooq.Field<java.lang.String> field14() {
return mineplex.database.tables.Npcs.npcs.helmet;
}
@ -416,7 +460,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field13() {
public org.jooq.Field<java.lang.String> field15() {
return mineplex.database.tables.Npcs.npcs.chestplate;
}
@ -424,7 +468,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field14() {
public org.jooq.Field<java.lang.String> field16() {
return mineplex.database.tables.Npcs.npcs.leggings;
}
@ -432,7 +476,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field15() {
public org.jooq.Field<java.lang.String> field17() {
return mineplex.database.tables.Npcs.npcs.boots;
}
@ -440,7 +484,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field16() {
public org.jooq.Field<java.lang.String> field18() {
return mineplex.database.tables.Npcs.npcs.inHand;
}
@ -448,7 +492,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.String> field17() {
public org.jooq.Field<java.lang.String> field19() {
return mineplex.database.tables.Npcs.npcs.info;
}
@ -456,7 +500,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Double> field18() {
public org.jooq.Field<java.lang.Double> field20() {
return mineplex.database.tables.Npcs.npcs.infoRadius;
}
@ -464,7 +508,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Integer> field19() {
public org.jooq.Field<java.lang.Integer> field21() {
return mineplex.database.tables.Npcs.npcs.infoDelay;
}
@ -523,12 +567,28 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
public java.lang.Double value7() {
return getZ();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Double value8() {
return getYaw();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Double value9() {
return getPitch();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Double value10() {
return getRadius();
}
@ -536,7 +596,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value9() {
public java.lang.String value11() {
return getEntityType();
}
@ -544,7 +604,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value10() {
public java.lang.String value12() {
return getEntityMeta();
}
@ -552,7 +612,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.Boolean value11() {
public java.lang.Boolean value13() {
return getAdult();
}
@ -560,7 +620,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value12() {
public java.lang.String value14() {
return getHelmet();
}
@ -568,7 +628,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value13() {
public java.lang.String value15() {
return getChestplate();
}
@ -576,7 +636,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value14() {
public java.lang.String value16() {
return getLeggings();
}
@ -584,7 +644,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value15() {
public java.lang.String value17() {
return getBoots();
}
@ -592,7 +652,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value16() {
public java.lang.String value18() {
return getInHand();
}
@ -600,7 +660,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.String value17() {
public java.lang.String value19() {
return getInfo();
}
@ -608,7 +668,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.Double value18() {
public java.lang.Double value20() {
return getInfoRadius();
}
@ -616,7 +676,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public java.lang.Integer value19() {
public java.lang.Integer value21() {
return getInfoDelay();
}
@ -682,12 +742,30 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
setZ(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public NpcsRecord value8(java.lang.Double value) {
setYaw(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public NpcsRecord value9(java.lang.Double value) {
setPitch(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public NpcsRecord value10(java.lang.Double value) {
setRadius(value);
return this;
}
@ -696,7 +774,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value9(java.lang.String value) {
public NpcsRecord value11(java.lang.String value) {
setEntityType(value);
return this;
}
@ -705,7 +783,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value10(java.lang.String value) {
public NpcsRecord value12(java.lang.String value) {
setEntityMeta(value);
return this;
}
@ -714,7 +792,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value11(java.lang.Boolean value) {
public NpcsRecord value13(java.lang.Boolean value) {
setAdult(value);
return this;
}
@ -723,7 +801,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value12(java.lang.String value) {
public NpcsRecord value14(java.lang.String value) {
setHelmet(value);
return this;
}
@ -732,7 +810,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value13(java.lang.String value) {
public NpcsRecord value15(java.lang.String value) {
setChestplate(value);
return this;
}
@ -741,7 +819,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value14(java.lang.String value) {
public NpcsRecord value16(java.lang.String value) {
setLeggings(value);
return this;
}
@ -750,7 +828,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value15(java.lang.String value) {
public NpcsRecord value17(java.lang.String value) {
setBoots(value);
return this;
}
@ -759,7 +837,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value16(java.lang.String value) {
public NpcsRecord value18(java.lang.String value) {
setInHand(value);
return this;
}
@ -768,7 +846,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value17(java.lang.String value) {
public NpcsRecord value19(java.lang.String value) {
setInfo(value);
return this;
}
@ -777,7 +855,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value18(java.lang.Double value) {
public NpcsRecord value20(java.lang.Double value) {
setInfoRadius(value);
return this;
}
@ -786,7 +864,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord value19(java.lang.Integer value) {
public NpcsRecord value21(java.lang.Integer value) {
setInfoDelay(value);
return this;
}
@ -795,7 +873,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
* {@inheritDoc}
*/
@Override
public NpcsRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.Double value5, java.lang.Double value6, java.lang.Double value7, java.lang.Double value8, java.lang.String value9, java.lang.String value10, java.lang.Boolean value11, java.lang.String value12, java.lang.String value13, java.lang.String value14, java.lang.String value15, java.lang.String value16, java.lang.String value17, java.lang.Double value18, java.lang.Integer value19) {
public NpcsRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.Double value5, java.lang.Double value6, java.lang.Double value7, java.lang.Double value8, java.lang.Double value9, java.lang.Double value10, java.lang.String value11, java.lang.String value12, java.lang.Boolean value13, java.lang.String value14, java.lang.String value15, java.lang.String value16, java.lang.String value17, java.lang.String value18, java.lang.String value19, java.lang.Double value20, java.lang.Integer value21) {
return this;
}
@ -813,7 +891,7 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
/**
* Create a detached, initialised NpcsRecord
*/
public NpcsRecord(java.lang.Integer id, java.lang.String server, java.lang.String name, java.lang.String world, java.lang.Double x, java.lang.Double y, java.lang.Double z, java.lang.Double radius, java.lang.String entityType, java.lang.String entityMeta, java.lang.Boolean adult, java.lang.String helmet, java.lang.String chestplate, java.lang.String leggings, java.lang.String boots, java.lang.String inHand, java.lang.String info, java.lang.Double infoRadius, java.lang.Integer infoDelay) {
public NpcsRecord(java.lang.Integer id, java.lang.String server, java.lang.String name, java.lang.String world, java.lang.Double x, java.lang.Double y, java.lang.Double z, java.lang.Double yaw, java.lang.Double pitch, java.lang.Double radius, java.lang.String entityType, java.lang.String entityMeta, java.lang.Boolean adult, java.lang.String helmet, java.lang.String chestplate, java.lang.String leggings, java.lang.String boots, java.lang.String inHand, java.lang.String info, java.lang.Double infoRadius, java.lang.Integer infoDelay) {
super(mineplex.database.tables.Npcs.npcs);
setValue(0, id);
@ -823,17 +901,19 @@ public class NpcsRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.datab
setValue(4, x);
setValue(5, y);
setValue(6, z);
setValue(7, radius);
setValue(8, entityType);
setValue(9, entityMeta);
setValue(10, adult);
setValue(11, helmet);
setValue(12, chestplate);
setValue(13, leggings);
setValue(14, boots);
setValue(15, inHand);
setValue(16, info);
setValue(17, infoRadius);
setValue(18, infoDelay);
setValue(7, yaw);
setValue(8, pitch);
setValue(9, radius);
setValue(10, entityType);
setValue(11, entityMeta);
setValue(12, adult);
setValue(13, helmet);
setValue(14, chestplate);
setValue(15, leggings);
setValue(16, boots);
setValue(17, inHand);
setValue(18, info);
setValue(19, infoRadius);
setValue(20, infoDelay);
}
}

View File

@ -7,9 +7,9 @@ import mineplex.core.common.Rank;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.server.util.TransactionResponse;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -22,6 +22,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.AbstractMap;
import java.util.Date;
import java.util.Iterator;
@ -34,6 +35,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
private DonationManager _donationManager;
private InventoryManager _inventoryManager;
private PurchaseManager _purchaseManager;
private PowerPlayClubRepository _powerPlayClubRepository;
private NautHashMap<String, Entry<UUID, Long>> _cachedUUIDs = new NautHashMap<String, Entry<UUID, Long>>();
private static Object _commandLock = new Object();
@ -51,6 +53,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
_inventoryManager = inventoryManager;
_purchaseManager = new PurchaseManager(plugin);
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager);
plugin.getCommand("enjin_mineplex").setExecutor(this);
plugin.getCommand("pull").setExecutor(this);
@ -103,37 +106,37 @@ public class Enjin extends MiniPlugin implements CommandExecutor
uuid = _clientManager.loadUUIDFromDB(name);
if (uuid == null)
uuid = UUIDFetcher.getUUIDOf(name);
}
if (uuid == null)
{
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID.");
return;
}
final UUID playerUUID = uuid;
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
if (!checkForClansPurchase(args, name, client))
{
if (!checkForBoosterPurchase(args, name, playerUUID, client))
{
if (!checkForCoinPurchase(args, name, playerUUID, client))
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID.");
return;
}
final UUID playerUUID = uuid;
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
if (!checkForClansPurchase(args, name, client))
{
if (!checkForBoosterPurchase(args, name, playerUUID, client))
{
if (!checkForRankPurchase(args, name, playerUUID, client))
if (!checkForCoinPurchase(args, name, playerUUID, client))
{
if (!checkForPurchase(args, name, client))
if (!checkForRankPurchase(args, name, playerUUID, client))
{
StringBuilder sb = new StringBuilder();
for (String arg : args)
if (!checkForPurchase(args, name, client))
{
sb.append(arg + " ");
}
if (!checkForPowerPlayClub(args, name, playerUUID, client))
{
StringBuilder sb = new StringBuilder();
System.out.println("Received Command : " + sb.toString());
for (String arg : args)
{
sb.append(arg + " ");
}
System.out.println("Received Command : " + sb.toString());
}
}
}
}
}
@ -168,7 +171,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
final Rank rank = mineplex.core.common.Rank.valueOf(args[2]);
final boolean perm = Boolean.parseBoolean(args[3]);
_clientManager.loadClientByName(name, loadedClient ->
{
if (rank == Rank.ALL || loadedClient.GetRank() == Rank.ALL || !loadedClient.GetRank().has(rank) || loadedClient.GetRank() == rank)
@ -191,7 +194,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
{
if (args.length < 3 || !args[0].equalsIgnoreCase("purchase"))
return false;
final int amount = Integer.parseInt(args[2]);
String tempName = args[4];
@ -281,6 +284,28 @@ public class Enjin extends MiniPlugin implements CommandExecutor
return true;
}
protected boolean checkForPowerPlayClub(String[] args, final String name, final UUID playerUUID, final CoreClient client)
{
if (args.length < 3 || !args[0].equalsIgnoreCase("powerplayclub"))
return false;
if (args[2].equalsIgnoreCase("add"))
{
String[] splitDate = args[3].split("/");
LocalDate date = LocalDate.of(Integer.parseInt(splitDate[2]), Integer.parseInt(splitDate[0]), Integer.parseInt(splitDate[1]));
String duration = args[4];
_powerPlayClubRepository.addSubscription(client.getAccountId(), date, duration);
} else if (args[2].equalsIgnoreCase("cancel"))
{
// TODO: cancel it in our logs? I don't think this is necessary.
}
return false;
}
protected boolean checkForClansPurchase(String[] args, final String name, final CoreClient client)
{

View File

@ -4,9 +4,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.command.CommandCenter;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.punish.Punish;
import mineplex.core.updater.Updater;
import org.bukkit.plugin.java.JavaPlugin;
public class EnjinTranslator extends JavaPlugin

View File

@ -33,7 +33,7 @@ public class TutorialRegion
private void pasteSchematic()
{
_locationMap = _schematic.paste(getOrigin(), false);
_locationMap = _schematic.paste(getOrigin(), false).getDataLocationMap();
}
/**

View File

@ -14,6 +14,8 @@ import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.chat.ChatFormat;
import mineplex.core.chat.IChatMessageFormatter;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -120,7 +122,7 @@ import java.util.UUID;
/**
* Main manager for clans hub
*/
public class HubManager extends MiniPlugin
public class HubManager extends MiniPlugin implements IChatMessageFormatter
{
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;
@ -176,23 +178,14 @@ public class HubManager extends MiniPlugin
_portal = portal;
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 179, 0.5, -90f, 0f);
runSyncLater(() ->
{
for (Entity e : _spawn.getWorld().getEntities())
{
if (npcManager.getNpcByEntity(e) != null)
{
e.teleport(new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), 90f, 0f));
}
}
}, 120L);
((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0;
new WorldManager(this);
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
_inventoryManager = inventoryManager;
new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, Managers.get(ProjectileManager.class), achievementManager, packetHandler, hologramManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager, incognito);
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
@ -537,6 +530,33 @@ public class HubManager extends MiniPlugin
}
}
@Override
public ChatFormat getChatFormat(Player player, String message)
{
Rank rank = GetClients().Get(player).getRealOrDisguisedRank();
//Level Prefix
String levelStr = _achievementManager.getMineplexLevel(player, rank);
//Rank Prefix
String rankStr = "";
if (rank != Rank.ALL)
rankStr = rank.getTag(true, true) + " ";
TextComponent rankComponent = new TextComponent(rankStr);
TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + "%1$s");
TextComponent component = new TextComponent();
rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create()));
component.setText(levelStr);
component.addExtra(rankComponent);
component.addExtra(playerNameText);
component.addExtra(" " + ChatColor.WHITE + "%2$s");
return new ChatFormat(component.toLegacyText(), false);
}
@EventHandler
public void Damage(EntityDamageEvent event)
{

View File

@ -1,5 +1,4 @@
package mineplex.hub;
import mineplex.core.Managers;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClient;
@ -12,17 +11,11 @@ import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.chat.ChatFormat;
import mineplex.core.chat.IChatMessageFormatter;
import mineplex.core.common.Rank;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.*;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
@ -38,6 +31,7 @@ import mineplex.core.incognito.IncognitoManager;
import mineplex.core.incognito.events.IncognitoHidePlayerEvent;
import mineplex.core.interactions.NewInteractionsManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.locations.LocationConstants;
import mineplex.core.menu.MenuManager;
import mineplex.core.message.PrivateMessageEvent;
import mineplex.core.mount.MountManager;
@ -75,15 +69,7 @@ import mineplex.hub.commands.ForcefieldRadius;
import mineplex.hub.commands.GadgetToggle;
import mineplex.hub.commands.GameModeCommand;
import mineplex.hub.commands.NewsCommand;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.HubVisibilityManager;
import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.KothManager;
import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.SoccerManager;
import mineplex.hub.modules.ValentinesManager;
import mineplex.hub.modules.WorldManager;
import mineplex.hub.modules.*;
import mineplex.hub.modules.nonpremium.NonPremiumManager;
import mineplex.hub.profile.gui.GUIProfile;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
@ -97,11 +83,7 @@ import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
@ -115,14 +97,7 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -131,13 +106,9 @@ import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import java.util.UUID;
import java.util.*;
public class HubManager extends MiniClientPlugin<HubClient>
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
{
// Snowman!
public HubType Type = HubType.Normal;
@ -173,6 +144,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private JumpManager _jumpManager;
// private HalloweenSpookinessManager _halloweenManager;
// private TrickOrTreatManager _trickOrTreatManager;
private MavericksManager _mavericksManager;
private Location _spawn;
@ -208,7 +180,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_portal = portal;
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 79, -23.5);
_spawn = LocationConstants.HUB_SPAWN.clone().add(0, 5, 0);
// Disable item merging
((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0;
@ -223,21 +195,25 @@ public class HubManager extends MiniClientPlugin<HubClient>
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
_inventoryManager = inventoryManager;
new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, Managers.get(ProjectileManager.class), achievementManager, packetHandler, hologramManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, Managers.get(ProjectileManager.class), achievementManager, packetHandler, hologramManager, incognito);
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());
CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager);
_mavericksManager = new MavericksManager(plugin, cosmeticManager, hologramManager, this);
new SoccerManager(this, _gadgetManager);
new KothManager(this, _gadgetManager);
new AntiSpamManager();
new MenuManager(_plugin);
new NewInteractionsManager();
AntiSpamManager antiSpam = new AntiSpamManager();
antiSpam.setMessageFormatter(this);
//new TrickOrTreatManager(_plugin, this, taskManager, donationManager, clientManager);
@ -744,6 +720,33 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
}
@Override
public ChatFormat getChatFormat(Player player, String message)
{
Rank rank = GetClients().Get(player).getRealOrDisguisedRank();
//Level Prefix
String levelStr = _achievementManager.getMineplexLevel(player, rank);
//Rank Prefix
String rankStr = "";
if (rank != Rank.ALL)
rankStr = rank.getTag(true, true) + " ";
TextComponent rankComponent = new TextComponent(rankStr);
TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + "%1$s");
TextComponent component = new TextComponent();
rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create()));
component.setText(levelStr);
component.addExtra(rankComponent);
component.addExtra(playerNameText);
component.addExtra(" " + ChatColor.WHITE + "%2$s");
return new ChatFormat(component.toLegacyText(), false);
}
@EventHandler
public void Damage(EntityDamageEvent event)
{
@ -887,6 +890,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
return _punishManager;
}
public MavericksManager getMavericksManager()
{
return _mavericksManager;
}
// public HalloweenSpookinessManager getHalloweenManager()
// {

View File

@ -107,6 +107,11 @@ public class KothManager extends MiniPlugin
public boolean inPlayerArena(Entity entity)
{
if (!entity.getWorld().equals(_cornerPlayerA.getWorld()))
{
return false;
}
return UtilAlg.inBoundingBox(entity.getLocation(), _cornerPlayerA, _cornerPlayerB);
}

View File

@ -0,0 +1,351 @@
package mineplex.hub.modules;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.BukkitFuture;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.mavericks.DisplaySlot;
import mineplex.core.mavericks.MavericksApprovedRepository;
import mineplex.core.mavericks.MavericksApprovedWrapper;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.modules.mavericks.MavericksPortalManager;
import mineplex.hub.modules.mavericks.MavericksWorldManager;
import mineplex.hub.modules.mavericks.basketball.BasketballManager;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.event.entity.EntityMountEvent;
/**
* A manager to handle all mavericks related content in the hub. Holds the mavericks portal manager in addition to handle
* the rotation of the "best of" builds from Mavericks Master Builders.
*/
public class MavericksManager extends MiniPlugin
{
// private static final long ROTATION_TIME = 1000*60*60*6;
private static final long ROTATION_TIME = 1000*30;
private MavericksPortalManager _portalManager;
private MavericksWorldManager _worldManager;
private MavericksApprovedRepository _repoApproved;
private List<DisplaySlot> _displaySlots = new ArrayList<>();
public MavericksManager(JavaPlugin plugin, CosmeticManager cosmeticManager, HologramManager hologramManager, HubManager hub)
{
super("Mavericks", plugin);
_worldManager = new MavericksWorldManager(plugin);
_portalManager = new MavericksPortalManager(plugin, hub, _worldManager, cosmeticManager);
_repoApproved = new MavericksApprovedRepository();
new BasketballManager(plugin, _worldManager, hub);
_displaySlots.add(new DisplaySlot(new Location(_worldManager.getWorld(), -41, 24, 237), hologramManager));
_displaySlots.add(new DisplaySlot(new Location(_worldManager.getWorld(), 19, 24, 237), hologramManager));
}
/**
* Main task to handle the rotation. Pulls data from the SQL DB and displays it in-game.
*/
@EventHandler
public void onUpdate(UpdateEvent event)
{
if(event.getType() != UpdateType.SLOW) return;
Function<? super List<MavericksApprovedWrapper>, ? extends CompletionStage<Void>> updateTask = BukkitFuture.accept((list) ->
{
List<DisplaySlot> openSlots = new ArrayList<>();
List<MavericksApprovedWrapper> undisplayedData = new ArrayList<>();
undisplayedData.addAll(list);
slots:
for(DisplaySlot slot : _displaySlots)
{
if(slot.getData() != null)
{
for(MavericksApprovedWrapper build : list)
{
if(slot.getData().getBuild().getBuildId() == build.getBuild().getBuildId())
{
undisplayedData.remove(build);
continue slots;
}
}
}
openSlots.add(slot);
}
for(int i = 0; i < Math.min(openSlots.size(), undisplayedData.size()); i++)
{
MavericksApprovedWrapper approved = undisplayedData.get(i);
if(approved.getFirstDisplayed() == null)
{
_repoApproved.setDisplayDate(approved.getBuild().getBuildId());
}
openSlots.get(i).setData(approved);
}
});
List<DisplaySlot> outdated = new ArrayList<>();
for(DisplaySlot slot : _displaySlots)
{
if(slot.getData() == null) continue;
if(slot.getData().getFirstDisplayed() == null)
{
_repoApproved.setDisplayDate(slot.getData().getBuild().getBuildId());
slot.getData().setFirstDisplayed(System.currentTimeMillis());
}
else if(slot.getData().getFirstDisplayed() + ROTATION_TIME < System.currentTimeMillis())
{
outdated.add(slot);
}
}
if(outdated.size() > 0)
{
_repoApproved.getToDisplay(true, outdated.size(), _displaySlots.size()).thenCompose(BukkitFuture.accept((list2) ->
{
if(list2.isEmpty()) return;
long[] ids = new long[list2.size()];
for(int i = 0; i < list2.size(); i++)
{
ids[i] = outdated.get(i).getData().getBuild().getBuildId();
}
_repoApproved.setDisplay(false, ids).thenCompose(BukkitFuture.accept((success) ->
{
_repoApproved.getToDisplay(true, _displaySlots.size(), 0).thenCompose(updateTask);
}));
}));
}
else
{
_repoApproved.getToDisplay(true, _displaySlots.size(), 0).thenCompose(updateTask);
}
}
@EventHandler
public void updateParticles(UpdateEvent event)
{
if(event.getType() == UpdateType.FAST)
{
for(DisplaySlot d : _displaySlots)
{
d.updateParticles();
}
}
}
@EventHandler
public void onUnload(ChunkUnloadEvent event)
{
for(Entity e : event.getChunk().getEntities())
{
if(isStatueEntity(e))
{
event.setCancelled(true);
return;
}
}
}
@EventHandler
public void onGrow(BlockGrowEvent event)
{
if(isInsideDisplaySlot(event.getBlock()))
event.setCancelled(true);
}
@EventHandler
public void onStructureGrow(StructureGrowEvent event)
{
for(BlockState b : event.getBlocks())
{
if(isInsideDisplaySlot(b.getBlock()))
{
event.setCancelled(true);
return;
}
}
}
@EventHandler
public void onForm(BlockFormEvent event)
{
if(isInsideDisplaySlot(event.getBlock()))
event.setCancelled(true);
}
@EventHandler
public void onBlockFromTo(BlockFromToEvent event)
{
if(isInsideDisplaySlot(event.getBlock()) || isInsideDisplaySlot(event.getToBlock()))
event.setCancelled(true);
}
@EventHandler
public void onSpread(BlockSpreadEvent event)
{
if(isInsideDisplaySlot(event.getBlock()) || isInsideDisplaySlot(event.getSource()))
event.setCancelled(true);
}
@EventHandler
public void onEntityBlockFormEvent(EntityBlockFormEvent event)
{
if(isInsideDisplaySlot(event.getBlock()) || isStatueEntity(event.getEntity()))
event.setCancelled(true);
}
@EventHandler
public void onBurn(BlockBurnEvent event)
{
if(isInsideDisplaySlot(event.getBlock()))
event.setCancelled(true);
}
@EventHandler
public void onFade(BlockFadeEvent event)
{
if(isInsideDisplaySlot(event.getBlock()))
event.setCancelled(true);
}
@EventHandler
public void onRedstone(BlockRedstoneEvent event)
{
if(isInsideDisplaySlot(event.getBlock()))
event.setNewCurrent(event.getOldCurrent());
}
@EventHandler
public void onDecay(LeavesDecayEvent event)
{
if(isInsideDisplaySlot(event.getBlock()))
event.setCancelled(true);
}
@EventHandler
public void onPhysics(BlockPhysicsEvent event)
{
if(isInsideDisplaySlot(event.getBlock()))
event.setCancelled(true);
}
@EventHandler
public void onBlockIgnite(BlockIgniteEvent event)
{
if(isInsideDisplaySlot(event.getBlock()) || isInsideDisplaySlot(event.getIgnitingBlock()))
event.setCancelled(true);
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if(event.getClickedBlock() == null) return;
if(isInsideDisplaySlot(event.getClickedBlock()))
event.setCancelled(true);
}
@EventHandler
public void ignite(EntityCombustEvent event)
{
if(isStatueEntity(event.getEntity()))
event.setCancelled(true);
}
@EventHandler
public void onInteractEntity(PlayerInteractEntityEvent event)
{
if(isStatueEntity(event.getRightClicked()))
event.setCancelled(true);
}
@EventHandler
public void onInteractEntity(PlayerInteractAtEntityEvent event)
{
if(isStatueEntity(event.getRightClicked()))
event.setCancelled(true);
}
@EventHandler
public void onVehicleCollide(VehicleEntityCollisionEvent event)
{
if(isStatueEntity(event.getVehicle()))
event.setCancelled(true);
}
@EventHandler
public void onMount(EntityMountEvent event)
{
if(isStatueEntity(event.getMount()))
event.setCancelled(true);
}
public boolean isInsideDisplaySlot(Block block)
{
return isInsideDisplaySlot(block.getLocation().add(0.5, 0.5, 0.5));
}
public boolean isInsideDisplaySlot(Location loc)
{
for(DisplaySlot d : _displaySlots)
{
if(d.isInside(loc)) return true;
}
return false;
}
/**
* Check if an entity is spawned in and managed by the mavericks "best of" builds.
* @param e The entity you want to check.
* @return Returns true if the entity is spawned and managed by this mavericks manager.
*/
public boolean isStatueEntity(Entity e)
{
for(DisplaySlot d : _displaySlots)
{
if(d.isDisplaySlotEntity(e)) return true;
}
return false;
}
public MavericksPortalManager getPortalManager()
{
return _portalManager;
}
}

View File

@ -103,14 +103,14 @@ public class SoccerManager extends MiniPlugin
_cornerGoalPlayerA = new Location(hubManager.GetSpawn().getWorld(), -17.5, 67, -71.5);
_cornerGoalPlayerB = new Location(hubManager.GetSpawn().getWorld(), 29.5, 100, -80.5);
_cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), -12.75, 67, -66.75);
_cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), -12.75, 67, -65.75);
_cornerFieldB = new Location(hubManager.GetSpawn().getWorld(), 24.25, 100, -86.25);
_cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 27.75, 67.5, -73.25);
_cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 25.25, 72.5, -79.25);
_cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 27.75, 66.5, -73.25);
_cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 25.25, 74.5, -79.25);
_cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), -15.75, 67.5, -79.75);
_cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), -13.25, 72.5, -73.75);
_cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), -15.75, 66.5, -79.75);
_cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), -13.25, 74.5, -73.75);
//Store Gadgets
for (Gadget gadget : gadgetManager.getGadgets(GadgetType.COSTUME))
@ -351,6 +351,8 @@ public class SoccerManager extends MiniPlugin
public boolean inPlayerArena(Entity entity)
{
if(!entity.getWorld().equals(_cornerFieldA.getWorld())) return false;
return UtilAlg.inBoundingBox(entity.getLocation(), _cornerFieldPlayerA, _cornerFieldPlayerB) ||
UtilAlg.inBoundingBox(entity.getLocation(), _cornerGoalPlayerA, _cornerGoalPlayerB);
}

View File

@ -83,6 +83,9 @@ public class StackerManager extends MiniPlugin implements IThrown
if (stackee instanceof EnderDragon)
return;
if (Manager.getMavericksManager().isStatueEntity(stackee))
return;
if (stackee instanceof Player && ((Player)stackee).getGameMode() != GameMode.SURVIVAL)
return;

View File

@ -2,7 +2,6 @@ package mineplex.hub.modules;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
@ -10,10 +9,8 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.npc.NpcManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.Hub;
import mineplex.hub.HubManager;
import mineplex.hub.HubType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -85,7 +82,6 @@ public class WorldManager extends MiniPlugin
}
world.setStorm(false);
world.setThundering(false);
fixEntities();
}
@EventHandler
@ -245,9 +241,9 @@ public class WorldManager extends MiniPlugin
return;
}
for (Player player : UtilServer.getPlayers())
for (Player player : Manager.GetSpawn().getWorld().getPlayers())
{
if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 210)
if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 350)
{
player.eject();
player.leaveVehicle();
@ -440,15 +436,4 @@ public class WorldManager extends MiniPlugin
event.setCancelled(true);
}
}
public void fixEntities()
{
NpcManager npcManager = ((Hub) Manager.getPlugin()).getNpcManager();
runSyncLater(() -> Manager.GetSpawn().getWorld().getEntities().stream().filter(e -> npcManager.getNpcByEntity(e) != null).forEach(e ->
{
float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory(e.getLocation(), Manager.GetSpawn()));
e.teleport(new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), yaw, 0f));
}), 120L);
}
}

View File

@ -0,0 +1,154 @@
package mineplex.hub.modules.mavericks;
import mineplex.core.gadget.types.GadgetType;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityPortalEnterEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.npc.event.NpcDamageByEntityEvent;
import mineplex.core.npc.event.NpcInteractEntityEvent;
import mineplex.core.recharge.Recharge;
import mineplex.hub.HubManager;
/**
* A small teleportation manager to manage the portal from the hub to the mavericks world and back.
*/
public class MavericksPortalManager extends MiniPlugin
{
private Box _portalMavericksHub;
private Location _destHub;
private Location _destMavericks;
private CosmeticManager _cosmeticManager;
public MavericksPortalManager(JavaPlugin plugin, HubManager hubManager, MavericksWorldManager worldManager, CosmeticManager cosmeticManager)
{
super("Mavericks Teleporter", plugin);
_cosmeticManager = cosmeticManager;
_destMavericks = worldManager.getSpawn();
_portalMavericksHub = new Box(worldManager.getWorld().getName(), new Vector(3, 20, 316), new Vector(-1, 25, 317));
_destHub = hubManager.GetSpawn();
}
@EventHandler
public void onEnable(GadgetEnableEvent event)
{
if (event.getPlayer().getWorld().equals(_destMavericks.getWorld()) && event.getGadget().getGadgetType() != GadgetType.COSTUME)
{
event.setCancelled(true);
}
}
@EventHandler
public void onUseNPC(NpcInteractEntityEvent event)
{
if (ChatColor.stripColor(event.getNpc().getName()).contains("Mavericks Lobby"))
{
useMavsNpc(event.getPlayer());
}
}
@EventHandler
public void onUseNPC(NpcDamageByEntityEvent event)
{
if (!(event.getDamager() instanceof Player))
{
return;
}
Player player = (Player) event.getDamager();
if (ChatColor.stripColor(event.getNpc().getName()).contains("Mavericks Lobby") && Recharge.Instance.use(player, "Go to Mavs Lobby", 1000, false, false))
{
useMavsNpc(player);
}
}
@EventHandler
public void onEnter(EntityPortalEnterEvent event)
{
if (!(event.getEntity() instanceof Player))
{
return;
}
Player p = (Player) event.getEntity();
Box box = isInside(p);
if (box == null)
{
return;
}
_cosmeticManager.getPetManager().disableAll(p);
_cosmeticManager.getMountManager().DisableAll(p);
_cosmeticManager.getGadgetManager().disableAll(p);
if (box == _portalMavericksHub)
{
p.teleport(_destHub);
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Hub") + " area."));
}
p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
}
private void useMavsNpc(Player player)
{
_cosmeticManager.getPetManager().disableAll(player);
_cosmeticManager.getMountManager().DisableAll(player);
_cosmeticManager.getGadgetManager().disableAll(player);
player.teleport(_destMavericks);
player.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area."));
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
}
private Box isInside(Player player)
{
if (_portalMavericksHub.isInside(player.getLocation()))
{
return _portalMavericksHub;
}
return null;
}
/**
* A small AABB box util class.
*/
private static class Box
{
private Vector _min;
private Vector _max;
private String _world;
public Box(String world, Vector a, Vector b)
{
_world = world;
_min = Vector.getMinimum(a, b);
_max = Vector.getMaximum(a, b);
}
public boolean isInside(Vector v)
{
return v.isInAABB(_min, _max);
}
public boolean isInside(Location loc)
{
return loc.getWorld().getName().equals(_world) && isInside(loc.toVector());
}
}
}

View File

@ -0,0 +1,93 @@
package mineplex.hub.modules.mavericks;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.worldgen.WorldGenCleanRoom;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
/**
* A small world manager for the mavericks world.
*/
public class MavericksWorldManager extends MiniPlugin
{
private World _world;
private Location _spawn;
public MavericksWorldManager(JavaPlugin plugin)
{
super("Mavericks World", plugin);
WorldCreator wc = new WorldCreator("Mav_Lobby");
wc.generator(new WorldGenCleanRoom());
_world = wc.createWorld();
_world.setGameRuleValue("doDaylightCycle", "false");
_world.setTime(6000);
_world.setPVP(true);
_spawn = new Location(_world, 1.5, 22, 287.5, -180, 0);
}
public Location getSpawn()
{
return _spawn.clone();
}
public World getWorld()
{
return _world;
}
public boolean isInWorld(Entity e)
{
return _world.equals(e.getWorld());
}
@EventHandler
public void onSpawn(CreatureSpawnEvent event)
{
if(isInWorld(event.getEntity()))
{
if(event.getSpawnReason() == SpawnReason.CUSTOM) return;
event.setCancelled(true);
}
}
@EventHandler
public void onWeather(WeatherChangeEvent event)
{
if(!event.getWorld().equals(_world)) return;
if(!event.toWeatherState()) return;
event.setCancelled(true);
}
@EventHandler
public void borderCheck(UpdateEvent event)
{
if(event.getType() != UpdateType.FAST)
{
for(Player p : _world.getPlayers())
{
if (UtilMath.offset(p.getLocation(), _world.getSpawnLocation()) > 400)
{
p.eject();
p.leaveVehicle();
p.teleport(getSpawn());
}
}
}
}
}

View File

@ -0,0 +1,647 @@
package mineplex.hub.modules.mavericks.basketball;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import net.minecraft.server.v1_8_R3.BlockPosition;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
/**
* Instance class for running a basketball game in the hub
*/
public class BasketballGame implements Listener
{
private HubManager _hub;
private World _world;
private List<Player> _players = Lists.newArrayList();
private Entity _ball;
private Player _dribbling;
private ThrowData _throwData;
private static final double THREE_POINTER_DISTANCE = 27;
private boolean _frozen = false;
private long _lastDribbleAnim = 0;
private long _lastDribbleMove = 0;
private long _start;
private HashMap<BasketballTeam, Block> _hoops = new HashMap<>();
private double _maxX = 0;
private double _minX = 0;
private double _maxZ = 0;
private double _minZ = 0;
private double _velocity = -7;
private int _redScore;
private int _blueScore;
public BasketballGame(JavaPlugin plugin, HubManager hub, World world)
{
_hub = hub;
_world = world;
setupMap();
Bukkit.getPluginManager().registerEvents(this, plugin);
beginGame();
_start = System.currentTimeMillis();
}
private Entity spawnBall(Location loc)
{
_velocity = -7;
Entity e = loc.getWorld().spawnEntity(loc, EntityType.SLIME);
UtilEnt.Vegetate(e, true);
UtilEnt.ghost(e, true, false);
((Slime)e).setSize(1);
return e;
}
private BasketballTeam getTeam(Player player)
{
if (player.getInventory().getHelmet() == null || !(player.getInventory().getHelmet().getItemMeta() instanceof LeatherArmorMeta))
{
return null;
}
Color color = ((LeatherArmorMeta)player.getInventory().getHelmet().getItemMeta()).getColor();
return BasketballTeam.getFromColor(color);
}
private boolean checkCatching()
{
if (_ball != null)
{
for (Player player : _players)
{
if (UtilMath.offset(player, _ball) <= 1.5)
{
if (Recharge.Instance.usable(player, "Catch Ball", false))
{
catchBall(player);
return true;
}
}
}
}
return false;
}
private int getWorth(Location start, Location hoop)
{
if (UtilMath.offset2d(start, hoop) >= THREE_POINTER_DISTANCE)
{
return 3;
}
return 2;
}
private void reboundBall()
{
if (_ball == null)
{
return;
}
Vector vec = _ball.getVelocity();
//Rebound Y
if (UtilEnt.isGrounded(_ball))
{
if (vec.getY() < 0)
{
vec.setY(_ball.getVelocity().getY() * _velocity);
_velocity = Math.max(0, _velocity - .5);
}
}
if (!UtilEnt.isGrounded(_ball))
{
vec.setY(vec.getY() - 0.08);
}
//Rebound X
if ((vec.getX() > 0 && _ball.getLocation().getX() >= _maxX) || (vec.getX() < 0 && _ball.getLocation().getX() <= _minX))
{
vec.setX(vec.getX() * -1);
vec = vec.multiply(0.9);
}
//Rebound Z
if ((vec.getZ() > 0 && _ball.getLocation().getZ() >= _maxZ) || (vec.getZ() < 0 && _ball.getLocation().getZ() <= _minZ))
{
vec.setZ(vec.getZ() * -1);
vec = vec.multiply(0.9);
}
_ball.setVelocity(vec);
}
private void spawnNeutralBall()
{
Location loc = DataLoc.CENTER_COURT.getLocation(_world);
_ball = spawnBall(loc);
}
private void throwBall(Player origin, boolean right)
{
Entity e = spawnBall(origin.getEyeLocation());
double power = 1.7;
if (right)
{
power = 3.1;
}
e.setVelocity(origin.getEyeLocation().getDirection().normalize().multiply(power));
Recharge.Instance.use(origin, "Catch Ball", 3000, false, false, false);
_ball = e;
if (_dribbling != null)
{
UtilInv.removeAll(_dribbling, Material.SLIME_BALL, (byte)0);
_dribbling = null;
}
_throwData = new ThrowData(origin, getTeam(origin));
}
private void catchBall(Player player)
{
_lastDribbleMove = System.currentTimeMillis();
_dribbling = player;
for (int i = 0; i < 8; i++)
{
_dribbling.getInventory().setItem(i, new ItemBuilder(Material.SLIME_BALL).setTitle(C.cGold + "Basketball").build());
}
_ball.remove();
_ball = null;
_throwData = null;
}
private void setupMap()
{
Block redHoop = DataLoc.RED_HOOP.getLocation(_world).getBlock();
redHoop.setType(Material.WEB);
Block blueHoop = DataLoc.BLUE_HOOP.getLocation(_world).getBlock();
blueHoop.setType(Material.WEB);
_hoops.put(BasketballTeam.RED, redHoop);
_hoops.put(BasketballTeam.BLUE, blueHoop);
_maxX = DataLoc.CORNER_MAX.getLocation(_world).getX();
_minX = DataLoc.CORNER_MIN.getLocation(_world).getX();
_maxZ = DataLoc.CORNER_MAX.getLocation(_world).getZ();
_minZ = DataLoc.CORNER_MIN.getLocation(_world).getZ();
}
private void beginGame()
{
spawnNeutralBall();
_ball.setVelocity(_ball.getVelocity().add(new Vector(0, 1.5, 0)));
}
private void stealBall(Player to, Player from)
{
Recharge.Instance.use(to, "ThrowBall", 1500, false, false, false);
_lastDribbleMove = System.currentTimeMillis();
_dribbling = to;
for (int i = 0; i < 8; i++)
{
to.getInventory().setItem(i, new ItemBuilder(Material.SLIME_BALL).setTitle(C.cGold + "Basketball").build());
}
UtilInv.removeAll(from, Material.SLIME_BALL, (byte)0);
for (Player player : _players)
{
UtilPlayer.message(player, F.main("Game", getTeam(to).getChatColor() + to.getName() + C.cGray + " has stolen the ball from " + getTeam(from).getChatColor() + from.getName() + C.cGray + "!"));
}
}
private void score(BasketballTeam team, Location hoop)
{
int points = getWorth(_throwData.getThrowOrigin(), hoop);
if (team == BasketballTeam.RED)
{
_redScore += points;
}
else if (team == BasketballTeam.BLUE)
{
_blueScore += points;
}
UtilTextMiddle.display(team.getName() + " has scored!", BasketballTeam.RED.getChatColor() + "" + _redScore + C.cWhite + " - " + BasketballTeam.BLUE.getChatColor() + _blueScore, 0, 20 * 2, 0, _players.toArray(new Player[] {}));
_ball.remove();
_ball = null;
_throwData = null;
BasketballTeam other = getOtherTeam(team);
List<Player> teamD = Lists.newArrayList();
List<Player> teamO = Lists.newArrayList();
for (Player player : _players)
{
if (getTeam(player) == team)
{
teamO.add(player);
}
else
{
teamD.add(player);
}
}
for (int i = 0; i < teamO.size(); i++)
{
Player player = teamO.get(i);
int locId = Math.min(i, team.getSpawns(_world).length);
player.teleport(team.getSpawns(_world)[locId]);
}
if (!teamD.isEmpty())
{
//Select player to get ball
Player carrier = teamD.get(new Random().nextInt(teamD.size()));
for (int i = 0; i < teamD.size(); i++)
{
Player player = teamD.get(i);
if (carrier.getEntityId() != player.getEntityId())
{
Location loc = null;
int locId = i;
if (other == BasketballTeam.BLUE)
{
locId = Math.min(DataLoc.BLUE_SCORE_SPAWN.getLocations(_world).length - 1, locId);
loc = DataLoc.BLUE_SCORE_SPAWN.getLocations(_world)[locId];
}
else if (other == BasketballTeam.RED)
{
locId = Math.min(DataLoc.RED_SCORE_SPAWN.getLocations(_world).length - 1, locId);
loc = DataLoc.RED_SCORE_SPAWN.getLocations(_world)[locId];
}
if (loc != null)
{
player.teleport(loc);
}
}
}
Location teleport = DataLoc.BLUE_HOOP.getLocation(_world);
if (other == BasketballTeam.RED)
teleport = DataLoc.RED_UNDER_HOOP.getLocation(_world);
teleport.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(teleport, DataLoc.CENTER_COURT.getLocation(_world))));
teleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(teleport, DataLoc.CENTER_COURT.getLocation(_world))));
carrier.teleport(teleport);
_lastDribbleMove = System.currentTimeMillis();
_dribbling = carrier;
for (int i = 0; i < 8; i++)
{
_dribbling.getInventory().setItem(i, new ItemBuilder(Material.SLIME_BALL).setTitle(C.cGold + "Basketball").build());
}
}
else
{
spawnNeutralBall();
}
}
private void checkScoring()
{
if (_ball == null)
{
return;
}
for (BasketballTeam team : _hoops.keySet())
{
Location check = _hoops.get(team).getLocation().add(.5, 0, .5);
if (UtilMath.offset(check, _ball.getLocation()) <= .9)
{
score(getOtherTeam(team), check);
return;
}
}
}
private void dribble()
{
if (_dribbling == null)
{
_lastDribbleAnim = System.currentTimeMillis();
return;
}
UtilTextBottom.display(C.cRed + "You have the ball!", _dribbling);
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _dribbling.getEyeLocation(), new Random().nextFloat(), new Random().nextFloat(), new Random().nextFloat(), 0, 1, ViewDist.MAX);
if (System.currentTimeMillis() - _lastDribbleAnim > 333)
{
_lastDribbleAnim = System.currentTimeMillis();
Item item = _dribbling.getWorld().dropItem(_dribbling.getLocation(), new ItemStack(Material.SLIME_BALL));
item.setPickupDelay(Integer.MAX_VALUE);
Bukkit.getScheduler().runTaskLater(_hub.getPlugin(), () -> {
item.remove();
}, 7);
}
}
/**
* Checks how long this game has been running
* @return The amount of time this game has been running
*/
public long getGameAge()
{
return System.currentTimeMillis() - _start;
}
/**
* Checks whether a location is out of bounds of the main arena
* @param loc The location to check
* @param ball Whether to base calculations on the location being the location of the ball
* @return Whether the location is out of bounds
*/
public boolean isOutOfBounds(Location loc, boolean ball)
{
if (ball)
{
if ((loc.getX() - 1) > _maxX || (loc.getX() + 1) < _minX)
{
return true;
}
if ((loc.getZ() - 1) > _maxZ || (loc.getZ() + 1) < _minZ)
{
return true;
}
return false;
}
if (loc.getX() >= _maxX || loc.getX() <= _minX)
{
return true;
}
if (loc.getZ() >= _maxZ || loc.getZ() <= _minZ)
{
return true;
}
return false;
}
/**
* Fetches the entity representing the ball in this game
* @return The entity representing the ball, or null if a player is dribbling
*/
public Entity getBall()
{
return _ball;
}
/**
* Quickly searches for the opposite team of the one given
* @param team The team to check
* @return The opposite team
*/
public BasketballTeam getOtherTeam(BasketballTeam team)
{
if (team == BasketballTeam.RED)
{
return BasketballTeam.BLUE;
}
if (team == BasketballTeam.BLUE)
{
return BasketballTeam.RED;
}
return null;
}
/**
* Fetches the list of players in this game
* @return The list containing all players in this game
*/
public List<Player> getPlayers()
{
return _players;
}
/**
* Forces the game to end, unregistering all listeners and cleaning up created entities
*/
public void end()
{
HandlerList.unregisterAll(this);
if (_ball != null)
{
_ball.remove();
}
if (_dribbling != null)
{
UtilInv.removeAll(_dribbling, Material.SLIME_BALL, (byte)0);
}
}
@EventHandler
public void onSwipe(EntityDamageByEntityEvent event)
{
if (_frozen)
return;
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
{
return;
}
if (!_players.contains((Player)event.getEntity()) || !_players.contains((Player)event.getDamager()))
{
return;
}
Player player = (Player)event.getDamager();
Player target = (Player)event.getEntity();
if (_dribbling != null && getTeam(player) != getTeam(target) && target.getEntityId() == _dribbling.getEntityId())
{
if (Recharge.Instance.usable(player, "Steal Ball", true))
{
Recharge.Instance.use(player, "Steal Ball", 1000 * 5, true, false, false);
if (new Random().nextDouble() <= .15)
{
stealBall(player, target);
}
else
{
player.sendMessage(F.main("Game", "Your steal attempt failed!"));
}
}
}
}
@EventHandler
public void onThrow(PlayerInteractEvent event)
{
if (_frozen)
return;
if (_dribbling != null && event.getPlayer().getEntityId() == _dribbling.getEntityId() && Recharge.Instance.usable(_dribbling, "ThrowBall", false))
{
throwBall(event.getPlayer(), event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK);
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.FASTEST)
{
for (Player player : _players)
{
CraftPlayer cp = (CraftPlayer)player;
for (int x = (int)Math.floor(cp.getHandle().getBoundingBox().a + 0.001); x <= (int)Math.floor(cp.getHandle().getBoundingBox().d - 0.001); x++)
{
for (int y = (int)Math.floor(cp.getHandle().getBoundingBox().b + 0.001); y <= (int)Math.floor(cp.getHandle().getBoundingBox().e - 0.001); y++)
{
for (int z = (int)Math.floor(cp.getHandle().getBoundingBox().c + 0.001); z <= (int)Math.floor(cp.getHandle().getBoundingBox().f - 0.001); z++)
{
CraftWorld world = (CraftWorld)_world;
if (net.minecraft.server.v1_8_R3.Block.getId(world.getHandle().getType(new BlockPosition(x, y, z)).getBlock()) == Material.WEB.getId())
{
player.teleport(new Location(player.getWorld(), x, y - 2, z));
}
}
}
}
}
if (_dribbling != null && (!_dribbling.isOnline() || !_players.contains(_dribbling)))
{
if (_dribbling != null)
{
UtilInv.removeAll(_dribbling, Material.SLIME_BALL, (byte)0);
}
_dribbling = null;
spawnNeutralBall();
}
if (_ball != null)
{
if (isOutOfBounds(_ball.getLocation(), true))
{
if (_ball.hasMetadata("Respawn"))
{
if (UtilTime.elapsed(_ball.getMetadata("Respawn").get(0).asLong(), 2000))
{
_ball.removeMetadata("Respawn", _hub.getPlugin());
_ball.setVelocity(UtilAlg.getTrajectory(_ball.getLocation(), DataLoc.CENTER_COURT.getLocation(_world)));
}
}
else
{
_ball.setMetadata("Respawn", new FixedMetadataValue(_hub.getPlugin(), System.currentTimeMillis()));
}
}
else
{
if (_ball.hasMetadata("Respawn"))
{
_ball.removeMetadata("Respawn", _hub.getPlugin());
}
}
}
reboundBall();
if (!checkCatching())
{
checkScoring();
}
dribble();
if (_dribbling != null)
{
if (UtilTime.elapsed(_lastDribbleMove, 15000))
{
throwBall(_dribbling, false);
}
}
}
}
@EventHandler
public void onMove(PlayerMoveEvent event)
{
if (!_players.contains(event.getPlayer()))
{
return;
}
if (UtilMath.offset2d(event.getFrom(), event.getTo()) <= 0)
{
return;
}
if (_frozen)
{
event.setTo(event.getFrom());
return;
}
if (_dribbling != null && event.getPlayer().getEntityId() == _dribbling.getEntityId())
{
_lastDribbleMove = System.currentTimeMillis();
}
}
}

View File

@ -0,0 +1,324 @@
package mineplex.hub.modules.mavericks.basketball;
import java.util.ArrayList;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.gadgets.outfit.OutfitTeam;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.modules.mavericks.MavericksWorldManager;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
/**
* Manager class for creating and maintaining basketball games in the hub
*/
public class BasketballManager extends MiniPlugin
{
private HubManager _hubManager;
private MavericksWorldManager _world;
private ArrayList<OutfitTeam> _teamArmor = Lists.newArrayList();
private BasketballGame _game;
public BasketballManager(JavaPlugin plugin, MavericksWorldManager world, HubManager hub)
{
super("Basketball Manager", plugin);
_world = world;
_hubManager = hub;
for (Gadget outfit : hub.GetGadget().getGadgets(GadgetType.COSTUME))
{
if (outfit instanceof OutfitTeam)
{
_teamArmor.add((OutfitTeam)outfit);
}
}
}
@Override
public void disable()
{
if (_game != null)
{
_game.end();
_game = null;
}
}
private void setBasketballMode(Player player, boolean enabled, Color color)
{
if (_game == null)
{
return;
}
if (enabled)
{
_game.getPlayers().add(player);
if (color == null)
UtilPlayer.message(player, F.main("Basketball", "You have entered " + F.elem("Basketball Mode") + "."));
else if (color == Color.RED)
UtilPlayer.message(player, F.main("Basketball", "You have joined " + F.elem(C.cRed + "Red Basketball Team") + "."));
else if (color == Color.AQUA)
UtilPlayer.message(player, F.main("Basketball", "You have joined " + F.elem(C.cAqua + "Blue Basketball Team") + "."));
ArrayList<String> outfit = new ArrayList<String>();
outfit.add("Team Helmet");
outfit.add("Team Shirt");
outfit.add("Team Pants");
outfit.add("Team Boots");
_hubManager.GetGadget().disableAll(player, outfit);
_hubManager.GetMount().DisableAll(player);
_hubManager.getPetManager().disableAll(player);
}
else
{
_game.getPlayers().remove(player);
UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Basketball Mode") + "."));
}
}
/**
* Fetches the color of a player's team based on their outfit
* @param player The player to check
* @return The color of the player's team, or null if they are not wearing a team outfit
*/
public Color getTeamColor(Player player)
{
//All pieces are always same color!
for (OutfitTeam outfit : _teamArmor)
{
if (outfit.isActive(player))
return outfit.getTeamColor(player);
}
return null;
}
/**
* Checks whether an entity is in the bounds considered the basketball court
* @param entity The entity to check
* @return Whether the entity is in the bounds considered the basketball court
*/
public boolean inPlayerArena(Entity entity)
{
if(!entity.getWorld().equals(_world.getWorld()))
{
return false;
}
Location loc = entity.getLocation();
return (loc.getX() > DataLoc.CORNER_MIN.getLocation(_world.getWorld()).getX() && loc.getX() < DataLoc.CORNER_MAX.getLocation(_world.getWorld()).getX()) && (loc.getZ() > DataLoc.CORNER_MIN.getLocation(_world.getWorld()).getZ() && loc.getZ() < DataLoc.CORNER_MAX.getLocation(_world.getWorld()).getZ());
}
@EventHandler
public void clean(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (Entity ent : _world.getWorld().getEntities())
{
if (ent instanceof Player)
continue;
if (_game != null && _game.getBall() != null && _game.getBall().equals(ent))
continue;
if (inPlayerArena(ent))
{
if (ent instanceof Bat || ent instanceof WitherSkull || ent instanceof TNTPrimed || ent instanceof Firework)
{
ent.remove();
continue;
}
Location bounce = UtilAlg.getMidpoint(DataLoc.CORNER_MAX.getLocation(_world.getWorld()), DataLoc.CORNER_MIN.getLocation(_world.getWorld()));
bounce.setY(Math.min(DataLoc.CORNER_MAX.getLocation(_world.getWorld()).getY(), DataLoc.CORNER_MIN.getLocation(_world.getWorld()).getY()));
Entity bottom = ent;
if (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory(bounce, ent.getLocation()), 1, false, 0, 0.4, 1, true);
}
}
if (_game != null && _game.getGameAge() > 5000 && _game.getPlayers().size() < 1)
{
_game.end();
_game = null;
}
}
@EventHandler
public void joinLeaveGame(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : UtilServer.getPlayers())
{
if (_game != null && _game.getPlayers().contains(player))
{
if (!inPlayerArena(player))
{
setBasketballMode(player, false, null);
continue;
}
//Took armor off
Color color = getTeamColor(player);
if (color == null || (color != Color.RED && color != Color.AQUA))
{
setBasketballMode(player, false, null);
}
}
else
{
if (inPlayerArena(player))
{
Color color = getTeamColor(player);
if (color != null && (color == BasketballTeam.RED.getColor() || color == BasketballTeam.BLUE.getColor()) && _game == null)
{
_game = new BasketballGame(getPlugin(), _hubManager, _world.getWorld());
}
//Join
if (color != null && (color == Color.RED || color == Color.AQUA) && _game != null && _game.getPlayers().size() < 10)
{
setBasketballMode(player, true, color);
}
//Eject
else
{
Location bounce = UtilAlg.getMidpoint(DataLoc.CORNER_MAX.getLocation(_world.getWorld()), DataLoc.CORNER_MIN.getLocation(_world.getWorld()));
bounce.setY(Math.min(DataLoc.CORNER_MAX.getLocation(_world.getWorld()).getY(), DataLoc.CORNER_MIN.getLocation(_world.getWorld()).getY()));
Entity bottom = player;
if (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(bounce, player.getLocation()), 1, false, 0, 0.8, 1, true);
if (Recharge.Instance.use(player, "Basketball Eject", 5000, false, false))
{
if (_game == null || (_game != null && _game.getPlayers().size() < 10))
{
UtilPlayer.message(player, F.main("Slimeball", "You must be wearing Red/Blue Team Outfit."));
UtilPlayer.message(player, F.main("Slimeball", "Type " + F.elem("/team red") + " or " + F.elem("/team blue") + "!"));
}
else
{
UtilPlayer.message(player, F.main("Slimeball", "The game is currently full!"));
}
}
}
}
}
}
}
@EventHandler
public void disableGadgets(GadgetEnableEvent event)
{
if (_game != null && _game.getPlayers().contains(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void disableMounts(MountActivateEvent event)
{
if (_game != null && _game.getPlayers().contains(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void playerGrabSlime(PlayerInteractEntityEvent event)
{
if (_game != null && _game.getPlayers().contains(event.getPlayer()))
{
event.setCancelled(true);
}
if (_game != null && _game.getBall() != null && event.getRightClicked().equals(_game.getBall()))
{
event.setCancelled(true);
}
}
@EventHandler
public void disableStacker(StackerEvent event)
{
if (_game != null && _game.getPlayers().contains(event.getEntity()))
{
event.setCancelled(true);
}
}
@EventHandler
public void disableGuardianLazer(GadgetSelectLocationEvent event)
{
if (_game != null && !_game.isOutOfBounds(event.getLocation(), false))
{
event.setCancelled(true);
}
}
@EventHandler
public void disableVelocity(PlayerVelocityEvent event)
{
// Disable velocity but allow double jumping.
if (_game != null && _game.getPlayers().contains(event.getPlayer()) && !_hubManager.getJumpManager().hasDoubleJumped(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
if (_game != null)
{
_game.getPlayers().remove(event.getPlayer());
}
}
}

Some files were not shown because too many files have changed in this diff Show More