Merge branch 'develop' of github.com:Mineplex-LLC/Minecraft-PC into feature/game-variants

# Conflicts:
#	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java
This commit is contained in:
xXVevzZXx 2016-05-06 03:40:00 +02:00
commit 9f2189d173
259 changed files with 22442 additions and 2438 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

@ -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

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

View File

@ -216,6 +216,24 @@ public class UtilAlg
return true; return true;
} }
public static boolean inBoundingBox(Location loc, Vector cornerA, Vector cornerB)
{
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
if (cornerA.getY() != cornerB.getY())
{
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
}
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
return true;
}
public static Vector cross(Vector a, Vector b) public static Vector cross(Vector a, Vector b)
{ {
double x = a.getY()*b.getZ() - a.getZ()*b.getY(); double x = a.getY()*b.getZ() - a.getZ()*b.getY();

View File

@ -1480,4 +1480,28 @@ 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);
} }
/**
* @return true if all of the blocks within the specified radius of the specified origin block are boundless ({@link UtilItem#isBoundless}.)
*/
public static boolean boundless(Location origin, double radius)
{
for (Block block : getInRadius(origin, radius).keySet())
{
if (!UtilItem.isBoundless(block.getType()))
{
return false;
}
}
return true;
}
/**
* @return true if there are any non-boundless ({@link UtilItem#isBoundless}) blocks within the specified radius of the specified origin block.
*/
public static boolean boundless(Block origin, double radius)
{
return boundless(origin.getLocation(), radius);
}
} }

View File

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

View File

@ -306,10 +306,10 @@ public class UtilItem
_materials.put(Material.DIAMOND_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
_materials.put(Material.DIAMOND_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
_materials.put(Material.DIAMOND_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
_materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR)); _materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
_materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR)); _materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
_materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR)); _materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
_materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR)); _materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
_materials.put(Material.FLINT, EnumSet.of(ItemCategory.ITEM)); _materials.put(Material.FLINT, EnumSet.of(ItemCategory.ITEM));
_materials.put(Material.PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD)); _materials.put(Material.PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
_materials.put(Material.GRILLED_PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); _materials.put(Material.GRILLED_PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
@ -550,7 +550,7 @@ public class UtilItem
public static boolean isSword(ItemStack stack) public static boolean isSword(ItemStack stack)
{ {
return isEdible(stack == null ? null : stack.getType()); return isSword(stack == null ? null : stack.getType());
} }
public static boolean isSword(Material material) public static boolean isSword(Material material)

View File

@ -28,6 +28,7 @@ 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 mineplex.core.common.events.PlayerMessageEvent;
import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PlayerConnection; import net.minecraft.server.v1_8_R3.PlayerConnection;
@ -277,6 +278,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);
} }

View File

@ -141,7 +141,12 @@ public class UtilServer
public static boolean IsOnline(String name) public static boolean IsOnline(String name)
{ {
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(player -> player.getName().equals(name))); return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(name::equals));
}
public static boolean IsOffline(String name)
{
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(name::equals));
} }
public static Player GetPlayer(String name) public static Player GetPlayer(String name)

View File

@ -2,10 +2,13 @@ package mineplex.core.common.util;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import com.google.common.collect.Lists;
public class UtilStreams public class UtilStreams
{ {
public static boolean IsEmpty(Stream<?> stream) public static boolean IsEmpty(Stream<?> stream)
@ -55,4 +58,9 @@ public class UtilStreams
return read; return read;
} }
public static <T> List<T> ToList(Stream<T> filter)
{
return Lists.newArrayList((T[]) ToArray(filter));
}
} }

View File

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

View File

@ -1,5 +1,6 @@
package mineplex.core.account; package mineplex.core.account;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -378,7 +379,12 @@ public class CoreClientManager extends MiniPlugin
@Override @Override
public void run() public void run()
{ {
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); try {
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_clientLoginLock.remove(client.GetPlayerName()); _clientLoginLock.remove(client.GetPlayerName());
} }
}); });

View File

@ -57,7 +57,7 @@ public class AccountRepository extends MinecraftRepository
//executeUpdate(CREATE_ACCOUNT_TABLE); //executeUpdate(CREATE_ACCOUNT_TABLE);
} }
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) throws SQLException
{ {
// First we try to grab the account id from cache - this saves an extra trip to database // First we try to grab the account id from cache - this saves an extra trip to database
int accountId = PlayerCache.getInstance().getAccountId(uuid); int accountId = PlayerCache.getInstance().getAccountId(uuid);
@ -117,10 +117,7 @@ public class AccountRepository extends MinecraftRepository
statement.getMoreResults(); statement.getMoreResults();
} }
} }
catch (Exception exception)
{
exception.printStackTrace();
}
return accountId; return accountId;
} }

View File

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

View File

@ -19,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,
@ -35,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,
@ -43,24 +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,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
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,
@ -68,100 +72,100 @@ 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},
Material.NAME_TAG, 0, GameCategory.CLASSICS, null), Material.NAME_TAG, 0, GameCategory.CLASSICS, null),*/
SPEED_BUILDERS("Speed Builders", null, SPEED_BUILDERS("Speed Builders", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")}, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")},
Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null); Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null, false, GameDisplay.SpeedBuilders.getGameId());
private String _name; private String _name;
@ -171,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;
@ -185,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

@ -21,6 +21,7 @@ import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; 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.elo.EloManager;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import mineplex.core.stats.event.StatChangeEvent; import mineplex.core.stats.event.StatChangeEvent;
@ -28,6 +29,7 @@ import mineplex.core.stats.event.StatChangeEvent;
public class AchievementManager extends MiniPlugin public class AchievementManager extends MiniPlugin
{ {
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 +39,12 @@ 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, EloManager eloManager)
{ {
super("Achievement Manager", statsManager.getPlugin()); super("Achievement Manager", statsManager.getPlugin());
_statsManager = statsManager; _statsManager = statsManager;
_eloManager = eloManager;
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement"); _shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
} }
@ -62,6 +65,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)
{ {

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

@ -738,14 +738,14 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{ {
//_inventoryManager.addItemToInventory(player, TreasureType.OLD.getItemName(), oldChests); //_inventoryManager.addItemToInventory(player, TreasureType.OLD.getItemName(), oldChests);
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(oldChests + " Old Chests"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(oldChests + " Old Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), mythicalChests)); _inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), oldChests));
} }
if (ancientChests > 0) if (ancientChests > 0)
{ {
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(ancientChests + " Ancient Chests"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(ancientChests + " Ancient Chests")));
//_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), ancientChests); //_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), ancientChests);
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), mythicalChests)); _inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), ancientChests));
} }
if (mythicalChests > 0) if (mythicalChests > 0)
@ -758,7 +758,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (gems > 0) if (gems > 0)
{ {
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems")));
//_gemQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), gems)); _gemQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), gems));
} }
if (gold > 0) if (gold > 0)
@ -785,7 +785,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (coins > 0) if (coins > 0)
{ {
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Treasure Shards"))); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Treasure Shards")));
//_coinQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), coins)); _coinQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), coins));
} }
if (tickets > 0) if (tickets > 0)

View File

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

View File

