Merge with develop

This commit is contained in:
Shaun Bennett 2016-05-24 19:10:55 +10:00
commit 1377e6724f
439 changed files with 50008 additions and 3744 deletions

View File

@ -1,4 +1,4 @@
From b3604650ac6e2813f9e1b4d54862ce79c37e001e Mon Sep 17 00:00:00 2001 From b3c9291331205afc5b78e85435b5daa099813a1b Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Mon, 15 Feb 2016 09:39:33 +1100 Date: Mon, 15 Feb 2016 09:39:33 +1100
Subject: [PATCH] Update groupId Subject: [PATCH] Update groupId
@ -18,5 +18,5 @@ index cb142f2..378fd01 100644
<version>1.8.8-R0.1-SNAPSHOT</version> <version>1.8.8-R0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 41b16c2e04b2bc8ada5d0ed363e4ea5e6b466ee1 Mon Sep 17 00:00:00 2001 From ad41271f22ea5f75476451b2c23f3ab0e54e2a6d Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:23:18 +1300 Date: Fri, 23 Oct 2015 21:23:18 +1300
Subject: [PATCH] LivingEntity changes Subject: [PATCH] LivingEntity changes
@ -30,5 +30,5 @@ index 48e2508..fb623ae 100644
+ public void setGhost(boolean ghost); + public void setGhost(boolean ghost);
} }
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 1bb1629f460d9c8ababad25722bebd0fedf2b269 Mon Sep 17 00:00:00 2001 From d3dc42fb5ba3a934b78f0ced14011facb075887d Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Sun, 22 Nov 2015 14:37:11 +1300 Date: Sun, 22 Nov 2015 14:37:11 +1300
Subject: [PATCH] EntityDismountEvent Subject: [PATCH] EntityDismountEvent
@ -43,5 +43,5 @@ index 24d4942..02943d6 100644
+ +
} }
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 32269ec951791791fe8553f0939c6eaa2b6b472b Mon Sep 17 00:00:00 2001 From 0c6ede1fb4e6dbaac8d8acf4fa72aa28ca6d9dc7 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 30 Dec 2015 19:57:10 +1300 Date: Wed, 30 Dec 2015 19:57:10 +1300
Subject: [PATCH] Add Elytra Subject: [PATCH] Add Elytra
@ -17,5 +17,5 @@ index 0fb2605..bc930d1 100644
GREEN_RECORD(2257, 1), GREEN_RECORD(2257, 1),
RECORD_3(2258, 1), RECORD_3(2258, 1),
-- --
1.9.5.msysgit.0 2.7.4

View File

@ -1,4 +1,4 @@
From 24a5d0cfe1d62e2ff6a3a0a279c63b038a134629 Mon Sep 17 00:00:00 2001 From a465cb15a5aea5c5f70957d5af0fe6b55108bff7 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 30 Dec 2015 21:05:47 +1300 Date: Wed, 30 Dec 2015 21:05:47 +1300
Subject: [PATCH] Levitation potion effect Subject: [PATCH] Levitation potion effect
@ -42,5 +42,5 @@ index 6ad9a91..a3dc228 100644
private final int damageValue, maxLevel; private final int damageValue, maxLevel;
-- --
1.9.5.msysgit.0 2.7.4

View File

@ -0,0 +1,22 @@
From c8afa4514a06be8257d3a05e0d261d4051a4dad0 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Mon, 25 Apr 2016 10:32:40 +1000
Subject: [PATCH] Update pom version
diff --git a/pom.xml b/pom.xml
index 378fd01..13a555d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
<groupId>com.mineplex</groupId>
<artifactId>spigot-api</artifactId>
- <version>1.8.8-R0.1-SNAPSHOT</version>
+ <version>1.8.8-1.9-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Spigot-API</name>
--
2.7.4

View File

