Merge branch 'feature/mavericks-master-builders' of github.com:Mineplex-LLC/Minecraft-PC into update/basketball-game
This commit is contained in:
commit
5ecfaef413
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,21 +45,25 @@ public class Pair<L, R> implements Serializable {
|
||||
return getLeft().toString() + ":" + getRight().toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof Pair))
|
||||
return false;
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Pair localPair = (Pair) obj;
|
||||
Pair<?, ?> pair = (Pair<?, ?>) o;
|
||||
|
||||
if (getLeft() != null ? !getLeft().equals(localPair.getLeft()) : localPair.getLeft() != null)
|
||||
return false;
|
||||
if (getRight() != null ? !getRight().equals(localPair.getRight()) : localPair.getRight() != null)
|
||||
return false;
|
||||
return true;
|
||||
if (left != null ? !left.equals(pair.left) : pair.left != null) return false;
|
||||
return right != null ? right.equals(pair.right) : pair.right == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = left != null ? left.hashCode() : 0;
|
||||
result = 31 * result + (right != null ? right.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
@ -224,6 +317,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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -1,12 +1,10 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class F
|
||||
{
|
||||
public static String main(String module, String body)
|
||||
@ -30,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;
|
||||
@ -200,7 +203,7 @@ public class F
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public static String currency(CurrencyType type, int amount)
|
||||
{
|
||||
return type.getString(amount) + ChatColor.RESET + C.mBody;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -173,7 +173,17 @@ public class UtilInv
|
||||
return getItems(player, true, true, true);
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getItemsUncloned(Player player)
|
||||
{
|
||||
return getItems(player, true, true, true, false);
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor, boolean getCrafting)
|
||||
{
|
||||
return getItems(player, getArmor, getCursor, getCrafting, true);
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor, boolean getCrafting, boolean clone)
|
||||
{
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
@ -182,7 +192,7 @@ public class UtilInv
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item.clone());
|
||||
items.add(clone ? item.clone() : item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +202,7 @@ public class UtilInv
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item.clone());
|
||||
items.add(clone ? item.clone() : item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,7 +212,7 @@ public class UtilInv
|
||||
ItemStack cursorItem = player.getItemOnCursor();
|
||||
|
||||
if (cursorItem != null && cursorItem.getType() != Material.AIR)
|
||||
items.add(cursorItem.clone());
|
||||
items.add(clone ? cursorItem.clone() : cursorItem);
|
||||
}
|
||||
|
||||
if (getCrafting)
|
||||
@ -215,7 +225,7 @@ public class UtilInv
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item.clone());
|
||||
items.add(clone ? item.clone() : item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,51 +8,51 @@ import org.bukkit.inventory.ItemStack;
|
||||
public enum CountryFlag
|
||||
{
|
||||
|
||||
Brazil(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)),
|
||||
Usa(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)),
|
||||
Canada(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
|
||||
BRAZIL(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)),
|
||||
USA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)),
|
||||
CANADA(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
|
||||
new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
|
||||
Uk(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT),
|
||||
UK(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT),
|
||||
new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.CROSS)),
|
||||
Ireland(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)),
|
||||
Spain(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.RED, PatternType.STRIPE_RIGHT)),
|
||||
Japan(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
|
||||
South_Sudan(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_RIGHT),
|
||||
IRELAND(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)),
|
||||
SPAIN(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.RED, PatternType.STRIPE_RIGHT)),
|
||||
JAPAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
|
||||
SOUTH_SUDAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_RIGHT),
|
||||
new Pattern(DyeColor.GREEN, PatternType.TRIANGLE_BOTTOM)),
|
||||
Jamaica(DyeColor.GREEN, new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_TOP), new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_BOTTOM),
|
||||
JAMAICA(DyeColor.GREEN, new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_TOP), new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_BOTTOM),
|
||||
new Pattern(DyeColor.YELLOW, PatternType.CROSS)),
|
||||
Italy(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM)),
|
||||
Senegal(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM),
|
||||
ITALY(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM)),
|
||||
SENEGAL(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM),
|
||||
new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)),
|
||||
France(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM)),
|
||||
India(DyeColor.WHITE, new Pattern(DyeColor.ORANGE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.GREEN, PatternType.STRIPE_RIGHT),
|
||||
FRANCE(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM)),
|
||||
INDIA(DyeColor.WHITE, new Pattern(DyeColor.ORANGE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.GREEN, PatternType.STRIPE_RIGHT),
|
||||
new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)),
|
||||
Belgium(DyeColor.YELLOW, new Pattern(DyeColor.BLACK, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
|
||||
England(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS)),
|
||||
Austria(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)),
|
||||
Armenia(DyeColor.RED, new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_RIGHT)),
|
||||
Argentina(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
|
||||
Greece(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.LIGHT_BLUE, PatternType.SQUARE_BOTTOM_LEFT)),
|
||||
Czech_Republic(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.BLUE, PatternType.TRIANGLE_BOTTOM)),
|
||||
Romania(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
|
||||
Honduras(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT)),
|
||||
Algeria(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR), new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
|
||||
Portugal(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.STRIPE_TOP), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
|
||||
Bahrain(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.TRIANGLES_BOTTOM)),
|
||||
Germany(DyeColor.RED, new Pattern(DyeColor.BLACK, PatternType.STRIPE_LEFT), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_RIGHT)),
|
||||
Gabon(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT), new Pattern(DyeColor.LIME, PatternType.STRIPE_LEFT)),
|
||||
Scotland(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.CROSS)),
|
||||
Peru(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM)),
|
||||
Tanzania(DyeColor.LIME, new Pattern(DyeColor.LIGHT_BLUE, PatternType.DIAGONAL_RIGHT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_DOWNLEFT)),
|
||||
Morocco(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)),
|
||||
Solomon_Islands(DyeColor.GREEN, new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_LEFT_MIRROR), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_DOWNRIGHT)),
|
||||
Switzerland(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
|
||||
BELGIUM(DyeColor.YELLOW, new Pattern(DyeColor.BLACK, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
|
||||
ENGLAND(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS)),
|
||||
AUSTRIA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)),
|
||||
ARMENIA(DyeColor.RED, new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_RIGHT)),
|
||||
ARGENTINA(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
|
||||
GREECE(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.LIGHT_BLUE, PatternType.SQUARE_BOTTOM_LEFT)),
|
||||
CZECH_REPUBLIC(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.BLUE, PatternType.TRIANGLE_BOTTOM)),
|
||||
ROMANIA(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
|
||||
HONDURAS(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT)),
|
||||
ALGERIA(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR), new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
|
||||
PORTUGAL(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.STRIPE_TOP), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
|
||||
BAHRAIN(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.TRIANGLES_BOTTOM)),
|
||||
GERMANY(DyeColor.RED, new Pattern(DyeColor.BLACK, PatternType.STRIPE_LEFT), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_RIGHT)),
|
||||
GABON(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT), new Pattern(DyeColor.LIME, PatternType.STRIPE_LEFT)),
|
||||
SCOTLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.CROSS)),
|
||||
PERU(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM)),
|
||||
TANZANIA(DyeColor.LIME, new Pattern(DyeColor.LIGHT_BLUE, PatternType.DIAGONAL_RIGHT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_DOWNLEFT)),
|
||||
MOROCCO(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)),
|
||||
SOLOMON_ISLANDS(DyeColor.GREEN, new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_LEFT_MIRROR), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_DOWNRIGHT)),
|
||||
SWITZERLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
|
||||
new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
|
||||
Finland(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_LEFT), new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_RIGHT),
|
||||
FINLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_LEFT), new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_RIGHT),
|
||||
new Pattern(DyeColor.WHITE, PatternType.HALF_HORIZONTAL), new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER)),
|
||||
South_Africa(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL),
|
||||
SOUTH_AFRICA(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL),
|
||||
new Pattern(DyeColor.GREEN, PatternType.STRIPE_CENTER), new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM)),
|
||||
Poland(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR));
|
||||
POLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR));
|
||||
|
||||
private DyeColor _baseColor;
|
||||
private Pattern[] _patterns;
|
||||
|
@ -35,7 +35,7 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
||||
synchronized (_clientDataLock)
|
||||
{
|
||||
if (!_clientData.containsKey(name))
|
||||
_clientData.put(name, AddPlayer(name));
|
||||
_clientData.put(name, addPlayer(name));
|
||||
|
||||
return _clientData.get(name);
|
||||
}
|
||||
@ -66,5 +66,5 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract DataType AddPlayer(String player);
|
||||
protected abstract DataType addPlayer(String player);
|
||||
}
|
||||
|
@ -57,7 +57,14 @@ public class CoreClientManager extends MiniPlugin
|
||||
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
||||
private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
|
||||
|
||||
private final Rank WHITELIST_BYPASS;
|
||||
|
||||
public CoreClientManager(JavaPlugin plugin, String webServer)
|
||||
{
|
||||
this(plugin, webServer, Rank.MODERATOR);
|
||||
}
|
||||
|
||||
public CoreClientManager(JavaPlugin plugin, String webServer, Rank whitelistBypass)
|
||||
{
|
||||
super("Client Manager", plugin);
|
||||
|
||||
@ -65,6 +72,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
_repository = new AccountRepository(plugin, webServer);
|
||||
_clientList = new NautHashMap<String, CoreClient>();
|
||||
_duplicateLoginGlitchPreventionList = new HashSet<String>();
|
||||
WHITELIST_BYPASS = whitelistBypass;
|
||||
}
|
||||
|
||||
public AccountRepository getRepository()
|
||||
@ -195,7 +203,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
_clientsProcessing.decrementAndGet();
|
||||
}
|
||||
|
||||
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(Rank.MODERATOR))
|
||||
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(WHITELIST_BYPASS))
|
||||
{
|
||||
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BenefitData AddPlayer(String player)
|
||||
protected BenefitData addPlayer(String player)
|
||||
{
|
||||
return new BenefitData();
|
||||
}
|
||||
|
@ -989,7 +989,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BonusClientData AddPlayer(String player)
|
||||
protected BonusClientData addPlayer(String player)
|
||||
{
|
||||
return new BonusClientData();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class YoutubeButton implements GuiItem
|
||||
message = "Click here to visit our YouTube page!";
|
||||
}
|
||||
|
||||
new JsonMessage(C.cAquaB + message).click(ClickEvent.OPEN_URL, "https://www.youtube.com/mineplexgamesofficial").sendToPlayer(_player);
|
||||
new JsonMessage(C.cAquaB + message).click(ClickEvent.OPEN_URL, "https://www.youtube.com/embed/RW3sOmkiEG-A?list=UU1MtBclG_aHPd0nLmUupCKg&controls=0&showinfo=0").sendToPlayer(_player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.boosters.command.BoosterCommand;
|
||||
import mineplex.core.boosters.event.BoosterActivateEvent;
|
||||
import mineplex.core.boosters.event.BoosterExpireEvent;
|
||||
import mineplex.core.boosters.event.BoosterItemGiveEvent;
|
||||
import mineplex.core.boosters.event.BoosterUpdateEvent;
|
||||
import mineplex.core.boosters.gui.BoosterShop;
|
||||
import mineplex.core.boosters.redis.BoosterUpdateRepository;
|
||||
@ -14,6 +15,7 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
@ -361,6 +363,11 @@ public class BoosterManager extends MiniPlugin
|
||||
{
|
||||
if (_giveInterfaceItem && !UtilGear.isMat(player.getInventory().getItem(INTERFACE_SLOT), Material.EMERALD))
|
||||
{
|
||||
BoosterItemGiveEvent event = new BoosterItemGiveEvent(player);
|
||||
UtilServer.CallEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
player.getInventory().setItem(INTERFACE_SLOT, INTERFACE_ITEM);
|
||||
|
||||
UtilInv.Update(player);
|
||||
|
@ -0,0 +1,48 @@
|
||||
package mineplex.core.boosters.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a player is about to receive a booster gem. If cancelled the player will not receive said gem
|
||||
*/
|
||||
public class BoosterItemGiveEvent extends Event implements Cancellable
|
||||
{
|
||||
private Player _player;
|
||||
private boolean _cancelled;
|
||||
|
||||
public BoosterItemGiveEvent(Player player)
|
||||
{
|
||||
this._player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return this._player;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return this._cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
this._cancelled = cancelled;
|
||||
}
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
private static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
}
|
@ -110,7 +110,7 @@ public class BoosterTipManager extends MiniDbClientPlugin<PlayerTipData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerTipData AddPlayer(String player)
|
||||
protected PlayerTipData addPlayer(String player)
|
||||
{
|
||||
return new PlayerTipData();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class FountainManager extends MiniPlugin
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);//-43.5, 66, -38.5
|
||||
|
||||
int goal = !new File("eu.dat").exists() ? 300000000 : 5000000;
|
||||
int goal = !new File("eu.dat").exists() ? 200000000 : 20000000;
|
||||
_gemFountain = new Fountain(new Location(world, -32.5, 72, -23.5), new Location(world, -43.5, 67, -38.5),
|
||||
C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public class CosmeticManager extends MiniPlugin
|
||||
{
|
||||
_gadgetManager.disableAll();
|
||||
_mountManager.DisableAll();
|
||||
_petManager.DisableAll();
|
||||
_petManager.disableAll();
|
||||
}
|
||||
|
||||
public void setHideParticles(boolean b)
|
||||
|
@ -8,7 +8,7 @@ public class PetSorter implements Comparator<Pet>
|
||||
{
|
||||
public int compare(Pet a, Pet b)
|
||||
{
|
||||
if (a.GetPetType().getTypeId() < b.GetPetType().getTypeId())
|
||||
if (a.getPetType().getTypeId() < b.getPetType().getTypeId())
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
|
@ -23,7 +23,7 @@ public class ActivatePetButton implements IButton
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_page.playAcceptSound(player);
|
||||
_page.getPlugin().getPetManager().AddPetOwner(player, _pet.GetPetType(), player.getLocation());
|
||||
_page.getPlugin().getPetManager().addPetOwner(player, _pet.getPetType(), player.getLocation());
|
||||
_page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class DeactivatePetButton implements IButton
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_page.playAcceptSound(player);
|
||||
_petManager.RemovePet(player, true);
|
||||
_petManager.removePet(player, true);
|
||||
_page.refresh();
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class OpenPets implements IButton
|
||||
else
|
||||
{
|
||||
_menu.playAcceptSound(player);
|
||||
_menu.getPlugin().getPetManager().RemovePet(player, true);
|
||||
_menu.getPlugin().getPetManager().removePet(player, true);
|
||||
_menu.refresh();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.banner.CountryFlag;
|
||||
import mineplex.core.gadget.event.GadgetChangeEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -291,7 +293,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8)
|
||||
{
|
||||
gadgetItemStack = CountryFlag.Usa.getBanner();
|
||||
gadgetItemStack = CountryFlag.USA.getBanner();
|
||||
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
||||
bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName());
|
||||
bannerMeta.setLore(meta.getLore());
|
||||
@ -314,7 +316,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8)
|
||||
{
|
||||
gadgetItemStack = CountryFlag.Usa.getBanner();
|
||||
gadgetItemStack = CountryFlag.USA.getBanner();
|
||||
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
||||
bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName());
|
||||
bannerMeta.setLore(meta.getLore());
|
||||
@ -393,6 +395,9 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
playAcceptSound(player);
|
||||
gadget.enable(player);
|
||||
GadgetChangeEvent gadgetChangeEvent = new GadgetChangeEvent(player, gadget,
|
||||
GadgetChangeEvent.GadgetState.ENABLED);
|
||||
UtilServer.getPluginManager().callEvent(gadgetChangeEvent);
|
||||
|
||||
refresh();
|
||||
}
|
||||
@ -409,6 +414,9 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
playAcceptSound(player);
|
||||
gadget.disable(player);
|
||||
GadgetChangeEvent gadgetChangeEvent = new GadgetChangeEvent(player, gadget,
|
||||
GadgetChangeEvent.GadgetState.DISABLED);
|
||||
UtilServer.getPluginManager().callEvent(gadgetChangeEvent);
|
||||
refresh();
|
||||
}
|
||||
}
|
@ -100,7 +100,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer());
|
||||
for (Mount<?> mount : getPlugin().getMountManager().getMounts())
|
||||
{
|
||||
if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName()) || mount.hasMount(getPlayer()))
|
||||
if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName()))
|
||||
{
|
||||
mountOwned++;
|
||||
}
|
||||
@ -110,17 +110,17 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
int petOwned = 0;
|
||||
int petMax = 0;
|
||||
for (Pet pet : getPlugin().getPetManager().GetFactory().GetPets())
|
||||
for (Pet pet : getPlugin().getPetManager().getFactory().GetPets())
|
||||
{
|
||||
NautHashMap<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).GetPets();
|
||||
if (pets != null && pets.containsKey(pet.GetPetType()))
|
||||
NautHashMap<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
|
||||
if (pets != null && pets.containsKey(pet.getPetType()))
|
||||
{
|
||||
petOwned++;
|
||||
}
|
||||
|
||||
petMax++;
|
||||
}
|
||||
Creature petActive = getPlugin().getPetManager().GetPet(getPlayer());
|
||||
Creature petActive = getPlugin().getPetManager().getPet(getPlayer());
|
||||
|
||||
GadgetType type = GadgetType.PARTICLE;
|
||||
String[] lore = getLore(ownedCount.get(type), maxCount.get(type), "Show everyone how cool you are with swirly particles that follow you when you walk!", "Visible Everywhere", enabled.get(type));
|
||||
|
@ -49,7 +49,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
int slot = 19;
|
||||
|
||||
List<Pet> pets = new ArrayList<Pet>(getPlugin().getPetManager().GetFactory().GetPets());
|
||||
List<Pet> pets = new ArrayList<Pet>(getPlugin().getPetManager().getFactory().GetPets());
|
||||
|
||||
Collections.sort(pets, new PetSorter());
|
||||
|
||||
@ -61,7 +61,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
itemLore.add(C.cGray + "Your very own " + pet.getName() + "!");
|
||||
|
||||
//Chest Unlocks
|
||||
if (!getPlugin().getPetManager().Get(getPlayer()).GetPets().containsKey(pet.GetPetType()))
|
||||
if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
|
||||
{
|
||||
if (pet.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
||||
{
|
||||
@ -113,21 +113,21 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
|
||||
//Owned
|
||||
if (getPlugin().getPetManager().Get(getPlayer()).GetPets().containsKey(pet.GetPetType()))
|
||||
if (getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
|
||||
{
|
||||
String petName = getPlugin().getPetManager().Get(getPlayer()).GetPets().get(pet.GetPetType());
|
||||
String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet.getPetType());
|
||||
if (petName == null)
|
||||
{
|
||||
petName = pet.getName();
|
||||
}
|
||||
|
||||
if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() == pet.GetPetType())
|
||||
if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() == pet.getPetType())
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Click to Disable");
|
||||
|
||||
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.GetPetType().getTypeId(),
|
||||
pet.GetPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
|
||||
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(),
|
||||
pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
|
||||
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager()));
|
||||
|
||||
addGlow(slot);
|
||||
@ -137,8 +137,8 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Click to Enable");
|
||||
|
||||
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.GetPetType().getTypeId(),
|
||||
pet.GetPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
|
||||
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(),
|
||||
pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
|
||||
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this));
|
||||
}
|
||||
}
|
||||
@ -156,18 +156,18 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Click to Purchase");
|
||||
|
||||
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this));
|
||||
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this));
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||
|
||||
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
|
||||
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
|
||||
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
|
||||
slot = 49;
|
||||
for (PetExtra petExtra : getPlugin().getPetManager().GetFactory().GetPetExtras())
|
||||
for (PetExtra petExtra : getPlugin().getPetManager().getFactory().GetPetExtras())
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
@ -233,7 +233,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
public void deactivatePet(Player player)
|
||||
{
|
||||
playAcceptSound(player);
|
||||
getPlugin().getPetManager().RemovePet(player, true);
|
||||
getPlugin().getPetManager().removePet(player, true);
|
||||
refresh();
|
||||
}
|
||||
}
|
@ -108,8 +108,8 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId();
|
||||
|
||||
token.Name = getPlayer().getName();
|
||||
token.PetType = _pet.GetPetType().toString();
|
||||
token.PetId = _pet.GetPetType().ordinal();
|
||||
token.PetType = _pet.getPetType().toString();
|
||||
token.PetId = _pet.getPetType().ordinal();
|
||||
token.PetName = _tagName;
|
||||
|
||||
PetToken petToken = new PetToken();
|
||||
@ -117,16 +117,16 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
if (_petPurchase)
|
||||
{
|
||||
getPlugin().getPetManager().GetRepository().AddPet(token);
|
||||
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.GetPetType());
|
||||
getPlugin().getPetManager().getRepository().AddPet(token);
|
||||
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType());
|
||||
}
|
||||
else
|
||||
{
|
||||
getPlugin().getPetManager().GetRepository().UpdatePet(token);
|
||||
getPlugin().getPetManager().getRepository().UpdatePet(token);
|
||||
getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName);
|
||||
}
|
||||
|
||||
getPlugin().getPetManager().Get(getPlayer()).GetPets().put(_pet.GetPetType(), token.PetName);
|
||||
getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName);
|
||||
|
||||
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer()));
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerCustomData AddPlayer(String player)
|
||||
protected PlayerCustomData addPlayer(String player)
|
||||
{
|
||||
return new PlayerCustomData(_repository);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DelayedTaskClient AddPlayer(String player)
|
||||
protected DelayedTaskClient addPlayer(String player)
|
||||
{
|
||||
return new DelayedTaskClient(Bukkit.getPlayer(player));
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Donor AddPlayer(String player)
|
||||
protected Donor addPlayer(String player)
|
||||
{
|
||||
return new Donor();
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EloClientData AddPlayer(String player)
|
||||
protected EloClientData addPlayer(String player)
|
||||
{
|
||||
return new EloClientData();
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public class Energy extends MiniClientPlugin<ClientEnergy>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientEnergy AddPlayer(String player)
|
||||
protected ClientEnergy addPlayer(String player)
|
||||
{
|
||||
return new ClientEnergy();
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class FacebookManager extends MiniDbClientPlugin<FacebookClient>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FacebookClient AddPlayer(String player)
|
||||
protected FacebookClient addPlayer(String player)
|
||||
{
|
||||
return new FacebookClient(false);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FriendData AddPlayer(String player)
|
||||
protected FriendData addPlayer(String player)
|
||||
{
|
||||
return new FriendData();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import mineplex.core.gadget.commands.LockCosmeticsCommand;
|
||||
import mineplex.core.gadget.event.GadgetChangeEvent;
|
||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
|
||||
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom;
|
||||
@ -660,10 +661,14 @@ public class GadgetManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void disableAll(Player player, boolean callEvent)
|
||||
public void disableAll(Player player, boolean winRooms)
|
||||
{
|
||||
for (GadgetType gadgetType : _gadgets.keySet())
|
||||
{
|
||||
if (gadgetType == GadgetType.WIN_EFFECT && winRooms)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
||||
{
|
||||
gadget.disable(player);
|
||||
@ -776,7 +781,9 @@ public class GadgetManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
saveGadgets(event.getPlayer());
|
||||
//saveGadgets(event.getPlayer());
|
||||
event.getPlayer().setWalkSpeed(0.2f);
|
||||
event.getPlayer().setFlySpeed(0.1f);
|
||||
disableAll(event.getPlayer(), false);
|
||||
_lastMove.remove(event.getPlayer());
|
||||
_playerActiveGadgetMap.remove(event.getPlayer());
|
||||
@ -914,89 +921,57 @@ public class GadgetManager extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private void saveGadgets(Player player)
|
||||
@EventHandler
|
||||
private void saveGadget(GadgetChangeEvent event)
|
||||
{
|
||||
if (player.getGameMode() == GameMode.SPECTATOR)
|
||||
return;
|
||||
Map<String, String> cache = new HashMap<>();
|
||||
for (Gadget gadget : getAllGadgets())
|
||||
Gadget gadget = event.getGadget();
|
||||
if (gadget != null)
|
||||
{
|
||||
String value = "disabled", key = "";
|
||||
GadgetType gadgetType = gadget.getGadgetType();
|
||||
if (gadget.ownsGadget(player))
|
||||
{
|
||||
switch (gadgetType)
|
||||
{
|
||||
case MUSIC_DISC:
|
||||
case ITEM:
|
||||
case MORPH:
|
||||
case BALLOON:
|
||||
break;
|
||||
case COSTUME:
|
||||
OutfitGadget outfitGadget = (OutfitGadget) gadget;
|
||||
String key = "activeCostume" + outfitGadget.getSlot().getDatabaseKey();
|
||||
if (cache.containsKey(key))
|
||||
continue;
|
||||
if (outfitGadget.isActive(player))
|
||||
cache.put(key, outfitGadget.getName());
|
||||
break;
|
||||
case GAME_MODIFIER:
|
||||
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
|
||||
if (gameModifierGadget.canAllowMultiple())
|
||||
{
|
||||
if (cache.containsKey(gadget.getName()))
|
||||
continue;
|
||||
cache.put(gadget.getName(), (gadget.isActive(player)) ? "enabled" : "disabled");
|
||||
} else
|
||||
{
|
||||
String dataKey = "activeModifier" + gameModifierGadget.getGameType().getName().replace(" ", "");
|
||||
if (cache.containsKey(dataKey))
|
||||
continue;
|
||||
if (gadget.isActive(player))
|
||||
cache.put(dataKey, gadget.getName());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (cache.containsKey(gadgetType.getDatabaseKey()))
|
||||
continue;
|
||||
if (gadget.isActive(player))
|
||||
cache.put(gadgetType.getDatabaseKey(), gadget.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cache = updateDefaultGadgets(cache);
|
||||
_userGadgetPersistence.save(player, cache);
|
||||
}
|
||||
|
||||
private Map<String, String> updateDefaultGadgets(Map<String, String> cache)
|
||||
{
|
||||
for (GadgetType gadgetType : GadgetType.values())
|
||||
{
|
||||
if (gadgetType == GadgetType.MUSIC_DISC || gadgetType == GadgetType.ITEM
|
||||
|| gadgetType == GadgetType.MORPH || gadgetType == GadgetType.BALLOON
|
||||
|| gadgetType == GadgetType.GAME_MODIFIER)
|
||||
continue;
|
||||
if (!cache.containsKey(gadgetType.getDatabaseKey()))
|
||||
switch (gadgetType)
|
||||
{
|
||||
String key = gadgetType.getDatabaseKey();
|
||||
if (gadgetType.equals(GadgetType.COSTUME))
|
||||
{
|
||||
for (ArmorSlot armorSlot : ArmorSlot.values())
|
||||
case MUSIC_DISC:
|
||||
case ITEM:
|
||||
case MORPH:
|
||||
case BALLOON:
|
||||
return;
|
||||
case COSTUME:
|
||||
OutfitGadget outfitGadget = (OutfitGadget) gadget;
|
||||
key = "activeCostume" + outfitGadget.getSlot().getDatabaseKey();
|
||||
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
||||
{
|
||||
key = "activeCostume" + armorSlot.getDatabaseKey();
|
||||
if (!cache.containsKey(key))
|
||||
value = outfitGadget.getName();
|
||||
}
|
||||
break;
|
||||
case GAME_MODIFIER:
|
||||
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
|
||||
if (gameModifierGadget.canAllowMultiple())
|
||||
{
|
||||
key = gameModifierGadget.getName();
|
||||
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
||||
{
|
||||
cache.put(key, "disabled");
|
||||
value = "enabled";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cache.put(key, "disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
key = "activeModifier" + gameModifierGadget.getGameType().getName().replace(" ", "");
|
||||
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
||||
{
|
||||
value = gameModifierGadget.getName();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
key = gadgetType.getDatabaseKey();
|
||||
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
||||
{
|
||||
value = gadget.getName();
|
||||
}
|
||||
}
|
||||
_userGadgetPersistence.save(event.getPlayer(), key, value);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
public boolean isKitModifierActive(KitModifier kitModifier, Player player)
|
||||
|
@ -2,12 +2,17 @@ package mineplex.core.gadget.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
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.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;
|
||||
|
||||
@ -28,7 +33,7 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
// Removes all cosmetic types
|
||||
if (args.length == 0)
|
||||
{
|
||||
addCosmetics(null, caller);
|
||||
lockCosmetics(null, caller);
|
||||
}
|
||||
// Removes specific type
|
||||
else
|
||||
@ -36,8 +41,16 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
String type = args[0];
|
||||
if (type.equalsIgnoreCase("all"))
|
||||
{
|
||||
addCosmetics(null, caller);
|
||||
lockCosmetics(null, caller);
|
||||
}
|
||||
else if (type.equalsIgnoreCase("pet"))
|
||||
{
|
||||
lockPets(caller);
|
||||
}
|
||||
else if (type.equalsIgnoreCase("mount"))
|
||||
{
|
||||
lockMounts(caller);
|
||||
}
|
||||
else
|
||||
{
|
||||
GadgetType gadgetType = GadgetType.valueOf(type);
|
||||
@ -47,27 +60,74 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
}
|
||||
else
|
||||
{
|
||||
addCosmetics(gadgetType, caller);
|
||||
lockCosmetics(gadgetType, caller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addCosmetics(GadgetType gadgetType, Player caller)
|
||||
private void lockCosmetics(GadgetType gadgetType, Player caller)
|
||||
{
|
||||
if (gadgetType == null)
|
||||
{
|
||||
for (GadgetType type : GadgetType.values())
|
||||
{
|
||||
addCosmetics(type, caller);
|
||||
lockCosmetics(type, caller);
|
||||
}
|
||||
lockMounts(caller);
|
||||
lockPets(caller);
|
||||
return;
|
||||
}
|
||||
int removed = 0;
|
||||
for (Gadget gadget : _plugin.getGadgets(gadgetType))
|
||||
{
|
||||
_plugin.getDonationManager().Get(caller.getName()).RemoveUnknownSalesPackagesOwned(gadget.getName());
|
||||
if (gadget.getGadgetType() == GadgetType.ITEM)
|
||||
continue;
|
||||
if (gadget.ownsGadget(caller))
|
||||
{
|
||||
Item clientItem = _plugin.getInventoryManager().getItem(gadget.getName());
|
||||
if (clientItem == null)
|
||||
continue;
|
||||
_plugin.getInventoryManager().Get(caller.getName()).removeItem(new ClientItem(clientItem, 1));
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name() + " cosmetics!"));
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name().toLowerCase()
|
||||
.replace("_", " ") + "! (Removed " + C.cRed + removed + C.cGray + " " +
|
||||
UtilText.plural("item", removed) + ")"));
|
||||
}
|
||||
|
||||
private void lockMounts(Player caller)
|
||||
{
|
||||
int removed = 0;
|
||||
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.getName()).removeItem(new ClientItem(clientItem, 1));
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
|
||||
UtilText.plural("mount", removed) + "!"));
|
||||
}
|
||||
|
||||
private void lockPets(Player caller)
|
||||
{
|
||||
int removed = 0;
|
||||
for (Pet pet : _plugin.getPetManager().getFactory().GetPets())
|
||||
{
|
||||
if (_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType()))
|
||||
{
|
||||
_plugin.getPetManager().Get(caller).getPets().remove(pet.getPetType());
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
|
||||
UtilText.plural("pet", removed) + "!"));
|
||||
}
|
||||
}
|
@ -2,15 +2,15 @@ package mineplex.core.gadget.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
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.mount.Mount;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.pet.Pet;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
@ -40,6 +40,14 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
{
|
||||
addCosmetics(null, caller);
|
||||
}
|
||||
else if (type.equalsIgnoreCase("pet"))
|
||||
{
|
||||
addPets(caller);
|
||||
}
|
||||
else if (type.equalsIgnoreCase("mount"))
|
||||
{
|
||||
addMounts(caller);
|
||||
}
|
||||
else
|
||||
{
|
||||
GadgetType gadgetType = GadgetType.valueOf(type);
|
||||
@ -64,12 +72,54 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
|
||||
{
|
||||
addCosmetics(type, caller);
|
||||
}
|
||||
addMounts(caller);
|
||||
addPets(caller);
|
||||
return;
|
||||
}
|
||||
int added = 0;
|
||||
int amount = 1;
|
||||
for (Gadget gadget : _plugin.getGadgets(gadgetType))
|
||||
{
|
||||
_plugin.getDonationManager().Get(caller.getName()).AddUnknownSalesPackagesOwned(gadget.getName());
|
||||
if (gadgetType == GadgetType.ITEM)
|
||||
amount = 20;
|
||||
if (!gadget.ownsGadget(caller))
|
||||
{
|
||||
_plugin.getInventoryManager().addItemToInventory(caller, gadget.getName(), amount);
|
||||
added++;
|
||||
}
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Added all the " + gadgetType.name() + " cosmetics!"));
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Added all the " + gadgetType.name().toLowerCase()
|
||||
.replace("_", " ") + "! (Added " + C.cRed + added + C.cGray + " " +
|
||||
UtilText.plural("item", added) + ")"));
|
||||
}
|
||||
|
||||
private void addMounts(Player caller)
|
||||
{
|
||||
int added = 0;
|
||||
for (Mount<?> mount : _plugin.getMountManager().getMounts())
|
||||
{
|
||||
if (!mount.hasMount(caller))
|
||||
{
|
||||
_plugin.getInventoryManager().addItemToInventory(caller, mount.getName(), 1);
|
||||
added++;
|
||||
}
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " +
|
||||
UtilText.plural("mount", added) + "!"));
|
||||
}
|
||||
|
||||
private void addPets(Player caller)
|
||||
{
|
||||
int added = 0;
|
||||
for (Pet pet : _plugin.getPetManager().getFactory().GetPets())
|
||||
{
|
||||
if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType()))
|
||||
{
|
||||
_plugin.getPetManager().Get(caller).getPets().put(pet.getPetType(), pet.getName());
|
||||
added++;
|
||||
}
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " +
|
||||
UtilText.plural("pet", added) + "!"));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
package mineplex.core.gadget.event;
|
||||
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a player enables or disables a gadget manually,
|
||||
* allowing it to be saved when the player changes a gadget, instead of
|
||||
* when they quit or join a server
|
||||
*/
|
||||
public class GadgetChangeEvent extends Event
|
||||
{
|
||||
|
||||
public enum GadgetState
|
||||
{
|
||||
ENABLED,
|
||||
DISABLED
|
||||
}
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final Player _player;
|
||||
private final Gadget _gadget;
|
||||
private final GadgetState _gadgetState;
|
||||
|
||||
public GadgetChangeEvent(Player player, Gadget gadget, GadgetState gadgetState)
|
||||
{
|
||||
_player = player;
|
||||
_gadget = gadget;
|
||||
_gadgetState = gadgetState;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public Gadget getGadget()
|
||||
{
|
||||
return _gadget;
|
||||
}
|
||||
|
||||
public GadgetState getGadgetState()
|
||||
{
|
||||
return _gadgetState;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package mineplex.core.gadget.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
|
||||
/**
|
||||
* This event is called when a gadget selects a location for a specific effect to be shown.
|
||||
*/
|
||||
public class GadgetSelectLocationEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private Gadget _gadget;
|
||||
private Location _location;
|
||||
private boolean _showMessage = true;
|
||||
private boolean _cancelled = false;
|
||||
|
||||
public GadgetSelectLocationEvent(Player player, Gadget gadget, Location location)
|
||||
{
|
||||
_player = player;
|
||||
_gadget = gadget;
|
||||
_location = location;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Gadget getGadget()
|
||||
{
|
||||
return _gadget;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel)
|
||||
{
|
||||
_cancelled = cancel;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a cancellation message should be displayed.
|
||||
*
|
||||
* @param showMessage True for the message to be shown and false for the message to be hidden/ignored.
|
||||
*/
|
||||
public void setShowMessage(boolean showMessage)
|
||||
{
|
||||
_showMessage = showMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not a cancellation message can be shown.
|
||||
*
|
||||
* @return True if the message can be shown and false if the message should be hidden/ignored.
|
||||
*/
|
||||
public boolean canShowMessage()
|
||||
{
|
||||
return _showMessage;
|
||||
}
|
||||
}
|
@ -117,7 +117,7 @@ public class ItemCoal extends ItemGadget
|
||||
}
|
||||
|
||||
//Coal Apparition
|
||||
if (!Manager.getPetManager().Get(player).GetPets().containsKey(EntityType.PIG_ZOMBIE))
|
||||
if (!Manager.getPetManager().Get(player).getPets().containsKey(EntityType.PIG_ZOMBIE))
|
||||
{
|
||||
goal = _pet;
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -17,6 +18,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
@ -32,6 +34,7 @@ import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseGuardian;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.recharge.RechargedEvent;
|
||||
@ -105,6 +108,19 @@ public class MorphTitan extends MorphGadget
|
||||
|
||||
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);
|
||||
|
||||
if (gadgetSelectLocationEvent.isCancelled())
|
||||
{
|
||||
if (gadgetSelectLocationEvent.canShowMessage())
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
|
||||
|
||||
stand.setVisible(false);
|
||||
|
@ -146,7 +146,7 @@ public class WinEffectLavaTrap extends WinEffectGadget
|
||||
Location loc = getBaseLocation().add(UtilAlg.getRight(dir).multiply(5)).add(0, 2, 0).subtract(dir);
|
||||
loc.setDirection(getBaseLocation().subtract(loc).toVector());
|
||||
|
||||
teleport(loc);
|
||||
super.teleport(loc);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ package mineplex.core.gadget.types;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -14,7 +14,10 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@ -26,6 +29,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||
|
||||
/**
|
||||
* A wrapper for different win effects
|
||||
@ -51,8 +55,8 @@ public abstract class WinEffectGadget extends Gadget
|
||||
protected List<Player> _nonTeam;
|
||||
/** All players on the team that didn't win + spectators which were not in the game at all. */
|
||||
protected List<Player> _other;
|
||||
/** All locked players */
|
||||
protected List<Player> _locked;
|
||||
/** All the players that were teleported to the winroom */
|
||||
protected List<Player> _allPlayers;
|
||||
|
||||
/**
|
||||
* @param manager The normal GadgetManager
|
||||
@ -90,55 +94,10 @@ public abstract class WinEffectGadget extends Gadget
|
||||
this._finish = _start + 1000*12;
|
||||
play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the player. Disabling any jump or walk movement
|
||||
* @param p The player to lock in place
|
||||
*/
|
||||
public void lockPlayer(Player p)
|
||||
{
|
||||
_locked.add(p);
|
||||
p.setWalkSpeed(0);
|
||||
p.setFlySpeed(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the player, allowing the player to walk and jump as normal again.
|
||||
* @param p The player to unlock
|
||||
*/
|
||||
public void unlockPlayer(Player p)
|
||||
{
|
||||
if (_locked.contains(p))
|
||||
_locked.remove(p);
|
||||
p.setWalkSpeed(0.2f);
|
||||
p.setFlySpeed(0.1f);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
for(PotionEffect p : event.getPlayer().getActivePotionEffects())
|
||||
{
|
||||
if(p.getType().equals(PotionEffectType.JUMP))
|
||||
{
|
||||
if(p.getAmplifier() == 250)
|
||||
{
|
||||
if(event.getTo().clone().subtract(event.getFrom()).lengthSquared() > 0)
|
||||
{
|
||||
Location loc = event.getPlayer().getLocation().getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
loc.setDirection(event.getTo().getDirection());
|
||||
event.setTo(loc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void runFinish()
|
||||
{
|
||||
finish();
|
||||
UtilServer.getPlayersCollection().forEach(p -> {unlockPlayer(p); UtilPlayer.showForAll(p); });
|
||||
_player = null;
|
||||
_baseLocation = null;
|
||||
_team.clear();
|
||||
@ -147,8 +106,8 @@ public abstract class WinEffectGadget extends Gadget
|
||||
_nonTeam = null;
|
||||
_other.clear();
|
||||
_other = null;
|
||||
_locked.clear();
|
||||
_locked = null;
|
||||
_allPlayers.clear();
|
||||
_allPlayers = null;
|
||||
// Loads gadgets back when players are teleported to the arcade hub, after the win effect
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
@ -221,7 +180,8 @@ public abstract class WinEffectGadget extends Gadget
|
||||
_other.remove(player);
|
||||
_other.removeAll(team);
|
||||
|
||||
_locked = new ArrayList<>();
|
||||
_allPlayers = new ArrayList<>();
|
||||
_allPlayers.addAll(UtilServer.getPlayersCollection());
|
||||
|
||||
this._start = System.currentTimeMillis();
|
||||
this._baseLocation = loc.clone();
|
||||
@ -245,32 +205,64 @@ public abstract class WinEffectGadget extends Gadget
|
||||
*/
|
||||
public void teleport(Location loc)
|
||||
{
|
||||
loc.getBlock().setType(Material.AIR);
|
||||
loc.getBlock().getRelative(BlockFace.UP).setType(Material.AIR);
|
||||
loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.BARRIER);
|
||||
loc.getBlock().getRelative(BlockFace.EAST).getRelative(BlockFace.UP).setType(Material.BARRIER);
|
||||
loc.getBlock().getRelative(BlockFace.WEST).getRelative(BlockFace.UP).setType(Material.BARRIER);
|
||||
loc.getBlock().getRelative(BlockFace.NORTH).getRelative(BlockFace.UP).setType(Material.BARRIER);
|
||||
loc.getBlock().getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP).setType(Material.BARRIER);
|
||||
loc.clone().add(0, 2, 0).getBlock().setType(Material.BARRIER);
|
||||
createBarriers(loc);
|
||||
|
||||
BukkitRunnable bRunnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(Player p : UtilServer.getPlayers()) {
|
||||
lockPlayer(p);
|
||||
UtilPlayer.hideFromAll(p);
|
||||
p.teleport(loc);
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 10 * 20, 1, false, false));
|
||||
p.getInventory().clear();
|
||||
p.teleport(loc.clone().add(.5, 0, .5));
|
||||
p.setAllowFlight(false);
|
||||
Manager.disableAll(p, false);
|
||||
p.setHealth(p.getMaxHealth());
|
||||
p.setFoodLevel(20);
|
||||
Manager.disableAll(p, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
bRunnable.runTaskLater(UtilServer.getPlugin(), 10l);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates players inventory
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (!isRunning())
|
||||
return;
|
||||
|
||||
for (Player player : _allPlayers)
|
||||
{
|
||||
player.getInventory().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if (isRunning())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (isRunning())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the win room, by default this will paste the scheamtic. Do any major setup here. This is called before the players are
|
||||
* teleported.
|
||||
@ -357,4 +349,69 @@ public abstract class WinEffectGadget extends Gadget
|
||||
}
|
||||
}
|
||||
|
||||
private void createBarriers(Location baseLocation)
|
||||
{
|
||||
// FLOOR
|
||||
Location floorBase = baseLocation.clone().subtract(0, 1, 0);
|
||||
setBarrierBlock(floorBase);
|
||||
setBarrierBlock(floorBase.clone().add(1, 0, 0));
|
||||
setBarrierBlock(floorBase.clone().add(0, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().subtract(1, 0, 0));
|
||||
setBarrierBlock(floorBase.clone().subtract(0, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().add(1, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().add(1, 0, -1));
|
||||
setBarrierBlock(floorBase.clone().add(-1, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().subtract(1, 0, 1));
|
||||
|
||||
// WALLS
|
||||
floorBase.add(0, 2, 0);
|
||||
setBarrierBlock(floorBase.clone().add(2, 0, 0));
|
||||
setBarrierBlock(floorBase.clone().add(2, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().add(2, 0, -1));
|
||||
|
||||
setBarrierBlock(floorBase.clone().subtract(2, 0, 0));
|
||||
setBarrierBlock(floorBase.clone().subtract(2, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().subtract(2, 0, -1));
|
||||
|
||||
setBarrierBlock(floorBase.clone().add(0, 0, 2));
|
||||
setBarrierBlock(floorBase.clone().add(1, 0, 2));
|
||||
setBarrierBlock(floorBase.clone().add(-1, 0, 2));
|
||||
|
||||
setBarrierBlock(floorBase.clone().subtract(0, 0, 2));
|
||||
setBarrierBlock(floorBase.clone().subtract(1, 0, 2));
|
||||
setBarrierBlock(floorBase.clone().subtract(-1, 0, 2));
|
||||
|
||||
// CEILING
|
||||
floorBase.add(0, 2, 0);
|
||||
setBarrierBlock(floorBase);
|
||||
setBarrierBlock(floorBase.clone().add(1, 0, 0));
|
||||
setBarrierBlock(floorBase.clone().add(0, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().subtract(1, 0, 0));
|
||||
setBarrierBlock(floorBase.clone().subtract(0, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().add(1, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().add(1, 0, -1));
|
||||
setBarrierBlock(floorBase.clone().add(-1, 0, 1));
|
||||
setBarrierBlock(floorBase.clone().subtract(1, 0, 1));
|
||||
|
||||
// CHANGES MIDDLE TO AIR
|
||||
floorBase.subtract(1, 3, 1);
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int z = 0; z < 3; z++)
|
||||
{
|
||||
floorBase.clone().add(x, y, z).getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setBarrierBlock(Location blockLocation)
|
||||
{
|
||||
if (blockLocation.getBlock().getType() == Material.AIR)
|
||||
blockLocation.getBlock().setType(Material.BARRIER);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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),
|
||||
|
@ -173,7 +173,7 @@ public class GiveawayManager extends MiniDbClientPlugin<PlayerGiveawayData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerGiveawayData AddPlayer(String player)
|
||||
protected PlayerGiveawayData addPlayer(String player)
|
||||
{
|
||||
return new PlayerGiveawayData();
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class IgnoreManager extends MiniDbClientPlugin<IgnoreData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IgnoreData AddPlayer(String player)
|
||||
protected IgnoreData addPlayer(String player)
|
||||
{
|
||||
return new IgnoreData();
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
|
||||
UtilPlayer.message(player, " ");
|
||||
}
|
||||
|
||||
protected IncognitoClient AddPlayer(String player)
|
||||
protected IncognitoClient addPlayer(String player)
|
||||
{
|
||||
return new IncognitoClient();
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientInventory AddPlayer(String player)
|
||||
protected ClientInventory addPlayer(String player)
|
||||
{
|
||||
return new ClientInventory();
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -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 + "]]";
|
||||
}
|
||||
|
||||
}
|
@ -87,7 +87,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientMessage AddPlayer(String player)
|
||||
protected ClientMessage addPlayer(String player)
|
||||
{
|
||||
Set(player, new ClientMessage());
|
||||
return Get(player);
|
||||
|
@ -40,7 +40,7 @@ public class Movement extends MiniClientPlugin<ClientMovement>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientMovement AddPlayer(String player)
|
||||
protected ClientMovement addPlayer(String player)
|
||||
{
|
||||
return new ClientMovement();
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
package mineplex.core.packethandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.mineplex.spigot.PacketProcessor;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -15,16 +11,22 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.mineplex.spigot.PacketProcessor;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class PacketHandler extends MiniPlugin
|
||||
{
|
||||
private NautHashMap<Player, PacketVerifier> _playerVerifierMap = new NautHashMap<Player, PacketVerifier>();
|
||||
private HashMap<Class, ArrayList<IPacketHandler>> _forceMainThread = new HashMap<Class, ArrayList<IPacketHandler>>();
|
||||
private HashMap<Class, ArrayList<IPacketHandler>> _packetHandlers = new HashMap<Class, ArrayList<IPacketHandler>>();
|
||||
private Map<Player, PacketVerifier> _playerVerifierMap = new HashMap<>();
|
||||
|
||||
private Map<Class<? extends Packet>, Set<IPacketHandler>> _forceMainThread = new HashMap<>();
|
||||
private Map<Class<? extends Packet>, Map<ListenerPriority, List<IPacketHandler>>> _packetHandlers = new HashMap<>();
|
||||
|
||||
public PacketHandler(JavaPlugin plugin)
|
||||
{
|
||||
@ -40,18 +42,6 @@ public class PacketHandler extends MiniPlugin
|
||||
.get(event.getPlayer()));
|
||||
}
|
||||
|
||||
public boolean handlePacket(Player player, Packet packet)
|
||||
{
|
||||
if (!_playerVerifierMap.containsKey(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
PacketVerifier verifier = _playerVerifierMap.get(player);
|
||||
|
||||
return handlePacket(new PacketInfo(player, packet, verifier));
|
||||
}
|
||||
|
||||
public boolean handlePacket(PacketInfo packetInfo)
|
||||
{
|
||||
if (!_packetHandlers.containsKey(packetInfo.getPacket().getClass()))
|
||||
@ -60,15 +50,18 @@ public class PacketHandler extends MiniPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
for (IPacketHandler handler : _packetHandlers.get(packetInfo.getPacket().getClass()))
|
||||
for (Entry<ListenerPriority, List<IPacketHandler>> entry : _packetHandlers.get(packetInfo.getPacket().getClass()).entrySet())
|
||||
{
|
||||
try
|
||||
for (IPacketHandler handler : entry.getValue())
|
||||
{
|
||||
handler.handle(packetInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
try
|
||||
{
|
||||
handler.handle(packetInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,72 +83,106 @@ public class PacketHandler extends MiniPlugin
|
||||
@SafeVarargs
|
||||
public final void addPacketHandler(IPacketHandler packetHandler, Class<? extends Packet>... packetsToListen)
|
||||
{
|
||||
if (packetsToListen.length == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to");
|
||||
}
|
||||
|
||||
addPacketHandler(packetHandler, false, packetsToListen);
|
||||
addPacketHandler(packetHandler, ListenerPriority.NORMAL, false, packetsToListen);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be used for incoming packets
|
||||
*/
|
||||
public void addPacketHandler(IPacketHandler packetHandler, boolean forceMainThread,
|
||||
Class<? extends Packet>... packetsToListen)
|
||||
@SafeVarargs
|
||||
public final void addPacketHandler(IPacketHandler packetHandler, boolean forceMainThread, Class<? extends Packet>... packetsToListen)
|
||||
{
|
||||
if (packetsToListen.length == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to");
|
||||
}
|
||||
|
||||
for (Class c : packetsToListen)
|
||||
addPacketHandler(packetHandler, ListenerPriority.NORMAL, forceMainThread, packetsToListen);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final void addPacketHandler(IPacketHandler packetHandler, ListenerPriority priority, Class<? extends Packet>... packetsToListen)
|
||||
{
|
||||
if (packetsToListen.length == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to");
|
||||
}
|
||||
|
||||
addPacketHandler(packetHandler, priority, false, packetsToListen);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be used for incoming packets
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final void addPacketHandler(IPacketHandler packetHandler, ListenerPriority priority, boolean forceMainThread,
|
||||
Class<? extends Packet>... packetsToListen)
|
||||
{
|
||||
if (packetsToListen.length == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to");
|
||||
}
|
||||
|
||||
for (Class<? extends Packet> c : packetsToListen)
|
||||
{
|
||||
if (forceMainThread)
|
||||
{
|
||||
if (!_forceMainThread.containsKey(c))
|
||||
{
|
||||
_forceMainThread.put(c, new ArrayList());
|
||||
}
|
||||
|
||||
_forceMainThread.get(c).add(packetHandler);
|
||||
_forceMainThread
|
||||
.computeIfAbsent(c, key -> new HashSet<>())
|
||||
.add(packetHandler);
|
||||
}
|
||||
|
||||
if (!_packetHandlers.containsKey(c))
|
||||
{
|
||||
_packetHandlers.put(c, new ArrayList());
|
||||
}
|
||||
_packetHandlers
|
||||
.computeIfAbsent(c, key -> new TreeMap<>())
|
||||
.computeIfAbsent(priority, key -> new ArrayList<>())
|
||||
.add(packetHandler);
|
||||
|
||||
_packetHandlers.get(c).add(packetHandler);
|
||||
PacketProcessor.addPacket(c, forceMainThread || _forceMainThread.containsKey(c));
|
||||
}
|
||||
}
|
||||
|
||||
public void removePacketHandler(IPacketHandler packetHandler)
|
||||
{
|
||||
Iterator<Entry<Class, ArrayList<IPacketHandler>>> itel = _packetHandlers.entrySet().iterator();
|
||||
Iterator<Entry<Class<? extends Packet>, Map<ListenerPriority, List<IPacketHandler>>>> itel = _packetHandlers.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Class, ArrayList<IPacketHandler>> entry = itel.next();
|
||||
Entry<Class<? extends Packet>, Map<ListenerPriority, List<IPacketHandler>>> entry = itel.next();
|
||||
|
||||
if (entry.getValue().remove(packetHandler))
|
||||
Set<ListenerPriority> removedFrom = new HashSet<>();
|
||||
|
||||
for (Entry<ListenerPriority, List<IPacketHandler>> ent : entry.getValue().entrySet())
|
||||
{
|
||||
if (_forceMainThread.containsKey(entry.getKey()) && _forceMainThread.get(entry.getKey()).remove(packetHandler))
|
||||
if (ent.getValue().remove(packetHandler))
|
||||
{
|
||||
if (_forceMainThread.get(entry.getKey()).isEmpty())
|
||||
{
|
||||
_forceMainThread.remove(entry.getKey());
|
||||
PacketProcessor.addPacket(entry.getKey(), false);
|
||||
}
|
||||
removedFrom.add(ent.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.getValue().isEmpty())
|
||||
for (ListenerPriority priority : removedFrom)
|
||||
{
|
||||
if (entry.getValue().get(priority).isEmpty())
|
||||
{
|
||||
PacketProcessor.removePacket(entry.getKey());
|
||||
itel.remove();
|
||||
entry.getValue().remove(priority);
|
||||
}
|
||||
}
|
||||
|
||||
if (_forceMainThread.containsKey(entry.getKey()) && _forceMainThread.get(entry.getKey()).remove(packetHandler))
|
||||
{
|
||||
if (_forceMainThread.get(entry.getKey()).isEmpty())
|
||||
{
|
||||
_forceMainThread.remove(entry.getKey());
|
||||
PacketProcessor.addPacket(entry.getKey(), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.getValue().isEmpty())
|
||||
{
|
||||
PacketProcessor.removePacket(entry.getKey());
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ListenerPriority
|
||||
{
|
||||
HIGH, NORMAL, LOW
|
||||
}
|
||||
}
|
||||
|
@ -24,17 +24,17 @@ public class Pet extends SalesPackageBase
|
||||
KnownPackage = false;
|
||||
}
|
||||
|
||||
public EntityType GetPetType()
|
||||
public EntityType getPetType()
|
||||
{
|
||||
return _petType;
|
||||
}
|
||||
|
||||
public void Update(PetSalesToken petToken)
|
||||
public void update(PetSalesToken petToken)
|
||||
{
|
||||
_name = petToken.Name;
|
||||
}
|
||||
|
||||
public String GetPetName()
|
||||
public String getPetName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class PetClient
|
||||
private NautHashMap<EntityType, String> _pets;
|
||||
private int _petNameTagCount;
|
||||
|
||||
public void Load(ClientPetToken token)
|
||||
public void load(ClientPetToken token)
|
||||
{
|
||||
_pets = new NautHashMap<EntityType, String>();
|
||||
|
||||
@ -26,7 +26,7 @@ public class PetClient
|
||||
_petNameTagCount = Math.max(0, token.PetNameTagCount);
|
||||
}
|
||||
|
||||
public NautHashMap<EntityType, String> GetPets()
|
||||
public NautHashMap<EntityType, String> getPets()
|
||||
{
|
||||
return _pets;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
|
||||
if (player != null && player.isOnline())
|
||||
{
|
||||
AddPetOwner(player, _petOwnerQueue.get(playerName), player.getLocation());
|
||||
addPetOwner(player, _petOwnerQueue.get(playerName), player.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,24 +160,24 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
|
||||
if (rank.has(Rank.LEGEND))
|
||||
{
|
||||
if (!Get(p).GetPets().containsKey(EntityType.WITHER))
|
||||
Get(p).GetPets().put(EntityType.WITHER, "Widder");
|
||||
if (!Get(p).getPets().containsKey(EntityType.WITHER))
|
||||
Get(p).getPets().put(EntityType.WITHER, "Widder");
|
||||
}
|
||||
|
||||
if (rank.has(Rank.TITAN))
|
||||
{
|
||||
if (!Get(p).GetPets().containsKey(EntityType.SKELETON))
|
||||
Get(p).GetPets().put(EntityType.SKELETON, "Guardian");
|
||||
if (!Get(p).getPets().containsKey(EntityType.SKELETON))
|
||||
Get(p).getPets().put(EntityType.SKELETON, "Guardian");
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPetOwner(Player player, EntityType entityType, Location location)
|
||||
public void addPetOwner(Player player, EntityType entityType, Location location)
|
||||
{
|
||||
if (_activePetOwners.containsKey(player.getName()))
|
||||
{
|
||||
if (_activePetOwners.get(player.getName()).getType() != entityType)
|
||||
{
|
||||
RemovePet(player, true);
|
||||
removePet(player, true);
|
||||
}
|
||||
else
|
||||
return;
|
||||
@ -214,10 +214,10 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
}
|
||||
|
||||
//Named Pet
|
||||
if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0)
|
||||
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
|
||||
{
|
||||
//pet.setCustomNameVisible(true);
|
||||
pet.setCustomName(Get(player).GetPets().get(entityType));
|
||||
pet.setCustomName(Get(player).getPets().get(entityType));
|
||||
}
|
||||
|
||||
if (pet instanceof Zombie)
|
||||
@ -245,9 +245,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
|
||||
DisguiseGuardian disguise = new DisguiseGuardian(pet);
|
||||
|
||||
if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0)
|
||||
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
|
||||
{
|
||||
disguise.setName(Get(player).GetPets().get(entityType));
|
||||
disguise.setName(Get(player).getPets().get(entityType));
|
||||
}
|
||||
|
||||
_disguiseManager.disguise(disguise);
|
||||
@ -265,12 +265,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
UtilEnt.Vegetate(pet);
|
||||
}
|
||||
|
||||
public Creature GetPet(Player player)
|
||||
public Creature getPet(Player player)
|
||||
{
|
||||
return _activePetOwners.get(player.getName());
|
||||
}
|
||||
|
||||
public void RemovePet(final Player player, boolean removeOwner)
|
||||
public void removePet(final Player player, boolean removeOwner)
|
||||
{
|
||||
if (_activePetOwners.containsKey(player.getName()))
|
||||
{
|
||||
@ -303,7 +303,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
RemovePet(event.getPlayer(), true);
|
||||
removePet(event.getPlayer(), true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -336,7 +336,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
|
||||
if (player != null && player.isOnline())
|
||||
{
|
||||
RemovePet(player, true);
|
||||
removePet(player, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -438,25 +438,25 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnClientWebResponse(ClientWebResponseEvent event)
|
||||
public void onClientWebResponse(ClientWebResponseEvent event)
|
||||
{
|
||||
ClientPetTokenWrapper token = new Gson().fromJson(event.GetResponse(), ClientPetTokenWrapper.class);
|
||||
|
||||
Get(token.Name).Load(token.DonorToken);
|
||||
Get(token.Name).load(token.DonorToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PetClient AddPlayer(String player)
|
||||
protected PetClient addPlayer(String player)
|
||||
{
|
||||
return new PetClient();
|
||||
}
|
||||
|
||||
public PetFactory GetFactory()
|
||||
public PetFactory getFactory()
|
||||
{
|
||||
return _petFactory;
|
||||
}
|
||||
|
||||
public PetRepository GetRepository()
|
||||
public PetRepository getRepository()
|
||||
{
|
||||
return _repository;
|
||||
}
|
||||
@ -471,15 +471,15 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
return _activePetOwners.get(name);
|
||||
}
|
||||
|
||||
public void DisableAll()
|
||||
public void disableAll()
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
RemovePet(player, true);
|
||||
removePet(player, true);
|
||||
}
|
||||
|
||||
public void DisableAll(Player player)
|
||||
public void disableAll(Player player)
|
||||
{
|
||||
RemovePet(player, true);
|
||||
removePet(player, true);
|
||||
}
|
||||
|
||||
public Collection<Creature> getPets()
|
||||
|
@ -51,7 +51,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerPollData AddPlayer(String player)
|
||||
protected PlayerPollData addPlayer(String player)
|
||||
{
|
||||
return new PlayerPollData();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UserPreferences AddPlayer(String player)
|
||||
protected UserPreferences addPlayer(String player)
|
||||
{
|
||||
return new UserPreferences();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class KitProgressionManager extends MiniClientPlugin<PlayerKit>
|
||||
|
||||
|
||||
@Override
|
||||
protected PlayerKit AddPlayer(String player)
|
||||
protected PlayerKit addPlayer(String player)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ public class RewardManager
|
||||
{
|
||||
if (!displayName.contains("Uncle Sam"))
|
||||
{
|
||||
display = CountryFlag.Usa.getBanner();
|
||||
display = CountryFlag.USA.getBanner();
|
||||
}
|
||||
}
|
||||
UnknownPackageReward reward =
|
||||
@ -929,7 +929,7 @@ public class RewardManager
|
||||
|
||||
public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight, int shards)
|
||||
{
|
||||
Pet pet = _petManager.GetFactory().getPet(entityType);
|
||||
Pet pet = _petManager.getFactory().getPet(entityType);
|
||||
PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager,
|
||||
pet.getName() + " Pet", pet.getName(), entityType, rarity, weight, shards);
|
||||
addReward(type, reward);
|
||||
|
@ -50,8 +50,8 @@ public class PetReward extends UnknownPackageReward
|
||||
PetToken petToken = new PetToken();
|
||||
petToken.PetType = token.PetType;
|
||||
|
||||
_petManager.GetRepository().AddPet(token);
|
||||
_petManager.Get(player).GetPets().put(_petEntity, token.PetName);
|
||||
_petManager.getRepository().AddPet(token);
|
||||
_petManager.Get(player).getPets().put(_petEntity, token.PetName);
|
||||
|
||||
_inventoryManager.addItemToInventory(player, _petEntity.toString(), 1);
|
||||
|
||||
@ -67,6 +67,6 @@ public class PetReward extends UnknownPackageReward
|
||||
return false;
|
||||
}
|
||||
|
||||
return !_petManager.Get(player).GetPets().containsKey(_petEntity);
|
||||
return !_petManager.Get(player).getPets().containsKey(_petEntity);
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerStats AddPlayer(String player)
|
||||
protected PlayerStats addPlayer(String player)
|
||||
{
|
||||
return new PlayerStats();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskClient AddPlayer(String playerName)
|
||||
protected TaskClient addPlayer(String playerName)
|
||||
{
|
||||
return new TaskClient();
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class TournamentManager extends MiniDbClientPlugin<ClientTournamentData>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientTournamentData AddPlayer(String player)
|
||||
protected ClientTournamentData addPlayer(String player)
|
||||
{
|
||||
return new ClientTournamentData();
|
||||
}
|
||||
|
@ -40,6 +40,19 @@ public class BuyChestButton implements IButton
|
||||
@Override
|
||||
public void onClick(final Player player, ClickType clickType)
|
||||
{
|
||||
if (_chestType == TreasureType.FREEDOM)
|
||||
{
|
||||
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
|
||||
{
|
||||
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(F.main("Treasure", "This chest is no longer available for purchases!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!_page.getPlugin().hasItemsToGivePlayer(TreasureType.ILLUMINATED.getRewardPool(), player)
|
||||
&& _chestType == TreasureType.ILLUMINATED)
|
||||
{
|
||||
|
@ -13,6 +13,7 @@ import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.mount.Mount;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -166,13 +167,11 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
|
||||
freedomLore.add(C.cGray + "carved this chest himself from the wood");
|
||||
freedomLore.add(C.cGray + "of the apple tree he cut down...");
|
||||
freedomLore.add(" ");
|
||||
if (freedomCount > 0)
|
||||
if (freedomCount > 0 && !hasAllFreedomItems(getPlayer()))
|
||||
freedomLore.add(ChatColor.RESET + C.cGreen + "Click to Open!");
|
||||
else
|
||||
{
|
||||
freedomLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "35000 Treasure Shards");
|
||||
freedomLore.add(" ");
|
||||
freedomLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
|
||||
freedomLore.add(C.cRed + "This item is no longer available!");
|
||||
}
|
||||
freedomLore.add(" ");
|
||||
freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/7 Unlocked");
|
||||
@ -188,8 +187,13 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
|
||||
addItem(40, shards);
|
||||
|
||||
addChest(11, christmas, TreasureType.CHRISTMAS, christmasCount);
|
||||
if (!hasAllFreedomItems(getPlayer()))
|
||||
if (!hasAllFreedomItems(getPlayer()) && freedomCount >= 1)
|
||||
addChest(13, freedom, TreasureType.FREEDOM, freedomCount);
|
||||
else
|
||||
{
|
||||
freedom = new ShopItem(Material.INK_SACK, DyeColor.SILVER.getData(), C.cRed + C.Bold + "Freedom " + C.cBlue + C.Bold + "Treasure", freedomLore.toArray(new String[0]), 0, true, false);
|
||||
addChest(13, freedom, TreasureType.FREEDOM, freedomCount);
|
||||
}
|
||||
addChest(15, illuminated, TreasureType.ILLUMINATED, illuminatedCount);
|
||||
addChest(20, basic, TreasureType.OLD, basicCount);
|
||||
addChest(22, heroic, TreasureType.ANCIENT, heroicCount);
|
||||
|
@ -2,7 +2,10 @@ package mineplex.core.youtube;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -14,6 +17,7 @@ import java.time.ZonedDateTime;
|
||||
|
||||
public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
|
||||
{
|
||||
private static final int REWARD_MESSAGE_DELAY_SECONDS = 30;
|
||||
private final YoutubeRepository _repository;
|
||||
private final DonationManager _donationManager;
|
||||
|
||||
@ -48,7 +52,11 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
|
||||
}
|
||||
YoutubeClient client = Get(player);
|
||||
client.setClickDate(ZonedDateTime.now(ZoneOffset.UTC).toLocalDate());
|
||||
_repository.attemptYoutube(player, client, () -> _donationManager.RewardCoinsLater("YouTube", player, 250));
|
||||
_repository.attemptYoutube(player, client, () ->
|
||||
{
|
||||
_donationManager.RewardCoinsLater("YouTube", player, 250);
|
||||
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem("250 Treasure Shards") + " for watching the YouTube video")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,7 +76,7 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected YoutubeClient AddPlayer(String player)
|
||||
protected YoutubeClient addPlayer(String player)
|
||||
{
|
||||
return new YoutubeClient(null);
|
||||
}
|
||||
|
@ -89,11 +89,14 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||
import mineplex.minecraft.game.core.IRelation;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.condition.Condition;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
import mineplex.minecraft.game.core.mechanics.Weapon;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -321,6 +324,19 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
Material targetType = event.getTargetBlock().getType();
|
||||
event.setCancelled(targetType == Material.POTATO || targetType == Material.CARROT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetCause() == EntityDamageEvent.DamageCause.CUSTOM
|
||||
&& event.GetDamageInitial() == 0.1
|
||||
&& event.GetDamageePlayer() != null)
|
||||
{
|
||||
Condition poisonShock = _condition.GetActiveCondition(event.GetDamageePlayer(), Condition.ConditionType.POISON_SHOCK);
|
||||
if (poisonShock != null)
|
||||
event.SetIgnoreArmor(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_worldEvent.setFactory(skillManager);
|
||||
@ -984,7 +1000,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientClan AddPlayer(String player)
|
||||
protected ClientClan addPlayer(String player)
|
||||
{
|
||||
return new ClientClan();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.Global.Recharge;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
@ -29,6 +30,11 @@ public class KillCommand extends CommandBase<DamageManager>
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial."));
|
||||
return;
|
||||
}
|
||||
if (mineplex.core.recharge.Recharge.Instance.use(caller, "Suicide", 5000, false, false))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding"));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Clans", "You have imploded."));
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class ClanWhoPage extends ClanPageBase
|
||||
|
||||
// Basic Clan Info
|
||||
lore.add(C.Reset + C.cYellow + "Founder " + C.cWhite + _lookupClan.getDesc());
|
||||
lore.add(C.Reset + C.cYellow + "Formed " + C.cWhite + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT));
|
||||
lore.add(C.Reset + C.cYellow + "Formed " + C.cWhite + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT) + " ago on " + UtilTime.when(_lookupClan.getDateCreated().getTime()));
|
||||
lore.add(C.Reset + C.cYellow + "Members " + C.cWhite + _lookupClan.getOnlinePlayerCount() + "/" + _lookupClan.getMembers().size());
|
||||
lore.add(C.Reset + C.cYellow + "Territory " + C.cWhite + _lookupClan.getClaims() + "/" + _lookupClan.getClaimsMax());
|
||||
lore.add(C.Reset + C.cYellow + "TNT Protection " + C.cWhite + _lookupClan.getProtected());
|
||||
|
@ -204,7 +204,7 @@ public class MurderManager extends MiniClientPlugin<ClientMurder>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientMurder AddPlayer(String player)
|
||||
protected ClientMurder addPlayer(String player)
|
||||
{
|
||||
return new ClientMurder();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class Playtime extends MiniClientPlugin<PlayingClient>
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Set(event.getPlayer(), AddPlayer(event.getPlayer().getName()));
|
||||
Set(event.getPlayer(), addPlayer(event.getPlayer().getName()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -73,7 +73,7 @@ public class Playtime extends MiniClientPlugin<PlayingClient>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayingClient AddPlayer(String player)
|
||||
protected PlayingClient addPlayer(String player)
|
||||
{
|
||||
return new PlayingClient(Bukkit.getPlayer(player), TaskManager.Instance);
|
||||
}
|
||||
|
@ -58,7 +58,10 @@ public class SafeLog extends MiniPlugin
|
||||
|
||||
if (!isSafeLog)
|
||||
{
|
||||
NPCManager.getInstance().spawnLogoutNpc(player);
|
||||
if (!_clansManager.getIncognitoManager().Get(player).Status)
|
||||
{
|
||||
NPCManager.getInstance().spawnLogoutNpc(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,9 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItem;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemFactory;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -105,7 +108,7 @@ public class CustomItem implements Listener
|
||||
|
||||
public ItemStack toItemStack(int amount)
|
||||
{
|
||||
ItemStack item = new ItemStack(_material, amount);
|
||||
ItemStack item = CraftItemStack.asCraftMirror(CraftItemStack.asNMSCopy(new ItemStack(_material, amount)));
|
||||
update(item);
|
||||
|
||||
if (_dullEnchantment)
|
||||
|
@ -2,6 +2,8 @@ package mineplex.game.clans.items;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -86,21 +88,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems;
|
||||
*/
|
||||
public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
{
|
||||
private static final Field UNHANDLED_TAGS_FIELD;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
UNHANDLED_TAGS_FIELD = Class.forName("org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem").getDeclaredField("unhandledTags");
|
||||
UNHANDLED_TAGS_FIELD.setAccessible(true);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException("Error getting unhandledTags field", t);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ITEM_SERIALIZATION_TAG = "-JSON-";
|
||||
private static final Gson GSON;
|
||||
|
||||
@ -626,7 +613,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
return null;
|
||||
}
|
||||
|
||||
CraftItemStack originalItem = CraftItemStack.asCraftMirror(item);
|
||||
CraftItemStack originalItem = CraftItemStack.asCraftMirror(item.cloneItemStack());
|
||||
ItemMeta originalMeta = originalItem.getItemMeta();
|
||||
|
||||
// No need to modify item packets with no lore
|
||||
@ -680,7 +667,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
List<String> cleansed = new ArrayList<>();
|
||||
for (String s : input)
|
||||
{
|
||||
if (!s.startsWith(ITEM_SERIALIZATION_TAG))
|
||||
if (s.startsWith(ITEM_SERIALIZATION_TAG))
|
||||
{
|
||||
cleansed.add(s);
|
||||
}
|
||||
@ -697,40 +684,35 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
// This will not be persistent if the ItemStack is a block and placed then picked up
|
||||
private static Map<String, NBTBase> getUnhandledTags(ItemStack itemStack)
|
||||
{
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta == null)
|
||||
net.minecraft.server.v1_8_R3.ItemStack handle = ((CraftItemStack) itemStack).getHandle();
|
||||
if (handle == null)
|
||||
return Collections.emptyMap();
|
||||
|
||||
NBTTagCompound tag = handle.getTag();
|
||||
|
||||
if (tag == null)
|
||||
return Collections.emptyMap();
|
||||
|
||||
Map<String, NBTBase> unhandled = new HashMap<>();
|
||||
for (String name : tag.c())
|
||||
{
|
||||
return null;
|
||||
unhandled.put(name, tag.get(name));
|
||||
}
|
||||
try
|
||||
{
|
||||
return (Map<String, NBTBase>) UNHANDLED_TAGS_FIELD.get(itemMeta);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
System.out.println("Could not get unhandledTags");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return unhandled;
|
||||
}
|
||||
|
||||
private static void saveUnhandledTags(ItemStack itemStack, Map<String, NBTBase> map)
|
||||
{
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta == null)
|
||||
net.minecraft.server.v1_8_R3.ItemStack handle = ((CraftItemStack) itemStack).getHandle();
|
||||
NBTTagCompound tag = handle.getTag();
|
||||
|
||||
if (tag != null)
|
||||
{
|
||||
return;
|
||||
for (String name : map.keySet())
|
||||
{
|
||||
tag.set(name, map.get(name));
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
UNHANDLED_TAGS_FIELD.set(itemMeta, map);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
System.out.println("Could not get unhandledTags");
|
||||
e.printStackTrace();
|
||||
}
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
public static void save(ItemStack itemStack, boolean remove)
|
||||
@ -743,7 +725,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
saveUnhandledTags(itemStack, data);
|
||||
if (remove)
|
||||
{
|
||||
_customItemCache.remove(item);
|
||||
_customItemCache.remove(UUID.fromString(item._uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
@ -44,7 +45,7 @@ public class ItemListener implements Listener, Runnable
|
||||
public ItemListener(JavaPlugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_plugin.getServer().getScheduler().runTaskTimer(_plugin, this, 20 * 60 * 5, 0);
|
||||
_plugin.getServer().getScheduler().runTaskTimer(_plugin, this, 0, 20 * 60 * 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,7 +66,7 @@ public class ItemListener implements Listener, Runnable
|
||||
|
||||
private void save(Player player, boolean remove)
|
||||
{
|
||||
for (ItemStack item : UtilInv.getItems(player))
|
||||
for (ItemStack item : UtilInv.getItemsUncloned(player))
|
||||
{
|
||||
GearManager.save(item, remove);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class LegendaryItem extends CustomItem
|
||||
{
|
||||
private final long BLOCK_COOLDOWN = 200L; // Right clicking activates right click for 200ms
|
||||
private static final long BLOCK_COOLDOWN = 200L; // Right clicking activates right click for 200ms
|
||||
|
||||
protected long _lastBlock; // Timestamp of last block from wielder
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class TutorialRegion
|
||||
|
||||
private void pasteSchematic()
|
||||
{
|
||||
_locationMap = _schematic.paste(getOrigin(), false);
|
||||
_locationMap = _schematic.paste(getOrigin(), false).getDataLocationMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,5 @@
|
||||
package mineplex.hub;
|
||||
|
||||
import mineplex.core.brawl.fountain.FountainManager;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -14,6 +12,7 @@ import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.brawl.fountain.FountainManager;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.events.ServerShutdownEvent;
|
||||
@ -74,10 +73,6 @@ import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Hub extends JavaPlugin implements IRelation
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
@ -1,4 +1,46 @@
|
||||
package mineplex.hub;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
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.server.ServerListPingEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -10,7 +52,15 @@ import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.*;
|
||||
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.cosmetic.CosmeticManager;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
@ -54,8 +104,22 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.valentines.ValentinesGiftManager;
|
||||
import mineplex.core.youtube.YoutubeManager;
|
||||
import mineplex.hub.commands.*;
|
||||
import mineplex.hub.modules.*;
|
||||
import mineplex.hub.commands.DisguiseCommand;
|
||||
import mineplex.hub.commands.ForcefieldRadius;
|
||||
import mineplex.hub.commands.GadgetToggle;
|
||||
import mineplex.hub.commands.GameModeCommand;
|
||||
import mineplex.hub.commands.NewsCommand;
|
||||
import mineplex.hub.modules.ForcefieldManager;
|
||||
import mineplex.hub.modules.HubVisibilityManager;
|
||||
import mineplex.hub.modules.JumpManager;
|
||||
import mineplex.hub.modules.KothManager;
|
||||
import mineplex.hub.modules.MavericksManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
import mineplex.hub.modules.ParkourManager;
|
||||
import mineplex.hub.modules.SoccerManager;
|
||||
import mineplex.hub.modules.TextManager;
|
||||
import mineplex.hub.modules.ValentinesManager;
|
||||
import mineplex.hub.modules.WorldManager;
|
||||
import mineplex.hub.profile.gui.GUIProfile;
|
||||
import mineplex.hub.tutorial.TutorialManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
@ -69,36 +133,6 @@ 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.*;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
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.*;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
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;
|
||||
|
||||
public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
@ -135,8 +169,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
private IncognitoManager _incognito;
|
||||
private ValentinesManager _valentinesManager;
|
||||
private BonusManager _bonusManager;
|
||||
private JumpManager _jumpManager;
|
||||
// private HalloweenSpookinessManager _halloweenManager;
|
||||
// private TrickOrTreatManager _trickOrTreatManager;
|
||||
private MavericksManager _mavericksManager;
|
||||
|
||||
private Location _spawn;
|
||||
private int _scoreboardTick = 0;
|
||||
@ -181,7 +217,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
_parkour = new ParkourManager(this, donationManager, taskManager);
|
||||
|
||||
new WorldManager(this);
|
||||
new JumpManager(this);
|
||||
_jumpManager = new JumpManager(this);
|
||||
//new TournamentInviter(this);
|
||||
|
||||
|
||||
@ -195,10 +231,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
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, boosterManager);
|
||||
|
||||
|
||||
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());
|
||||
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager);
|
||||
|
||||
CosmeticManager cosmetics = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager);
|
||||
|
||||
_mavericksManager = new MavericksManager(plugin, cosmetics, hologramManager);
|
||||
|
||||
new SoccerManager(this, _gadgetManager);
|
||||
new KothManager(this, _gadgetManager);
|
||||
@ -786,7 +823,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HubClient AddPlayer(String player)
|
||||
protected HubClient addPlayer(String player)
|
||||
{
|
||||
return new HubClient(player);
|
||||
}
|
||||
@ -880,6 +917,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
return _punishManager;
|
||||
}
|
||||
|
||||
public MavericksManager getMavericksManager()
|
||||
{
|
||||
return _mavericksManager;
|
||||
}
|
||||
|
||||
// public HalloweenSpookinessManager getHalloweenManager()
|
||||
// {
|
||||
@ -1072,4 +1114,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
return _incognito;
|
||||
}
|
||||
|
||||
public JumpManager getJumpManager()
|
||||
{
|
||||
return _jumpManager;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class MailManager extends MiniClientPlugin<PlayerMailData> implements Not
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerMailData AddPlayer(String player)
|
||||
protected PlayerMailData addPlayer(String player)
|
||||
{
|
||||
return new PlayerMailData();
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -28,6 +30,7 @@ import mineplex.hub.HubManager;
|
||||
public class JumpManager extends MiniPlugin
|
||||
{
|
||||
public HubManager Manager;
|
||||
private HashSet<String> _preparedDoubleJump = new HashSet<>();
|
||||
|
||||
public JumpManager(HubManager manager)
|
||||
{
|
||||
@ -66,8 +69,9 @@ public class JumpManager extends MiniPlugin
|
||||
vec.setY(Math.abs(vec.getY()));
|
||||
|
||||
//Velocity
|
||||
_preparedDoubleJump.add(player.getName());
|
||||
UtilAction.velocity(player, vec, 1.4, false, 0, 0.2, 1, true);
|
||||
|
||||
|
||||
//Sound
|
||||
player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
|
||||
|
||||
@ -105,8 +109,20 @@ public class JumpManager extends MiniPlugin
|
||||
{
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(false);
|
||||
_preparedDoubleJump.remove(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_preparedDoubleJump.remove(event.getPlayer().getName());
|
||||
}
|
||||
|
||||
public boolean hasDoubleJumped(Player player)
|
||||
{
|
||||
return _preparedDoubleJump.contains(player.getName());
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class KothManager extends MiniPlugin
|
||||
|
||||
Manager.GetGadget().disableAll(player, outfit);
|
||||
Manager.GetMount().DisableAll(player);
|
||||
Manager.getPetManager().DisableAll(player);
|
||||
Manager.getPetManager().disableAll(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -0,0 +1,347 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.function.Function;
|
||||
|
||||
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;
|
||||
|
||||
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.modules.mavericks.MavericksPortalManager;
|
||||
import mineplex.hub.modules.mavericks.MavericksWorldManager;
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
super("Mavericks", plugin);
|
||||
|
||||
_worldManager = new MavericksWorldManager(plugin);
|
||||
_portalManager = new MavericksPortalManager(plugin, _worldManager, cosmeticManager);
|
||||
_repoApproved = new MavericksApprovedRepository();
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
}
|
@ -3,9 +3,9 @@ package mineplex.hub.modules;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Bat;
|
||||
@ -20,9 +20,10 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
@ -37,8 +38,10 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.event.StackerEvent;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
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;
|
||||
@ -50,8 +53,8 @@ import mineplex.hub.HubManager;
|
||||
|
||||
public class SoccerManager extends MiniPlugin
|
||||
{
|
||||
public HubManager Manager;
|
||||
|
||||
private HubManager _hubManager;
|
||||
|
||||
private HashSet<Player> _active = new HashSet<Player>();
|
||||
|
||||
private ArrayList<OutfitTeam> _teamArmor = new ArrayList<OutfitTeam>();
|
||||
@ -71,10 +74,10 @@ public class SoccerManager extends MiniPlugin
|
||||
private Location _cornerBlueGoalA;
|
||||
private Location _cornerBlueGoalB;
|
||||
|
||||
int _blueGoals = 0;
|
||||
int _redGoals = 0;
|
||||
private int _blueGoals = 0;
|
||||
private int _redGoals = 0;
|
||||
|
||||
int _insideGoalTicks = 0;
|
||||
private int _insideGoalTicks = 0;
|
||||
|
||||
private Slime _ball;
|
||||
private Vector _ballVel;
|
||||
@ -89,29 +92,29 @@ public class SoccerManager extends MiniPlugin
|
||||
protected Location _lastLoc;
|
||||
protected ArrayList<Vector> _velHistory = new ArrayList<Vector>();
|
||||
|
||||
public SoccerManager(HubManager manager, GadgetManager gadgets)
|
||||
public SoccerManager(HubManager hubManager, GadgetManager gadgetManager)
|
||||
{
|
||||
super("Football Manager", manager.getPlugin());
|
||||
super("Football Manager", hubManager.getPlugin());
|
||||
|
||||
Manager = manager;
|
||||
_hubManager = hubManager;
|
||||
|
||||
_cornerFieldPlayerA = new Location(hubManager.GetSpawn().getWorld(), 28.5,70,-27.5);
|
||||
_cornerFieldPlayerB = new Location(hubManager.GetSpawn().getWorld(), 50.5,100,-65.5);
|
||||
|
||||
_cornerFieldPlayerA = new Location(Manager.GetSpawn().getWorld(), 28.5,70,-27.5);
|
||||
_cornerFieldPlayerB = new Location(Manager.GetSpawn().getWorld(), 50.5,100,-65.5);
|
||||
_cornerGoalPlayerA = new Location(hubManager.GetSpawn().getWorld(), 35.5,70,-24.5);
|
||||
_cornerGoalPlayerB = new Location(hubManager.GetSpawn().getWorld(), 43.5,100,-68.5);
|
||||
|
||||
_cornerGoalPlayerA = new Location(Manager.GetSpawn().getWorld(), 35.5,70,-24.5);
|
||||
_cornerGoalPlayerB = new Location(Manager.GetSpawn().getWorld(), 43.5,100,-68.5);
|
||||
_cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), 29.75,70,-28.75);
|
||||
_cornerFieldB = new Location(hubManager.GetSpawn().getWorld(), 49.25,100,-64.25);
|
||||
|
||||
_cornerFieldA = new Location(Manager.GetSpawn().getWorld(), 29.75,70,-28.75);
|
||||
_cornerFieldB = new Location(Manager.GetSpawn().getWorld(), 49.25,100,-64.25);
|
||||
_cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-64.25);
|
||||
_cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-67.25);
|
||||
|
||||
_cornerRedGoalA = new Location(Manager.GetSpawn().getWorld(), 36.75,70,-64.25);
|
||||
_cornerRedGoalB = new Location(Manager.GetSpawn().getWorld(), 42.25,73.5,-67.25);
|
||||
|
||||
_cornerBlueGoalA = new Location(Manager.GetSpawn().getWorld(), 36.75,70,-25.75);
|
||||
_cornerBlueGoalB = new Location(Manager.GetSpawn().getWorld(), 42.25,73.5,-28.75);
|
||||
_cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-25.75);
|
||||
_cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-28.75);
|
||||
|
||||
//Store Gadgets
|
||||
for (Gadget gadget : gadgets.getGadgets(GadgetType.COSTUME))
|
||||
for (Gadget gadget : gadgetManager.getGadgets(GadgetType.COSTUME))
|
||||
{
|
||||
if (gadget instanceof OutfitTeam)
|
||||
{
|
||||
@ -349,10 +352,12 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void clean(UpdateEvent event)
|
||||
{
|
||||
@ -470,9 +475,9 @@ public class SoccerManager extends MiniPlugin
|
||||
outfit.add("Team Pants");
|
||||
outfit.add("Team Boots");
|
||||
|
||||
Manager.GetGadget().disableAll(player, outfit);
|
||||
Manager.GetMount().DisableAll(player);
|
||||
Manager.getPetManager().DisableAll(player);
|
||||
_hubManager.GetGadget().disableAll(player, outfit);
|
||||
_hubManager.GetMount().DisableAll(player);
|
||||
_hubManager.getPetManager().disableAll(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -481,11 +486,11 @@ public class SoccerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSoccerMode(Player player)
|
||||
public boolean isSoccerMode(Entity entity)
|
||||
{
|
||||
return _active.contains(player);
|
||||
return _active.contains(entity);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void disableGadgets(GadgetEnableEvent event)
|
||||
{
|
||||
@ -510,6 +515,35 @@ public class SoccerManager extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableStacker(StackerEvent event)
|
||||
{
|
||||
if (isSoccerMode(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableGuardianLazer(GadgetSelectLocationEvent event)
|
||||
{
|
||||
if (UtilAlg.inBoundingBox(event.getLocation(), _cornerFieldA, _cornerFieldB))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
// Disable velocity but allow double jumping.
|
||||
|
||||
if (isSoccerMode(event.getPlayer()) && !_hubManager.getJumpManager().hasDoubleJumped(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
|
@ -81,6 +81,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;
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class WorldManager extends MiniPlugin
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
for (Player player : Manager.GetSpawn().getWorld().getPlayers())
|
||||
{
|
||||
if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 200)
|
||||
{
|
||||
|
@ -0,0 +1,108 @@
|
||||
package mineplex.hub.modules.mavericks;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
/**
|
||||
* A small teleportation manager to manage the portal from the hub to the mavericks world and back.
|
||||
*/
|
||||
public class MavericksPortalManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private Box _portalHubMavericks;
|
||||
private Box _portalMavericksHub;
|
||||
|
||||
private Location _destHub;
|
||||
private Location _destMavericks;
|
||||
|
||||
private CosmeticManager _cosmeticManager;
|
||||
|
||||
public MavericksPortalManager(JavaPlugin plugin, MavericksWorldManager worldManager, CosmeticManager cosmeticManager)
|
||||
{
|
||||
super("Mavericks Teleporter", plugin);
|
||||
|
||||
_cosmeticManager = cosmeticManager;
|
||||
|
||||
_portalHubMavericks = new Box("world", new Vector(20, 71, -1), new Vector(21, 74, 1));
|
||||
_destMavericks = worldManager.getSpawn();
|
||||
|
||||
_portalMavericksHub = new Box(worldManager.getWorld().getName(), new Vector(3, 20, 316), new Vector(-1, 25, 317));
|
||||
_destHub = new Location(Bukkit.getWorld("world"), 0.5, 80, 0.5);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK) return;
|
||||
|
||||
for(Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
|
||||
Box box = isInside(p);
|
||||
|
||||
if(box == null) continue;
|
||||
|
||||
_cosmeticManager.getPetManager().disableAll(p);
|
||||
_cosmeticManager.getMountManager().DisableAll(p);
|
||||
|
||||
if(box == _portalHubMavericks)
|
||||
{
|
||||
p.teleport(_destMavericks);
|
||||
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area."));
|
||||
}
|
||||
else 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 Box isInside(Player player)
|
||||
{
|
||||
if(_portalHubMavericks.isInside(player.getLocation())) return _portalHubMavericks;
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
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_Stadium");
|
||||
wc.generator(new WorldGenCleanRoom());
|
||||
_world = wc.createWorld();
|
||||
|
||||
_world.setGameRuleValue("doDaylightCycle", "false");
|
||||
_world.setTime(6000);
|
||||
|
||||
_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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -948,7 +948,7 @@ public class ServerManager extends MiniDbClientPlugin<SimpleClanToken> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SimpleClanToken AddPlayer(String player)
|
||||
protected SimpleClanToken addPlayer(String player)
|
||||
{
|
||||
return new SimpleClanToken();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public enum GameType
|
||||
Barbarians("A Barbarians Life"),
|
||||
Bridge("The Bridges"),
|
||||
Build("Master Builders"),
|
||||
BuildMavericks("Mavericks Master Builders"),
|
||||
CastleSiege("Castle Siege"),
|
||||
ChampionsTDM("Champions TDM", "Champions"),
|
||||
ChampionsDominate("Champions Domination", "Champions"),
|
||||
|
@ -322,7 +322,7 @@ public class ClassManager extends MiniClientPlugin<ClientClass> implements IClas
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientClass AddPlayer(String player)
|
||||
protected ClientClass addPlayer(String player)
|
||||
{
|
||||
return new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(player), _donationManager.Get(player), null);
|
||||
}
|
||||
|
@ -402,6 +402,18 @@ public class ConditionManager extends MiniPlugin
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean HasCondition(LivingEntity target, ConditionType type)
|
||||
{
|
||||
if (!_conditions.containsKey(target))
|
||||
return false;
|
||||
|
||||
for (Condition cond : _conditions.get(target))
|
||||
if (type == null || cond.GetType() == type)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public WeakHashMap<LivingEntity, LinkedList<ConditionActive>> GetActiveConditions()
|
||||
{
|
||||
|
@ -3,6 +3,9 @@ package mineplex.minecraft.game.core.damage;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -57,6 +60,9 @@ public class DamageManager extends MiniPlugin
|
||||
public boolean DisableDamageChanges = false;
|
||||
|
||||
private boolean _enabled = true;
|
||||
|
||||
private final HashMap<String, Integer> _protectionTypeModifiers = new HashMap<String, Integer>();
|
||||
private final HashMap<String, DamageCause[]> _protectionCauses = new HashMap<String, DamageCause[]>();
|
||||
|
||||
public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager, ConditionManager conditionManager)
|
||||
{
|
||||
@ -79,6 +85,102 @@ public class DamageManager extends MiniPlugin
|
||||
}
|
||||
|
||||
registerEvents(new NpcProtectListener(npcManager));
|
||||
|
||||
_protectionTypeModifiers.put(Enchantment.PROTECTION_ENVIRONMENTAL.getName(), 1);
|
||||
_protectionTypeModifiers.put(Enchantment.PROTECTION_FIRE.getName(), 2);
|
||||
_protectionTypeModifiers.put(Enchantment.PROTECTION_EXPLOSIONS.getName(), 2);
|
||||
_protectionTypeModifiers.put(Enchantment.PROTECTION_PROJECTILE.getName(), 2);
|
||||
_protectionTypeModifiers.put(Enchantment.PROTECTION_FALL.getName(), 3);
|
||||
|
||||
_protectionCauses.put(Enchantment.PROTECTION_ENVIRONMENTAL.getName(), new DamageCause[] {DamageCause.BLOCK_EXPLOSION, DamageCause.CONTACT, DamageCause.CUSTOM, DamageCause.DROWNING, DamageCause.ENTITY_ATTACK, DamageCause.ENTITY_EXPLOSION, DamageCause.FALL, DamageCause.FALLING_BLOCK, DamageCause.FIRE, DamageCause.FIRE_TICK, DamageCause.LAVA, DamageCause.LIGHTNING, DamageCause.PROJECTILE, DamageCause.SUFFOCATION, DamageCause.THORNS});
|
||||
_protectionCauses.put(Enchantment.PROTECTION_FIRE.getName(), new DamageCause[] {DamageCause.FIRE, DamageCause.FIRE_TICK, DamageCause.LAVA});
|
||||
_protectionCauses.put(Enchantment.PROTECTION_EXPLOSIONS.getName(), new DamageCause[] {DamageCause.BLOCK_EXPLOSION, DamageCause.ENTITY_EXPLOSION});
|
||||
_protectionCauses.put(Enchantment.PROTECTION_PROJECTILE.getName(), new DamageCause[] {DamageCause.PROJECTILE});
|
||||
_protectionCauses.put(Enchantment.PROTECTION_FALL.getName(), new DamageCause[] {DamageCause.FALL});
|
||||
}
|
||||
|
||||
private int getHighestLevel(Enchantment ench, ItemStack[] items)
|
||||
{
|
||||
int level = 0;
|
||||
|
||||
for (ItemStack item : items)
|
||||
{
|
||||
if (item == null && item.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!item.containsEnchantment(ench))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.getEnchantmentLevel(ench) <= level)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
level = item.getEnchantmentLevel(ench);
|
||||
}
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
private int getTotalEPF(Enchantment ench, ItemStack[] items)
|
||||
{
|
||||
if (!_protectionTypeModifiers.containsKey(ench.getName()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!_protectionCauses.containsKey(ench.getName()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int epf = 0;
|
||||
|
||||
for (ItemStack item : items)
|
||||
{
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!item.containsEnchantment(ench))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.getEnchantmentLevel(ench) <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
epf += (item.getEnchantmentLevel(ench) * _protectionTypeModifiers.get(ench.getName()));
|
||||
}
|
||||
|
||||
return Math.min(20, epf);
|
||||
}
|
||||
|
||||
private double getTotalEnchantReduction(ItemStack[] armor, DamageCause cause)
|
||||
{
|
||||
int epf = 0;
|
||||
|
||||
for (Enchantment ench : Enchantment.values())
|
||||
{
|
||||
if (!_protectionTypeModifiers.containsKey(ench.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!_protectionCauses.containsKey(ench.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!Arrays.asList(_protectionCauses.get(ench.getName())).contains(cause))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
epf += getTotalEPF(ench, armor);
|
||||
}
|
||||
|
||||
epf = Math.max(0, Math.min(20, epf));
|
||||
return new BigDecimal(1).subtract(new BigDecimal(epf).divide(new BigDecimal(25))).doubleValue();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -129,6 +231,9 @@ public class DamageManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onEntityCombust(EntityCombustByEntityEvent event)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (!(event.getCombuster() instanceof Player || event.getCombuster() instanceof Arrow))
|
||||
return;
|
||||
|
||||
@ -273,35 +378,9 @@ public class DamageManager extends MiniPlugin
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
if (damagee != null)
|
||||
{
|
||||
for (ItemStack stack : damagee.getInventory().getArmorContents())
|
||||
if (getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()) > 0)
|
||||
{
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
Map<Enchantment, Integer> enchants = stack.getEnchantments();
|
||||
for (Enchantment e : enchants.keySet())
|
||||
{
|
||||
if (e.equals(Enchantment.PROTECTION_ENVIRONMENTAL))
|
||||
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
|
||||
|
||||
else if (e.equals(Enchantment.PROTECTION_FIRE) &&
|
||||
event.GetCause() == DamageCause.FIRE &&
|
||||
event.GetCause() == DamageCause.FIRE_TICK &&
|
||||
event.GetCause() == DamageCause.LAVA)
|
||||
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
|
||||
|
||||
else if (e.equals(Enchantment.PROTECTION_FALL) &&
|
||||
event.GetCause() == DamageCause.FALL)
|
||||
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
|
||||
|
||||
else if (e.equals(Enchantment.PROTECTION_EXPLOSIONS) &&
|
||||
event.GetCause() == DamageCause.ENTITY_EXPLOSION)
|
||||
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
|
||||
|
||||
else if (e.equals(Enchantment.PROTECTION_PROJECTILE) &&
|
||||
event.GetCause() == DamageCause.PROJECTILE)
|
||||
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
|
||||
}
|
||||
event.AddMult("Ench Prot", damagee.getName(), getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()), false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,8 +403,15 @@ public class DamageManager extends MiniPlugin
|
||||
|
||||
else if (e.equals(Enchantment.FIRE_ASPECT))
|
||||
if (_conditionManager != null)
|
||||
{
|
||||
double reduce = 0;
|
||||
if (damagee != null)
|
||||
{
|
||||
reduce = (15 * getHighestLevel(Enchantment.PROTECTION_FIRE, damagee.getInventory().getArmorContents())) * (4 * (double)enchants.get(e));
|
||||
}
|
||||
_conditionManager.Factory().Ignite("Ench Fire", event.GetDamageeEntity(), damager,
|
||||
4 * (double)enchants.get(e), false, false);
|
||||
(4 * (double)enchants.get(e)) - reduce, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
@ -48,7 +49,7 @@ public class StaffServer extends JavaPlugin
|
||||
|
||||
//Static Modules
|
||||
CommandCenter.Initialize(this);
|
||||
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress);
|
||||
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress, Rank.DEVELOPER);
|
||||
CommandCenter.Instance.setClientManager(clientManager);
|
||||
Recharge.Initialize(this);
|
||||
|
||||
@ -83,15 +84,15 @@ public class StaffServer extends JavaPlugin
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EvilEsther"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("adaa7613-6683-400f-baf8-7272c04b2cb4"), "Timmy48081_"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("57791647-93b1-4980-8835-7fddadd20eb8"), "xTheOnlyOreOx"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("231fb752-9556-489b-8428-f47c7598e061"), "Nuclear_Poptart"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "Cherdy8s"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo"));
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD"));
|
||||
|
||||
|
||||
((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20"));
|
||||
((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp"));
|
||||
((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo"));
|
||||
((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD"));
|
||||
|
||||
new ProfileCacheManager(this);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user