@ -1,14 +1,22 @@
package mineplex.core.disguise; package mineplex.core.disguise;
import java.lang.reflect.Field; import com.mineplex.spigot.ChunkAddEntityEvent;
import java.util.ArrayList; import mineplex.core.MiniPlugin;
import java.util.Arrays; import mineplex.core.common.util.NautHashMap;
import java.util.Collection; import mineplex.core.common.util.UtilEnt;
import java.util.HashMap; import mineplex.core.common.util.UtilPlayer;
import java.util.HashSet; import mineplex.core.disguise.disguises.*;
import java.util.Iterator; import mineplex.core.packethandler.IPacketHandler;
import java.util.Map.Entry; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -22,61 +30,13 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.mineplex.spigot.ChunkAddEntityEvent; import java.lang.reflect.Field;
import java.util.*;
import mineplex.core.MiniPlugin; import java.util.Map.Entry;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseRabbit;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkSection;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunkBulk;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedSoundEffect;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes;
import net.minecraft.server.v1_8_R3.WorldServer;
public class DisguiseManager extends MiniPlugin implements IPacketHandler public class DisguiseManager extends MiniPlugin implements IPacketHandler
{ {
@ -98,6 +58,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
private Chunk _bedChunk; private Chunk _bedChunk;
private boolean _bedPackets; private boolean _bedPackets;
public DisguiseManager(JavaPlugin plugin, PacketHandler packetHandler) public DisguiseManager(JavaPlugin plugin, PacketHandler packetHandler)
{ {
super("Disguise Manager", plugin); super("Disguise Manager", plugin);

View File

@ -4,5 +4,5 @@ import mineplex.core.common.util.NautHashMap;
public class EloClientData public class EloClientData
{ {
public NautHashMap<String, Integer> Elos = new NautHashMap<String, Integer>(); public NautHashMap<Integer, Integer> Elos = new NautHashMap<Integer, Integer>();
} }

View File

@ -2,120 +2,363 @@ package mineplex.core.elo;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.itemstack.ItemBuilder;
import org.bukkit.Bukkit; import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class EloManager extends MiniDbClientPlugin<EloClientData> public class EloManager extends MiniDbClientPlugin<EloClientData>
{ {
private static Object _playerEloLock = new Object(); private EloRepository _repository;
private EloRatingSystem _ratingSystem;
private NautHashMap<String, EloTeam> _eloTeams = new NautHashMap<>();
private EloRepository _repository; public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
private EloRatingSystem _ratingSystem; {
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos; super("Elo Rating", plugin, clientManager);
public EloManager(JavaPlugin plugin, CoreClientManager clientManager) _repository = new EloRepository(plugin);
{ _ratingSystem = new EloRatingSystem
super("Elo Rating", plugin, clientManager); (
new KFactor(0, 1299, 50),
new KFactor(1300, 1899, 45),
new KFactor(1900, 2499, 40),
new KFactor(2500, 3099, 30),
new KFactor(3100, 3699, 20),
new KFactor(3700, 5000, 10)
);
}
_repository = new EloRepository(plugin); public EloRepository getRepo()
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10)); {
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>(); return _repository;
} }
public int getElo(UUID uuid, String gameType)
{
int elo = 1000;
synchronized (_playerEloLock) @Override
{ public void addCommands()
if (_playerElos.containsKey(uuid.toString())) {
{ addCommand(new TopEloCommand(this));
if (_playerElos.get(uuid.toString()).containsKey(gameType)) }
public int getElo(Player player, int gameType)
{
if (!Get(player).Elos.containsKey(gameType))
{
return 1000;
}
return Get(player).Elos.get(gameType);
}
public EloTeam getNewRatings(EloTeam teamA, EloTeam teamB, GameResult result)
{
EloTeam newTeam = new EloTeam();
int newTotal = _ratingSystem.getNewRating(teamA.TotalElo / teamA.getPlayers().size(), teamB.TotalElo / teamB.getPlayers().size(), result) * teamA.getPlayers().size();
int kTotal = 0;
for (EloPlayer player : teamA.getPlayers())
{
kTotal += _ratingSystem.getKFactor(player.getRating());
}
for (EloPlayer player : teamA.getPlayers())
{
int newRating = (int) (player.getRating() + (_ratingSystem.getKFactor(player.getRating()) / (double) kTotal) * (newTotal - teamA.TotalElo));
EloPlayer newPlayer = new EloPlayer(player.getPlayer(), player.getAccountId(), newRating);
newTeam.addPlayer(newPlayer);
}
return newTeam;
}
public void saveElo(final Player player, final int accountId, final int gameType, final int oldElo, final int elo)
{
runAsync(() -> {
boolean success = false;
try
{
success = _repository.saveElo(accountId, gameType, oldElo, elo);
} catch (SQLException e)
{
e.printStackTrace();
} finally
{
System.out.println("Saving " + accountId + "'s new elo rating of " + elo + " for gameType " + gameType + (success ? " SUCCEEDED." : " FAILED."));
}
final boolean finalSuccess = success;
runSync(() -> {
if (finalSuccess)
{
if (player.isOnline())
{
Get(player).Elos.put(gameType, elo);
}
}
});
});
}
@Override
protected EloClientData AddPlayer(String player)
{
return new EloClientData();
}
@Override
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
Set(playerName, _repository.loadClientInformation(resultSet));
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT gameType, elo FROM eloRating WHERE accountId = '" + accountId + "';";
}
public void addTeam(String displayName, EloTeam eloTeam)
{
_eloTeams.put(displayName, eloTeam);
}
public void setWinningTeam(String displayName)
{
_eloTeams.get(displayName).Winner = true;
}
/**
* Checks if a player is banned from ranked games async
* @param accountId The player's account ID
* @param afterCheck Code to be executed with the fetched ban status
*/
public void checkRankBannedAsync(int accountId, Callback<Long> afterCheck)
{
getRankBanExpiryAsync(accountId, expiry -> {
boolean expired = System.currentTimeMillis() >= expiry;
if (expired)
{
_repository.getStrikeExpiry(accountId, strikeExpiration -> {
if (System.currentTimeMillis() >= strikeExpiration)
{
_repository.resetStrikes(accountId);
}
});
}
afterCheck.run(expiry);
});
}
/**
* Checks if a player is banned from ranked games (Should not be run on main thread)
* @param accountId The player's account ID
* @return The ban status of the player
*/
public boolean checkRankBanned(int accountId)
{
boolean expired = System.currentTimeMillis() >= getRankBanExpiry(accountId);
if (expired)
{
_repository.getStrikeExpiry(accountId, strikeExpiration -> {
if (System.currentTimeMillis() >= strikeExpiration)
{ {
elo = _playerElos.get(uuid.toString()).get(gameType); _repository.resetStrikes(accountId);
} }
} });
} }
return elo; return !expired;
} }
public EloTeam getNewRatings(EloTeam teamA, EloTeam teamB, GameResult result) /**
{ * Gets a player's remaining ranked game ban duration (Should not be run on main thread)
EloTeam newTeam = new EloTeam(); * @param accountId The player's account ID
* @return The ban expiry of the player (0 if not found)
*/
public long getRankBanExpiry(int accountId)
{
return _repository.getBanExpiry(accountId);
}
System.out.println("Old " + result + " Team Rating:" + teamA.TotalElo); /**
* Gets a player's remaining ranked game ban duration if applicable async
* @param accountId The player's account ID
* @param afterFetch Code to be executed with the fetched ban expiration
*/
public void getRankBanExpiryAsync(int accountId, Callback<Long> afterFetch)
{
_repository.getBanExpiryAsync(accountId, afterFetch);
}
int newTotal = _ratingSystem.getNewRating(teamA.TotalElo / teamA.getPlayers().size(), teamB.TotalElo / teamB.getPlayers().size(), result) * teamA.getPlayers().size(); /**
* Bans a player from joining ranked games temporarily
* @param accountId The player's account ID
*/
public void banFromRanked(int accountId)
{
_repository.addRankedBan(accountId);
}
System.out.println("New " + result + " Team Rating:" + newTotal); /**
* Called when game ends to calculate new Elo and award it
* @param gameId The game's ID
*/
public void endMatch(int gameId)
{
EloTeam teamWinner = null;
EloTeam teamLoser = null;
for (EloPlayer player : teamA.getPlayers()) for (EloTeam team : _eloTeams.values())
{ {
EloPlayer newPlayer = new EloPlayer(); if (team.Winner)
newPlayer.UniqueId = player.UniqueId; {
newPlayer.Rating = (int)(player.Rating + ((double)player.Rating / (double)teamA.TotalElo) * (newTotal - teamA.TotalElo)); teamWinner = team;
} else
{
teamLoser = team;
}
}
System.out.println("Old:"); EloTeam teamWinnerNew = getNewRatings(teamWinner, teamLoser, GameResult.Win);
player.printInfo(); EloTeam teamLoserNew = getNewRatings(teamLoser, teamWinner, GameResult.Loss);
System.out.println("New:"); // Use teams to calculate Elo
newPlayer.printInfo(); for (EloPlayer eloPlayer : teamWinnerNew.getPlayers())
{
int oldElo = teamWinner.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating();
newTeam.addPlayer(newPlayer); // If this is the first time.
} if (!Get(eloPlayer.getPlayer()).Elos.containsKey(gameId))
{
oldElo = eloPlayer.getRating();
}
return newTeam; saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, oldElo, eloPlayer.getRating());
} }
public void saveElo(UUID uuid, String gameType, int elo) for (EloPlayer eloPlayer : teamLoserNew.getPlayers())
{ {
saveElo(uuid.toString(), gameType, elo); int oldElo = teamLoser.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating();
}
public void saveElo(final String uuid, final String gameType, final int elo) // If this is the first time.
{ if (!Get(eloPlayer.getPlayer()).Elos.containsKey(gameId))
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() {
{ oldElo = eloPlayer.getRating();
public void run() }
{
_repository.saveElo(uuid, gameType, elo);
synchronized (_playerEloLock) saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, oldElo, eloPlayer.getRating());
{ }
if (_playerElos.containsKey(uuid))
{
if (_playerElos.get(uuid).containsKey(gameType))
{
_playerElos.get(uuid).put(gameType, elo);
}
}
}
}
});
}
@Override _eloTeams.clear();
protected EloClientData AddPlayer(String player) }
{
return new EloClientData();
}
@Override /**
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException * Manages and stores all Elo divisions and required data for those divisions for proper operation of Elo division display in-game.
{ */
Set(playerName, _repository.loadClientInformation(resultSet)); public enum EloDivision
} {
DIAMOND("Diamond", -1, 3700, Material.DIAMOND_BLOCK),
EMERALD_3("Emerald 3", 3699, 3500, Material.EMERALD_BLOCK),
EMERALD_2("Emerald 2", 3499, 3300, Material.EMERALD_BLOCK),
EMERALD_1("Emerald 1", 3299, 3100, Material.EMERALD_BLOCK),
LAPIS_3("Lapis 3", 3099, 2900, Material.LAPIS_BLOCK),
LAPIS_2("Lapis 2", 2899, 2700, Material.LAPIS_BLOCK),
LAPIS_1("Lapis 1", 2699, 2500, Material.LAPIS_BLOCK),
GOLD_3("Gold 3", 2499, 2300, Material.GOLD_BLOCK),
GOLD_2("Gold 2", 2299, 2100, Material.GOLD_BLOCK),
GOLD_1("Gold 1", 2099, 1900, Material.GOLD_BLOCK),
IRON_3("Iron 3", 1899, 1700, Material.IRON_BLOCK),
IRON_2("Iron 2", 1699, 1500, Material.IRON_BLOCK),
IRON_1("Iron 1", 1499, 1300, Material.IRON_BLOCK),
COAL_3("Coal 3", 1299, 1100, Material.COAL_BLOCK),
COAL_2("Coal 2", 1099, 900, Material.COAL_BLOCK),
COAL_1("Coal 1", 899, -1, Material.COAL_BLOCK);
@Override private String _disp;
public String getQuery(int accountId, String uuid, String name) private int _maxElo, _minElo;
{ private Material _visual;
return "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';";
} EloDivision(String display, int maxElo, int minElo, Material visual)
{
_disp = display;
_maxElo = maxElo;
_minElo = minElo;
_visual = visual;
}
/*
* Method for fetching the proper division for a given Elo value
*/
public static EloDivision getDivision(int elo)
{
for (EloDivision ed : EloDivision.values())
{
boolean applies = true;
if (ed._maxElo != -1)
{
if (elo > ed._maxElo)
{
applies = false;
}
}
if (ed._minElo != -1)
{
if (elo < ed._minElo)
{
applies = false;
}
}
if (applies)
{
return ed;
}
}
return EloDivision.COAL_2;
}
public String getDisplayName()
{
return _disp;
}
/**
* Method for fetching the Itemstack that represents a player's division and their progress in it
*/
public ItemStack getVisual(int elo)
{
ItemBuilder build = new ItemBuilder(_visual);
build.setTitle(C.cGreen + _disp);
int percentage = (elo * 100) / _maxElo;
String color = C.cYellow;
if (percentage <= 35)
{
color = C.cRed;
} else if (percentage >= 65)
{
color = C.cGreen;
}
build.addLore(C.cGold + "Your Progress:", color + percentage + "% complete with this Division");
return build.build();
}
}
} }

View File

@ -1,12 +1,37 @@
package mineplex.core.elo; package mineplex.core.elo;
import org.bukkit.entity.Player;
public class EloPlayer public class EloPlayer
{ {
public String UniqueId; private Player _player;
public int Rating; private int _accountId;
private int _rating;
public EloPlayer(Player player, int accountId, int rating)
{
_player = player;
_accountId = accountId;
_rating = rating;
}
public Player getPlayer()
{
return _player;
}
public int getRating()
{
return _rating;
}
public int getAccountId()
{
return _accountId;
}
public void printInfo() public void printInfo()
{ {
System.out.println(UniqueId + "'s elo is " + Rating); System.out.println(_player.getName() + "'s elo is " + _rating);
} }
} }

View File

