Merge branch 'develop' into thanos-mineware

Conflicts:
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java
This commit is contained in:
Thanos paravantis 2016-04-22 22:03:15 +03:00
commit fa75bc15ad
545 changed files with 40144 additions and 6811 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ bin
MagicMC MagicMC
.externalToolBuilders/
/Plugins/Mineplex.Core/.externalToolBuilders/Core Builder.launch /Plugins/Mineplex.Core/.externalToolBuilders/Core Builder.launch
/Plugins/Mineplex.AntiCheat /Plugins/Mineplex.AntiCheat

View File

@ -0,0 +1,21 @@
From 32269ec951791791fe8553f0939c6eaa2b6b472b Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 30 Dec 2015 19:57:10 +1300
Subject: [PATCH] Add Elytra
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 0fb2605..bc930d1 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -443,6 +443,7 @@ public enum Material {
JUNGLE_DOOR_ITEM(429),
ACACIA_DOOR_ITEM(430),
DARK_OAK_DOOR_ITEM(431),
+ ELYTRA(443),
GOLD_RECORD(2256, 1),
GREEN_RECORD(2257, 1),
RECORD_3(2258, 1),
--
1.9.5.msysgit.0

View File

@ -0,0 +1,46 @@
From 24a5d0cfe1d62e2ff6a3a0a279c63b038a134629 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 30 Dec 2015 21:05:47 +1300
Subject: [PATCH] Levitation potion effect
diff --git a/src/main/java/org/bukkit/potion/PotionEffectType.java b/src/main/java/org/bukkit/potion/PotionEffectType.java
index 4919d59..e75aa18 100644
--- a/src/main/java/org/bukkit/potion/PotionEffectType.java
+++ b/src/main/java/org/bukkit/potion/PotionEffectType.java
@@ -126,6 +126,11 @@ public abstract class PotionEffectType {
*/
public static final PotionEffectType SATURATION = new PotionEffectTypeWrapper(23);
+ /**
+ * Slows the fall rate down
+ */
+ public static final PotionEffectType LEVITATION = new PotionEffectTypeWrapper(25);
+
private final int id;
protected PotionEffectType(int id) {
@@ -202,7 +207,7 @@ public abstract class PotionEffectType {
return "PotionEffectType[" + id + ", " + getName() + "]";
}
- private static final PotionEffectType[] byId = new PotionEffectType[24];
+ private static final PotionEffectType[] byId = new PotionEffectType[26];
private static final Map<String, PotionEffectType> byName = new HashMap<String, PotionEffectType>();
// will break on updates.
private static boolean acceptingNew = true;
diff --git a/src/main/java/org/bukkit/potion/PotionType.java b/src/main/java/org/bukkit/potion/PotionType.java
index 6ad9a91..a3dc228 100644
--- a/src/main/java/org/bukkit/potion/PotionType.java
+++ b/src/main/java/org/bukkit/potion/PotionType.java
@@ -15,6 +15,7 @@ public enum PotionType {
INSTANT_DAMAGE(12, PotionEffectType.HARM, 2),
WATER_BREATHING(13, PotionEffectType.WATER_BREATHING, 1),
INVISIBILITY(14, PotionEffectType.INVISIBILITY, 1),
+ LEVITATION(15, PotionEffectType.LEVITATION, 1),
;
private final int damageValue, maxLevel;
--
1.9.5.msysgit.0

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,82 @@
From d1cf06c308d35a765cf2d11b170a9d0f8fabb418 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 30 Dec 2015 22:38:30 +1300
Subject: [PATCH] Some debug and crash fixes
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index b1348b9..147295e 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -932,12 +932,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
protected void a(MobEffect mobeffect, boolean flag) {
super.a(mobeffect, flag);
- this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect));
+ if (this.playerConnection.networkManager.getVersion() > 47 || mobeffect.getEffectId() != 25)
+ this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect));
}
protected void b(MobEffect mobeffect) {
super.b(mobeffect);
- this.playerConnection.sendPacket(new PacketPlayOutRemoveEntityEffect(this.getId(), mobeffect));
+ if (this.playerConnection.networkManager.getVersion() > 47 || mobeffect.getEffectId() != 25)
+ this.playerConnection.sendPacket(new PacketPlayOutRemoveEntityEffect(this.getId(), mobeffect));
}
public void enderTeleportTo(double d0, double d1, double d2) {
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 39f0b73..e5c947f 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -428,7 +428,8 @@ public class EntityTrackerEntry {
while (iterator.hasNext()) {
MobEffect mobeffect = (MobEffect) iterator.next();
- entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.tracker.getId(), mobeffect));
+ if (entityplayer.playerConnection.networkManager.getVersion() > 47 || mobeffect.getEffectId() != 25)
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.tracker.getId(), mobeffect));
}
}
}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
index ef51cd4..54c1ec9 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
@@ -14,7 +14,7 @@ public class PacketPlayOutMapChunkBulk implements Packet<PacketListenerPlayOut>
public PacketPlayOutMapChunkBulk() {}
- public PacketPlayOutMapChunkBulk(List<Chunk> list) {Thread.dumpStack();
+ public PacketPlayOutMapChunkBulk(List<Chunk> list) {
int i = list.size();
mapChunks = list;
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 81e231d..42d9e76 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -168,7 +168,8 @@ public abstract class PlayerList {
while (iterator.hasNext()) {
MobEffect mobeffect = (MobEffect) iterator.next();
- playerconnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
+ if (playerconnection.networkManager.getVersion() > 47 || mobeffect.getEffectId() != 25)
+ playerconnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
}
entityplayer.syncInventory();
@@ -615,7 +616,9 @@ public abstract class PlayerList {
entityplayer.updateAbilities();
for (Object o1 : entityplayer.getEffects()) {
MobEffect mobEffect = (MobEffect) o1;
- entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
+
+ if (entityplayer.playerConnection.networkManager.getVersion() > 47 || mobEffect.getEffectId() != 25)
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
}
// entityplayer1.syncInventory();
// CraftBukkit end
--
1.9.5.msysgit.0

View File

@ -0,0 +1,319 @@
From 0d1bec3dad53441ead8ac0f22e2464a924fb8818 Mon Sep 17 00:00:00 2001
From: git <libraryaddict115@yahoo.co.nz>
Date: Thu, 25 Feb 2016 18:20:02 +1300
Subject: [PATCH] Current patch stuff
diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java
index 5c09068..45a9acb 100644
--- a/src/main/java/net/minecraft/server/EntityEnderman.java
+++ b/src/main/java/net/minecraft/server/EntityEnderman.java
@@ -160,6 +160,8 @@ public class EntityEnderman extends EntityMonster {
}
protected boolean k(double d0, double d1, double d2) {
+ if (isVegetated())
+ return false;
double d3 = this.locX;
double d4 = this.locY;
double d5 = this.locZ;
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index d074110..e9a324a 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -550,13 +550,13 @@ public abstract class EntityLiving extends Entity {
protected void B() {
if (this.effects.isEmpty()) {
this.bj();
- this.setInvisible(false);
+ this.setInvisible(isMineplexInvisible());
} else {
int i = PotionBrewer.a(this.effects.values());
this.datawatcher.watch(8, Byte.valueOf((byte) (PotionBrewer.b(this.effects.values()) ? 1 : 0)), META_AMBIENT_POTION, PotionBrewer.b(this.effects.values()));
this.datawatcher.watch(7, Integer.valueOf(i), META_POTION_COLOR, i);
- this.setInvisible(this.hasEffect(MobEffectList.INVISIBILITY.id));
+ this.setInvisible(isMineplexInvisible() || this.hasEffect(MobEffectList.INVISIBILITY.id));
}
}
diff --git a/src/main/java/net/minecraft/server/EnumProtocol.java b/src/main/java/net/minecraft/server/EnumProtocol.java
index f3877e4..0343bf8 100644
--- a/src/main/java/net/minecraft/server/EnumProtocol.java
+++ b/src/main/java/net/minecraft/server/EnumProtocol.java
@@ -219,7 +219,11 @@ public enum EnumProtocol
public Integer a(EnumProtocolDirection enumprotocoldirection, Packet packet, boolean is1_8)
{
Entry entry = (Entry) ((BiMap)j.get(enumprotocoldirection)).inverse().get(packet.getClass());
- if ((Integer) (is1_8 ? entry.getKey() : entry.getValue()) < 0){System.out.print("Trying to send unsupported " + packet.getClass().getSimpleName());Thread.dumpStack();}
+ if ((Integer) (is1_8 ? entry.getKey() : entry.getValue()) < 0)
+ {
+ System.out.print("Trying to send unsupported " + packet.getClass().getSimpleName());
+ Thread.dumpStack();
+ }
return (Integer) (is1_8 ? entry.getKey() : entry.getValue());
}
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 824ec1b..9d27032 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -25,7 +25,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
int version = packethandshakinginsetprotocol.b();
//System.out.print(version);
- boolean supported = version == 47 || version == 94;
+ boolean supported = version == 47 || version == 104;
if (supported)
{
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
index 702d33d..c3a067e 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
@@ -5,9 +5,9 @@ import java.io.IOException;
public class PacketPlayOutEntity implements Packet<PacketListenerPlayOut> {
public int a;
- public byte b;
- public byte c;
- public byte d;
+ public short b;
+ public short c;
+ public short d;
public byte e;
public byte f;
public boolean g;
@@ -87,9 +87,18 @@ public class PacketPlayOutEntity implements Packet<PacketListenerPlayOut> {
public void b(PacketDataSerializer packetdataserializer) throws IOException {
super.b(packetdataserializer);
- packetdataserializer.writeByte(this.b);
- packetdataserializer.writeByte(this.c);
- packetdataserializer.writeByte(this.d);
+ if (packetdataserializer.version != 47)
+ {
+ packetdataserializer.writeShort(this.b);
+ packetdataserializer.writeShort(this.c);
+ packetdataserializer.writeShort(this.d);
+ }
+ else
+ {
+ packetdataserializer.writeByte(this.b);
+ packetdataserializer.writeByte(this.c);
+ packetdataserializer.writeByte(this.d);
+ }
packetdataserializer.writeBoolean(this.g);
}
}
@@ -123,9 +132,18 @@ public class PacketPlayOutEntity implements Packet<PacketListenerPlayOut> {
public void b(PacketDataSerializer packetdataserializer) throws IOException {
super.b(packetdataserializer);
- packetdataserializer.writeByte(this.b);
- packetdataserializer.writeByte(this.c);
- packetdataserializer.writeByte(this.d);
+ if (packetdataserializer.version != 47)
+ {
+ packetdataserializer.writeShort(this.b);
+ packetdataserializer.writeShort(this.c);
+ packetdataserializer.writeShort(this.d);
+ }
+ else
+ {
+ packetdataserializer.writeByte(this.b);
+ packetdataserializer.writeByte(this.c);
+ packetdataserializer.writeByte(this.d);
+ }
packetdataserializer.writeByte(this.e);
packetdataserializer.writeByte(this.f);
packetdataserializer.writeBoolean(this.g);
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
index 4730b34..3fa9fe4 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
@@ -44,9 +44,15 @@ public class PacketPlayOutEntityTeleport implements Packet<PacketListenerPlayOut
public void b(PacketDataSerializer packetdataserializer) {
packetdataserializer.b(this.a);
+ if (packetdataserializer.version == 47){
packetdataserializer.writeInt(this.b);
packetdataserializer.writeInt(this.c);
packetdataserializer.writeInt(this.d);
+ } else {
+ packetdataserializer.writeDouble(this.b/32D);
+ packetdataserializer.writeDouble(this.c/32D);
+ packetdataserializer.writeDouble(this.d/32D);
+ }
packetdataserializer.writeByte(this.e);
packetdataserializer.writeByte(this.f);
packetdataserializer.writeBoolean(this.g);
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java b/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
index 340787a..efc9a08 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
@@ -48,9 +48,15 @@ public class PacketPlayOutNamedEntitySpawn implements Packet<PacketListenerPlayO
public void b(PacketDataSerializer packetdataserializer) throws IOException {
packetdataserializer.b(this.a);
packetdataserializer.a(this.b);
- packetdataserializer.writeInt(this.c);
- packetdataserializer.writeInt(this.d);
- packetdataserializer.writeInt(this.e);
+ if (packetdataserializer.version != 47){
+ packetdataserializer.writeDouble(this.c/32D);
+ packetdataserializer.writeDouble(this.d/32D);
+ packetdataserializer.writeDouble(this.e/32D);
+ }else {
+ packetdataserializer.writeInt(this.c);
+ packetdataserializer.writeInt(this.d);
+ packetdataserializer.writeInt(this.e);
+ }
packetdataserializer.writeByte(this.f);
packetdataserializer.writeByte(this.g);
if (packetdataserializer.version == 47)
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java b/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java
index 6c8c8fa..b72b7d7 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java
@@ -279,6 +279,7 @@ public class PacketPlayOutNamedSoundEffect
toPlay = sounds.get(toPlay);
packetdataserializer.a(toPlay);
+ packetdataserializer.b(0);
packetdataserializer.writeInt(b);
packetdataserializer.writeInt(c);
packetdataserializer.writeInt(d);
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
index 0c60066..c9de471 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
@@ -93,9 +93,15 @@ public class PacketPlayOutSpawnEntity implements Packet<PacketListenerPlayOut> {
if (packetdataserializer.version != 47)
packetdataserializer.a(this.uuid);
packetdataserializer.writeByte(this.j);
- packetdataserializer.writeInt(this.b);
- packetdataserializer.writeInt(this.c);
- packetdataserializer.writeInt(this.d);
+ if (packetdataserializer.version != 47){
+ packetdataserializer.writeDouble(this.b/32D);
+ packetdataserializer.writeDouble(this.c/32D);
+ packetdataserializer.writeDouble(this.d/32D);
+ }else {
+ packetdataserializer.writeInt(this.b);
+ packetdataserializer.writeInt(this.c);
+ packetdataserializer.writeInt(this.d);
+ }
packetdataserializer.writeByte(this.h);
packetdataserializer.writeByte(this.i);
packetdataserializer.writeInt(this.k);
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityExperienceOrb.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityExperienceOrb.java
index 4f2b03e..0a39433 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityExperienceOrb.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityExperienceOrb.java
@@ -42,9 +42,15 @@ public class PacketPlayOutSpawnEntityExperienceOrb
throws IOException
{
packetdataserializer.b(a);
- packetdataserializer.writeInt(b);
- packetdataserializer.writeInt(c);
- packetdataserializer.writeInt(d);
+ if (packetdataserializer.version != 47){
+ packetdataserializer.writeDouble(this.b/32D);
+ packetdataserializer.writeDouble(this.c/32D);
+ packetdataserializer.writeDouble(this.d/32D);
+ }else {
+ packetdataserializer.writeInt(this.b);
+ packetdataserializer.writeInt(this.c);
+ packetdataserializer.writeInt(this.d);
+ }
packetdataserializer.writeShort(e);
}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
index 9da448e..ea7c98b 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
@@ -88,9 +88,15 @@ public class PacketPlayOutSpawnEntityLiving implements Packet<PacketListenerPlay
if (packetdataserializer.version != 47)
packetdataserializer.a(this.uuid);
packetdataserializer.writeByte(this.b & 255);
- packetdataserializer.writeInt(this.c);
- packetdataserializer.writeInt(this.d);
- packetdataserializer.writeInt(this.e);
+ if (packetdataserializer.version != 47){
+ packetdataserializer.writeDouble(this.c/32D);
+ packetdataserializer.writeDouble(this.d/32D);
+ packetdataserializer.writeDouble(this.e/32D);
+ }else {
+ packetdataserializer.writeInt(this.c);
+ packetdataserializer.writeInt(this.d);
+ packetdataserializer.writeInt(this.e);
+ }
packetdataserializer.writeByte(this.i);
packetdataserializer.writeByte(this.j);
packetdataserializer.writeByte(this.k);
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityWeather.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityWeather.java
index 2ce95fa..51a3a21 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityWeather.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityWeather.java
@@ -44,9 +44,15 @@ public class PacketPlayOutSpawnEntityWeather
{
packetdataserializer.b(a);
packetdataserializer.writeByte(e);
- packetdataserializer.writeInt(b);
- packetdataserializer.writeInt(c);
- packetdataserializer.writeInt(d);
+ if (packetdataserializer.version != 47){
+ packetdataserializer.writeDouble(this.b/32D);
+ packetdataserializer.writeDouble(this.c/32D);
+ packetdataserializer.writeDouble(this.d/32D);
+ }else {
+ packetdataserializer.writeInt(this.b);
+ packetdataserializer.writeInt(this.c);
+ packetdataserializer.writeInt(this.d);
+ }
}
public void a(PacketListenerPlayOut packetlistenerplayout)
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 16f8609..b1400c7 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1212,6 +1212,17 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
}
+ // Spigot start
+ else if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK
+ && (player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.ADVENTURE || player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.SPECTATOR)) {
+ // RIGHT_CLICK_BLOCK sets this flag
+ if (player.playerInteractManager.firedInteract) {
+ player.playerInteractManager.firedInteract = false;
+ } else {
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, player.inventory.getItemInHand(), true);
+ }
+ }
+ // Spigot end
// Arm swing animation
PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
index 0cc8f9b..dd07600 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
@@ -14,9 +14,9 @@ public class CraftSound {
set(AMBIENCE_RAIN, "ambient.weather.rain");
set(AMBIENCE_THUNDER, "ambient.weather.thunder");
// Damage
- set(HURT_FLESH, "game.neutral.hurt");
- set(FALL_BIG, "game.neutral.hurt.fall.big");
- set(FALL_SMALL, "game.neutral.hurt.fall.small");
+ set(HURT_FLESH, "game.player.hurt");
+ set(FALL_BIG, "game.player.hurt.fall.big");
+ set(FALL_SMALL, "game.player.hurt.fall.small");
// Dig Sounds
set(DIG_WOOL, "dig.cloth");
set(DIG_GRASS, "dig.grass");
--
1.9.5.msysgit.0

View File

@ -0,0 +1,135 @@
From af6ac4b09da7ad63ebb568333807c7621398f0a6 Mon Sep 17 00:00:00 2001
From: git <libraryaddict115@yahoo.co.nz>
Date: Sun, 28 Feb 2016 00:37:30 +1300
Subject: [PATCH] Changed maven version, fixed entity movement, fixed sound
packet
diff --git a/pom.xml b/pom.xml
index 91627ff..1ea9f81 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<packaging>jar</packaging>
- <version>1.8.8-R0.1-SNAPSHOT</version>
+ <version>1.8.8-1.9-SNAPSHOT</version>
<name>Spigot</name>
<url>http://www.spigotmc.org</url>
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index e5c947f..9cd9be6 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -145,6 +145,7 @@ public class EntityTrackerEntry {
int k1 = j - this.yLoc;
int l1 = k - this.zLoc;
Object object = null;
+ Object object2 = null;
boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4 || this.m % 60 == 0;
boolean flag1 = Math.abs(l - this.yRot) >= 4 || Math.abs(i1 - this.xRot) >= 4;
@@ -163,10 +164,12 @@ public class EntityTrackerEntry {
if (this.m > 0 || this.tracker instanceof EntityArrow) {
if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.v <= 400 && !this.x && this.y == this.tracker.onGround) {
+ object2 = new PacketPlayOutEntityTeleport(this.tracker.getId(), i, j, k, (byte) l, (byte) i1, this.tracker.onGround);
if ((!flag || !flag1) && !(this.tracker instanceof EntityArrow)) {
if (flag) {
object = new PacketPlayOutEntity.PacketPlayOutRelEntityMove(this.tracker.getId(), (byte) j1, (byte) k1, (byte) l1, this.tracker.onGround);
} else if (flag1) {
+ object2 = null;
object = new PacketPlayOutEntity.PacketPlayOutEntityLook(this.tracker.getId(), (byte) l, (byte) i1, this.tracker.onGround);
}
} else {
@@ -200,7 +203,15 @@ public class EntityTrackerEntry {
}
if (object != null) {
- this.broadcast((Packet) object);
+
+ Iterator iterator = this.trackedPlayers.iterator();
+
+ while (iterator.hasNext()) {
+ EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ Packet packetToSend = object2 == null || entityplayer.playerConnection.networkManager.getVersion() == 47 ? (Packet) object : (Packet) object2;
+
+ entityplayer.playerConnection.sendPacket(packetToSend);
+ }
}
this.b();
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 9d27032..21dbf3b 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -25,7 +25,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
int version = packethandshakinginsetprotocol.b();
//System.out.print(version);
- boolean supported = version == 47 || version == 104;
+ boolean supported = version == 47 || version >= 104;
if (supported)
{
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
index c3a067e..8436897 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
@@ -5,9 +5,9 @@ import java.io.IOException;
public class PacketPlayOutEntity implements Packet<PacketListenerPlayOut> {
public int a;
- public short b;
- public short c;
- public short d;
+ public byte b;
+ public byte c;
+ public byte d;
public byte e;
public byte f;
public boolean g;
@@ -89,9 +89,9 @@ public class PacketPlayOutEntity implements Packet<PacketListenerPlayOut> {
super.b(packetdataserializer);
if (packetdataserializer.version != 47)
{
- packetdataserializer.writeShort(this.b);
- packetdataserializer.writeShort(this.c);
- packetdataserializer.writeShort(this.d);
+ packetdataserializer.writeShort((short) this.b);
+ packetdataserializer.writeShort((short) this.c);
+ packetdataserializer.writeShort((short) this.d);
}
else
{
@@ -134,9 +134,9 @@ public class PacketPlayOutEntity implements Packet<PacketListenerPlayOut> {
super.b(packetdataserializer);
if (packetdataserializer.version != 47)
{
- packetdataserializer.writeShort(this.b);
- packetdataserializer.writeShort(this.c);
- packetdataserializer.writeShort(this.d);
+ packetdataserializer.writeShort((short) this.b);
+ packetdataserializer.writeShort((short) this.c);
+ packetdataserializer.writeShort((short) this.d);
}
else
{
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java b/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java
index b72b7d7..bcfdab9 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutNamedSoundEffect.java
@@ -279,7 +279,8 @@ public class PacketPlayOutNamedSoundEffect
toPlay = sounds.get(toPlay);
packetdataserializer.a(toPlay);
- packetdataserializer.b(0);
+ if (packetdataserializer.version > 47)
+ packetdataserializer.b(0);
packetdataserializer.writeInt(b);
packetdataserializer.writeInt(c);
packetdataserializer.writeInt(d);
--
1.9.5.msysgit.0

View File

@ -0,0 +1,60 @@
From 48550b9915d18d2d4a528c4028c8fa35a97a036c Mon Sep 17 00:00:00 2001
From: git <libraryaddict115@yahoo.co.nz>
Date: Tue, 1 Mar 2016 09:29:32 +1300
Subject: [PATCH] Update to 1.9, fix blocking
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 2f52ea2..c2ce92f 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1745,6 +1745,14 @@ public abstract class Entity implements ICommandListener {
}
public void f(boolean flag) {
+ if (this instanceof EntityPlayer)
+ {
+ EntityPlayer player = (EntityPlayer) this;
+
+ if (player.playerConnection.networkManager.getVersion() != 47 && player.bS() && player.getHeldItem().getItem().e(player.getHeldItem()) == EnumAnimation.BLOCK)
+ return;
+ }
+
this.b(4, flag);
}
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 743df69..998ea69 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -124,8 +124,13 @@ public abstract class EntityHuman extends EntityLiving {
}
+ public ItemStack getHeldItem()
+ {
+ return this.g;
+ }
+
public boolean isBlocking() {
- return this.bS() && this.g.getItem().e(this.g) == EnumAnimation.BLOCK;
+ return ((EntityPlayer) this).playerConnection.networkManager.getVersion() == 47 && this.bS() && this.g.getItem().e(this.g) == EnumAnimation.BLOCK;
}
public void t_() {
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 21dbf3b..0d8aff4 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -25,7 +25,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
int version = packethandshakinginsetprotocol.b();
//System.out.print(version);
- boolean supported = version == 47 || version >= 104;
+ boolean supported = version == 47 || version == 107;
if (supported)
{
--
1.9.5.msysgit.0

View File

@ -54,12 +54,12 @@ public class MotdManager implements Listener, Runnable
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f"; // String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
String motdLine = " §f❄ §2§lMerry Christmas §f❄ §2§lElf Presents §f❄"; String motdLine = " §f> §4§lCLANS BETA §f- §c§lOpen to Everyone §f<";
// String motdLine = " §f❄ §2§lServer Maintenance §f❄ §2§lBe Back Soon §f❄"; // String motdLine = " §f❄ §2§lServer Maintenance §f❄ §2§lBe Back Soon §f❄";
//String motdLine = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §d§lRank Sale §a§l40% Off");
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine); updateMainMotd(" §f§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§f§m §r", motdLine);
System.out.println("Updated Bungee MOTD"); System.out.println("Updated Bungee MOTD");
} }
} }

View File

@ -39,7 +39,7 @@ public class PlayerCache
catch (Exception exception) catch (Exception exception)
{ {
System.out.println("Error adding player info in PlayerCache : " + exception.getMessage()); System.out.println("Error adding player info in PlayerCache : " + exception.getMessage());
// exception.printStackTrace(); exception.printStackTrace();
} }
} }
@ -47,15 +47,7 @@ public class PlayerCache
{ {
try try
{ {
System.out.println("Getting PlayerCache for " + uuid.toString());
PlayerInfo playerInfo = _repository.getElement(uuid.toString()); PlayerInfo playerInfo = _repository.getElement(uuid.toString());
System.out.println("Got playerINfo: " + playerInfo);
if (playerInfo != null)
{
System.out.println("account id: " + playerInfo.getAccountId());
System.out.println("name: " + playerInfo.getName());
}
return playerInfo; return playerInfo;
} }
catch (Exception exception) catch (Exception exception)
@ -67,6 +59,17 @@ public class PlayerCache
return null; return null;
} }
/**
* Attempts to grab a player's account ID from the cache
* @param uuid Minecraft Account UUID
* @return The account id of the player, or -1 if the player is not in the cache
*/
public int getAccountId(UUID uuid)
{
PlayerInfo info = getPlayer(uuid);
return info == null ? -1 : info.getAccountId();
}
public void clean() public void clean()
{ {
_repository.clean(); _repository.clean();

View File

@ -0,0 +1,35 @@
package mineplex.core.common;
import java.util.HashMap;
import java.util.function.Function;
public class DefaultHashMap<K, V>
{
private HashMap<K, V> _map;
private Function<K, V> _defaultPopulator;
public DefaultHashMap(Function<K, V> defaultPopulator)
{
_map = new HashMap<K, V>();
_defaultPopulator = defaultPopulator;
}
public V get(K key)
{
_map.putIfAbsent(key, _defaultPopulator.apply(key));
return _map.get(key);
}
public void put(K key, V value)
{
_map.put(key, value);
}
public void remove(K key)
{
_map.remove(key);
}
}

View File

@ -0,0 +1,80 @@
package mineplex.core.common;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
public class GsonLocation
{
private String _world;
private double _posX;
private double _posY;
private double _posZ;
private float _yaw;
private float _pitch;
public GsonLocation(Location location)
{
_world = location.getWorld().getName();
_posX = location.getX();
_posY = location.getY();
_posZ = location.getZ();
_yaw = location.getYaw();
_pitch = location.getPitch();
}
public GsonLocation(String world, double x, double y, double z)
{
this(Bukkit.getWorld(world), x, y, z, .0f, .0f);
}
public GsonLocation(String world, double x, double y, double z, float yaw, float pitch)
{
this(Bukkit.getWorld(world), x, y, z, yaw, pitch);
}
public GsonLocation(World world, double x, double y, double z, float yaw, float pitch)
{
_world = world.getName();
_posX = x;
_posY = y;
_posZ = z;
_yaw = yaw;
_pitch = pitch;
}
public GsonLocation(double x, double y, double z)
{
this(x, y, z, .0f, .0f);
}
public GsonLocation(double x, double y, double z, float yaw, float pitch)
{
this("world", x, y, z, yaw, pitch);
}
public Location bukkit()
{
return new Location(Bukkit.getWorld(_world), _posX, _posY, _posZ);
}
public String getWorld()
{
return _world;
}
public double getX()
{
return _posX;
}
public double getY()
{
return _posY;
}
public double getZ()
{
return _posZ;
}
}

View File

@ -0,0 +1,46 @@
package mineplex.core.common;
import org.bukkit.Material;
public class MaterialData
{
private final Material _material;
private final byte _data;
private MaterialData(Material material, byte data)
{
_material = material;
_data = data;
}
public static MaterialData of(Material material)
{
return new MaterialData(material, (byte) 0);
}
public static MaterialData of(Material material, byte data)
{
return new MaterialData(material, data);
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MaterialData that = (MaterialData) o;
if (_data != that._data) return false;
return _material == that._material;
}
@Override
public int hashCode()
{
int result = _material.hashCode();
result = 31 * result + (int) _data;
return result;
}
}

View File

@ -0,0 +1,8 @@
package mineplex.core.common;
public enum MinecraftVersion
{
ALL,
Version1_9,
Version1_8
}

View File

@ -0,0 +1,83 @@
package mineplex.core.common.block;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
public class DataLocationMap
{
private EnumMap<DyeColor, List<Location>> _goldDataMap;
private EnumMap<DyeColor, List<Location>> _ironDataMap;
private EnumMap<DyeColor, List<Location>> _spongeDataMap;
public DataLocationMap()
{
_goldDataMap = new EnumMap<>(DyeColor.class);
_ironDataMap = new EnumMap<>(DyeColor.class);
_spongeDataMap = new EnumMap<>(DyeColor.class);
}
public List<Location> getGoldLocations(DyeColor color)
{
List<Location> list = _goldDataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
public void addGoldLocation(DyeColor color, Location location)
{
if (_goldDataMap.containsKey(color))
{
_goldDataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_goldDataMap.put(color, list);
}
}
public List<Location> getIronLocations(DyeColor color)
{
List<Location> list = _ironDataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
public void addIronLocation(DyeColor color, Location location)
{
if (_ironDataMap.containsKey(color))
{
_ironDataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_ironDataMap.put(color, list);
}
}
public void addSpongeLocation(DyeColor color, Location location) {
if (_spongeDataMap.containsKey(color))
{
_spongeDataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_spongeDataMap.put(color, list);
}
}
public List<Location> getSpongeLocations(DyeColor color)
{
List<Location> list = _spongeDataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
}

View File

@ -1,8 +1,11 @@
package mineplex.core.common.block.schematic; package mineplex.core.common.block.schematic;
import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.util.UtilBlock;
public class Schematic public class Schematic
{ {
@ -21,8 +24,10 @@ public class Schematic
_blockData = blockData; _blockData = blockData;
} }
public void paste(Location originLocation) public DataLocationMap paste(Location originLocation, boolean ignoreAir)
{ {
DataLocationMap locationMap = new DataLocationMap();
int startX = originLocation.getBlockX(); int startX = originLocation.getBlockX();
int startY = originLocation.getBlockY(); int startY = originLocation.getBlockY();
int startZ = originLocation.getBlockZ(); int startZ = originLocation.getBlockZ();
@ -34,21 +39,107 @@ public class Schematic
for (int z = 0; z < _length; z++) for (int z = 0; z < _length; z++)
{ {
int index = getIndex(x, y, z); int index = getIndex(x, y, z);
Block block = originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z);
// some blocks were giving me negative id's in the schematic (like stairs) // some blocks were giving me negative id's in the schematic (like stairs)
// not sure why but the math.abs is my simple fix // not sure why but the math.abs is my simple fix
int materialId = Math.abs(_blocks[index]); int materialId = Math.abs(_blocks[index]);
Material material = Material.getMaterial(materialId); if (ignoreAir && materialId == 0) // Air
if (material == null)
{ {
System.out.println(materialId + " data: " + _blockData[index]);
continue; continue;
} }
block.setTypeIdAndData(materialId, _blockData[index], false); else if (materialId == 147) // Gold Plate
{
// Check for data wool at location below the gold plate
if (addDataWool(locationMap, true, originLocation, x, y - 1, z))
continue;
}
else if (materialId == 148) // Iron Plate
{
// Check for data wool at location below the gold plate
if (addDataWool(locationMap, false, originLocation, x, y - 1, z))
continue;
}
else if (materialId == Material.SPONGE.getId())
{
if (addSpongeLocation(locationMap, originLocation, x, y + 1, z))
continue;
}
else if (materialId == 35)
{
// Check if this is a dataloc so we can skip setting the block
int aboveIndex = getIndex(x, y + 1, z);
if (hasIndex(aboveIndex))
{
if (Math.abs(_blocks[aboveIndex]) == Material.GOLD_PLATE.getId() || Math.abs(_blocks[aboveIndex]) == Material.IRON_PLATE.getId())
continue;
}
int belowIndex = getIndex(x, y - 1, z);
if (hasIndex(belowIndex))
{
if(Math.abs(_blocks[belowIndex]) == Material.SPONGE.getId())
continue;
}
}
UtilBlock.setQuick(originLocation.getWorld(), startX + x, startY + y, startZ + z, materialId, _blockData[index]);
} }
} }
} }
return locationMap;
}
/**
* Checks the schematic location for x, y, z and adds the a Location to the DataLocationMap if it is a wool block
*
* @return true if a location was added to the DataLocationMap
*/
private boolean addDataWool(DataLocationMap map, boolean gold, Location origin, int x, int y, int z)
{
int index = getIndex(x, y, z);
if (hasIndex(index))
{
int materialId = Math.abs(_blocks[index]);
if (materialId == 35) // WOOL
{
byte data = _blockData[index];
DyeColor color = DyeColor.getByWoolData(data);
if (color != null)
{
if (gold)
{
map.addGoldLocation(color, origin.clone().add(x, y, z));
}
else
{
map.addIronLocation(color, origin.clone().add(x, y, z));
}
return true;
}
}
}
return false;
}
private boolean addSpongeLocation(DataLocationMap map, Location origin, int x, int y, int z)
{
int index = getIndex(x, y, z);
if (hasIndex(index))
{
int materialId = Math.abs(_blocks[index]);
if (materialId == 35) // WOOL
{
byte data = _blockData[index];
DyeColor color = DyeColor.getByWoolData(data);
if (color != null)
{
map.addSpongeLocation(color, origin.clone().add(x, y - 1, z));
return true;
}
}
}
return false;
} }
public int getSize() public int getSize()
@ -61,6 +152,11 @@ public class Schematic
return y * _width * _length + z * _width + x; return y * _width * _length + z * _width + x;
} }
public boolean hasIndex(int index)
{
return index < _blocks.length;
}
public short getBlock(int x, int y, int z) public short getBlock(int x, int y, int z)
{ {
return _blocks[getIndex(x, y, z)]; return _blocks[getIndex(x, y, z)];
@ -99,6 +195,6 @@ public class Schematic
@Override @Override
public String toString() public String toString()
{ {
return String.format("width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d", _width, _length, _height, _blocks.length, _blockData.length); return String.format("Schematic [width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d]", _width, _length, _height, _blocks.length, _blockData.length);
} }
} }

View File

@ -0,0 +1,52 @@
package mineplex.core.common.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerRecieveBroadcastEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private String _message;
private boolean _cancelled;
public PlayerRecieveBroadcastEvent(Player player, String message)
{
_player = player;
_message = message;
}
public Player getPlayer()
{
return _player;
}
public boolean isCancelled()
{
return _cancelled;
}
public String getMessage()
{
return _message;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,7 @@
package mineplex.core.common.function;
@FunctionalInterface
public interface Result<T>
{
public void Get(T result);
}

View File

@ -0,0 +1,15 @@
package mineplex.core.common.generator;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
public class VoidGenerator extends ChunkGenerator
{
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
{
return createChunkData(world);
}
}

View File

@ -19,7 +19,6 @@ import net.minecraft.server.v1_8_R3.NBTTagString;
public class SkinData public class SkinData
{ {
private static long _nameCount = -99999999999999L; private static long _nameCount = -99999999999999L;
public final static SkinData MOOSHROOM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NDk4NzI0OTU0MTcsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxOWJlYTU0Y2FkN2Q1OGFiNWRhNDA2YjBhOTJhYjNhODI0MjI1MjY2Nzc3ZTUzNGI3ZGI2YzM3MmRkZmY3ZiJ9fX0=","UoSif81+UyvkcaanU8KAMYBpw9mefAmWehE2liDUFvk+y0X/9NovsxTYVpIDCltTSpLW3sNgamvbj4Ybs+s6DbudPiEkvh0ER7Bv2v29UJw7RzIdr6/1g548X12zcnh5iPGz/P75uNRnSfTFQx0ed8P/GNkPIjWpDuJFxEj6KcPzrCAGMx+BVw1VwryBIYf9cCDHky8z0bxR89rjiIvPTBFI6MRhqI3vgpEBTySHDS+Ki0Hwl5oa3PwS6+jgYx/4RSfFsb+BawcvDk2Xpkt5UimvqZ5BceYLIfCt4KbShYipgLXLfYUZrntjPemd3SxthjxUuA07i44UxRdiC8uqy1twLT/HUS28gpk68lA/id9tKFwu1CUzshgcmvQPt3ghtNViNziR/2t7D/+5D31Vzmhf6n7Pnpdirt/5frMi2BKMMs7pLa0EF8CrrDU7QCwPav+EZVGFvVZbxSkCDq+n3IQ3PUWSCzy6KPxpdOlUjD0pAfLoiNj0P8u4+puQtID76r/St8ExchYl2dodUImu1ZETWeFUClF3ZGat62evx8uRQEI2W4dsVwj40VUfjaAuvyDzuouaKTrCzJXLQZZjR1B8URvuK61fGX0nhW607mEi6DE+nxP2ZoBrROEX4e37Ap6+TQn9Q8tKDPdcxtwSOpPO4Qkncjn/mGtP9lZU/DQ="); public final static SkinData MOOSHROOM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NDk4NzI0OTU0MTcsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxOWJlYTU0Y2FkN2Q1OGFiNWRhNDA2YjBhOTJhYjNhODI0MjI1MjY2Nzc3ZTUzNGI3ZGI2YzM3MmRkZmY3ZiJ9fX0=","UoSif81+UyvkcaanU8KAMYBpw9mefAmWehE2liDUFvk+y0X/9NovsxTYVpIDCltTSpLW3sNgamvbj4Ybs+s6DbudPiEkvh0ER7Bv2v29UJw7RzIdr6/1g548X12zcnh5iPGz/P75uNRnSfTFQx0ed8P/GNkPIjWpDuJFxEj6KcPzrCAGMx+BVw1VwryBIYf9cCDHky8z0bxR89rjiIvPTBFI6MRhqI3vgpEBTySHDS+Ki0Hwl5oa3PwS6+jgYx/4RSfFsb+BawcvDk2Xpkt5UimvqZ5BceYLIfCt4KbShYipgLXLfYUZrntjPemd3SxthjxUuA07i44UxRdiC8uqy1twLT/HUS28gpk68lA/id9tKFwu1CUzshgcmvQPt3ghtNViNziR/2t7D/+5D31Vzmhf6n7Pnpdirt/5frMi2BKMMs7pLa0EF8CrrDU7QCwPav+EZVGFvVZbxSkCDq+n3IQ3PUWSCzy6KPxpdOlUjD0pAfLoiNj0P8u4+puQtID76r/St8ExchYl2dodUImu1ZETWeFUClF3ZGat62evx8uRQEI2W4dsVwj40VUfjaAuvyDzuouaKTrCzJXLQZZjR1B8URvuK61fGX0nhW607mEi6DE+nxP2ZoBrROEX4e37Ap6+TQn9Q8tKDPdcxtwSOpPO4Qkncjn/mGtP9lZU/DQ=");
@ -33,6 +32,9 @@ public class SkinData
public final static SkinData LOVESTRUCK = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAyNDMyNjUsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMTY5YWQwZTUyYjM1N2NiZGYxZDU0NGVkNGNmOWJmOTI4YmI0ZWNlMDhlY2YyY2M0YmYyYTlmMjJhODI4MmQifX19", "LL4RiSKQoTZamRQ4QG6izpvhgFu5gAqW4eZxcWAihk7GkhyxifpJpBTOzKrj5hH9fCUfYkkijVWUYTEcVSVRWhocp2HXW59TbKfxOeMvHU5vTMwgpwm6PnUfwuTsRPSLC7WMnEreI3cjOxPVmXbTniOSd+o8j4oOIgwFS+VLPiYLh5Jl16i5I/9ekafl3/x41NISKWl62geqO2jPWehlk+r3soiRJsxaKw20T61GSNLu19iA96Rz2T2tUHB4opm8hbLgoiNL2g1affTjq3cZPLHH4JWF3vPhqLB5uw6xb55vFLM/PP0YiEMIi7YZOfRGeaPp7uXbXgHeew+7PG9UDVMfqbwANQY4ndECijZoei54+xX3MDXkMhQsc5S+FLnGH6e4d008v81eEOyzJUPkKbGxLCBgTUb1s4IHwomCr30twPlo1IuFBOY1qeVvZUfAfPJsREuj5q/oCAoYFgupmb3ClWECnwwaH/T4wdHjfSBHoZQdLzcgDOAl0b5EXxWmYBECqk/WA4TrYIDVGdwkqjI0RkPLUoxTj6135KO+F7P7PwhU9WBGeW8hHq918DBL0fjQVHjrzvolTqwmw6nySSePnPOxFX/iwtHWzpBa9V6kUNNN+V7OGTgRr0H/yUxB+oq1F8UBqyqT4YpqxXCSD36derF/Xt5IdpTbEbGBpm0="); public final static SkinData LOVESTRUCK = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAyNDMyNjUsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMTY5YWQwZTUyYjM1N2NiZGYxZDU0NGVkNGNmOWJmOTI4YmI0ZWNlMDhlY2YyY2M0YmYyYTlmMjJhODI4MmQifX19", "LL4RiSKQoTZamRQ4QG6izpvhgFu5gAqW4eZxcWAihk7GkhyxifpJpBTOzKrj5hH9fCUfYkkijVWUYTEcVSVRWhocp2HXW59TbKfxOeMvHU5vTMwgpwm6PnUfwuTsRPSLC7WMnEreI3cjOxPVmXbTniOSd+o8j4oOIgwFS+VLPiYLh5Jl16i5I/9ekafl3/x41NISKWl62geqO2jPWehlk+r3soiRJsxaKw20T61GSNLu19iA96Rz2T2tUHB4opm8hbLgoiNL2g1affTjq3cZPLHH4JWF3vPhqLB5uw6xb55vFLM/PP0YiEMIi7YZOfRGeaPp7uXbXgHeew+7PG9UDVMfqbwANQY4ndECijZoei54+xX3MDXkMhQsc5S+FLnGH6e4d008v81eEOyzJUPkKbGxLCBgTUb1s4IHwomCr30twPlo1IuFBOY1qeVvZUfAfPJsREuj5q/oCAoYFgupmb3ClWECnwwaH/T4wdHjfSBHoZQdLzcgDOAl0b5EXxWmYBECqk/WA4TrYIDVGdwkqjI0RkPLUoxTj6135KO+F7P7PwhU9WBGeW8hHq918DBL0fjQVHjrzvolTqwmw6nySSePnPOxFX/iwtHWzpBa9V6kUNNN+V7OGTgRr0H/yUxB+oq1F8UBqyqT4YpqxXCSD36derF/Xt5IdpTbEbGBpm0=");
public final static SkinData SECRET_PACKAGE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAzNzE3OTIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QyNWI5YTRjOWRhOThkZTliZmIwZDNjOWI1M2MzMjJhMjgxN2IyMTMxOTQzY2E1YWM2NTBjZThmMzEzZjdhIn19fQ==", "Wb5T0Zhp1RVt78V/i8dYrwZCNT0xZIRe3LvL0bngH498f8Jrl43KHgTi4f299zE9giVynkTogGhJ8inq/xqFCRctl7Nn9L3LVu78uQwt+fs+o+kw/Qc+lggFSjEIc+fc13AZndpec0Df46Kh/OGD7NXbtbLb6TE/0dU2RwQlvZrZ/QHYJb8OJ6aUcnHvAZim8NUtG/nlZtSClepHVSuKdNnfzoF9rFVFA/x4jTr6mZYPZ33YgQd2oTAPk+qE3iN+0InjZQNs2YLoKFmFrgzn+tGvNApC0siF0HEZGQCFIwJOtnBsasGoxujIrln/ZdOil+5ac4VWInXr8lKgY0Q3Ocy8/0cJl+E/XqB+ztG29zhB8B1zdHBfJr+MgeSIqBCPx4SCtY6r7gnMlQYG+uVx5NP3S5aJW/cEfDyXmpCykIcBPzeErnKC0SiAqXkCVNjWJpX6qRWvWMXqS69w6ht6qHvEY2GxlZUb5AP+JgFlsl3hJDms6EPvM4zNL0Ko4oWIBzwYRQXiemrP9TGgyo0aL1RcQ0JgBFO2hSo37PK0YL3tUPgteJXzm21wu0TiZLkLCWSgMUfYfvVnhTa+xzod0xvfujpN6Y1DUTdcf8WS8TRYw2JigSkWrRW0fXPBCtTtQN5jiwM5/HrTpNLzg03J6SpfZ+rr8Rhq0S/8beQOMas="); public final static SkinData SECRET_PACKAGE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAzNzE3OTIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QyNWI5YTRjOWRhOThkZTliZmIwZDNjOWI1M2MzMjJhMjgxN2IyMTMxOTQzY2E1YWM2NTBjZThmMzEzZjdhIn19fQ==", "Wb5T0Zhp1RVt78V/i8dYrwZCNT0xZIRe3LvL0bngH498f8Jrl43KHgTi4f299zE9giVynkTogGhJ8inq/xqFCRctl7Nn9L3LVu78uQwt+fs+o+kw/Qc+lggFSjEIc+fc13AZndpec0Df46Kh/OGD7NXbtbLb6TE/0dU2RwQlvZrZ/QHYJb8OJ6aUcnHvAZim8NUtG/nlZtSClepHVSuKdNnfzoF9rFVFA/x4jTr6mZYPZ33YgQd2oTAPk+qE3iN+0InjZQNs2YLoKFmFrgzn+tGvNApC0siF0HEZGQCFIwJOtnBsasGoxujIrln/ZdOil+5ac4VWInXr8lKgY0Q3Ocy8/0cJl+E/XqB+ztG29zhB8B1zdHBfJr+MgeSIqBCPx4SCtY6r7gnMlQYG+uVx5NP3S5aJW/cEfDyXmpCykIcBPzeErnKC0SiAqXkCVNjWJpX6qRWvWMXqS69w6ht6qHvEY2GxlZUb5AP+JgFlsl3hJDms6EPvM4zNL0Ko4oWIBzwYRQXiemrP9TGgyo0aL1RcQ0JgBFO2hSo37PK0YL3tUPgteJXzm21wu0TiZLkLCWSgMUfYfvVnhTa+xzod0xvfujpN6Y1DUTdcf8WS8TRYw2JigSkWrRW0fXPBCtTtQN5jiwM5/HrTpNLzg03J6SpfZ+rr8Rhq0S/8beQOMas=");
public final static SkinData CHISS = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI5NjgyNDEsInByb2ZpbGVJZCI6IjFkMmJmZTYxN2ViZDQ0NWRiYTdkODM1NGEwZmZkMWVhIiwicHJvZmlsZU5hbWUiOiJDaGlzcyIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTg3MmNkMzRjY2IzMTIxYjRjNmEzOGFjM2JmOGVkM2UwMzk3YmQ2YTg4NDI4YjdhZmM2ZTUyNTI4NTVhMzQzIiwibWV0YWRhdGEiOnsibW9kZWwiOiJzbGltIn19fX0=", "hNTLRA2acZYx2dM90lnJN8FMK/ceD3+AxKNdD5FrXzxGtYL4C1Jr/vbTE0UosmwFP3wScNEW/fuDOjeZRjZHMJdvgDZMlMK/5KDhOY6sj/RS9RckztsgummSyjH/hdDn7TWWfhZLMbiia/K0VReI9eq2yD6zGQpvMlz5hB/5SX5YHWXvCah3TL4UzYSlSVDlwY/Q3sVuIZUr8m/LIXJwniJKLGo6tUgtiJd9eseOsbBpVjzCUtLD8A9WBe2/eODgmLfqEvXESIoDRG8vL2nPSXWma/YolYHIl32/i+ZxVD7dRRaXQFYSiLI24EtzX1pPhMjyaTLazP9abH43J6J31w02pKM7N/xTa62020L/YfRRKGT5lygEDb1NMoSpAjszPxah+Ra2/L+yUWEI8cMES6I4mIJ00tclPjWK01xhIn3tqg+y2gqsGHwPhu/7vmF5NirNfKFw0qciKNBfbCAF7ae+mkUKjmAPuvBUBqQb7BOcpNVWsCo/XvzmiZZYsf5P4Uwz8LqUK4uH6V/5dg7lY2Xg3+IUylsrDqLGFDI8iy/NdjIQMbuRadh4IDO6DcmxBri2Ax4JNBPBTnRezge8uq37MZcft/IXQgFWKB9RtidVEACaTOkRj27k+Ojnkki+j44k0wZB47hiXFUHMCHl3a0SVdQe15ZbVsQj/HAvAS0=");
public final static SkinData DEFEK7 = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI3ODkwNTksInByb2ZpbGVJZCI6Ijg5ZDQ2M2Y3MjNlYzQ3MGE4MjQ0NDU3ZjBjOGQ4NjFjIiwicHJvZmlsZU5hbWUiOiJkZWZlazciLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2JmYWNjOWM4ZjhlY2E1OWU0NTE4MTUxZmE4OGFiMDZjOTFmNjM3OTE2NzJmMTRlNGYzODY3YTI2OTVlN2NmYmYifSwiQ0FQRSI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIyYjljNWVhNzYzYzg2ZmM1Y2FlYTMzZDgyYjBmYTY1YTdjMjI4ZmQzMjFiYTU0NzY2ZWE5NWEzZDBiOTc5MyJ9fX0=", "jBoRvkhQXz+nap8yJJIZ+4HClMItWODumeSOYjXytP3WWKHK0UMq0xC/keXsnmvo89lMRdRbknPt2ZX5Flgyjgr4Rt0KtDvpL/hG4BUsTWryUZZMKxdd6DkZXYRtTogLUfHeDYIz+cZQ0aXGMtvX/ZYTXJfMi6FYbIHY/qEEDnWhDX5y+SPpaJaZByPsvzi+qbfcFGnJ6nqi9ccyZYnYpnI2IVBM/yO/VRXWHxfqvJ0VVvv5KsGmVbko2Jxo0SDCxUL2UTH2+eol53FxhkkC+m2geC14k1zsZQLHDF3BgAG9+kFJ4UEoYRKF2Gy1FxeDCJtjYNdrYR8fdaUKRMcpBgEs+ZGe2U9EVVS/ZcBCjB7S+1Ne2bPzPFzTQPuBoMgggo1xbxBmQ5NyhYo4gwgj/xjSLIhb+5h7ioN1URfSRcfYdVv6RRO9l/u9l09jEom8y/jGRviefpEr+/e9iAl5Dd/6nzQgosBQja3NSfqYZmyuet2eI9zu61CObDTpR6yaCbNgBe/lWofRfULdpJpgjb4UNTBom3q82FcCiOe02OekGPw4+YlilhICBhajF5JzN8FKAdqI1osDcX3KuJgikYIW3voNaOP5YN3GXgilJNdou20KFC8ICq68HglgX7/0rLrWKIEoswnINIM6HcJbQuXncVPwQhV6K34Hlt/Na60=");
private Property _skinProperty; private Property _skinProperty;
public SkinData(String value, String signature) public SkinData(String value, String signature)

View File

@ -75,6 +75,8 @@ public class C
public static String chatAdminHead = "" + ChatColor.DARK_PURPLE; public static String chatAdminHead = "" + ChatColor.DARK_PURPLE;
public static String chatAdminBody = "" + ChatColor.LIGHT_PURPLE; public static String chatAdminBody = "" + ChatColor.LIGHT_PURPLE;
public static String cClansNether = "" + ChatColor.RED;
public static String listTitle = "" + ChatColor.WHITE; public static String listTitle = "" + ChatColor.WHITE;
public static String listValue = "" + ChatColor.YELLOW; public static String listValue = "" + ChatColor.YELLOW;
public static String listValueOn = "" + ChatColor.GREEN; public static String listValueOn = "" + ChatColor.GREEN;

View File

@ -0,0 +1,31 @@
package mineplex.core.common.util;
public class EnclosedObject<T>
{
private T _value;
public EnclosedObject()
{
this((T) null);
}
public EnclosedObject(T t)
{
_value = t;
}
public T Get()
{
return _value;
}
public T Set(T value)
{
return _value = value;
}
public String toString()
{
return _value.toString();
}
}

View File

@ -215,4 +215,9 @@ public class F
? "an" : "a"; ? "an" : "a";
} }
public static String clansNether(String word)
{
return C.cClansNether + word + C.mBody;
}
} }

View File

@ -0,0 +1,27 @@
package mineplex.core.common.util;
import java.util.HashMap;
import java.util.Map;
public class MapBuilder<K, V>
{
private Map<K, V> _map;
public MapBuilder()
{
_map = new HashMap<>();
}
public MapBuilder<K, V> Put(K key, V value)
{
_map.put(key, value);
return this;
}
public Map<K, V> GetMap()
{
return _map;
}
}

View File

@ -5,11 +5,22 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
public class NautArrayList<Elem> public class NautArrayList<Elem> implements Iterable<Elem>
{ {
private ArrayList<Elem> _wrappedArrayList = new ArrayList<Elem>(); private ArrayList<Elem> _wrappedArrayList = new ArrayList<Elem>();
public NautArrayList()
{
}
public NautArrayList(Elem[] elements)
{
UtilCollections.addAll(elements, _wrappedArrayList);
}
public boolean add(Elem elem) public boolean add(Elem elem)
{ {
return _wrappedArrayList.add(elem); return _wrappedArrayList.add(elem);
@ -129,4 +140,19 @@ public class NautArrayList<Elem>
{ {
return _wrappedArrayList.toArray(); return _wrappedArrayList.toArray();
} }
public void forEach(Consumer<? super Elem> consumer)
{
_wrappedArrayList.forEach(consumer);
}
public Stream<Elem> stream()
{
return _wrappedArrayList.stream();
}
public List<Elem> getWrapped()
{
return _wrappedArrayList;
}
} }

View File

@ -3,12 +3,26 @@ package mineplex.core.common.util;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.commons.lang3.Validate;
import java.util.Set; import java.util.Set;
public class NautHashMap<KeyType, ValueType> public class NautHashMap<KeyType, ValueType>
{ {
private HashMap<KeyType, ValueType> _wrappedHashMap = new HashMap<KeyType, ValueType>(); private HashMap<KeyType, ValueType> _wrappedHashMap = new HashMap<KeyType, ValueType>();
public NautHashMap()
{
}
public NautHashMap(KeyType[] keys, ValueType[] values)
{
Validate.isTrue(keys.length == values.length, "Keys array and values array must be the same size when making a Map");
UtilCollections.loop(0, keys.length, i -> _wrappedHashMap.put(keys[i.intValue()], values[i.intValue()]));
}
public boolean containsKey(KeyType key) public boolean containsKey(KeyType key)
{ {
return _wrappedHashMap.containsKey(key); return _wrappedHashMap.containsKey(key);

View File

@ -1,33 +0,0 @@
package mineplex.core.common.util;
public class NonFinalInteger
{
private int _value;
public NonFinalInteger()
{
this(0);
}
public NonFinalInteger(int value)
{
_value = value;
}
public NonFinalInteger add(int value)
{
_value += value;
return this;
}
public NonFinalInteger subtract(int value)
{
_value -= value;
return this;
}
public int get()
{
return _value;
}
}

View File

@ -0,0 +1,28 @@
package mineplex.core.common.util;
public class NumberFloater
{
private double _min;
private double _max;
private double _modifyPerCall;
private double _cur;
private boolean _up;
public NumberFloater(double min, double max, double modify)
{
_min = min;
_max = max;
_modifyPerCall = modify;
}
public double pulse()
{
if (_up && (_cur = UtilMath.clamp(_cur += _modifyPerCall, _min, _max)) >= _max)
_up = false;
else if ((_cur = UtilMath.clamp(_cur -= _modifyPerCall, _min, _max)) <= _min)
_up = true;
return _cur;
}
}

View File

@ -1,42 +0,0 @@
package mineplex.core.common.util;
public class NumericalPulser
{
private double _min;
private double _max;
private double _modifyPerCall;
private double _cur;
private boolean _up;
public NumericalPulser(double min, double max, double modify)
{
_min = min;
_max = max;
_modifyPerCall = modify;
}
public double pulse()
{
if (_up)
{
_cur = UtilMath.clamp(_cur += _modifyPerCall, _min, _max);
if (_cur >= _max)
{
_up = false;
}
}
else
{
_cur = UtilMath.clamp(_cur -= _modifyPerCall, _min, _max);
if (_cur <= _min)
{
_up = true;
}
}
return _cur;
}
}

View File

@ -88,7 +88,7 @@ public class ProfileLoader
} }
catch (Exception e) catch (Exception e)
{ {
; // Failed to load skin e.printStackTrace();
} }
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import org.bukkit.util.Vector;
public class RGBData public class RGBData
{ {
private double _red; private double _red;
@ -50,4 +52,19 @@ public class RGBData
+ "green=" + (int) (_green * 255) + ", " + "green=" + (int) (_green * 255) + ", "
+ "blue=" + (int) (_blue * 255) + "]"; + "blue=" + (int) (_blue * 255) + "]";
} }
public Vector ToVector()
{
return new Vector(Math.max(0.001, _red), _green, _blue);
}
public RGBData Darken()
{
return new RGBData(getFullRed() - 25, getFullGreen() - 25, getFullBlue() - 25);
}
public RGBData Lighten()
{
return new RGBData(getFullRed() + 25, getFullGreen() + 25, getFullBlue() + 25);
}
} }

View File

@ -0,0 +1,31 @@
package mineplex.core.common.util;
import com.google.common.base.Optional;
import net.minecraft.server.v1_8_R3.EntityTameableAnimal;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftTameableAnimal;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Tameable;
public class SpigotUtil
{
// Explanation:
// - Tameable animals (wolves, ocelots) keep track of their most
// recent owner.
// - When an animal is assigned a new owner, its data watcher is
// updated with the new owner's UUID
// - During this process, the old owner's UUID is checked against
// the new one
// - If the animal didn't have a previous owner, the old owner's
// UUID is the empty string.
// - UUID.fromString() is called on the empty string, and throws
// an exception.
//
// We can mitigate this issue by manually setting a previous owner
// UUID before we call Tameable#setOwner(AnimalTamer)
//
// (note: this does not apply to horses)
public static void setOldOwner_RemoveMeWhenSpigotFixesThis(Tameable tameable, AnimalTamer tamer)
{
((CraftTameableAnimal)tameable).getHandle().getDataWatcher().watch(17, tamer.getUniqueId().toString(), EntityTameableAnimal.META_OWNER, Optional.absent());
}
}

View File

@ -2,10 +2,14 @@ package mineplex.core.common.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.stream.Stream;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -167,6 +171,34 @@ public class UtilAlg
return element; return element;
} }
public static List<Block> getBox(Block cornerA, Block cornerB)
{
if (cornerA == null || cornerB == null || (cornerA.getWorld() != cornerB.getWorld()))
return Collections.emptyList();
ArrayList<Block> list = new ArrayList<>();
int minX = Math.min(cornerA.getX(), cornerB.getX());
int minY = Math.min(cornerA.getY(), cornerB.getY());
int minZ = Math.min(cornerA.getZ(), cornerB.getZ());
int maxX = Math.max(cornerA.getX(), cornerB.getX());
int maxY = Math.max(cornerA.getY(), cornerB.getY());
int maxZ = Math.max(cornerA.getZ(), cornerB.getZ());
for (int x = minX; x <= maxX; x++)
{
for (int y = minY; y <= maxY; y++)
{
for (int z = minZ; z <= maxZ; z++)
{
list.add(cornerA.getWorld().getBlockAt(x, y, z));
}
}
}
return list;
}
public static boolean inBoundingBox(Location loc, Location cornerA, Location cornerB) public static boolean inBoundingBox(Location loc, Location cornerA, Location cornerB)
{ {
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false; if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
@ -184,6 +216,24 @@ public class UtilAlg
return true; return true;
} }
public static boolean inBoundingBox(Location loc, Vector cornerA, Vector cornerB)
{
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
if (cornerA.getY() != cornerB.getY())
{
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
}
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
return true;
}
public static Vector cross(Vector a, Vector b) public static Vector cross(Vector a, Vector b)
{ {
double x = a.getY()*b.getZ() - a.getZ()*b.getY(); double x = a.getY()*b.getZ() - a.getZ()*b.getY();
@ -218,7 +268,7 @@ public class UtilAlg
return cross(vec, getRight(vec)); return cross(vec, getRight(vec));
} }
public static Location getAverageLocation(ArrayList<Location> locs) public static Location getAverageLocation(List<Location> locs)
{ {
if (locs.isEmpty()) if (locs.isEmpty())
return null; return null;
@ -237,7 +287,26 @@ public class UtilAlg
return vec.toLocation(locs.get(0).getWorld()); return vec.toLocation(locs.get(0).getWorld());
} }
public static Vector getAverageBump(Location source, ArrayList<Location> locs) public static Location getAverageBlockLocation(List<Block> locs)
{
if (locs.isEmpty())
return null;
Vector vec = new Vector(0,0,0);
double amount = 0;
for (Block loc : locs)
{
vec.add(loc.getLocation().toVector());
amount++;
}
vec.multiply(1d/amount);
return vec.toLocation(locs.get(0).getWorld());
}
public static Vector getAverageBump(Location source, List<Location> locs)
{ {
if (locs.isEmpty()) if (locs.isEmpty())
return null; return null;
@ -550,4 +619,25 @@ public class UtilAlg
return new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ()); return new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ());
} }
public static Location moveForward(Location location, double strength, float yaw, boolean reverse)
{
double x = location.getX();
double z = location.getZ();
double rad = Math.toRadians(yaw);
x = reverse ? (x + strength * Math.sin(rad)) : (x - strength * Math.sin(rad));
z = reverse ? (z - strength * Math.cos(rad)) : (z + strength * Math.cos(rad));
return new Location(location.getWorld(), x, location.getY(), z, location.getYaw(), location.getPitch());
}
public static Location getRandomLocation(Location center, int radius)
{
Random r = new Random();
int x = r.nextInt(radius * 2) - radius;
int y = r.nextInt(radius * 2) - radius;
int z = r.nextInt(radius * 2) - radius;
return center.clone().add(x, y, z);
}
} }

View File

@ -3,6 +3,7 @@ package mineplex.core.common.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Queue;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -30,6 +31,7 @@ import org.bukkit.material.Bed;
import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.EnumDirection; import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.Item; import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftKey; import net.minecraft.server.v1_8_R3.MinecraftKey;
@ -467,7 +469,12 @@ public class UtilBlock
public static Block getHighest(World world, Location location) public static Block getHighest(World world, Location location)
{ {
return getHighest(world, location.getBlockX(), location.getBlockZ(), null); return getHighest(world, location.getBlockX(), location.getBlockZ());
}
public static Block getHighest(World world, Block block)
{
return getHighest(world, block.getLocation());
} }
public static Block getHighest(World world, int x, int z, HashSet<Material> ignore) public static Block getHighest(World world, int x, int z, HashSet<Material> ignore)
@ -1423,4 +1430,78 @@ public class UtilBlock
return itemStacks; return itemStacks;
} }
public static Location nearestFloor(Location location)
{
if (!UtilItem.isBoundless(location.getBlock().getType()))
{
return location.clone();
}
Location gr = location.clone();
while (UtilItem.isBoundless(gr.getBlock().getType()) && gr.getY() > 0)
{
gr.subtract(0, 0.5, 0);
}
return gr.getBlock().getLocation();
}
public static boolean setSilent(Block block, Material type)
{
return setSilent(block, type, (byte) 0);
}
/**
* Sets block data without causing a block update.
*/
public static boolean setSilent(Block block, Material type, byte data)
{
BlockState state = block.getState();
state.setType(type);
state.setRawData(data);
return state.update(false, false);
}
public static void setQuick(World world, int x, int y, int z, int type, byte data)
{
int cx = x >> 4;
int cz = z >> 4;
if (!world.isChunkLoaded(cx, cz))
{
world.loadChunk(cx, cz, true);
}
net.minecraft.server.v1_8_R3.Chunk chunk = ((CraftWorld) world).getHandle().getChunkAt(x >> 4, z >> 4);
BlockPosition pos = new BlockPosition(x, y, z);
IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getById(type).fromLegacyData(data);
chunk.a(pos, ibd);
}
/**
* @return true if all of the blocks within the specified radius of the specified origin block are boundless ({@link UtilItem#isBoundless}.)
*/
public static boolean boundless(Location origin, double radius)
{
for (Block block : getInRadius(origin, radius).keySet())
{
if (!UtilItem.isBoundless(block.getType()))
{
return false;
}
}
return true;
}
/**
* @return true if there are any non-boundless ({@link UtilItem#isBoundless}) blocks within the specified radius of the specified origin block.
*/
public static boolean boundless(Block origin, double radius)
{
return boundless(origin.getLocation(), radius);
}
} }

View File

@ -0,0 +1,278 @@
package mineplex.core.common.util;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import com.google.common.collect.Lists;
public class UtilCollections
{
public static Random Random = new Random();
@SafeVarargs
public static <E> NautArrayList<E> newNautList(E... elements)
{
return new NautArrayList<E>(elements);
}
public static <E> NautArrayList<E> newNautList()
{
return new NautArrayList<E>();
}
public static <K, V> NautHashMap<K, V> newNautMap(K[] keys, V[] values)
{
return new NautHashMap<K, V>(keys, values);
}
public static <K, V> NautHashMap<K, V> newNautMap()
{
return new NautHashMap<K, V>();
}
public static <T> T getLast(List<T> list)
{
return list.isEmpty() ? null : list.get(list.size() - 1);
}
public static <T> T getFirst(List<T> list)
{
return list.isEmpty() ? null : list.get(0);
}
public static <T> T getLast(NautArrayList<T> list)
{
return list.isEmpty() ? null : list.get(list.size() - 1);
}
public static <T> T getFirst(NautArrayList<T> list)
{
return list.isEmpty() ? null : list.get(0);
}
public static <E> void forEach(E[] elements, Function<E, E> filter, Consumer<E> consumer)
{
for (int i = 0; i < elements.length; i++)
{
consumer.accept(filter.apply(elements[i]));
}
}
public static <E> void forEach(E[] elements, Consumer<E> consumer)
{
for (int i = 0; i < elements.length; i++)
{
consumer.accept(elements[i]);
}
}
public static <E> void forEach(E[] elements, BiConsumer<Integer, E> consumer)
{
for (int i = 0; i < elements.length; i++)
{
consumer.accept(Integer.valueOf(i), elements[i]);
}
}
public static <E> void addAll(E[] elements, Collection<E> collection)
{
forEach(elements, collection::add);
}
public static void loop(int min, int max, Consumer<Integer> consumer)
{
for (int i = min; i < max; i++)
{
consumer.accept(Integer.valueOf(i));
}
}
public static byte[] ensureSize(byte[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static boolean[] ensureSize(boolean[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static int[] ensureSize(int[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static long[] ensureSize(long[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static short[] ensureSize(short[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static char[] ensureSize(char[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static float[] ensureSize(float[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static double[] ensureSize(double[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static <T> T[] ensureSize(T[] array, int size)
{
if (array.length <= size)
{
return array;
}
return Arrays.copyOf(array, size);
}
public static byte random(byte[] array)
{
return array[Random.nextInt(array.length)];
}
public static short random(short[] array)
{
return array[Random.nextInt(array.length)];
}
public static char random(char[] array)
{
return array[Random.nextInt(array.length)];
}
public static boolean random(boolean[] array)
{
return array[Random.nextInt(array.length)];
}
public static int random(int[] array)
{
return array[Random.nextInt(array.length)];
}
public static long random(long[] array)
{
return array[Random.nextInt(array.length)];
}
public static double random(double[] array)
{
return array[Random.nextInt(array.length)];
}
public static float random(float[] array)
{
return array[Random.nextInt(array.length)];
}
public static <T> T random(T[] array)
{
return array[Random.nextInt(array.length)];
}
public static <T> List<? extends T> toList(T[] array)
{
return Lists.newArrayList(array);
}
public static <T1, T2> boolean equal(T1[] array1, T2[] array2)
{
return Arrays.equals(array1, array2);
}
public static <X> void ForEach(List<X> list, Consumer<X> consumer)
{
Iterator<X> iterator = list.iterator();
while (iterator.hasNext())
{
consumer.accept(iterator.next());
}
}
@SafeVarargs
public static <X> List<? extends X> newList(X... elements)
{
return toList(elements);
}
public static <X> String combine(X[] data, String delimiter)
{
StringBuilder total = new StringBuilder();
int loops = 0;
for (X x : data)
{
if (delimiter != null && loops != 0)
{
total.append(delimiter);
}
total.append(x.toString());
loops++;
}
return total.toString();
}
}

View File

@ -10,6 +10,8 @@ public class UtilColor
public static final RGBData RgbRed = hexToRgb(0xee0100); public static final RGBData RgbRed = hexToRgb(0xee0100);
public static final RGBData RgbGold = hexToRgb(0xffd014); public static final RGBData RgbGold = hexToRgb(0xffd014);
public static final RGBData RgbLightBlue = hexToRgb(0x61fff7); public static final RGBData RgbLightBlue = hexToRgb(0x61fff7);
public static final RGBData RgbLightRed = hexToRgb(0xeb1c1c);
public static final RGBData RgbPurple = hexToRgb(0x9c17a3);
public static byte chatColorToClayData(ChatColor chatColor) public static byte chatColorToClayData(ChatColor chatColor)
{ {
@ -84,4 +86,9 @@ public class UtilColor
{ {
return (red << 16 | green << 8 | blue); return (red << 16 | green << 8 | blue);
} }
public static RGBData rgb(int r, int g, int b)
{
return new RGBData(r, g, b);
}
} }

View File

@ -5,24 +5,6 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.EntityBat;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.NavigationAbstract;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
import net.minecraft.server.v1_8_R3.PathfinderGoal;
import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_8_R3.PathfinderGoalMoveTowardsRestriction;
import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -40,8 +22,29 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Giant; import org.bukkit.entity.Giant;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.EntityBat;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.NavigationAbstract;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
import net.minecraft.server.v1_8_R3.PathfinderGoal;
import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_8_R3.PathfinderGoalMoveTowardsRestriction;
import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
import net.minecraft.server.v1_8_R3.WorldServer;
public class UtilEnt public class UtilEnt
{ {
@ -163,7 +166,7 @@ public class UtilEnt
if (entity instanceof CraftCreature) if (entity instanceof CraftCreature)
{ {
EntityCreature creature = ((CraftCreature)entity).getHandle(); EntityCreature creature = ((CraftCreature) entity).getHandle();
if (_bsRestrictionGoal == null) if (_bsRestrictionGoal == null)
{ {
@ -176,26 +179,26 @@ public class UtilEnt
if (((CraftEntity)entity).getHandle() instanceof EntityInsentient) if (((CraftEntity)entity).getHandle() instanceof EntityInsentient)
{ {
EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle(); EntityInsentient creature = (EntityInsentient) ((CraftEntity) entity).getHandle();
creature.setVegetated(true); creature.setVegetated(true);
creature.setSilent(mute); creature.setSilent(mute);
((List) _pathfinderBList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear(); ((List<?>) _pathfinderBList.get(((PathfinderGoalSelector) _goalSelector.get(creature)))).clear();
((List)_pathfinderCList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear(); ((List<?>) _pathfinderCList.get(((PathfinderGoalSelector) _goalSelector.get(creature)))).clear();
((List)_pathfinderBList.get(((PathfinderGoalSelector)_targetSelector.get(creature)))).clear(); ((List<?>) _pathfinderBList.get(((PathfinderGoalSelector) _targetSelector.get(creature)))).clear();
((List)_pathfinderCList.get(((PathfinderGoalSelector)_targetSelector.get(creature)))).clear(); ((List<?>) _pathfinderCList.get(((PathfinderGoalSelector) _targetSelector.get(creature)))).clear();
} }
if (((CraftEntity)entity).getHandle() instanceof EntityBat) if (((CraftEntity)entity).getHandle() instanceof EntityBat)
{ {
((EntityBat)((CraftEntity)entity).getHandle()).setVegetated(true); ((EntityBat) ((CraftEntity) entity).getHandle()).setVegetated(true);
} }
if (((CraftEntity)entity).getHandle() instanceof EntityEnderDragon) if (((CraftEntity) entity).getHandle() instanceof EntityEnderDragon)
{ {
EntityEnderDragon creature = (EntityEnderDragon)((CraftEntity)entity).getHandle(); EntityEnderDragon creature = (EntityEnderDragon) ((CraftEntity) entity).getHandle();
creature.setVegetated(true); creature.setVegetated(true);
} }
@ -255,6 +258,34 @@ public class UtilEnt
} }
} }
public static void Rotate(LivingEntity entity, float yaw, float pitch)
{
EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
while (yaw < -180.0F) yaw += 360.0F;
while (yaw >= 180.0F) yaw -= 360.0F;
handle.yaw = yaw;
handle.aK = yaw;
handle.aI = yaw;
handle.aL = yaw;
handle.pitch = pitch;
}
public static void LookAt(LivingEntity entity, Location location)
{
if (!(entity.getWorld().equals(location.getWorld())))
return;
Vector dir = entity.getEyeLocation().toVector().subtract(location.toVector()).normalize();
Location loc = entity.getEyeLocation().clone();
loc.setYaw(180 - (float) Math.toDegrees(Math.atan2(dir.getX(), dir.getZ())));
loc.setPitch(90 - (float) Math.toDegrees(Math.acos(dir.getY())));
Rotate(entity, loc.getYaw(), loc.getPitch());
}
public static void populate() public static void populate()
{ {
if (creatureMap.isEmpty()) if (creatureMap.isEmpty())
@ -442,7 +473,7 @@ public class UtilEnt
if (offset < dR) if (offset < dR)
{ {
ents.put(ent, 1 - (offset/dR)); ents.put(ent, Double.valueOf(1 - (offset/dR)));
continue; continue;
} }
@ -451,7 +482,7 @@ public class UtilEnt
if (offset < dR) if (offset < dR)
{ {
ents.put(ent, 1 - (offset/dR)); ents.put(ent, Double.valueOf(1 - (offset/dR)));
continue; continue;
} }
} }
@ -473,7 +504,7 @@ public class UtilEnt
if (offset < dR) if (offset < dR)
{ {
ents.put(cur, 1 - (offset/dR)); ents.put(cur, Double.valueOf(1 - (offset/dR)));
continue; continue;
} }
} }
@ -775,7 +806,7 @@ public class UtilEnt
field.setAccessible(true); field.setAccessible(true);
int entityId = field.getInt(null); int entityId = field.getInt(null);
if (modifynumber) { if (modifynumber) {
field.set(null, entityId+1); field.set(null, Integer.valueOf(entityId + 1));
} }
return entityId; return entityId;
} }
@ -816,8 +847,36 @@ public class UtilEnt
} }
} }
public static double getBlockSizeOfSlime(int size)
{
return .51 * ((double) size);
}
public static boolean inWater(LivingEntity ent) public static boolean inWater(LivingEntity ent)
{ {
return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9; return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9;
} }
public static void SetMetadata(Entity entity, String key, Object value)
{
entity.setMetadata(key, new FixedMetadataValue(UtilServer.getPlugin(), value));
}
// Nicer than doing entity.getMetadata(key).get(0);
public static Object GetMetadata(Entity entity, String key)
{
if (!entity.hasMetadata(key))
{
return null;
}
return entity.getMetadata(key).get(0);
}
public static void SetItemInHand(LivingEntity entity, ItemStack item)
{
EntityEquipment equipment = entity.getEquipment();
equipment.setItemInHand(item);
}
} }

View File

@ -1,5 +1,6 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
@ -46,6 +47,15 @@ public class UtilEvent
return false; return false;
} }
public static boolean isBowDamage(EntityDamageEvent event)
{
if (!(event instanceof EntityDamageByEntityEvent))
return false;
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent)event;
return e.getDamager() instanceof Arrow;
}
public static LivingEntity GetDamagerEntity(EntityDamageEvent event, boolean ranged) public static LivingEntity GetDamagerEntity(EntityDamageEvent event, boolean ranged)
{ {
if (!(event instanceof EntityDamageByEntityEvent)) if (!(event instanceof EntityDamageByEntityEvent))

View File

@ -1,310 +1,53 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
public class UtilFile public class UtilFile
{ {
public static void writePlainFile(File file, String text) throws FileNotFoundException public static String read(File file)
{
PrintWriter writer = new PrintWriter(file);
writer.print(text);
writer.close();
}
/**
* Will read the specified file, and return the contents, or a null value,
* if an exception is thrown. Will handle all exceptions, and simply ignore
* them and return null. No stack trace printed or anything.
*/
public static String readIgnoreErrors(File file)
{ {
try try
{ {
return readToStr(file); return new String(readBytes(file));
} }
catch (IOException exception) catch (IOException e)
{ {
return null; return null;
} }
} }
public static String readToStr(File file) throws IOException
{
return new String(readAllBytes(file));
}
public static byte[] readAllBytes(File file) throws IOException
{
return Files.readAllBytes(Paths.get(file.toURI()));
}
public static void writePlainFile(String file, String text) throws FileNotFoundException
{
writePlainFile(new File(file), text);
}
/** /**
* Will read the specified file, and return the contents, or a null value, * @param file
* if an exception is thrown. Will handle all exceptions, and simply ignore * @return
* them and return null. No stack trace printed or anything. * @throws IOException
*/ */
public static String readIgnoreErrors(String file) public static byte[] readBytes(File file) throws IOException
{ {
return readIgnoreErrors(new File(file)); FileInputStream stream = new FileInputStream(file);
byte[] bytes = new byte[stream.available() /* estimated bytes available */];
int pointer = 0;
while (true)
{
int read = stream.read();
if (read == -1)
{
break;
} }
public static String readToStr(String file) throws IOException bytes = UtilCollections.ensureSize(bytes, bytes.length + 1);
{
return readToStr(new File(file)); bytes[pointer] = (byte) read;
++pointer;
} }
public static byte[] readAllBytes(String file) throws IOException
{
return readAllBytes(new File(file));
}
public static void writeDataFile(File file, DataFileChunk... chunks) throws IOException
{
DataOutputStream stream = new DataOutputStream(new FileOutputStream(file));
for (DataFileChunk chunk : chunks)
{
chunk.writeTo(stream);
}
stream.close(); stream.close();
return bytes;
} }
public static DataFileReader beginReading(String file) throws FileNotFoundException
{
return beginReading(new File(file));
}
public static DataFileReader beginReading(File file) throws FileNotFoundException
{
return new DataFileReader(file);
}
public static void writeDataFile(String file, DataFileChunk... chunks) throws IOException
{
writeDataFile(new File(file), chunks);
}
public static class DataFileChunk
{
private ChunkType _type;
private Object _value;
public DataFileChunk(ChunkType type, Object value)
{
if (type == null)
{
throw new RuntimeException("ChunkType can NOT be null.");
}
_type = type;
if (!_type.isValid(value))
{
throw new RuntimeException("Invalid value provided for the specified ChunkType.");
}
_value = value;
}
public void writeTo(DataOutputStream stream) throws IOException
{
_type.writeTo(stream, _value);
}
}
public static enum ChunkType
{
STRING(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
String str = (String) value;
INTEGER.writeTo(stream, str.length());
for (char b : str.toCharArray())
{
CHAR.writeTo(stream, b);
}
}
public boolean isValid(Object value)
{
return value.getClass().equals(String.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
int length = (int) INTEGER.readFrom(stream);
StringBuilder string = new StringBuilder();
for (int i = 0; i < length; i++)
{
string.append(CHAR.readFrom(stream));
}
return string.toString();
}
}),
DOUBLE(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
double number = (double) value;
stream.writeDouble(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Double.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readDouble();
}
}),
INTEGER(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
int number = (int) value;
stream.writeInt(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Integer.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readInt();
}
}),
BYTE(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
byte number = (byte) value;
stream.writeByte(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Byte.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readByte();
}
}),
CHAR(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
char number = (char) value;
stream.writeChar(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Character.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readChar();
}
}),
LONG(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
long number = (long) value;
stream.writeLong(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Long.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readLong();
}
});
private ChunkImpl _impl;
ChunkType(ChunkImpl impl)
{
_impl = impl;
}
protected void writeTo(DataOutputStream stream, Object value) throws IOException
{
_impl.writeTo(stream, value);
}
protected boolean isValid(Object value)
{
return value != null && _impl.isValid(value);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return _impl.readFrom(stream);
}
}
public static class DataFileReader
{
private DataInputStream _stream;
public DataFileReader(File file) throws FileNotFoundException
{
_stream = new DataInputStream(new FileInputStream(file));
}
public Object readChunk(ChunkType type) throws IOException
{
return type.readFrom(_stream);
}
public void close() throws IOException
{
_stream.close();
}
}
protected interface ChunkImpl
{
void writeTo(DataOutputStream stream, Object value) throws IOException;
Object readFrom(DataInputStream stream) throws IOException;
boolean isValid(Object value);
}
} }

View File

@ -74,10 +74,10 @@ public class UtilFirework
public static void packetPlayFirework(Player player, Location loc, Type type, Color color, boolean flicker, boolean trail) public static void packetPlayFirework(Player player, Location loc, Type type, Color color, boolean flicker, boolean trail)
{ {
Firework firework = (Firework) loc.getWorld().spawn(loc, Firework.class); Firework firework = loc.getWorld().spawn(loc, Firework.class);
FireworkEffect effect = FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build(); FireworkEffect effect = FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build();
FireworkMeta data = (FireworkMeta) firework.getFireworkMeta(); FireworkMeta data = firework.getFireworkMeta();
data.clearEffects(); data.clearEffects();
data.setPower(1); data.setPower(1);
data.addEffect(effect); data.addEffect(effect);
@ -98,4 +98,14 @@ public class UtilFirework
UtilPlayer.sendPacket(viewing, packet); UtilPlayer.sendPacket(viewing, packet);
} }
} }
public static void spawnRandomFirework(Location location)
{
playFirework(location,
Type.values()[UtilMath.r(Type.values().length)],
Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256)),
UtilMath.random.nextBoolean(),
UtilMath.random.nextBoolean()
);
}
} }