@ -1,4 +1,4 @@
From 409122f500f205b8a9b0fdec56900d83cee9f1ba Mon Sep 17 00:00:00 2001 From 4c5177323b3556b7c6616ddd5bfa854a0b1b7e3c Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Mon, 15 Feb 2016 09:56:14 +1100 Date: Mon, 15 Feb 2016 09:56:14 +1100
Subject: [PATCH] Update groupId Subject: [PATCH] Update groupId
@ -27,5 +27,5 @@ index 91627ff..c1d1fb7 100644
<version>${project.version}</version> <version>${project.version}</version>
<type>jar</type> <type>jar</type>
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 687c7ed26e1733b8ed688243cd6df91c45db148a Mon Sep 17 00:00:00 2001 From 2f928d1889df46e390373df141f75a07b267cb33 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:14:50 +1300 Date: Fri, 23 Oct 2015 21:14:50 +1300
Subject: [PATCH] Modify packets to public Subject: [PATCH] Modify packets to public
@ -2033,5 +2033,5 @@ index 0000000..4c2705b
+} +}
\ No newline at end of file \ No newline at end of file
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From ca990c7ca61006f0933d0e117f1003822b887667 Mon Sep 17 00:00:00 2001 From 90e32385d69e8936969ac3e7e7b2cd52f2d19e28 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:16:07 +1300 Date: Fri, 23 Oct 2015 21:16:07 +1300
Subject: [PATCH] Modifiy entity Subject: [PATCH] Modifiy entity
@ -800,5 +800,5 @@ index 5317cff..60e8584 100644
return Math.min(Math.max(0, getHandle().getHealth()), getMaxHealth()); return Math.min(Math.max(0, getHandle().getHealth()), getMaxHealth());
} }
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From c8c2e86ef3ac3baf774afacf5fe2fab0b39a39a6 Mon Sep 17 00:00:00 2001 From 72e734acdc1912563f5d8e4a906579e3ab65064b Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:21:32 +1300 Date: Fri, 23 Oct 2015 21:21:32 +1300
Subject: [PATCH] Chunk changes Subject: [PATCH] Chunk changes
@ -231,5 +231,5 @@ index 975d666..a55bd6c 100644
/* /*
* If it's a new world, the first few chunks are generated inside * If it's a new world, the first few chunks are generated inside
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 04418c14f74d251cebe99e4bc6315d619b0a4440 Mon Sep 17 00:00:00 2001 From 1da9bcc60b080e3b068aff9202dbe7823d1abe64 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:22:05 +1300 Date: Fri, 23 Oct 2015 21:22:05 +1300
Subject: [PATCH] Packet listener changes Subject: [PATCH] Packet listener changes
@ -349,5 +349,5 @@ index 5740e49..5edef3e 100644
public void a(PacketPlayInWindowClick packetplayinwindowclick) { public void a(PacketPlayInWindowClick packetplayinwindowclick) {
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 413c649570b54e6d7a50da7aa888cfb20018f523 Mon Sep 17 00:00:00 2001 From bf6cbe47c5b1ab50e4ceb7a98b25975b90ae92c2 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:22:36 +1300 Date: Fri, 23 Oct 2015 21:22:36 +1300
Subject: [PATCH] Inventory changes Subject: [PATCH] Inventory changes
@ -66,5 +66,5 @@ index 23f05f4..fdaf026 100644
public int getTypeId() { public int getTypeId() {
return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0; return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0;
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 7772a2a9b83ee223c01ac2003ba32a1b95a7c0cd Mon Sep 17 00:00:00 2001 From ed2a06418ba178cb6ff227ef1aca14f7b5f951df Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:23:00 +1300 Date: Fri, 23 Oct 2015 21:23:00 +1300
Subject: [PATCH] Misc changes Subject: [PATCH] Misc changes
@ -273,5 +273,5 @@ index 29082aa..e979f69 100644
} }
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 969a70f201e6eda7d990e11e292e0dacc35f8ddf Mon Sep 17 00:00:00 2001 From 562c6e8165bebbabc22f7f1d472e1fc0bf54dc86 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 28 Oct 2015 09:00:24 +1300 Date: Wed, 28 Oct 2015 09:00:24 +1300
Subject: [PATCH] EntityGuardian is now vegetateable Subject: [PATCH] EntityGuardian is now vegetateable
@ -601,5 +601,5 @@ index 0000000..c14caf2
+ public PathfinderGoalRandomStroll goalRandomStroll; + public PathfinderGoalRandomStroll goalRandomStroll;
+} +}
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From a48503259a76ca5b9fec3bd7ec06e0e5c1d3f8e1 Mon Sep 17 00:00:00 2001 From 5455de50dc5b6fe4ea5ba5b98b0f9169705a0e65 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 30 Oct 2015 20:02:58 +1300 Date: Fri, 30 Oct 2015 20:02:58 +1300
Subject: [PATCH] Controller look vegetateHead, Entity collide changes Subject: [PATCH] Controller look vegetateHead, Entity collide changes
@ -39,5 +39,5 @@ index cb9ba53..8660762 100644
double d0 = entity.locX - this.locX; double d0 = entity.locX - this.locX;
double d1 = entity.locZ - this.locZ; double d1 = entity.locZ - this.locZ;
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From bafc21b97584c9207f29804520942285752d6b53 Mon Sep 17 00:00:00 2001 From 9f6ec15bfe47f1860d878212035f477b5b253c63 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Tue, 3 Nov 2015 21:21:02 +1300 Date: Tue, 3 Nov 2015 21:21:02 +1300
Subject: [PATCH] Vegetate head ai Subject: [PATCH] Vegetate head ai
@ -135,5 +135,5 @@ index f75b0b1..e384c2c 100644
} else if (!this.bM()) { } else if (!this.bM()) {
this.motX *= 0.98D; this.motX *= 0.98D;
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 5e1591dec2adb9001c9c3aafd0908d95eadff484 Mon Sep 17 00:00:00 2001 From a50aa59123b6a4b164fe368c83dbdd426dba0f6e Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Sun, 8 Nov 2015 17:57:05 +1300 Date: Sun, 8 Nov 2015 17:57:05 +1300
Subject: [PATCH] Modifications to cb Subject: [PATCH] Modifications to cb
@ -1614,5 +1614,5 @@ index 0000000..fdf0e10
+ } + }
+} +}
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From d57744e41ed408a6f924665509bb03fac0590cfa Mon Sep 17 00:00:00 2001 From 9d2015fe106bc67d93ea1d9a80d057f1bfad0fd0 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Mon, 9 Nov 2015 00:07:26 +1300 Date: Mon, 9 Nov 2015 00:07:26 +1300
Subject: [PATCH] Add IEntitySelector, have isGhost() return the same as Subject: [PATCH] Add IEntitySelector, have isGhost() return the same as
@ -115,5 +115,5 @@ index 0000000..1536600
+ +
+} +}
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From c6967f167cb74718389c7d87a0e4847d2824e855 Mon Sep 17 00:00:00 2001 From 436b55243d79c6ae0d839a2666a2f43ed186fe70 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Mon, 9 Nov 2015 00:13:21 +1300 Date: Mon, 9 Nov 2015 00:13:21 +1300
Subject: [PATCH] Add player spectator Subject: [PATCH] Add player spectator
@ -18,5 +18,5 @@ index 1536600..f86cf48 100644
public boolean apply(Object obj) public boolean apply(Object obj)
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 9eb0754b8eaed3dd60355206dd53c6b4dacab361 Mon Sep 17 00:00:00 2001 From b1e36dc87d3c5623283c9f461807a65d40538be3 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Mon, 9 Nov 2015 02:41:31 +1300 Date: Mon, 9 Nov 2015 02:41:31 +1300
Subject: [PATCH] Fixed ai typo Subject: [PATCH] Fixed ai typo
@ -18,5 +18,5 @@ index f86cf48..b4d70ad 100644
public boolean apply(Object obj) public boolean apply(Object obj)
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From d37159de8e6c19ed8e232666661572cc399dc82a Mon Sep 17 00:00:00 2001 From 838463c93cd7f0b29814507cab9e7c3465e75bbb Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 11 Nov 2015 00:21:54 +1300 Date: Wed, 11 Nov 2015 00:21:54 +1300
Subject: [PATCH] Fix casting bug Subject: [PATCH] Fix casting bug
@ -60,5 +60,5 @@ index 60e8584..746961e 100644
public boolean isGhost() public boolean isGhost()
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From c881d98fee52e719e60a5c8f5eeb9497357dd597 Mon Sep 17 00:00:00 2001 From e1d672bf80a66283809f25f925121487cc02e040 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 11 Nov 2015 11:43:17 +1300 Date: Wed, 11 Nov 2015 11:43:17 +1300
Subject: [PATCH] Fix schedulers Subject: [PATCH] Fix schedulers
@ -33,5 +33,5 @@ index 1d29ae7..55e2afd 100644
SpigotTimings.processQueueTimer.startTiming(); // Spigot SpigotTimings.processQueueTimer.startTiming(); // Spigot
while (!processQueue.isEmpty()) { while (!processQueue.isEmpty()) {
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From b0eb73047d9e8e06c2822142dc8c443efa9eda2e Mon Sep 17 00:00:00 2001 From 08847caa91ab71f3a67bbb4bef1ebd00acac6f6a Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Sun, 22 Nov 2015 14:41:11 +1300 Date: Sun, 22 Nov 2015 14:41:11 +1300
Subject: [PATCH] EntityDismountEvent & teleport crash fix Subject: [PATCH] EntityDismountEvent & teleport crash fix
@ -133,5 +133,5 @@ index efbf1a8..ad53590 100644
// Spigot start // Spigot start
if (!location.getWorld().equals(getWorld())) { if (!location.getWorld().equals(getWorld())) {
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 6514e2834135adf7d133d11bbcad9377544d73f0 Mon Sep 17 00:00:00 2001 From 76027e46da8c636f0c59912ce06379373880862c Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 27 Nov 2015 22:26:34 +1300 Date: Fri, 27 Nov 2015 22:26:34 +1300
Subject: [PATCH] Server freezing, fix fake yaw/pitch Subject: [PATCH] Server freezing, fix fake yaw/pitch
@ -64,5 +64,5 @@ index 5edef3e..d3b1586 100644
} else { } else {
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 22472882d2708e0eb4e35f0d31978b70d2c4b4f5 Mon Sep 17 00:00:00 2001 From c97267c98bac90ee24f0bb7bfa710a58f3c990af Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Tue, 12 Jan 2016 19:56:07 +1300 Date: Tue, 12 Jan 2016 19:56:07 +1300
Subject: [PATCH] Sound and vehicle fixes Subject: [PATCH] Sound and vehicle fixes
@ -22,5 +22,5 @@ index 0cc8f9b..dd07600 100644
set(DIG_WOOL, "dig.cloth"); set(DIG_WOOL, "dig.cloth");
set(DIG_GRASS, "dig.grass"); set(DIG_GRASS, "dig.grass");
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 1e687cfb7b343f9c2a2e3cfdef346a896be747bb Mon Sep 17 00:00:00 2001 From fd52634ee952e6c24f5d874d4130abae2524ac39 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 29 Jan 2016 16:59:00 +1300 Date: Fri, 29 Jan 2016 16:59:00 +1300
Subject: [PATCH] md_5's player interaction for specs patch Subject: [PATCH] md_5's player interaction for specs patch
@ -27,5 +27,5 @@ index d3b1586..6fd49b3 100644
// Arm swing animation // Arm swing animation
PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 125596ec9aee25d141781b4010eac881c7b36eb5 Mon Sep 17 00:00:00 2001 From 967ca8d8c01a90f93d52bd9aa2bbe1e9d2fd7a66 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 29 Jan 2016 16:59:12 +1300 Date: Fri, 29 Jan 2016 16:59:12 +1300
Subject: [PATCH] Fix enderman teleporting when vegetated Subject: [PATCH] Fix enderman teleporting when vegetated
@ -21,5 +21,5 @@ index a250062..5ad2d07 100644
double d4 = this.locY; double d4 = this.locY;
double d5 = this.locZ; double d5 = this.locZ;
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 742d6b5d828128519f06f7c6f5e188847263e609 Mon Sep 17 00:00:00 2001 From 87e9cd7cd56efee729c47710a8b1d9ed265c8903 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net> From: md_5 <git@md-5.net>
Date: Sun, 7 Feb 2016 20:28:54 +1100 Date: Sun, 7 Feb 2016 20:28:54 +1100
Subject: [PATCH] Implement Sentry for exception monitoring. Subject: [PATCH] Implement Sentry for exception monitoring.
@ -323,5 +323,5 @@ index f37d1c2..b9d8704 100644
</Loggers> </Loggers>
</Configuration> </Configuration>
-- --
2.5.0 2.7.4

View File

@ -1,4 +1,4 @@
From 4b151cd529c5de0d32cc78357f417c9fa4866198 Mon Sep 17 00:00:00 2001 From b764e7185cb062f830a74b814017b148a062a59a Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Sun, 29 Nov 2015 02:53:00 +1300 Date: Sun, 29 Nov 2015 02:53:00 +1300
Subject: [PATCH] Dual version patch and some other fixes Subject: [PATCH] Dual version patch and some other fixes
@ -1836,10 +1836,10 @@ index dec091e..9e351b1 100644
public Object b() { public Object b() {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 7165579..96d9312 100644 index 721d0e6..a301af7 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -128,6 +128,12 @@ public abstract class Entity implements ICommandListener { @@ -127,6 +127,12 @@ public abstract class Entity implements ICommandListener {
public boolean fromMobSpawner; public boolean fromMobSpawner;
public void inactiveTick() { } public void inactiveTick() { }
// Spigot end // Spigot end
@ -1852,7 +1852,7 @@ index 7165579..96d9312 100644
public int getId() { public int getId() {
return this.id; return this.id;
@@ -201,11 +207,11 @@ public abstract class Entity implements ICommandListener { @@ -206,11 +212,11 @@ public abstract class Entity implements ICommandListener {
// Spigot end // Spigot end
this.datawatcher = new DataWatcher(this); this.datawatcher = new DataWatcher(this);
@ -1869,7 +1869,7 @@ index 7165579..96d9312 100644
this.h(); this.h();
} }
@@ -839,7 +845,7 @@ public abstract class Entity implements ICommandListener { @@ -844,7 +850,7 @@ public abstract class Entity implements ICommandListener {
} }
public void b(boolean flag) { public void b(boolean flag) {
@ -1878,24 +1878,7 @@ index 7165579..96d9312 100644
} }
protected boolean s_() { protected boolean s_() {
@@ -1612,11 +1618,13 @@ public abstract class Entity implements ICommandListener { @@ -1760,9 +1766,9 @@ public abstract class Entity implements ICommandListener {
EntityDismountEvent exitEvent1 = null;
if (this.vehicle != null) {
if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle))
+ {
exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
- pluginManager.callEvent(exitEvent);
+ pluginManager.callEvent(exitEvent);
- if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
- return;
+ if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
+ return;
+ }
}
exitEvent1 = new EntityDismountEvent(this.vehicle.getBukkitEntity(), this.bukkitEntity);
@@ -1748,9 +1756,9 @@ public abstract class Entity implements ICommandListener {
byte b0 = this.datawatcher.getByte(0); byte b0 = this.datawatcher.getByte(0);
if (flag) { if (flag) {
@ -1907,7 +1890,7 @@ index 7165579..96d9312 100644
} }
} }
@@ -1760,7 +1768,7 @@ public abstract class Entity implements ICommandListener { @@ -1772,7 +1778,7 @@ public abstract class Entity implements ICommandListener {
} }
public void setAirTicks(int i) { public void setAirTicks(int i) {
@ -1916,7 +1899,7 @@ index 7165579..96d9312 100644
} }
public void onLightningStrike(EntityLightning entitylightning) { public void onLightningStrike(EntityLightning entitylightning) {
@@ -2123,7 +2131,7 @@ public abstract class Entity implements ICommandListener { @@ -2135,7 +2141,7 @@ public abstract class Entity implements ICommandListener {
s = s.substring(0, 256); s = s.substring(0, 256);
} }
// CraftBukkit end // CraftBukkit end
@ -1925,7 +1908,7 @@ index 7165579..96d9312 100644
} }
public String getCustomName() { public String getCustomName() {
@@ -2135,7 +2143,7 @@ public abstract class Entity implements ICommandListener { @@ -2147,7 +2153,7 @@ public abstract class Entity implements ICommandListener {
} }
public void setCustomNameVisible(boolean flag) { public void setCustomNameVisible(boolean flag) {
@ -2384,7 +2367,7 @@ index ed7f549..2198042 100644
public EntityEnderDragon(World world) { public EntityEnderDragon(World world) {
super(world); super(world);
diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java
index a250062..5c09068 100644 index 5ad2d07..7039b8d 100644
--- a/src/main/java/net/minecraft/server/EntityEnderman.java --- a/src/main/java/net/minecraft/server/EntityEnderman.java
+++ b/src/main/java/net/minecraft/server/EntityEnderman.java +++ b/src/main/java/net/minecraft/server/EntityEnderman.java
@@ -7,6 +7,7 @@ import java.util.List; @@ -7,6 +7,7 @@ import java.util.List;
@ -2417,7 +2400,7 @@ index a250062..5c09068 100644
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
@@ -254,7 +257,7 @@ public class EntityEnderman extends EntityMonster { @@ -259,7 +262,7 @@ public class EntityEnderman extends EntityMonster {
} }
public void setCarried(IBlockData iblockdata) { public void setCarried(IBlockData iblockdata) {
@ -2426,7 +2409,7 @@ index a250062..5c09068 100644
} }
public IBlockData getCarried() { public IBlockData getCarried() {
@@ -306,7 +309,7 @@ public class EntityEnderman extends EntityMonster { @@ -311,7 +314,7 @@ public class EntityEnderman extends EntityMonster {
} }
public void a(boolean flag) { public void a(boolean flag) {
@ -2888,10 +2871,10 @@ index 1008567..a3d7b66 100644
this.world.updateAdjacentComparators(this.blockPosition, Blocks.AIR); this.world.updateAdjacentComparators(this.blockPosition, Blocks.AIR);
} }
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 96b3905..d0af93f 100644 index 19fc521..710def4 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java --- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -114,11 +114,17 @@ public abstract class EntityLiving extends Entity { @@ -113,11 +113,17 @@ public abstract class EntityLiving extends Entity {
_ghost = ghost; _ghost = ghost;
} }
@ -2910,7 +2893,7 @@ index 96b3905..d0af93f 100644
this.k = true; this.k = true;
this.aH = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.aH = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.setPosition(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
@@ -129,10 +135,11 @@ public abstract class EntityLiving extends Entity { @@ -128,10 +134,11 @@ public abstract class EntityLiving extends Entity {
} }
protected void h() { protected void h() {
@ -2926,7 +2909,7 @@ index 96b3905..d0af93f 100644
} }
protected void initAttributes() { protected void initAttributes() {
@@ -547,16 +554,16 @@ public abstract class EntityLiving extends Entity { @@ -546,16 +553,16 @@ public abstract class EntityLiving extends Entity {
} else { } else {
int i = PotionBrewer.a(this.effects.values()); int i = PotionBrewer.a(this.effects.values());
@ -2947,7 +2930,7 @@ index 96b3905..d0af93f 100644
} }
public void removeAllEffects() { public void removeAllEffects() {
@@ -709,11 +716,11 @@ public abstract class EntityLiving extends Entity { @@ -708,11 +715,11 @@ public abstract class EntityLiving extends Entity {
player.setRealHealth(f); player.setRealHealth(f);
} }
@ -2961,7 +2944,7 @@ index 96b3905..d0af93f 100644
} }
public boolean damageEntity(DamageSource damagesource, float f) { public boolean damageEntity(DamageSource damagesource, float f) {
@@ -1174,7 +1181,7 @@ public abstract class EntityLiving extends Entity { @@ -1173,7 +1180,7 @@ public abstract class EntityLiving extends Entity {
} }
public final void o(int i) { public final void o(int i) {
@ -4632,7 +4615,7 @@ index 0000000..eb425dc
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 64f6a9b..bec9f80 100644 index 215648e..fa1a1e1 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java --- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java +++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -22,6 +22,16 @@ public class HandshakeListener implements PacketHandshakingInListener { @@ -22,6 +22,16 @@ public class HandshakeListener implements PacketHandshakingInListener {
@ -4652,21 +4635,6 @@ index 64f6a9b..bec9f80 100644
switch (HandshakeListener.SyntheticClass_1.a[packethandshakinginsetprotocol.a().ordinal()]) { switch (HandshakeListener.SyntheticClass_1.a[packethandshakinginsetprotocol.a().ordinal()]) {
case 1: case 1:
this.b.a(EnumProtocol.LOGIN); this.b.a(EnumProtocol.LOGIN);
@@ -61,12 +71,8 @@ public class HandshakeListener implements PacketHandshakingInListener {
org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t);
}
// CraftBukkit end
-
- if (packethandshakinginsetprotocol.b() > 47) {
- chatcomponenttext = new ChatComponentText( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage, "1.8.8" ) ); // Spigot
- this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext));
- this.b.close(chatcomponenttext);
- } else if (packethandshakinginsetprotocol.b() < 47) {
+
+ if (!supported) {
chatcomponenttext = new ChatComponentText( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage, "1.8.8" ) ); // Spigot
this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext));
this.b.close(chatcomponenttext);
diff --git a/src/main/java/net/minecraft/server/MathHelper.java b/src/main/java/net/minecraft/server/MathHelper.java diff --git a/src/main/java/net/minecraft/server/MathHelper.java b/src/main/java/net/minecraft/server/MathHelper.java
new file mode 100644 new file mode 100644
index 0000000..db19ad4 index 0000000..db19ad4
@ -7051,7 +7019,7 @@ index abb24c8..2d8db9c 100644
this.players.remove(entityplayer); // CraftBukkit this.players.remove(entityplayer); // CraftBukkit
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 5edef3e..a8c5b44 100644 index 6fd49b3..43fc802 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java --- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -386,7 +386,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList @@ -386,7 +386,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@ -7154,7 +7122,7 @@ index 5edef3e..a8c5b44 100644
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand())); this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
} }
} }
@@ -1992,7 +1993,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList @@ -2003,7 +2004,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
itemstack1 = this.player.inventory.getItemInHand(); itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) { if (itemstack1 != null) {
@ -7163,7 +7131,7 @@ index 5edef3e..a8c5b44 100644
// CraftBukkit start // CraftBukkit start
itemstack1 = new ItemStack(Items.WRITTEN_BOOK); itemstack1 = new ItemStack(Items.WRITTEN_BOOK);
itemstack1.a("author", (NBTBase) (new NBTTagString(this.player.getName()))); itemstack1.a("author", (NBTBase) (new NBTTagString(this.player.getName())));
@@ -2247,4 +2248,65 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList @@ -2258,4 +2259,65 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
} }
} }
@ -7303,20 +7271,12 @@ index eca86db..e61032c 100644
entity = (Entity) this.k.get(i); entity = (Entity) this.k.get(i);
// CraftBukkit start - Fixed an NPE // CraftBukkit start - Fixed an NPE
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index efbf1a8..dbc7b54 100644 index ad53590..48f7d58 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1,6 +1,7 @@ @@ -239,6 +239,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
package org.bukkit.craftbukkit.entity; return false;
}
import com.google.common.base.Preconditions;
+import com.google.common.primitives.Doubles;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -234,6 +235,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
// If this entity is riding another entity, we must dismount before teleporting.
entity.mount(null);
+ if (!Doubles.isFinite(location.getX()) || !Doubles.isFinite(location.getY()) || !Doubles.isFinite(location.getZ())) + if (!Doubles.isFinite(location.getX()) || !Doubles.isFinite(location.getY()) || !Doubles.isFinite(location.getZ()))
+ { + {
@ -7376,5 +7336,5 @@ index 18da426..79bd517 100644
@Override @Override
-- --
1.9.5.msysgit.0 2.7.4

View File

@ -1,4 +1,4 @@
From db79f5bc9cf52fa7bb9cf080e206d88641fa0617 Mon Sep 17 00:00:00 2001 From 78251d4e835e96e8119c0f0ce87ad915339f5093 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 30 Dec 2015 21:06:12 +1300 Date: Wed, 30 Dec 2015 21:06:12 +1300
Subject: [PATCH] Added new stuff, elytra and levitation Subject: [PATCH] Added new stuff, elytra and levitation
@ -161,10 +161,10 @@ index b86369b..4301bc9 100644
this.c("127.0.0.1"); this.c("127.0.0.1");
} else { } else {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 96d9312..2f52ea2 100644 index a301af7..51ca1f3 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1763,6 +1763,50 @@ public abstract class Entity implements ICommandListener { @@ -1773,6 +1773,50 @@ public abstract class Entity implements ICommandListener {
} }
@ -259,10 +259,10 @@ index 5294c66..743df69 100644
} }
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index d0af93f..d074110 100644 index 710def4..41eede5 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java --- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -956,7 +956,7 @@ public abstract class EntityLiving extends Entity { @@ -955,7 +955,7 @@ public abstract class EntityLiving extends Entity {
if (i > 0) { if (i > 0) {
// CraftBukkit start // CraftBukkit start
@ -271,7 +271,7 @@ index d0af93f..d074110 100644
return; return;
} }
// CraftBukkit end // CraftBukkit end
@@ -1668,6 +1668,7 @@ public abstract class EntityLiving extends Entity { @@ -1667,6 +1667,7 @@ public abstract class EntityLiving extends Entity {
this.aZ *= 0.98F; this.aZ *= 0.98F;
this.ba *= 0.98F; this.ba *= 0.98F;
this.bb *= 0.9F; this.bb *= 0.9F;
@ -279,7 +279,7 @@ index d0af93f..d074110 100644
SpigotTimings.timerEntityAIMove.startTiming(); // Spigot SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
this.g(this.aZ, this.ba); this.g(this.aZ, this.ba);
SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
@@ -1682,6 +1683,37 @@ public abstract class EntityLiving extends Entity { @@ -1681,6 +1682,37 @@ public abstract class EntityLiving extends Entity {
this.world.methodProfiler.b(); this.world.methodProfiler.b();
} }
@ -382,7 +382,7 @@ index eb425dc..f3877e4 100644
a(EnumProtocolDirection.SERVERBOUND, PacketPlayInBlockPlace.class, 8, 28); a(EnumProtocolDirection.SERVERBOUND, PacketPlayInBlockPlace.class, 8, 28);
a(EnumProtocolDirection.SERVERBOUND, PacketPlayInRightClick.class, -1, 29); a(EnumProtocolDirection.SERVERBOUND, PacketPlayInRightClick.class, -1, 29);
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index bec9f80..824ec1b 100644 index fa1a1e1..31e1ea1 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java --- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/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 { @@ -25,7 +25,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
@ -796,7 +796,7 @@ index 9a3b275..ef18545 100644
} }
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index a8c5b44..16f8609 100644 index 43fc802..6372719 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java --- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -386,7 +386,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList @@ -386,7 +386,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@ -829,7 +829,7 @@ index a8c5b44..16f8609 100644
default: default:
throw new IllegalArgumentException("Invalid player action"); throw new IllegalArgumentException("Invalid player action");
} }
@@ -1445,6 +1450,13 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList @@ -1456,6 +1461,13 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
return; return;
} }
@ -843,7 +843,7 @@ index a8c5b44..16f8609 100644
InventoryView inventory = this.player.activeContainer.getBukkitView(); InventoryView inventory = this.player.activeContainer.getBukkitView();
SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b()); SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b());
@@ -2246,6 +2258,12 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList @@ -2257,6 +2269,12 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
; ;
} }
@ -856,7 +856,7 @@ index a8c5b44..16f8609 100644
} }
} }
@@ -2253,7 +2271,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList @@ -2264,7 +2282,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
public void a(PacketPlayInUnknownPosition paramPacketPlayInUnknownPosition){System.out.print("Received unknown position");} public void a(PacketPlayInUnknownPosition paramPacketPlayInUnknownPosition){System.out.print("Received unknown position");}
@ -867,7 +867,7 @@ index a8c5b44..16f8609 100644
public void a(PacketPlayInRightClick paramPacketPlayInRightClick) public void a(PacketPlayInRightClick paramPacketPlayInRightClick)
{ {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index d3d19dd..81e231d 100644 index da576bc..8d826df 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java --- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -1032,10 +1032,21 @@ public abstract class PlayerList { @@ -1032,10 +1032,21 @@ public abstract class PlayerList {
@ -1376,5 +1376,5 @@ index 3a362b7..f55ddcd 100644
Material.BED_BLOCK, Material.BED_BLOCK,
Material.NETHER_WARTS, Material.NETHER_WARTS,
-- --
1.9.5.msysgit.0 2.7.4

View File

@ -1,4 +1,4 @@
From d1cf06c308d35a765cf2d11b170a9d0f8fabb418 Mon Sep 17 00:00:00 2001 From 4374ab4f758cd98b874600ad6c2b5c1474135a93 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz> From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 30 Dec 2015 22:38:30 +1300 Date: Wed, 30 Dec 2015 22:38:30 +1300
Subject: [PATCH] Some debug and crash fixes Subject: [PATCH] Some debug and crash fixes
@ -53,7 +53,7 @@ index ef51cd4..54c1ec9 100644
mapChunks = list; mapChunks = list;
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 81e231d..42d9e76 100644 index 8d826df..b50db37 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java --- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/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 { @@ -168,7 +168,8 @@ public abstract class PlayerList {
@ -78,5 +78,5 @@ index 81e231d..42d9e76 100644
// entityplayer1.syncInventory(); // entityplayer1.syncInventory();
// CraftBukkit end // CraftBukkit end
-- --
1.9.5.msysgit.0 2.7.4

View File

@ -1,27 +1,14 @@
From 0d1bec3dad53441ead8ac0f22e2464a924fb8818 Mon Sep 17 00:00:00 2001 From 7c7c941e8a0275a063065f592d57db5bdc103db8 Mon Sep 17 00:00:00 2001
From: git <libraryaddict115@yahoo.co.nz> From: git <libraryaddict115@yahoo.co.nz>
Date: Thu, 25 Feb 2016 18:20:02 +1300 Date: Thu, 25 Feb 2016 18:20:02 +1300
Subject: [PATCH] Current patch stuff 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 diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index d074110..e9a324a 100644 index 41eede5..40d4232 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java --- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/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 { @@ -549,13 +549,13 @@ public abstract class EntityLiving extends Entity {
protected void B() { protected void B() {
if (this.effects.isEmpty()) { if (this.effects.isEmpty()) {
this.bj(); this.bj();
@ -55,7 +42,7 @@ index f3877e4..0343bf8 100644
} }
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 824ec1b..9d27032 100644 index 31e1ea1..f6e8560 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java --- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/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 { @@ -25,7 +25,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
@ -275,45 +262,6 @@ index 2ce95fa..51a3a21 100644
} }
public void a(PacketListenerPlayOut packetlistenerplayout) 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 2.7.4

View File

@ -1,4 +1,4 @@
From af6ac4b09da7ad63ebb568333807c7621398f0a6 Mon Sep 17 00:00:00 2001 From 9dfce5478dba231619b0527f28af3640aef5480c Mon Sep 17 00:00:00 2001
From: git <libraryaddict115@yahoo.co.nz> From: git <libraryaddict115@yahoo.co.nz>
Date: Sun, 28 Feb 2016 00:37:30 +1300 Date: Sun, 28 Feb 2016 00:37:30 +1300
Subject: [PATCH] Changed maven version, fixed entity movement, fixed sound Subject: [PATCH] Changed maven version, fixed entity movement, fixed sound
@ -6,11 +6,11 @@ Subject: [PATCH] Changed maven version, fixed entity movement, fixed sound
diff --git a/pom.xml b/pom.xml diff --git a/pom.xml b/pom.xml
index 91627ff..1ea9f81 100644 index ceb3ec2..a44f7b1 100644
--- a/pom.xml --- a/pom.xml
+++ b/pom.xml +++ b/pom.xml
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<groupId>org.spigotmc</groupId> <groupId>com.mineplex</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
- <version>1.8.8-R0.1-SNAPSHOT</version> - <version>1.8.8-R0.1-SNAPSHOT</version>
@ -61,7 +61,7 @@ index e5c947f..9cd9be6 100644
this.b(); this.b();
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 9d27032..21dbf3b 100644 index f6e8560..fae7922 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java --- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/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 { @@ -25,7 +25,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
@ -131,5 +131,5 @@ index b72b7d7..bcfdab9 100644
packetdataserializer.writeInt(c); packetdataserializer.writeInt(c);
packetdataserializer.writeInt(d); packetdataserializer.writeInt(d);
-- --
1.9.5.msysgit.0 2.7.4

View File

@ -1,14 +1,14 @@
From 48550b9915d18d2d4a528c4028c8fa35a97a036c Mon Sep 17 00:00:00 2001 From 6e5d8f23968f7b24c084816f2b55edfbc99e820f Mon Sep 17 00:00:00 2001
From: git <libraryaddict115@yahoo.co.nz> From: git <libraryaddict115@yahoo.co.nz>
Date: Tue, 1 Mar 2016 09:29:32 +1300 Date: Tue, 1 Mar 2016 09:29:32 +1300
Subject: [PATCH] Update to 1.9, fix blocking 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 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 2f52ea2..c2ce92f 100644 index 51ca1f3..c6d3183 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/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 { @@ -1755,6 +1755,14 @@ public abstract class Entity implements ICommandListener {
} }
public void f(boolean flag) { public void f(boolean flag) {
@ -43,7 +43,7 @@ index 743df69..998ea69 100644
public void t_() { public void t_() {
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 21dbf3b..0d8aff4 100644 index fae7922..7d12515 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java --- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/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 { @@ -25,7 +25,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
@ -56,5 +56,5 @@ index 21dbf3b..0d8aff4 100644
if (supported) if (supported)
{ {
-- --
1.9.5.msysgit.0 2.7.4

View File

@ -0,0 +1,29 @@
From 6e7c7edf9e6144385bc909b17dd14539d8ac98d6 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Mon, 25 Apr 2016 10:36:56 +1000
Subject: [PATCH] Fix TnT Datawatcher
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index 9b13620..4f4511f 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -97,13 +97,13 @@ public class EntityTNTPrimed extends Entity {
protected void a(NBTTagCompound nbttagcompound) {
this.fuseTicks = nbttagcompound.getByte("Fuse");
- datawatcher.a(24, 0, META_FUSE, fuseTicks);
+ datawatcher.watch(24, 0, META_FUSE, fuseTicks);
}
public void setFuseTicks(int newTicks)
{
fuseTicks = newTicks;
- datawatcher.a(24, 0, META_FUSE, fuseTicks);
+ datawatcher.watch(24, 0, META_FUSE, fuseTicks);
}
public EntityLiving getSource() {
--
2.7.4

Binary file not shown.

View File

@ -10,10 +10,10 @@ import mineplex.core.common.util.UtilPlayer;
public enum Rank public enum Rank
{ {
//Staff //Staff
LT("Leader", ChatColor.GOLD, "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team."), LT("Leader", ChatColor.DARK_RED, "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team."),
OWNER("Owner", ChatColor.GOLD, "Owners are the founders of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation."), OWNER("Owner", ChatColor.DARK_RED, "Owners are the founders of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation."),
DEVELOPER("Dev", ChatColor.GOLD, "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."), DEVELOPER("Dev", ChatColor.DARK_RED, "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."),
ADMIN("Admin", ChatColor.GOLD, "An Administrators role is to manage \ntheir respective Senior Moderator team \nand all moderators within it."), ADMIN("Admin", ChatColor.DARK_RED, "An Administrators role is to manage \ntheir respective Senior Moderator team \nand all moderators within it."),
JNR_DEV("Jr.Dev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."), JNR_DEV("Jr.Dev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."),
SUPPORT("Support", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service."), SUPPORT("Support", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service."),
CMOD("C.Mod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a <message>") + "."), CMOD("C.Mod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a <message>") + "."),

View File

@ -0,0 +1,52 @@
package mineplex.core.common.animation;
import org.bukkit.util.Vector;
import java.util.Objects;
public class AnimationPoint
{
private final int _tick;
private final Vector _move;
private final Vector _dir;
public AnimationPoint(int tick, Vector move, Vector dir)
{
_tick = tick;
_move = move.clone();
_dir = dir.clone();
}
public Vector getMove()
{
return _move.clone();
}
public Vector getDirection()
{
return _dir.clone();
}
public int getTick()
{
return _tick;
}
@Override
public boolean equals(Object obj)
{
if(obj instanceof AnimationPoint) {
AnimationPoint point = (AnimationPoint) obj;
return point._tick == _tick && point._move.equals(_move);
}
return false;
}
@Override
public int hashCode()
{
return Objects.hash(_tick, _move);
}
}

View File

@ -0,0 +1,161 @@
package mineplex.core.common.animation;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
/**
* Self sufficient animator to animate task with steps using local vector logic
*/
public abstract class Animator
{
private final Plugin _plugin;
// private TreeSet<AnimationPoint> _points = new TreeSet<>((a, b) -> Integer.compare(a.getTick(), b.getTick()));
private Set<AnimationPoint> _points = new HashSet<>();
private PriorityQueue<AnimationPoint> _queue = new PriorityQueue<>((a, b) -> Integer.compare(a.getTick(), b.getTick()));
private AnimationPoint _prev;
private AnimationPoint _next;
private Location _baseLoc;
private int _tick = -1;
private boolean _repeat = false;
private BukkitTask _task;
public Animator(Plugin plugin)
{
_plugin = plugin;
}
public void addPoint(AnimationPoint point) {
_points.add(point);
}
public void removePoint(AnimationPoint point) {
_points.remove(point);
}
/**
* @return Returns a cloned list of the animator points for this instance.
*/
public Set<AnimationPoint> getSet() {
return new HashSet<AnimationPoint>(_points);
}
/**
* @return Returns the actual list of animator points used by this instance. As this is not a copy, editing this list will apply
* changes to the current instance.
*/
public Set<AnimationPoint> getSetRaw() {
return _points;
}
/**
* Start the animation at the given location. If the animator is already running then this call will be silently ignored.
* @param loc Location the animation will start relative too. The vector poitns will be added to relative to this location.
*/
public void start(Location loc)
{
if(isRunning()) return;
_queue.clear();
_queue.addAll(_points);
if(_queue.isEmpty()) return;
_baseLoc = loc.clone();
_next = _queue.peek();
_prev = new AnimationPoint(0, _next.getMove().clone(), _next.getDirection().clone());
_task = new BukkitRunnable()
{
public void run()
{
_tick++;
if(_next.getTick() < _tick)
{
_queue.remove();
_prev = _next;
_next = _queue.peek();
}
if(_queue.isEmpty())
{
if(_repeat)
{
Location clone = _baseLoc.clone();
stop();
start(clone);
}
else
{
finish(_baseLoc);
stop();
}
return;
}
Location prev = _baseLoc.clone().add(_prev.getMove());
Location next = _baseLoc.clone().add(_next.getMove());
prev.setDirection(_prev.getDirection());
double diff = ((double)_tick-_prev.getTick())/(_next.getTick()-_prev.getTick());
prev.add(next.clone().subtract(prev).toVector().multiply(diff));
Vector dirDiff = _next.getDirection().subtract(prev.getDirection());
dirDiff.multiply(diff);
prev.setDirection(prev.getDirection().add(dirDiff));
tick(prev);
}
}.runTaskTimer(_plugin, 0, 1);
}
public boolean isRunning()
{
return _task != null;
}
public void stop()
{
if(!isRunning()) return;
_task.cancel();
_task = null;
_tick = -1;
_baseLoc = null;
}
/**
* @return Returns true if the animation should repeat.
* @see #setRepeat(boolean)
*/
public boolean isRepeat()
{
return _repeat;
}
/**
* If the last animation point does not make the animation end up at the exact same location as the start
* then it might lead to unexpected results as it will re-start the animation from the end of the animation.
*/
public void setRepeat(boolean repeat)
{
_repeat = repeat;
}
protected abstract void tick(Location loc);
protected abstract void finish(Location loc);
}