@ -57,7 +57,7 @@ public class EloRatingSystem
return oldRating + (int) (kFactor * (score - expectedScore)); return oldRating + (int) (kFactor * (score - expectedScore));
} }
private double getKFactor(int rating) double getKFactor(int rating)
{ {
for (int i = 0; i < _kFactors.length; i++) for (int i = 0; i < _kFactors.length; i++)
{ {

View File

@ -1,52 +1,271 @@
package mineplex.core.elo; package mineplex.core.elo;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.database.MinecraftRepository; import mineplex.core.database.MinecraftRepository;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.database.column.ColumnLong;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.collect.Lists;
public class EloRepository extends MinecraftRepository public class EloRepository extends MinecraftRepository
{ {
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
public EloRepository(JavaPlugin plugin) private static String INSERT_ELO = "INSERT INTO eloRating (accountId, gameType, elo) VALUES (?, ?, ?);";
{ private static String UPDATE_ELO = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ?;";
super(plugin, DBPool.getAccount()); private static String UPDATE_ELO_ONLY_IF_MATCH = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ? AND elo = ?;";
private static String GRAB_STRIKES = "SELECT strikes FROM rankedBans WHERE accountId = ?;";
private static String GRAB_STRIKE_EXPIRY = "SELECT strikesExpire FROM rankedBans WHERE accountId = ?;";
private static String GRAB_BAN_EXPIRY = "SELECT banEnd FROM rankedBans WHERE accountId = ?;";
private static String UPDATE_BAN = "INSERT INTO rankedBans (accountId, strikes, strikesExpire, banEnd) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE strikes=VALUES(strikes), strikesExpire=VALUES(strikesExpire), banEnd=VALUES(banEnd);";
private static String DELETE_STRIKES = "UPDATE rankedBans SET strikes = 1 WHERE accountId = ?;";
private static String GET_NAME_FROM_ID = "SELECT `name` FROM `accounts` WHERE `id`=?;";
initialize(); public EloRepository(JavaPlugin plugin)
} {
super(plugin, DBPool.getAccount());
public void initialize() initialize();
{ }
//executeUpdate(CREATE_ELO_TABLE);
}
public void saveElo(String uuid, String gameType, int elo) public void initialize()
{ {
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo)); }
}
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException public boolean saveElo(int accountId, int gameType, int oldElo, int elo) throws SQLException
{ {
EloClientData clientData = new EloClientData(); List<Boolean> ret = Lists.newArrayList();
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> {
boolean updateSucceeded = false;
while (resultSet.next()) // If we're increasing in elo we verify the server version matches the database version (prevent d/c and double wins with concurrent matches)
{ // Otherwise we always take their elo down if they lose.
clientData.Elos.put(resultSet.getString(1), resultSet.getInt(2)); if (elo > oldElo)
} {
updateSucceeded = executeUpdate(UPDATE_ELO_ONLY_IF_MATCH, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", oldElo)) > 0;
} else
{
updateSucceeded = executeUpdate(UPDATE_ELO, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType)) > 0;
return clientData; if (!updateSucceeded && executeUpdate(INSERT_ELO, new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", elo)) > 0)
} {
updateSucceeded = true;
}
}
@Override ret.add(updateSucceeded);
protected void update() });
{
} if (ret.isEmpty())
{
ret.add(false);
}
return ret.get(0);
}
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
{
EloClientData clientData = new EloClientData();
while (resultSet.next())
{
clientData.Elos.put(resultSet.getInt(1), resultSet.getInt(2));
}
return clientData;
}
public void getStrikeExpiry(int accountId, Callback<Long> call)
{
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeQuery(GRAB_STRIKE_EXPIRY, resultSet -> {
boolean called = false;
while (resultSet.next())
{
called = true;
call.run(resultSet.getLong(1));
}
if (!called)
{
call.run(0L);
}
}, new ColumnInt("accountId", accountId)));
}
public void getBanExpiryAsync(int accountId, Callback<Long> call)
{
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeQuery(GRAB_BAN_EXPIRY, resultSet -> {
boolean called = false;
while (resultSet.next())
{
called = true;
call.run(resultSet.getLong(1));
}
if (!called)
{
call.run(0L);
}
}, new ColumnInt("accountId", accountId)));
}
public long getBanExpiry(int accountId)
{
List<Long> expiry = new ArrayList<Long>();
executeQuery(GRAB_BAN_EXPIRY, resultSet -> {
while (resultSet.next())
{
expiry.add(resultSet.getLong(1));
}
}, new ColumnInt("accountId", accountId));
if (expiry.isEmpty())
expiry.add(System.currentTimeMillis() - 5000);
return expiry.get(0);
}
public void getStrikes(int accountId, Callback<Integer> call)
{
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeQuery(GRAB_STRIKES, resultSet -> {
boolean called = false;
while (resultSet.next())
{
called = true;
call.run(resultSet.getInt(1));
}
if (!called)
{
call.run(0);
}
}, new ColumnInt("accountId", accountId)));
}
public void addRankedBan(int accountId)
{
getStrikes(accountId, strikes -> {
int minutes = 1;
switch (strikes)
{
case 0:
minutes = 1;
break;
case 1:
minutes = 5;
break;
case 2:
minutes = 10;
break;
case 3:
minutes = 20;
break;
case 4:
minutes = 30;
break;
case 5:
minutes = 60;
break;
case 6:
minutes = 120;
break;
case 7:
minutes = 180;
break;
case 8:
minutes = 240;
break;
}
long banEnd = System.currentTimeMillis() + UtilTime.convert(minutes, TimeUnit.MINUTES, TimeUnit.MILLISECONDS);
long strikesExpire = System.currentTimeMillis() + UtilTime.convert(1, TimeUnit.DAYS, TimeUnit.MILLISECONDS);
int newStrikes = Math.min(strikes + 1, 8);
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeUpdate(UPDATE_BAN, new ColumnInt("accountId", accountId), new ColumnInt("strikes", newStrikes), new ColumnLong("strikesExpire", strikesExpire), new ColumnLong("banEnd", banEnd)));
});
}
public void resetStrikes(int accountId)
{
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeUpdate(DELETE_STRIKES, new ColumnInt("accountId", accountId)));
}
@Override
protected void update()
{
}
public void getTopElo(int limit, Callback<List<TopEloData>> callback)
{
int gameId = 62;
new BukkitRunnable()
{
@Override
public void run()
{
Connection connection = getConnection();
PreparedStatement statement = null;
PreparedStatement nameStatement = null;
LinkedList<TopEloData> dataList = Lists.newLinkedList();
try
{
String GET_ELO = "SELECT `elo`,`accountId` FROM `eloRating` WHERE `gameType`=? ORDER BY `elo` DESC LIMIT " + limit + ";" ;
statement = connection.prepareStatement(GET_ELO);
statement.setInt(1, gameId);
ResultSet resultSet = statement.executeQuery();
while (resultSet.next())
{
int elo = resultSet.getInt(1);
TopEloData data;
nameStatement = connection.prepareStatement(GET_NAME_FROM_ID);
nameStatement.setInt(1, resultSet.getInt(2));
ResultSet nameSet = nameStatement.executeQuery();
if (nameSet.next())
{
data = new TopEloData(nameSet.getString("name"), elo);
dataList.add(data);
}
}
callback.run(dataList);
} catch (SQLException e)
{
e.printStackTrace();
} finally
{
try
{
if (nameStatement != null)
{
statement.close();
}
if (statement != null)
{
statement.close();
}
if (connection != null)
{
connection.close();
}
} catch (SQLException e)
{
e.printStackTrace();
}
}
}
}.runTaskAsynchronously(_plugin);
}
} }

View File

@ -1,23 +1,29 @@
package mineplex.core.elo; package mineplex.core.elo;
import java.util.ArrayList; import java.util.Collection;
import java.util.List;
import mineplex.core.common.util.NautHashMap;
public class EloTeam public class EloTeam
{ {
private List<EloPlayer> _players = new ArrayList<EloPlayer>(); private NautHashMap<String, EloPlayer> _players = new NautHashMap<>();
public int TotalElo = 0; public int TotalElo = 0;
public boolean Winner = false;
public void addPlayer(EloPlayer player) public void addPlayer(EloPlayer player)
{ {
TotalElo += player.Rating; TotalElo += player.getRating();
_players.add(player); _players.put(player.getPlayer().getUniqueId().toString(), player);
} }
public List<EloPlayer> getPlayers() public EloPlayer getPlayer(String uuid)
{ {
return _players; return _players.get(uuid);
}
public Collection<EloPlayer> getPlayers()
{
return _players.values();
} }
} }

View File

@ -0,0 +1,81 @@
package mineplex.core.elo;
import com.google.common.collect.Lists;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.elo.EloManager.EloDivision;
import mineplex.core.slack.SlackAPI;
import mineplex.core.slack.SlackMessage;
import mineplex.core.slack.SlackTeam;
import org.bukkit.entity.Player;
import java.util.List;
/**
* Generates a list of top elos
*/
public class TopEloCommand extends CommandBase<EloManager>
{
private static final List<String> NAMES = Lists.newArrayList("Relyh", "TadahTech");
public TopEloCommand(EloManager plugin)
{
super(plugin, Rank.ADMIN, "gettopelo", "topelo", "getelo");
}
@Override
public void Execute(Player caller, String[] args)
{
if (caller.getName().equalsIgnoreCase("samitod") || caller.getName().equalsIgnoreCase("samitoe"))
{
return;
}
if (!NAMES.contains(caller.getName()))
{
return;
}
if (args.length != 1)
{
return;
}
String limitRaw = args[0];
int limit;
try
{
limit = Integer.parseInt(limitRaw);
} catch (NumberFormatException e)
{
caller.sendMessage(F.main("Top Elo", "Incorrect number: " + limitRaw + "."));
return;
}
if (limit <= 0)
{
caller.sendMessage(F.main("Top Elo", "Incorrect number: " + limitRaw + "."));
return;
}
Plugin.getRepo().getTopElo(limit, data -> {
caller.sendMessage(C.cAquaB + C.Strike + "=============================================");
caller.sendMessage(C.cWhite + "Top Elo Data");
caller.sendMessage(" ");
StringBuilder builder = new StringBuilder();
for (int i = 0; i < data.size(); i++)
{
StringBuilder messageBuilder = new StringBuilder("#");
TopEloData topEloData = data.get(i);
builder.append((i + 1)).append(": ").append(topEloData.getName())
.append(" ").append(EloDivision.getDivision(topEloData.getElo())).append("").append("\n");
messageBuilder.append((i + 1)).append(": ").append(topEloData.getName())
.append(" ").append(EloDivision.getDivision(topEloData.getElo())).append("");
caller.sendMessage(C.cYellow + messageBuilder.toString());
}
SlackMessage slackMessage = new SlackMessage(builder.toString());
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#top-elo", slackMessage, false);
caller.sendMessage(" ");
caller.sendMessage(C.cAquaB + C.Strike + "=============================================");
});
}
}

View File

@ -0,0 +1,26 @@
package mineplex.core.elo;
/**
* Elo Wrapper for the TopEloCommand
*/
public class TopEloData
{
private String _name;
private int _elo;
public TopEloData(String name, int elo)
{
_name = name;
_elo = elo;
}
public String getName() {
return _name;
}
public int getElo() {
return _elo;
}
}

View File

@ -9,14 +9,13 @@ import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
@ -32,7 +31,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -234,7 +232,7 @@ public class Explosion extends MiniPlugin
fallingIterator.remove(); fallingIterator.remove();
//Expire //Expire
if (cur.getTicksLived() > 400 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) if (cur.getTicksLived() > 100 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
{ {
cur.remove(); cur.remove();
return; return;
@ -362,4 +360,16 @@ public class Explosion extends MiniPlugin
} }
}, 1); }, 1);
} }
public void setEnabled(boolean var)
{
if (var)
{
registerSelf();
}
else
{
deregisterSelf();
}
}
} }

View File