View File

@ -396,4 +396,61 @@ public class UtilInv
return amount; return amount;
} }
public static ItemStack decrement(ItemStack item)
{
ItemStack newItem;
if (item.getAmount() == 1)
{
newItem = null;
}
else
{
newItem = item;
newItem.setAmount(newItem.getAmount() - 1);
}
return newItem;
}
public static boolean HasSpace(Player player, Material material, int amount)
{
int slotsFree = 0;
for (int slot = 0; slot < player.getInventory().getSize(); slot++)
{
if (player.getInventory().getItem(slot) == null)
{
slotsFree++;
if (slotsFree >= amount / 64)
{
return true;
}
}
else if (player.getInventory().getItem(slot).getType().equals(material) && amount <= (64 - player.getInventory().getItem(slot).getAmount()))
{
return true;
}
}
return false;
}
public static void give(Player player, Material material)
{
give(player, material, 1);
}
public static void give(Player player, Material material, int amount)
{
give(player, material, amount, (byte) 0);
}
public static void give(Player shooter, Material material, int amount, byte data)
{
shooter.getInventory().addItem(new ItemStack(material, amount, data));
}
} }

View File

@ -306,10 +306,10 @@ public class UtilItem
_materials.put(Material.DIAMOND_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
_materials.put(Material.DIAMOND_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
_materials.put(Material.DIAMOND_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
_materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR)); _materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
_materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR)); _materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
_materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR)); _materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
_materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR)); _materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
_materials.put(Material.FLINT, EnumSet.of(ItemCategory.ITEM)); _materials.put(Material.FLINT, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD)); _materials.put(Material.PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
_materials.put(Material.GRILLED_PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); _materials.put(Material.GRILLED_PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
@ -550,7 +550,7 @@ public class UtilItem
public static boolean isSword(ItemStack stack) public static boolean isSword(ItemStack stack)
{ {
return isEdible(stack == null ? null : stack.getType()); return isSword(stack == null ? null : stack.getType());
} }
public static boolean isSword(Material material) public static boolean isSword(Material material)
@ -878,6 +878,16 @@ public class UtilItem
return isLeaf(stack == null ? null : stack.getType()); return isLeaf(stack == null ? null : stack.getType());
} }
public static boolean isDoor(Material type)
{
return type == null ? false : (contains(type, ItemCategory.DOOR));
}
public static boolean isDoor(ItemStack stack)
{
return isDoor(stack == null ? null : stack.getType());
}
public static boolean isTool(Material material) public static boolean isTool(Material material)
{ {
return material == null ? false : (contains(material, ItemCategory.TOOL)); return material == null ? false : (contains(material, ItemCategory.TOOL));
@ -1137,4 +1147,56 @@ public class UtilItem
i.setItemMeta(im); i.setItemMeta(im);
return i; return i;
} }
public static double getAttackDamage(Material type)
{
return ItemDamage.get(type);
}
enum ItemDamage
{
IRON_SHOVEL(Material.IRON_SPADE, 3),
IRON_PICKAXE(Material.IRON_PICKAXE, 4),
IRON_AXE(Material.IRON_AXE, 5),
WOODEN_SHOVEL(Material.WOOD_SPADE, 1),
WOODEN_PICKAXE(Material.WOOD_PICKAXE, 2),
WOODEN_AXE(Material.WOOD_AXE, 3),
STONE_SHOVEL(Material.STONE_SPADE, 2),
STONE_PICKAXE(Material.STONE_PICKAXE, 3),
STONE_AXE(Material.STONE_AXE, 4),
DIAMOND_SHOVEL(Material.DIAMOND_SPADE, 4),
DIAMOND_PICKAXE(Material.DIAMOND_PICKAXE, 5),
DIAMOND_AXE(Material.DIAMOND_AXE, 6),
GOLD_SHOVEL(Material.GOLD_SPADE, 1),
GOLD_PICKAXE(Material.GOLD_PICKAXE, 2),
GOLD_AXE(Material.GOLD_AXE, 3),
IRON_SWORD(Material.IRON_SWORD, 6),
WOODEN_SWORD(Material.WOOD_SWORD, 4),
STONE_SWORD(Material.STONE_SWORD, 5),
DIAMOND_SWORD(Material.DIAMOND_SWORD, 7),
GOLDEN_SWORD(Material.GOLD_SWORD, 4);
private double _damage;
private Material _type;
ItemDamage(Material type, double damage)
{
_type = type;
_damage = damage;
}
public static double get(Material type)
{
for (ItemDamage item : values())
{
if (item._type.equals(type))
{
return item._damage;
}
}
return 1;
}
}
} }