View File

@ -0,0 +1,39 @@
package mineplex.core.common.animation;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
/**
* An implementation of the {@link Animator} which will teleport the provided entity along the animation path each tick.
*/
public class AnimatorEntity extends Animator
{
private final Entity _ent;
public AnimatorEntity(Plugin plugin, Entity ent)
{
super(plugin);
_ent = ent;
}
@Override
protected void tick(Location loc)
{
if(!_ent.isValid())
{
stop();
return;
}
_ent.setVelocity(new Vector(0,0,0));
_ent.teleport(loc);
}
@Override
protected void finish(Location loc) {}
}

View File

@ -0,0 +1,126 @@
package mineplex.core.common.block;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange.MultiBlockChangeInfo;
/**
* An agent used to easily record and send multi-block update packets to players. The agent handles if the packet should be a
* MultiBlock packet or a chunk update. It also supports blocks across multiple chunks.
*/
public class MultiBlockUpdaterAgent
{
private Map<Chunk, List<BlockVector>> _chunks = new HashMap<>();
/**
* Add a block to the list of blocks to send to the player. The agent supports blocks across different chunks and
* will not send duplicates.
* @param block The block to send. The block is stored using a BlockVector, meaning that when the send method is called, it will use
* the material and data found for the block at the moment you call the send method.
* @see #send(Collection)
*/
public void addBlock(Block block)
{
Chunk c = ((CraftChunk)block.getChunk()).getHandle();
List<BlockVector> list = _chunks.computeIfAbsent(c,chunk -> new ArrayList<>());
if(list.size() >= 64) return;
BlockVector bv = block.getLocation().toVector().toBlockVector();
if(list.contains(bv)) return;
list.add(bv);
}
/**
* Sends all the record blocks to all online players. Players out of range will not receive packets.
* @see #send(Collection)
*/
public void send()
{
send(UtilServer.getPlayersCollection());
}
/**
* Clear all blocks for this agent.
*/
public void reset()
{
_chunks.clear();
}
/**
* Send all the recorded blocks to the provided players. This will only send packets to players in range. If the blocks span multiple
* chunks then players will only receive block updates for chunks close to them.
* @param players The players which will the packets will be sent to.
*/
public void send(Collection<? extends Player> players)
{
for(Player p : players)
{
for(Chunk c : _chunks.keySet())
{
if(!p.getWorld().equals(c.bukkitChunk.getWorld())) continue;
int x = p.getLocation().getChunk().getX();
int z = p.getLocation().getChunk().getZ();
int chunkDist = Math.max(Math.abs(c.locX-x), Math.abs(c.locZ-z));
if(chunkDist > Bukkit.getViewDistance()) continue;
sendPacket(c, players);
}
}
}
private void sendPacket(Chunk c, Collection<? extends Player> players)
{
List<BlockVector> list = _chunks.get(c);
if(list == null) return;
if(list.size() >= 64)
{
for(Player p : players)
{
MapUtil.SendChunkForPlayer(c, p);
}
}
else
{
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange();
packet.a = new ChunkCoordIntPair(c.locX, c.locZ);
packet.b = new MultiBlockChangeInfo[list.size()];
for(int i = 0; i < list.size(); i++)
{
BlockVector bv = list.get(i);
short xyz = (short)((bv.getBlockX() & 0xF) << 12 | (bv.getBlockZ() & 0xF) << 8 | bv.getBlockY());
packet.b[i] = packet.new MultiBlockChangeInfo(xyz, c);
}
for(Player p : players)
{
UtilPlayer.sendPacket(p, packet);
}
}
}
}

View File

@ -3,6 +3,9 @@ package mineplex.core.common.block.schematic;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.util.Vector;
import com.mysql.jdbc.Util;
import mineplex.core.common.block.DataLocationMap; import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
@ -14,24 +17,47 @@ public class Schematic
private final short _length; private final short _length;
private final short[] _blocks; private final short[] _blocks;
private final byte[] _blockData; private final byte[] _blockData;
private final Vector _weOffset;
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData) public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset)
{ {
_width = width; _width = width;
_height = height; _height = height;
_length = length; _length = length;
_blocks = blocks; _blocks = blocks;
_blockData = blockData; _blockData = blockData;
_weOffset = worldEditOffset;
}
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData)
{
this(width, height, length, blocks, blockData, null);
}
public DataLocationMap paste(Location originLocation)
{
return paste(originLocation, false);
} }
public DataLocationMap paste(Location originLocation, boolean ignoreAir) public DataLocationMap paste(Location originLocation, boolean ignoreAir)
{ {
return paste(originLocation, ignoreAir, false);
}
public DataLocationMap paste(Location originLocation, boolean ignoreAir, boolean worldEditOffset)
{
if(worldEditOffset && hasWorldEditOffset())
{
originLocation = originLocation.clone().add(_weOffset);
}
DataLocationMap locationMap = new DataLocationMap(); DataLocationMap locationMap = new DataLocationMap();
int startX = originLocation.getBlockX(); int startX = originLocation.getBlockX();
int startY = originLocation.getBlockY(); int startY = originLocation.getBlockY();
int startZ = originLocation.getBlockZ(); int startZ = originLocation.getBlockZ();
UtilBlock.startQuickRecording();
for (int x = 0; x < _width; x++) for (int x = 0; x < _width; x++)
{ {
for (int y = 0; y < _height; y++) for (int y = 0; y < _height; y++)
@ -87,6 +113,8 @@ public class Schematic
} }
} }
UtilBlock.stopQuickRecording();
return locationMap; return locationMap;
} }
@ -142,6 +170,11 @@ public class Schematic
return false; return false;
} }
public boolean hasWorldEditOffset()
{
return _weOffset != null;
}
public int getSize() public int getSize()
{ {
return _blocks.length; return _blocks.length;

View File

@ -6,8 +6,11 @@ import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import org.bukkit.util.Vector;
import com.java.sk89q.jnbt.ByteArrayTag; import com.java.sk89q.jnbt.ByteArrayTag;
import com.java.sk89q.jnbt.CompoundTag; import com.java.sk89q.jnbt.CompoundTag;
import com.java.sk89q.jnbt.IntTag;
import com.java.sk89q.jnbt.NBTInputStream; import com.java.sk89q.jnbt.NBTInputStream;
import com.java.sk89q.jnbt.NamedTag; import com.java.sk89q.jnbt.NamedTag;
import com.java.sk89q.jnbt.ShortTag; import com.java.sk89q.jnbt.ShortTag;
@ -37,6 +40,15 @@ public class UtilSchematic
short[] blocks = new short[blockId.length]; short[] blocks = new short[blockId.length];
byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue(); byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
Vector weOffset = null;
if(schematic.containsKey("WEOffsetX") && schematic.containsKey("WEOffsetY") && schematic.containsKey("WEOffsetZ"))
{
int x = getChildTag(schematic, "WEOffsetX", IntTag.class).getValue();
int y = getChildTag(schematic, "WEOffsetY", IntTag.class).getValue();
int z = getChildTag(schematic, "WEOffsetZ", IntTag.class).getValue();
weOffset = new Vector(x, y, z);
}
if (schematic.containsKey("AddBlocks")) if (schematic.containsKey("AddBlocks"))
{ {
addId = getChildTag(schematic, "AddBlocks", ByteArrayTag.class).getValue(); addId = getChildTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
@ -56,7 +68,7 @@ public class UtilSchematic
} }
return new Schematic(width, height, length, blocks, blockData); return new Schematic(width, height, length, blocks, blockData, weOffset);
} }

View File