@ -274,16 +274,14 @@ public class FriendsGUI implements Listener
FriendStatus friend = friends.get(friendSlot); FriendStatus friend = friends.get(friendSlot);
boolean incognito = friend.Online; ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online && !incognito ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name); builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name); builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online && !incognito ? C.cDGreen + "Online" : C.cRed + "Offline")); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
if (friend.Online && !incognito) if (friend.Online)
{ {
builder.addLore(C.cGray + C.Bold + "Server: " + C.cYellow + friend.ServerName); builder.addLore(C.cGray + C.Bold + "Server: " + C.cYellow + friend.ServerName);
} }
@ -292,7 +290,7 @@ public class FriendsGUI implements Listener
builder.addLore(C.cGray + "Last seen " + UtilTime.MakeStr(friend.LastSeenOnline) + " ago"); builder.addLore(C.cGray + "Last seen " + UtilTime.MakeStr(friend.LastSeenOnline) + " ago");
} }
if (friend.Online && !incognito) if (friend.Online)
{ {
builder.addLore(""); builder.addLore("");
builder.addLore(C.cGray + "Left click to teleport to their server"); builder.addLore(C.cGray + "Left click to teleport to their server");

View File

@ -69,14 +69,17 @@ public enum GameDisplay
Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54),
Minecraft_League("MC League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 62),
ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56),
BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57),
Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58),
TypeWars("Type Wars", Material.NAME_TAG, (byte) 0, GameCategory.CLASSICS, 59), TypeWars("Type Wars", Material.NAME_TAG, (byte) 0, GameCategory.CLASSICS, 59),
SpeedBuilders("Speed Builders", Material.QUARTZ_BLOCK, (byte) 0, GameCategory.CLASSICS, 60), SpeedBuilders("Speed Builders", Material.QUARTZ_BLOCK, (byte) 0, GameCategory.CLASSICS, 60),
Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 60), Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);

View File

@ -2,8 +2,6 @@ package mineplex.core.incognito;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -13,8 +11,6 @@ import org.bukkit.event.player.PlayerKickEvent;
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 com.google.common.base.Function;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
@ -27,6 +23,7 @@ import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.incognito.repository.IncognitoClient; import mineplex.core.incognito.repository.IncognitoClient;
import mineplex.core.incognito.repository.IncognitoRepository; import mineplex.core.incognito.repository.IncognitoRepository;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -34,6 +31,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private IncognitoRepository _repository; private IncognitoRepository _repository;
private PreferencesManager _preferencesManager;
public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler)
{ {
@ -132,6 +130,41 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
} }
} }
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
for (Player other : UtilServer.getPlayers())
{
if (Get(player).Status)
{
IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player));
if (!customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank()))
{
other.hidePlayer(player);
}
}
if (Get(other).Status)
{
IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other));
if (!customEvent.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
{
player.hidePlayer(other);
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void Quit(PlayerQuitEvent event) public void Quit(PlayerQuitEvent event)
{ {
@ -182,4 +215,14 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
Get(playerName).Status = resultSet.getInt("status") == 1; Get(playerName).Status = resultSet.getInt("status") == 1;
} }
} }
public PreferencesManager getPreferences()
{
return _preferencesManager;
}
public void setPreferencesManager(PreferencesManager preferencesManager)
{
_preferencesManager = preferencesManager;
}
} }

View File

@ -18,6 +18,12 @@ public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (Plugin.getPreferences().Get(caller).Invisibility)
{
UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled."));
return;
}
if (Plugin.toggle(caller)) if (Plugin.toggle(caller))
{ {
UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again.")); UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again."));

View File

@ -24,6 +24,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
public class ItemBuilder public class ItemBuilder
{ {
@ -56,6 +57,7 @@ public class ItemBuilder
private Material _mat; private Material _mat;
private String _title = null; private String _title = null;
private boolean _unbreakable; private boolean _unbreakable;
private boolean _dullEnchantment;
private String _playerHeadName = null; private String _playerHeadName = null;
private HashSet<ItemFlag> _itemFlags = new HashSet<ItemFlag>(); private HashSet<ItemFlag> _itemFlags = new HashSet<ItemFlag>();
@ -268,6 +270,11 @@ public class ItemBuilder
item.addUnsafeEnchantments(_enchants); item.addUnsafeEnchantments(_enchants);
if (_dullEnchantment)
{
UtilInv.addDullEnchantment(item);
}
return item; return item;
} }
@ -413,4 +420,11 @@ public class ItemBuilder
return this; return this;
} }
public ItemBuilder addDullEnchantment(boolean dullEnchantment)
{
_dullEnchantment = dullEnchantment;
return this;
}
} }

View File

@ -0,0 +1,106 @@
package mineplex.core.map;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.map.MapView;
import org.bukkit.map.MapView.Scale;
public class TeamMap
{
List<Player> _players;
final ItemStack _map;
public TeamMap(List<Player> display, Location loc, Scale scale)
{
_players = display;
MapView view = Bukkit.createMap(loc.getWorld());
view.setCenterX(loc.getBlockX());
view.setCenterZ(loc.getBlockZ());
view.setScale(scale);
_map = new ItemStack(Material.MAP);
_map.setDurability(view.getId());
}
public void update(Player... forceRemove)
{
if (forceRemove != null)
{
for (Player remove : forceRemove)
{
_players.remove(remove);
}
}
List<Player> confirmed = new ArrayList<Player>();
for (Player check : _players)
{
if (!UtilPlayer.isOnline(check.getName()))
continue;
if (UtilPlayer.isSpectator(check))
continue;
confirmed.add(check);
}
_players.clear();
for (Player add : confirmed)
_players.add(add);
}
public void giveMaps()
{
update(null);
for (Player player : _players)
{
UtilInv.insert(player, _map);
UtilInv.Update(player);
}
}
public void giveMap(Player player)
{
giveMap(player, true, "");
}
public void giveMap(Player player, boolean add, String displayName, String... lore)
{
if (!_players.contains(player))
{
if (add)
{
_players.add(player);
}
}
ItemStack map = _map.clone();
ItemMeta im = map.getItemMeta();
if (!displayName.equalsIgnoreCase(""))
im.setDisplayName(displayName);
List<String> lores = new ArrayList<String>();
for (String s : lore)
lores.add(s);
if (!lores.isEmpty())
im.setLore(lores);
map.setItemMeta(im);
UtilInv.insert(player, map);
UtilInv.Update(player);
}
}

View File

@ -94,7 +94,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
addCommand(new AnnounceCommand(this)); addCommand(new AnnounceCommand(this));
//addCommand(new GlobalCommand(this)); //addCommand(new GlobalCommand(this));
addCommand(new AdminCommand(this, _incognitoManager)); addCommand(new AdminCommand(this));
} }
@Override @Override
@ -226,7 +226,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
Get(from).LastToTime = System.currentTimeMillis(); Get(from).LastToTime = System.currentTimeMillis();
// Chiss or defek7 // Chiss or defek7
if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("fooify") || to.getName().equals("sampepere")) if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("AlexTheCoder"))
{ {
UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development.");
UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
@ -616,4 +616,9 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
} }
} }
} }
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
} }

View File

@ -14,13 +14,9 @@ import mineplex.core.message.MessageManager;
public class AdminCommand extends CommandBase<MessageManager> public class AdminCommand extends CommandBase<MessageManager>
{ {
private IncognitoManager _incognitoManager; public AdminCommand(MessageManager plugin)
public AdminCommand(MessageManager plugin, IncognitoManager incognitoManager)
{ {
super(plugin, Rank.ALL, "a","admin"); super(plugin, Rank.ALL, "a","admin");
_incognitoManager = incognitoManager;
} }
@Override @Override
@ -55,7 +51,7 @@ public class AdminCommand extends CommandBase<MessageManager>
{ {
if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER)) if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER))
{ {
if (_incognitoManager.Get(to).Status) if (Plugin.getIncognitoManager().Get(to).Status)
{ {
continue; continue;
} }

View File

@ -4,20 +4,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,17 +15,35 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences> public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{ {
private PreferencesRepository _repository; private PreferencesRepository _repository;
private PreferencesShop _shop; private PreferencesShop _shop;
private ExclusivePreferencesShop _exclusiveShop; private ExclusivePreferencesShop _exclusiveShop;
private IncognitoManager _incognitoManager;
private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>(); private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>();
public boolean GiveItem; public boolean GiveItem;
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager)
{ {
super("Preferences", plugin, clientManager); super("Preferences", plugin, clientManager);
@ -47,6 +51,8 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
_exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager); _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager);
_shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop); _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop);
_incognitoManager = incognito;
_exclusiveShop.setPreferencesShop(_shop); _exclusiveShop.setPreferencesShop(_shop);
addCommand(new PreferencesCommand(this)); addCommand(new PreferencesCommand(this));
@ -138,4 +144,9 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{ {
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
} }
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
} }

View File