View File

@ -108,6 +108,11 @@ public class UtilMath
return num < min ? min : (num > max ? max : num); return num < min ? min : (num > max ? max : num);
} }
public static float clamp(float num, float min, float max)
{
return num < min ? min : (num > max ? max : num);
}
public static long clamp(long num, long min, long max) public static long clamp(long num, long min, long max)
{ {
return num < min ? min : (num > max ? max : num); return num < min ? min : (num > max ? max : num);
@ -137,4 +142,145 @@ public class UtilMath
return ((double) rand) / 100.d; return ((double) rand) / 100.d;
} }
public static <T> T getLast(List<T> list)
{
return list.isEmpty() ? null : list.get(list.size() - 1);
}
public static <T> T getFirst(List<T> list)
{
return list.isEmpty() ? null : list.get(0);
}
public static <T> T getLast(NautArrayList<T> list)
{
return list.isEmpty() ? null : list.get(list.size() - 1);
}
public static <T> T getFirst(NautArrayList<T> list)
{
return list.isEmpty() ? null : list.get(0);
}
public static <N extends Number> N closest(List<N> values, N value)
{
int closestIndex = -1;
int index = 0;
for (N number : values)
{
if (closestIndex == -1 || (Math.abs(number.doubleValue() - value.doubleValue()) < Math.abs(values.get(closestIndex).doubleValue() - value.doubleValue())))
{
closestIndex = index;
}
index++;
}
return values.get(closestIndex);
}
public static boolean isOdd(int size)
{
return !isEven(size);
}
public static boolean isEven(int size)
{
return size % 2 == 0;
}
public static byte[] getBits(int value)
{
byte[] bits = new byte[32];
String bit = Long.toBinaryString(value);
while (bit.length() < 32)
{
bit = "0" + bit;
}
int index = 0;
for (char c : bit.toCharArray())
{
bits[index] = (byte) (c == '1' ? '1' : '0');
index++;
}
return bits;
}
public static byte[] getBits(long value)
{
byte[] bits = new byte[64];
String bit = Long.toBinaryString(value);
while (bit.length() < 64)
{
bit = "0" + bit;
}
int index = 0;
for (char c : bit.toCharArray())
{
bits[index] = (byte) (c == '1' ? '1' : '0');
index++;
}
return bits;
}
public static byte[] getBits(byte value)
{
byte[] bits = new byte[8];
String bit = Long.toBinaryString(value);
while (bit.length() < 8)
{
bit = "0" + bit;
}
int index = 0;
for (char c : bit.toCharArray())
{
bits[index] = (byte) (c == '1' ? '1' : '0');
index++;
}
return bits;
}
public static byte[] getBits(short value)
{
byte[] bits = new byte[16];
String bit = Long.toBinaryString(value);
while (bit.length() < 16)
{
bit = "0" + bit;
}
int index = 0;
for (char c : bit.toCharArray())
{
bits[index] = (byte) (c == '1' ? '1' : '0');
index++;
}
return bits;
}
public static double getDecimalPoints(double n)
{
return n - ((int) ((int) n));
}
} }