@ -0,0 +1,61 @@
package mineplex.core.common.events;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called just before UtilPlayer#message sends out a message to the specified Player.
*/
public class PlayerMessageEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private String _message;
private boolean _cancelled;
public PlayerMessageEvent(Player player, String message)
{
_player = player;
_message = message;
}
public Player getPlayer()
{
return _player;
}
public boolean isCancelled()
{
return _cancelled;
}
public String getMessage()
{
return _message;
}
public String getUnformattedMessage()
{
return ChatColor.stripColor(_message);
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -43,6 +43,38 @@ public class ChildJsonMessage extends JsonMessage
return this; return this;
} }
@Override
public ChildJsonMessage italic()
{
super.italic();
return this;
}
@Override
public ChildJsonMessage underlined()
{
super.underlined();
return this;
}
@Override
public ChildJsonMessage strikethrough()
{
super.strikethrough();
return this;
}
@Override
public ChildJsonMessage obfuscated()
{
super.obfuscated();
return this;
}
@Override @Override
public ChildJsonMessage click(String action, String value) public ChildJsonMessage click(String action, String value)
{ {
@ -51,6 +83,14 @@ public class ChildJsonMessage extends JsonMessage
return this; return this;
} }
@Override
public ChildJsonMessage click(ClickEvent event, String value)
{
super.click(event, value);
return this;
}
@Override @Override
public ChildJsonMessage hover(String action, String value) public ChildJsonMessage hover(String action, String value)
{ {
@ -59,6 +99,14 @@ public class ChildJsonMessage extends JsonMessage
return this; return this;
} }
@Override
public ChildJsonMessage hover(HoverEvent event, String value)
{
super.hover(event, value);
return this;
}
@Override @Override
public String toString() public String toString()
{ {

View File

@ -0,0 +1,16 @@
package mineplex.core.common.shape;
import org.bukkit.Location;
/**
* Interface used by classes which can display visuals at provided locations.
*/
public interface CosmeticShape
{
/**
* Display a visual at the given location
* @param loc The location to display the visual at
*/
void display(Location loc);
}

View File

@ -0,0 +1,189 @@
package mineplex.core.common.shape;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.util.Vector;
/**
* A simple 3D vector stored shape
*/
public class Shape
{
protected final static double DEFAULT_DENSITY = 1;
protected HashSet<Vector> _points = new HashSet<>();
public Shape(){}
public Shape(Collection<Vector> points){
this._points.addAll(points);
}
/**
* Rotate this shape along the X-axis
* @param radians Radians to rotate the shape
*/
public void rotateOnXAxis(double radians)
{
for(Vector v : _points)
{
double y = v.getY();
double z = v.getZ();
v.setY(y * Math.cos(radians) - z * Math.sin(radians));
v.setZ(y * Math.sin(radians) + z * Math.cos(radians));
}
}
/**
* Rotate this shape along the Y-axis
* @param radians Radians to rotate the shape
*/
public void rotateOnYAxis(double radians)
{
for(Vector v : _points)
{
double x = v.getX();
double z = v.getZ();
v.setX(x * Math.cos(radians) - z * Math.sin(radians));
v.setZ(x * Math.sin(radians) + z * Math.cos(radians));
}
}
/**
* Rotate this shape along the Z-axis
* @param radians Radians to rotate the shape
*/
public void rotateOnZAxis(double radians)
{
for(Vector v : _points)
{
double x = v.getX();
double y = v.getY();
v.setX(x * Math.cos(radians) - y * Math.sin(radians));
v.setY(x * Math.sin(radians) + y * Math.cos(radians));
}
}
/**
* Offsets all the points based on the given vector
* @param v
*/
public void add(Vector v)
{
for(Vector p : _points) p.add(v);
}
public void addPoint(Vector v)
{
_points.add(v);
}
public boolean removePoint(Vector v)
{
return _points.remove(v);
}
public Set<Vector> getPoints()
{
return new HashSet<>(_points);
}
/**
* Multiply all the points by m.
* If m > 1 then the shape will become larger.
* If m < 1 then the shape will become smaller.
* If m = 1 then the shape will stay the same.
* If m < 0 then the shape will become inverted.
* @param m
*/
public void multiply(double m)
{
for(Vector v : _points) v.multiply(m);
}
public Shape clone() {
List<Vector> list = new ArrayList<>();
for(Vector p : _points)
{
list.add(p.clone());
}
return new Shape(list);
}
public Vector getMidPoint()
{
return getMaxAABBCorner().subtract(getMinAABBCorner()).multiply(0.5);
}
public Vector getMaxAABBCorner()
{
Vector max = null;
for(Vector v : _points)
{
if(max == null)
{
max = v.clone();
continue;
}
if(v.getX() > max.getX()) max.setX(v.getX());
if(v.getY() > max.getY()) max.setY(v.getY());
if(v.getZ() > max.getZ()) max.setZ(v.getZ());
}
return max;
}
public Vector getMinAABBCorner()
{
Vector min = null;
for(Vector v : _points)
{
if(min == null)
{
min = v.clone();
continue;
}
if(v.getX() < min.getX()) min.setX(v.getX());
if(v.getY() < min.getY()) min.setY(v.getY());
if(v.getZ() < min.getZ()) min.setZ(v.getZ());
}
return min;
}
/**
* Get the closest length which will be a factor of the provided length, but not longer then max
* E.g. You want to split a length of 9 into even peaces, but the peaces should not be longer than the max 5, then this will
* return 4.5, as 4.5 goes 2 times to make up precisely 9.
* @param length The length which the returned factor should fit into
* @param max The max distance of the returned length
* @return The closest to length to be a factor of the provided length which is <= max
*/
public static double getRoundFactor(double length, double max)
{
return length/Math.ceil(length/max);
}
/**
* Get the closest RoundFactor length applied to a vector, using the vector as the max length. The returned vector is a cloned
* parallel vector to the provided length
* @param length The vector used as length and direction
* @param maxLength The max length of the new returned vector
* @return Returns a parallel vector to the given length vector which is also a factor of the provided vector, but not longer
* then maxLength
*
* @see #getRoundFactor(double, double)
*/
public static Vector getVectorFactor(Vector length, double maxLength)
{
return length.clone().multiply(getRoundFactor(length.length(), maxLength));
}
}

View File

@ -0,0 +1,71 @@
package mineplex.core.common.shape;
import org.bukkit.util.Vector;
/**
* An extension of {@link Shape} creating a simple box
*/
public class ShapeBox extends Shape
{
/**
* Define a parallelepiped using three vectors using default density {@link Shape#DefaultDensity} and is not hollow
* @param localx The first vector to use as local x direction, does not have to align to global x direction
* @param localy The second vector to use as local y direction, does not have to align to global y direction
* @param localz The third vector to use as local z direction, does not have to align to global z direction
*/
public ShapeBox(Vector localx, Vector localy, Vector localz)
{
this(localx, localy, localz, false, DEFAULT_DENSITY);
}
/**
* Define a parallelepiped using three vectors using default density {@link Shape#DefaultDensity}
* @param localx The first vector to use as local x direction, does not have to align to global x direction
* @param localy The second vector to use as local y direction, does not have to align to global y direction
* @param localz The third vector to use as local z direction, does not have to align to global z direction
* @param hollow If the parallelepiped box should be hollow or not
*/
public ShapeBox(Vector localx, Vector localy, Vector localz, boolean hollow)
{
this(localx, localy, localz, hollow, DEFAULT_DENSITY);
}
/**
* Define a parallelepiped using three vectors
* @param localx The first vector to use as local x direction, does not have to align to global x direction
* @param localy The second vector to use as local y direction, does not have to align to global y direction
* @param localz The third vector to use as local z direction, does not have to align to global z direction
* @param hollow If the parallelepiped box should be hollow or not
* @param density The density of the vector points
*/
public ShapeBox(Vector localx, Vector localy, Vector localz, boolean hollow, double density)
{
Vector x = Shape.getVectorFactor(localx, density);
Vector y = Shape.getVectorFactor(localx, density);
Vector z = Shape.getVectorFactor(localx, density);
int xm = (int) Math.sqrt(localx.lengthSquared()/x.lengthSquared());
int ym = (int) Math.sqrt(localy.lengthSquared()/y.lengthSquared());
int zm = (int) Math.sqrt(localz.lengthSquared()/z.lengthSquared());
for(int ix = 0; ix < xm; ix++)
{
for(int iy = 0; iy < ym; iy++)
{
for(int iz = 0; iz < zm; iz++)
{
if(hollow)
{
if(!(ix == 0 || ix == xm-1 || iy == 0 || iy == ym-1 || iz == 0 || iz == zm-1)) continue;
}
_points.add(x.clone().multiply(ix).add(y.clone().multiply(iy)).add(z.clone().multiply(iz)));
}
}
}
}
}

View File

@ -0,0 +1,64 @@
package mineplex.core.common.shape;
import org.bukkit.util.Vector;
/**
* A simple grid shape which uses string inputs to define points
*/
public class ShapeGrid extends Shape
{
/**
* Each string in the array represents a layer on the XY-plane, meaning the layers moves towards positive Z.
* Each line in the string represents a line on parallel with the X-axis, where the first line is on the top of the shape.
* Use '#' for each point and anything else for each "non-point".
* The finished shape will then be centered afterwards.
*/
public ShapeGrid(String... input)
{
this(DEFAULT_DENSITY, '#', input);
}
/**
* Each string in the array represents a layer on the XY-plane, meaning the layers moves towards positive Z.
* Each line in the string represents a line on parallel with the X-axis, where the first line is on the top of the shape.
* Use the <code>read</code> char for each point and anything else for each "non-point".
* The finished shape will then be centered afterwards.
*/
public ShapeGrid(char read, String...input)
{
this(DEFAULT_DENSITY, read, input);
}
/**
* Each string in the array represents a layer on the XY-plane, meaning the layers moves towards positive Z.
* Each line in the string represents a line on parallel with the X-axis.
* Use the <code>read</code> char for each point and anything else for each "non-point".
* The finished shape will then be centered afterwards.
*/
public ShapeGrid(double density, char read, String...input)
{
int lx = 0;
int ly = 0;
int lz = 0;
for(int y = 0; y < input.length; y++)
{
String[] lines = input[y].split("\n");
for(int z = 0; z < lines.length; z++)
{
String line = lines[z];
for(int x = 0; x < line.length(); x++)
{
if(line.charAt(x) == read) addPoint(new Vector(-x,-y+input.length,-z).multiply(density));
if(x > lx) lx = x;
if(-y+input.length > ly) ly = -y+input.length;
if(z > lz) lz= z;
}
}
}
add(new Vector(-lx,ly,-lz).multiply(-0.5*density));
}
}

View File

@ -0,0 +1,38 @@
package mineplex.core.common.shape;
import java.util.Collection;
import org.bukkit.util.Vector;
/**
* A bag collection of several shapes. This will add all the points from the given shapes into a new shape
*/
public class ShapeMulti extends Shape
{
/**
* @param shapes Shapes which points will be added to this instance of a shape
*/
public ShapeMulti(Collection<Shape> shapes)
{
for(Shape shape : shapes) addShape(shape);
}
/**
* @param shapes Shapes which points will be added to this instance of a shape
*/
public ShapeMulti(Shape... shapes)
{
for(Shape shape : shapes) addShape(shape);
}
/**
* Add all the points from the given shape to this shape
* @param shape
*/
public void addShape(Shape shape) {
for(Vector v : shape._points) add(v);
}
}

View File

@ -0,0 +1,67 @@
package mineplex.core.common.shape;
import org.bukkit.util.Vector;
/**
* A simple sphere defined using vector points extending {@link Shape}
*/
public class ShapeSphere extends Shape
{
/**
* Define a sphere with radius r that is not hollow and using default density {@link Shape#DefaultDensity}
* @param r Radius for the sphere
*/
public ShapeSphere(double r)
{
this(r,r,r);
}
/**
* A sphere with different radiuses on different planes that is not hollow and using default density {@link Shape#DefaultDensity}
* @param x Radius in x direction
* @param y Radius in y direction
* @param z Radius in z direction
*/
public ShapeSphere(double x, double y, double z)
{
this(x, y, z, false, DEFAULT_DENSITY);
}
/**
* A sphere with different radiuses on different planes using default density {@link Shape#DefaultDensity}
* @param x Radius in x direction
* @param y Radius in y direction
* @param z Radius in z direction
* @param hollow If the sphere should be hollow or not
*/
public ShapeSphere(double x, double y, double z, boolean hollow)
{
this(x, y, z, hollow, DEFAULT_DENSITY);
}
/**
* A sphere with different radiuses on different planes
* @param x Radius in x direction
* @param y Radius in y direction
* @param z Radius in z direction
* @param hollow If the sphere should be hollow or not
* @param density Density between points
*/
public ShapeSphere(double x, double y, double z, boolean hollow, double density)
{
for(double px = -x; px <= x; x += Shape.getRoundFactor(2*x, density))
{
for(double py = -y; py <= y; y += Shape.getRoundFactor(2*y, density))
{
for(double pz = -z; pz <= z; z += Shape.getRoundFactor(2*z, density))
{
if( hollow && px*px/x*x + py*py/y*y + pz*pz/z*z == 1) _points.add(new Vector(px,py,pz));
else if(!hollow && px*px/x*x + py*py/y*y + pz*pz/z*z <= 1) _points.add(new Vector(px,py,pz));
}
}
}
}
}

View File

@ -0,0 +1,173 @@
package mineplex.core.common.shape;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
/**
* Some simple wing shapes implementing {@link ICosmeticShape} storing additional particle information
*/
public class ShapeWings extends ShapeGrid implements CosmeticShape
{
public static final String[] ANGEL_WING_PATTERN = new String[]
{
"000$$0000000000$$000",
"00$##$00000000$##$00",
"0$####$000000$####$0",
"$#####$000000$#####$",
"$#####$000000$#####$",
"$######$0000$######$",
"$######$0000$######$",
"$######$0000$######$",
"$######$$$$$$######$",
"$##################$",
"0$################$0",
"00$####$$$$$$####$00",
"00$####$0000$####$00",
"000$##$000000$##$000",
"000$##$000000$##$000",
"000$#$00000000$#$000",
"00$#$0000000000$#$00",
"00$#$0000000000$#$00",
"000$000000000000$000",
};
public static final String[] BUTTERFLY_WING_PATTERN = new String[]
{
"0$$0000000000000000$$0",
"$##$00000000000000$##$",
"0$##$000000000000$##$0",
"00$##$0000000000$##$00",
"00$###$00000000$###$00",
"000$####$0000$####$000",
"000$######$$#####$0000",
"0000$############$0000",
"00000$##########$00000",
"00000$##########$00000",
"00000$####$$$###$00000",
"00000$###$000$###$0000",
"00000$##$00000$##$0000",
"000000$000000000$00000"
};
/**
* Default rotation to give the wings a little tilt when displayed on players for instance
*/
public static double DEFAULT_ROTATION = Math.PI/0.05;
private String _particle;
private Vector _offsetData;
private float _speed;
private int _count;
/**
* A simple non-edge wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}. It also uses default redstone dust particle with offset of 0, speed of 0 and count 1
*/
public ShapeWings()
{
this(ParticleType.RED_DUST.particleName);
}
/**
* A simple non-edge wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}
* @param particle The particle to display at each point in the wing shape. Using offset of 0, speed of 0 and count 1
*/
public ShapeWings(String particle)
{
this(particle, null, 0, 1);
}
/**
* A simple non-edge wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count)
{
this(particle, offsetData, speed, count, false);
}
/**
* A simple wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
* @param edge If this is the edge of the wings or not
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count, boolean edge)
{
this(particle, offsetData, speed, count, edge, DEFAULT_ROTATION);
}
/**
* A simple wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
* @param edge If this is the edge of the wings or not
* @param xRotation Rotation on the x axis
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count, boolean edge, double xRotation)
{
this(particle, offsetData, speed, count, edge, xRotation, BUTTERFLY_WING_PATTERN);
}
/**
* A simple wing shape
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
* @param edge If this is the edge of the wings or not
* @param xRotation Rotation on the x axis
* @param pattern Pattern to use as wing shape
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count, boolean edge, double xRotation, String... pattern)
{
super(0.15, edge? '$' : '#',
pattern
);
_particle = particle;
_offsetData = offsetData;
_speed = speed;
_count = count;
rotateOnXAxis(xRotation);
}
@Override
public void display(Location loc)
{
Shape clone = clone();
clone.rotateOnYAxis(Math.toRadians(loc.getYaw()));
for(Vector v : clone._points)
{
Location ploc = loc.clone().add(v);
displayParticle(ploc);
}
}
/**
* Display a single particle of the type provided to this shape at the given location.
*/
public void displayParticle(Location loc)
{
UtilParticle.PlayParticleToAll(_particle, loc, _offsetData, _speed, _count, ViewDist.NORMAL);
}
}

View File

@ -3,7 +3,6 @@ package mineplex.core.common.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Queue;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -28,9 +27,9 @@ import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.Bed; import org.bukkit.material.Bed;
import mineplex.core.common.block.MultiBlockUpdaterAgent;
import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.IBlockData; import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.Item; import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
@ -92,6 +91,8 @@ public class UtilBlock
*/ */
public static HashSet<BlockFace> horizontals = new HashSet<>(); public static HashSet<BlockFace> horizontals = new HashSet<>();
private static MultiBlockUpdaterAgent _quickChangeRecorder;
static static
{ {
@ -604,14 +605,52 @@ public class UtilBlock
return getInBoundingBox(a, b, true); return getInBoundingBox(a, b, true);
} }
public static ArrayList<Block> getInBoundingBox(Location a, Location b, boolean ignoreAir) public static ArrayList<Block> getInBoundingBox(Location a, Location b, boolean ignoreAir) {
return getInBoundingBox(a, b, ignoreAir, false, true, true);
}
public static ArrayList<Block> getInBoundingBox(Location a, Location b, boolean ignoreAir, boolean hollow, boolean walls, boolean ceilfloor)
{ {
ArrayList<Block> blocks = new ArrayList<Block>(); ArrayList<Block> blocks = new ArrayList<Block>();
for (int x = Math.min(a.getBlockX(), b.getBlockX()); x <= Math.max(a.getBlockX(), b.getBlockX()); x++) int xmin = Math.min(a.getBlockX(), b.getBlockX());
for (int y = Math.min(a.getBlockY(), b.getBlockY()); y <= Math.max(a.getBlockY(), b.getBlockY()); y++) int xmax = Math.max(a.getBlockX(), b.getBlockX());
for (int z = Math.min(a.getBlockZ(), b.getBlockZ()); z <= Math.max(a.getBlockZ(), b.getBlockZ()); z++)
int ymin = Math.min(a.getBlockY(), b.getBlockY());
int ymax = Math.max(a.getBlockY(), b.getBlockY());
int zmin = Math.min(a.getBlockZ(), b.getBlockZ());
int zmax = Math.max(a.getBlockZ(), b.getBlockZ());
for (int x = xmin; x <= xmax; x++)
for (int y = ymin; y <= ymax; y++)
for (int z = zmin; z <= zmax; z++)
{ {
if(hollow)
{
if(!(x == xmin || x == xmax || y == ymin || y == ymax || z == zmin || z == zmax)) continue;
}
if(!walls)
{
if(
(x == xmin || x == xmax) ||
(z == zmin || z == zmax)
)
{
continue;
}
}
if(!ceilfloor)
{
if(y == ymin || y == ymax)
{
continue;
}
}
Block block = a.getWorld().getBlockAt(x, y, z); Block block = a.getWorld().getBlockAt(x, y, z);
if (ignoreAir) if (ignoreAir)
@ -619,8 +658,10 @@ public class UtilBlock
if (block.getType() != Material.AIR) blocks.add(block); if (block.getType() != Material.AIR) blocks.add(block);
} }
else else
{
blocks.add(block); blocks.add(block);
} }
}
return blocks; return blocks;
} }
@ -1466,6 +1507,39 @@ public class UtilBlock
return state.update(false, false); return state.update(false, false);
} }
/**
* See {@link #setQuick(World, int, int, int, int, byte)}
*/
public static void startQuickRecording()
{
if(_quickChangeRecorder != null)
{
_quickChangeRecorder.send();
_quickChangeRecorder.reset();
}
else
{
_quickChangeRecorder = new MultiBlockUpdaterAgent();
}
}
/**
* See {@link #setQuick(World, int, int, int, int, byte)}
*/
public static void stopQuickRecording()
{
if(_quickChangeRecorder == null) return;
_quickChangeRecorder.send();
_quickChangeRecorder.reset();
_quickChangeRecorder = null;
}
/**
* This doesn't send the block changes to the client. If you want to change lots of blocks and then send it to the player
* then do <code>startQuickRecording()</code> first. Change all the blocks you want. Then to send it do
* <code>stopQuickRecording()</code>. This will automatically send all the block changes to all relevant players.
*/
public static void setQuick(World world, int x, int y, int z, int type, byte data) public static void setQuick(World world, int x, int y, int z, int type, byte data)
{ {
int cx = x >> 4; int cx = x >> 4;
@ -1482,6 +1556,11 @@ public class UtilBlock
IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getById(type).fromLegacyData(data); IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getById(type).fromLegacyData(data);
chunk.a(pos, ibd); chunk.a(pos, ibd);
nmsWorld.notify(pos); nmsWorld.notify(pos);
if(_quickChangeRecorder != null)
{
_quickChangeRecorder.addBlock(world.getBlockAt(x, y, z));
}
} }
/** /**
@ -1507,4 +1586,35 @@ public class UtilBlock
{ {
return boundless(origin.getLocation(), radius); return boundless(origin.getLocation(), radius);
} }
/**
* Gets the max distance this blocks bounding box extends in the given block face. E.g. stone have a max:min of 1:0 in all direction.
* Slabs have 0:1 in horizontal directions, but 0:0.5 or 0.5:1 depending on if it is top or bottom.
* @param block The block to test
* @param blockFace The direction to test in
* @return
*/
public static double getSize(Block block, BlockFace blockFace)
{
BlockPosition bpos = new BlockPosition(block.getX(), block.getY(), block.getZ());
net.minecraft.server.v1_8_R3.Block b = ((CraftWorld)block.getWorld()).getHandle().c(bpos);
switch (blockFace)
{
default:
case WEST:
return b.B(); //min-x
case EAST:
return b.C(); //max-x
case DOWN:
return b.D(); //min-y
case UP:
return b.E(); //max-y
case NORTH:
return b.F(); //min-z
case SOUTH:
return b.G(); //max-z
}
}
} }