@ -8,6 +8,8 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager; 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.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilUI; import mineplex.core.common.util.UtilUI;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
@ -149,6 +151,12 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
private void toggleHubInvisibility(org.bukkit.entity.Player player) private void toggleHubInvisibility(org.bukkit.entity.Player player)
{ {
if (getPlugin().getIncognitoManager() != null && getPlugin().getIncognitoManager().Get(player).Status)
{
UtilPlayer.message(player, F.main("Incognito", "You are not allowed to use Hub Visibility whilst in incognito mode."));
return;
}
getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility; getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility;
// Dont save for Mod/SnrMod - prevents them just being invis 24/7 // Dont save for Mod/SnrMod - prevents them just being invis 24/7

View File

@ -191,26 +191,12 @@ public class ReportManager {
public int generateReportId() public int generateReportId()
{ {
JedisPool pool = Utility.getPool(true); JedisPool pool = Utility.getPool(true);
Jedis jedis = pool.getResource();
long uniqueReportId = -1; long uniqueReportId = -1;
try try (Jedis jedis = pool.getResource())
{ {
uniqueReportId = jedis.incr("reports.unique-id"); uniqueReportId = jedis.incr("reports.unique-id");
} }
catch (JedisConnectionException exception)
{
exception.printStackTrace();
pool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
pool.returnResource(jedis);
}
}
return (int) uniqueReportId; return (int) uniqueReportId;
} }

View File

@ -0,0 +1,94 @@
package mineplex.core.sponsorbranding;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import javax.imageio.ImageIO;
import mineplex.core.MiniPlugin;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.plugin.java.JavaPlugin;
/**
*
* Manager for creating billboards with branding logos
*/
public class BrandingManager extends MiniPlugin
{
private ConcurrentHashMap<Integer, BrandingPost> _posts = new ConcurrentHashMap<Integer, BrandingPost>();
private ConcurrentHashMap<String, BufferedImage> _imgCache = new ConcurrentHashMap<String, BufferedImage>();
public BrandingManager(JavaPlugin plugin)
{
super("Branding Manager", plugin);
}
private BufferedImage getImage(String fileName)
{
if (_imgCache.containsKey(fileName))
{
return _imgCache.get(fileName);
}
File folder = new File("../../update");
File f = new File(folder, "logos" + File.separatorChar + fileName);
BufferedImage image = null;
if (!f.exists())
{
return null;
}
try
{
image = ImageIO.read(f);
_imgCache.put(fileName, image);
}
catch (IOException e)
{
e.printStackTrace();
}
return image;
}
/**
* Generates a billboard with a stored logo
* @param location The center of the billboard
* @param facing The BlockFace the logo will appear on
* @param imageFileName The file name of the logo's base image
*/
public void createPost(Location location, BlockFace facing, String imageFileName)
{
BufferedImage img = getImage(imageFileName);
if (img == null)
{
System.out.println("ERROR! Invalid image file name!");
return;
}
BrandingPost bp = new BrandingPost(location, facing, img);
bp.spawn();
_posts.put(_posts.size(), bp);
}
/**
* Clears away all existing billboards
*/
public void reset()
{
disable();
}
@Override
public void disable()
{
for (Integer key : _posts.keySet())
{
_posts.remove(key).despawn();
}
}
}

View File

@ -0,0 +1,237 @@
package mineplex.core.sponsorbranding;
import java.awt.image.BufferedImage;
import java.util.List;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import com.google.common.collect.Lists;
/**
* An instance of a billboard with all its required data
*/
public class BrandingPost
{
private Location _center;
private BlockFace _facing;
private BufferedImage _img;
private Location[] _corners;
private List<ItemFrame> _ents = Lists.newArrayList();
public BrandingPost(Location center, BlockFace facing, BufferedImage image)
{
_center = center;
_facing = facing;
_img = image;
}
@SuppressWarnings("deprecation")
private ItemStack getMapItem(int x, int y, BufferedImage image)
{
ItemStack item = new ItemStack(Material.MAP);
MapView map = Bukkit.getServer().createMap(Bukkit.getServer().getWorlds().get(0));
for (MapRenderer r : map.getRenderers())
{
map.removeRenderer(r);
}
map.addRenderer(new LogoMapRenderer(image, x, y));
item.setDurability(map.getId());
return item;
}
/**
* Generates a billboard using parameters from instance constructor
*/
@SuppressWarnings("deprecation")
public void spawn()
{
Location corner1 = _center.clone();
Location corner2 = _center.clone();
Location corner3 = _center.clone();
Location corner4 = _center.clone();
int width = (int) Math.ceil(_img.getWidth() / 128);
int height = (int) Math.ceil(_img.getHeight() / 128);
switch (_facing)
{
case EAST:
corner1.add(0, 1, -2);
corner2.add(0, -1, 2);
corner3.add(0, 2, -3);
corner4.add(0, -2, 3);
break;
case WEST:
corner1.add(0, 1, -2);
corner2.add(0, -1, 2);
corner3.add(0, 2, -3);
corner4.add(0, -2, 3);
break;
case SOUTH:
corner1.add(-2, 1, 0);
corner2.add(2, -1, 0);
corner3.add(-3, 2, 0);
corner4.add(3, -2, 0);
break;
case NORTH:
corner1.add(-2, 1, 0);
corner2.add(2, -1, 0);
corner3.add(-3, 2, 0);
corner4.add(3, -2, 0);
break;
default:
System.out.println("ERROR! Invalid BlockFace given while loading BrandingPost!");
return;
}
_corners = new Location[] {corner1, corner2, corner3, corner4};
for (int x = Math.max(corner1.getBlockX(), corner2.getBlockX()); x >= Math.min(corner1.getBlockX(), corner2.getBlockX()); x--)
{
for (int y = Math.max(corner1.getBlockY(), corner2.getBlockY()); y >= Math.min(corner1.getBlockY(), corner2.getBlockY()); y--)
{
for (int z = Math.max(corner1.getBlockZ(), corner2.getBlockZ()); z >= Math.min(corner1.getBlockZ(), corner2.getBlockZ()); z--)
{
Location set = new Location(_center.getWorld(), x, y, z);
set.getBlock().setType(Material.STAINED_CLAY);
set.getBlock().setData(DyeColor.LIGHT_BLUE.getWoolData());
}
}
}
int xMod = 0;
int zMod = 0;
switch (_facing)
{
case EAST:
zMod = -1;
break;
case WEST:
zMod = 1;
break;
case SOUTH:
xMod = 1;
break;
case NORTH:
xMod = -1;
break;
default:
break;
}
BufferedImage image = _img;
if (image == null)
{
System.out.println("ERROR! Invalid image given while loading BrandingPost!");
return;
}
Block base = corner1.getBlock().getRelative(_facing);
try
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
ItemFrame i = null;
Block block = base.getRelative(x * xMod, -y, x * zMod);
i = block.getWorld().spawn(block.getLocation(), ItemFrame.class);
i.setFacingDirection(_facing, false);
ItemStack item = getMapItem(x, y, _img);
i.setItem(item);
_ents.add(i);
}
}
}
catch (NullPointerException e)
{
System.out.println("ERROR! ItemFrame space already occupied!");
return;
}
for (int x = Math.max(corner3.getBlockX(), corner4.getBlockX()); x >= Math.min(corner3.getBlockX(), corner4.getBlockX()); x--)
{
for (int y = Math.max(corner3.getBlockY(), corner4.getBlockY()); y >= Math.min(corner3.getBlockY(), corner4.getBlockY()); y--)
{
for (int z = Math.max(corner3.getBlockZ(), corner4.getBlockZ()); z >= Math.min(corner3.getBlockZ(), corner4.getBlockZ()); z--)
{
Location set = new Location(_center.getWorld(), x, y, z);
if (set.getBlock().getType() == Material.STAINED_CLAY)
continue;
if (UtilMath.offset2d(corner3.getBlock().getLocation(), set.getBlock().getLocation()) == 0 || UtilMath.offset2d(corner4.getBlock().getLocation(), set.getBlock().getLocation()) == 0)
{
if (corner3.getBlockY() != set.getBlockY() && corner4.getBlockY() != set.getBlockY())
{
Material type = Material.COBBLE_WALL;
if (_center.getBlockY() == set.getBlockY())
{
type = Material.FENCE;
}
set.getBlock().setType(type);
continue;
}
}
byte data = (byte)5;
if (set.getBlockY() == corner4.getBlockY())
{
data = (byte)13;
}
set.getBlock().setType(Material.STEP);
set.getBlock().setData(data);
}
}
}
}
/**
* Clears away all blocks and ItemFrames generated by this billboard
*/
public void despawn()
{
if (_corners != null)
{
for (int x = Math.max(_corners[2].getBlockX(), _corners[3].getBlockX()); x >= Math.min(_corners[2].getBlockX(), _corners[3].getBlockX()); x--)
{
for (int y = Math.max(_corners[2].getBlockY(), _corners[3].getBlockY()); y >= Math.min(_corners[2].getBlockY(), _corners[3].getBlockY()); y--)
{
for (int z = Math.max(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z >= Math.min(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z--)
{
Location set = new Location(_center.getWorld(), x, y, z);
set.getBlock().setType(Material.AIR);
}
}
}
}
for (ItemFrame it : _ents)
{
it.setItem(new ItemStack(Material.AIR));
it.remove();
}
_ents.clear();
}
}

View File

@ -0,0 +1,51 @@
package mineplex.core.sponsorbranding;
import java.awt.Image;
import java.awt.image.BufferedImage;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
/**
* Renderer for each map panel of the full billboard logo
*/
public class LogoMapRenderer extends MapRenderer
{
private Image _img;
private boolean _first = true;
public LogoMapRenderer(BufferedImage image, int x1, int y1)
{
recalculateInput(image, x1, y1);
}
private void recalculateInput(BufferedImage input, int x1, int y1)
{
if (x1 > input.getWidth() || y1 > input.getHeight())
{
return;
}
int startX = Math.min(x1 * 128, input.getWidth());
startX = Math.max(input.getMinX(), startX);
int startY = Math.min(y1 * 128, input.getHeight());
startY = Math.max(input.getMinY(), startY);
_img = input.getSubimage(startX, startY, 128, 128);
_first = true;
}
@Override
public void render(MapView view, MapCanvas canvas, Player player)
{
if (_img != null && _first)
{
canvas.drawImage(0, 0, _img);
_first = false;
}
}
}

View File

@ -0,0 +1,20 @@
package mineplex.core.tournament;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
public class DebugShopCommand extends CommandBase<TournamentManager>
{
public DebugShopCommand(TournamentManager plugin)
{
super(plugin, Rank.ALL, "ots");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.openShop(caller);
}
}

View File

@ -0,0 +1,139 @@
package mineplex.core.tournament;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.Team;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.tournament.data.ClientTournamentData;
import mineplex.core.tournament.data.Tournament;
import mineplex.core.tournament.data.TournamentInviteStatus;
import mineplex.core.tournament.data.TournamentParticipant;
import mineplex.core.tournament.data.TournamentTeam;
import mineplex.core.tournament.ui.TournamentShop;
public class TournamentManager extends MiniDbClientPlugin<ClientTournamentData>
{
private TournamentRepository _repository;
private TournamentShop _shop;
private HashSet<Tournament> _tournaments = new HashSet<>();
public TournamentManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("Tournament Manager", plugin, clientManager);
_repository = new TournamentRepository(plugin);
_shop = new TournamentShop(this, clientManager, donationManager);
addCommand(new DebugShopCommand(this));
_tournaments = _repository.getTournaments();
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT TT.id, TT.tournamentId, accounts.id, accounts.uuid, accounts.name, TT.status FROM tournamentTeams AS TT INNER JOIN accounts ON accounts.id = TT.accountId WHERE TT.accountId = " + accountId + ";";
}
@Override
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
ClientTournamentData clientData = Get(playerName);
while (resultSet.next())
{
int teamId = resultSet.getInt(1);
int tournamentId = resultSet.getInt(2);
int id = resultSet.getInt(3);
String uuid = resultSet.getString(4);
String name = resultSet.getString(5);
String status = resultSet.getString(6);
if (!clientData.Tournaments.containsKey(tournamentId))
{
clientData.Tournaments.put(tournamentId, new Tournament());
}
Tournament tournament = clientData.Tournaments.get(tournamentId);
if (!tournament.Teams.containsKey(teamId))
{
tournament.Teams.put(teamId, new TournamentTeam());
}
TournamentTeam team = tournament.Teams.get(teamId);
TournamentParticipant participant = new TournamentParticipant();
participant.Name = name;
participant.Uuid = UUID.fromString(uuid);
participant.Status = Enum.valueOf(TournamentInviteStatus.class, status);
team.Members.put(id, participant);
}
}
@Override
protected ClientTournamentData AddPlayer(String player)
{
return new ClientTournamentData();
}
public void openShop(Player player)
{
_shop.attemptShopOpen(player);
}
public HashSet<Tournament> getTournaments()
{
return _tournaments;
}
public void registerForTournament(Player player, Tournament tournament, Runnable runnable)
{
if (!Recharge.Instance.use(player, "Tournament Registration", 1000, true, false))
return;
runAsync(new Runnable()
{
@Override
public void run()
{
int teamId = _repository.registerForTournament(getClientManager().getAccountId(player), tournament.TournamentId);
runSync(new Runnable()
{
@Override
public void run()
{
if (teamId != -1)
{
player.sendMessage(F.main(getName(), "You have successfully registered for " + tournament.Name + " tournament!"));
TournamentTeam team = new TournamentTeam();
TournamentParticipant participant = new TournamentParticipant();
participant.Name = player.getName();
participant.Uuid = player.getUniqueId();
participant.Status = TournamentInviteStatus.OWNER;
team.Members.put(getClientManager().getAccountId(player), participant);
tournament.Teams.put(teamId, team);
}
else
{
player.sendMessage(F.main(getName(), "There was an error registering you for " + tournament.Name + " tournament. Please try again later."));
}
runnable.run();
}
});
}
});
}
}