View File

@ -0,0 +1,29 @@
package mineplex.core.common.util;
import java.io.File;
import java.io.FileInputStream;
import org.bukkit.inventory.ItemStack;
import com.java.sk89q.jnbt.NBTInputStream;
import com.java.sk89q.jnbt.NamedTag;
public class UtilOfflinePlayer
{
public static ItemStack loadOfflineInventory(File file)
{
try (NBTInputStream stream = new NBTInputStream(new FileInputStream(file)))
{
NamedTag tag = stream.readNamedTag();
System.out.println(tag);
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
}

View File

@ -27,6 +27,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.util.BlockIterator; import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.MinecraftVersion;
import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PlayerConnection; import net.minecraft.server.v1_8_R3.PlayerConnection;
@ -67,6 +68,11 @@ public class UtilPlayer
return true; return true;
} }
public static boolean is1_9(Player player)
{
return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() > 47;
}
private static class Vector3D private static class Vector3D
{ {
@ -784,4 +790,37 @@ public class UtilPlayer
return null; return null;
} }
public static boolean isGliding(Player player)
{
return ((CraftPlayer) player).getHandle().isGliding();
}
public static void setGliding(Player player, boolean gliding)
{
((CraftPlayer) player).getHandle().setGliding(gliding);
}
public static void setAutoDeploy(Player player, boolean autoDeploy)
{
((CraftPlayer) player).getHandle().setAutoWingsDeploy(autoDeploy);
}
public static void setGlidableWithoutWings(Player player, boolean glidableWithoutWings)
{
((CraftPlayer) player).getHandle().setGlidableWithoutWings(glidableWithoutWings);
}
public static void setAutoDeployDistance(Player player, float distance)
{
((CraftPlayer) player).getHandle().setWingsDeployAt(distance);
}
public static MinecraftVersion getVersion(Player player)
{
if (is1_9(player))
return MinecraftVersion.Version1_9;
return MinecraftVersion.Version1_8;
}
} }

View File

@ -1,20 +1,38 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.collect.Lists;
import mineplex.core.common.events.PlayerRecieveBroadcastEvent;
public class UtilServer public class UtilServer
{ {
// Quite hacky. would be nice if we could have a "MineplexPlugin" interface
// which would define a getServerName() method and then implement it in
// whatever way needed.
// MineplexPlugin plugin = (MineplexPlugin) plugin.getClass().getDeclaredMethod("getMineplexPlugin").invoke(plugin);
// plugin.getServerName();
private static String _serverName;
public static Player[] getPlayers() public static Player[] getPlayers()
{ {
return getServer().getOnlinePlayers().toArray(new Player[0]); return getServer().getOnlinePlayers().toArray(new Player[0]);
@ -52,8 +70,11 @@ public class UtilServer
public static void broadcast(String message) public static void broadcast(String message)
{ {
for (Player cur : getPlayers()) for (Player cur : getPlayers())
{
if (!UtilServer.CallEvent(new PlayerRecieveBroadcastEvent(cur, message)).isCancelled())
UtilPlayer.message(cur, message); UtilPlayer.message(cur, message);
} }
}
public static void broadcast(LinkedList<String> messages) public static void broadcast(LinkedList<String> messages)
{ {
@ -86,4 +107,116 @@ public class UtilServer
{ {
return (double)getPlayers().length / (double)UtilServer.getServer().getMaxPlayers(); return (double)getPlayers().length / (double)UtilServer.getServer().getMaxPlayers();
} }
public static void RegisterEvents(Listener listener)
{
getPluginManager().registerEvents(listener, getPlugin());
}
public static void Unregister(Listener listener)
{
HandlerList.unregisterAll(listener);
}
public static Plugin getPlugin()
{
return getPluginManager().getPlugins()[0];
}
public static PluginManager getPluginManager()
{
return getServer().getPluginManager();
}
public static <T extends Event> T CallEvent(T event)
{
getPluginManager().callEvent(event);
return event;
}
public static void repeat(BukkitRunnable runnable, long time)
{
runnable.runTaskTimer(getPlugin(), time, time);
}
public static boolean IsOnline(String name)
{
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(player -> player.getName().equals(name)));
}
public static Player GetPlayer(String name)
{
return UtilStreams.GetFirst(getPlayersCollection().stream().filter(player -> player.getName().equals(name)));
}
public static OfflinePlayer GetOffline(String player)
{
return getServer().getOfflinePlayer(player);
}
public static String getServerName()
{
if (_serverName == null)
{
try
{
Class<?> Portal = Class.forName("mineplex.core.portal.Portal");
Object instance = null;
List<Field> stringFields = Lists.newArrayList();
for (Field field : Portal.getDeclaredFields())
{
if (field.getType().equals(Portal))
{
field.setAccessible(true);
instance = field.get(null);
}
if (field.getType().equals(String.class))
{
stringFields.add(field);
}
}
for (Field field : stringFields)
{
field.setAccessible(true);
String value = (String) field.get(instance);
if (stringFields.size() > 1)
{
if (value.contains("-"))
{
_serverName = new String(value);
}
}
else
{
_serverName = new String(value);
}
}
if (_serverName == null)
{
_serverName = "UNKOWN";
System.out.println("ERROR: Could not get server name from Portal. Cause is most likely ambiguous fields in the class. Please revise UtilServer's method of getting the current server name.");
}
}
catch (Exception exception)
{
System.out.println("FATAL ERROR WHILE TRYING TO GET SERVER NAME");
exception.printStackTrace();
}
}
return _serverName;
}
public static Collection<Player> GetPlayers()
{
return Lists.newArrayList(getPlayers());
}
} }

View File

@ -11,38 +11,40 @@ public class UtilShapes
{ {
private final static BlockFace[] radial = private final static BlockFace[] radial =
{ {
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.SOUTH,
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST BlockFace.SOUTH_WEST,
BlockFace.WEST,
BlockFace.NORTH_WEST,
BlockFace.NORTH,
BlockFace.NORTH_EAST,
BlockFace.EAST,
BlockFace.SOUTH_EAST
}; };
public static ArrayList<Location> getCircle(Location loc, boolean hollow, double radius) public static ArrayList<Location> getCircle(Location loc, boolean hollow, double radius)
{ {
return getCircleBlocks(loc, radius, 0, hollow, false); return getSphereBlocks(loc, radius, 0, hollow);
} }
public static ArrayList<Location> getSphereBlocks(Location loc, double radius, double height, boolean hollow) public static ArrayList<Location> getSphereBlocks(Location loc, double width, double height, boolean hollow)
{
return getCircleBlocks(loc, radius, height, hollow, true);
}
private static ArrayList<Location> getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere)
{ {
ArrayList<Location> circleblocks = new ArrayList<Location>(); ArrayList<Location> circleblocks = new ArrayList<Location>();
double cx = loc.getBlockX(); double cx = loc.getBlockX();
double cy = loc.getBlockY(); double cy = loc.getBlockY();
double cz = loc.getBlockZ(); double cz = loc.getBlockZ();
for (double y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height + 1); y++) for (double y = height; y < height + 1; y++)
{ {
for (double x = cx - radius; x <= cx + radius; x++) for (double x = -width; x <= width; x++)
{ {
for (double z = cz - radius; z <= cz + radius; z++) for (double z = -width; z <= width; z++)
{ {
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0); double dist = (x * x) + (z * z) + (y * y);
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1))) if (dist < width * width
&& !(hollow && Math.abs(x) - width < 1 && Math.abs(z) - width < 1 && Math.abs(y) - height < 1))
{ {
Location l = new Location(loc.getWorld(), x, y, z); Location l = new Location(loc.getWorld(), x + cx, y + cy, z + cz);
circleblocks.add(l); circleblocks.add(l);
} }
} }
@ -75,7 +77,8 @@ public class UtilShapes
right = radial[high]; right = radial[high];
return new BlockFace[] return new BlockFace[]
{ {
left, right left,
right
}; };
} }
} }
@ -87,13 +90,19 @@ public class UtilShapes
BlockFace[] faces = getSideBlockFaces(facing); BlockFace[] faces = getSideBlockFaces(facing);
return new Block[] return new Block[]
{ {
b.getRelative(faces[0]), b.getRelative(faces[1]) b.getRelative(faces[0]),
b.getRelative(faces[1])
}; };
} }
public static BlockFace getFacing(float yaw) public static BlockFace getFacing(float yaw)
{ {
return radial[Math.round(yaw / 45f) & 0x7]; return radial[Math.round(yaw / 45f) % 8];
}
public static float getFacing(BlockFace face)
{
return UtilAlg.GetYaw(new Vector(face.getModX(), face.getModY(), face.getModZ()).normalize());
} }
public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint, public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint,
@ -133,6 +142,24 @@ public class UtilShapes
return locs; return locs;
} }
/**
* Rotates the blocks around 0,0,0
*/
public static ArrayList<Location> rotate(ArrayList<Location> locs, double degree)
{
ArrayList<Location> rotated = new ArrayList<Location>();
for (Location loc : locs)
{
double xRot = Math.cos(degree) * (loc.getX()) - Math.sin(degree) * (loc.getZ());
double zRot = loc.getZ() + Math.sin(degree) * (loc.getX()) + Math.cos(degree) * (loc.getZ());
rotated.add(new Location(loc.getWorld(), xRot, loc.getY(), zRot));
}
return rotated;
}
public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius) public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius)
{ {
return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius); return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius);
@ -157,12 +184,14 @@ public class UtilShapes
new int[] new int[]
{ {
allowDiagonal ? facing.getModX() : facing.getModZ(), allowDiagonal ? 0 : -facing.getModX() allowDiagonal ? facing.getModX() : facing.getModZ(),
allowDiagonal ? 0 : -facing.getModX()
}, },
new int[] new int[]
{ {
allowDiagonal ? 0 : -facing.getModZ(), allowDiagonal ? facing.getModZ() : facing.getModX() allowDiagonal ? 0 : -facing.getModZ(),
allowDiagonal ? facing.getModZ() : facing.getModX()
} }
}; };
@ -189,7 +218,8 @@ public class UtilShapes
{ {
faces = new BlockFace[] faces = new BlockFace[]
{ {
faces[1], faces[0] faces[1],
faces[0]
}; };
} }
@ -228,7 +258,8 @@ public class UtilShapes
return new Block[] return new Block[]
{ {
b.getRelative(faces[0]), b.getRelative(faces[1]) b.getRelative(faces[0]),
b.getRelative(faces[1])
}; };
} }

View File

