Merge pull request #18 from Mineplex-LLC/develop
Update master to code running on the network.
This commit is contained in:
commit
7209ca4522
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@ bin
|
||||
|
||||
MagicMC
|
||||
|
||||
.externalToolBuilders/
|
||||
/Plugins/Mineplex.Core/.externalToolBuilders/Core Builder.launch
|
||||
/Plugins/Mineplex.AntiCheat
|
||||
|
||||
|
21
Patches/Bukkit-Patches/0032-Add-Elytra.patch
Normal file
21
Patches/Bukkit-Patches/0032-Add-Elytra.patch
Normal 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
|
||||
|
46
Patches/Bukkit-Patches/0033-Levitation-potion-effect.patch
Normal file
46
Patches/Bukkit-Patches/0033-Levitation-potion-effect.patch
Normal 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
@ -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
|
||||
|
319
Patches/CraftBukkit-Patches/0180-Current-patch-stuff.patch
Normal file
319
Patches/CraftBukkit-Patches/0180-Current-patch-stuff.patch
Normal 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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -56,12 +56,12 @@ public class MotdManager implements Listener, Runnable
|
||||
//String motdLine = "§f§l◄ §c§lMaintenance§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 = " §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 = " §d§lRank Sale §a§l40% Off");
|
||||
//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");
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class PlayerCache
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Error adding player info in PlayerCache : " + exception.getMessage());
|
||||
// exception.printStackTrace();
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,15 +47,7 @@ public class PlayerCache
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("Getting PlayerCache for " + 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;
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -66,7 +58,18 @@ public class PlayerCache
|
||||
|
||||
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()
|
||||
{
|
||||
_repository.clean();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.common;
|
||||
|
||||
public enum MinecraftVersion
|
||||
{
|
||||
ALL,
|
||||
Version1_9,
|
||||
Version1_8
|
||||
}
|
@ -8,7 +8,7 @@ public class Pair<L, R> implements Serializable {
|
||||
|
||||
private L left;
|
||||
private R right;
|
||||
|
||||
|
||||
public static <L, R> Pair<L, R> create(L left, R right)
|
||||
{
|
||||
return new Pair<L, R>(left, right);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package mineplex.core.common.block.schematic;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import mineplex.core.common.block.DataLocationMap;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
|
||||
public class Schematic
|
||||
{
|
||||
@ -21,8 +24,10 @@ public class Schematic
|
||||
_blockData = blockData;
|
||||
}
|
||||
|
||||
public void paste(Location originLocation)
|
||||
public DataLocationMap paste(Location originLocation, boolean ignoreAir)
|
||||
{
|
||||
DataLocationMap locationMap = new DataLocationMap();
|
||||
|
||||
int startX = originLocation.getBlockX();
|
||||
int startY = originLocation.getBlockY();
|
||||
int startZ = originLocation.getBlockZ();
|
||||
@ -34,21 +39,107 @@ public class Schematic
|
||||
for (int z = 0; z < _length; 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)
|
||||
// not sure why but the math.abs is my simple fix
|
||||
int materialId = Math.abs(_blocks[index]);
|
||||
|
||||
Material material = Material.getMaterial(materialId);
|
||||
if (material == null)
|
||||
if (ignoreAir && materialId == 0) // Air
|
||||
{
|
||||
System.out.println(materialId + " data: " + _blockData[index]);
|
||||
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()
|
||||
@ -61,6 +152,11 @@ public class Schematic
|
||||
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)
|
||||
{
|
||||
return _blocks[getIndex(x, y, z)];
|
||||
@ -99,6 +195,6 @@ public class Schematic
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package mineplex.core.common.function;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Result<T>
|
||||
{
|
||||
public void Get(T result);
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@ import net.minecraft.server.v1_8_R3.NBTTagString;
|
||||
|
||||
public class SkinData
|
||||
{
|
||||
|
||||
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=");
|
||||
@ -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 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;
|
||||
|
||||
public SkinData(String value, String signature)
|
||||
|
@ -75,6 +75,8 @@ public class C
|
||||
public static String chatAdminHead = "" + ChatColor.DARK_PURPLE;
|
||||
public static String chatAdminBody = "" + ChatColor.LIGHT_PURPLE;
|
||||
|
||||
public static String cClansNether = "" + ChatColor.RED;
|
||||
|
||||
public static String listTitle = "" + ChatColor.WHITE;
|
||||
public static String listValue = "" + ChatColor.YELLOW;
|
||||
public static String listValueOn = "" + ChatColor.GREEN;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ public class F
|
||||
{
|
||||
return C.mElem + elem.toString() + ChatColor.RESET + C.mBody;
|
||||
}
|
||||
|
||||
|
||||
public static String name(String elem)
|
||||
{
|
||||
return C.mElem + elem + C.mBody;
|
||||
@ -215,4 +215,9 @@ public class F
|
||||
? "an" : "a";
|
||||
}
|
||||
|
||||
public static String clansNether(String word)
|
||||
{
|
||||
return C.cClansNether + word + C.mBody;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FileUtil
|
||||
public class FileUtil
|
||||
{
|
||||
public static void DeleteFolder(File folder)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -5,11 +5,22 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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>();
|
||||
|
||||
|
||||
public NautArrayList()
|
||||
{
|
||||
}
|
||||
|
||||
public NautArrayList(Elem[] elements)
|
||||
{
|
||||
UtilCollections.addAll(elements, _wrappedArrayList);
|
||||
}
|
||||
|
||||
public boolean add(Elem elem)
|
||||
{
|
||||
return _wrappedArrayList.add(elem);
|
||||
@ -129,4 +140,19 @@ public class NautArrayList<Elem>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,26 @@ package mineplex.core.common.util;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class NautHashMap<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)
|
||||
{
|
||||
return _wrappedHashMap.containsKey(key);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ public class ProfileLoader
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
; // Failed to load skin
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class RGBData
|
||||
{
|
||||
private double _red;
|
||||
@ -50,4 +52,19 @@ public class RGBData
|
||||
+ "green=" + (int) (_green * 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);
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,14 @@ package mineplex.core.common.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
@ -167,6 +171,34 @@ public class UtilAlg
|
||||
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)
|
||||
{
|
||||
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
|
||||
@ -218,7 +250,7 @@ public class UtilAlg
|
||||
return cross(vec, getRight(vec));
|
||||
}
|
||||
|
||||
public static Location getAverageLocation(ArrayList<Location> locs)
|
||||
public static Location getAverageLocation(List<Location> locs)
|
||||
{
|
||||
if (locs.isEmpty())
|
||||
return null;
|
||||
@ -236,8 +268,27 @@ public class UtilAlg
|
||||
|
||||
return vec.toLocation(locs.get(0).getWorld());
|
||||
}
|
||||
|
||||
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, ArrayList<Location> locs)
|
||||
public static Vector getAverageBump(Location source, List<Location> locs)
|
||||
{
|
||||
if (locs.isEmpty())
|
||||
return null;
|
||||
@ -550,4 +601,25 @@ public class UtilAlg
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.common.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Queue;
|
||||
|
||||
import org.bukkit.Location;
|
||||
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.Blocks;
|
||||
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.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftKey;
|
||||
@ -467,7 +469,12 @@ public class UtilBlock
|
||||
|
||||
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)
|
||||
@ -1423,4 +1430,54 @@ public class UtilBlock
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,8 @@ public class UtilColor
|
||||
public static final RGBData RgbRed = hexToRgb(0xee0100);
|
||||
public static final RGBData RgbGold = hexToRgb(0xffd014);
|
||||
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)
|
||||
{
|
||||
@ -84,4 +86,9 @@ public class UtilColor
|
||||
{
|
||||
return (red << 16 | green << 8 | blue);
|
||||
}
|
||||
|
||||
public static RGBData rgb(int r, int g, int b)
|
||||
{
|
||||
return new RGBData(r, g, b);
|
||||
}
|
||||
}
|
||||
|
@ -5,24 +5,6 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
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.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -40,8 +22,29 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
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 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
|
||||
{
|
||||
|
||||
@ -163,7 +166,7 @@ public class UtilEnt
|
||||
|
||||
if (entity instanceof CraftCreature)
|
||||
{
|
||||
EntityCreature creature = ((CraftCreature)entity).getHandle();
|
||||
EntityCreature creature = ((CraftCreature) entity).getHandle();
|
||||
|
||||
if (_bsRestrictionGoal == null)
|
||||
{
|
||||
@ -176,26 +179,26 @@ public class UtilEnt
|
||||
|
||||
if (((CraftEntity)entity).getHandle() instanceof EntityInsentient)
|
||||
{
|
||||
EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle();
|
||||
EntityInsentient creature = (EntityInsentient) ((CraftEntity) entity).getHandle();
|
||||
|
||||
creature.setVegetated(true);
|
||||
creature.setSilent(mute);
|
||||
|
||||
((List) _pathfinderBList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear();
|
||||
((List)_pathfinderCList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear();
|
||||
((List<?>) _pathfinderBList.get(((PathfinderGoalSelector) _goalSelector.get(creature)))).clear();
|
||||
((List<?>) _pathfinderCList.get(((PathfinderGoalSelector) _goalSelector.get(creature)))).clear();
|
||||
|
||||
((List)_pathfinderBList.get(((PathfinderGoalSelector)_targetSelector.get(creature)))).clear();
|
||||
((List)_pathfinderCList.get(((PathfinderGoalSelector)_targetSelector.get(creature)))).clear();
|
||||
((List<?>) _pathfinderBList.get(((PathfinderGoalSelector) _targetSelector.get(creature)))).clear();
|
||||
((List<?>) _pathfinderCList.get(((PathfinderGoalSelector) _targetSelector.get(creature)))).clear();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -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()
|
||||
{
|
||||
if (creatureMap.isEmpty())
|
||||
@ -442,7 +473,7 @@ public class UtilEnt
|
||||
|
||||
if (offset < dR)
|
||||
{
|
||||
ents.put(ent, 1 - (offset/dR));
|
||||
ents.put(ent, Double.valueOf(1 - (offset/dR)));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -451,7 +482,7 @@ public class UtilEnt
|
||||
|
||||
if (offset < dR)
|
||||
{
|
||||
ents.put(ent, 1 - (offset/dR));
|
||||
ents.put(ent, Double.valueOf(1 - (offset/dR)));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -473,7 +504,7 @@ public class UtilEnt
|
||||
|
||||
if (offset < dR)
|
||||
{
|
||||
ents.put(cur, 1 - (offset/dR));
|
||||
ents.put(cur, Double.valueOf(1 - (offset/dR)));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -775,7 +806,7 @@ public class UtilEnt
|
||||
field.setAccessible(true);
|
||||
int entityId = field.getInt(null);
|
||||
if (modifynumber) {
|
||||
field.set(null, entityId+1);
|
||||
field.set(null, Integer.valueOf(entityId + 1));
|
||||
}
|
||||
return entityId;
|
||||
}
|
||||
@ -815,9 +846,37 @@ public class UtilEnt
|
||||
((EntityInsentient)e.getHandle()).k(!ai);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static double getBlockSizeOfSlime(int size)
|
||||
{
|
||||
return .51 * ((double) size);
|
||||
}
|
||||
|
||||
public static boolean inWater(LivingEntity ent)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,310 +1,53 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class UtilFile
|
||||
{
|
||||
public static void writePlainFile(File file, String text) throws FileNotFoundException
|
||||
{
|
||||
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)
|
||||
public static String read(File file)
|
||||
{
|
||||
try
|
||||
{
|
||||
return readToStr(file);
|
||||
return new String(readBytes(file));
|
||||
}
|
||||
catch (IOException exception)
|
||||
catch (IOException e)
|
||||
{
|
||||
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,
|
||||
* if an exception is thrown. Will handle all exceptions, and simply ignore
|
||||
* them and return null. No stack trace printed or anything.
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readIgnoreErrors(String file)
|
||||
public static byte[] readBytes(File file) throws IOException
|
||||
{
|
||||
return readIgnoreErrors(new File(file));
|
||||
}
|
||||
|
||||
public static String readToStr(String file) throws IOException
|
||||
{
|
||||
return readToStr(new File(file));
|
||||
}
|
||||
|
||||
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)
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
|
||||
byte[] bytes = new byte[stream.available() /* estimated bytes available */];
|
||||
|
||||
int pointer = 0;
|
||||
while (true)
|
||||
{
|
||||
chunk.writeTo(stream);
|
||||
int read = stream.read();
|
||||
|
||||
if (read == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
bytes = UtilCollections.ensureSize(bytes, bytes.length + 1);
|
||||
|
||||
bytes[pointer] = (byte) read;
|
||||
|
||||
++pointer;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ public class UtilFirework
|
||||
|
||||
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();
|
||||
|
||||
FireworkMeta data = (FireworkMeta) firework.getFireworkMeta();
|
||||
FireworkMeta data = firework.getFireworkMeta();
|
||||
data.clearEffects();
|
||||
data.setPower(1);
|
||||
data.addEffect(effect);
|
||||
@ -98,4 +98,14 @@ public class UtilFirework
|
||||
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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -396,4 +396,61 @@ public class UtilInv
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -878,6 +878,16 @@ public class UtilItem
|
||||
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)
|
||||
{
|
||||
return material == null ? false : (contains(material, ItemCategory.TOOL));
|
||||
@ -1137,4 +1147,56 @@ public class UtilItem
|
||||
i.setItemMeta(im);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,11 @@ public class UtilMath
|
||||
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)
|
||||
{
|
||||
return num < min ? min : (num > max ? max : num);
|
||||
@ -137,4 +142,145 @@ public class UtilMath
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
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.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PlayerConnection;
|
||||
@ -67,6 +68,11 @@ public class UtilPlayer
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean is1_9(Player player)
|
||||
{
|
||||
return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() > 47;
|
||||
}
|
||||
|
||||
private static class Vector3D
|
||||
{
|
||||
|
||||
@ -336,7 +342,7 @@ public class UtilPlayer
|
||||
{
|
||||
if (cur.getName().equalsIgnoreCase(player))
|
||||
return cur;
|
||||
|
||||
|
||||
if (cur.getName().toLowerCase().contains(player.toLowerCase()))
|
||||
matchList.add(cur);
|
||||
}
|
||||
@ -784,4 +790,37 @@ public class UtilPlayer
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,38 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
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
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
return getServer().getOnlinePlayers().toArray(new Player[0]);
|
||||
@ -52,7 +70,10 @@ public class UtilServer
|
||||
public static void broadcast(String message)
|
||||
{
|
||||
for (Player cur : getPlayers())
|
||||
UtilPlayer.message(cur, message);
|
||||
{
|
||||
if (!UtilServer.CallEvent(new PlayerRecieveBroadcastEvent(cur, message)).isCancelled())
|
||||
UtilPlayer.message(cur, message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void broadcast(LinkedList<String> messages)
|
||||
@ -86,4 +107,116 @@ public class UtilServer
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -11,38 +11,40 @@ public class UtilShapes
|
||||
{
|
||||
private final static BlockFace[] radial =
|
||||
{
|
||||
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
|
||||
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
|
||||
BlockFace.SOUTH,
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return getCircleBlocks(loc, radius, height, hollow, true);
|
||||
}
|
||||
|
||||
private static ArrayList<Location> getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere)
|
||||
public static ArrayList<Location> getSphereBlocks(Location loc, double width, double height, boolean hollow)
|
||||
{
|
||||
ArrayList<Location> circleblocks = new ArrayList<Location>();
|
||||
double cx = loc.getBlockX();
|
||||
double cy = loc.getBlockY();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -51,7 +53,7 @@ public class UtilShapes
|
||||
|
||||
return circleblocks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the block at the exact corners, will return a diagonal.
|
||||
*
|
||||
@ -75,7 +77,8 @@ public class UtilShapes
|
||||
right = radial[high];
|
||||
return new BlockFace[]
|
||||
{
|
||||
left, right
|
||||
left,
|
||||
right
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -87,13 +90,19 @@ public class UtilShapes
|
||||
BlockFace[] faces = getSideBlockFaces(facing);
|
||||
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)
|
||||
{
|
||||
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,
|
||||
@ -133,6 +142,24 @@ public class UtilShapes
|
||||
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)
|
||||
{
|
||||
return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius);
|
||||
@ -157,12 +184,14 @@ public class UtilShapes
|
||||
|
||||
new int[]
|
||||
{
|
||||
allowDiagonal ? facing.getModX() : facing.getModZ(), allowDiagonal ? 0 : -facing.getModX()
|
||||
allowDiagonal ? facing.getModX() : facing.getModZ(),
|
||||
allowDiagonal ? 0 : -facing.getModX()
|
||||
},
|
||||
|
||||
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[1], faces[0]
|
||||
faces[1],
|
||||
faces[0]
|
||||
};
|
||||
}
|
||||
|
||||
@ -228,7 +258,8 @@ public class UtilShapes
|
||||
|
||||
return new Block[]
|
||||
{
|
||||
b.getRelative(faces[0]), b.getRelative(faces[1])
|
||||
b.getRelative(faces[0]),
|
||||
b.getRelative(faces[1])
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -6,14 +6,14 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
|
||||
public class UtilText
|
||||
{
|
||||
@ -614,6 +614,11 @@ public class UtilText
|
||||
|
||||
public static String repeat(String txt, int times)
|
||||
{
|
||||
if (times <= 0)
|
||||
{
|
||||
return new String();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return getProgress(prefix, amount, suffix, progressDirectionSwap, 24);
|
||||
}
|
||||
|
||||
public static String getProgress(String prefix, double amount, String suffix, boolean progressDirectionSwap, int bars)
|
||||
{
|
||||
if (progressDirectionSwap)
|
||||
amount = 1 - amount;
|
||||
|
||||
//Generate Bar
|
||||
int bars = 24;
|
||||
String progressBar = C.cGreen + "";
|
||||
boolean colorChange = false;
|
||||
for (int i=0 ; i<bars ; i++)
|
||||
@ -673,6 +682,20 @@ public class UtilText
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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)
|
||||
{
|
||||
if (players.length == 1 && players[0] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setTimings(fadeInTicks, stayTicks, fadeOutTicks, players);
|
||||
|
||||
display(text, subtitle, players);
|
||||
|
@ -1,8 +1,15 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.DummyEntity;
|
||||
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.PacketPlayOutBossBar;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
|
||||
@ -10,144 +17,220 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
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.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)
|
||||
{
|
||||
displayProgress(text, 1, players);
|
||||
}
|
||||
|
||||
|
||||
public static void displayProgress(String text, double progress, Player... players)
|
||||
{
|
||||
for (Player player : players)
|
||||
displayTextBar(player, progress, text);
|
||||
}
|
||||
|
||||
//Logic
|
||||
|
||||
// Logic
|
||||
public static final int EntityDragonId = 777777;
|
||||
public static final int EntityWitherId = 777778;
|
||||
|
||||
//Display
|
||||
public static final UUID BossUUID = UUID.fromString("178f5cde-2fb0-3e73-8296-967ec7e46748");
|
||||
private static HashMap<String, BukkitRunnable> _lastUpdated = new HashMap<String, BukkitRunnable>();
|
||||
|
||||
// Display
|
||||
public static void displayTextBar(final Player player, double healthPercent, String text)
|
||||
{
|
||||
deleteOld(player);
|
||||
|
||||
healthPercent = Math.min(1, healthPercent);
|
||||
|
||||
//Display Dragon
|
||||
if (_lastUpdated.containsKey(player.getName()))
|
||||
{
|
||||
Location loc = player.getLocation().subtract(0, 200, 0);
|
||||
|
||||
UtilPlayer.sendPacket(player, getDragonPacket(text, healthPercent, loc));
|
||||
_lastUpdated.get(player.getName()).cancel();
|
||||
}
|
||||
|
||||
|
||||
//Display Wither (as well as Dragon)
|
||||
Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(24));
|
||||
|
||||
UtilPlayer.sendPacket(player, getWitherPacket(text, healthPercent, loc));
|
||||
|
||||
//Remove
|
||||
Bukkit.getServer().getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugins()[0], new Runnable()
|
||||
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);
|
||||
|
||||
_lastUpdated.remove(player.getName());
|
||||
}
|
||||
}, 20);
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
UtilPlayer.sendPacket(player, getDragonPacket(text, healthPercent, loc));
|
||||
}
|
||||
|
||||
// Display Wither (as well as Dragon)
|
||||
Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(24));
|
||||
|
||||
UtilPlayer.sendPacket(player, getWitherPacket(text, healthPercent, loc));
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (UtilPlayer.is1_9(player))
|
||||
{
|
||||
PacketPlayOutBossBar bossBar = new PacketPlayOutBossBar();
|
||||
|
||||
bossBar.uuid = BossUUID;
|
||||
bossBar.action = 1;
|
||||
|
||||
UtilPlayer.sendPacket(player, bossBar);
|
||||
return;
|
||||
}
|
||||
// Delete Dragon (All Clients)
|
||||
PacketPlayOutEntityDestroy destroyDragonPacket = new PacketPlayOutEntityDestroy(new int[]
|
||||
{
|
||||
EntityDragonId
|
||||
EntityDragonId
|
||||
});
|
||||
UtilPlayer.sendPacket(player, destroyDragonPacket);
|
||||
|
||||
// Delete Wither (1.8+ Only)
|
||||
PacketPlayOutEntityDestroy destroyWitherPacket = new PacketPlayOutEntityDestroy(new int[]
|
||||
{
|
||||
EntityWitherId
|
||||
EntityWitherId
|
||||
});
|
||||
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)
|
||||
{
|
||||
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
|
||||
|
||||
mobPacket.a = (int) EntityDragonId; //Entity ID
|
||||
mobPacket.b = (byte) EntityType.ENDER_DRAGON.getTypeId(); //Mob type
|
||||
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position
|
||||
mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); //Y position
|
||||
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position
|
||||
mobPacket.f = (byte) 0; //Pitch
|
||||
mobPacket.g = (byte) 0; //Head Pitch
|
||||
mobPacket.h = (byte) 0; //Yaw
|
||||
mobPacket.i = (short) 0; //X velocity
|
||||
mobPacket.j = (short) 0; //Y velocity
|
||||
mobPacket.k = (short) 0; //Z velocity
|
||||
|
||||
//Health
|
||||
mobPacket.a = (int) EntityDragonId; // Entity ID
|
||||
mobPacket.b = (byte) EntityType.ENDER_DRAGON.getTypeId(); // Mob type
|
||||
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); // X position
|
||||
mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); // Y position
|
||||
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); // Z position
|
||||
mobPacket.f = (byte) 0; // Pitch
|
||||
mobPacket.g = (byte) 0; // Head Pitch
|
||||
mobPacket.h = (byte) 0; // Yaw
|
||||
mobPacket.i = (short) 0; // X velocity
|
||||
mobPacket.j = (short) 0; // Y velocity
|
||||
mobPacket.k = (short) 0; // Z velocity
|
||||
mobPacket.uuid = UUID.randomUUID();
|
||||
|
||||
// Health
|
||||
double health = healthPercent * 199.9 + 0.1;
|
||||
//if (halfHealth)
|
||||
// health = healthPercent * 99 + 101;
|
||||
|
||||
//Watcher
|
||||
// if (halfHealth)
|
||||
// health = healthPercent * 99 + 101;
|
||||
|
||||
// Watcher
|
||||
DataWatcher watcher = getWatcher(text, health, loc.getWorld());
|
||||
mobPacket.l = watcher;
|
||||
|
||||
return mobPacket;
|
||||
}
|
||||
|
||||
|
||||
public static PacketPlayOutSpawnEntityLiving getWitherPacket(String text, double healthPercent, Location loc)
|
||||
{
|
||||
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
|
||||
|
||||
mobPacket.a = (int) EntityWitherId; //Entity ID
|
||||
mobPacket.b = (byte) EntityType.WITHER.getTypeId(); //Mob type
|
||||
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position
|
||||
mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); //Y position
|
||||
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position
|
||||
mobPacket.f = (byte) 0; //Pitch
|
||||
mobPacket.g = (byte) 0; //Head Pitch
|
||||
mobPacket.h = (byte) 0; //Yaw
|
||||
mobPacket.i = (short) 0; //X velocity
|
||||
mobPacket.j = (short) 0; //Y velocity
|
||||
mobPacket.k = (short) 0; //Z velocity
|
||||
|
||||
//Health
|
||||
mobPacket.a = (int) EntityWitherId; // Entity ID
|
||||
mobPacket.b = (byte) EntityType.WITHER.getTypeId(); // Mob type
|
||||
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); // X position
|
||||
mobPacket.d = (int) MathHelper.floor(loc.getBlockY() * 32.0D); // Y position
|
||||
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); // Z position
|
||||
mobPacket.f = (byte) 0; // Pitch
|
||||
mobPacket.g = (byte) 0; // Head Pitch
|
||||
mobPacket.h = (byte) 0; // Yaw
|
||||
mobPacket.i = (short) 0; // X velocity
|
||||
mobPacket.j = (short) 0; // Y velocity
|
||||
mobPacket.k = (short) 0; // Z velocity
|
||||
mobPacket.uuid = UUID.randomUUID();
|
||||
|
||||
// Health
|
||||
double health = healthPercent * 299.9 + 0.1;
|
||||
//if (halfHealth)
|
||||
// health = healthPercent * 149 + 151;
|
||||
|
||||
//Watcher
|
||||
// if (halfHealth)
|
||||
// health = healthPercent * 149 + 151;
|
||||
|
||||
// Watcher
|
||||
DataWatcher watcher = getWatcher(text, health, loc.getWorld());
|
||||
mobPacket.l = watcher;
|
||||
|
||||
return mobPacket;
|
||||
}
|
||||
|
||||
|
||||
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(6, (Float) (float) health);
|
||||
watcher.a(2, (String) text); //Entity name
|
||||
watcher.a(3, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show
|
||||
watcher.a(16, (Integer) (int) health); //Health
|
||||
watcher.a(20, (Integer) (int) 881); //Inv
|
||||
|
||||
int i1 = watcher.getByte(0);
|
||||
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
|
||||
watcher.a(0, (Byte) (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5)); // Flags, 0x20 = invisible
|
||||
watcher.a(6, (Float) (float) health, EntityLiving.META_HEALTH, (float) health);
|
||||
watcher.a(2, (String) text, Entity.META_CUSTOMNAME, text); // Entity name
|
||||
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, EntityWither.META); //Health
|
||||
watcher.a(20, (Integer) (int) 881, EntityWither.META_INVUL_TIME, 881); // Inv
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -209,4 +209,5 @@ public class UtilWorld
|
||||
origin.getBlock().getRelative(BlockFace.SOUTH),
|
||||
origin.getBlock().getRelative(BlockFace.WEST));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher;
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.EntityArmorStand;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
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.PacketPlayOutEntityMetadata;
|
||||
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.PacketPlayOutSpawnEntityLiving;
|
||||
|
||||
@ -65,12 +68,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
{
|
||||
super("Custom Tag Fix", plugin);
|
||||
|
||||
packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class,
|
||||
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class,
|
||||
PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class);
|
||||
packetHandler.addPacketHandler(this, true, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class,
|
||||
PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutNamedEntitySpawn.class,
|
||||
PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class, PacketPlayOutNewAttachEntity.class);
|
||||
|
||||
// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
|
||||
// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
|
||||
// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
|
||||
// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
|
||||
NCPHookManager.addHook(CheckType.ALL, this);
|
||||
}
|
||||
|
||||
@ -119,7 +122,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
@EventHandler
|
||||
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()))
|
||||
{
|
||||
_exemptTimeMap.put(event.getPlayer().getUniqueId(),
|
||||
@ -254,15 +258,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
return;
|
||||
}
|
||||
|
||||
int newId = UtilEnt.getNewEntityId();
|
||||
Integer[] ids = new Integer[]
|
||||
{
|
||||
UtilEnt.getNewEntityId(),
|
||||
UtilEnt.getNewEntityId()
|
||||
};
|
||||
|
||||
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
|
||||
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
|
||||
{
|
||||
newId
|
||||
});
|
||||
_entityMap.get(owner.getName()).put(spawnPacket.a, ids);
|
||||
|
||||
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, -1);
|
||||
sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -299,17 +304,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
return;
|
||||
}
|
||||
|
||||
int newId = UtilEnt.getNewEntityId();
|
||||
int newId2 = UtilEnt.getNewEntityId();
|
||||
Integer[] ids = new Integer[]
|
||||
{
|
||||
UtilEnt.getNewEntityId(),
|
||||
UtilEnt.getNewEntityId()
|
||||
};
|
||||
|
||||
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
|
||||
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
|
||||
{
|
||||
newId,
|
||||
newId2
|
||||
});
|
||||
_entityMap.get(owner.getName()).put(spawnPacket.a, ids);
|
||||
|
||||
sendProtocolPackets(owner, spawnPacket.a, newId2, entityName, verifier, true, newId);
|
||||
sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -329,13 +333,13 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
}
|
||||
|
||||
String newName = currentName;
|
||||
boolean newDisplay = isDisplaying;
|
||||
boolean displayName = isDisplaying;
|
||||
|
||||
for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b)
|
||||
{
|
||||
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)
|
||||
@ -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 ((!newName.equals(currentName) && newDisplay) || newDisplay != isDisplaying)
|
||||
if ((!newName.equals(currentName) && displayName) || displayName != isDisplaying)
|
||||
{
|
||||
// If name is still being displayed
|
||||
if (newDisplay)
|
||||
if (displayName)
|
||||
{
|
||||
Integer[] newId;
|
||||
|
||||
@ -361,6 +365,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
{
|
||||
newId = new Integer[]
|
||||
{
|
||||
UtilEnt.getNewEntityId(),
|
||||
UtilEnt.getNewEntityId()
|
||||
};
|
||||
|
||||
@ -368,7 +373,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
}
|
||||
|
||||
_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
|
||||
{ // 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)
|
||||
{
|
||||
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet;
|
||||
int vech = -1;
|
||||
int rider = -1;
|
||||
|
||||
if (packet instanceof PacketPlayOutAttachEntity)
|
||||
{
|
||||
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
|
||||
// When detaching, c is sent, b is -1
|
||||
@ -470,27 +491,27 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
|
||||
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);
|
||||
|
||||
_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),
|
||||
verifier, true, ids.length > 1 ? ids[0] : -1);
|
||||
sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true,
|
||||
ids);
|
||||
}
|
||||
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];
|
||||
|
||||
@ -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,
|
||||
final PacketVerifier packetList, final boolean newPacket, final int squidId)
|
||||
private void sendProtocolPackets(final Player owner, final int entityId, String entityName, final PacketVerifier packetList,
|
||||
final boolean newPacket, final Integer[] entityIds)
|
||||
{
|
||||
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
|
||||
_plugin.getServer().getPluginManager().callEvent(event);
|
||||
@ -519,63 +540,81 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
{
|
||||
DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
|
||||
|
||||
watcher.a(0, (byte) (0 | 1 << 5)); // Invisible
|
||||
watcher.a(1, Short.valueOf((short) 300));
|
||||
watcher.a(2, finalEntityName);
|
||||
watcher.a(3, (byte) 1);
|
||||
watcher.a(4, Byte.valueOf((byte) 0));
|
||||
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
|
||||
watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32); // Invisible
|
||||
watcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 0);
|
||||
watcher.a(2, finalEntityName, Entity.META_CUSTOMNAME, finalEntityName);
|
||||
watcher.a(3, (byte) 1, Entity.META_CUSTOMNAME_VISIBLE, true);
|
||||
watcher.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); // Small
|
||||
|
||||
if (newPacket)
|
||||
{
|
||||
if (squidId >= 0)
|
||||
{
|
||||
watcher.watch(10, (byte) 16);
|
||||
|
||||
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();
|
||||
spawnPacket.a = squidId;
|
||||
spawnPacket.a = entityIds[1];
|
||||
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.uuid = UUID.randomUUID();
|
||||
|
||||
UtilPlayer.sendPacket(owner, spawnPacket);
|
||||
|
||||
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
|
||||
vehiclePacket.a = 0;
|
||||
vehiclePacket.b = spawnPacket.a;
|
||||
vehiclePacket.c = entityId;
|
||||
if (UtilPlayer.is1_9(owner))
|
||||
{
|
||||
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[]
|
||||
{
|
||||
entityIds[1]
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
|
||||
vehiclePacket.a = 0;
|
||||
vehiclePacket.b = spawnPacket.a;
|
||||
vehiclePacket.c = entityId;
|
||||
|
||||
UtilPlayer.sendPacket(owner, vehiclePacket);
|
||||
UtilPlayer.sendPacket(owner, vehiclePacket);
|
||||
}
|
||||
}
|
||||
|
||||
PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
|
||||
spawnPacket.a = newEntityId;
|
||||
spawnPacket.a = entityIds[0];
|
||||
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.uuid = UUID.randomUUID();
|
||||
|
||||
UtilPlayer.sendPacket(owner, spawnPacket);
|
||||
|
||||
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
|
||||
vehiclePacket.a = 0;
|
||||
vehiclePacket.b = spawnPacket.a;
|
||||
vehiclePacket.c = squidId >= 0 ? squidId : entityId;
|
||||
if (UtilPlayer.is1_9(owner))
|
||||
{
|
||||
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[]
|
||||
{
|
||||
entityIds[0]
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
|
||||
vehiclePacket.a = 0;
|
||||
vehiclePacket.b = entityIds[0];
|
||||
vehiclePacket.c = entityIds[1];
|
||||
|
||||
UtilPlayer.sendPacket(owner, vehiclePacket);
|
||||
UtilPlayer.sendPacket(owner, vehiclePacket);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
|
||||
entityMetadata.a = newEntityId;
|
||||
entityMetadata.a = entityIds[0];
|
||||
entityMetadata.b = watcher.c();
|
||||
|
||||
packetList.bypassProcess(entityMetadata);
|
||||
|
@ -15,7 +15,6 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
||||
|
||||
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
|
||||
|
||||
|
||||
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
||||
{
|
||||
super(moduleName, plugin);
|
||||
@ -41,7 +40,7 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
||||
return _clientData.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveData(String name, int accountId) {}
|
||||
|
||||
public DataType Get(Player player)
|
||||
|
@ -1,5 +1,9 @@
|
||||
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.Listener;
|
||||
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.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.thread.ThreadPool;
|
||||
|
||||
public abstract class MiniPlugin implements Listener
|
||||
{
|
||||
@ -19,11 +24,15 @@ public abstract class MiniPlugin implements Listener
|
||||
protected JavaPlugin _plugin;
|
||||
protected NautHashMap<String, ICommand> _commands;
|
||||
|
||||
public MiniPlugin(String moduleName, JavaPlugin plugin)
|
||||
protected long _initializedTime;
|
||||
|
||||
public MiniPlugin(String moduleName, JavaPlugin plugin)
|
||||
{
|
||||
_moduleName = moduleName;
|
||||
_plugin = plugin;
|
||||
|
||||
_initializedTime = System.currentTimeMillis();
|
||||
|
||||
_commands = new NautHashMap<String, ICommand>();
|
||||
|
||||
onEnable();
|
||||
@ -100,12 +109,13 @@ public abstract class MiniPlugin implements Listener
|
||||
|
||||
public void log(String message)
|
||||
{
|
||||
System.out.println(F.main(_moduleName, message));
|
||||
Bukkit.getConsoleSender().sendMessage(F.main(_moduleName, message));
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
@ -49,9 +49,8 @@ public class CoreClientManager extends MiniPlugin
|
||||
private NautHashMap<String, CoreClient> _clientList;
|
||||
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
||||
|
||||
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
||||
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
|
||||
|
||||
private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
|
||||
|
||||
private Object _clientLock = new Object();
|
||||
|
||||
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
||||
@ -185,7 +184,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
if (!LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress()))
|
||||
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.");
|
||||
exception.printStackTrace();
|
||||
@ -260,7 +259,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
CoreClient client = Add(playerName);
|
||||
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
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
@ -332,7 +331,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
CoreClient client = Add(playerName);
|
||||
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
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
@ -373,12 +372,13 @@ public class CoreClientManager extends MiniPlugin
|
||||
_clientLoginLock.put(client.GetPlayerName(), new Object());
|
||||
ClientToken token = null;
|
||||
Gson gson = new Gson();
|
||||
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
|
||||
_clientLoginLock.remove(client.GetPlayerName());
|
||||
}
|
||||
});
|
||||
@ -386,7 +386,8 @@ public class CoreClientManager extends MiniPlugin
|
||||
TimingManager.start(client.GetPlayerName() + " GetClient.");
|
||||
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
|
||||
TimingManager.stop(client.GetPlayerName() + " GetClient.");
|
||||
|
||||
|
||||
TimingManager.start(client.GetPlayerName() + " Event.");
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
||||
@ -395,7 +396,9 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
// JSON sql response
|
||||
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)
|
||||
{
|
||||
try
|
||||
@ -407,6 +410,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
TimingManager.stop(client.GetPlayerName() + " While Loop.");
|
||||
|
||||
if (_clientLoginLock.containsKey(client.GetPlayerName()))
|
||||
{
|
||||
@ -646,14 +650,9 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
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)
|
||||
{
|
||||
CoreClient client = Get(player);
|
||||
@ -662,10 +661,4 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
return client.GetRank().has(rank);
|
||||
}
|
||||
|
||||
public int getCachedClientAccountId(UUID uuid)
|
||||
{
|
||||
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||
return playerInfo == null ? -1 : playerInfo.getAccountId();
|
||||
}
|
||||
}
|
@ -6,30 +6,28 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.cache.player.PlayerCache;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.account.IQuerylessLoginProcessor;
|
||||
import mineplex.core.account.repository.token.LoginToken;
|
||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||
import mineplex.core.common.Rank;
|
||||
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.DatabaseRunnable;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
import mineplex.serverdata.database.column.ColumnTimestamp;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.core.server.remotecall.JsonWebCall;
|
||||
|
||||
public class AccountRepository extends MinecraftRepository
|
||||
{
|
||||
@ -59,100 +57,64 @@ public class AccountRepository extends MinecraftRepository
|
||||
//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)
|
||||
{
|
||||
int accountId = -1;
|
||||
try (
|
||||
Connection connection = getConnection();
|
||||
Statement statement = connection.createStatement()
|
||||
)
|
||||
// First we try to grab the account id from cache - this saves an extra trip to database
|
||||
int accountId = PlayerCache.getInstance().getAccountId(uuid);
|
||||
|
||||
try (Connection connection = getConnection(); Statement statement = connection.createStatement())
|
||||
{
|
||||
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;");
|
||||
ResultSet resultSet = statement.getResultSet();
|
||||
|
||||
while (resultSet.next())
|
||||
if (accountId <= 0)
|
||||
{
|
||||
accountId = resultSet.getInt(1);
|
||||
}
|
||||
|
||||
if (accountId == -1)
|
||||
{
|
||||
final List<Integer> tempList = new ArrayList<Integer>(1);
|
||||
|
||||
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
tempList.add(resultSet.getInt(1));
|
||||
}
|
||||
}
|
||||
},new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 100, name));
|
||||
|
||||
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 + "';"
|
||||
);
|
||||
*/
|
||||
// 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;");
|
||||
ResultSet resultSet = statement.getResultSet();
|
||||
|
||||
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)
|
||||
if (resultSet.next())
|
||||
{
|
||||
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));
|
||||
}
|
||||
accountId = resultSet.getInt(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (statement.getUpdateCount() == -1)
|
||||
break;
|
||||
// Player doesn't exist in our database, add them to the accounts table
|
||||
final List<Integer> tempList = new ArrayList<Integer>(1);
|
||||
|
||||
System.out.println("Update statement : " + statement.getUpdateCount() + " rows affected.");
|
||||
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
tempList.add(resultSet.getInt(1));
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid.toString()), new ColumnVarChar("name", 100, name));
|
||||
|
||||
accountId = tempList.get(0);
|
||||
}
|
||||
|
||||
statementStatus = statement.getMoreResults();
|
||||
}
|
||||
|
||||
System.out.println("Done");
|
||||
*/
|
||||
else
|
||||
{
|
||||
System.out.println(name + " Loaded Account ID From Cache [" + name + " - " + accountId + "]");
|
||||
}
|
||||
|
||||
final int finalId = accountId;
|
||||
final String uuidString = uuid.toString();
|
||||
|
||||
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.getMoreResults();
|
||||
|
||||
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||
{
|
||||
loginProcessor.processLoginResultSet(name, accountId, statement.getResultSet());
|
||||
statement.getMoreResults();
|
||||
}
|
||||
|
||||
for (IQuerylessLoginProcessor loginProcessor : querylessLoginProcessors)
|
||||
for (ILoginProcessor loginProcessor : loginProcessors)
|
||||
{
|
||||
loginProcessor.processLogin(name, accountId);
|
||||
loginProcessor.processLoginResultSet(name, finalId, statement.getResultSet());
|
||||
statement.getMoreResults();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -202,7 +204,12 @@ public class AntiHack extends MiniPlugin
|
||||
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;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import mineplex.core.donation.GiveDonorData;
|
||||
import mineplex.core.facebook.FacebookManager;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.ClientItem;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.npc.Npc;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
@ -72,6 +73,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher;
|
||||
import net.minecraft.server.v1_8_R3.EntityCreeper;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||
|
||||
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
|
||||
@ -408,7 +410,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (!_enabled)
|
||||
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)
|
||||
@ -416,7 +418,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (!_enabled)
|
||||
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
|
||||
@ -473,6 +475,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
if (timeTillRankBonus(player) > 0)
|
||||
result.run(false);
|
||||
|
||||
getRepository().attemptRankBonus(player, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
@ -733,31 +736,35 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
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")));
|
||||
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), mythicalChests));
|
||||
}
|
||||
|
||||
if (ancientChests > 0)
|
||||
{
|
||||
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()), mythicalChests));
|
||||
}
|
||||
|
||||
if (mythicalChests > 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems")));
|
||||
_gemQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), gems));
|
||||
//_gemQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), gems));
|
||||
}
|
||||
|
||||
if (gold > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold")));
|
||||
/*
|
||||
_donationManager.rewardGold(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
@ -772,12 +779,13 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
}
|
||||
}, "Earned", player.getName(), coreClient.getAccountId(), gold, true);
|
||||
*/
|
||||
}
|
||||
|
||||
if (coins > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Treasure Shards")));
|
||||
_coinQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), coins));
|
||||
//_coinQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), coins));
|
||||
}
|
||||
|
||||
if (tickets > 0)
|
||||
@ -916,7 +924,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
if (client.getHologram() == null)
|
||||
{
|
||||
double yAdd = 2.18;
|
||||
double yAdd = 2.3;
|
||||
hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
|
||||
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
|
||||
hologram.addPlayer(player);
|
||||
@ -939,9 +947,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
// Charged
|
||||
DataWatcher watcher = new DataWatcher(null);
|
||||
watcher.a(0, (byte) 0);
|
||||
watcher.a(1, (short) 300);
|
||||
watcher.a(17, (byte) 1);
|
||||
watcher.a(0, (byte) 0, EntityCreeper.META_ENTITYDATA, (byte) 0);
|
||||
watcher.a(1, (short) 300, EntityCreeper.META_AIR, 0);
|
||||
watcher.a(17, (byte) 1, EntityCreeper.META_POWERED, true);
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata();
|
||||
packet.a = _carlNpc.getEntity().getEntityId();
|
||||
packet.b = watcher.c();
|
||||
@ -958,7 +966,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
// Charged
|
||||
DataWatcher watcher = new DataWatcher(null);
|
||||
watcher.a(17, (byte) 0);
|
||||
watcher.a(17, (byte) 0, EntityCreeper.META_POWERED, false);
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata();
|
||||
packet.a = _carlNpc.getEntity().getEntityId();
|
||||
packet.b = watcher.c();
|
||||
|
@ -259,42 +259,48 @@ public class BonusRepository extends MinecraftRepository
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
final JavaPlugin plug = _manager.getPlugin();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
try (Connection connection = getConnection();
|
||||
CallableStatement callableStatement = connection.prepareCall("{call check_rank(?, ?, ?, ?, ?)}")) {
|
||||
CallableStatement callableStatement = connection.prepareCall("{call rankBonus(?, ?, ?, ?, ?, ?)}"))
|
||||
{
|
||||
callableStatement.setInt(1, accountId);
|
||||
callableStatement.setInt(2, coins);
|
||||
callableStatement.setInt(3, 0);
|
||||
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(5, java.sql.Types.DATE);
|
||||
callableStatement.setInt(3, gems);
|
||||
callableStatement.setInt(4, mythicalChestChange);
|
||||
callableStatement.registerOutParameter(5, java.sql.Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(6, java.sql.Types.DATE);
|
||||
|
||||
callableStatement.executeUpdate();
|
||||
|
||||
final boolean pass = callableStatement.getBoolean(4);
|
||||
final boolean pass = callableStatement.getBoolean(5);
|
||||
|
||||
final Date date = callableStatement.getDate(5);
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable() {
|
||||
final Date date = callableStatement.getDate(6);
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable()
|
||||
{
|
||||
@Override
|
||||
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);
|
||||
e.printStackTrace();
|
||||
System.out.println("Error : " + e.getMessage());
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
|
@ -153,9 +153,10 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly");
|
||||
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly");
|
||||
lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly");
|
||||
lore.add(ChatColor.AQUA + "Ultra receives 1 Mythical Chest Monthly");
|
||||
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 2 Mythical Chests 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 + "Purchase a Rank at;");
|
||||
lore.add(ChatColor.WHITE + "www.mineplex.com/shop");
|
||||
|
@ -7,9 +7,12 @@ import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
@ -18,24 +21,7 @@ import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
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.apache.commons.lang3.Validate;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -48,11 +34,31 @@ import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
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
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private PreferencesManager _preferences;
|
||||
private AchievementManager _achievements;
|
||||
private IncognitoManager _incognitoManager;
|
||||
|
||||
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";
|
||||
@ -63,13 +69,17 @@ public class Chat extends MiniPlugin
|
||||
private int _chatSlow = 0;
|
||||
private long _silenced = 0;
|
||||
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>();
|
||||
|
||||
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);
|
||||
|
||||
|
||||
_incognitoManager = incognitoManager;
|
||||
_clientManager = clientManager;
|
||||
_serverName = serverName;
|
||||
_preferences = preferences;
|
||||
@ -299,7 +309,23 @@ public class Chat extends MiniPlugin
|
||||
return;
|
||||
|
||||
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))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@ -346,12 +372,21 @@ public class Chat extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!event.isCancelled())
|
||||
_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)
|
||||
{
|
||||
msg = " " + msg.toLowerCase().replaceAll("[^a-z ]", "") + " ";
|
||||
for (String s : _hackusations) {
|
||||
@ -596,4 +631,22 @@ public class Chat extends MiniPlugin
|
||||
{
|
||||
_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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package mineplex.core.chat;
|
||||
|
||||
public enum FilterPriority
|
||||
{
|
||||
HIGH,
|
||||
LOW;
|
||||
}
|
@ -62,4 +62,14 @@ public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -401,17 +401,17 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
disguise(disguise, true, players);
|
||||
}
|
||||
|
||||
public Packet[] getBedChunkLoadPackets(Player player, Location newLoc)
|
||||
public PacketPlayOutMapChunk[] getBedChunkLoadPackets(Player player, Location newLoc)
|
||||
{
|
||||
prepareChunk(newLoc);
|
||||
|
||||
Packet[] packets = new Packet[2];
|
||||
PacketPlayOutMapChunk[] packets = new PacketPlayOutMapChunk[2];
|
||||
|
||||
// Make unload
|
||||
packets[0] = new PacketPlayOutMapChunk(_bedChunk, true, 0);
|
||||
|
||||
// Make load
|
||||
packets[1] = new PacketPlayOutMapChunkBulk(Arrays.asList(_bedChunk));
|
||||
packets[1] = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff');
|
||||
|
||||
return packets;
|
||||
}
|
||||
@ -823,7 +823,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityAgeable;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public abstract class DisguiseAgeable extends DisguiseCreature
|
||||
@ -8,14 +10,7 @@ public abstract class DisguiseAgeable extends DisguiseCreature
|
||||
{
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(12, new Byte((byte)0));
|
||||
}
|
||||
|
||||
public void UpdateDataWatcher()
|
||||
{
|
||||
super.UpdateDataWatcher();
|
||||
|
||||
DataWatcher.watch(12, DataWatcher.getByte(12));
|
||||
DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false);
|
||||
}
|
||||
|
||||
public boolean isBaby()
|
||||
@ -25,6 +20,6 @@ public abstract class DisguiseAgeable extends DisguiseCreature
|
||||
|
||||
public void setBaby()
|
||||
{
|
||||
DataWatcher.watch(12, new Byte((byte) ( -1 )));
|
||||
DataWatcher.watch(12, new Byte((byte) ( -1 )), EntityAgeable.META_BABY, true);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
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.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
@ -13,12 +14,14 @@ public class DisguiseArmorStand extends DisguiseInsentient
|
||||
{
|
||||
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(i, new Vector3f(0, 0, 0));
|
||||
}
|
||||
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(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
|
||||
}
|
||||
@ -55,6 +58,7 @@ public class DisguiseArmorStand extends DisguiseInsentient
|
||||
packet.i = (byte) ((int) (Entity.yaw * 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.uuid = Entity.getUniqueID();
|
||||
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
@ -103,51 +107,55 @@ public class DisguiseArmorStand extends DisguiseInsentient
|
||||
|
||||
public void setBodyPosition(Vector vector)
|
||||
{
|
||||
DataWatcher.watch(12, convert(vector));
|
||||
DataWatcher.watch(12, convert(vector), EntityArmorStand.META_BODY_POSE, convert(vector));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
DataWatcher.watch(11, convert(vector));
|
||||
DataWatcher.watch(11, convert(vector), EntityArmorStand.META_HEAD_POSE, convert(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)
|
||||
{
|
||||
DataWatcher.watch(15, convert(vector));
|
||||
DataWatcher.watch(15, convert(vector), EntityArmorStand.META_LEFT_LEG_POSE, convert(vector));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
DataWatcher.watch(14, convert(vector));
|
||||
DataWatcher.watch(14, convert(vector), EntityArmorStand.META_RIGHT_ARM_POSE, convert(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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ public abstract class DisguiseBase
|
||||
}
|
||||
|
||||
DataWatcher = new DataWatcher(new DummyEntity(null));
|
||||
|
||||
DataWatcher.a(0, Byte.valueOf((byte)0));
|
||||
DataWatcher.a(1, Short.valueOf((short)300));
|
||||
|
||||
|
||||
DataWatcher.a(0, Byte.valueOf((byte) 0), Entity.META_ENTITYDATA, (byte) 0);
|
||||
DataWatcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 300);
|
||||
|
||||
_soundDisguise = this;
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@ public abstract class DisguiseBase
|
||||
|
||||
public void UpdateDataWatcher()
|
||||
{
|
||||
DataWatcher.watch(0, Entity.getDataWatcher().getByte(0));
|
||||
DataWatcher.watch(1, Entity.getDataWatcher().getShort(1));
|
||||
DataWatcher.watch(0, Entity.getDataWatcher().getByte(0), Entity.META_ENTITYDATA, Entity.getDataWatcher().getByte(0));
|
||||
DataWatcher.watch(1, Entity.getDataWatcher().getShort(1), Entity.META_AIR, (int) Entity.getDataWatcher().getShort(1));
|
||||
}
|
||||
|
||||
public abstract Packet GetSpawnPacket();
|
||||
|
@ -1,30 +1,32 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityBat;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseBat extends DisguiseAnimal
|
||||
public class DisguiseBat extends DisguiseCreature
|
||||
{
|
||||
public DisguiseBat(org.bukkit.entity.Entity 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()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x1) != 0;
|
||||
}
|
||||
|
||||
public void setSitting(boolean paramBoolean)
|
||||
public void setSitting(boolean paramBoolean)
|
||||
{
|
||||
int i = DataWatcher.getByte(16);
|
||||
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
|
||||
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()
|
||||
{
|
||||
return "mob.bat.hurt";
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityBlaze;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseBlaze extends DisguiseMonster
|
||||
@ -7,27 +9,27 @@ public class DisguiseBlaze extends DisguiseMonster
|
||||
public DisguiseBlaze(org.bukkit.entity.Entity 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()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x01) != 0;
|
||||
}
|
||||
|
||||
|
||||
public void a(boolean flag)
|
||||
{
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
|
||||
|
||||
if (flag)
|
||||
b0 = (byte)(b0 | 0x1);
|
||||
b0 = (byte) (b0 | 0x1);
|
||||
else
|
||||
b0 = (byte)(b0 | 0xFFFFFFFE);
|
||||
|
||||
DataWatcher.watch(16, Byte.valueOf(b0));
|
||||
b0 = (byte) (b0 | 0xFFFFFFFE);
|
||||
|
||||
DataWatcher.watch(16, Byte.valueOf(b0), EntityBlaze.META_FIRE, b0);
|
||||
}
|
||||
|
||||
|
||||
public String getHurtSound()
|
||||
{
|
||||
return "mob.blaze.hit";
|
||||
|
@ -9,26 +9,26 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
|
||||
public class DisguiseBlock extends DisguiseBase
|
||||
{
|
||||
private static Random _random = new Random();
|
||||
|
||||
|
||||
private int _blockId;
|
||||
private int _blockData;
|
||||
|
||||
|
||||
public DisguiseBlock(org.bukkit.entity.Entity entity, int blockId, int blockData)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
|
||||
_blockId = blockId;
|
||||
_blockData = blockData;
|
||||
}
|
||||
|
||||
|
||||
public int GetBlockId()
|
||||
{
|
||||
return _blockId;
|
||||
}
|
||||
|
||||
|
||||
public byte GetBlockData()
|
||||
{
|
||||
return (byte)_blockData;
|
||||
return (byte) _blockData;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,38 +43,45 @@ public class DisguiseBlock extends DisguiseBase
|
||||
packet.i = MathHelper.d(Entity.yaw * 256.0F / 360.0F);
|
||||
packet.j = 70;
|
||||
packet.k = _blockId | _blockData << 12;
|
||||
packet.uuid = Entity.getUniqueID();
|
||||
|
||||
double d1 = Entity.motX;
|
||||
double d2 = Entity.motY;
|
||||
double d3 = Entity.motZ;
|
||||
double d4 = 3.9D;
|
||||
|
||||
if (d1 < -d4) d1 = -d4;
|
||||
if (d2 < -d4) d2 = -d4;
|
||||
if (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.f = ((int)(d2 * 8000.0D));
|
||||
packet.g = ((int)(d3 * 8000.0D));
|
||||
|
||||
if (d1 < -d4)
|
||||
d1 = -d4;
|
||||
if (d2 < -d4)
|
||||
d2 = -d4;
|
||||
if (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.f = ((int) (d2 * 8000.0D));
|
||||
packet.g = ((int) (d3 * 8000.0D));
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "damage.hit";
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "damage.hit";
|
||||
}
|
||||
|
||||
protected float getPitch()
|
||||
{
|
||||
return (_random.nextFloat() - _random.nextFloat()) * 0.2F + 1.0F;
|
||||
}
|
||||
protected float getVolume()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
protected float getPitch()
|
||||
{
|
||||
return (_random.nextFloat() - _random.nextFloat()) * 0.2F + 1.0F;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityOcelot;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseCat extends DisguiseTameableAnimal
|
||||
@ -8,21 +10,21 @@ public class DisguiseCat extends DisguiseTameableAnimal
|
||||
{
|
||||
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()
|
||||
{
|
||||
return DataWatcher.getByte(18);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
return "mob.cat.hitt";
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.cat.hitt";
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntitySpider;
|
||||
|
||||
public class DisguiseCaveSpider extends DisguiseMonster
|
||||
{
|
||||
|
||||
@ -9,7 +11,7 @@ public class DisguiseCaveSpider extends DisguiseMonster
|
||||
{
|
||||
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()
|
||||
@ -26,7 +28,7 @@ public class DisguiseCaveSpider extends DisguiseMonster
|
||||
else
|
||||
b0 = (byte) (b0 & 0xFFFFFFFE);
|
||||
|
||||
DataWatcher.watch(16, Byte.valueOf(b0));
|
||||
DataWatcher.watch(16, Byte.valueOf(b0), EntitySpider.META_CLIMBING, b0);
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
|
@ -33,6 +33,7 @@ public abstract class DisguiseCreature extends DisguiseInsentient
|
||||
packet.i = (byte) ((int) (Entity.yaw * 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.uuid = Entity.getUniqueID();
|
||||
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityCreeper;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseCreeper extends DisguiseMonster
|
||||
@ -7,33 +9,33 @@ public class DisguiseCreeper extends DisguiseMonster
|
||||
public DisguiseCreeper(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.CREEPER, entity);
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte)-1));
|
||||
DataWatcher.a(17, Byte.valueOf((byte)0));
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte) -1), EntityCreeper.META_FUSE_STATE, -1);
|
||||
DataWatcher.a(17, Byte.valueOf((byte) 0), EntityCreeper.META_POWERED, false);
|
||||
}
|
||||
|
||||
|
||||
public boolean IsPowered()
|
||||
{
|
||||
return DataWatcher.getByte(17) == 1;
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
return DataWatcher.getByte(16);
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
return "mob.creeper.say";
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.creeper.say";
|
||||
}
|
||||
}
|
||||
|
@ -2,50 +2,71 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
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.MobEffectList;
|
||||
import net.minecraft.server.v1_8_R3.PotionBrewer;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
public class DisguiseEnderman extends DisguiseMonster
|
||||
{
|
||||
public DisguiseEnderman(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.ENDERMAN, entity);
|
||||
|
||||
DataWatcher.a(16, new Short( (short) 0));
|
||||
DataWatcher.a(17, new Byte( (byte) 0));
|
||||
DataWatcher.a(18, new Byte( (byte) 0));
|
||||
|
||||
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(7, Integer.valueOf(i));
|
||||
|
||||
DataWatcher.a(16, new Short((short) 0), EntityEnderman.META_BLOCK, Optional.<IBlockData> absent());
|
||||
DataWatcher.a(17, new Byte((byte) 0), EntityEnderman.META_BLOCK, Optional.<IBlockData> absent());
|
||||
DataWatcher.a(18, new Byte((byte) 0), EntityEnderman.META_ANGRY, false);
|
||||
|
||||
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)), 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()
|
||||
{
|
||||
super.UpdateDataWatcher();
|
||||
|
||||
DataWatcher.watch(0, Byte.valueOf((byte)(DataWatcher.getByte(0) & ~(1 << 0))));
|
||||
DataWatcher.watch(16, DataWatcher.getShort(16));
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (DataWatcher.getByte(0) & ~(1 << 0))), Entity.META_ENTITYDATA,
|
||||
(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)
|
||||
{
|
||||
DataWatcher.watch(16, new Short( (short)(i & 0xFF)) );
|
||||
DataWatcher.watch(16, new Short((short) (i & 0xFF)), EntityEnderman.META_BLOCK, getBlock(i));
|
||||
}
|
||||
|
||||
|
||||
public int GetCarriedId()
|
||||
{
|
||||
return DataWatcher.getByte(16);
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
return DataWatcher.getByte(17);
|
||||
@ -55,14 +76,14 @@ public class DisguiseEnderman extends DisguiseMonster
|
||||
{
|
||||
return DataWatcher.getByte(18) > 0;
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
return "mob.endermen.hit";
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.endermen.hit";
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,25 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityGuardian;
|
||||
|
||||
public class DisguiseGuardian extends DisguiseCreature
|
||||
{
|
||||
public DisguiseGuardian(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.GUARDIAN, entity);
|
||||
DataWatcher.a(16, 0);
|
||||
DataWatcher.a(17, 0);
|
||||
DataWatcher.a(16, 0, EntityGuardian.META_ELDER, (byte) 0);
|
||||
DataWatcher.a(17, 0, EntityGuardian.META_TARGET, 0);
|
||||
}
|
||||
|
||||
public void setTarget(int target)
|
||||
{
|
||||
DataWatcher.watch(17, target);
|
||||
DataWatcher.watch(17, target, EntityGuardian.META_TARGET, target);
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -1,23 +1,29 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityHorse;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
public class DisguiseHorse extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseHorse(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.HORSE, entity);
|
||||
|
||||
DataWatcher.a(16, Integer.valueOf(0));
|
||||
DataWatcher.a(19, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(20, Integer.valueOf(0));
|
||||
DataWatcher.a(21, String.valueOf(""));
|
||||
DataWatcher.a(22, Integer.valueOf(0));
|
||||
DataWatcher.a(16, Integer.valueOf(0), EntityHorse.META_HORSE_STATE, (byte) 0);
|
||||
DataWatcher.a(19, Byte.valueOf((byte) 0), EntityHorse.META_TYPE, 0);
|
||||
DataWatcher.a(20, Integer.valueOf(0), EntityHorse.META_VARIANT, 0);
|
||||
DataWatcher.a(21, String.valueOf(""), EntityHorse.META_OWNER, Optional.<UUID> absent());
|
||||
DataWatcher.a(22, Integer.valueOf(0), EntityHorse.META_ARMOR, 0);
|
||||
}
|
||||
|
||||
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()
|
||||
@ -27,7 +33,7 @@ public class DisguiseHorse extends DisguiseAnimal
|
||||
|
||||
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()
|
||||
@ -35,49 +41,35 @@ public class DisguiseHorse extends DisguiseAnimal
|
||||
return Horse.Color.values()[DataWatcher.getInt(20)];
|
||||
}
|
||||
|
||||
private boolean w(int i)
|
||||
{
|
||||
return (DataWatcher.getInt(16) & i) != 0;
|
||||
}
|
||||
|
||||
public void kick()
|
||||
{
|
||||
b(32, false);
|
||||
b(64, true);
|
||||
b(32, false);
|
||||
b(64, true);
|
||||
}
|
||||
|
||||
|
||||
public void stopKick()
|
||||
{
|
||||
b(64, false);
|
||||
b(64, false);
|
||||
}
|
||||
|
||||
|
||||
private void b(int i, boolean flag)
|
||||
{
|
||||
int j = DataWatcher.getInt(16);
|
||||
|
||||
if (flag)
|
||||
DataWatcher.watch(16, Integer.valueOf(j | i));
|
||||
DataWatcher.watch(16, Integer.valueOf(j | i), EntityHorse.META_HORSE_STATE, (byte) (j | i));
|
||||
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()
|
||||
{
|
||||
return DataWatcher.getString(21);
|
||||
}
|
||||
|
||||
public void setOwnerName(String s)
|
||||
{
|
||||
DataWatcher.watch(21, s);
|
||||
}
|
||||
|
||||
public int cf()
|
||||
public int getArmor()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||
|
||||
public abstract class DisguiseHuman extends DisguiseLiving
|
||||
{
|
||||
public DisguiseHuman(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
DataWatcher.a(10, (byte) 0); // todo
|
||||
DataWatcher.a(16, (byte) 0);
|
||||
DataWatcher.a(17, Float.valueOf(0.0F));
|
||||
DataWatcher.a(18, Integer.valueOf(0));
|
||||
|
||||
DataWatcher.a(10, (byte) 0, EntityHuman.META_SKIN, (byte) 0); // todo
|
||||
DataWatcher.a(16, (byte) 1, EntityHuman.META_CAPE, (byte) 1);
|
||||
DataWatcher.a(17, Float.valueOf(0.0F), EntityHuman.META_SCALED_HEALTH, 0f);
|
||||
DataWatcher.a(18, Integer.valueOf(0), EntityHuman.META_SCORE, 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,27 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import mineplex.core.common.*;
|
||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||
|
||||
import org.bukkit.*;
|
||||
|
||||
public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
{
|
||||
private boolean _showArmor;
|
||||
|
||||
private boolean _showArmor;
|
||||
|
||||
public DisguiseInsentient(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
DataWatcher.a(3, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(2, "");
|
||||
DataWatcher.a(3, Byte.valueOf((byte) 0), EntityInsentient.META_CUSTOMNAME_VISIBLE, false);
|
||||
DataWatcher.a(2, "", EntityInsentient.META_CUSTOMNAME, "");
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setName(name, null);
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name, Rank rank)
|
||||
{
|
||||
if (rank != null)
|
||||
@ -30,35 +32,34 @@ public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
}
|
||||
}
|
||||
|
||||
DataWatcher.watch(2, name);
|
||||
DataWatcher.watch(2, name, EntityInsentient.META_CUSTOMNAME, name);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return DataWatcher.getString(2).length() > 0;
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
return DataWatcher.getByte(11) == 1;
|
||||
}
|
||||
|
||||
|
||||
public boolean armorVisible()
|
||||
{
|
||||
return _showArmor;
|
||||
}
|
||||
|
||||
|
||||
public void showArmor()
|
||||
{
|
||||
_showArmor = true;
|
||||
}
|
||||
|
||||
|
||||
public void hideArmor()
|
||||
{
|
||||
_showArmor = false;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityIronGolem;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseIronGolem extends DisguiseGolem
|
||||
@ -8,26 +10,27 @@ public class DisguiseIronGolem extends DisguiseGolem
|
||||
{
|
||||
super(EntityType.IRON_GOLEM, entity);
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte)0));
|
||||
}
|
||||
|
||||
public boolean bW()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x1) != 0;
|
||||
DataWatcher.a(16, Byte.valueOf((byte) 0), EntityIronGolem.META_PLAYER_CREATED, (byte) 0);
|
||||
}
|
||||
|
||||
public void setPlayerCreated(boolean flag)
|
||||
public boolean bW()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x1) != 0;
|
||||
}
|
||||
|
||||
public void setPlayerCreated(boolean flag)
|
||||
{
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
|
||||
|
||||
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
|
||||
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()
|
||||
{
|
||||
return "mob.irongolem.hit";
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.irongolem.hit";
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ public abstract class DisguiseLiving extends DisguiseBase
|
||||
{
|
||||
super(entity);
|
||||
|
||||
DataWatcher.a(6, Float.valueOf(1.0F));
|
||||
DataWatcher.a(7, Integer.valueOf(0));
|
||||
DataWatcher.a(8, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(9, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(6, Float.valueOf(1.0F), EntityLiving.META_HEALTH, 1F);
|
||||
DataWatcher.a(7, Integer.valueOf(0), EntityLiving.META_POTION_COLOR, 0);
|
||||
DataWatcher.a(8, Byte.valueOf((byte) 0), EntityLiving.META_AMBIENT_POTION, false);
|
||||
DataWatcher.a(9, Byte.valueOf((byte) 0), EntityLiving.META_ARROWS, 0);
|
||||
}
|
||||
|
||||
public ItemStack[] getEquipment()
|
||||
@ -106,16 +106,20 @@ public abstract class DisguiseLiving extends DisguiseBase
|
||||
byte b0 = DataWatcher.getByte(0);
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
DataWatcher.watch(6, Entity.getDataWatcher().getFloat(6));
|
||||
DataWatcher.watch(7, Entity.getDataWatcher().getInt(7));
|
||||
DataWatcher.watch(8, Entity.getDataWatcher().getByte(8));
|
||||
DataWatcher.watch(9, Entity.getDataWatcher().getByte(9));
|
||||
DataWatcher.watch(6, Entity.getDataWatcher().getFloat(6), EntityLiving.META_HEALTH,
|
||||
Entity.getDataWatcher().getFloat(6));
|
||||
DataWatcher.watch(7, Entity.getDataWatcher().getInt(7), EntityLiving.META_POTION_COLOR, Entity.getDataWatcher()
|
||||
.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)
|
||||
{
|
||||
DataWatcher.watch(6, Float.valueOf(health));
|
||||
DataWatcher.watch(6, Float.valueOf(health), EntityLiving.META_HEALTH, health);
|
||||
}
|
||||
|
||||
public float getHealth()
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
@ -10,14 +11,14 @@ public class DisguiseMagmaCube extends DisguiseInsentient
|
||||
{
|
||||
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)
|
||||
{
|
||||
DataWatcher.watch(16, new Byte((byte)i));
|
||||
DataWatcher.watch(16, new Byte((byte) i), EntitySlime.META_SIZE, i);
|
||||
}
|
||||
|
||||
|
||||
public int GetSize()
|
||||
{
|
||||
return DataWatcher.getByte(16);
|
||||
@ -28,65 +29,66 @@ public class DisguiseMagmaCube extends DisguiseInsentient
|
||||
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = (byte) 62;
|
||||
packet.c = (int)MathHelper.floor(Entity.locX * 32D);
|
||||
packet.d = (int)MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = (int)MathHelper.floor(Entity.locZ * 32D);
|
||||
packet.c = (int) MathHelper.floor(Entity.locX * 32D);
|
||||
packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = (int) MathHelper.floor(Entity.locZ * 32D);
|
||||
packet.i = (byte) ((int) (Entity.yaw * 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.uuid = Entity.getUniqueID();
|
||||
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
double var6 = 0;
|
||||
double var8 = 0;
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
double var6 = 0;
|
||||
double var8 = 0;
|
||||
|
||||
if (var4 < -var2)
|
||||
{
|
||||
var4 = -var2;
|
||||
}
|
||||
if (var4 < -var2)
|
||||
{
|
||||
var4 = -var2;
|
||||
}
|
||||
|
||||
if (var6 < -var2)
|
||||
{
|
||||
var6 = -var2;
|
||||
}
|
||||
if (var6 < -var2)
|
||||
{
|
||||
var6 = -var2;
|
||||
}
|
||||
|
||||
if (var8 < -var2)
|
||||
{
|
||||
var8 = -var2;
|
||||
}
|
||||
if (var8 < -var2)
|
||||
{
|
||||
var8 = -var2;
|
||||
}
|
||||
|
||||
if (var4 > var2)
|
||||
{
|
||||
var4 = var2;
|
||||
}
|
||||
if (var4 > var2)
|
||||
{
|
||||
var4 = var2;
|
||||
}
|
||||
|
||||
if (var6 > var2)
|
||||
{
|
||||
var6 = var2;
|
||||
}
|
||||
if (var6 > var2)
|
||||
{
|
||||
var6 = var2;
|
||||
}
|
||||
|
||||
if (var8 > var2)
|
||||
{
|
||||
var8 = var2;
|
||||
}
|
||||
if (var8 > var2)
|
||||
{
|
||||
var8 = var2;
|
||||
}
|
||||
|
||||
packet.f = (int) (var4 * 8000.0D);
|
||||
packet.g = (int) (var6 * 8000.0D);
|
||||
packet.h = (int) (var8 * 8000.0D);
|
||||
|
||||
packet.l = DataWatcher;
|
||||
packet.m = DataWatcher.b();
|
||||
|
||||
packet.f = (int)(var4 * 8000.0D);
|
||||
packet.g = (int)(var6 * 8000.0D);
|
||||
packet.h = (int)(var8 * 8000.0D);
|
||||
|
||||
packet.l = DataWatcher;
|
||||
packet.m = DataWatcher.b();
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.slime." + (GetSize() > 1 ? "big" : "small");
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 0.4F * (float)GetSize();
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.slime." + (GetSize() > 1 ? "big" : "small");
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 0.4F * (float) GetSize();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.block.BlockFace;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
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.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
|
||||
@ -17,31 +18,31 @@ import net.minecraft.server.v1_8_R3.WorldSettings;
|
||||
|
||||
public class DisguisePlayer extends DisguiseHuman
|
||||
{
|
||||
private GameProfile _profile;
|
||||
private boolean _sneaking;
|
||||
private BlockFace _sleeping;
|
||||
private GameProfile _profile;
|
||||
private boolean _sneaking;
|
||||
private BlockFace _sleeping;
|
||||
private boolean _sendSkinToSelf;
|
||||
|
||||
public DisguisePlayer(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
}
|
||||
public DisguisePlayer(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile)
|
||||
{
|
||||
this(entity);
|
||||
public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile)
|
||||
{
|
||||
this(entity);
|
||||
|
||||
setProfile(profile);
|
||||
}
|
||||
setProfile(profile);
|
||||
}
|
||||
|
||||
public void setProfile(GameProfile profile)
|
||||
{
|
||||
GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName());
|
||||
public void setProfile(GameProfile profile)
|
||||
{
|
||||
GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName());
|
||||
|
||||
newProfile.getProperties().putAll(profile.getProperties());
|
||||
newProfile.getProperties().putAll(profile.getProperties());
|
||||
|
||||
_profile = newProfile;
|
||||
}
|
||||
_profile = newProfile;
|
||||
}
|
||||
|
||||
public GameProfile getProfile()
|
||||
{
|
||||
@ -66,28 +67,28 @@ public class DisguisePlayer extends DisguiseHuman
|
||||
return _sendSkinToSelf;
|
||||
}
|
||||
|
||||
public BlockFace getSleepingDirection()
|
||||
{
|
||||
return _sleeping;
|
||||
}
|
||||
public BlockFace getSleepingDirection()
|
||||
{
|
||||
return _sleeping;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 that added.
|
||||
*/
|
||||
public void setSleeping(BlockFace sleeping)
|
||||
{
|
||||
_sleeping = sleeping;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* that added.
|
||||
*/
|
||||
public void setSleeping(BlockFace sleeping)
|
||||
{
|
||||
_sleeping = sleeping;
|
||||
}
|
||||
|
||||
public void setSneaking(boolean sneaking)
|
||||
{
|
||||
_sneaking = sneaking;
|
||||
}
|
||||
|
||||
public boolean getSneaking()
|
||||
{
|
||||
return _sneaking;
|
||||
public void setSneaking(boolean sneaking)
|
||||
{
|
||||
_sneaking = sneaking;
|
||||
}
|
||||
|
||||
public boolean getSneaking()
|
||||
{
|
||||
return _sneaking;
|
||||
}
|
||||
|
||||
public Packet getNewInfoPacket(boolean add)
|
||||
@ -103,56 +104,55 @@ public class DisguisePlayer extends DisguiseHuman
|
||||
return newDisguiseInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateDataWatcher()
|
||||
{
|
||||
super.UpdateDataWatcher();
|
||||
@Override
|
||||
public void UpdateDataWatcher()
|
||||
{
|
||||
super.UpdateDataWatcher();
|
||||
|
||||
byte b0 = DataWatcher.getByte(0);
|
||||
DataWatcher.watch(10, (Object)(byte)0x40);
|
||||
|
||||
if(_sneaking)
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)));
|
||||
else
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))));
|
||||
}
|
||||
byte b0 = DataWatcher.getByte(0);
|
||||
|
||||
public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation)
|
||||
{
|
||||
Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30));
|
||||
loc.setY(Math.max(loc.getY(), 0));
|
||||
if (_sneaking)
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)), EntityHuman.META_ENTITYDATA, (byte) (b0 | 1 << 1));
|
||||
else
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))), EntityHuman.META_ENTITYDATA, (byte) (b0 & ~(1 << 1)));
|
||||
}
|
||||
|
||||
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = _profile.getId();
|
||||
packet.c = MathHelper.floor(loc.getX() * 32.0D);
|
||||
packet.d = MathHelper.floor(loc.getY() * 32.0D);
|
||||
packet.e = MathHelper.floor(loc.getZ() * 32.0D);
|
||||
packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
packet.i = DataWatcher;
|
||||
public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation)
|
||||
{
|
||||
Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30));
|
||||
loc.setY(Math.max(loc.getY(), 0));
|
||||
|
||||
return packet;
|
||||
}
|
||||
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = _profile.getId();
|
||||
packet.c = MathHelper.floor(loc.getX() * 32.0D);
|
||||
packet.d = MathHelper.floor(loc.getY() * 32.0D);
|
||||
packet.e = MathHelper.floor(loc.getZ() * 32.0D);
|
||||
packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
packet.i = DataWatcher;
|
||||
|
||||
@Override
|
||||
public PacketPlayOutNamedEntitySpawn GetSpawnPacket()
|
||||
{
|
||||
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = _profile.getId();
|
||||
packet.c = MathHelper.floor(Entity.locX * 32.0D);
|
||||
packet.d = MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = MathHelper.floor(Entity.locZ * 32.0D);
|
||||
packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
|
||||
packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
|
||||
packet.i = DataWatcher;
|
||||
return packet;
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
@Override
|
||||
public PacketPlayOutNamedEntitySpawn GetSpawnPacket()
|
||||
{
|
||||
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = _profile.getId();
|
||||
packet.c = MathHelper.floor(Entity.locX * 32.0D);
|
||||
packet.d = MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = MathHelper.floor(Entity.locZ * 32.0D);
|
||||
packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
|
||||
packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
|
||||
packet.i = DataWatcher;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _profile.getName();
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _profile.getName();
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityRabbit;
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
|
||||
public class DisguiseRabbit extends DisguiseInsentient
|
||||
public class DisguiseRabbit extends DisguiseAnimal
|
||||
{
|
||||
|
||||
public DisguiseRabbit(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
super(EntityType.RABBIT, entity);
|
||||
|
||||
DataWatcher.a(4, Byte.valueOf((byte) 0));
|
||||
|
||||
DataWatcher.a(12, (byte) 0);
|
||||
DataWatcher.a(15, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(18, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(18, Byte.valueOf((byte) 0), EntityRabbit.META_TYPE, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,6 +29,7 @@ public class DisguiseRabbit extends DisguiseInsentient
|
||||
packet.i = (byte) ((int) (Entity.yaw * 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.uuid = Entity.getUniqueID();
|
||||
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntitySheep;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
@ -9,34 +11,35 @@ public class DisguiseSheep extends DisguiseAnimal
|
||||
{
|
||||
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()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 16) != 0;
|
||||
}
|
||||
|
||||
|
||||
public void setSheared(boolean sheared)
|
||||
{
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
|
||||
if (sheared)
|
||||
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 16)));
|
||||
else
|
||||
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & -17)));
|
||||
if (sheared)
|
||||
DataWatcher.watch(16, Byte.valueOf((byte) (b0 | 16)), EntitySheep.META_WOOL_STATE, (byte) (b0 | 16));
|
||||
else
|
||||
DataWatcher.watch(16, Byte.valueOf((byte) (b0 & -17)), EntitySheep.META_WOOL_STATE, (byte) (b0 & -17));
|
||||
}
|
||||
|
||||
public int getColor()
|
||||
|
||||
public int getColor()
|
||||
{
|
||||
return DataWatcher.getByte(16) & 15;
|
||||
return DataWatcher.getByte(16) & 15;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setColor(DyeColor color)
|
||||
public void setColor(DyeColor color)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntitySkeleton;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
|
||||
@ -8,22 +10,22 @@ public class DisguiseSkeleton extends DisguiseMonster
|
||||
public DisguiseSkeleton(org.bukkit.entity.Entity 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)
|
||||
{
|
||||
DataWatcher.watch(13, Byte.valueOf((byte)skeletonType.getId()));
|
||||
DataWatcher.watch(13, Byte.valueOf((byte) skeletonType.getId()), EntitySkeleton.META_TYPE, skeletonType.getId());
|
||||
}
|
||||
|
||||
|
||||
public int GetSkeletonType()
|
||||
{
|
||||
return DataWatcher.getByte(13);
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.skeleton.hurt";
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.skeleton.hurt";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
@ -10,14 +11,14 @@ public class DisguiseSlime extends DisguiseInsentient
|
||||
{
|
||||
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)
|
||||
{
|
||||
DataWatcher.watch(16, new Byte((byte)i));
|
||||
DataWatcher.watch(16, new Byte((byte) i), EntitySlime.META_SIZE, i);
|
||||
}
|
||||
|
||||
|
||||
public int GetSize()
|
||||
{
|
||||
return DataWatcher.getByte(16);
|
||||
@ -29,63 +30,64 @@ public class DisguiseSlime extends DisguiseInsentient
|
||||
packet.a = Entity.getId();
|
||||
packet.b = (byte) 55;
|
||||
packet.c = (int) MathHelper.floor(Entity.locX * 32D);
|
||||
packet.d = (int)MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = (int)MathHelper.floor(Entity.locZ * 32D);
|
||||
packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = (int) MathHelper.floor(Entity.locZ * 32D);
|
||||
packet.i = (byte) ((int) (Entity.yaw * 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.uuid = Entity.getUniqueID();
|
||||
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
double var6 = 0;
|
||||
double var8 = 0;
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
double var6 = 0;
|
||||
double var8 = 0;
|
||||
|
||||
if (var4 < -var2)
|
||||
{
|
||||
var4 = -var2;
|
||||
}
|
||||
if (var4 < -var2)
|
||||
{
|
||||
var4 = -var2;
|
||||
}
|
||||
|
||||
if (var6 < -var2)
|
||||
{
|
||||
var6 = -var2;
|
||||
}
|
||||
if (var6 < -var2)
|
||||
{
|
||||
var6 = -var2;
|
||||
}
|
||||
|
||||
if (var8 < -var2)
|
||||
{
|
||||
var8 = -var2;
|
||||
}
|
||||
if (var8 < -var2)
|
||||
{
|
||||
var8 = -var2;
|
||||
}
|
||||
|
||||
if (var4 > var2)
|
||||
{
|
||||
var4 = var2;
|
||||
}
|
||||
if (var4 > var2)
|
||||
{
|
||||
var4 = var2;
|
||||
}
|
||||
|
||||
if (var6 > var2)
|
||||
{
|
||||
var6 = var2;
|
||||
}
|
||||
if (var6 > var2)
|
||||
{
|
||||
var6 = var2;
|
||||
}
|
||||
|
||||
if (var8 > var2)
|
||||
{
|
||||
var8 = var2;
|
||||
}
|
||||
if (var8 > var2)
|
||||
{
|
||||
var8 = var2;
|
||||
}
|
||||
|
||||
packet.f = (int)(var4 * 8000.0D);
|
||||
packet.g = (int)(var6 * 8000.0D);
|
||||
packet.h = (int)(var8 * 8000.0D);
|
||||
packet.f = (int) (var4 * 8000.0D);
|
||||
packet.g = (int) (var6 * 8000.0D);
|
||||
packet.h = (int) (var8 * 8000.0D);
|
||||
packet.l = DataWatcher;
|
||||
packet.m = DataWatcher.b();
|
||||
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.slime." + (GetSize() > 1 ? "big" : "small");
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 0.4F * (float)GetSize();
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.slime." + (GetSize() > 1 ? "big" : "small");
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 0.4F * (float) GetSize();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntitySpider;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseSpider extends DisguiseMonster
|
||||
@ -8,7 +10,7 @@ public class DisguiseSpider extends DisguiseMonster
|
||||
{
|
||||
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()
|
||||
@ -20,12 +22,12 @@ public class DisguiseSpider extends DisguiseMonster
|
||||
{
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
|
||||
if(flag)
|
||||
if (flag)
|
||||
b0 = (byte) (b0 | 0x1);
|
||||
else
|
||||
b0 = (byte) (b0 & 0xFFFFFFFE);
|
||||
|
||||
DataWatcher.watch(16, Byte.valueOf(b0));
|
||||
DataWatcher.watch(16, Byte.valueOf(b0), EntitySpider.META_CLIMBING, b0);
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
|
@ -7,34 +7,15 @@ public class DisguiseSquid extends DisguiseMonster
|
||||
public DisguiseSquid(org.bukkit.entity.Entity 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)
|
||||
protected String getHurtSound()
|
||||
{
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
|
||||
if (flag)
|
||||
b0 = (byte)(b0 | 0x1);
|
||||
else
|
||||
b0 = (byte)(b0 & 0xFFFFFFFE);
|
||||
|
||||
DataWatcher.watch(16, Byte.valueOf(b0));
|
||||
return "damage.hit";
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 0.4F;
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "damage.hit";
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 0.4F;
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +1,53 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityTameableAnimal;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
public abstract class DisguiseTameableAnimal extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte)0));
|
||||
DataWatcher.a(17, "");
|
||||
|
||||
DataWatcher.a(16, Byte.valueOf((byte) 0), EntityTameableAnimal.META_SITTING_TAMED, (byte) 0);
|
||||
DataWatcher.a(17, "", EntityTameableAnimal.META_OWNER, Optional.<UUID> absent());
|
||||
}
|
||||
|
||||
|
||||
public boolean isTamed()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x4) != 0;
|
||||
}
|
||||
|
||||
|
||||
public void setTamed(boolean tamed)
|
||||
{
|
||||
int i = DataWatcher.getByte(16);
|
||||
|
||||
|
||||
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
|
||||
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()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x1) != 0;
|
||||
}
|
||||
|
||||
|
||||
public void setSitting(boolean sitting)
|
||||
{
|
||||
int i = DataWatcher.getByte(16);
|
||||
|
||||
|
||||
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
|
||||
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0xFFFFFFFE)));
|
||||
}
|
||||
|
||||
public void setOwnerName(String name)
|
||||
{
|
||||
DataWatcher.watch(17, name);
|
||||
}
|
||||
|
||||
public String getOwnerName()
|
||||
{
|
||||
return DataWatcher.getString(17);
|
||||
DataWatcher.watch(16, Byte.valueOf((byte) (i | 0xFFFFFFFE)), EntityTameableAnimal.META_SITTING_TAMED,
|
||||
(byte) (i | 0xFFFFFFFE));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityWitch;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseWitch extends DisguiseMonster
|
||||
@ -8,21 +10,21 @@ public class DisguiseWitch extends DisguiseMonster
|
||||
{
|
||||
super(EntityType.WITCH, entity);
|
||||
|
||||
DataWatcher.a(21, Byte.valueOf((byte)0));
|
||||
}
|
||||
|
||||
public String getHurtSound()
|
||||
{
|
||||
return "mob.witch.hurt";
|
||||
DataWatcher.a(21, Byte.valueOf((byte) 0), EntityWitch.META_AGGRESSIVE, false);
|
||||
}
|
||||
|
||||
public void a(boolean flag)
|
||||
public String getHurtSound()
|
||||
{
|
||||
DataWatcher.watch(21, Byte.valueOf((byte)(flag ? 1 : 0)));
|
||||
return "mob.witch.hurt";
|
||||
}
|
||||
|
||||
public boolean bT()
|
||||
|
||||
public void a(boolean flag)
|
||||
{
|
||||
return DataWatcher.getByte(21) == 1;
|
||||
DataWatcher.watch(21, Byte.valueOf((byte) (flag ? 1 : 0)), EntityWitch.META_AGGRESSIVE, flag);
|
||||
}
|
||||
|
||||
public boolean bT()
|
||||
{
|
||||
return DataWatcher.getByte(21) == 1;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,37 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityWither;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
public class DisguiseWither extends DisguiseMonster
|
||||
{
|
||||
public DisguiseWither(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.WITHER, entity);
|
||||
|
||||
DataWatcher.a(17, new Integer(0));
|
||||
DataWatcher.a(18, new Integer(0));
|
||||
DataWatcher.a(19, new Integer(0));
|
||||
DataWatcher.a(20, new Integer(0));
|
||||
|
||||
DataWatcher.a(17, new Integer(0), EntityWither.META_INVUL_TIME, 0);
|
||||
DataWatcher.a(18, new Integer(0), EntityWither.META_TARGET_1, 0);
|
||||
DataWatcher.a(19, new Integer(0), EntityWither.META_TARGET_2, 0);
|
||||
DataWatcher.a(20, new Integer(0), EntityWither.META_TARGET_3, 0);
|
||||
}
|
||||
|
||||
public int getInvulTime()
|
||||
{
|
||||
return DataWatcher.getInt(20);
|
||||
}
|
||||
|
||||
public void setInvulTime(int i)
|
||||
{
|
||||
DataWatcher.watch(20, Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public int t(int i)
|
||||
{
|
||||
return DataWatcher.getInt(17 + i);
|
||||
}
|
||||
public int getInvulTime()
|
||||
{
|
||||
return DataWatcher.getInt(20);
|
||||
}
|
||||
|
||||
public void b(int i, int j)
|
||||
{
|
||||
DataWatcher.watch(17 + i, Integer.valueOf(j));
|
||||
}
|
||||
public void setInvulTime(int 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)
|
||||
{
|
||||
return DataWatcher.getInt(17 + i);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityWolf;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseWolf extends DisguiseTameableAnimal
|
||||
@ -8,51 +10,52 @@ public class DisguiseWolf extends DisguiseTameableAnimal
|
||||
{
|
||||
super(EntityType.WOLF, entity);
|
||||
|
||||
DataWatcher.a(18, new Float(20F));
|
||||
DataWatcher.a(19, new Byte((byte)0));
|
||||
DataWatcher.a(20, new Byte((byte)14));
|
||||
DataWatcher.a(18, new Float(20F), EntityWolf.META_WOLF_HEALTH, 20F);
|
||||
DataWatcher.a(19, new Byte((byte) 0), EntityWolf.META_BEGGING, false);
|
||||
DataWatcher.a(20, new Byte((byte) 14), EntityWolf.META_COLLAR, 14);
|
||||
}
|
||||
|
||||
public boolean isAngry()
|
||||
|
||||
public boolean isAngry()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x2) != 0;
|
||||
}
|
||||
|
||||
|
||||
public void setAngry(boolean angry)
|
||||
{
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
|
||||
if (angry)
|
||||
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 0x2)));
|
||||
else
|
||||
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 0xFFFFFFFD)));
|
||||
if (angry)
|
||||
DataWatcher.watch(16, Byte.valueOf((byte) (b0 | 0x2)), EntityWolf.META_SITTING_TAMED, (byte) (b0 | 0x2));
|
||||
else
|
||||
DataWatcher
|
||||
.watch(16, Byte.valueOf((byte) (b0 & 0xFFFFFFFD)), EntityWolf.META_SITTING_TAMED, (byte) (b0 & 0xFFFFFFFD));
|
||||
}
|
||||
|
||||
public int getCollarColor()
|
||||
public int getCollarColor()
|
||||
{
|
||||
return DataWatcher.getByte(20) & 0xF;
|
||||
return DataWatcher.getByte(20) & 0xF;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (flag)
|
||||
DataWatcher.watch(19, Byte.valueOf((byte)1));
|
||||
else
|
||||
DataWatcher.watch(19, Byte.valueOf((byte)0));
|
||||
if (flag)
|
||||
DataWatcher.watch(19, Byte.valueOf((byte) 1), EntityWolf.META_BEGGING, flag);
|
||||
else
|
||||
DataWatcher.watch(19, Byte.valueOf((byte) 0), EntityWolf.META_BEGGING, flag);
|
||||
}
|
||||
|
||||
|
||||
public boolean ce()
|
||||
{
|
||||
return DataWatcher.getByte(19) == 1;
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.wolf.hurt";
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.wolf.hurt";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityZombie;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseZombie extends DisguiseMonster
|
||||
@ -12,34 +14,34 @@ public class DisguiseZombie extends DisguiseMonster
|
||||
public DisguiseZombie(EntityType disguiseType, Entity entity)
|
||||
{
|
||||
super(disguiseType, entity);
|
||||
|
||||
DataWatcher.a(12, Byte.valueOf((byte)0));
|
||||
DataWatcher.a(13, Byte.valueOf((byte)0));
|
||||
DataWatcher.a(14, Byte.valueOf((byte)0));
|
||||
|
||||
DataWatcher.a(12, Byte.valueOf((byte) 0), EntityZombie.META_CHILD, false);
|
||||
DataWatcher.a(13, Byte.valueOf((byte) 0), EntityZombie.META_VILLAGER, false);
|
||||
DataWatcher.a(14, Byte.valueOf((byte) 0), EntityZombie.META_CONVERTING, false);
|
||||
}
|
||||
|
||||
|
||||
public boolean IsBaby()
|
||||
{
|
||||
return DataWatcher.getByte(12) == 1;
|
||||
}
|
||||
|
||||
|
||||
public void SetBaby(boolean baby)
|
||||
{
|
||||
DataWatcher.watch(12, Byte.valueOf((byte)(baby ? 1 : 0)));
|
||||
DataWatcher.watch(12, Byte.valueOf((byte) (baby ? 1 : 0)), EntityZombie.META_CHILD, baby);
|
||||
}
|
||||
|
||||
|
||||
public boolean IsVillager()
|
||||
{
|
||||
return DataWatcher.getByte(13) == 1;
|
||||
}
|
||||
|
||||
|
||||
public void SetVillager(boolean villager)
|
||||
{
|
||||
DataWatcher.watch(13, Byte.valueOf((byte)(villager ? 1 : 0)));
|
||||
DataWatcher.watch(13, Byte.valueOf((byte) (villager ? 1 : 0)), EntityZombie.META_VILLAGER, villager);
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.zombie.hurt";
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.zombie.hurt";
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
|
||||
public class GemCommand extends CommandBase<DonationManager>
|
||||
@ -32,7 +33,11 @@ public class GemCommand extends CommandBase<DonationManager>
|
||||
String gemsString = args[1];
|
||||
Player target = UtilPlayer.searchExact(targetName);
|
||||
|
||||
if (target == null)
|
||||
if (targetName.equalsIgnoreCase("@a"))
|
||||
{
|
||||
rewardAllGems(caller, gemsString);
|
||||
}
|
||||
else if (target == null)
|
||||
{
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(targetName);
|
||||
if (uuid != null)
|
||||
@ -50,6 +55,42 @@ public class GemCommand extends CommandBase<DonationManager>
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardAllGems(Player caller, String gemsString)
|
||||
{
|
||||
try
|
||||
{
|
||||
int gems = Integer.parseInt(gemsString);
|
||||
|
||||
if (gems > 1000)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Gem", "You can only give everybody 1000 gems at a time."));
|
||||
return;
|
||||
}
|
||||
|
||||
rewardAllGems(caller, gems);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Gem", "Invalid gems Amount"));
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardAllGems(Player caller, int gems)
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
Plugin.RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
|
||||
}
|
||||
}, caller.getName(), player.getName(), player.getUniqueId(), gems);
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Gem", "Gave everyone " + F.elem(gems + " gems")));
|
||||
}
|
||||
|
||||
private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, String gemsString)
|
||||
{
|
||||
try
|
||||
|
@ -6,8 +6,8 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ShardCommand extends CommandBase<DonationManager>
|
||||
@ -30,7 +30,11 @@ public class ShardCommand extends CommandBase<DonationManager>
|
||||
final String coinsString = args[1];
|
||||
Player target = UtilPlayer.searchExact(targetName);
|
||||
|
||||
if (target == null)
|
||||
if (targetName.equalsIgnoreCase("@a"))
|
||||
{
|
||||
rewardAllShards(caller, coinsString);
|
||||
}
|
||||
else if (target == null)
|
||||
{
|
||||
Plugin.getClientManager().loadClientByName(targetName, new Runnable()
|
||||
{
|
||||
@ -53,6 +57,44 @@ public class ShardCommand extends CommandBase<DonationManager>
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardAllShards(Player caller, String shardsString)
|
||||
{
|
||||
try
|
||||
{
|
||||
int shards = Integer.parseInt(shardsString);
|
||||
|
||||
if (shards > 1000)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Shards", "You can only give everybody 1000 shards at a time."));
|
||||
return;
|
||||
}
|
||||
|
||||
rewardAllShards(caller, shards);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Shards", "Invalid Shards Amount"));
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardAllShards(Player caller, int shards)
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
CoreClient client = Plugin.getClientManager().Get(player);
|
||||
|
||||
Plugin.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
|
||||
}
|
||||
}, caller.getName(), player.getName(), client.getAccountId(), shards);
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Shards", "Gave everyone " + F.elem(shards + " Treasure Shards")));
|
||||
}
|
||||
|
||||
private void rewardCoins(final Player caller, final Player target, final String targetName, final int accountId, String coinsString)
|
||||
{
|
||||
try
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user