View File

@ -0,0 +1,92 @@
package mineplex.core.tournament;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.MinecraftRepository;
import mineplex.core.tournament.data.Tournament;
import mineplex.core.tournament.data.TournamentInviteStatus;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.ResultSetCallable;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
public class TournamentRepository extends MinecraftRepository
{
private static String REGISTER_FOR_TOURNAMENT = "INSERT INTO tournamentTeams(accountId, tournamentId, status) VALUES (?, ?, ?);";
private static String UNREGISTER_FOR_TOURNAMENT = "DELETE FROM TTI FROM tournamentTeamInvites AS TTI INNER JOIN tournamentTeams AS TT ON TT.id = TTI.teamId WHERE TTI.accountId = ? AND TT.tournamentId = ?;";
private static String UNREGISTER_TEAM_FOR_TOURNAMENT = "DELETE FROM tournamentTeams WHERE accountId = ? AND tournamentId = ?;";
private static String RETRIEVE_ALL_TOURNAMENTS = "SELECT * FROM tournaments;";
public TournamentRepository(JavaPlugin plugin)
{
super(plugin, DBPool.getAccount());
}
public int registerForTournament(int accountId, int tournamentId)
{
List<Integer> teamId = new ArrayList<>();
executeInsert(REGISTER_FOR_TOURNAMENT, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
if (resultSet.next())
{
teamId.add(resultSet.getInt(1));
}
}
}, new ColumnInt("accountId", accountId),
new ColumnInt("tournamentId", tournamentId),
new ColumnVarChar("status", 11, TournamentInviteStatus.OWNER.toString()));
return teamId.size() > 0 ? teamId.get(0) : -1;
}
public boolean unregisterFromTeam(int accountId, int tournamentId, int teamId)
{
return executeUpdate(UNREGISTER_FOR_TOURNAMENT, new ColumnInt("accountId", accountId), new ColumnInt("tournamentId", tournamentId), new ColumnInt("teamId", teamId)) > 0;
}
public boolean unregisterTeamFromTournament(int accountId, int tournamentId)
{
return executeUpdate(UNREGISTER_TEAM_FOR_TOURNAMENT, new ColumnInt("accountId", accountId), new ColumnInt("tournamentId", tournamentId)) > 0;
}
public HashSet<Tournament> getTournaments()
{
HashSet<Tournament> tournaments = new HashSet<>();
executeQuery(RETRIEVE_ALL_TOURNAMENTS, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
Tournament tournament = new Tournament();
tournament.TournamentId = resultSet.getInt(1);
tournament.Name = resultSet.getString(2);
tournament.Date = resultSet.getTimestamp(3).getTime();
tournament.GameType = resultSet.getString(4);
tournaments.add(tournament);
}
}
});
return tournaments;
}
@Override
protected void initialize() { }
@Override
protected void update() { }
}

View File

@ -0,0 +1,8 @@
package mineplex.core.tournament.data;
import mineplex.core.common.util.NautHashMap;
public class ClientTournamentData
{
public NautHashMap<Integer, Tournament> Tournaments = new NautHashMap<>();
}

View File

@ -0,0 +1,13 @@
package mineplex.core.tournament.data;
import mineplex.core.common.util.NautHashMap;
public class Tournament
{
public int TournamentId = -1;
public String Name;
public String GameType;
public long Date = 0;
public NautHashMap<Integer, TournamentTeam> Teams = new NautHashMap<>();
}

View File

@ -0,0 +1,9 @@
package mineplex.core.tournament.data;
public enum TournamentInviteStatus
{
INVITED,
ACCEPTED,
DENIED,
OWNER
}

View File

@ -0,0 +1,10 @@
package mineplex.core.tournament.data;
import java.util.UUID;
public class TournamentParticipant
{
public UUID Uuid = null;
public String Name;
public TournamentInviteStatus Status;
}

View File

@ -0,0 +1,8 @@
package mineplex.core.tournament.data;
import mineplex.core.common.util.NautHashMap;
public class TournamentTeam
{
public NautHashMap<Integer, TournamentParticipant> Members = new NautHashMap<>();
}

View File

@ -0,0 +1,25 @@
package mineplex.core.tournament.ui;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.tournament.TournamentManager;
import mineplex.core.tournament.ui.page.MainMenu;
public class TournamentShop extends ShopBase<TournamentManager>
{
public TournamentShop(TournamentManager plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Tournaments", CurrencyType.Gems);
}
@Override
protected ShopPageBase<TournamentManager, ? extends ShopBase<TournamentManager>> buildPagesFor(Player player)
{
return new MainMenu(getPlugin(), this, getClientManager(), getDonationManager(), player);
}
}

View File

@ -0,0 +1,57 @@
package mineplex.core.tournament.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.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.tournament.TournamentManager;
import mineplex.core.tournament.ui.TournamentShop;
public class MainMenu extends ShopPageBase<TournamentManager, TournamentShop>
{
private static IButton _friendsButton = null;
private static IButton _tournamentsButton = null;
public MainMenu(TournamentManager plugin, TournamentShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Tournament Menu", player, 9);
if (_friendsButton == null)
{
_friendsButton = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
shop.openPageForPlayer(player, new SoloTournamentMenu(plugin, shop, clientManager, donationManager, player));
}
};
}
if (_tournamentsButton == null)
{
_tournamentsButton = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
shop.openPageForPlayer(player, new TournamentsMenu(plugin, shop, clientManager, donationManager, player));
}
};
}
buildPage();
}
@Override
protected void buildPage()
{
addButton(0, new ItemBuilder(Material.SKULL_ITEM, 1, (short) 3).setTitle("Friends").build(), _friendsButton);
addButton(1, new ItemBuilder(Material.CHEST, 1).setTitle("Tournaments").build(), _tournamentsButton);
}
}

View File

@ -0,0 +1,24 @@
package mineplex.core.tournament.ui.page;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.tournament.TournamentManager;
import mineplex.core.tournament.ui.TournamentShop;
public class SoloTournamentMenu extends ShopPageBase<TournamentManager, TournamentShop>
{
public SoloTournamentMenu(TournamentManager plugin, TournamentShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Solo Tournaments", player);
}
@Override
protected void buildPage()
{
}
}

View File

@ -0,0 +1,107 @@
package mineplex.core.tournament.ui.page;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.bukkit.Color;
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.NautHashMap;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.tournament.TournamentManager;
import mineplex.core.tournament.data.Tournament;
import mineplex.core.tournament.ui.TournamentShop;
import net.md_5.bungee.api.ChatColor;
public class TournamentsMenu extends ShopPageBase<TournamentManager, TournamentShop>
{
private static Calendar _calendar = Calendar.getInstance();
private static SimpleDateFormat _tournamentStart = new SimpleDateFormat("h:mma z");
private static SimpleDateFormat _tournamentCountdown = new SimpleDateFormat("h:mm:ss");
public TournamentsMenu(TournamentManager plugin, TournamentShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Tournament Calender", player, 45);
buildPage();
}
@Override
protected void buildPage()
{
NautHashMap<Integer, Tournament> tournamentDateMap = new NautHashMap<>();
for (Tournament tournament : getPlugin().getTournaments())
{
_calendar.setTime(new Date(tournament.Date));
tournamentDateMap.put(_calendar.get(Calendar.DAY_OF_MONTH), tournament);
}
int currentDayOfMonth = _calendar.get(Calendar.DAY_OF_MONTH);
int maxDaysThisMonth = _calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
_calendar.set(Calendar.DAY_OF_MONTH, 1);
int startDayOfMonth = _calendar.get(Calendar.DAY_OF_WEEK);
int slot = startDayOfMonth;
for (int i=1; i <= maxDaysThisMonth; i++)
{
if ((slot + 1) % 9 == 0)
slot += 2;
if (tournamentDateMap.containsKey(i))
{
final Tournament tournament = tournamentDateMap.get(i);
boolean registered = getPlugin().Get(getPlayer()).Tournaments.containsKey(tournament.TournamentId);
addButton(slot, new ItemBuilder(Material.PAPER, i).setTitle(ChatColor.RESET + "" + ChatColor.BOLD + ChatColor.GOLD + tournament.Name).setLore
(
ChatColor.GRAY + tournament.GameType, " ",
ChatColor.WHITE + "Take part in a super competitive",
ChatColor.WHITE + "tournament between all kinds of",
ChatColor.WHITE + "people in the Mineplex community!",
registered ? ChatColor.GREEN + "" + ChatColor.BOLD + "You are registered for this tournament!" : " ",
ChatColor.GRAY + "Time: " + ChatColor.YELLOW + _tournamentStart.format(new Date(tournament.Date)),
ChatColor.GRAY + "Countdown: " + ChatColor.LIGHT_PURPLE + _tournamentCountdown.format(new Date(tournament.Date - System.currentTimeMillis()))
).build(), !registered ? new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
getPlugin().registerForTournament(player, tournament, new Runnable()
{
@Override
public void run()
{
buildPage();
}
});
}
} : null);
}
else
{
/*
if (i == currentDayOfMonth)
addItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE, i, (byte)5).setTitle("TODAY.").build());
else
*/
addItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE, i, (byte)14).setTitle(ChatColor.RESET + "" + ChatColor.BOLD + ChatColor.RED + "No Events").setLore
(
ChatColor.GRAY + "Sorry, there are no events",
ChatColor.GRAY + "on this particular date."
).build());
}
slot++;
}
}
}

View File