@ -0,0 +1,58 @@
package mineplex.core.common.util;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.stream.Stream;
import org.apache.commons.lang.Validate;
public class UtilStreams
{
public static boolean IsEmpty(Stream<?> stream)
{
return Sum(stream) != 0;
}
public static int Sum(Stream<?> stream)
{
return stream.mapToInt(v -> 1).sum();
}
public static Object[] ToArray(Stream<? extends Object> stream)
{
return stream.toArray();
}
public static <T> T Get(int index, Stream<T> stream)
{
if (Sum(stream) < index + 1)
{
return null;
}
return (T) ToArray(stream)[index];
}
public static <T> T GetFirst(Stream<T> stream)
{
return Get(0, stream);
}
public static <T> T GetLast(Stream<T> stream)
{
return Get(Sum(stream) + 1, stream);
}
public static byte[] ReadBytes(DataInputStream dos, int bytes) throws IOException
{
Validate.isTrue(bytes > 0, "Amount of bytes to read must be > 0");
byte[] read = new byte[bytes];
for (int i = 0; i < bytes; i++)
read[i] = dos.readByte();
return read;
}
}

View File

@ -6,14 +6,14 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import mineplex.core.common.CurrencyType;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.common.CurrencyType;
public class UtilText public class UtilText
{ {
@ -614,6 +614,11 @@ public class UtilText
public static String repeat(String txt, int times) public static String repeat(String txt, int times)
{ {
if (times <= 0)
{
return new String();
}
return new String(new byte[times]).replace("\0", txt); return new String(new byte[times]).replace("\0", txt);
} }
@ -653,12 +658,16 @@ public class UtilText
} }
public static String getProgress(String prefix, double amount, String suffix, boolean progressDirectionSwap) public static String getProgress(String prefix, double amount, String suffix, boolean progressDirectionSwap)
{
return getProgress(prefix, amount, suffix, progressDirectionSwap, 24);
}
public static String getProgress(String prefix, double amount, String suffix, boolean progressDirectionSwap, int bars)
{ {
if (progressDirectionSwap) if (progressDirectionSwap)
amount = 1 - amount; amount = 1 - amount;
//Generate Bar //Generate Bar
int bars = 24;
String progressBar = C.cGreen + ""; String progressBar = C.cGreen + "";
boolean colorChange = false; boolean colorChange = false;
for (int i=0 ; i<bars ; i++) for (int i=0 ; i<bars ; i++)
@ -675,4 +684,18 @@ public class UtilText
return(prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix); return(prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix);
} }
public static String possesive(String possesiveNoun, String noun)
{
if (possesiveNoun == null || noun == null)
{
return "???";
}
if (possesiveNoun.isEmpty() || noun.isEmpty())
{
return "???";
}
return possesiveNoun.endsWith("s") ? possesiveNoun + "' " + noun : possesiveNoun + "'s " + noun;
}
} }

View File

@ -1,6 +1,5 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.minecraft.server.v1_8_R3.ChatMessage; import net.minecraft.server.v1_8_R3.ChatMessage;
@ -28,6 +27,11 @@ public class UtilTextMiddle
public static void display(String text, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players) public static void display(String text, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players)
{ {
if (players.length == 1 && players[0] == null)
{
return;
}
setTimings(fadeInTicks, stayTicks, fadeOutTicks, players); setTimings(fadeInTicks, stayTicks, fadeOutTicks, players);
display(text, subtitle, players); display(text, subtitle, players);

View File

@ -1,8 +1,15 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.HashMap;
import java.util.UUID;
import mineplex.core.common.DummyEntity; import mineplex.core.common.DummyEntity;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_8_R3.EntityWither;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.PacketPlayOutBossBar;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -10,13 +17,16 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class UtilTextTop public class UtilTextTop
{ {
//Base Commands // Base Commands
public static void display(String text, Player... players) public static void display(String text, Player... players)
{ {
displayProgress(text, 1, players); displayProgress(text, 1, players);
@ -28,42 +38,107 @@ public class UtilTextTop
displayTextBar(player, progress, text); displayTextBar(player, progress, text);
} }
//Logic // Logic
public static final int EntityDragonId = 777777; public static final int EntityDragonId = 777777;
public static final int EntityWitherId = 777778; public static final int EntityWitherId = 777778;
public static final UUID BossUUID = UUID.fromString("178f5cde-2fb0-3e73-8296-967ec7e46748");
private static HashMap<String, BukkitRunnable> _lastUpdated = new HashMap<String, BukkitRunnable>();
//Display // Display
public static void displayTextBar(final Player player, double healthPercent, String text) public static void displayTextBar(final Player player, double healthPercent, String text)
{ {
if (_lastUpdated.containsKey(player.getName()))
{
_lastUpdated.get(player.getName()).cancel();
}
healthPercent = Math.max(0, Math.min(1, healthPercent));
// Remove
final BukkitRunnable runnable = new BukkitRunnable()
{
public void run()
{
if (_lastUpdated.containsKey(player.getName()) && _lastUpdated.get(player.getName()) != this)
return;
deleteOld(player); deleteOld(player);
healthPercent = Math.min(1, healthPercent); _lastUpdated.remove(player.getName());
}
};
//Display Dragon runnable.runTaskLater(Bukkit.getPluginManager().getPlugins()[0], 20);
if (UtilPlayer.is1_9(player))
{
sendBossBar(player, healthPercent, text);
_lastUpdated.put(player.getName(), runnable);
return;
}
_lastUpdated.put(player.getName(), runnable);
deleteOld(player);
// Display Dragon
{ {
Location loc = player.getLocation().subtract(0, 200, 0); Location loc = player.getLocation().subtract(0, 200, 0);
UtilPlayer.sendPacket(player, getDragonPacket(text, healthPercent, loc)); UtilPlayer.sendPacket(player, getDragonPacket(text, healthPercent, loc));
} }
// Display Wither (as well as Dragon)
//Display Wither (as well as Dragon)
Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(24)); Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(24));
UtilPlayer.sendPacket(player, getWitherPacket(text, healthPercent, loc)); UtilPlayer.sendPacket(player, getWitherPacket(text, healthPercent, loc));
//Remove
Bukkit.getServer().getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugins()[0], new Runnable()
{
public void run()
{
deleteOld(player);
} }
}, 20);
private static void sendBossBar(Player player, double health, String text)
{
if (_lastUpdated.containsKey(player.getName()))
{
PacketPlayOutBossBar bossBar1 = new PacketPlayOutBossBar();
bossBar1.uuid = BossUUID;
bossBar1.action = 2;
bossBar1.health = (float) health;
PacketPlayOutBossBar bossBar2 = new PacketPlayOutBossBar();
bossBar2.uuid = BossUUID;
bossBar2.action = 3;
bossBar2.title = text;
UtilPlayer.sendPacket(player, bossBar1, bossBar2);
}
else
{
PacketPlayOutBossBar bossBar = new PacketPlayOutBossBar();
bossBar.uuid = BossUUID;
bossBar.title = text;
bossBar.health = (float) health;
bossBar.color = 2;
UtilPlayer.sendPacket(player, bossBar);
}
} }
private static void deleteOld(Player player) private static void deleteOld(Player player)
{ {
if (UtilPlayer.is1_9(player))
{
PacketPlayOutBossBar bossBar = new PacketPlayOutBossBar();
bossBar.uuid = BossUUID;
bossBar.action = 1;
UtilPlayer.sendPacket(player, bossBar);
return;
}
// Delete Dragon (All Clients) // Delete Dragon (All Clients)
PacketPlayOutEntityDestroy destroyDragonPacket = new PacketPlayOutEntityDestroy(new int[] PacketPlayOutEntityDestroy destroyDragonPacket = new PacketPlayOutEntityDestroy(new int[]
{ {
@ -79,28 +154,38 @@ public class UtilTextTop
UtilPlayer.sendPacket(player, destroyWitherPacket); UtilPlayer.sendPacket(player, destroyWitherPacket);
} }
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
if (UtilPlayer.is1_9(event.getPlayer()))
{
deleteOld(event.getPlayer());
}
}
public static PacketPlayOutSpawnEntityLiving getDragonPacket(String text, double healthPercent, Location loc) public static PacketPlayOutSpawnEntityLiving getDragonPacket(String text, double healthPercent, Location loc)
{ {
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
mobPacket.a = (int) EntityDragonId; //Entity ID mobPacket.a = (int) EntityDragonId; // Entity ID
mobPacket.b = (byte) EntityType.ENDER_DRAGON.getTypeId(); //Mob type mobPacket.b = (byte) EntityType.ENDER_DRAGON.getTypeId(); // Mob type
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); // X position
mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); //Y position mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); // Y position
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); // Z position
mobPacket.f = (byte) 0; //Pitch mobPacket.f = (byte) 0; // Pitch
mobPacket.g = (byte) 0; //Head Pitch mobPacket.g = (byte) 0; // Head Pitch
mobPacket.h = (byte) 0; //Yaw mobPacket.h = (byte) 0; // Yaw
mobPacket.i = (short) 0; //X velocity mobPacket.i = (short) 0; // X velocity
mobPacket.j = (short) 0; //Y velocity mobPacket.j = (short) 0; // Y velocity
mobPacket.k = (short) 0; //Z velocity mobPacket.k = (short) 0; // Z velocity
mobPacket.uuid = UUID.randomUUID();
//Health // Health
double health = healthPercent * 199.9 + 0.1; double health = healthPercent * 199.9 + 0.1;
//if (halfHealth) // if (halfHealth)
// health = healthPercent * 99 + 101; // health = healthPercent * 99 + 101;
//Watcher // Watcher
DataWatcher watcher = getWatcher(text, health, loc.getWorld()); DataWatcher watcher = getWatcher(text, health, loc.getWorld());
mobPacket.l = watcher; mobPacket.l = watcher;
@ -111,24 +196,25 @@ public class UtilTextTop
{ {
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
mobPacket.a = (int) EntityWitherId; //Entity ID mobPacket.a = (int) EntityWitherId; // Entity ID
mobPacket.b = (byte) EntityType.WITHER.getTypeId(); //Mob type mobPacket.b = (byte) EntityType.WITHER.getTypeId(); // Mob type
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); // X position
mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); //Y position mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); // Y position
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); // Z position
mobPacket.f = (byte) 0; //Pitch mobPacket.f = (byte) 0; // Pitch
mobPacket.g = (byte) 0; //Head Pitch mobPacket.g = (byte) 0; // Head Pitch
mobPacket.h = (byte) 0; //Yaw mobPacket.h = (byte) 0; // Yaw
mobPacket.i = (short) 0; //X velocity mobPacket.i = (short) 0; // X velocity
mobPacket.j = (short) 0; //Y velocity mobPacket.j = (short) 0; // Y velocity
mobPacket.k = (short) 0; //Z velocity mobPacket.k = (short) 0; // Z velocity
mobPacket.uuid = UUID.randomUUID();
//Health // Health
double health = healthPercent * 299.9 + 0.1; double health = healthPercent * 299.9 + 0.1;
//if (halfHealth) // if (halfHealth)
// health = healthPercent * 149 + 151; // health = healthPercent * 149 + 151;
//Watcher // Watcher
DataWatcher watcher = getWatcher(text, health, loc.getWorld()); DataWatcher watcher = getWatcher(text, health, loc.getWorld());
mobPacket.l = watcher; mobPacket.l = watcher;
@ -137,17 +223,14 @@ public class UtilTextTop
public static DataWatcher getWatcher(String text, double health, World world) public static DataWatcher getWatcher(String text, double health, World world)
{ {
DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)world).getHandle())); DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) world).getHandle()));
watcher.a(0, (Byte) (byte) 0); //Flags, 0x20 = invisible watcher.a(0, (Byte) (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5)); // Flags, 0x20 = invisible
watcher.a(6, (Float) (float) health); watcher.a(6, (Float) (float) health, EntityLiving.META_HEALTH, (float) health);
watcher.a(2, (String) text); //Entity name watcher.a(2, (String) text, Entity.META_CUSTOMNAME, text); // Entity name
watcher.a(3, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show watcher.a(3, (Byte) (byte) 0, Entity.META_CUSTOMNAME_VISIBLE, false); // Show name, 1 = show, 0 = don't show
watcher.a(16, (Integer) (int) health); //Health // watcher.a(16, (Integer) (int) health, EntityWither.META); //Health
watcher.a(20, (Integer) (int) 881); //Inv watcher.a(20, (Integer) (int) 881, EntityWither.META_INVUL_TIME, 881); // Inv
int i1 = watcher.getByte(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
return watcher; return watcher;
} }

View File

@ -0,0 +1,80 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class UtilTrig
{
public static List<Vector> GetCirclePoints(Vector origin, int points, double radius)
{
List<Vector> list = new LinkedList<>();
double slice = 2 * Math.PI / points;
for (int point = 0; point < points; point++)
{
double angle = slice * point;
list.add(new Vector(origin.getX() + radius * Math.cos(angle), 0, origin.getZ() + radius * Math.sin(angle)));
}
return list;
}
public static ArrayList<Location> GetSpherePoints(Location loc, double radius, double height, boolean hollow, double addition)
{
ArrayList<Location> circleblocks = new ArrayList<Location>();
double cx = loc.getBlockX();
double cy = loc.getBlockY();
double cz = loc.getBlockZ();
for (double y = cy - radius; y < cy + radius; y += addition)
{
for (double x = cx - radius; x <= cx + radius; x += addition)
{
for (double z = cz - radius; z <= cz + radius; z += addition)
{
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (cy - y) * (cy - y);
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
{
Location l = new Location(loc.getWorld(), x, y, z);
circleblocks.add(l);
}
}
}
}
return circleblocks;
}
public static List<Vector> GetSpherePoints(Vector vector, double radius, double height, boolean hollow, double addition)
{
List<Vector> circleblocks = new ArrayList<>();
double cx = vector.getX();
double cy = vector.getY();
double cz = vector.getZ();
for (double y = cy - radius; y < cy + radius; y += addition)
{
for (double x = cx - radius; x <= cx + radius; x += addition)
{
for (double z = cz - radius; z <= cz + radius; z += addition)
{
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (cy - y) * (cy - y);
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
{
Vector l = new Vector(x, y, z);
circleblocks.add(l);
}
}
}
}
return circleblocks;
}
}

View File

@ -0,0 +1,58 @@
package mineplex.core.common.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
public class UtilWeb
{
public static String doPOST(String url, Map<String, Object> params)
{
try
{
StringBuilder postData = new StringBuilder();
for (Map.Entry<String,Object> param : params.entrySet())
{
if (postData.length() != 0)
{
postData.append('&');
}
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
StringBuilder back = new StringBuilder();
for (int $char; ($char = in.read()) >= 0;)
{
back.append((char) $char);
}
return back.toString();
}
catch (Exception exception)
{
exception.printStackTrace();
return null;
}
}
}

View File

@ -2,18 +2,20 @@ package mineplex.core.common.util;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class UtilWorld public class UtilWorld
{ {
public static World getWorld(String world) public static World getWorld(String world)
@ -209,4 +211,82 @@ public class UtilWorld
origin.getBlock().getRelative(BlockFace.SOUTH), origin.getBlock().getRelative(BlockFace.SOUTH),
origin.getBlock().getRelative(BlockFace.WEST)); origin.getBlock().getRelative(BlockFace.WEST));
} }
/**
* This method will use the World provided by the given Location.<p>
* @return <b>true</b> if the specified location is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean inWorldBorder(Location location)
{
WorldBorder border = location.getWorld().getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ;
}
/**
* This method will use the World specified by the second argument, and the
* x, y, and z provided by the given Location.<p>
* @return <b>true</b> if the specified location is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean inWorldBorder(World world, Location location)
{
WorldBorder border = world.getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ;
}
/**
* @return <b>true</b> if the specified bounding box is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean isBoxInWorldBorder(World world, Location min, Location max)
{
WorldBorder border = world.getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
double startX = Math.min(min.getX(), max.getX());
double startZ = Math.min(min.getZ(), max.getZ());
double endX = Math.max(min.getX(), max.getX());
double endZ = Math.max(min.getZ(), max.getZ());
return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ;
}
} }

View File

@ -19,6 +19,8 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
@ -26,6 +28,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -65,12 +68,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
super("Custom Tag Fix", plugin); super("Custom Tag Fix", plugin);
packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, packetHandler.addPacketHandler(this, true, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutNamedEntitySpawn.class,
PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class); PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class, PacketPlayOutNewAttachEntity.class);
// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); // NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); // NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
NCPHookManager.addHook(CheckType.ALL, this); NCPHookManager.addHook(CheckType.ALL, this);
} }
@ -119,7 +122,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
@EventHandler @EventHandler
public void ncpExemptVelocity(final PlayerVelocityEvent event) public void ncpExemptVelocity(final PlayerVelocityEvent event)
{ {
long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 2000); long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 1500);
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId())) if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{ {
_exemptTimeMap.put(event.getPlayer().getUniqueId(), _exemptTimeMap.put(event.getPlayer().getUniqueId(),
@ -254,15 +258,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return; return;
} }
int newId = UtilEnt.getNewEntityId(); Integer[] ids = new Integer[]
{
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[] _entityMap.get(owner.getName()).put(spawnPacket.a, ids);
{
newId
});
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, -1); sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break; break;
} }
} }
@ -299,17 +304,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return; return;
} }
int newId = UtilEnt.getNewEntityId(); Integer[] ids = new Integer[]
int newId2 = UtilEnt.getNewEntityId(); {
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[] _entityMap.get(owner.getName()).put(spawnPacket.a, ids);
{
newId,
newId2
});
sendProtocolPackets(owner, spawnPacket.a, newId2, entityName, verifier, true, newId); sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break; break;
} }
} }
@ -329,13 +333,13 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
String newName = currentName; String newName = currentName;
boolean newDisplay = isDisplaying; boolean displayName = isDisplaying;
for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b) for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b)
{ {
if (watchable.a() == 3 && watchable.b() instanceof Byte) if (watchable.a() == 3 && watchable.b() instanceof Byte)
{ {
newDisplay = ((Byte) watchable.b()) == 1; displayName = ((Byte) watchable.b()) == 1;
} }
if (watchable.a() == 2 && watchable.b() instanceof String) if (watchable.a() == 2 && watchable.b() instanceof String)
@ -345,10 +349,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
// If the name has changed and the name should be showing, or the name display status has changed. // If the name has changed and the name should be showing, or the name display status has changed.
if ((!newName.equals(currentName) && newDisplay) || newDisplay != isDisplaying) if ((!newName.equals(currentName) && displayName) || displayName != isDisplaying)
{ {
// If name is still being displayed // If name is still being displayed
if (newDisplay) if (displayName)
{ {
Integer[] newId; Integer[] newId;
@ -361,6 +365,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
newId = new Integer[] newId = new Integer[]
{ {
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId() UtilEnt.getNewEntityId()
}; };
@ -368,7 +373,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName); _entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
sendProtocolPackets(owner, metaPacket.a, newId[0], newName, verifier, !isDisplaying, -1); sendProtocolPackets(owner, metaPacket.a, newName, verifier, !isDisplaying, newId);
} }
else else
{ // Lets delete it { // Lets delete it
@ -449,9 +454,25 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
} }
} }
else if (packet instanceof PacketPlayOutAttachEntity) else if (packet instanceof PacketPlayOutAttachEntity || packet instanceof PacketPlayOutNewAttachEntity)
{
int vech = -1;
int rider = -1;
if (packet instanceof PacketPlayOutAttachEntity)
{ {
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet;
vech = attachPacket.b;
rider = attachPacket.c;
}
else if (packet instanceof PacketPlayOutNewAttachEntity)
{
PacketPlayOutNewAttachEntity attachPacket = (PacketPlayOutNewAttachEntity) packet;
vech = attachPacket.a;
if (attachPacket.b.length > 0)
rider = attachPacket.b[0];
}
// c = rider, b = ridden // c = rider, b = ridden
// When detaching, c is sent, b is -1 // When detaching, c is sent, b is -1
@ -470,27 +491,27 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
int vehicleId = -1; int vehicleId = -1;
if (_entityRiding.get(owner.getName()).containsKey(attachPacket.b)) if (_entityRiding.get(owner.getName()).containsKey(vech))
{ {
vehicleId = _entityRiding.get(owner.getName()).get(attachPacket.b); vehicleId = _entityRiding.get(owner.getName()).get(vech);
} }
if (attachPacket.c == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId)) if (rider == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId))
{ {
Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId); Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId);
_entityRiding.get(owner.getName()).remove(attachPacket.b); _entityRiding.get(owner.getName()).remove(vech);
sendProtocolPackets(owner, vehicleId, ids[ids.length - 1], _entityNameMap.get(owner.getName()).get(vehicleId), sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true,
verifier, true, ids.length > 1 ? ids[0] : -1); ids);
} }
else else
{ {
Integer[] ids = _entityMap.get(owner.getName()).get(attachPacket.c); Integer[] ids = _entityMap.get(owner.getName()).get(rider);
if (ids != null && ids[0] != attachPacket.b) if (ids != null && ids[1] != vech)
{ {
_entityRiding.get(owner.getName()).put(attachPacket.b, attachPacket.c); _entityRiding.get(owner.getName()).put(vech, rider);
int[] newIds = new int[ids.length]; int[] newIds = new int[ids.length];
@ -506,8 +527,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
} }
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, private void sendProtocolPackets(final Player owner, final int entityId, String entityName, final PacketVerifier packetList,
final PacketVerifier packetList, final boolean newPacket, final int squidId) final boolean newPacket, final Integer[] entityIds)
{ {
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event); _plugin.getServer().getPluginManager().callEvent(event);
@ -519,35 +540,39 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
watcher.a(0, (byte) (0 | 1 << 5)); // Invisible watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32); // Invisible
watcher.a(1, Short.valueOf((short) 300)); watcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 0);
watcher.a(2, finalEntityName); watcher.a(2, finalEntityName, Entity.META_CUSTOMNAME, finalEntityName);
watcher.a(3, (byte) 1); watcher.a(3, (byte) 1, Entity.META_CUSTOMNAME_VISIBLE, true);
watcher.a(4, Byte.valueOf((byte) 0)); watcher.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); // Small
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte) 0));
watcher.a(9, Byte.valueOf((byte) 0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, (byte) (0 | 0x1)); // Small
if (newPacket) if (newPacket)
{ {
if (squidId >= 0)
{ {
watcher.watch(10, (byte) 16);
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
squidWatcher.a(0, (byte) (0 | 1 << 5)); squidWatcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32);
PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = squidId; spawnPacket.a = entityIds[1];
spawnPacket.b = (byte) EntityType.SQUID.getTypeId(); spawnPacket.b = (byte) EntityType.SQUID.getTypeId();
spawnPacket.c = 1000000; spawnPacket.c = owner.getLocation().getBlockX() * 32;
spawnPacket.d = -150;
spawnPacket.e = owner.getLocation().getBlockZ() * 32;
spawnPacket.l = squidWatcher; spawnPacket.l = squidWatcher;
spawnPacket.uuid = UUID.randomUUID();
UtilPlayer.sendPacket(owner, spawnPacket); UtilPlayer.sendPacket(owner, spawnPacket);
if (UtilPlayer.is1_9(owner))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[]
{
entityIds[1]
}));
}
else
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0; vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a; vehiclePacket.b = spawnPacket.a;
@ -555,27 +580,41 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
UtilPlayer.sendPacket(owner, vehiclePacket); UtilPlayer.sendPacket(owner, vehiclePacket);
} }
}
PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId; spawnPacket.a = entityIds[0];
spawnPacket.b = (byte) 30; spawnPacket.b = (byte) 30;
spawnPacket.c = 1000000; spawnPacket.c = owner.getLocation().getBlockX() * 32;
spawnPacket.d = -150;
spawnPacket.e = owner.getLocation().getBlockZ() * 32;
spawnPacket.l = watcher; spawnPacket.l = watcher;
spawnPacket.uuid = UUID.randomUUID();
UtilPlayer.sendPacket(owner, spawnPacket); UtilPlayer.sendPacket(owner, spawnPacket);
if (UtilPlayer.is1_9(owner))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[]
{
entityIds[0]
}));
}
else
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0; vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a; vehiclePacket.b = entityIds[0];
vehiclePacket.c = squidId >= 0 ? squidId : entityId; vehiclePacket.c = entityIds[1];
UtilPlayer.sendPacket(owner, vehiclePacket); UtilPlayer.sendPacket(owner, vehiclePacket);
} }
}
else else
{ {
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(); PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
entityMetadata.a = newEntityId; entityMetadata.a = entityIds[0];
entityMetadata.b = watcher.c(); entityMetadata.b = watcher.c();
packetList.bypassProcess(entityMetadata); packetList.bypassProcess(entityMetadata);

View File

@ -15,7 +15,6 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>(); private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
public MiniClientPlugin(String moduleName, JavaPlugin plugin) public MiniClientPlugin(String moduleName, JavaPlugin plugin)
{ {
super(moduleName, plugin); super(moduleName, plugin);

View File

@ -1,5 +1,9 @@
package mineplex.core; package mineplex.core;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -12,6 +16,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.thread.ThreadPool;
public abstract class MiniPlugin implements Listener public abstract class MiniPlugin implements Listener
{ {
@ -19,11 +24,15 @@ public abstract class MiniPlugin implements Listener
protected JavaPlugin _plugin; protected JavaPlugin _plugin;
protected NautHashMap<String, ICommand> _commands; protected NautHashMap<String, ICommand> _commands;
protected long _initializedTime;
public MiniPlugin(String moduleName, JavaPlugin plugin) public MiniPlugin(String moduleName, JavaPlugin plugin)
{ {
_moduleName = moduleName; _moduleName = moduleName;
_plugin = plugin; _plugin = plugin;
_initializedTime = System.currentTimeMillis();
_commands = new NautHashMap<String, ICommand>(); _commands = new NautHashMap<String, ICommand>();
onEnable(); onEnable();
@ -100,12 +109,13 @@ public abstract class MiniPlugin implements Listener
public void log(String message) public void log(String message)
{ {
System.out.println(F.main(_moduleName, message)); Bukkit.getConsoleSender().sendMessage(F.main(_moduleName, message));
} }
public void runAsync(Runnable runnable) public void runAsync(Runnable runnable)
{ {
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, runnable); // Instead of using
ThreadPool.ASYNC.execute(runnable);
} }
public void runAsync(Runnable runnable, long time) public void runAsync(Runnable runnable, long time)

View File

@ -1,8 +1,9 @@
package mineplex.core.account; package mineplex.core.account;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@ -49,8 +50,7 @@ public class CoreClientManager extends MiniPlugin
private NautHashMap<String, CoreClient> _clientList; private NautHashMap<String, CoreClient> _clientList;
private HashSet<String> _duplicateLoginGlitchPreventionList; private HashSet<String> _duplicateLoginGlitchPreventionList;
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>(); private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
private Object _clientLock = new Object(); private Object _clientLock = new Object();
@ -185,7 +185,7 @@ public class CoreClientManager extends MiniPlugin
if (!LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress())) if (!LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress()))
event.disallow(Result.KICK_OTHER, "There was a problem logging you in."); event.disallow(Result.KICK_OTHER, "There was a problem logging you in.");
} }
catch(Exception exception) catch (Exception exception)
{ {
event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute."); event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute.");
exception.printStackTrace(); exception.printStackTrace();
@ -260,7 +260,7 @@ public class CoreClientManager extends MiniPlugin
CoreClient client = Add(playerName); CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank), false); client.SetRank(Rank.valueOf(token.Rank), false);
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
// JSON sql response // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
@ -332,7 +332,7 @@ public class CoreClientManager extends MiniPlugin
CoreClient client = Add(playerName); CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank), false); client.SetRank(Rank.valueOf(token.Rank), false);
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
// JSON sql response // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
@ -376,9 +376,15 @@ public class CoreClientManager extends MiniPlugin
runAsync(new Runnable() runAsync(new Runnable()
{ {
@Override
public void run() public void run()
{ {
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); try {
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_clientLoginLock.remove(client.GetPlayerName()); _clientLoginLock.remove(client.GetPlayerName());
} }
}); });
@ -387,6 +393,7 @@ public class CoreClientManager extends MiniPlugin
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress); String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
TimingManager.stop(client.GetPlayerName() + " GetClient."); TimingManager.stop(client.GetPlayerName() + " GetClient.");
TimingManager.start(client.GetPlayerName() + " Event.");
token = gson.fromJson(response, ClientToken.class); token = gson.fromJson(response, ClientToken.class);
client.SetRank(Rank.valueOf(token.Rank), false); client.SetRank(Rank.valueOf(token.Rank), false);
@ -395,7 +402,9 @@ public class CoreClientManager extends MiniPlugin
// JSON sql response // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
TimingManager.stop(client.GetPlayerName() + " Event.");
TimingManager.start(client.GetPlayerName() + " While Loop.");
while (_clientLoginLock.containsKey(client.GetPlayerName()) && System.currentTimeMillis() - timeStart < 15000) while (_clientLoginLock.containsKey(client.GetPlayerName()) && System.currentTimeMillis() - timeStart < 15000)
{ {
try try
@ -407,6 +416,7 @@ public class CoreClientManager extends MiniPlugin
e.printStackTrace(); e.printStackTrace();
} }
} }
TimingManager.stop(client.GetPlayerName() + " While Loop.");
if (_clientLoginLock.containsKey(client.GetPlayerName())) if (_clientLoginLock.containsKey(client.GetPlayerName()))
{ {
@ -646,12 +656,7 @@ public class CoreClientManager extends MiniPlugin
public void addStoredProcedureLoginProcessor(ILoginProcessor processor) public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
{ {
_loginProcessors.put(processor.getName(), processor); _loginProcessors.add(processor);
}
public void addStoredProcedureLoginProcessor(IQuerylessLoginProcessor processor)
{
_querylessLoginProcessors.add(processor);
} }
public boolean hasRank(Player player, Rank rank) public boolean hasRank(Player player, Rank rank)
@ -662,10 +667,4 @@ public class CoreClientManager extends MiniPlugin
return client.GetRank().has(rank); return client.GetRank().has(rank);
} }
public int getCachedClientAccountId(UUID uuid)
{
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
return playerInfo == null ? -1 : playerInfo.getAccountId();
}
} }

View File

@ -6,30 +6,28 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import mineplex.core.database.MinecraftRepository;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.cache.player.PlayerCache;
import mineplex.core.account.ILoginProcessor; import mineplex.core.account.ILoginProcessor;
import mineplex.core.account.IQuerylessLoginProcessor;
import mineplex.core.account.repository.token.LoginToken; import mineplex.core.account.repository.token.LoginToken;
import mineplex.core.account.repository.token.RankUpdateToken; import mineplex.core.account.repository.token.RankUpdateToken;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap; import mineplex.core.database.MinecraftRepository;
import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.DatabaseRunnable; import mineplex.serverdata.database.DatabaseRunnable;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.ResultSetCallable; import mineplex.serverdata.database.ResultSetCallable;
import mineplex.serverdata.database.column.ColumnBoolean; import mineplex.serverdata.database.column.ColumnBoolean;
import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnTimestamp;
import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.database.column.ColumnVarChar;
import mineplex.core.server.remotecall.JsonWebCall;
public class AccountRepository extends MinecraftRepository public class AccountRepository extends MinecraftRepository
{ {
@ -59,24 +57,26 @@ public class AccountRepository extends MinecraftRepository
//executeUpdate(CREATE_ACCOUNT_TABLE); //executeUpdate(CREATE_ACCOUNT_TABLE);
} }
public int login(NautHashMap<String, ILoginProcessor> loginProcessors, LinkedList<IQuerylessLoginProcessor> querylessLoginProcessors, String uuid, String name) public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) throws SQLException
{ {
int accountId = -1; // First we try to grab the account id from cache - this saves an extra trip to database
try ( int accountId = PlayerCache.getInstance().getAccountId(uuid);
Connection connection = getConnection();
Statement statement = connection.createStatement() try (Connection connection = getConnection(); Statement statement = connection.createStatement())
)
{ {
if (accountId <= 0)
{
// Player was not found in cache, we need to grab the account id from database
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;"); statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;");
ResultSet resultSet = statement.getResultSet(); ResultSet resultSet = statement.getResultSet();
while (resultSet.next()) if (resultSet.next())
{ {
accountId = resultSet.getInt(1); accountId = resultSet.getInt(1);
} }
else
if (accountId == -1)
{ {
// Player doesn't exist in our database, add them to the accounts table
final List<Integer> tempList = new ArrayList<Integer>(1); final List<Integer> tempList = new ArrayList<Integer>(1);
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable() executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable()
@ -89,76 +89,35 @@ public class AccountRepository extends MinecraftRepository
tempList.add(resultSet.getInt(1)); tempList.add(resultSet.getInt(1));
} }
} }
},new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 100, name)); }, new ColumnVarChar("uuid", 100, uuid.toString()), new ColumnVarChar("name", 100, name));
accountId = tempList.get(0); accountId = tempList.get(0);
} }
/*
boolean statementStatus = statement.execute(
"UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';"
+ "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"
+ "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = '" + uuid + "';"
+ "SELECT benefit FROM rankBenefits WHERE rankBenefits.uuid = '" + uuid + "';"
+ "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = '" + uuid + "';"
+ "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = '" + uuid + "';"
+ "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';"
);
*/
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE id = '" + accountId + "';";
for (ILoginProcessor loginProcessor : loginProcessors.values())
{
loginString += loginProcessor.getQuery(accountId, uuid, name);
}
statement.execute(loginString);
/*
while (true)
{
if (statementStatus)
{
System.out.println("ResultSet : " + statement.getResultSet().getMetaData().getColumnCount() + " columns:");
for (int i = 0; i < statement.getResultSet().getMetaData().getColumnCount(); i++)
{
System.out.println(statement.getResultSet().getMetaData().getColumnName(i + 1));
}
} }
else else
{ {
if (statement.getUpdateCount() == -1) System.out.println(name + " Loaded Account ID From Cache [" + name + " - " + accountId + "]");
break;
System.out.println("Update statement : " + statement.getUpdateCount() + " rows affected.");
} }
statementStatus = statement.getMoreResults(); final int finalId = accountId;
} final String uuidString = uuid.toString();
System.out.println("Done"); String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE id = '" + accountId + "';";
*/ // We can use a parallel stream because they will be in the correct order when we collect
loginString += loginProcessors.parallelStream().map(processor -> processor.getQuery(finalId, uuidString, name)).collect(Collectors.joining());
statement.execute(loginString);
statement.getUpdateCount(); statement.getUpdateCount();
statement.getMoreResults(); statement.getMoreResults();
for (ILoginProcessor loginProcessor : loginProcessors.values()) for (ILoginProcessor loginProcessor : loginProcessors)
{ {
loginProcessor.processLoginResultSet(name, accountId, statement.getResultSet()); loginProcessor.processLoginResultSet(name, finalId, statement.getResultSet());
statement.getMoreResults(); statement.getMoreResults();
} }
}
for (IQuerylessLoginProcessor loginProcessor : querylessLoginProcessors)
{
loginProcessor.processLogin(name, accountId);
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
return accountId; return accountId;
} }