View File

@ -1,6 +1,13 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import javax.annotation.Nonnull;
/** /**
* Created by Shaun on 11/12/2014. * Created by Shaun on 11/12/2014.
@ -13,6 +20,8 @@ public class UtilColor
public static final RGBData RgbLightRed = hexToRgb(0xeb1c1c); public static final RGBData RgbLightRed = hexToRgb(0xeb1c1c);
public static final RGBData RgbPurple = hexToRgb(0x9c17a3); public static final RGBData RgbPurple = hexToRgb(0x9c17a3);
public static final Color DEFAULT_LEATHER_COLOR = Color.fromRGB(160, 101, 64);
public static byte chatColorToClayData(ChatColor chatColor) public static byte chatColorToClayData(ChatColor chatColor)
{ {
//TODO //TODO
@ -72,6 +81,52 @@ public class UtilColor
} }
} }
public static ChatColor woolDataToChatColor(byte data)
{
switch (data)
{
case 0:
return ChatColor.WHITE;
case 1:
return ChatColor.GOLD;
case 2:
return ChatColor.DARK_PURPLE;
case 3:
return ChatColor.BLUE;
case 4:
return ChatColor.YELLOW;
case 5:
return ChatColor.GREEN;
case 6:
return ChatColor.LIGHT_PURPLE;
case 7:
return ChatColor.DARK_GRAY;
case 8:
return ChatColor.GRAY;
case 9:
return ChatColor.DARK_AQUA;
case 10:
return ChatColor.DARK_PURPLE;
case 11:
return ChatColor.DARK_BLUE;
case 12:
return ChatColor.DARK_RED;
case 13:
return ChatColor.DARK_GREEN;
case 14:
return ChatColor.RED;
case 15:
return ChatColor.BLACK;
default:
return ChatColor.WHITE;
}
}
public static Vector colorToVector(Color color)
{
return new Vector(Math.max(color.getRed()/255.0, 0.00001f), color.getGreen()/255.0, color.getBlue()/255.0);
}
public static RGBData hexToRgb(int hex) public static RGBData hexToRgb(int hex)
{ {
return new RGBData(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF); return new RGBData(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF);
@ -91,4 +146,73 @@ public class UtilColor
{ {
return new RGBData(r, g, b); return new RGBData(r, g, b);
} }
public static Color getNextColor(Color original, Color finalColor, int increment)
{
int red = original.getRed(), green = original.getGreen(), blue = original.getBlue();
if (red > finalColor.getRed())
red -= increment;
else if (red < finalColor.getRed())
red += increment;
else if (green > finalColor.getGreen())
green -= increment;
else if (green < finalColor.getGreen())
green += increment;
else if (blue > finalColor.getBlue())
blue -= increment;
else if (blue < finalColor.getBlue())
blue += increment;
red = UtilMath.clamp(red, 0, 255);
green = UtilMath.clamp(green, 0, 255);
blue = UtilMath.clamp(blue, 0, 255);
return Color.fromRGB(red, green, blue);
}
/**
* Applies Color to a Leather armor
* @param itemStack
* @param color
* @return ItemStack with color applied
*/
public static ItemStack applyColor(@Nonnull ItemStack itemStack, Color color)
{
switch (itemStack.getType())
{
case LEATHER_HELMET:
case LEATHER_CHESTPLATE:
case LEATHER_LEGGINGS:
case LEATHER_BOOTS:
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta();
leatherArmorMeta.setColor(color);
itemStack.setItemMeta(leatherArmorMeta);
return itemStack;
default:
return itemStack;
}
}
/**
* Gets color from Leather armor
* @param itemStack
* @return Color of the item
*/
public static Color getItemColor(@Nonnull ItemStack itemStack)
{
switch (itemStack.getType())
{
case LEATHER_HELMET:
case LEATHER_CHESTPLATE:
case LEATHER_LEGGINGS:
case LEATHER_BOOTS:
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta();
return leatherArmorMeta.getColor();
default:
return DEFAULT_LEATHER_COLOR;
}
}
} }

View File