@ -0,0 +1,47 @@
package mineplex.core.incognito.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when an Incognito player is getting hidden from all other players.
*/
public class IncognitoHidePlayerEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private boolean _cancelled;
public IncognitoHidePlayerEvent(Player player)
{
_player = player;
}
public Player getPlayer()
{
return _player;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -1,13 +1,7 @@
package mineplex.game.clans; package mineplex.game.clans;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix; import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix; import mineplex.core.FoodDupeFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.AntiHack;
@ -19,6 +13,7 @@ import mineplex.core.common.Pair;
import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.delayedtask.DelayedTask; import mineplex.core.delayedtask.DelayedTask;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.explosion.Explosion; import mineplex.core.explosion.Explosion;
import mineplex.core.fallingblock.FallingBlocks; import mineplex.core.fallingblock.FallingBlocks;
import mineplex.core.friend.FriendManager; import mineplex.core.friend.FriendManager;
@ -56,6 +51,11 @@ import mineplex.game.clans.spawn.travel.TravelShop;
import mineplex.game.clans.world.WorldManager; import mineplex.game.clans.world.WorldManager;
import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
public class Clans extends JavaPlugin public class Clans extends JavaPlugin
{ {
public static final String VERSION = "Beta 1.0"; public static final String VERSION = "Beta 1.0";
@ -97,7 +97,11 @@ public class Clans extends JavaPlugin
new ServerConfiguration(this, _clientManager); new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); PacketHandler packetHandler = new PacketHandler(this);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
incognito.setPreferencesManager(preferenceManager);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
@ -109,9 +113,8 @@ public class Clans extends JavaPlugin
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
// ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
PacketHandler packetHandler = new PacketHandler(this);
Punish punish = new Punish(this, webServerAddress, _clientManager); Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false); AntiHack.Instance.setKick(false);
@ -120,10 +123,9 @@ public class Clans extends JavaPlugin
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
StatsManager statsManager = new StatsManager(this, _clientManager); StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); EloManager eloManager = new EloManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager, eloManager);
Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
@ -134,8 +136,8 @@ public class Clans extends JavaPlugin
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal); ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
resourcePackManager.setResourcePack(new Pair[] resourcePackManager.setResourcePack(new Pair[]
{ {
Pair.create(MinecraftVersion.Version1_8, "http://phinary.ca/ResClans.zip"), Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResClans.zip"),
Pair.create(MinecraftVersion.Version1_9, "http://phinary.ca/ResClans19.zip") Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResClans19.zip")
}, true); }, true);
// Enable custom-gear related managers // Enable custom-gear related managers
@ -143,7 +145,7 @@ public class Clans extends JavaPlugin
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
HologramManager hologram = new HologramManager(this, packetHandler); HologramManager hologram = new HologramManager(this, packetHandler);
_clansManager = new ClansManager(this, /*clansBans,*/ serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
new Recipes(this); new Recipes(this);
new Farming(this); new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager); new BuildingShop(_clansManager, _clientManager, _donationManager);

View File

@ -806,7 +806,7 @@ public class ClansDataAccessLayer
public void run() public void run()
{ {
ClanToken clan = _repository.retrieveClan(clanName); ClanToken clan = _repository.retrieveClan(clanName);
callback.run(clan); runSync(() -> callback.run(clan));
} }
}); });
} }

View File

@ -522,8 +522,7 @@ public class ClansGame extends MiniPlugin
ClanInfo clan = _clans.getClanUtility().getClanByPlayer(event.getPlayer()); ClanInfo clan = _clans.getClanUtility().getClanByPlayer(event.getPlayer());
if (clan == null) return; if (clan == null) return;
if(!clan.isOnline()) clan.setLastOnline(new Timestamp(System.currentTimeMillis())); //Noone else on clan.setLastOnline(new Timestamp(System.currentTimeMillis()));
else clan.setLastOnline(new Timestamp(0));
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)

View File

@ -12,12 +12,14 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
@ -28,6 +30,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -41,6 +44,7 @@ import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat; import mineplex.core.chat.Chat;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.events.PlayerMessageEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
@ -52,12 +56,12 @@ import mineplex.core.creature.Creature;
import mineplex.core.creature.event.CreatureSpawnCustomEvent; import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy; import mineplex.core.energy.Energy;
import mineplex.core.explosion.Explosion; import mineplex.core.explosion.Explosion;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.IncognitoManager;
import mineplex.core.incognito.events.IncognitoHidePlayerEvent;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.movement.Movement; import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager; import mineplex.core.npc.NpcManager;
@ -67,6 +71,7 @@ import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish; import mineplex.core.punish.Punish;
import mineplex.core.punish.PunishClient; import mineplex.core.punish.PunishClient;
import mineplex.core.recharge.Recharge;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport; import mineplex.core.teleport.Teleport;
@ -75,6 +80,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.Clans; import mineplex.game.clans.Clans;
import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ban.ClansBanManager;
import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClanManagementCommand;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand;
@ -99,7 +105,6 @@ import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.regions.ClansRegions;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.staff.SilentChestOpen;
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.war.WarManager;
@ -221,22 +226,22 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator;
/*private ClansBanManager _clansBans;*/ private ClansBanManager _clansBans;
public ClanTips ClanTips; public ClanTips ClanTips;
// Spawn area // Spawn area
public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
{ {
super("Clans Manager", plugin); super("Clans Manager", plugin);
_instance = this; _instance = this;
/*_clansBans = clansBans;*/ _clansBans = clansBans;
_punish = punish; _punish = punish;
_incognitoManager = new IncognitoManager(plugin, clientManager, packetHandler); _incognitoManager = incognitoManager;
_serverName = serverName; _serverName = serverName;
_clientManager = clientManager; _clientManager = clientManager;
_combatManager = new CombatManager(plugin); _combatManager = new CombatManager(plugin);
@ -296,8 +301,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new Field(plugin, creature, _condition, this, energy, serverName); new Field(plugin, creature, _condition, this, energy, serverName);
new SilentChestOpen(this);
// Required managers to be initialized // Required managers to be initialized
new Spawn(plugin, this); new Spawn(plugin, this);
new NPCManager(this, _hologramManager); new NPCManager(this, _hologramManager);
@ -333,7 +336,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler());
ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler()); ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler());
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager); EloManager eloManager = new EloManager(plugin, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager, eloManager);
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
@ -351,6 +355,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
loadClan(token); loadClan(token);
} }
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
// new ClaimVisualizer(plugin, this); // new ClaimVisualizer(plugin, this);
// RedisDataRepository(ConnectionData writeConn, ConnectionData // RedisDataRepository(ConnectionData writeConn, ConnectionData
@ -403,7 +410,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
hologram.start(); hologram.start();
} }
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
_siegeManager = new SiegeManager(this); _siegeManager = new SiegeManager(this);
// _netherManager = new NetherManager(this); // _netherManager = new NetherManager(this);
@ -599,21 +605,21 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{ {
event.setJoinMessage(null); event.setJoinMessage(null);
/*if (_clansBans.willBeKicked(event.getPlayer())) if (_clansBans.willBeKicked(event.getPlayer()))
{ {
return; return;
}*/ }
if (_incognitoManager.Get(event.getPlayer()).Status) if (_incognitoManager.Get(event.getPlayer()).Status)
{ {
return; return;
} }
/*_clansBans.runAfterLoad(event.getPlayer().getName(), () -> { _clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
if (_clansBans.Get(event.getPlayer().getName()).isBanned()) if (_clansBans.Get(event.getPlayer().getName()).isBanned())
{ {
return; return;
}*/ }
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
@ -625,7 +631,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
other.sendMessage(F.sys("Join", event.getPlayer().getName())); other.sendMessage(F.sys("Join", event.getPlayer().getName()));
} }
/*});*/ });
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -638,10 +644,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return; return;
} }
/*if (_clansBans.willBeKicked(event.getPlayer())) if (_clansBans.Get(event.getPlayer().getName()) != null && _clansBans.Get(event.getPlayer().getName()).isBanned())
{ {
return; return;
}*/ }
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
@ -651,7 +657,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
continue; continue;
} }
other.sendMessage(F.sys("Quit", event.getPlayer().getName())); other.sendMessage(F.sys("Quit ", event.getPlayer().getName()));
} }
} }
@ -664,12 +670,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return; return;
} }
/*if (_clansBans.willBeKicked(event.getPlayer())) if (_clansBans.willBeKicked(event.getPlayer()))
{ {
return; return;
}*/ }
if (event.getReason().contains("You are banned from Clans")) if (event.getReason().contains("banned from Clans"))
{ {
return; return;
} }
@ -849,7 +855,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{ {
if (clan == null) if (clan == null)
{ {
UtilServer.broadcast(String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), _chat.getFilteredMessage(event.getPlayer(), event.getMessage()))); for (Player other : event.getRecipients())
{
if (_tutorial.inTutorial(other))
continue;
UtilPlayer.message(other, String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage()));
}
return; return;
} }
@ -897,28 +909,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void handlePlayerChat(AsyncPlayerChatEvent event) public void handlePlayerChat(AsyncPlayerChatEvent event)
{ {
// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
//
// if (punishclient != null && punishclient.IsMuted())
// {
// return;
// }
//
// if (_chat.SilenceCheck(event.getPlayer()))
// {
// return;
// }
// MessageData lastMessage = _chat.lastMessage(event.getPlayer());
// long chatSlowTime = 1000L * _chat.getChatSlow();
// long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
// if (timeDiff < chatSlowTime && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
// {
//
// }
ClientClan client = Get(event.getPlayer()); ClientClan client = Get(event.getPlayer());
if (client == null) if (client == null)
@ -1298,17 +1288,23 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
} }
} }
@EventHandler
public void message(PlayerMessageEvent event)
{
if(!_tutorial.inTutorial(event.getPlayer()))
{
return;
}
if (event.getMessage().startsWith(C.cBlue + "Death>"))
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void handleClansDeath(PlayerDeathEvent event) public void handleClansDeath(PlayerDeathEvent event)
{ {
event.setDeathMessage(null);
for(Player player : UtilServer.getPlayers())
{
if(!_tutorial.inTutorial(player))
player.sendMessage(event.getDeathMessage());
}
PlayerClan playerClan; PlayerClan playerClan;
PlayerClan killerClan = null; PlayerClan killerClan = null;
@ -1339,6 +1335,41 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
} }
@EventHandler
public void disableHorses(VehicleEnterEvent event)
{
if (event.getEntered() instanceof Player && event.getVehicle() instanceof Horse)
{
if(!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false))
{
event.setCancelled(true);
}
}
}
@EventHandler
public void damageHorse(EntityDamageEvent event)
{
if (event.getEntity() instanceof Horse)
{
if (event.getEntity().getPassenger() != null && event.getEntity().getPassenger() instanceof Player)
{
event.getEntity().getPassenger().eject();
Recharge.Instance.use((Player) event.getEntity().getPassenger(), "Ride Horse", 2 * 20L, false, false);
}
event.getEntity().eject();
}
else if(event.getEntity() instanceof Player)
{
if(event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof Horse)
{
Recharge.Instance.use((Player) event.getEntity(), "Ride Horse", 2 * 20L, false, false);
event.getEntity().getVehicle().eject();
}
}
}
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time) public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
{ {
if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time) if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time)

View File

@ -6,6 +6,9 @@ import java.util.UUID;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
/**
* Stores the information about a ban in Clans.
*/
public class ClansBan public class ClansBan
{ {
private int _id; private int _id;
@ -90,4 +93,9 @@ public class ClansBan
{ {
return _uuid; return _uuid;
} }
public void remove()
{
_removed = true;
}
} }

View File

@ -0,0 +1,26 @@
package mineplex.game.clans.clans.ban;
/**
* Stores the data provided through the /cban (Clans ban) command for use further in the plugin.
*/
public class ClansBanCache
{
private String _victim;
private String _reason;
public ClansBanCache(String victim, String reason)
{
_victim = victim;
_reason = reason;
}
public String getVictim()
{
return _victim;
}
public String getReason()
{
return _reason;
}
}

View File