View File

@ -164,6 +164,43 @@ public enum Achievement
new int[]{10}, new int[]{10},
AchievementCategory.UHC), AchievementCategory.UHC),
//MC League
MC_LEAGUE_STRIKE("First Strike", 600,
new String[] {"MC League.FirstStrike"},
new String[] {"Earn 30 First Bloods"},
new int[] {30},
AchievementCategory.MC_LEAGUE),
MC_LEAGUE_HEAD("Head Hunter", 600,
new String[] {"MC League.HeadHunter"},
new String[] {"Grab 25 Wither Skulls"},
new int[] {25},
AchievementCategory.MC_LEAGUE),
MC_LEAGUE_ALTAR("Altar Builder", 600,
new String[] {"MC League.AltarBuilder"},
new String[] {"Place 50 Wither Skulls", "on your Altar"},
new int[] {50},
AchievementCategory.MC_LEAGUE),
MC_LEAGUE_WINS("Mineplex Champion", 900,
new String[] {"MC League.Wins"},
new String[] {"Win 25 Games"},
new int[] {25},
AchievementCategory.MC_LEAGUE),
MC_LEAGUE_TOWER("Tower Defender", 800,
new String[] {"MC League.TowerDefender"},
new String[] {"Get a double kill", "inside your Active Tower"},
new int[] {1},
AchievementCategory.MC_LEAGUE),
MC_LEAGUE_SAVING("Saving Up", 900,
new String[] {"MC League.SavingUp"},
new String[] {"Craft a Diamond Chestplate"},
new int[] {1},
AchievementCategory.MC_LEAGUE),
//UHC //UHC
WIZARDS_WINS("Supreme Wizard", 600, WIZARDS_WINS("Supreme Wizard", 600,
new String[]{"Wizards.Wins"}, new String[]{"Wizards.Wins"},
@ -880,7 +917,7 @@ public enum Achievement
new int[]{15}, new int[]{15},
AchievementCategory.GLADIATORS), AchievementCategory.GLADIATORS),
TYPE_WARS_SPEED_DEMON("Speed Demon", 1000, /*TYPE_WARS_SPEED_DEMON("Speed Demon", 1000,
new String[]{"Type Wars.Demon"}, new String[]{"Type Wars.Demon"},
new String[]{"Kill 5 Mobs in 8 seconds", "by typing"}, new String[]{"Kill 5 Mobs in 8 seconds", "by typing"},
new int[]{1}, new int[]{1},
@ -914,7 +951,7 @@ public enum Achievement
new String[]{"Type Wars.Wins"}, new String[]{"Type Wars.Wins"},
new String[]{"Win 30 Games"}, new String[]{"Win 30 Games"},
new int[]{30}, new int[]{30},
AchievementCategory.TYPE_WARS), AchievementCategory.TYPE_WARS),*/
SPEED_BUILDERS_SPEED_MASTER("Speed Master", 800, SPEED_BUILDERS_SPEED_MASTER("Speed Master", 800,
new String[]{"Speed Builders.Wins"}, new String[]{"Speed Builders.Wins"},

View File

@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.game.GameCategory;
import mineplex.core.game.GameDisplay; import mineplex.core.game.GameDisplay;
import mineplex.core.stats.PlayerStats; import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
@ -49,6 +50,10 @@ public enum AchievementCategory
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"), Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"),
MC_LEAGUE("MC League", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None"),
WIZARDS("Wizards", null, WIZARDS("Wizards", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit"), Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit"),
@ -159,9 +164,9 @@ public enum AchievementCategory
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_SWORD, 0, GameCategory.ARCADE, null), Material.IRON_SWORD, 0, GameCategory.ARCADE, null),
TYPE_WARS("Type Wars", null, /*TYPE_WARS("Type Wars", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED}, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED},
Material.NAME_TAG, 0, GameCategory.CLASSICS, null), Material.NAME_TAG, 0, GameCategory.CLASSICS, null),*/
SPEED_BUILDERS("Speed Builders", null, SPEED_BUILDERS("Speed Builders", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")}, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")},

View File

@ -11,6 +11,7 @@ import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
@ -30,6 +31,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -202,7 +204,12 @@ public class AntiHack extends MiniPlugin
return true; return true;
} }
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player)) if (player.isFlying() || ((CraftPlayer) player).getHandle().isGliding() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
{
return true;
}
if (UtilInv.IsItem(player.getInventory().getArmorContents()[2], Material.ELYTRA, (byte) 0))
{ {
return true; return true;
} }

View File

@ -33,6 +33,7 @@ import mineplex.core.donation.GiveDonorData;
import mineplex.core.facebook.FacebookManager; import mineplex.core.facebook.FacebookManager;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.ClientItem;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.npc.Npc; import mineplex.core.npc.Npc;
import mineplex.core.npc.NpcManager; import mineplex.core.npc.NpcManager;
@ -72,6 +73,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.EntityCreeper;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
@ -408,7 +410,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (!_enabled) if (!_enabled)
return; return;
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) -1); ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) -1, EntityCreeper.META_FUSE_STATE, -1);
} }
public void IncreaseSize(Entity player) public void IncreaseSize(Entity player)
@ -416,7 +418,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (!_enabled) if (!_enabled)
return; return;
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) 1); ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) 1, EntityCreeper.META_FUSE_STATE, 1);
} }
// DAILY BONUS // DAILY BONUS
@ -473,6 +475,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{ {
if (timeTillRankBonus(player) > 0) if (timeTillRankBonus(player) > 0)
result.run(false); result.run(false);
getRepository().attemptRankBonus(player, new Callback<Boolean>() getRepository().attemptRankBonus(player, new Callback<Boolean>()
{ {
@Override @Override
@ -733,20 +736,23 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (oldChests > 0) if (oldChests > 0)
{ {
_inventoryManager.addItemToInventory(player, TreasureType.OLD.getItemName(), oldChests); //_inventoryManager.addItemToInventory(player, TreasureType.OLD.getItemName(), oldChests);
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(oldChests + " Old Chests"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(oldChests + " Old Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), oldChests));
} }
if (ancientChests > 0) if (ancientChests > 0)
{ {
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(ancientChests + " Ancient Chests"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(ancientChests + " Ancient Chests")));
_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), ancientChests); //_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), ancientChests);
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), ancientChests));
} }
if (mythicalChests > 0) if (mythicalChests > 0)
{ {
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(mythicalChests + " Mythical Chests"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(mythicalChests + " Mythical Chests")));
_inventoryManager.addItemToInventory(player, TreasureType.MYTHICAL.getItemName(), mythicalChests); //_inventoryManager.addItemToInventory(player, TreasureType.MYTHICAL.getItemName(), mythicalChests);
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.MYTHICAL.getItemName()), mythicalChests));
} }
if (gems > 0) if (gems > 0)
@ -758,6 +764,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (gold > 0) if (gold > 0)
{ {
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold")));
/*
_donationManager.rewardGold(new Callback<Boolean>() _donationManager.rewardGold(new Callback<Boolean>()
{ {
@Override @Override
@ -772,6 +779,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
} }
} }
}, "Earned", player.getName(), coreClient.getAccountId(), gold, true); }, "Earned", player.getName(), coreClient.getAccountId(), gold, true);
*/
} }
if (coins > 0) if (coins > 0)
@ -916,7 +924,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (client.getHologram() == null) if (client.getHologram() == null)
{ {
double yAdd = 2.18; double yAdd = 2.3;
hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), ""); hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
hologram.addPlayer(player); hologram.addPlayer(player);
@ -939,9 +947,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{ {
// Charged // Charged
DataWatcher watcher = new DataWatcher(null); DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 0); watcher.a(0, (byte) 0, EntityCreeper.META_ENTITYDATA, (byte) 0);
watcher.a(1, (short) 300); watcher.a(1, (short) 300, EntityCreeper.META_AIR, 0);
watcher.a(17, (byte) 1); watcher.a(17, (byte) 1, EntityCreeper.META_POWERED, true);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata();
packet.a = _carlNpc.getEntity().getEntityId(); packet.a = _carlNpc.getEntity().getEntityId();
packet.b = watcher.c(); packet.b = watcher.c();
@ -958,7 +966,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{ {
// Charged // Charged
DataWatcher watcher = new DataWatcher(null); DataWatcher watcher = new DataWatcher(null);
watcher.a(17, (byte) 0); watcher.a(17, (byte) 0, EntityCreeper.META_POWERED, false);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata();
packet.a = _carlNpc.getEntity().getEntityId(); packet.a = _carlNpc.getEntity().getEntityId();
packet.b = watcher.c(); packet.b = watcher.c();

View File

@ -259,42 +259,48 @@ public class BonusRepository extends MinecraftRepository
public void attemptRankBonus(final Player player, final Callback<Boolean> result) public void attemptRankBonus(final Player player, final Callback<Boolean> result)
{ {
if (!Recharge.Instance.usable(player, "AttemptRankBonus")) { if (!Recharge.Instance.usable(player, "AttemptRankBonus"))
{
result.run(false); result.run(false);
return; return;
} }
final int accountId = _manager.getClientManager().Get(player).getAccountId(); final int accountId = _manager.getClientManager().Get(player).getAccountId();
final int coins = _manager.getRankBonusAmount(player).getCoins(); final int coins = _manager.getRankBonusAmount(player).getCoins();
final int gems = _manager.getRankBonusAmount(player).getGems();
final int mythicalChestChange = _manager.getRankBonusAmount(player).getMythicalChests();
if (!_manager.getRankBonusAmount(player).isGreaterThanZero()) { if (!_manager.getRankBonusAmount(player).isGreaterThanZero())
{
result.run(false); result.run(false);
return; return;
} }
final JavaPlugin plug = _manager.getPlugin(); final JavaPlugin plug = _manager.getPlugin();
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable()
{
@Override @Override
public void run() public void run()
{ {
try (Connection connection = getConnection(); try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_rank(?, ?, ?, ?, ?)}")) { CallableStatement callableStatement = connection.prepareCall("{call rankBonus(?, ?, ?, ?, ?, ?)}"))
{
callableStatement.setInt(1, accountId); callableStatement.setInt(1, accountId);
callableStatement.setInt(2, coins); callableStatement.setInt(2, coins);
callableStatement.setInt(3, 0); callableStatement.setInt(3, gems);
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN); callableStatement.setInt(4, mythicalChestChange);
callableStatement.registerOutParameter(5, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.BOOLEAN);
callableStatement.registerOutParameter(6, java.sql.Types.DATE);
callableStatement.executeUpdate(); callableStatement.executeUpdate();
final boolean pass = callableStatement.getBoolean(4); final boolean pass = callableStatement.getBoolean(5);
final Date date = callableStatement.getDate(5); final Date date = callableStatement.getDate(6);
Bukkit.getScheduler().runTask(plug, new Runnable() {
Bukkit.getScheduler().runTask(plug, new Runnable()
{
@Override @Override
public void run() public void run()
{ {
@ -311,9 +317,12 @@ public class BonusRepository extends MinecraftRepository
} }
} }
}); });
} catch (Exception e) { }
catch (Exception e)
{
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false); Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false);
e.printStackTrace(); e.printStackTrace();
System.out.println("Error : " + e.getMessage());
result.run(false); result.run(false);
} }
} }

View File

@ -153,9 +153,10 @@ public class RankBonusButton implements GuiItem, Listener {
lore.add(" "); lore.add(" ");
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!"); lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
lore.add(ChatColor.WHITE + ""); lore.add(ChatColor.WHITE + "");
lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly"); lore.add(ChatColor.AQUA + "Ultra receives 1 Mythical Chest Monthly");
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly"); lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 2 Mythical Chests Monthly");
lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly"); lore.add(ChatColor.GREEN + "Legend receives 3 Mythical Chests Monthly");
lore.add(ChatColor.RED + "Titan receives 5 Mythical Chests Monthly");
lore.add(ChatColor.WHITE + ""); lore.add(ChatColor.WHITE + "");
lore.add(ChatColor.WHITE + "Purchase a Rank at;"); lore.add(ChatColor.WHITE + "Purchase a Rank at;");
lore.add(ChatColor.WHITE + "www.mineplex.com/shop"); lore.add(ChatColor.WHITE + "www.mineplex.com/shop");

View File

@ -7,9 +7,12 @@ import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
@ -18,24 +21,7 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import mineplex.core.MiniPlugin; import org.apache.commons.lang3.Validate;
import mineplex.core.chat.command.ChatSlowCommand;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.chat.command.BroadcastCommand;
import mineplex.core.chat.command.SilenceCommand;
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.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -48,11 +34,31 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.chat.command.BroadcastCommand;
import mineplex.core.chat.command.ChatSlowCommand;
import mineplex.core.chat.command.SilenceCommand;
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.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class Chat extends MiniPlugin public class Chat extends MiniPlugin
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private PreferencesManager _preferences; private PreferencesManager _preferences;
private AchievementManager _achievements; private AchievementManager _achievements;
private IncognitoManager _incognitoManager;
private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"}; private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"};
private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate"; private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate";
@ -64,12 +70,16 @@ public class Chat extends MiniPlugin
private long _silenced = 0; private long _silenced = 0;
private boolean _threeSecondDelay = true; private boolean _threeSecondDelay = true;
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
private List<Function<AsyncPlayerChatEvent, Boolean>> _lowPriorityFilters = new ArrayList<>();
private HashMap<UUID, MessageData> _playerLastMessage = new HashMap<UUID, MessageData>(); private HashMap<UUID, MessageData> _playerLastMessage = new HashMap<UUID, MessageData>();
public Chat(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName) public Chat(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName)
{ {
super("Chat", plugin); super("Chat", plugin);
_incognitoManager = incognitoManager;
_clientManager = clientManager; _clientManager = clientManager;
_serverName = serverName; _serverName = serverName;
_preferences = preferences; _preferences = preferences;
@ -300,6 +310,22 @@ public class Chat extends MiniPlugin
Player sender = event.getPlayer(); Player sender = event.getPlayer();
if (_incognitoManager != null && _incognitoManager.Get(sender).Status)
{
UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito.");
event.setCancelled(true);
return;
}
for (Function<AsyncPlayerChatEvent, Boolean> filter : _highPriorityFilters)
{
if (filter.apply(event).booleanValue())
{
event.setCancelled(true);
return;
}
}
if (SilenceCheck(sender)) if (SilenceCheck(sender))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -349,6 +375,15 @@ public class Chat extends MiniPlugin
if (!event.isCancelled()) if (!event.isCancelled())
_playerLastMessage.put(sender.getUniqueId(), new MessageData(event.getMessage())); _playerLastMessage.put(sender.getUniqueId(), new MessageData(event.getMessage()));
for (Function<AsyncPlayerChatEvent, Boolean> filter : _lowPriorityFilters)
{
if (filter.apply(event).booleanValue())
{
event.setCancelled(true);
return;
}
}
} }
private boolean msgContainsHack(String msg) private boolean msgContainsHack(String msg)
@ -596,4 +631,22 @@ public class Chat extends MiniPlugin
{ {
_threeSecondDelay = b; _threeSecondDelay = b;
} }
/**
* If the function returns Boolean.TRUE then the message will be CANCELLED.
*/
public void AddFilter(Function<AsyncPlayerChatEvent, Boolean> restriction, FilterPriority priority)
{
Validate.isTrue(priority != null, "Priority must not be null.");
switch (priority)
{
case HIGH:
_highPriorityFilters.add(restriction);
break;
case LOW:
_lowPriorityFilters.add(restriction);
}
}
} }

View File

@ -0,0 +1,7 @@
package mineplex.core.chat;
public enum FilterPriority
{
HIGH,
LOW;
}

View File