@ -258,6 +258,21 @@ public class UtilEnt
} }
} }
public static void addGoalSelector(Entity entity, int priority, PathfinderGoal goal)
{
try
{
if(((CraftEntity)entity).getHandle() instanceof EntityInsentient)
{
((EntityInsentient)((CraftEntity)entity).getHandle()).goalSelector.a(priority, goal);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void Rotate(LivingEntity entity, float yaw, float pitch) public static void Rotate(LivingEntity entity, float yaw, float pitch)
{ {
EntityLiving handle = ((CraftLivingEntity) entity).getHandle(); EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
@ -857,6 +872,11 @@ public class UtilEnt
return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9; return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9;
} }
public static void setBoundingBox(Entity ent, double width, double height)
{
((CraftEntity)ent).getHandle().setSize((float) width, (float)height);
}
public static void SetMetadata(Entity entity, String key, Object value) public static void SetMetadata(Entity entity, String key, Object value)
{ {
entity.setMetadata(key, new FixedMetadataValue(UtilServer.getPlugin(), value)); entity.setMetadata(key, new FixedMetadataValue(UtilServer.getPlugin(), value));
@ -879,4 +899,40 @@ public class UtilEnt
equipment.setItemInHand(item); equipment.setItemInHand(item);
} }
public static byte getEntityEggData(EntityType type)
{
switch (type)
{
case CREEPER: return (byte) 50;
case SKELETON: return (byte) 51;
case SPIDER: return (byte) 52;
case ZOMBIE: return (byte) 54;
case SLIME: return (byte) 55;
case GHAST: return (byte) 56;
case PIG_ZOMBIE: return (byte) 57;
case ENDERMAN: return (byte) 58;
case CAVE_SPIDER: return (byte) 59;
case SILVERFISH: return (byte) 60;
case BLAZE: return (byte) 61;
case MAGMA_CUBE: return (byte) 62;
case BAT: return (byte) 65;
case WITCH: return (byte) 66;
case ENDERMITE: return (byte) 67;
case GUARDIAN: return (byte) 68;
//case SHULKER: return (byte) 69;
case PIG: return (byte) 90;
case SHEEP: return (byte) 91;
case COW: return (byte) 92;
case CHICKEN: return (byte) 93;
case SQUID: return (byte) 94;
case WOLF: return (byte) 95;
case MUSHROOM_COW: return (byte) 96;
case OCELOT: return (byte) 98;
case HORSE: return (byte) 100;
case RABBIT: return (byte) 101;
case VILLAGER: return (byte) 120;
default: return 0;
}
}
} }

View File

@ -193,6 +193,13 @@ public class UtilGear
return item.getType() == mat; return item.getType() == mat;
} }
public static boolean isMatAndData(ItemStack item, Material mat, byte data)
{
if (item == null) return false;
return item.getType() == mat && item.getData().getData() == data;
}
public static boolean isRepairable(ItemStack item) public static boolean isRepairable(ItemStack item)
{ {
return (item.getType().getMaxDurability() > 0); return (item.getType().getMaxDurability() > 0);

View File

@ -9,13 +9,21 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.structs.ItemContainer; import mineplex.core.common.structs.ItemContainer;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagLong;
public class UtilItem public class UtilItem
{ {
@ -1148,6 +1156,66 @@ public class UtilItem
return i; return i;
} }
/**
*
* @param item The item stack to use as source for this Item entity
* @param loc Location of where to spawn the Item entity
* @param dropNaturaly If false then no velocity is applied. If true then it drops with random velocity like from when blocks break.
* @param allowPickup If false then it will disable pickup of this item.
* @param ticksToLive Ticks before this item should be removed from the ground. (default 6000 ticks = 5min, -1 to never remove it)
* @param allowMerge If false then the item will not merge with any other items.
* @return
*/
public static Item dropItem(ItemStack item, Location loc, boolean dropNaturaly, boolean allowPickup, int ticksToLive, boolean allowMerge)
{
Item ent;
if(dropNaturaly)
{
ent = loc.getWorld().dropItemNaturally(loc, item);
} else {
ent = loc.getWorld().dropItem(loc, item);
}
if(!allowPickup)
{
ent.setPickupDelay(32767);
}
ent.setTicksLived(32768);
UtilEnt.SetMetadata(ent, "UtilItemSpawning", true);
if(ticksToLive != -1)
{
Plugin plugin = Bukkit.getPluginManager().getPlugin("Hub");
if(plugin == null) plugin = Bukkit.getPluginManager().getPlugin("Arcade");
if(plugin == null) plugin = Bukkit.getPluginManager().getPlugins()[0];
new BukkitRunnable()
{
public void run()
{
ent.remove();
}
}.runTaskLater(plugin, ticksToLive);
}
if(!allowMerge)
{
net.minecraft.server.v1_8_R3.ItemStack stack = CraftItemStack.asNMSCopy(ent.getItemStack());
NBTTagCompound tag = stack.getTag();
if(!stack.hasTag())
{
stack.setTag(new NBTTagCompound());
tag = stack.getTag();
}
tag.set("Pickup_" + UtilMath.r(Integer.MAX_VALUE), new NBTTagLong(UtilMath.random.nextLong()));
ent.setItemStack(CraftItemStack.asBukkitCopy(stack));
}
return ent;
}
public static double getAttackDamage(Material type) public static double getAttackDamage(Material type)
{ {
return ItemDamage.get(type); return ItemDamage.get(type);

View File

@ -12,7 +12,26 @@ public class UtilParticle
{ {
public enum ViewDist public enum ViewDist
{ {
SHORT(8), NORMAL(24), LONG(48), LONGER(96), MAX(256); /**
* 8 blocks
*/
SHORT(8),
/**
* 24 blocks
*/
NORMAL(24),
/**
* 48 blocks
*/
LONG(48),
/**
* 96 blocks
*/
LONGER(96),
/**
* 256 blocks
*/
MAX(256);
private int _dist; private int _dist;

View File

@ -1,15 +1,8 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.Collection; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -28,16 +21,20 @@ import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.MinecraftVersion; import mineplex.core.common.MinecraftVersion;
import net.minecraft.server.v1_8_R3.EntityPlayer; import mineplex.core.common.events.PlayerMessageEvent;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PlayerConnection;
public class UtilPlayer public class UtilPlayer
{ {
private static Random RANDOM = new Random(); private static Random RANDOM = new Random();
// A mapping of player names (Keys) to the system time when they last changed active Hotbar Slot // A mapping of player names (Keys) to the system time when they last changed active Hotbar Slot
private static Map<String, Long> _hotbarUpdates = new HashMap<String, Long>(); private static Map<String, Long> _hotbarUpdates = new HashMap<>();
// A mapping of player UUIDs (Keys) to the world border they are using (if they are using)
private static final Map<UUID, WorldBorder> WORLD_BORDERS = new HashMap<>();
// A mapping of player UUIDs (Keys) to the list of command they're allowed
private static final Map<UUID, List<String>> ALLOWED_COMMANDS = new HashMap<>();
// The amount of time (in milliseconds) after changin hotbars that you can block // The amount of time (in milliseconds) after changin hotbars that you can block
public static final long BLOCKING_HOTBAR_DELAY = 100; public static final long BLOCKING_HOTBAR_DELAY = 100;
@ -68,6 +65,38 @@ public class UtilPlayer
return true; return true;
} }
public static void hideFrom(Player player, Collection<Player> players) {
players.stream().forEach(p->p.hidePlayer(player));
}
public static void showFor(Player player, Collection<Player> players) {
players.stream().forEach(p->p.hidePlayer(player));
}
public static void hideFromAll(Player player, Collection<Player> except) {
UtilServer.getPlayersCollection().stream().filter(p->!except.contains(p)).forEach(p->p.hidePlayer(player));
}
public static void showForAll(Player player, Collection<Player> except) {
UtilServer.getPlayersCollection().stream().filter(p->!except.contains(p)).forEach(p->p.showPlayer(player));
}
public static void hideFrom(Player player, Player...players) {
hideFrom(player, Arrays.asList(players));
}
public static void showFor(Player player, Player...players) {
showFor(player, Arrays.asList(players));
}
public static void hideFromAll(Player player, Player...players) {
hideFromAll(player, Arrays.asList(players));
}
public static void showForAll(Player player, Player...players) {
showForAll(player, Arrays.asList(players));
}
public static boolean is1_9(Player player) public static boolean is1_9(Player player)
{ {
return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() > 47; return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() > 47;
@ -277,6 +306,12 @@ public class UtilPlayer
message = UtilWiki.link(message); message = UtilWiki.link(message);
*/ */
PlayerMessageEvent event = UtilServer.CallEvent(new PlayerMessageEvent((Player) client, message));
if (event.isCancelled())
return;
((Player) client).sendMessage(message); ((Player) client).sendMessage(message);
} }
@ -816,6 +851,45 @@ public class UtilPlayer
((CraftPlayer) player).getHandle().setWingsDeployAt(distance); ((CraftPlayer) player).getHandle().setWingsDeployAt(distance);
} }
/**
* Sets the world border red screen for a player
* @param player
* @param warningDistance
*/
public static void sendRedScreen(Player player, int warningDistance)
{
WorldBorder worldBorder = WORLD_BORDERS.computeIfAbsent(player.getUniqueId(), uuid -> new WorldBorder());
worldBorder.setCenter(player.getLocation().getX(), player.getLocation().getZ());
worldBorder.setSize(10000);
worldBorder.setWarningDistance(warningDistance);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE);
sendPacket(player, packet);
WORLD_BORDERS.put(player.getUniqueId(), worldBorder);
}
/**
* Checks if player has a WorldBorder object stored
* @param player
* @return true if WorldBorder object is stored for that player
*/
public static boolean hasWorldBorder(Player player)
{
return WORLD_BORDERS.containsKey(player.getUniqueId());
}
/**
* Removes player from world border map
* @param player
*/
public static void removeWorldBorder(Player player)
{
if (hasWorldBorder(player))
{
sendRedScreen(player, 0);
WORLD_BORDERS.remove(player.getUniqueId());
}
}
public static MinecraftVersion getVersion(Player player) public static MinecraftVersion getVersion(Player player)
{ {
if (is1_9(player)) if (is1_9(player))
@ -823,4 +897,44 @@ public class UtilPlayer
return MinecraftVersion.Version1_8; return MinecraftVersion.Version1_8;
} }
/**
* Allows player to run specific command
* @param player The player to be allowed
* @param command The command that will be allowed
*/
public static void allowCommand(Player player, String command)
{
List<String> commandList = new ArrayList<>();
if (ALLOWED_COMMANDS.containsKey(player.getUniqueId()))
commandList = ALLOWED_COMMANDS.get(player.getUniqueId());
if (!commandList.contains(command))
commandList.add(command);
ALLOWED_COMMANDS.put(player.getUniqueId(), commandList);
}
/**
* Disallows player to run specific command
* @param player The player to be disallowed
* @param command The command that will be disallowed
* @return True if player had command allowed
*/
public static boolean disallowCommand(Player player, String command)
{
if (!isCommandAllowed(player, command))
return false;
List<String> commandList = ALLOWED_COMMANDS.get(player.getUniqueId());
commandList.remove(command);
ALLOWED_COMMANDS.put(player.getUniqueId(), commandList);
return true;
}
public static boolean isCommandAllowed(Player player, String command)
{
if (!ALLOWED_COMMANDS.containsKey(player.getUniqueId()))
return false;
if (!ALLOWED_COMMANDS.get(player.getUniqueId()).contains(command))
return false;
return true;
}
} }

View File

@ -1,15 +1,8 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.lang.reflect.Field; import com.google.common.collect.Lists;
import java.util.ArrayList; import mineplex.core.common.events.PlayerRecieveBroadcastEvent;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -20,9 +13,8 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.collect.Lists; import java.lang.reflect.Field;
import java.util.*;
import mineplex.core.common.events.PlayerRecieveBroadcastEvent;
public class UtilServer public class UtilServer
{ {
@ -139,21 +131,6 @@ public class UtilServer
runnable.runTaskTimer(getPlugin(), time, 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() public static String getServerName()
{ {
if (_serverName == null) if (_serverName == null)

View File

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

View File

@ -6,7 +6,6 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -17,8 +16,10 @@ import mineplex.core.common.CurrencyType;
public class UtilText public class UtilText
{ {
private static HashMap<Character, Integer> _characters = new HashMap<Character, Integer>(); private static HashMap<Character, Integer> _characters = new HashMap<>();
private static HashMap<Character, BufferedImage> _characterImages = new HashMap<Character, BufferedImage>(); private static HashMap<Character, BufferedImage> _characterImages = new HashMap<>();
private final static char[] VOWELS = new char[]{'a', 'e', 'i', 'o', 'u'};
static static
{ {
@ -286,12 +287,7 @@ public class UtilText
public static String[] splitLineToArray(String string, LineFormat lineFormat) public static String[] splitLineToArray(String string, LineFormat lineFormat)
{ {
ArrayList<String> lineList = splitLine(string, lineFormat); return splitLinesToArray(string.split("\n"), lineFormat);
String[] lineArray = new String[lineList.size()];
lineArray = lineList.toArray(lineArray);
return lineArray;
} }
public static ArrayList<String> splitLine(String string, LineFormat lineFormat) public static ArrayList<String> splitLine(String string, LineFormat lineFormat)
@ -308,7 +304,7 @@ public class UtilText
// Empty // Empty
if (string.equals("") || string.equals(" ")) if (string.equals("") || string.equals(" "))
{ {
strings.add(string); strings.add(" ");
return strings; return strings;
} }
@ -624,7 +620,20 @@ public class UtilText
public static boolean plural(int x) public static boolean plural(int x)
{ {
return x <= 0 ? true : x > 1; return x != 1;
}
public static String plural(String word, int amount)
{
if(!plural(amount)) return word;
String sufix = "s";
if(word.endsWith("s") || word.endsWith("x") || word.endsWith("z") || word.endsWith("ch")) sufix = "es";
else if(word.endsWith("y"))
{
word.substring(0, word.length()-2);
sufix = "ies";
}
return word + sufix;
} }
public static String trim(int maxLength, String s) public static String trim(int maxLength, String s)
@ -698,4 +707,43 @@ public class UtilText
return possesiveNoun.endsWith("s") ? possesiveNoun + "' " + noun : possesiveNoun + "'s " + noun; return possesiveNoun.endsWith("s") ? possesiveNoun + "' " + noun : possesiveNoun + "'s " + noun;
} }
public static boolean startsWithVowel(String word)
{
if(word == null || word.isEmpty()) return false;
char v = word.toLowerCase().charAt(0);
for(char c : VOWELS)
{
if(c == v) return true;
}
return false;
}
public static String getPronoun(String word)
{
return startsWithVowel(word) ? "an" : "a";
}
public static String prefixPronoun(String word)
{
return getPronoun(word) + " " + word;
}
/**
* Do a replaceAll on all strings in the array. It will replace the strings inside
* the given array. The returned array is the same instance as the one provided.
*/
public static String[] replaceAll(String[] array, String regex, String replacement)
{
if(array == null) return null;
for(int i = 0; i < array.length; i++)
{
if(array[i] == null) continue;
array[i] = array[i].replaceAll(regex, replacement);
}
return array;
}
} }

View File

@ -54,6 +54,7 @@ public class WorldUtil
generator = server.getGenerator(name); generator = server.getGenerator(name);
} }
Convertable converter = new WorldLoaderServer(server.getWorldContainer()); Convertable converter = new WorldLoaderServer(server.getWorldContainer());
if (converter.isConvertable(name)) if (converter.isConvertable(name))
{ {

View File

@ -0,0 +1,24 @@
package mineplex.core.common.util.worldgen;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
/**
* A simple clean room void chunk generator
*/
public class WorldGenCleanRoom extends ChunkGenerator
{
/**
* Creates a clean void chunk with no blocks
*/
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
{
return createChunkData(world);
}
}

View File

@ -442,8 +442,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
newPacket.a = entry.getKey(); newPacket.a = entry.getKey();
newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK newPacket.action = usePacket.action;
: EnumEntityUseAction.INTERACT; newPacket.c = usePacket.c;
{ {
((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);

View File

@ -1,8 +1,5 @@
package mineplex.core; package mineplex.core;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -99,12 +96,12 @@ public abstract class MiniPlugin implements Listener
public final void addCommand(ICommand command) public final void addCommand(ICommand command)
{ {
CommandCenter.Instance.AddCommand(command); CommandCenter.Instance.addCommand(command);
} }
public final void removeCommand(ICommand command) public final void removeCommand(ICommand command)
{ {
CommandCenter.Instance.RemoveCommand(command); CommandCenter.Instance.removeCommand(command);
} }
public void log(String message) public void log(String message)

View File

@ -38,7 +38,7 @@ public class TestRank extends CommandBase<CoreClientManager>
if (args == null) if (args == null)
{ {
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + AliasUsed + " MODERATOR")); UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " MODERATOR"));
} }
else else
{ {

View File

@ -30,7 +30,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
{ {
if (args == null) if (args == null)
{ {
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + AliasUsed + " joeschmo MODERATOR")); UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " joeschmo MODERATOR"));
} }
else else
{ {

View File

@ -6,7 +6,6 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.game.GameCategory;
import mineplex.core.game.GameDisplay; import mineplex.core.game.GameDisplay;
import mineplex.core.stats.PlayerStats; import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
@ -20,15 +19,15 @@ public enum AchievementCategory
GLOBAL("Global", null, GLOBAL("Global", null,
new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null, new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null,
new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote"), null, new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") }, new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote"), null, new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") },
Material.EMERALD, 0, GameCategory.GLOBAL, "None"), Material.EMERALD, 0, GameCategory.GLOBAL, "None", false, -1),
HOLIDAY("Holiday Achievements", null, HOLIDAY("Holiday Achievements", null,
new StatDisplay[] {}, new StatDisplay[] {},
Material.CAKE, 0, GameCategory.HOLIDAY, "None"), Material.CAKE, 0, GameCategory.HOLIDAY, "None", false, -1),
BRIDGES("The Bridges", null, BRIDGES("The Bridges", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_PICKAXE, 0, GameCategory.SURVIVAL, "Destructor Kit"), Material.IRON_PICKAXE, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Bridge.getGameId()),
SURVIVAL_GAMES("Survival Games", null, SURVIVAL_GAMES("Survival Games", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED,
@ -36,7 +35,7 @@ public enum AchievementCategory
StatDisplay.fromGame("Wins", GameDisplay.SurvivalGamesTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SurvivalGamesTeams, "Wins", "Losses"), StatDisplay.fromGame("Wins", GameDisplay.SurvivalGamesTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SurvivalGamesTeams, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.SurvivalGamesTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SurvivalGamesTeams, "Deaths"), StatDisplay.fromGame("Kills", GameDisplay.SurvivalGamesTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SurvivalGamesTeams, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.SurvivalGamesTeams, "GemsEarned") }, StatDisplay.fromGame("Gems Earned", GameDisplay.SurvivalGamesTeams, "GemsEarned") },
Material.DIAMOND_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"), Material.DIAMOND_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit", false, GameDisplay.SurvivalGames.getGameId(), GameDisplay.SurvivalGamesTeams.getGameId()),
SKYWARS("Skywars",null, SKYWARS("Skywars",null,
new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED,
@ -44,28 +43,28 @@ public enum AchievementCategory
StatDisplay.fromGame("Wins", GameDisplay.SkywarsTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkywarsTeams, "Wins", "Losses"), StatDisplay.fromGame("Wins", GameDisplay.SkywarsTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkywarsTeams, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.SkywarsTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkywarsTeams, "Deaths"), StatDisplay.fromGame("Kills", GameDisplay.SkywarsTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkywarsTeams, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.SkywarsTeams, "GemsEarned") }, StatDisplay.fromGame("Gems Earned", GameDisplay.SkywarsTeams, "GemsEarned") },
Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit"), Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()),
UHC("Ultra Hardcore", null, UHC("Ultra Hardcore", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"), Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None", false, GameDisplay.UHC.getGameId()),
MC_LEAGUE("MC League", null, MC_LEAGUE("MC League", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None"), Material.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None", true, GameDisplay.Minecraft_League.getGameId()),
WIZARDS("Wizards", null, WIZARDS("Wizards", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit"), Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit", false, GameDisplay.Wizards.getGameId()),
CASTLE_SIEGE("Castle Siege", null, CASTLE_SIEGE("Castle Siege", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"), new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"),
new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED }, new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED },
Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null), Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiege.getGameId()),
BLOCK_HUNT("Block Hunt", null, BLOCK_HUNT("Block Hunt", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GRASS, 0, GameCategory.CLASSICS, "Infestor Kit"), Material.GRASS, 0, GameCategory.CLASSICS, "Infestor Kit", false, GameDisplay.HideSeek.getGameId()),
SMASH_MOBS("Super Smash Mobs", null, SMASH_MOBS("Super Smash Mobs", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED,
@ -73,92 +72,92 @@ public enum AchievementCategory
StatDisplay.fromGame("Wins", GameDisplay.SmashTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SmashTeams, "Wins", "Losses"), StatDisplay.fromGame("Wins", GameDisplay.SmashTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SmashTeams, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.SmashTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SmashTeams, "Deaths"), StatDisplay.fromGame("Kills", GameDisplay.SmashTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SmashTeams, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.SmashTeams, "GemsEarned")}, StatDisplay.fromGame("Gems Earned", GameDisplay.SmashTeams, "GemsEarned")},
Material.SKULL_ITEM, 4, GameCategory.CLASSICS, "Sheep Kit"), Material.SKULL_ITEM, 4, GameCategory.CLASSICS, "Sheep Kit", false, GameDisplay.Smash.getGameId(), GameDisplay.SmashTeams.getGameId()),
MINE_STRIKE("MineStrike", null, MINE_STRIKE("MineStrike", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.TNT, 0, GameCategory.CLASSICS, "None"), Material.TNT, 0, GameCategory.CLASSICS, "None", false, GameDisplay.MineStrike.getGameId()),
DRAW_MY_THING("Draw My Thing", null, DRAW_MY_THING("Draw My Thing", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit"), Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit", false, GameDisplay.Draw.getGameId()),
CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM", "Champions CTF"}, CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM", "Champions CTF"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay("Flags Captured", "Captures") }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay("Flags Captured", "Captures") },
Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"), Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills", false, GameDisplay.ChampionsCTF.getGameId(), GameDisplay.ChampionsDominate.getGameId(), GameDisplay.ChampionsTDM.getGameId()),
MASTER_BUILDERS("Master Builders", null, MASTER_BUILDERS("Master Builders", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
Material.WOOD, 0, GameCategory.CLASSICS, "None"), Material.WOOD, 0, GameCategory.CLASSICS, "None", false, GameDisplay.Build.getGameId()),
//Arcade //Arcade
DRAGONS("Dragons", null, DRAGONS("Dragons", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
Material.ENDER_STONE, 0, GameCategory.ARCADE, null), Material.ENDER_STONE, 0, GameCategory.ARCADE, null, false, GameDisplay.Dragons.getGameId()),
DRAGON_ESCAPE("Dragon Escape", null, DRAGON_ESCAPE("Dragon Escape", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
Material.DRAGON_EGG, 0, GameCategory.ARCADE, "Digger Kit"), Material.DRAGON_EGG, 0, GameCategory.ARCADE, "Digger Kit", false, GameDisplay.DragonEscape.getGameId()),
SHEEP_QUEST("Sheep Quest", null, SHEEP_QUEST("Sheep Quest", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.WOOL, 0, GameCategory.ARCADE, null), Material.WOOL, 0, GameCategory.ARCADE, null, false, GameDisplay.Sheep.getGameId()),
SNEAKY_ASSASSINS("Sneaky Assassins", null, SNEAKY_ASSASSINS("Sneaky Assassins", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.INK_SACK, 0, GameCategory.ARCADE, "Briber Kit"), Material.INK_SACK, 0, GameCategory.ARCADE, "Briber Kit", false, GameDisplay.SneakyAssassins.getGameId()),
ONE_IN_THE_QUIVER("One in the Quiver", null, ONE_IN_THE_QUIVER("One in the Quiver", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BOW, 0, GameCategory.ARCADE, "Ninja Kit"), Material.BOW, 0, GameCategory.ARCADE, "Ninja Kit", false, GameDisplay.Quiver.getGameId()),
SUPER_PAINTBALL("Super Paintball", null, SUPER_PAINTBALL("Super Paintball", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.ENDER_PEARL, 0, GameCategory.ARCADE, "Sniper Kit"), Material.ENDER_PEARL, 0, GameCategory.ARCADE, "Sniper Kit", false, GameDisplay.Paintball.getGameId()),
TURF_WARS("Turf Wars", null, TURF_WARS("Turf Wars", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.HARD_CLAY, 14, GameCategory.ARCADE, null), Material.HARD_CLAY, 14, GameCategory.ARCADE, null, false, GameDisplay.TurfWars.getGameId()),
RUNNER("Runner", null, RUNNER("Runner", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null), Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null, false, GameDisplay.Runner.getGameId()),
SPLEEF("Super Spleef", null, SPLEEF("Super Spleef", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_SPADE, 0, GameCategory.ARCADE, null), Material.IRON_SPADE, 0, GameCategory.ARCADE, null, false, GameDisplay.Spleef.getGameId()),
DEATH_TAG("Death Tag", null, DEATH_TAG("Death Tag", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.SKULL_ITEM, 0, GameCategory.ARCADE, null), Material.SKULL_ITEM, 0, GameCategory.ARCADE, null, false, GameDisplay.DeathTag.getGameId()),
SNAKE("Snake", null, SNAKE("Snake", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.WOOL, 4, GameCategory.ARCADE, "Reversal Snake Kit"), Material.WOOL, 4, GameCategory.ARCADE, "Reversal Snake Kit", false, GameDisplay.Snake.getGameId()),
BACON_BRAWL("Bacon Brawl", null, BACON_BRAWL("Bacon Brawl", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.PORK, 0, GameCategory.ARCADE, null), Material.PORK, 0, GameCategory.ARCADE, null, false, GameDisplay.BaconBrawl.getGameId()),
MICRO_BATTLE("Micro Battle", null, MICRO_BATTLE("Micro Battle", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.LAVA_BUCKET, 0, GameCategory.ARCADE, null), Material.LAVA_BUCKET, 0, GameCategory.ARCADE, null, false, GameDisplay.Micro.getGameId()),
BOMB_LOBBERS("Bomb Lobbers", null, BOMB_LOBBERS("Bomb Lobbers", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit"), Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit", false, GameDisplay.Lobbers.getGameId()),
EVOLUTION("Evolution", null, EVOLUTION("Evolution", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
Material.MONSTER_EGG, 0, GameCategory.ARCADE, "Harvester Kit"), Material.MONSTER_EGG, 0, GameCategory.ARCADE, "Harvester Kit", false, GameDisplay.Evolution.getGameId()),
MONSTER_MAZE("Monster Maze", null, MONSTER_MAZE("Monster Maze", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM"), Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM", false, GameDisplay.MonsterMaze.getGameId()),
GLADIATORS("Gladiators", null, GLADIATORS("Gladiators", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.IRON_SWORD, 0, GameCategory.ARCADE, null), Material.IRON_SWORD, 0, GameCategory.ARCADE, null, false, GameDisplay.Gladiators.getGameId()),
/*TYPE_WARS("Type Wars", null, /*TYPE_WARS("Type Wars", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED}, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED},
@ -166,7 +165,7 @@ public enum AchievementCategory
SPEED_BUILDERS("Speed Builders", null, SPEED_BUILDERS("Speed Builders", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")}, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")},
Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null); Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null, false, GameDisplay.SpeedBuilders.getGameId());
private String _name; private String _name;
@ -176,8 +175,10 @@ public enum AchievementCategory
private GameCategory _gameCategory; private GameCategory _gameCategory;
private byte _iconData; private byte _iconData;
private String _kitReward; private String _kitReward;
public boolean DisplayDivision;
public int[] GameId;
AchievementCategory(String name, String[] statsToPull, StatDisplay[] statDisplays, Material icon, int iconData, GameCategory gameCategory, String kitReward) AchievementCategory(String name, String[] statsToPull, StatDisplay[] statDisplays, Material icon, int iconData, GameCategory gameCategory, String kitReward, boolean displayDivision, int... gameId)
{ {
_name = name; _name = name;
@ -190,6 +191,9 @@ public enum AchievementCategory
_iconData = (byte)iconData; _iconData = (byte)iconData;
_gameCategory = gameCategory; _gameCategory = gameCategory;
_kitReward = kitReward; _kitReward = kitReward;
GameId = gameId;
DisplayDivision = displayDivision;
} }
public String getFriendlyName() public String getFriendlyName()

View File

@ -1,33 +1,28 @@
package mineplex.core.achievement; package mineplex.core.achievement;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.command.StatsCommand; import mineplex.core.achievement.command.StatsCommand;
import mineplex.core.achievement.ui.AchievementShop; import mineplex.core.achievement.ui.AchievementShop;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.elo.EloManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import mineplex.core.stats.event.StatChangeEvent; import mineplex.core.stats.event.StatChangeEvent;
public class AchievementManager extends MiniPlugin public class AchievementManager extends MiniPlugin
{ {
private IncognitoManager _incognitoManager;
private StatsManager _statsManager; private StatsManager _statsManager;
private EloManager _eloManager;
private AchievementShop _shop; private AchievementShop _shop;
private int _interfaceSlot = 7; private int _interfaceSlot = 7;
@ -37,11 +32,13 @@ public class AchievementManager extends MiniPlugin
private boolean _shopEnabled = true; private boolean _shopEnabled = true;
public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager) public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager, IncognitoManager incognitoManager, EloManager eloManager)
{ {
super("Achievement Manager", statsManager.getPlugin()); super("Achievement Manager", statsManager.getPlugin());
_incognitoManager = incognitoManager;
_statsManager = statsManager; _statsManager = statsManager;
_eloManager = eloManager;
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement"); _shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
} }
@ -62,6 +59,11 @@ public class AchievementManager extends MiniPlugin
return type.getLevelData(exp); return type.getLevelData(exp);
} }
public EloManager getEloManager()
{
return _eloManager;
}
@EventHandler @EventHandler
public void informLevelUp(StatChangeEvent event) public void informLevelUp(StatChangeEvent event)
{ {
@ -213,4 +215,9 @@ public class AchievementManager extends MiniPlugin
{ {
_shopEnabled = var; _shopEnabled = var;
} }
public IncognitoManager getIncognito()
{
return _incognitoManager;
}
} }

View File

@ -30,6 +30,11 @@ public class StatsCommand extends CommandBase<AchievementManager>
return; return;
} }
if (/* StaffServer special case */Plugin.getIncognito() != null && Plugin.getIncognito().Get(target).Hidden)
{
return;
}
Plugin.openShop(caller, target); Plugin.openShop(caller, target);
} }
} }