@ -1,17 +1,22 @@
package mineplex.game.clans.clans.ban; package mineplex.game.clans.clans.ban;
import java.util.List; import java.util.Set;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
/**
* Signifies a player on clans, and a Set of their current clan bans.
*/
public class ClansBanClient public class ClansBanClient
{ {
public String Name;
public String UUID; public String UUID;
public List<ClansBan> Bans; public Set<ClansBan> Bans;
public ClansBanClient(String uuid, List<ClansBan> bans) public ClansBanClient(String name, String uuid, Set<ClansBan> bans)
{ {
Name = name;
UUID = uuid; UUID = uuid;
Bans = bans; Bans = bans;
} }
@ -75,7 +80,7 @@ public class ClansBanClient
continue; continue;
} }
if (ban.getTimeLeft() > longest.getTimeLeft()) if (ban.getTimeLeft() > longest.getTimeLeft() || ban.isPermanent())
{ {
longest = ban; longest = ban;
} }

View File

@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -17,16 +16,15 @@ import org.bukkit.event.player.PlayerKickEvent;
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 com.google.common.collect.Lists;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor; import mineplex.core.account.ILoginProcessor;
import mineplex.core.common.DefaultHashMap; import mineplex.core.common.DefaultHashMap;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilStreams;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
@ -41,7 +39,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private ClansBanRepository _repository; private ClansBanRepository _repository;
private Map<String, ClansBanClient> _clients; private Map<String, ClansBanClient> _clients;
private Map<String, Pair<String, String>> _cache; private Map<String, ClansBanCache> _cache;
private DefaultHashMap<String, List<Runnable>> _runAfterLoad; private DefaultHashMap<String, List<Runnable>> _runAfterLoad;
private ClansBanShop _shop; private ClansBanShop _shop;
@ -55,7 +53,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
_clientManager = clientManager; _clientManager = clientManager;
_repository = new ClansBanRepository(plugin, this); _repository = new ClansBanRepository(plugin);
_clients = new HashMap<>(); _clients = new HashMap<>();
_cache = new HashMap<>(); _cache = new HashMap<>();
@ -85,29 +83,30 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
} }
player.kickPlayer(reason); player.kickPlayer(reason);
runSyncLater(() -> {
_toKick.remove(name);
}, 20l);
}); });
} }
if (!event.getType().equals(UpdateType.MIN_01)) if (event.getType().equals(UpdateType.MIN_01))
{ {
return; synchronized (_lock)
} {
UtilStreams.ToList(_clients.keySet().stream().filter(UtilServer::IsOnline)).forEach(this::UnloadClient);
synchronized (_lock) }
{
List<String> purge = Lists.newArrayList();
_clients.keySet().stream().filter(name -> Bukkit.getPlayer(name) == null).forEach(purge::add);
purge.forEach(this::UnloadClient);
} }
} }
public void ban(ClansBanClient client, String name, String admin, long time, String reason, Callback<ClansBanClient> callback) public void ban(ClansBanClient client, String admin, long time, String reason, Callback<ClansBanClient> callback)
{ {
_repository.ban(UUID.fromString(client.UUID), admin, time, reason, time == -1); runAsync(() -> {
_repository.ban(UUID.fromString(client.UUID), admin, time, reason, time == -1, ban -> {
LoadClient(name, callback); client.Bans.add(ban);
callback.run(client);
});
});
} }
public CoreClientManager getClientManager() public CoreClientManager getClientManager()
@ -154,21 +153,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
public void UnloadClient(ClansBanClient client) public void UnloadClient(ClansBanClient client)
{ {
synchronized (_lock) UnloadClient(client.Name);
{
String name = "";
for (Entry<String, ClansBanClient> entry : _clients.entrySet())
{
if (entry.getValue().equals(client))
{
name = entry.getKey();
break;
}
}
_clients.remove(name);
}
} }
public void UnloadClient(String name) public void UnloadClient(String name)
@ -179,17 +164,24 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
} }
} }
public void LoadClient(final String name, Callback<ClansBanClient> callback) public void LoadClient(String name, Callback<ClansBanClient> callback)
{ {
if (_clients.containsKey(name)) if (_clients.containsKey(name))
{
System.out.println("Clans Bans> Soft Warning: Loading client even though client is already loaded.");
_clients.remove(name); _clients.remove(name);
}
GetRepository().loadBans(name, client -> { GetRepository().loadClient(name, client -> {
synchronized (_lock) synchronized (_lock)
{ {
_clients.put(name, client); _clients.put(name.toLowerCase(), client);
System.out.println("> CLIENTS: " + _clients); System.out.println("> CLIENTS: " + _clients);
if (callback != null) callback.run(client);
if (callback != null)
{
callback.run(client);
}
} }
}); });
} }
@ -207,12 +199,12 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
return _shop; return _shop;
} }
public void cache(Player player, String playerName, String reason) public void cache(Player player, String victim, String reason)
{ {
_cache.put(player.getName(), Pair.create(playerName, reason)); _cache.put(player.getName(), new ClansBanCache(victim, reason));
} }
public Pair<String, String> getCachedData(Player player) public ClansBanCache getCachedData(Player player)
{ {
return _cache.get(player.getName()); return _cache.get(player.getName());
} }
@ -222,16 +214,17 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
_cache.remove(name); _cache.remove(name);
} }
public void unban(ClansBanClient target, ClansBan ban, String name, Callback<ClansBanClient> callback) public void unban(ClansBanClient target, ClansBan ban, Callback<ClansBanClient> callback)
{ {
if (!target.UUID.equals(ban.getUUID().toString())) if (!target.UUID.equals(ban.getUUID().toString()))
{ {
return; return;
} }
ban.remove();
_repository.removeBan(ban); _repository.removeBan(ban);
LoadClient(name, callback); callback.run(target);
} }
public boolean willBeKicked(Player player) public boolean willBeKicked(Player player)
@ -239,33 +232,27 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
return _toKick.containsKey(player.getName()); return _toKick.containsKey(player.getName());
} }
public void queueToKick(Player target, String reason)
{
_toKick.put(target.getName(), reason);
}
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{ {
_repository.loadBans(playerName, client -> { LoadClient(playerName, client -> {
if (client.isBanned()) if (client.isBanned())
{ {
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT); String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
if (client.getLongestBan().isPermanent()) if (client.getLongestBan().isPermanent())
{
time = "Permanent"; time = "Permanent";
}
String reason = C.cRedB + "You are banned from Clans for " + time + String reason = C.cRedB + "You are banned from Clans for " + time +
"\n" + C.cWhite + client.getLongestBan().getReason(); "\n" + C.cWhite + client.getLongestBan().getReason();
_toKick.put(playerName, reason); _toKick.put(playerName, reason);
ClansManager.getInstance().runSyncLater(() -> {
if (Bukkit.getPlayer(playerName) != null)
{
Bukkit.getPlayer(playerName).kickPlayer(_toKick.remove(playerName));
}
else
{
_runAfterLoad.get(playerName).forEach(Runnable::run);
_runAfterLoad.get(playerName).clear();
}
}, 5L);
} }
}); });
} }

View File

@ -1,14 +1,13 @@
package mineplex.game.clans.clans.ban; package mineplex.game.clans.clans.ban;
import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.Set;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.CoreClient; import com.google.common.collect.Sets;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.MinecraftRepository; import mineplex.core.database.MinecraftRepository;
@ -20,65 +19,44 @@ import mineplex.serverdata.database.column.ColumnVarChar;
public class ClansBanRepository extends MinecraftRepository public class ClansBanRepository extends MinecraftRepository
{ {
private ClansBanManager _manager;
private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);"; private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);";
private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;"; private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;";
private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;"; private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;";
public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager) public ClansBanRepository(JavaPlugin plugin)
{ {
super(plugin, DBPool.getAccount()); super(plugin, DBPool.getAccount());
_manager = manager;
} }
public void ban(UUID uuid, String admin, long time, String reason, boolean permanent) public void ban(UUID uuid, String admin, long time, String reason, boolean permanent, Callback<ClansBan> callback)
{ {
executeInsert(BAN_PLAYER, null, Timestamp banTime = new Timestamp(System.currentTimeMillis());
Timestamp unbanTime = new Timestamp(System.currentTimeMillis() + time);
executeInsert(BAN_PLAYER,
generatedKeys -> {
if (generatedKeys.next() && callback != null)
{
callback.run(new ClansBan(generatedKeys.getInt(1), uuid, admin, reason, banTime, unbanTime, permanent, false));
}
},
new ColumnVarChar("uuid", 36, uuid.toString()), new ColumnVarChar("uuid", 36, uuid.toString()),
new ColumnVarChar("admin", 16, admin), new ColumnVarChar("admin", 16, admin),
new ColumnVarChar("reason", 128, reason), new ColumnVarChar("reason", 128, reason),
new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())), new ColumnTimestamp("banTime", banTime),
new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)), new ColumnTimestamp("unbanTime", unbanTime),
new ColumnBoolean("permanent", permanent), new ColumnBoolean("permanent", permanent),
new ColumnBoolean("removed", false) new ColumnBoolean("removed", false)
); );
} }
public void loadBans(final String name, final Callback<ClansBanClient> callback) public void loadClient(String name, final Callback<ClansBanClient> callback)
{ {
loadClientByName(name, client -> { String uuid = UUIDFetcher.getUUIDOf(name).toString();
String uuid = UUIDFetcher.getUUIDOf(client.GetPlayerName()).toString();
executeQuery(GET_ALL_BANS, resultSet -> { executeQuery(GET_ALL_BANS, resultSet -> {
final List<ClansBan> list = new ArrayList<ClansBan>(); final Set<ClansBan> bans = Sets.newConcurrentHashSet();
while (resultSet.next())
{
int id = resultSet.getInt(1);
String ruuid = resultSet.getString(2);
String admin = resultSet.getString(3);
String reason = resultSet.getString(4);
Timestamp banTime = resultSet.getTimestamp(5);
Timestamp unbanTime = resultSet.getTimestamp(6);
boolean permanent = resultSet.getBoolean(7);
boolean removed = resultSet.getBoolean(8);
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
}
callback.run(new ClansBanClient(uuid, list));
}, new ColumnVarChar("uuid", 36, uuid));
});
}
public void loadBans(final String name, final String uuid, final ResultSet resultSet, final Callback<ClansBanClient> callback)
{
try
{
final List<ClansBan> list = new ArrayList<ClansBan>();
while (resultSet.next()) while (resultSet.next())
{ {
@ -91,32 +69,14 @@ public class ClansBanRepository extends MinecraftRepository
boolean permanent = resultSet.getBoolean(7); boolean permanent = resultSet.getBoolean(7);
boolean removed = resultSet.getBoolean(8); boolean removed = resultSet.getBoolean(8);
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed)); bans.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
System.out.println("Got ban for " + name);
} }
callback.run(new ClansBanClient(uuid, list)); if (callback != null)
{
System.out.println("> Successfully handled result"); callback.run(new ClansBanClient(name, uuid, bans));
System.out.println(">> FINISH"); }
} }, new ColumnVarChar("uuid", 36, uuid));
catch (Exception exception)
{
exception.printStackTrace();
}
}
private void loadClientByName(String name, Callback<CoreClient> client)
{
if (_manager.getClientManager().Contains(name))
{
client.run(_manager.getClientManager().Get(name));
}
else
{
_manager.getClientManager().loadClientByName(name, () -> client.run(_manager.getClientManager().Get(name)));
}
} }
@Override @Override

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