@ -83,6 +83,15 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
return; return;
} }
if (_tagName.equalsIgnoreCase("ULTRA"))
{
UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + _tagName + " is a restricted name."));
playDenySound(getPlayer());
getShop().openPageForPlayer(getPlayer(), new PetPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Pets", getPlayer()));
return;
}
PetExtra tag = new PetExtra("Rename " + _pet.GetName() + " to " + _tagName, Material.NAME_TAG, 100); PetExtra tag = new PetExtra("Rename " + _pet.GetName() + " to " + _tagName, Material.NAME_TAG, 100);
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName); _pet.setDisplayName(C.cGreen + "Purchase " + _tagName);

View File

@ -62,4 +62,14 @@ public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
{ {
return new DelayedTaskClient(Bukkit.getPlayer(player)); return new DelayedTaskClient(Bukkit.getPlayer(player));
} }
public boolean HasTask(Player player, String task)
{
return Get(player).getStartTime(task) != -1;
}
public boolean HasTask(String player, String task)
{
return HasTask(Bukkit.getPlayer(player), task);
}
} }

View File

@ -401,17 +401,17 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
disguise(disguise, true, players); disguise(disguise, true, players);
} }
public Packet[] getBedChunkLoadPackets(Player player, Location newLoc) public PacketPlayOutMapChunk[] getBedChunkLoadPackets(Player player, Location newLoc)
{ {
prepareChunk(newLoc); prepareChunk(newLoc);
Packet[] packets = new Packet[2]; PacketPlayOutMapChunk[] packets = new PacketPlayOutMapChunk[2];
// Make unload // Make unload
packets[0] = new PacketPlayOutMapChunk(_bedChunk, true, 0); packets[0] = new PacketPlayOutMapChunk(_bedChunk, true, 0);
// Make load // Make load
packets[1] = new PacketPlayOutMapChunkBulk(Arrays.asList(_bedChunk)); packets[1] = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff');
return packets; return packets;
} }
@ -823,7 +823,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
PacketPlayOutNamedEntitySpawn namePacket = pDisguise.spawnBeforePlayer(player.getLocation()); PacketPlayOutNamedEntitySpawn namePacket = pDisguise.spawnBeforePlayer(player.getLocation());
namePacket.i.watch(0, (byte) 32); namePacket.i.watch(0, (byte) 32, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 32);
handlePacket(namePacket, packetVerifier); handlePacket(namePacket, packetVerifier);

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityAgeable;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public abstract class DisguiseAgeable extends DisguiseCreature public abstract class DisguiseAgeable extends DisguiseCreature
@ -8,14 +10,7 @@ public abstract class DisguiseAgeable extends DisguiseCreature
{ {
super(disguiseType, entity); super(disguiseType, entity);
DataWatcher.a(12, new Byte((byte)0)); DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false);
}
public void UpdateDataWatcher()
{
super.UpdateDataWatcher();
DataWatcher.watch(12, DataWatcher.getByte(12));
} }
public boolean isBaby() public boolean isBaby()
@ -25,6 +20,6 @@ public abstract class DisguiseAgeable extends DisguiseCreature
public void setBaby() public void setBaby()
{ {
DataWatcher.watch(12, new Byte((byte) ( -1 ))); DataWatcher.watch(12, new Byte((byte) ( -1 )), EntityAgeable.META_BABY, true);
} }
} }

View File

@ -2,6 +2,7 @@ package mineplex.core.disguise.disguises;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -13,12 +14,14 @@ public class DisguiseArmorStand extends DisguiseInsentient
{ {
super(entity); super(entity);
DataWatcher.a(10, (byte) 0); DataWatcher.a(10, (byte) 0, EntityArmorStand.META_ARMOR_OPTION, (byte) 0);
for (int i = 11; i < 17; i++) DataWatcher.a(11, new Vector3f(0, 0, 0), EntityArmorStand.META_HEAD_POSE, new Vector3f(0, 0, 0));
{ DataWatcher.a(12, new Vector3f(0, 0, 0), EntityArmorStand.META_BODY_POSE, new Vector3f(0, 0, 0));
DataWatcher.a(i, new Vector3f(0, 0, 0)); DataWatcher.a(13, new Vector3f(0, 0, 0), EntityArmorStand.META_LEFT_ARM_POSE, new Vector3f(0, 0, 0));
} DataWatcher.a(14, new Vector3f(0, 0, 0), EntityArmorStand.META_RIGHT_ARM_POSE, new Vector3f(0, 0, 0));
DataWatcher.a(15, new Vector3f(0, 0, 0), EntityArmorStand.META_LEFT_LEG_POSE, new Vector3f(0, 0, 0));
DataWatcher.a(16, new Vector3f(0, 0, 0), EntityArmorStand.META_RIGHT_LEG_POSE, new Vector3f(0, 0, 0));
// Rotations are from -360 to 360 // Rotations are from -360 to 360
} }
@ -55,6 +58,7 @@ public class DisguiseArmorStand extends DisguiseInsentient
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D; double var2 = 3.9D;
double var4 = 0; double var4 = 0;
@ -103,51 +107,55 @@ public class DisguiseArmorStand extends DisguiseInsentient
public void setBodyPosition(Vector vector) public void setBodyPosition(Vector vector)
{ {
DataWatcher.watch(12, convert(vector)); DataWatcher.watch(12, convert(vector), EntityArmorStand.META_BODY_POSE, convert(vector));
} }
public void setHasArms() public void setHasArms()
{ {
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 4); DataWatcher.watch(10, (byte) (DataWatcher.getByte(10) | 4), EntityArmorStand.META_ARMOR_OPTION,
(byte) (DataWatcher.getByte(10) | 4));
} }
public void setHeadPosition(Vector vector) public void setHeadPosition(Vector vector)
{ {
DataWatcher.watch(11, convert(vector)); DataWatcher.watch(11, convert(vector), EntityArmorStand.META_HEAD_POSE, convert(vector));
} }
public void setLeftArmPosition(Vector vector) public void setLeftArmPosition(Vector vector)
{ {
DataWatcher.watch(13, convert(vector)); DataWatcher.watch(13, convert(vector), EntityArmorStand.META_LEFT_ARM_POSE, convert(vector));
} }
public void setLeftLegPosition(Vector vector) public void setLeftLegPosition(Vector vector)
{ {
DataWatcher.watch(15, convert(vector)); DataWatcher.watch(15, convert(vector), EntityArmorStand.META_LEFT_LEG_POSE, convert(vector));
} }
public void setRemoveBase() public void setRemoveBase()
{ {
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 8); DataWatcher.watch(10, (byte) (DataWatcher.getByte(10) | 8), EntityArmorStand.META_ARMOR_OPTION,
(byte) (DataWatcher.getByte(10) | 8));
} }
public void setRightArmPosition(Vector vector) public void setRightArmPosition(Vector vector)
{ {
DataWatcher.watch(14, convert(vector)); DataWatcher.watch(14, convert(vector), EntityArmorStand.META_RIGHT_ARM_POSE, convert(vector));
} }
public void setRightLegPosition(Vector vector) public void setRightLegPosition(Vector vector)
{ {
DataWatcher.watch(16, convert(vector)); DataWatcher.watch(16, convert(vector), EntityArmorStand.META_RIGHT_LEG_POSE, convert(vector));
} }
public void setSmall() public void setSmall()
{ {
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 1); DataWatcher.watch(10, (byte) (DataWatcher.getByte(10) | 1), EntityArmorStand.META_ARMOR_OPTION,
(byte) (DataWatcher.getByte(10) | 1));
} }
public void setGravityEffected() public void setGravityEffected()
{ {
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 2); DataWatcher.watch(10, (byte) (DataWatcher.getByte(10) | 2), EntityArmorStand.META_ARMOR_OPTION,
(byte) (DataWatcher.getByte(10) | 2));
} }
} }

View File

@ -32,8 +32,8 @@ public abstract class DisguiseBase
DataWatcher = new DataWatcher(new DummyEntity(null)); DataWatcher = new DataWatcher(new DummyEntity(null));
DataWatcher.a(0, Byte.valueOf((byte)0)); DataWatcher.a(0, Byte.valueOf((byte) 0), Entity.META_ENTITYDATA, (byte) 0);
DataWatcher.a(1, Short.valueOf((short)300)); DataWatcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 300);
_soundDisguise = this; _soundDisguise = this;
} }
@ -45,8 +45,8 @@ public abstract class DisguiseBase
public void UpdateDataWatcher() public void UpdateDataWatcher()
{ {
DataWatcher.watch(0, Entity.getDataWatcher().getByte(0)); DataWatcher.watch(0, Entity.getDataWatcher().getByte(0), Entity.META_ENTITYDATA, Entity.getDataWatcher().getByte(0));
DataWatcher.watch(1, Entity.getDataWatcher().getShort(1)); DataWatcher.watch(1, Entity.getDataWatcher().getShort(1), Entity.META_AIR, (int) Entity.getDataWatcher().getShort(1));
} }
public abstract Packet GetSpawnPacket(); public abstract Packet GetSpawnPacket();

View File

@ -1,14 +1,16 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityBat;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseBat extends DisguiseAnimal public class DisguiseBat extends DisguiseCreature
{ {
public DisguiseBat(org.bukkit.entity.Entity entity) public DisguiseBat(org.bukkit.entity.Entity entity)
{ {
super(EntityType.BAT, entity); super(EntityType.BAT, entity);
DataWatcher.a(16, new Byte((byte)0)); DataWatcher.a(16, new Byte((byte) 0), EntityBat.META_UPSIDEDOWN, (byte) 0);
} }
public boolean isSitting() public boolean isSitting()
@ -20,9 +22,9 @@ public class DisguiseBat extends DisguiseAnimal
{ {
int i = DataWatcher.getByte(16); int i = DataWatcher.getByte(16);
if (paramBoolean) if (paramBoolean)
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0x1))); DataWatcher.watch(16, Byte.valueOf((byte) (i | 0x1)), EntityBat.META_UPSIDEDOWN, (byte) (i | 0x1));
else else
DataWatcher.watch(16, Byte.valueOf((byte)(i & 0xFFFFFFFE))); DataWatcher.watch(16, Byte.valueOf((byte) (i & 0xFFFFFFFE)), EntityBat.META_UPSIDEDOWN, (byte) (i & 0xFFFFFFFE));
} }
public String getHurtSound() public String getHurtSound()

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityBlaze;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseBlaze extends DisguiseMonster public class DisguiseBlaze extends DisguiseMonster
@ -8,7 +10,7 @@ public class DisguiseBlaze extends DisguiseMonster
{ {
super(EntityType.BLAZE, entity); super(EntityType.BLAZE, entity);
DataWatcher.a(16, new Byte((byte)0)); DataWatcher.a(16, new Byte((byte) 0), EntityBlaze.META_FIRE, (byte) 0);
} }
public boolean bT() public boolean bT()
@ -21,11 +23,11 @@ public class DisguiseBlaze extends DisguiseMonster
byte b0 = DataWatcher.getByte(16); byte b0 = DataWatcher.getByte(16);
if (flag) if (flag)
b0 = (byte)(b0 | 0x1); b0 = (byte) (b0 | 0x1);
else else
b0 = (byte)(b0 | 0xFFFFFFFE); b0 = (byte) (b0 | 0xFFFFFFFE);
DataWatcher.watch(16, Byte.valueOf(b0)); DataWatcher.watch(16, Byte.valueOf(b0), EntityBlaze.META_FIRE, b0);
} }
public String getHurtSound() public String getHurtSound()

View File

@ -28,7 +28,7 @@ public class DisguiseBlock extends DisguiseBase
public byte GetBlockData() public byte GetBlockData()
{ {
return (byte)_blockData; return (byte) _blockData;
} }
@Override @Override
@ -43,22 +43,29 @@ public class DisguiseBlock extends DisguiseBase
packet.i = MathHelper.d(Entity.yaw * 256.0F / 360.0F); packet.i = MathHelper.d(Entity.yaw * 256.0F / 360.0F);
packet.j = 70; packet.j = 70;
packet.k = _blockId | _blockData << 12; packet.k = _blockId | _blockData << 12;
packet.uuid = Entity.getUniqueID();
double d1 = Entity.motX; double d1 = Entity.motX;
double d2 = Entity.motY; double d2 = Entity.motY;
double d3 = Entity.motZ; double d3 = Entity.motZ;
double d4 = 3.9D; double d4 = 3.9D;
if (d1 < -d4) d1 = -d4; if (d1 < -d4)
if (d2 < -d4) d2 = -d4; d1 = -d4;
if (d3 < -d4) d3 = -d4; if (d2 < -d4)
if (d1 > d4) d1 = d4; d2 = -d4;
if (d2 > d4) d2 = d4; if (d3 < -d4)
if (d3 > d4) d3 = d4; d3 = -d4;
if (d1 > d4)
d1 = d4;
if (d2 > d4)
d2 = d4;
if (d3 > d4)
d3 = d4;
packet.e = ((int)(d1 * 8000.0D)); packet.e = ((int) (d1 * 8000.0D));
packet.f = ((int)(d2 * 8000.0D)); packet.f = ((int) (d2 * 8000.0D));
packet.g = ((int)(d3 * 8000.0D)); packet.g = ((int) (d3 * 8000.0D));
return packet; return packet;
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityOcelot;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseCat extends DisguiseTameableAnimal public class DisguiseCat extends DisguiseTameableAnimal
@ -8,7 +10,7 @@ public class DisguiseCat extends DisguiseTameableAnimal
{ {
super(EntityType.OCELOT, entity); super(EntityType.OCELOT, entity);
DataWatcher.a(18, Byte.valueOf((byte)0)); DataWatcher.a(18, Byte.valueOf((byte) 0), EntityOcelot.META_TYPE, 0);
} }
public int getCatType() public int getCatType()
@ -18,7 +20,7 @@ public class DisguiseCat extends DisguiseTameableAnimal
public void setCatType(int i) public void setCatType(int i)
{ {
DataWatcher.watch(18, Byte.valueOf((byte)i)); DataWatcher.watch(18, Byte.valueOf((byte) i), EntityOcelot.META_TYPE, i);
} }
protected String getHurtSound() protected String getHurtSound()

View File

@ -2,6 +2,8 @@ package mineplex.core.disguise.disguises;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import net.minecraft.server.v1_8_R3.EntitySpider;
public class DisguiseCaveSpider extends DisguiseMonster public class DisguiseCaveSpider extends DisguiseMonster
{ {
@ -9,7 +11,7 @@ public class DisguiseCaveSpider extends DisguiseMonster
{ {
super(EntityType.CAVE_SPIDER, entity); super(EntityType.CAVE_SPIDER, entity);
DataWatcher.a(16, new Byte((byte) 0)); DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0);
} }
public boolean bT() public boolean bT()
@ -26,7 +28,7 @@ public class DisguiseCaveSpider extends DisguiseMonster
else else
b0 = (byte) (b0 & 0xFFFFFFFE); b0 = (byte) (b0 & 0xFFFFFFFE);
DataWatcher.watch(16, Byte.valueOf(b0)); DataWatcher.watch(16, Byte.valueOf(b0), EntitySpider.META_CLIMBING, b0);
} }
protected String getHurtSound() protected String getHurtSound()

View File

@ -33,6 +33,7 @@ public abstract class DisguiseCreature extends DisguiseInsentient
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D; double var2 = 3.9D;
double var4 = 0; double var4 = 0;

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityCreeper;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseCreeper extends DisguiseMonster public class DisguiseCreeper extends DisguiseMonster
@ -8,8 +10,8 @@ public class DisguiseCreeper extends DisguiseMonster
{ {
super(EntityType.CREEPER, entity); super(EntityType.CREEPER, entity);
DataWatcher.a(16, Byte.valueOf((byte)-1)); DataWatcher.a(16, Byte.valueOf((byte) -1), EntityCreeper.META_FUSE_STATE, -1);
DataWatcher.a(17, Byte.valueOf((byte)0)); DataWatcher.a(17, Byte.valueOf((byte) 0), EntityCreeper.META_POWERED, false);
} }
public boolean IsPowered() public boolean IsPowered()
@ -19,7 +21,7 @@ public class DisguiseCreeper extends DisguiseMonster
public void SetPowered(boolean powered) public void SetPowered(boolean powered)
{ {
DataWatcher.watch(17, Byte.valueOf((byte)(powered ? 1 : 0))); DataWatcher.watch(17, Byte.valueOf((byte) (powered ? 1 : 0)), EntityCreeper.META_POWERED, powered);
} }
public int bV() public int bV()
@ -29,7 +31,7 @@ public class DisguiseCreeper extends DisguiseMonster
public void a(int i) public void a(int i)
{ {
DataWatcher.watch(16, Byte.valueOf((byte)i)); DataWatcher.watch(16, Byte.valueOf((byte) i), EntityCreeper.META_FUSE_STATE, i);
} }
protected String getHurtSound() protected String getHurtSound()

View File

@ -2,38 +2,59 @@ package mineplex.core.disguise.disguises;
import java.util.Arrays; import java.util.Arrays;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.EntityEnderman;
import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.MobEffect; import net.minecraft.server.v1_8_R3.MobEffect;
import net.minecraft.server.v1_8_R3.MobEffectList; import net.minecraft.server.v1_8_R3.MobEffectList;
import net.minecraft.server.v1_8_R3.PotionBrewer; import net.minecraft.server.v1_8_R3.PotionBrewer;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import com.google.common.base.Optional;
public class DisguiseEnderman extends DisguiseMonster public class DisguiseEnderman extends DisguiseMonster
{ {
public DisguiseEnderman(org.bukkit.entity.Entity entity) public DisguiseEnderman(org.bukkit.entity.Entity entity)
{ {
super(EntityType.ENDERMAN, entity); super(EntityType.ENDERMAN, entity);
DataWatcher.a(16, new Short( (short) 0)); DataWatcher.a(16, new Short((short) 0), EntityEnderman.META_BLOCK, Optional.<IBlockData> absent());
DataWatcher.a(17, new Byte( (byte) 0)); DataWatcher.a(17, new Byte((byte) 0), EntityEnderman.META_BLOCK, Optional.<IBlockData> absent());
DataWatcher.a(18, new Byte( (byte) 0)); DataWatcher.a(18, new Byte((byte) 0), EntityEnderman.META_ANGRY, false);
int i = PotionBrewer.a(Arrays.asList(new MobEffect(MobEffectList.FIRE_RESISTANCE.id, 777))); int i = PotionBrewer.a(Arrays.asList(new MobEffect(MobEffectList.FIRE_RESISTANCE.id, 777)));
DataWatcher.watch(8, Byte.valueOf((byte)(PotionBrewer.b(Arrays.asList(new MobEffect(MobEffectList.FIRE_RESISTANCE.id, 777))) ? 1 : 0))); DataWatcher.watch(8, Byte.valueOf((byte) (PotionBrewer.b(Arrays.asList(new MobEffect(MobEffectList.FIRE_RESISTANCE.id,
DataWatcher.watch(7, Integer.valueOf(i)); 777))) ? 1 : 0)), EntityLiving.META_AMBIENT_POTION, PotionBrewer.b(Arrays.asList(new MobEffect(
MobEffectList.FIRE_RESISTANCE.id, 777))));
DataWatcher.watch(7, Integer.valueOf(i), EntityLiving.META_POTION_COLOR, i);
} }
public void UpdateDataWatcher() public void UpdateDataWatcher()
{ {
super.UpdateDataWatcher(); super.UpdateDataWatcher();
DataWatcher.watch(0, Byte.valueOf((byte)(DataWatcher.getByte(0) & ~(1 << 0)))); DataWatcher.watch(0, Byte.valueOf((byte) (DataWatcher.getByte(0) & ~(1 << 0))), Entity.META_ENTITYDATA,
DataWatcher.watch(16, DataWatcher.getShort(16)); (byte) (DataWatcher.getByte(0) & ~(1 << 0)));
DataWatcher.watch(16, DataWatcher.getShort(16), EntityEnderman.META_BLOCK, getBlock(DataWatcher.getShort(16)));
}
private Optional<IBlockData> getBlock(int i)
{
Block b = Block.getById(i);
if (b != null && b != Blocks.AIR)
{
return Optional.fromNullable(b.getBlockData());
}
return Optional.fromNullable(null);
} }
public void SetCarriedId(int i) public void SetCarriedId(int i)
{ {
DataWatcher.watch(16, new Short( (short)(i & 0xFF)) ); DataWatcher.watch(16, new Short((short) (i & 0xFF)), EntityEnderman.META_BLOCK, getBlock(i));
} }
public int GetCarriedId() public int GetCarriedId()
@ -43,7 +64,7 @@ public class DisguiseEnderman extends DisguiseMonster
public void SetCarriedData(int i) public void SetCarriedData(int i)
{ {
DataWatcher.watch(17, Byte.valueOf((byte)(i & 0xFF))); DataWatcher.watch(17, Byte.valueOf((byte) (i & 0xFF)), EntityEnderman.META_BLOCK, getBlock(0));
} }
public int GetCarriedData() public int GetCarriedData()
@ -58,7 +79,7 @@ public class DisguiseEnderman extends DisguiseMonster
public void a(boolean flag) public void a(boolean flag)
{ {
DataWatcher.watch(18, Byte.valueOf((byte)(flag ? 1 : 0))); DataWatcher.watch(18, Byte.valueOf((byte) (flag ? 1 : 0)), EntityEnderman.META_ANGRY, flag);
} }
protected String getHurtSound() protected String getHurtSound()

View File

@ -2,23 +2,25 @@ package mineplex.core.disguise.disguises;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import net.minecraft.server.v1_8_R3.EntityGuardian;
public class DisguiseGuardian extends DisguiseCreature public class DisguiseGuardian extends DisguiseCreature
{ {
public DisguiseGuardian(org.bukkit.entity.Entity entity) public DisguiseGuardian(org.bukkit.entity.Entity entity)
{ {
super(EntityType.GUARDIAN, entity); super(EntityType.GUARDIAN, entity);
DataWatcher.a(16, 0); DataWatcher.a(16, 0, EntityGuardian.META_ELDER, (byte) 0);
DataWatcher.a(17, 0); DataWatcher.a(17, 0, EntityGuardian.META_TARGET, 0);
} }
public void setTarget(int target) public void setTarget(int target)
{ {
DataWatcher.watch(17, target); DataWatcher.watch(17, target, EntityGuardian.META_TARGET, target);
} }
public void setElder(boolean elder) public void setElder(boolean elder)
{ {
DataWatcher.watch(16, Integer.valueOf(DataWatcher.getInt(16) | 4)); DataWatcher.watch(16, Integer.valueOf(DataWatcher.getInt(16) | 4), EntityGuardian.META_ELDER, (byte) (DataWatcher.getInt(16) | 4));
} }
public boolean isElder() public boolean isElder()

View File

@ -1,23 +1,29 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.EntityHorse;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import com.google.common.base.Optional;
public class DisguiseHorse extends DisguiseAnimal public class DisguiseHorse extends DisguiseAnimal
{ {
public DisguiseHorse(org.bukkit.entity.Entity entity) public DisguiseHorse(org.bukkit.entity.Entity entity)
{ {
super(EntityType.HORSE, entity); super(EntityType.HORSE, entity);
DataWatcher.a(16, Integer.valueOf(0)); DataWatcher.a(16, Integer.valueOf(0), EntityHorse.META_HORSE_STATE, (byte) 0);
DataWatcher.a(19, Byte.valueOf((byte) 0)); DataWatcher.a(19, Byte.valueOf((byte) 0), EntityHorse.META_TYPE, 0);
DataWatcher.a(20, Integer.valueOf(0)); DataWatcher.a(20, Integer.valueOf(0), EntityHorse.META_VARIANT, 0);
DataWatcher.a(21, String.valueOf("")); DataWatcher.a(21, String.valueOf(""), EntityHorse.META_OWNER, Optional.<UUID> absent());
DataWatcher.a(22, Integer.valueOf(0)); DataWatcher.a(22, Integer.valueOf(0), EntityHorse.META_ARMOR, 0);
} }
public void setType(Horse.Variant horseType) public void setType(Horse.Variant horseType)
{ {
DataWatcher.watch(19, Byte.valueOf((byte) horseType.ordinal())); DataWatcher.watch(19, Byte.valueOf((byte) horseType.ordinal()), EntityHorse.META_TYPE, horseType.ordinal());
} }
public Horse.Variant getType() public Horse.Variant getType()
@ -27,7 +33,7 @@ public class DisguiseHorse extends DisguiseAnimal
public void setVariant(Horse.Color color) public void setVariant(Horse.Color color)
{ {
DataWatcher.watch(20, Integer.valueOf(color.ordinal())); DataWatcher.watch(20, Integer.valueOf(color.ordinal()), EntityHorse.META_VARIANT, color.ordinal());
} }
public Horse.Color getVariant() public Horse.Color getVariant()
@ -35,11 +41,6 @@ public class DisguiseHorse extends DisguiseAnimal
return Horse.Color.values()[DataWatcher.getInt(20)]; return Horse.Color.values()[DataWatcher.getInt(20)];
} }
private boolean w(int i)
{
return (DataWatcher.getInt(16) & i) != 0;
}
public void kick() public void kick()
{ {
b(32, false); b(32, false);
@ -56,28 +57,19 @@ public class DisguiseHorse extends DisguiseAnimal
int j = DataWatcher.getInt(16); int j = DataWatcher.getInt(16);
if (flag) if (flag)
DataWatcher.watch(16, Integer.valueOf(j | i)); DataWatcher.watch(16, Integer.valueOf(j | i), EntityHorse.META_HORSE_STATE, (byte) (j | i));
else else
DataWatcher.watch(16, Integer.valueOf(j & (i ^ 0xFFFFFFFF))); DataWatcher.watch(16, Integer.valueOf(j & (i ^ 0xFFFFFFFF)), EntityHorse.META_HORSE_STATE,
(byte) (j & (i ^ 0xFFFFFFFF)));
} }
public String getOwnerName() public int getArmor()
{
return DataWatcher.getString(21);
}
public void setOwnerName(String s)
{
DataWatcher.watch(21, s);
}
public int cf()
{ {
return DataWatcher.getInt(22); return DataWatcher.getInt(22);
} }
public void r(int i) public void setArmor(int i)
{ {
DataWatcher.watch(22, Integer.valueOf(i)); DataWatcher.watch(22, Integer.valueOf(i), EntityHorse.META_ARMOR, i);
} }
} }

View File

@ -1,14 +1,16 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityHuman;
public abstract class DisguiseHuman extends DisguiseLiving public abstract class DisguiseHuman extends DisguiseLiving
{ {
public DisguiseHuman(org.bukkit.entity.Entity entity) public DisguiseHuman(org.bukkit.entity.Entity entity)
{ {
super(entity); super(entity);
DataWatcher.a(10, (byte) 0); // todo DataWatcher.a(10, (byte) 0, EntityHuman.META_SKIN, (byte) 0); // todo
DataWatcher.a(16, (byte) 0); DataWatcher.a(16, (byte) 1, EntityHuman.META_CAPE, (byte) 1);
DataWatcher.a(17, Float.valueOf(0.0F)); DataWatcher.a(17, Float.valueOf(0.0F), EntityHuman.META_SCALED_HEALTH, 0f);
DataWatcher.a(18, Integer.valueOf(0)); DataWatcher.a(18, Integer.valueOf(0), EntityHuman.META_SCORE, 0);
} }
} }

View File

@ -1,6 +1,8 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import mineplex.core.common.*; import mineplex.core.common.*;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import org.bukkit.*; import org.bukkit.*;
public abstract class DisguiseInsentient extends DisguiseLiving public abstract class DisguiseInsentient extends DisguiseLiving
@ -11,8 +13,8 @@ public abstract class DisguiseInsentient extends DisguiseLiving
{ {
super(entity); super(entity);
DataWatcher.a(3, Byte.valueOf((byte) 0)); DataWatcher.a(3, Byte.valueOf((byte) 0), EntityInsentient.META_CUSTOMNAME_VISIBLE, false);
DataWatcher.a(2, ""); DataWatcher.a(2, "", EntityInsentient.META_CUSTOMNAME, "");
} }
public void setName(String name) public void setName(String name)
@ -30,10 +32,9 @@ public abstract class DisguiseInsentient extends DisguiseLiving
} }
} }
DataWatcher.watch(2, name); DataWatcher.watch(2, name, EntityInsentient.META_CUSTOMNAME, name);
} }
public boolean hasCustomName() public boolean hasCustomName()
{ {
return DataWatcher.getString(2).length() > 0; return DataWatcher.getString(2).length() > 0;
@ -41,7 +42,7 @@ public abstract class DisguiseInsentient extends DisguiseLiving
public void setCustomNameVisible(boolean visible) public void setCustomNameVisible(boolean visible)
{ {
DataWatcher.watch(3, Byte.valueOf((byte)(visible ? 1 : 0))); DataWatcher.watch(3, Byte.valueOf((byte) (visible ? 1 : 0)), EntityInsentient.META_CUSTOMNAME_VISIBLE, visible);
} }
public boolean getCustomNameVisible() public boolean getCustomNameVisible()

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityIronGolem;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseIronGolem extends DisguiseGolem public class DisguiseIronGolem extends DisguiseGolem
@ -8,7 +10,7 @@ public class DisguiseIronGolem extends DisguiseGolem
{ {
super(EntityType.IRON_GOLEM, entity); super(EntityType.IRON_GOLEM, entity);
DataWatcher.a(16, Byte.valueOf((byte)0)); DataWatcher.a(16, Byte.valueOf((byte) 0), EntityIronGolem.META_PLAYER_CREATED, (byte) 0);
} }
public boolean bW() public boolean bW()
@ -21,9 +23,10 @@ public class DisguiseIronGolem extends DisguiseGolem
byte b0 = DataWatcher.getByte(16); byte b0 = DataWatcher.getByte(16);
if (flag) if (flag)
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 0x1))); DataWatcher.watch(16, Byte.valueOf((byte) (b0 | 0x1)), EntityIronGolem.META_PLAYER_CREATED, (byte) (b0 | 0x1));
else else
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 0xFFFFFFFE))); DataWatcher.watch(16, Byte.valueOf((byte) (b0 & 0xFFFFFFFE)), EntityIronGolem.META_PLAYER_CREATED,
(byte) (b0 & 0xFFFFFFFE));
} }
protected String getHurtSound() protected String getHurtSound()