View File

@ -3,14 +3,6 @@ package mineplex.core.achievement.ui.page;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.Achievement; import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementCategory; import mineplex.core.achievement.AchievementCategory;
@ -19,17 +11,28 @@ import mineplex.core.achievement.AchievementManager;
import mineplex.core.achievement.ui.AchievementShop; import mineplex.core.achievement.ui.AchievementShop;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.elo.EloManager.EloDivision;
import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase; import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class AchievementPage extends ShopPageBase<AchievementManager, AchievementShop> public class AchievementPage extends ShopPageBase<AchievementManager, AchievementShop>
{ {
private static int ACHIEVEMENT_MIDDLE_INDEX = 31; private static int ACHIEVEMENT_MIDDLE_INDEX = 31;
private AchievementCategory _category; private AchievementCategory _category;
private StatsManager _statsManager; private StatsManager _statsManager;
private EloManager _eloManager;
private Player _target; private Player _target;
public AchievementPage(AchievementManager plugin, StatsManager statsManager, AchievementCategory category, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Player target) public AchievementPage(AchievementManager plugin, StatsManager statsManager, AchievementCategory category, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Player target)
@ -39,6 +42,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
_statsManager = statsManager; _statsManager = statsManager;
_category = category; _category = category;
_target = target; _target = target;
_eloManager = plugin.getEloManager();
buildPage(); buildPage();
} }
@ -126,6 +130,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
addBackButton(); addBackButton();
addStats(); addStats();
addDivisionDisplay();
} }
private void addBackButton() private void addBackButton()
@ -168,6 +173,31 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
setItem(22, item); setItem(22, item);
} }
private void addDivisionDisplay()
{
if (_category.getFriendlyName().startsWith("Global"))
return;
if (!_category.DisplayDivision || _category.GameId.length < 1)
return;
if (_category.GameId.length > 1)
{
for (int i = 0; i < _category.GameId.length; i++)
{
int id = _category.GameId[i];
int elo = _eloManager.getElo(_target, id);
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
setItem(44 + i + 1, disp);
}
}
else
{
int id = _category.GameId[0];
int elo = _eloManager.getElo(_target, id);
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
setItem(49, disp);
}
}
public List<Achievement> getAchievements() public List<Achievement> getAchievements()
{ {
List<Achievement> achievements = new ArrayList<Achievement>(); List<Achievement> achievements = new ArrayList<Achievement>();

View File

@ -53,6 +53,10 @@ public class Blood extends MiniPlugin
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void display(BloodEvent event) public void display(BloodEvent event)
{
if(event.isCancelled()) return;
if(event.getMaterial() != null && event.getMaterial() != Material.AIR)
{ {
for (int i = 0 ; i < event.getParticles() ; i++) for (int i = 0 ; i < event.getParticles() ; i++)
{ {
@ -65,10 +69,12 @@ public class Blood extends MiniPlugin
_blood.put(item, event.getTicks()); _blood.put(item, event.getTicks());
} }
}
if (event.getBloodStep()) if (event.getBloodStep())
event.getLocation().getWorld().playEffect(event.getLocation(), Effect.STEP_SOUND, 55); event.getLocation().getWorld().playEffect(event.getLocation(), Effect.STEP_SOUND, 55);
if(event.getSound() != null)
event.getLocation().getWorld().playSound(event.getLocation(), event.getSound(), event.getSoundVolume(), event.getSoundPitch()); event.getLocation().getWorld().playSound(event.getLocation(), event.getSound(), event.getSoundVolume(), event.getSoundPitch());
} }

View File

@ -1,36 +1,28 @@
package mineplex.core.bonuses; package mineplex.core.bonuses;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.TimeZone;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor; import mineplex.core.account.ILoginProcessor;
import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.bonuses.animations.AnimationCarl;
import mineplex.core.bonuses.commands.AllowCommand;
import mineplex.core.bonuses.commands.AnimationCommand;
import mineplex.core.bonuses.commands.GuiCommand;
import mineplex.core.bonuses.commands.TicketCommand;
import mineplex.core.bonuses.event.CarlSpinnerEvent;
import mineplex.core.bonuses.gui.BonusGui;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.bonuses.redis.VoteHandler; import mineplex.core.bonuses.redis.VoteHandler;
import mineplex.core.bonuses.redis.VotifierCommand; import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.*;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.serverdata.database.DBPool;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.donation.GiveDonorData; import mineplex.core.donation.GiveDonorData;
import mineplex.core.facebook.FacebookManager; import mineplex.core.facebook.FacebookManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.ClientItem; import mineplex.core.inventory.ClientItem;
@ -38,6 +30,7 @@ import mineplex.core.inventory.InventoryManager;
import mineplex.core.npc.Npc; import mineplex.core.npc.Npc;
import mineplex.core.npc.NpcManager; import mineplex.core.npc.NpcManager;
import mineplex.core.pet.PetManager; import mineplex.core.pet.PetManager;
import mineplex.core.poll.PollManager;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
@ -46,19 +39,12 @@ import mineplex.core.treasure.TreasureType;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.database.Tables; import mineplex.database.Tables;
import mineplex.core.bonuses.animations.AnimationCarl;
import mineplex.core.bonuses.commands.AnimationCommand;
import mineplex.core.bonuses.commands.GuiCommand;
import mineplex.core.bonuses.commands.TicketCommand;
import mineplex.core.bonuses.event.CarlSpinnerEvent;
import mineplex.core.bonuses.gui.BonusGui;
import mineplex.database.tables.records.BonusRecord; import mineplex.database.tables.records.BonusRecord;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.poll.PollManager;
import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.commands.ServerCommandManager;
import mineplex.serverdata.database.DBPool;
import org.jooq.SQLDialect; import net.minecraft.server.v1_8_R3.DataWatcher;
import org.jooq.impl.DSL; import net.minecraft.server.v1_8_R3.EntityCreeper;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
@ -71,10 +57,14 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
import net.minecraft.server.v1_8_R3.DataWatcher; import java.sql.Date;
import net.minecraft.server.v1_8_R3.EntityCreeper; import java.sql.ResultSet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.*;
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
{ {
@ -169,7 +159,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet(); updateOffSet();
} }
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager) public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, GadgetManager gadgetManager)
{ {
super("Bonus", plugin); super("Bonus", plugin);
_repository = new BonusRepository(plugin, this, donationManager); _repository = new BonusRepository(plugin, this, donationManager);
@ -179,12 +169,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_hologramManager = hologramManager; _hologramManager = hologramManager;
_inventoryManager = inventoryManager; _inventoryManager = inventoryManager;
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, _rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, statsManager, gadgetManager);
100, 250,
500, 1000,
4000, 6000,
12000, 32000,
true, true);
_pollManager = pollManager; _pollManager = pollManager;
_statsManager = statsManager; _statsManager = statsManager;
@ -236,6 +221,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
addCommand(new GuiCommand(this)); addCommand(new GuiCommand(this));
addCommand(new AnimationCommand(this)); addCommand(new AnimationCommand(this));
addCommand(new TicketCommand(this)); addCommand(new TicketCommand(this));
addCommand(new AllowCommand(this));
} }
// Just keeping things up-to-date // Just keeping things up-to-date
@ -925,6 +911,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (client.getHologram() == null) if (client.getHologram() == null)
{ {
double yAdd = 2.3; double yAdd = 2.3;
if(!UtilPlayer.is1_9(player))
{
yAdd = 2.45;
}
hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), ""); hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
hologram.addPlayer(player); hologram.addPlayer(player);

View File

@ -0,0 +1,83 @@
package mineplex.core.bonuses.commands;
import java.util.Arrays;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.command.CommandBase;
import mineplex.core.command.CommandCenter;
import mineplex.core.command.ICommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.entity.Player;
/**
* Allows players to run rank-specific commands
* Found no better place to create it
*/
public class AllowCommand extends CommandBase<BonusManager>
{
private BonusManager _plugin;
public AllowCommand(BonusManager plugin)
{
super(plugin, Rank.MODERATOR, "allowCommand", "allowCmd");
_plugin = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length < 2 || args.length > 3)
{
UtilPlayer.message(caller, F.main("Allow Command", "Usage: /allowCmd <player> <command> [disallow]"));
return;
}
NautHashMap<String, ICommand> commands = CommandCenter.getCommands();
if (!commands.containsKey(args[1].toLowerCase()))
{
UtilPlayer.message(caller, F.main("Allow Command", "Command not found!"));
return;
}
ICommand iCommand = commands.get(args[1]);
Rank playerRank = _plugin.getClientManager().Get(caller).GetRank();
if (playerRank.compareTo(iCommand.GetRequiredRank()) > 0
&& Arrays.asList(iCommand.GetSpecificRanks()).contains(playerRank))
{
UtilPlayer.message(caller, F.main("Allow Command", "You're not allowed to use that command!"));
return;
}
boolean disallow = false;
if (args.length == 3)
disallow = Boolean.parseBoolean(args[2]);
Player receiver = UtilPlayer.searchExact(args[0]);
if (receiver == null)
{
UtilPlayer.message(caller, F.main("Allow Command", "Could not find player " + F.name(args[0]) + "!"));
return;
}
if (receiver.getUniqueId().equals(caller.getUniqueId()))
{
UtilPlayer.message(caller, F.main("Allow Command", "You can't use that for yourself!"));
return;
}
if (disallow)
{
boolean canDisallow = UtilPlayer.disallowCommand(receiver, args[1].toLowerCase());
if (!canDisallow)
{
UtilPlayer.message(caller, F.main("Allow Command", "That command was not allowed for the player " + F.name(receiver.getName()) + "!"));
return;
}
UtilPlayer.message(caller, F.main("Allow Command", "You disallowed the player " + F.name(receiver.getName()) + " to use the command " + F.elem(args[1]) + "!"));
UtilPlayer.message(receiver, F.main("Allow Command", "The player " + F.name(caller.getName()) + " disallowed you to use the command " + F.elem(args[1]) + "!"));
return;
}
UtilPlayer.allowCommand(receiver, args[1].toLowerCase());
UtilPlayer.message(caller, F.main("Allow Command", "You allowed the player " + F.name(receiver.getName()) + " to use the command " + F.elem(args[1]) + "!"));
UtilPlayer.message(receiver, F.main("Allow Command", "The player " + F.name(caller.getName()) + " allowed you to use the command " + F.elem(args[1]) + "!"));
}
}

View File

@ -12,6 +12,7 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.reward.Reward; import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType; import mineplex.core.reward.RewardType;
import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.ShopItem;
@ -101,11 +102,11 @@ public class SpinGui extends SimpleGui
{ {
if (i != _stopSpinnerAt + 4) if (i != _stopSpinnerAt + 4)
{ {
_rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerFiller, true); _rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SpinnerFiller, true);
} }
else else
{ {
_rewards[i] = rewardManager.nextReward(player, null, false, RewardType.SpinnerReal, true); _rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SpinnerReal, true);
_reward = _rewards[i]; _reward = _rewards[i];
} }
} }

View File

@ -0,0 +1,10 @@
package mineplex.core.chatsnap;
/**
* Holds all types of messages a player can receive from another player
*/
public enum MessageType
{
CHAT,
PM
}

View File

@ -0,0 +1,119 @@
package mineplex.core.chatsnap;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import org.bukkit.ChatColor;
import com.google.gson.annotations.SerializedName;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents a message sent by a player.
*/
public class Snapshot implements Comparable<Snapshot>
{
@SerializedName("type")
private MessageType _messageType;
@SerializedName("sender")
private UUID _sender;
@SerializedName("recipients")
private Collection<UUID> _recipients;
@SerializedName("message")
private String _message;
@SerializedName("time")
private LocalDateTime _time;
public Snapshot(UUID sender, UUID recipient, String message)
{
this(MessageType.PM, sender, Collections.singletonList(recipient), message, LocalDateTime.now());
}
public Snapshot(UUID sender, Collection<UUID> recipients, String message)
{
this(MessageType.CHAT, sender, recipients, message, LocalDateTime.now());
}
public Snapshot(MessageType messageType, UUID sender, Collection<UUID> recipients, String message, LocalDateTime time)
{
_messageType = messageType;
_sender = checkNotNull(sender);
_recipients = checkNotNull(recipients);
_message = checkNotNull(message);
_time = checkNotNull(time);
if (messageType == MessageType.PM && recipients.size() > 1)
{
throw new IllegalArgumentException("Snapshot type PM may not have more than 1 recipient.");
}
}
public MessageType getMessageType()
{
return _messageType;
}
public UUID getSender()
{
return _sender;
}
public String getMessage()
{
return _message;
}
public Set<UUID> getRecipients()
{
return new HashSet<>(_recipients);
}
public LocalDateTime getSentTime()
{
return _time;
}
@Override
public int compareTo(Snapshot o)
{
return getSentTime().compareTo(o.getSentTime());
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Snapshot that = (Snapshot) o;
return _time == that._time &&
Objects.equals(_sender, that._sender) &&
Objects.equals(_recipients, that._recipients) &&
Objects.equals(_message, that._message);
}
@Override
public int hashCode()
{
return Objects.hash(_sender, _recipients, _message, _time);
}
@Override
public String toString()
{
return "Snapshot{" +
"sender=" + _sender +
", recipients=" + _recipients +
", message='" + ChatColor.stripColor(_message) + '\'' +
", created=" + _time +
'}';
}
}

View File