View File

@ -21,10 +21,10 @@ public abstract class DisguiseLiving extends DisguiseBase
{ {
super(entity); super(entity);
DataWatcher.a(6, Float.valueOf(1.0F)); DataWatcher.a(6, Float.valueOf(1.0F), EntityLiving.META_HEALTH, 1F);
DataWatcher.a(7, Integer.valueOf(0)); DataWatcher.a(7, Integer.valueOf(0), EntityLiving.META_POTION_COLOR, 0);
DataWatcher.a(8, Byte.valueOf((byte) 0)); DataWatcher.a(8, Byte.valueOf((byte) 0), EntityLiving.META_AMBIENT_POTION, false);
DataWatcher.a(9, Byte.valueOf((byte) 0)); DataWatcher.a(9, Byte.valueOf((byte) 0), EntityLiving.META_ARROWS, 0);
} }
public ItemStack[] getEquipment() public ItemStack[] getEquipment()
@ -106,16 +106,20 @@ public abstract class DisguiseLiving extends DisguiseBase
byte b0 = DataWatcher.getByte(0); byte b0 = DataWatcher.getByte(0);
if (_invisible) if (_invisible)
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 5))); DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 5)), EntityLiving.META_ENTITYDATA, (byte) (b0 | 1 << 5));
else else
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 5)))); DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 5))), EntityLiving.META_ENTITYDATA, (byte) (b0 & ~(1 << 5)));
if (Entity instanceof EntityLiving) if (Entity instanceof EntityLiving)
{ {
DataWatcher.watch(6, Entity.getDataWatcher().getFloat(6)); DataWatcher.watch(6, Entity.getDataWatcher().getFloat(6), EntityLiving.META_HEALTH,
DataWatcher.watch(7, Entity.getDataWatcher().getInt(7)); Entity.getDataWatcher().getFloat(6));
DataWatcher.watch(8, Entity.getDataWatcher().getByte(8)); DataWatcher.watch(7, Entity.getDataWatcher().getInt(7), EntityLiving.META_POTION_COLOR, Entity.getDataWatcher()
DataWatcher.watch(9, Entity.getDataWatcher().getByte(9)); .getInt(7));
DataWatcher.watch(8, Entity.getDataWatcher().getByte(8), EntityLiving.META_AMBIENT_POTION, Entity.getDataWatcher()
.getByte(8) == 1);
DataWatcher.watch(9, Entity.getDataWatcher().getByte(9), EntityLiving.META_ARROWS, (int) Entity.getDataWatcher()
.getByte(9));
} }
} }
@ -146,7 +150,7 @@ public abstract class DisguiseLiving extends DisguiseBase
public void setHealth(float health) public void setHealth(float health)
{ {
DataWatcher.watch(6, Float.valueOf(health)); DataWatcher.watch(6, Float.valueOf(health), EntityLiving.META_HEALTH, health);
} }
public float getHealth() public float getHealth()

View File

@ -1,5 +1,6 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntitySlime;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -10,12 +11,12 @@ public class DisguiseMagmaCube extends DisguiseInsentient
{ {
super(entity); super(entity);
DataWatcher.a(16, new Byte((byte)1)); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1);
} }
public void SetSize(int i) public void SetSize(int i)
{ {
DataWatcher.watch(16, new Byte((byte)i)); DataWatcher.watch(16, new Byte((byte) i), EntitySlime.META_SIZE, i);
} }
public int GetSize() public int GetSize()
@ -28,12 +29,13 @@ public class DisguiseMagmaCube extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId(); packet.a = Entity.getId();
packet.b = (byte) 62; packet.b = (byte) 62;
packet.c = (int)MathHelper.floor(Entity.locX * 32D); packet.c = (int) MathHelper.floor(Entity.locX * 32D);
packet.d = (int)MathHelper.floor(Entity.locY * 32.0D); packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int)MathHelper.floor(Entity.locZ * 32D); packet.e = (int) MathHelper.floor(Entity.locZ * 32D);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D; double var2 = 3.9D;
double var4 = 0; double var4 = 0;
@ -70,9 +72,9 @@ public class DisguiseMagmaCube extends DisguiseInsentient
var8 = var2; var8 = var2;
} }
packet.f = (int)(var4 * 8000.0D); packet.f = (int) (var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D); packet.g = (int) (var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D); packet.h = (int) (var8 * 8000.0D);
packet.l = DataWatcher; packet.l = DataWatcher;
packet.m = DataWatcher.b(); packet.m = DataWatcher.b();
@ -87,6 +89,6 @@ public class DisguiseMagmaCube extends DisguiseInsentient
protected float getVolume() protected float getVolume()
{ {
return 0.4F * (float)GetSize(); return 0.4F * (float) GetSize();
} }
} }

View File

@ -8,6 +8,7 @@ import org.bukkit.block.BlockFace;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import mineplex.core.common.skin.SkinData; import mineplex.core.common.skin.SkinData;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
@ -72,8 +73,8 @@ public class DisguisePlayer extends DisguiseHuman
} }
/** /**
* Don't use this if the disguise is already on as it will not work the way * Don't use this if the disguise is already on as it will not work the way you want it to. Contact libraryaddict if you need
* you want it to. Contact libraryaddict if you need that added. * that added.
*/ */
public void setSleeping(BlockFace sleeping) public void setSleeping(BlockFace sleeping)
{ {
@ -109,12 +110,11 @@ public class DisguisePlayer extends DisguiseHuman
super.UpdateDataWatcher(); super.UpdateDataWatcher();
byte b0 = DataWatcher.getByte(0); byte b0 = DataWatcher.getByte(0);
DataWatcher.watch(10, (Object)(byte)0x40);
if(_sneaking) if (_sneaking)
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1))); DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)), EntityHuman.META_ENTITYDATA, (byte) (b0 | 1 << 1));
else else
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1)))); DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))), EntityHuman.META_ENTITYDATA, (byte) (b0 & ~(1 << 1)));
} }
public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation) public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation)

View File

@ -1,21 +1,20 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import org.bukkit.entity.EntityType;
import net.minecraft.server.v1_8_R3.EntityRabbit;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
public class DisguiseRabbit extends DisguiseInsentient public class DisguiseRabbit extends DisguiseAnimal
{ {
public DisguiseRabbit(org.bukkit.entity.Entity entity) public DisguiseRabbit(org.bukkit.entity.Entity entity)
{ {
super(entity); super(EntityType.RABBIT, entity);
DataWatcher.a(4, Byte.valueOf((byte) 0)); DataWatcher.a(18, Byte.valueOf((byte) 0), EntityRabbit.META_TYPE, 0);
DataWatcher.a(12, (byte) 0);
DataWatcher.a(15, Byte.valueOf((byte) 0));
DataWatcher.a(18, Byte.valueOf((byte) 0));
} }
@Override @Override
@ -30,6 +29,7 @@ public class DisguiseRabbit extends DisguiseInsentient
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D; double var2 = 3.9D;
double var4 = 0; double var4 = 0;

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntitySheep;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.entity.*; import org.bukkit.entity.*;
@ -9,7 +11,7 @@ public class DisguiseSheep extends DisguiseAnimal
{ {
super(EntityType.SHEEP, entity); super(EntityType.SHEEP, entity);
DataWatcher.a(16, new Byte((byte)0)); DataWatcher.a(16, new Byte((byte) 0), EntitySheep.META_WOOL_STATE, (byte) 0);
} }
public boolean isSheared() public boolean isSheared()
@ -22,9 +24,9 @@ public class DisguiseSheep extends DisguiseAnimal
byte b0 = DataWatcher.getByte(16); byte b0 = DataWatcher.getByte(16);
if (sheared) if (sheared)
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 16))); DataWatcher.watch(16, Byte.valueOf((byte) (b0 | 16)), EntitySheep.META_WOOL_STATE, (byte) (b0 | 16));
else else
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & -17))); DataWatcher.watch(16, Byte.valueOf((byte) (b0 & -17)), EntitySheep.META_WOOL_STATE, (byte) (b0 & -17));
} }
public int getColor() public int getColor()
@ -37,6 +39,7 @@ public class DisguiseSheep extends DisguiseAnimal
{ {
byte b0 = DataWatcher.getByte(16); byte b0 = DataWatcher.getByte(16);
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 240 | color.getWoolData() & 15))); DataWatcher.watch(16, Byte.valueOf((byte) (b0 & 240 | color.getWoolData() & 15)), EntitySheep.META_WOOL_STATE,
(byte) (b0 & 240 | color.getWoolData() & 15));
} }
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntitySkeleton;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.Skeleton.SkeletonType;
@ -9,12 +11,12 @@ public class DisguiseSkeleton extends DisguiseMonster
{ {
super(EntityType.SKELETON, entity); super(EntityType.SKELETON, entity);
DataWatcher.a(13, Byte.valueOf((byte)0)); DataWatcher.a(13, Byte.valueOf((byte) 0), EntitySkeleton.META_TYPE, 0);
} }
public void SetSkeletonType(SkeletonType skeletonType) public void SetSkeletonType(SkeletonType skeletonType)
{ {
DataWatcher.watch(13, Byte.valueOf((byte)skeletonType.getId())); DataWatcher.watch(13, Byte.valueOf((byte) skeletonType.getId()), EntitySkeleton.META_TYPE, skeletonType.getId());
} }
public int GetSkeletonType() public int GetSkeletonType()

View File

@ -1,5 +1,6 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntitySlime;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -10,12 +11,12 @@ public class DisguiseSlime extends DisguiseInsentient
{ {
super(entity); super(entity);
DataWatcher.a(16, new Byte((byte)1)); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1);
} }
public void SetSize(int i) public void SetSize(int i)
{ {
DataWatcher.watch(16, new Byte((byte)i)); DataWatcher.watch(16, new Byte((byte) i), EntitySlime.META_SIZE, i);
} }
public int GetSize() public int GetSize()
@ -29,11 +30,12 @@ public class DisguiseSlime extends DisguiseInsentient
packet.a = Entity.getId(); packet.a = Entity.getId();
packet.b = (byte) 55; packet.b = (byte) 55;
packet.c = (int) MathHelper.floor(Entity.locX * 32D); packet.c = (int) MathHelper.floor(Entity.locX * 32D);
packet.d = (int)MathHelper.floor(Entity.locY * 32.0D); packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int)MathHelper.floor(Entity.locZ * 32D); packet.e = (int) MathHelper.floor(Entity.locZ * 32D);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.uuid = Entity.getUniqueID();
double var2 = 3.9D; double var2 = 3.9D;
double var4 = 0; double var4 = 0;
@ -70,9 +72,9 @@ public class DisguiseSlime extends DisguiseInsentient
var8 = var2; var8 = var2;
} }
packet.f = (int)(var4 * 8000.0D); packet.f = (int) (var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D); packet.g = (int) (var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D); packet.h = (int) (var8 * 8000.0D);
packet.l = DataWatcher; packet.l = DataWatcher;
packet.m = DataWatcher.b(); packet.m = DataWatcher.b();
@ -86,6 +88,6 @@ public class DisguiseSlime extends DisguiseInsentient
protected float getVolume() protected float getVolume()
{ {
return 0.4F * (float)GetSize(); return 0.4F * (float) GetSize();
} }
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntitySpider;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseSpider extends DisguiseMonster public class DisguiseSpider extends DisguiseMonster
@ -8,7 +10,7 @@ public class DisguiseSpider extends DisguiseMonster
{ {
super(EntityType.SPIDER, entity); super(EntityType.SPIDER, entity);
DataWatcher.a(16, new Byte((byte) 0)); DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0);
} }
public boolean bT() public boolean bT()
@ -20,12 +22,12 @@ public class DisguiseSpider extends DisguiseMonster
{ {
byte b0 = DataWatcher.getByte(16); byte b0 = DataWatcher.getByte(16);
if(flag) if (flag)
b0 = (byte) (b0 | 0x1); b0 = (byte) (b0 | 0x1);
else else
b0 = (byte) (b0 & 0xFFFFFFFE); b0 = (byte) (b0 & 0xFFFFFFFE);
DataWatcher.watch(16, Byte.valueOf(b0)); DataWatcher.watch(16, Byte.valueOf(b0), EntitySpider.META_CLIMBING, b0);
} }
protected String getHurtSound() protected String getHurtSound()

View File

@ -7,25 +7,6 @@ public class DisguiseSquid extends DisguiseMonster
public DisguiseSquid(org.bukkit.entity.Entity entity) public DisguiseSquid(org.bukkit.entity.Entity entity)
{ {
super(EntityType.SQUID, entity); super(EntityType.SQUID, entity);
DataWatcher.a(16, new Byte((byte)0));
}
public boolean bT()
{
return (DataWatcher.getByte(16) & 0x01) != 0;
}
public void a(boolean flag)
{
byte b0 = DataWatcher.getByte(16);
if (flag)
b0 = (byte)(b0 | 0x1);
else
b0 = (byte)(b0 & 0xFFFFFFFE);
DataWatcher.watch(16, Byte.valueOf(b0));
} }
protected String getHurtSound() protected String getHurtSound()

View File

@ -1,15 +1,21 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.EntityTameableAnimal;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import com.google.common.base.Optional;
public abstract class DisguiseTameableAnimal extends DisguiseAnimal public abstract class DisguiseTameableAnimal extends DisguiseAnimal
{ {
public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity) public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity)
{ {
super(disguiseType, entity); super(disguiseType, entity);
DataWatcher.a(16, Byte.valueOf((byte)0)); DataWatcher.a(16, Byte.valueOf((byte) 0), EntityTameableAnimal.META_SITTING_TAMED, (byte) 0);
DataWatcher.a(17, ""); DataWatcher.a(17, "", EntityTameableAnimal.META_OWNER, Optional.<UUID> absent());
} }
public boolean isTamed() public boolean isTamed()
@ -22,9 +28,10 @@ public abstract class DisguiseTameableAnimal extends DisguiseAnimal
int i = DataWatcher.getByte(16); int i = DataWatcher.getByte(16);
if (tamed) if (tamed)
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0x4))); DataWatcher.watch(16, Byte.valueOf((byte) (i | 0x4)), EntityTameableAnimal.META_SITTING_TAMED, (byte) (i | 0x4));
else else
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0xFFFFFFFB))); DataWatcher.watch(16, Byte.valueOf((byte) (i | 0xFFFFFFFB)), EntityTameableAnimal.META_SITTING_TAMED,
(byte) (i | 0xFFFFFFFB));
} }
public boolean isSitting() public boolean isSitting()
@ -37,18 +44,10 @@ public abstract class DisguiseTameableAnimal extends DisguiseAnimal
int i = DataWatcher.getByte(16); int i = DataWatcher.getByte(16);
if (sitting) if (sitting)
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0x1))); DataWatcher.watch(16, Byte.valueOf((byte) (i | 0x1)), EntityTameableAnimal.META_SITTING_TAMED, (byte) (i | 0x1));
else else
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0xFFFFFFFE))); DataWatcher.watch(16, Byte.valueOf((byte) (i | 0xFFFFFFFE)), EntityTameableAnimal.META_SITTING_TAMED,
(byte) (i | 0xFFFFFFFE));
} }
public void setOwnerName(String name)
{
DataWatcher.watch(17, name);
}
public String getOwnerName()
{
return DataWatcher.getString(17);
}
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityWitch;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseWitch extends DisguiseMonster public class DisguiseWitch extends DisguiseMonster
@ -8,7 +10,7 @@ public class DisguiseWitch extends DisguiseMonster
{ {
super(EntityType.WITCH, entity); super(EntityType.WITCH, entity);
DataWatcher.a(21, Byte.valueOf((byte)0)); DataWatcher.a(21, Byte.valueOf((byte) 0), EntityWitch.META_AGGRESSIVE, false);
} }
public String getHurtSound() public String getHurtSound()
@ -18,7 +20,7 @@ public class DisguiseWitch extends DisguiseMonster
public void a(boolean flag) public void a(boolean flag)
{ {
DataWatcher.watch(21, Byte.valueOf((byte)(flag ? 1 : 0))); DataWatcher.watch(21, Byte.valueOf((byte) (flag ? 1 : 0)), EntityWitch.META_AGGRESSIVE, flag);
} }
public boolean bT() public boolean bT()

View File

@ -1,18 +1,22 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityWither;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import mineplex.core.common.util.UtilMath;
public class DisguiseWither extends DisguiseMonster public class DisguiseWither extends DisguiseMonster
{ {
public DisguiseWither(org.bukkit.entity.Entity entity) public DisguiseWither(org.bukkit.entity.Entity entity)
{ {
super(EntityType.WITHER, entity); super(EntityType.WITHER, entity);
DataWatcher.a(17, new Integer(0)); DataWatcher.a(17, new Integer(0), EntityWither.META_INVUL_TIME, 0);
DataWatcher.a(18, new Integer(0)); DataWatcher.a(18, new Integer(0), EntityWither.META_TARGET_1, 0);
DataWatcher.a(19, new Integer(0)); DataWatcher.a(19, new Integer(0), EntityWither.META_TARGET_2, 0);
DataWatcher.a(20, new Integer(0)); DataWatcher.a(20, new Integer(0), EntityWither.META_TARGET_3, 0);
} }
public int getInvulTime() public int getInvulTime()
@ -22,16 +26,12 @@ public class DisguiseWither extends DisguiseMonster
public void setInvulTime(int i) public void setInvulTime(int i)
{ {
DataWatcher.watch(20, Integer.valueOf(i)); DataWatcher.watch(17, Integer.valueOf(i), EntityWither.META_INVUL_TIME, i);
DataWatcher.watch(20, Integer.valueOf(i), EntityWither.META_INVUL_TIME, i);
} }
public int t(int i) public int t(int i)
{ {
return DataWatcher.getInt(17 + i); return DataWatcher.getInt(17 + i);
} }
public void b(int i, int j)
{
DataWatcher.watch(17 + i, Integer.valueOf(j));
}
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_8_R3.EntityWolf;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public class DisguiseWolf extends DisguiseTameableAnimal public class DisguiseWolf extends DisguiseTameableAnimal
@ -8,9 +10,9 @@ public class DisguiseWolf extends DisguiseTameableAnimal
{ {
super(EntityType.WOLF, entity); super(EntityType.WOLF, entity);
DataWatcher.a(18, new Float(20F)); DataWatcher.a(18, new Float(20F), EntityWolf.META_WOLF_HEALTH, 20F);
DataWatcher.a(19, new Byte((byte)0)); DataWatcher.a(19, new Byte((byte) 0), EntityWolf.META_BEGGING, false);
DataWatcher.a(20, new Byte((byte)14)); DataWatcher.a(20, new Byte((byte) 14), EntityWolf.META_COLLAR, 14);
} }
public boolean isAngry() public boolean isAngry()
@ -23,9 +25,10 @@ public class DisguiseWolf extends DisguiseTameableAnimal
byte b0 = DataWatcher.getByte(16); byte b0 = DataWatcher.getByte(16);
if (angry) if (angry)
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 0x2))); DataWatcher.watch(16, Byte.valueOf((byte) (b0 | 0x2)), EntityWolf.META_SITTING_TAMED, (byte) (b0 | 0x2));
else else
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 0xFFFFFFFD))); DataWatcher
.watch(16, Byte.valueOf((byte) (b0 & 0xFFFFFFFD)), EntityWolf.META_SITTING_TAMED, (byte) (b0 & 0xFFFFFFFD));
} }
public int getCollarColor() public int getCollarColor()
@ -35,15 +38,15 @@ public class DisguiseWolf extends DisguiseTameableAnimal
public void setCollarColor(int i) public void setCollarColor(int i)
{ {
DataWatcher.watch(20, Byte.valueOf((byte)(i & 0xF))); DataWatcher.watch(20, Byte.valueOf((byte) (i & 0xF)), EntityWolf.META_COLLAR, (i & 0xF));
} }
public void m(boolean flag) public void m(boolean flag)
{ {
if (flag) if (flag)
DataWatcher.watch(19, Byte.valueOf((byte)1)); DataWatcher.watch(19, Byte.valueOf((byte) 1), EntityWolf.META_BEGGING, flag);
else else
DataWatcher.watch(19, Byte.valueOf((byte)0)); DataWatcher.watch(19, Byte.valueOf((byte) 0), EntityWolf.META_BEGGING, flag);
} }
public boolean ce() public boolean ce()

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