@ -0,0 +1,77 @@
package mineplex.core.chatsnap;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
/**
* Handles temporary storage of {@link Snapshot} instances.
*/
public class SnapshotManager
{
// There aren't any List or Set caching implementations
// For an easy work around, we store values as the Key
// For the value we just use some dummy object
// I went with Boolean as it's the smallest data type
private final Cache<Snapshot, Boolean> _snapshots = CacheBuilder.newBuilder()
.concurrencyLevel(4)
.expireAfterWrite(30, TimeUnit.MINUTES)
.build();
private final SnapshotPublisher _snapshotPublisher;
public SnapshotManager(SnapshotPublisher snapshotPublisher)
{
_snapshotPublisher = snapshotPublisher;
}
public SnapshotPublisher getSnapshotPublisher()
{
return _snapshotPublisher;
}
/**
* Keeps a snapshot in memory temporarily (30 minutes) and then discards it.
* During this time, other modules (such as the Report module) can access it for their own use.
*
* @param snapshot the snapshot to temporarily store
*/
public void cacheSnapshot(Snapshot snapshot)
{
_snapshots.put(snapshot, true);
}
/**
* Gets all currently stored snapshots.
* The set is in chronological order of the time the message was sent.
*
* @return a set containing all snapshots
*/
public Set<Snapshot> getSnapshots()
{
// The compareTo method in Snapshot will ensure this in chronological order
Set<Snapshot> snapshots = new TreeSet<>();
snapshots.addAll(_snapshots.asMap().keySet());
return snapshots;
}
/**
* Gets all instances of {@link Snapshot} which involve a particular user.
* The user may be the sender or recipient of a message.
*
* @param search the user to search for snaps involved in
* @return the snaps that the user is involved in
*/
public Set<Snapshot> getSnapshots(UUID search)
{
return _snapshots.asMap().keySet().stream()
.filter(snapshot -> snapshot.getSender().equals(search) || snapshot.getRecipients().contains(search))
.collect(Collectors.toCollection(TreeSet::new));
}
}

View File

@ -0,0 +1,73 @@
package mineplex.core.chatsnap;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.chatsnap.commands.ChatCacheCommand;
import mineplex.core.message.PrivateMessageEvent;
/**
* Starter class for all snapshot related functions (ie capturing messages, retrieving snapshots).
*/
public class SnapshotPlugin extends MiniPlugin
{
private final SnapshotManager _snapshotManager;
public SnapshotPlugin(JavaPlugin plugin, SnapshotManager snapshotManager)
{
super("ChatSnap", plugin);
_snapshotManager = snapshotManager;
}
public SnapshotManager getSnapshotManager()
{
return _snapshotManager;
}
@Override
public void addCommands()
{
addCommand(new ChatCacheCommand(this));
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncPlayerChatEvent e)
{
_snapshotManager.cacheSnapshot(createSnapshot(e));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPrivateMessage(PrivateMessageEvent e)
{
_snapshotManager.cacheSnapshot(createSnapshot(e));
}
public Set<UUID> getUUIDSet(Set<Player> playerSet)
{
return playerSet.stream().map(Player::getUniqueId).collect(Collectors.toSet());
}
public Snapshot createSnapshot(AsyncPlayerChatEvent e)
{
UUID senderUUID = e.getPlayer().getUniqueId();
Set<UUID> uuidSet = getUUIDSet(e.getRecipients());
uuidSet.remove(senderUUID);
return new Snapshot(senderUUID, uuidSet, e.getMessage());
}
public Snapshot createSnapshot(PrivateMessageEvent e)
{
Player sender = e.getSender();
Player recipient = e.getRecipient();
String message = e.getMessage();
return new Snapshot(sender.getUniqueId(), recipient.getUniqueId(), message);
}
}

View File

@ -0,0 +1,54 @@
package mineplex.core.chatsnap.commands;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import mineplex.core.chatsnap.SnapshotPlugin;
import mineplex.core.chatsnap.Snapshot;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
/**
* Displays what chat messages we have cached for a player.
*/
public class ChatCacheCommand extends CommandBase<SnapshotPlugin>
{
public ChatCacheCommand(SnapshotPlugin plugin)
{
super(plugin, Rank.MODERATOR, "chatcache");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args.length != 1)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), String.format("Invalid arguments, usage: /%s <player>", _aliasUsed)));
return;
}
final String playerName = args[0];
// getOfflinePlayer sometimes blocks, see this needs to be async
Plugin.getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
{
@Override
public void run()
{
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
Set<Snapshot> snaps = Plugin.getSnapshotManager().getSnapshots(offlinePlayer.getUniqueId());
for (Snapshot snapshot : snaps)
{
// TODO: show sender name
caller.sendMessage(snapshot.getMessage());
}
}
});
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.chatsnap.publishing;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
/**
* Handles serialization of Java 8's {@link LocalDateTime}.
*/
public class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime>
{
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
private ZoneId _zoneId;
public LocalDateTimeSerializer(ZoneId zoneId)
{
_zoneId = zoneId;
}
@Override
public JsonElement serialize(LocalDateTime localDateTime, Type type, JsonSerializationContext jsonSerializationContext)
{
return new JsonPrimitive(localDateTime.atZone(_zoneId).toLocalDateTime().truncatedTo(ChronoUnit.SECONDS).format(FORMATTER));
}
}

View File

@ -0,0 +1,32 @@
package mineplex.core.chatsnap.publishing;
import java.lang.reflect.Type;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import mineplex.core.report.Report;
/**
* Handles serialization of {@link Report} instances.
*/
public class ReportSerializer implements JsonSerializer<Report>
{
@Override
public JsonElement serialize(Report report, Type type, JsonSerializationContext jsonSerializationContext)
{
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("id", report.getReportId());
jsonObject.addProperty("serverName", report.getServerName());
if (report.getHandler() != null)
{
jsonObject.addProperty("handler", report.getHandler().toString());
}
jsonObject.addProperty("suspect", report.getSuspect().toString());
jsonObject.add("reporters", jsonSerializationContext.serialize(report.getReportReasons()));
return jsonObject;
}
}

View File

@ -0,0 +1,119 @@
package mineplex.core.chatsnap.publishing;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import mineplex.core.chatsnap.Snapshot;
import mineplex.core.report.Report;
import mineplex.serverdata.Utility;
import mineplex.serverdata.servers.ServerManager;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
/**
* Class responsible for publishing snapshots on the website via Redis and a separate Report server.
*/
public class SnapshotPublisher
{
private static final ZoneId ZONE_ID = ZoneId.of("America/Chicago"); // This means "CST"
private static final Gson GSON = new GsonBuilder()
.setPrettyPrinting()
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer(ZONE_ID))
.registerTypeAdapter(Report.class, new ReportSerializer())
.create();
public static ZoneId getZoneId()
{
return ZONE_ID;
}
public static Gson getGson()
{
return GSON;
}
public static String getURL(String token)
{
return URL_PREFIX + token;
}
private static final String URL_PREFIX = "http://file.mineplex.com/chatsnap/view.php?identifier=";
public static final String CHANNEL_DEPLOY = "reportserver:deploy";
public static final String CHANNEL_DESTROY = "reportserver:destroy";
private JavaPlugin _plugin;
private JedisPool _jedisPool;
public SnapshotPublisher(JavaPlugin plugin)
{
_plugin = plugin;
_jedisPool = Utility.generatePool(ServerManager.getMasterConnection());
}
public void publishChatLog(String token, JsonObject jsonObject)
{
jsonObject.addProperty("token", token);
String json = GSON.toJson(jsonObject);
// getting a Jedis resource can block, so lets async it
Bukkit.getScheduler().runTaskAsynchronously(_plugin, () ->
{
try (Jedis jedis = _jedisPool.getResource())
{
jedis.publish(CHANNEL_DEPLOY, json);
}
});
}
public void unpublishChatLog(String token)
{
// getting a Jedis resource can block, so lets async it
Bukkit.getScheduler().runTaskAsynchronously(_plugin, () ->
{
try (Jedis jedis = _jedisPool.getResource())
{
jedis.publish(CHANNEL_DESTROY, token);
}
});
}
public Set<UUID> getUUIDs(Collection<Snapshot> snapshots)
{
// Being a Set ensures no duplicates
Set<UUID> uuids = new HashSet<>();
for (Snapshot snapshot : snapshots)
{
uuids.add(snapshot.getSender());
uuids.addAll(snapshot.getRecipients().stream().collect(Collectors.toList()));
}
return uuids;
}
public Map<UUID, String> getUsernameMap(Collection<UUID> collection)
{
Map<UUID, String> uuidUsernameMap = new HashMap<>();
for (UUID uuid : collection)
{
String username = Bukkit.getOfflinePlayer(uuid).getName();
uuidUsernameMap.put(uuid, username);
}
return uuidUsernameMap;
}
}

View File

@ -21,8 +21,8 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
private List<String> _aliases; private List<String> _aliases;
protected PluginType Plugin; protected PluginType Plugin;
protected String AliasUsed; protected String _aliasUsed;
protected CommandCenter CommandCenter; protected CommandCenter _commandCenter;
public CommandBase(PluginType plugin, Rank requiredRank, String...aliases) public CommandBase(PluginType plugin, Rank requiredRank, String...aliases)
{ {
@ -47,7 +47,7 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
public void SetAliasUsed(String alias) public void SetAliasUsed(String alias)
{ {
AliasUsed = alias; _aliasUsed = alias;
} }
public Rank GetRequiredRank() public Rank GetRequiredRank()
@ -62,7 +62,7 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
public void SetCommandCenter(CommandCenter commandCenter) public void SetCommandCenter(CommandCenter commandCenter)
{ {
CommandCenter = commandCenter; _commandCenter = commandCenter;
} }
protected void resetCommandCharge(Player caller) protected void resetCommandCharge(Player caller)

View File

@ -1,10 +1,9 @@
package mineplex.core.command; package mineplex.core.command;
import java.util.List;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -18,7 +17,7 @@ public class CommandCenter implements Listener
protected JavaPlugin Plugin; protected JavaPlugin Plugin;
protected CoreClientManager ClientManager; protected CoreClientManager ClientManager;
protected NautHashMap<String, ICommand> Commands; protected static NautHashMap<String, ICommand> Commands;
public static void Initialize(JavaPlugin plugin) public static void Initialize(JavaPlugin plugin)
{ {
@ -34,7 +33,7 @@ public class CommandCenter implements Listener
private CommandCenter(JavaPlugin instance) private CommandCenter(JavaPlugin instance)
{ {
Plugin = instance; Plugin = instance;
Commands = new NautHashMap<String, ICommand>(); Commands = new NautHashMap<>();
Plugin.getServer().getPluginManager().registerEvents(this, Plugin); Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
} }
@ -44,7 +43,7 @@ public class CommandCenter implements Listener
} }
@EventHandler @EventHandler
public void OnPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{ {
String commandName = event.getMessage().substring(1); String commandName = event.getMessage().substring(1);
String[] args = new String[] {}; String[] args = new String[] {};
@ -61,7 +60,8 @@ public class CommandCenter implements Listener
{ {
event.setCancelled(true); event.setCancelled(true);
if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)) if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)
|| UtilPlayer.isCommandAllowed(event.getPlayer(), commandName.toLowerCase()))
{ {
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false)) if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
{ {
@ -76,7 +76,7 @@ public class CommandCenter implements Listener
} }
public void AddCommand(ICommand command) public void addCommand(ICommand command)
{ {
for (String commandRoot : command.Aliases()) for (String commandRoot : command.Aliases())
{ {
@ -85,7 +85,7 @@ public class CommandCenter implements Listener
} }
} }
public void RemoveCommand(ICommand command) public void removeCommand(ICommand command)
{ {
for (String commandRoot : command.Aliases()) for (String commandRoot : command.Aliases())
{ {
@ -93,4 +93,9 @@ public class CommandCenter implements Listener
command.SetCommandCenter(null); command.SetCommandCenter(null);
} }
} }
public static NautHashMap<String, ICommand> getCommands()
{
return Commands;
}
} }

View File

@ -33,7 +33,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
for (String commandRoot : command.Aliases()) for (String commandRoot : command.Aliases())
{ {
Commands.put(commandRoot, command); Commands.put(commandRoot, command);
command.SetCommandCenter(CommandCenter); command.SetCommandCenter(_commandCenter);
} }
} }
@Override @Override
@ -59,7 +59,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
ICommand command = Commands.get(commandName); ICommand command = Commands.get(commandName);
if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true)) if (command != null && _commandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
{ {
command.SetAliasUsed(commandName); command.SetAliasUsed(commandName);

View File

@ -1,12 +1,10 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.ArrowTrailPage; import mineplex.core.cosmetic.ui.page.ArrowTrailPage;
import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.shop.item.IButton;
public class OpenArrowTrails extends OpenPageButton public class OpenArrowTrails extends OpenPageButton
{ {

View File

@ -1,12 +1,10 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.DeathEffectPage; import mineplex.core.cosmetic.ui.page.DeathEffectPage;
import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.shop.item.IButton;
public class OpenDeathAnimations extends OpenPageButton public class OpenDeathAnimations extends OpenPageButton
{ {

View File

@ -1,12 +1,10 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.DoubleJumpPage; import mineplex.core.cosmetic.ui.page.DoubleJumpPage;
import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.shop.item.IButton;
public class OpenDoubleJump extends OpenPageButton public class OpenDoubleJump extends OpenPageButton
{ {

View File

@ -1,12 +1,10 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.GadgetPage; import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class OpenGadgets extends OpenPageButton public class OpenGadgets extends OpenPageButton
{ {

View File

@ -0,0 +1,21 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.GameModifierPage;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.gadget.types.Gadget;
public class OpenGameModifiers extends OpenPageButton
{
public OpenGameModifiers(Menu menu, Gadget active)
{
super(menu, active);
}
@Override
protected void leftClick(Player player)
{
getMenu().getShop().openPageForPlayer(player, new GameModifierPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Game Modifiers", player));
}
}

View File

@ -1,14 +1,13 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.MountPage;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.mount.Mount;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.MountPage;
import mineplex.core.mount.Mount;
import mineplex.core.shop.item.IButton;
public class OpenMounts implements IButton public class OpenMounts implements IButton
{ {
private Menu _menu; private Menu _menu;

View File

@ -1,11 +1,9 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.shop.item.IButton;
public class OpenMusic extends OpenPageButton public class OpenMusic extends OpenPageButton
{ {

View File

@ -1,13 +1,10 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.ParticlePage; import mineplex.core.cosmetic.ui.page.ParticlePage;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class OpenParticles extends OpenPageButton public class OpenParticles extends OpenPageButton
{ {

View File

@ -1,14 +1,12 @@
package mineplex.core.cosmetic.ui.button; package mineplex.core.cosmetic.ui.button;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.MountPage;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.pet.Pet;
import mineplex.core.shop.item.IButton;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.shop.item.IButton;
public class OpenPets implements IButton public class OpenPets implements IButton
{ {
private Menu _menu; private Menu _menu;

View File

@ -0,0 +1,21 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.WinEffectPage;
import mineplex.core.gadget.types.Gadget;
public class OpenWinEffect extends OpenPageButton
{
public OpenWinEffect(Menu menu, Gadget active)
{
super(menu, active);
}
@Override
protected void leftClick(Player player)
{
getMenu().getShop().openPageForPlayer(player, new WinEffectPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Win Effects", player));
}
}

View File

@ -1,10 +1,5 @@
package mineplex.core.cosmetic.ui.page; package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -16,8 +11,8 @@ import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuit; import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuit;
import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuit; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuit;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget; import mineplex.core.gadget.types.ItemGadget;

View File

@ -0,0 +1,81 @@
package mineplex.core.cosmetic.ui.page;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.types.GadgetGameModifier;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
public class GameModifierPage extends GadgetPage
{
public GameModifierPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name,
Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
int slot = 19;
for (GameModifierType type : GameModifierType.values())
{
int own = 0;
int total = 0;
for(GadgetGameModifier g : getPlugin().getGadgetManager().getGameModifiers(type)) {
if(g.ownsGadget(getPlayer())) own++;
total++;
}
if (total == 0)
continue;
ItemStack item = type.getItemStack();
ItemMeta meta = item.getItemMeta();
List<String> lore = meta.getLore();
lore.add(0, " ");
lore.add(" ");
lore.add(C.cWhite + "You own " + own + "/" + total);
lore.add(" ");
lore.add(C.cGreen + "Left-click to view Sub-Category");
meta.setLore(lore);
item.setItemMeta(meta);
addButton(slot, item, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(player, new GameModifierSubPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), type.getName(), player, type));
}
});
slot++;
if(slot%9 == 8) slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
}
});
}
}

View File

@ -0,0 +1,108 @@
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
import mineplex.core.gadget.types.GadgetGameModifier;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class GameModifierSubPage extends GadgetPage
{
private final GameModifierType _type;
public GameModifierSubPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager,
String name, Player player, GameModifierType gameType)
{
super(plugin, shop, clientManager, donationManager, name, player);
_type = gameType;
buildPage();
}
@Override
protected void buildPage()
{
if(_type == null) return;
int slot = 19;
if (_type.hasKits())
{
for (KitModifierType kitModifierType : KitModifierType.values())
{
if (kitModifierType.getGameModifierType().equals(_type))
{
int own = 0;
int total = 0;
for (GadgetGameModifier g : getPlugin().getGadgetManager().getGameModifiers(kitModifierType))
{
if (g.ownsGadget(getPlayer())) own++;
total++;
}
ItemStack itemStack = kitModifierType.getItemStack();
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> lore = itemMeta.getLore();
lore.add(0, " ");
lore.add(" ");
lore.add(C.cWhite + "You own " + own + "/" + total);
lore.add(" ");
lore.add(C.cGreen + "Left-click to view Kit Modifiers");
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
addButton(slot, itemStack, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(player, new KitGameModifierPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), kitModifierType.getKitName(), player, _type, kitModifierType));
}
});
slot++;
if(slot%9 == 8) slot += 2;
}
}
}
else
{
for (GadgetGameModifier gadget : getPlugin().getGadgetManager().getGameModifiers(_type))
{
addGadget(gadget, slot);
if (gadget.IsActive(getPlayer()))
addGlow(slot);
slot++;
if(slot%9 == 8) slot += 2;
}
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new GameModifierPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Game Modifiers", player));
}
});
}
}

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