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

This commit is contained in:
William Burns 2016-04-28 18:19:45 +01:00
commit 5d1194192d
211 changed files with 10317 additions and 1804 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,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

@ -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()
{ {
try {
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); 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

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

View File

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

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

@ -0,0 +1,72 @@
package mineplex.core.elo;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.material.MaterialData;
public class EloDivision
{
private byte _divisionPercentile;
private int _playerElo;
private UUID _uuid;
private String _divisionName;
//If I understand MaterialData objects correctly,
private Material _divisionMaterial;
private byte _divisionMaterialValue;
private MaterialData _divisionMaterialData;
public EloDivision(UUID userID, byte divPercent, int pElo)
{
_uuid = userID;
_divisionPercentile = divPercent;
_playerElo = pElo;
_divisionName = calculateDivision(divPercent, _playerElo);
}
public String calculateDivision(double divPercent, int _playerElo)
{
if (divPercent > 99 && _playerElo > 3500) { return "Diamond"; }
if (_playerElo >= 3500) { return "Emerald 3"; }
if (_playerElo < 3500 && _playerElo >= 3300) { return "Emerald 2"; }
if (_playerElo < 3300 && _playerElo >= 3100) { return "Emerald 1"; }
if (_playerElo < 3100 && _playerElo >= 2900) { return "Lapis 3"; }
if (_playerElo < 2900 && _playerElo >= 2700) { return "Lapis 2"; }
if (_playerElo < 2700 && _playerElo >= 2500) { return "Lapis 1"; }
if (_playerElo < 2500 && _playerElo >= 2300) { return "Gold 3"; }
if (_playerElo < 2300 && _playerElo >= 2100) { return "Gold 2"; }
if (_playerElo < 2100 && _playerElo >= 1900) { return "Gold 1"; }
if (_playerElo < 1900 && _playerElo >= 1700) { return "Iron 3"; }
if (_playerElo < 1700 && _playerElo >= 1500) { return "Iron 2"; }
if (_playerElo < 1500 && _playerElo >= 1300) { return "Iron 1"; }
if (_playerElo < 1300 && _playerElo >= 800) { return "Coal 3"; }
if (_playerElo < 800 && _playerElo >= 600) { return "Coal 2"; }
if (_playerElo < 600) { return "Coal 1"; }
//if none of the above are true, a player is in the bottom 20%
return "Coal 1";
}
@SuppressWarnings("deprecation")
//method to set icon's material(since it will change with player's ELO)
public void setDivisionIcon(Material divMat, byte divData)
{
_divisionMaterial = divMat;
_divisionMaterialValue = divData;
_divisionMaterialData = new MaterialData(_divisionMaterial, _divisionMaterialValue);
}
public MaterialData getMaterialData()
{
return _divisionMaterialData;
}
public String getDivisionName()
{
return _divisionName;
}
}

View File

@ -2,71 +2,61 @@ 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 java.util.HashSet;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import org.bukkit.Bukkit; import org.bukkit.entity.Player;
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 EloRepository _repository;
private EloRatingSystem _ratingSystem; private EloRatingSystem _ratingSystem;
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos; private NautHashMap<String, EloTeam> _eloTeams = new NautHashMap<>();
public EloManager(JavaPlugin plugin, CoreClientManager clientManager) public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
{ {
super("Elo Rating", plugin, clientManager); super("Elo Rating", plugin, clientManager);
_repository = new EloRepository(plugin); _repository = new EloRepository(plugin);
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10)); _ratingSystem = new EloRatingSystem
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>(); (
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)
);
} }
public int getElo(UUID uuid, String gameType) public int getElo(Player player, int gameType)
{ {
int elo = 1000; if (!Get(player).Elos.containsKey(gameType))
return 1000;
synchronized (_playerEloLock) return Get(player).Elos.get(gameType);
{
if (_playerElos.containsKey(uuid.toString()))
{
if (_playerElos.get(uuid.toString()).containsKey(gameType))
{
elo = _playerElos.get(uuid.toString()).get(gameType);
}
}
}
return elo;
} }
public EloTeam getNewRatings(EloTeam teamA, EloTeam teamB, GameResult result) public EloTeam getNewRatings(EloTeam teamA, EloTeam teamB, GameResult result)
{ {
EloTeam newTeam = new EloTeam(); EloTeam newTeam = new EloTeam();
System.out.println("Old " + result + " Team Rating:" + teamA.TotalElo);
int newTotal = _ratingSystem.getNewRating(teamA.TotalElo / teamA.getPlayers().size(), teamB.TotalElo / teamB.getPlayers().size(), result) * teamA.getPlayers().size(); int newTotal = _ratingSystem.getNewRating(teamA.TotalElo / teamA.getPlayers().size(), teamB.TotalElo / teamB.getPlayers().size(), result) * teamA.getPlayers().size();
int kTotal = 0;
System.out.println("New " + result + " Team Rating:" + newTotal);
for (EloPlayer player : teamA.getPlayers()) for (EloPlayer player : teamA.getPlayers())
{ {
EloPlayer newPlayer = new EloPlayer(); kTotal += _ratingSystem.getKFactor(player.getRating());
newPlayer.UniqueId = player.UniqueId; }
newPlayer.Rating = (int)(player.Rating + ((double)player.Rating / (double)teamA.TotalElo) * (newTotal - teamA.TotalElo));
System.out.println("Old:"); for (EloPlayer player : teamA.getPlayers())
player.printInfo(); {
int newRating = (int)(player.getRating() + ((double)_ratingSystem.getKFactor(player.getRating()) / (double)kTotal) * (newTotal - teamA.TotalElo));
System.out.println("New:"); EloPlayer newPlayer = new EloPlayer(player.getPlayer(), player.getAccountId(), newRating);
newPlayer.printInfo();
newTeam.addPlayer(newPlayer); newTeam.addPlayer(newPlayer);
} }
@ -74,32 +64,84 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
return newTeam; return newTeam;
} }
public void saveElo(UUID uuid, String gameType, int elo) public void saveElo(final Player player, final int accountId, final int gameType, final int oldElo, final int elo)
{ {
saveElo(uuid.toString(), gameType, elo); runAsync(new Runnable()
}
public void saveElo(final String uuid, final String gameType, final int elo)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{ {
public void run() public void run()
{ {
_repository.saveElo(uuid, gameType, elo); boolean success = false;
synchronized (_playerEloLock) try
{ {
if (_playerElos.containsKey(uuid)) success = _repository.saveElo(accountId, gameType, oldElo, elo);
{
if (_playerElos.get(uuid).containsKey(gameType))
{
_playerElos.get(uuid).put(gameType, 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(new Runnable()
{
public void run()
{
if (finalSuccess)
{
if (player.isOnline())
Get(player).Elos.put(gameType, elo);
} }
} }
}); });
} }
});
}
public String getPlayerDivision(Player player, int gameType)
{
int playerElo = getElo(player, gameType);
String divisionName = "Player's division";
if (playerElo >= 3700)
divisionName = "Diamond";
else if (playerElo < 3700 && playerElo >= 3500)
divisionName = "Emerald 3";
else if (playerElo < 3500 && playerElo >= 3300)
divisionName = "Emerald 2";
else if (playerElo < 3300 && playerElo >= 3100)
divisionName = "Emerald 1";
else if (playerElo < 3100 && playerElo >= 2900)
divisionName = "Lapis 3";
else if (playerElo < 2900 && playerElo >= 2700)
divisionName = "Lapis 2";
else if (playerElo < 2700 && playerElo >= 2500)
divisionName = "Lapis 1";
else if (playerElo < 2500 && playerElo >= 2300)
divisionName = "Gold 3";
else if (playerElo < 2300 && playerElo >= 2100)
divisionName = "Gold 2";
else if (playerElo < 2100 && playerElo >= 1900)
divisionName = "Gold 1";
else if (playerElo < 1900 && playerElo >= 1700)
divisionName = "Iron 3";
else if (playerElo < 1700 && playerElo >= 1500)
divisionName = "Iron 2";
else if (playerElo < 1500 && playerElo >= 1300)
divisionName = "Iron 1";
else if (playerElo < 1300 && playerElo >= 1100)
divisionName = "Coal 3";
else if (playerElo < 1100 && playerElo >= 900)
divisionName = "Coal 2";
else if (playerElo < 900)
divisionName = "Coal 1";
return divisionName;
}
@Override @Override
protected EloClientData AddPlayer(String player) protected EloClientData AddPlayer(String player)
@ -116,6 +158,58 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
@Override @Override
public String getQuery(int accountId, String uuid, String name) public String getQuery(int accountId, String uuid, String name)
{ {
return "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';"; 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;
}
public void endMatch(int gameId)
{
EloTeam teamWinner = null;
EloTeam teamLoser = null;
for (EloTeam team : _eloTeams.values())
{
if (team.Winner)
teamWinner = team;
else
teamLoser = team;
}
EloTeam teamWinnerNew = getNewRatings(teamWinner, teamLoser, GameResult.Win);
EloTeam teamLoserNew = getNewRatings(teamLoser, teamWinner, GameResult.Loss);
// Use teams to calculate Elo
for (EloPlayer eloPlayer : teamWinnerNew.getPlayers())
{
int oldElo = teamWinner.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating();
// If this is the first time.
if (!Get(eloPlayer.getPlayer()).Elos.containsKey(gameId))
oldElo = eloPlayer.getRating();
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, oldElo, eloPlayer.getRating());
}
for (EloPlayer eloPlayer : teamLoserNew.getPlayers())
{
int oldElo = teamLoser.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating();
// If this is the first time.
if (!Get(eloPlayer.getPlayer()).Elos.containsKey(gameId))
oldElo = eloPlayer.getRating();
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, oldElo, eloPlayer.getRating());
}
_eloTeams.clear();
} }
} }

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

@ -4,17 +4,16 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
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 org.bukkit.plugin.java.JavaPlugin;
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 (accountId, gameType, elo) VALUES (?, ?, ?);";
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);"; private static String UPDATE_ELO = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ?;";
private static String UPDATE_ELO_ONLY_IF_MATCH = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ? AND elo = ?;";
public EloRepository(JavaPlugin plugin) public EloRepository(JavaPlugin plugin)
{ {
@ -23,14 +22,26 @@ public class EloRepository extends MinecraftRepository
initialize(); initialize();
} }
public void initialize() public void initialize() { }
public boolean saveElo(int accountId, int gameType, int oldElo, int elo) throws SQLException
{ {
//executeUpdate(CREATE_ELO_TABLE); boolean updateSucceeded = false;
// 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.
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;
if (!updateSucceeded && executeUpdate(INSERT_ELO, new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", elo)) > 0)
updateSucceeded = true;
} }
public void saveElo(String uuid, String gameType, int elo)
{ return updateSucceeded;
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 EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
@ -39,7 +50,7 @@ public class EloRepository extends MinecraftRepository
while (resultSet.next()) while (resultSet.next())
{ {
clientData.Elos.put(resultSet.getString(1), resultSet.getInt(2)); clientData.Elos.put(resultSet.getInt(1), resultSet.getInt(2));
} }
return clientData; return clientData;

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

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

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

@ -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));
@ -111,7 +115,6 @@ public class Clans extends JavaPlugin
// 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,8 +123,6 @@ 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); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
@ -143,7 +144,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

@ -9,15 +9,19 @@ import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.UUID; import java.util.UUID;
import mineplex.core.recharge.Recharge;
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.entity.Vehicle;
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 +32,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;
@ -57,7 +62,6 @@ 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;
@ -99,7 +103,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;
@ -227,7 +230,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// 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);
@ -236,7 +239,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
/*_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 +299,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);
@ -1339,6 +1340,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

@ -1,5 +1,6 @@
package mineplex.game.clans.clans.commands; package mineplex.game.clans.clans.commands;
import mineplex.game.clans.clans.ClansManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
@ -23,6 +24,11 @@ public class KillCommand extends CommandBase<DamageManager>
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat.")); UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat."));
return; return;
} }
if(ClansManager.getInstance().getTutorial().inTutorial(caller))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial."));
return;
}
UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); UtilPlayer.message(caller, F.main("Clans", "You have imploded."));

View File

@ -112,6 +112,7 @@ public class SiegeManager extends MiniPlugin
if (!part) if (!part)
{ {
System.out.println("Removing slime...");
slime.remove(); slime.remove();
} }
else else
@ -162,11 +163,13 @@ public class SiegeManager extends MiniPlugin
{ {
if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().getType().equals(Material.SPONGE)) if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().getType().equals(Material.SPONGE))
{ {
System.out.println("Removing armor stand");
entity.remove(); entity.remove();
} }
if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime) if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime)
{ {
System.out.println("Removing armostand + children");
entity.getPassenger().getPassenger().remove(); entity.getPassenger().getPassenger().remove();
entity.getPassenger().remove(); entity.getPassenger().remove();
entity.remove(); entity.remove();

View File

@ -126,7 +126,6 @@ public class SiegeWeaponRepository extends MinecraftRepository
token.Health = columns.getShort("health"); token.Health = columns.getShort("health");
token.Yaw = columns.getShort("yaw"); token.Yaw = columns.getShort("yaw");
token.LastFired = columns.getTimestamp("lastFired").getTime(); token.LastFired = columns.getTimestamp("lastFired").getTime();
token.Entities = decodeEntities(columns.getString("entities"));
System.out.println("Siege Repo> Loaded weapon " + token.UniqueId); System.out.println("Siege Repo> Loaded weapon " + token.UniqueId);
} }
@ -158,47 +157,14 @@ public class SiegeWeaponRepository extends MinecraftRepository
new ColumnInt("health", token.Health), new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw), new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)), new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnVarChar("entities", 100, encodeEntities(token.Entities))) new ColumnVarChar("entities", 100, ""))
); );
} }
private String encodeEntities(Map<String, String> entities)
{
StringBuilder builder = new StringBuilder();
int l = 0;
for (String name : entities.keySet())
{
if (l != 0)
{
builder.append(",");
}
builder.append(name + ":" + entities.get(name));
l++;
}
return builder.toString();
}
private Map<String, String> decodeEntities(String data)
{
Map<String, String> map = new HashMap<>();
for (String entries : data.split(","))
{
map.put(entries.split(":")[0], entries.split(":")[1]);
}
return map;
}
@Override @Override
protected void initialize() protected void initialize()
{ {
_siegeManager.runAsync(() -> executeUpdate(CREATE);
executeUpdate(CREATE)
);
} }
@Override @Override

View File

@ -16,6 +16,5 @@ public class SiegeWeaponToken
public int Health; public int Health;
public int Yaw; public int Yaw;
public long LastFired; public long LastFired;
public Map<String, String> Entities;
} }

View File

@ -1,8 +1,6 @@
package mineplex.game.clans.clans.siege.weapon; package mineplex.game.clans.clans.siege.weapon;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Map.Entry;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -39,7 +37,6 @@ import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile; import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule; import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType; import mineplex.game.clans.clans.siege.weapon.util.AccessType;
@ -55,6 +52,13 @@ public class Cannon extends SiegeWeapon
{ {
super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager); super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager);
if (_ownerClan == null)
{
System.out.println("[cannon] owner clan null, killing");
kill();
return;
}
System.out.println("Siege> Loading Cannon from token " + token.UniqueId); System.out.println("Siege> Loading Cannon from token " + token.UniqueId);
setBoundingBox(1); setBoundingBox(1);
@ -69,8 +73,6 @@ public class Cannon extends SiegeWeapon
_baseDamage = 650; _baseDamage = 650;
setProjectileAttributes(new ProjectileAttributes().setPrimedTnt().setDoCrater().craterSize(3).craterChanceOfAir(2.d));
setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> { setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> {
if (!isRiding(player)) if (!isRiding(player))
{ {
@ -107,11 +109,11 @@ public class Cannon extends SiegeWeapon
enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider())));
setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { setRideable(new AccessRule(AccessType.RCLICK_BB, player -> {
// if (!_ownerClan.isMember(player)) if (!_ownerClan.isMember(player))
// { {
// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan."));
// return false; return false;
// } }
if (getRider() != null && !getRider().equals(player)) if (getRider() != null && !getRider().equals(player))
{ {
@ -140,7 +142,7 @@ public class Cannon extends SiegeWeapon
setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1)); setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1));
setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0)); setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0));
loadEntities(); loadEntities(true);
setFirepowerType(Material.SULPHUR); setFirepowerType(Material.SULPHUR);
setAmmunitionType(Material.TNT); setAmmunitionType(Material.TNT);
@ -153,8 +155,6 @@ public class Cannon extends SiegeWeapon
_baseDamage = 650; _baseDamage = 650;
setProjectileAttributes(new ProjectileAttributes().setPrimedTnt().setDoCrater().craterSize(3).craterChanceOfAir(2.d));
setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> { setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> {
if (!isRiding(player)) if (!isRiding(player))
{ {
@ -179,9 +179,9 @@ public class Cannon extends SiegeWeapon
return false; return false;
} }
if (System.currentTimeMillis() - _lastFired < 20000) if (System.currentTimeMillis() - _lastFired < 30000)
{ {
UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(20000 - (System.currentTimeMillis() - _lastFired))) + ")")); UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(30000 - (System.currentTimeMillis() - _lastFired))) + ")"));
return false; return false;
} }
@ -191,11 +191,11 @@ public class Cannon extends SiegeWeapon
enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider())));
setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { setRideable(new AccessRule(AccessType.RCLICK_BB, player -> {
// if (!_ownerClan.isMember(player)) if (!_ownerClan.isMember(player))
// { {
// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan."));
// return false; return false;
// } }
if (getRider() != null && !getRider().equals(player)) if (getRider() != null && !getRider().equals(player))
{ {
@ -298,7 +298,7 @@ public class Cannon extends SiegeWeapon
return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2; return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2;
} }
private void loadEntities() private void loadEntities(boolean insert)
{ {
Slime filler = _location.getWorld().spawn(_location.clone(), Slime.class); Slime filler = _location.getWorld().spawn(_location.clone(), Slime.class);
@ -332,38 +332,35 @@ public class Cannon extends SiegeWeapon
addEntity(weapon, "WEAPON"); addEntity(weapon, "WEAPON");
if (insert)
{
insert(); insert();
} }
}
@Override @Override
public void FindEntities() public void FindEntities()
{ {
Lists.newArrayList(_location.getWorld().getEntities()) Lists.newArrayList(_location.getWorld().getEntities())
.forEach(entity -> { .forEach(entity -> {
for (Entry<String, String> entry : _loadedToken.Entities.entrySet()) if (Integer.toString(_uniqueId).equals(entity.getCustomName()))
{ {
if (entity.getUniqueId().toString().equals(entry.getValue())) entity.remove();
{
addEntity(entity, entry.getKey());
}
} }
}); });
if (getEntity("WEAPON") == null || getEntity("Filler_1") == null || getEntity("PLAYERMOUNT") == null) loadEntities(false);
{
System.out.println("[Cannon] Could not find all entities, killing.");
kill();
}
} }
@Override @Override
public void CustomFire(WeaponProjectile projectile) protected WeaponProjectile CustomFire(double yawRot, double verticalVel, double horizontalVel)
{ {
projectile.setLocation(projectile.getLocation().add(.0, .2, .0)); Location location = UtilAlg.moveForward(new Location(_location.getWorld(), _location.getX(), _location.getY() + .2, _location.getZ(), (float) yawRot, (float) 0), 0.35, (float) yawRot, false);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, projectile.getLocation(), new Vector(0, 0, 0), .1f, 2, ViewDist.MAX); UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, location, new Vector(0, 0, 0), .1f, 2, ViewDist.MAX);
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(projectile.getLocation(), Sound.EXPLODE, 1.f, 1.f)); UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(location, Sound.EXPLODE, 1.f, 1.f));
return new TntProjectile(this, location, yawRot, verticalVel, horizontalVel);
} }
@Override @Override
@ -428,12 +425,12 @@ public class Cannon extends SiegeWeapon
@EventHandler @EventHandler
public void explosionEffects(SiegeWeaponExplodeEvent event) public void explosionEffects(SiegeWeaponExplodeEvent event)
{ {
for (int i = 0; i < 8; i++) // for (int i = 0; i < 8; i++)
{ // {
// Explosion particle effects. // // Explosion particle effects.
Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5); // Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX); // UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX);
} // }
// Block explosion. // Block explosion.
ArrayList<Block> blocks = new ArrayList<>(); ArrayList<Block> blocks = new ArrayList<>();
@ -441,6 +438,12 @@ public class Cannon extends SiegeWeapon
while (blocks.size() < 10 && (attempts < 30)) while (blocks.size() < 10 && (attempts < 30))
{ {
Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock(); Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock();
if (_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()) != null && !_siegeManager.getClansManager().getBlacklist().allowed(_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()).Owner))
{
continue;
}
if ((block.getType() != Material.AIR) && (!blocks.contains(block))) if ((block.getType() != Material.AIR) && (!blocks.contains(block)))
{ {
blocks.add(block); blocks.add(block);
@ -449,9 +452,10 @@ public class Cannon extends SiegeWeapon
attempts++; attempts++;
} }
_siegeManager.getClansManager().getExplosion().BlockExplosion( _clans.getExplosion().BlockExplosion(
blocks, blocks,
event.getProjectile().getLocation(), event.getProjectile().getLocation(),
false,
false false
); );
} }

View File

@ -1,6 +1,5 @@
package mineplex.game.clans.clans.siege.weapon; package mineplex.game.clans.clans.siege.weapon;
import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -49,12 +48,12 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanDeleteEvent;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.events.LoadSiegeWeaponEvent; import mineplex.game.clans.clans.siege.events.LoadSiegeWeaponEvent;
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent; import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile; import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule; import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType; import mineplex.game.clans.clans.siege.weapon.util.AccessType;
@ -138,7 +137,6 @@ public abstract class SiegeWeapon implements Listener
protected int _baseDamage; protected int _baseDamage;
protected ProjectileAttributes _projectileAttributes;
protected WeaponProjectile _projectile; protected WeaponProjectile _projectile;
public SiegeWeapon(int maxHealth, String name, SiegeWeaponToken token, ClansManager clansManager, SiegeManager siegeManager) public SiegeWeapon(int maxHealth, String name, SiegeWeaponToken token, ClansManager clansManager, SiegeManager siegeManager)
@ -328,7 +326,7 @@ public abstract class SiegeWeapon implements Listener
_inventory.clear(); _inventory.clear();
CustomFire(_projectile = new WeaponProjectile(this, _location.clone().add(.5, 0, .5), _projectileAttributes, ((ArmorStand) getEntity("WEAPON")).getHeadPose().getY(), vel[0], vel[1])); _projectile = CustomFire(((ArmorStand) getEntity("WEAPON")).getHeadPose().getY(), vel[0], vel[1]);
} }
protected void setFireRule(AccessRule rule) protected void setFireRule(AccessRule rule)
@ -366,11 +364,6 @@ public abstract class SiegeWeapon implements Listener
_maxAmmunition = maxAmmunition; _maxAmmunition = maxAmmunition;
} }
protected void setProjectileAttributes(ProjectileAttributes projectileAttributes)
{
_projectileAttributes = projectileAttributes;
}
protected boolean isRiding(Player player) protected boolean isRiding(Player player)
{ {
return player.equals(getRider()); return player.equals(getRider());
@ -523,19 +516,22 @@ public abstract class SiegeWeapon implements Listener
protected abstract double[] GetProjectileVelocity(); protected abstract double[] GetProjectileVelocity();
protected abstract String GetNextState(); protected abstract String GetNextState();
protected abstract void FindEntities(); protected abstract void FindEntities();
protected abstract WeaponProjectile CustomFire(double yawRot, double verticalVel, double horizontalVel);
protected void CustomTick() { return; } protected void CustomTick() { return; }
protected void CustomOnMount(Player player) { return; } protected void CustomOnMount(Player player) { return; }
protected void CustomLeftClick(Player player) { return; } protected void CustomLeftClick(Player player) { return; }
protected void CustomRightClick(Player player) { return; } protected void CustomRightClick(Player player) { return; }
protected void CustomCleanup() { return; } protected void CustomCleanup() { return; }
protected void CustomUpdateState(String state) { return; } protected void CustomUpdateState(String state) { return; }
protected void CustomFire(WeaponProjectile projectile) { return; }
protected double CustomRotate(double yaw) { return yaw; } protected double CustomRotate(double yaw) { return yaw; }
protected boolean CustomDismount(Player player, Entity entity) { return false; } protected boolean CustomDismount(Player player, Entity entity) { return false; }
protected boolean CustomMount(Player player) { return false; } protected boolean CustomMount(Player player) { return false; }
protected final void addEntity(Entity entity, String uniqueName) protected final void addEntity(Entity entity, String uniqueName)
{ {
entity.setCustomName(Integer.toString(_uniqueId));
entity.setCustomNameVisible(false);
_comprisedOf.add(entity); _comprisedOf.add(entity);
_entityMapping.put(uniqueName, entity); _entityMapping.put(uniqueName, entity);
@ -691,6 +687,16 @@ public abstract class SiegeWeapon implements Listener
} }
} }
@EventHandler
public void clanDelete(ClanDeleteEvent event)
{
if (event.getClanInfo().getName().equals(_ownerClan.getName()))
{
System.out.println("Killing Siege weapon " + _uniqueId + " because owner clan has been deleted.");
kill();
}
}
@EventHandler @EventHandler
public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event) public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event)
{ {
@ -942,18 +948,11 @@ public abstract class SiegeWeapon implements Listener
token.Location = _location; token.Location = _location;
token.Health = _health; token.Health = _health;
token.Yaw = (int) _yaw; token.Yaw = (int) _yaw;
token.Entities = new HashMap<>();
_entityMapping.entrySet().forEach(entry ->
token.Entities.put(entry.getKey(), entry.getValue().getUniqueId().toString())
);
return token; return token;
} }
public boolean isPartOf(UUID uniqueId) public boolean isPartOf(UUID uniqueId)
{
if (_loadedToken == null)
{ {
for (Entity entity : _comprisedOf) for (Entity entity : _comprisedOf)
{ {
@ -964,9 +963,6 @@ public abstract class SiegeWeapon implements Listener
return false; return false;
} }
return _loadedToken.Entities.values().contains(uniqueId.toString());
}
public void setInvincible(boolean invincible) public void setInvincible(boolean invincible)
{ {
_invincible = invincible; _invincible = invincible;

View File

@ -0,0 +1,63 @@
package mineplex.game.clans.clans.siege.weapon;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
public class TntProjectile extends WeaponProjectile
{
public TntProjectile(SiegeWeapon weapon, Location origin, double yawRot, double yVel, double xMulti)
{
super(weapon, origin, yawRot, yVel, xMulti);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onTntExplode(EntityExplodeEvent event)
{
if (event.getEntity().equals(_projectileEntity))
{
((TNTPrimed) event.getEntity()).setFuseTicks(60);
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onTntExplode(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
((TNTPrimed) _projectileEntity).setFuseTicks(60);
}
@Override
public Entity spawn()
{
TNTPrimed tnt = _origin.getWorld().spawn(_origin, TNTPrimed.class);
Vector velocity = UtilAlg.getTrajectory(
_origin,
UtilAlg.moveForward(
_origin,
2.,
(float) Math.toDegrees(_yawRot), false))
.multiply(_xMulti)
.setY(_yVel);
tnt.setVelocity(velocity);
return tnt;
}
}

View File

@ -26,9 +26,9 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.nameblacklist.ClansBlacklist;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.Explosion;
public class Crater implements Listener public class Crater implements Listener
{ {
@ -39,14 +39,9 @@ public class Crater implements Listener
private final long _birthTime; private final long _birthTime;
private final int _size;
private final double _airChance;
private final boolean _fire;
private final List<CraterBlock> _blocks; private final List<CraterBlock> _blocks;
public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin, int size, double airChance, boolean doFire) public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin)
{ {
_weapon = weapon; _weapon = weapon;
_origin = origin; _origin = origin;
@ -54,10 +49,6 @@ public class Crater implements Listener
_birthTime = System.currentTimeMillis(); _birthTime = System.currentTimeMillis();
_blocks = new ArrayList<>(); _blocks = new ArrayList<>();
_size = size;
_airChance = airChance;
_fire = doFire;
UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin()); UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin());
createExplosion(); createExplosion();
@ -108,124 +99,57 @@ public class Crater implements Listener
return; return;
} }
_blocks.add(new CraterBlock(_origin, 0, Material.AIR)); boolean explosion = _origin.getWorld().createExplosion(_origin, 2.6f);
HashMap<Block, Double> blockList = new HashMap<Block, Double>(); boolean floating = _origin.distance(UtilBlock.nearestFloor(_origin)) > 0.6;
int iR = (int) _size + 1;
for (int x = -iR; x <= iR; x++) if (explosion)
{ {
for (int z = -iR; z <= iR; z++) for (Block block : UtilBlock.getInRadius(_origin.getBlock(), 2.6f).keySet())
{ {
for (int y = -iR; y <= iR; y++) boolean charred = false;
double dist = block.getLocation().distance(_origin);
if (floating)
{ {
Block curBlock = _origin.getBlock().getRelative(x, y, z); if (!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
&& !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
double offset = UtilMath.offset(_origin, curBlock.getLocation()); && Math.random() > 0.79)
if (offset <= _size)
{ {
blockList.put(curBlock, Double.valueOf(offset)); charred = true;
} }
} }
} else
}
for (Entry<Block, Double> entry : blockList.entrySet())
{ {
Block block = entry.getKey(); if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR)
&& !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation()); && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
&& Math.random() > 0.79)
if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner))
{ {
continue; charred = true;
}
} }
double distance = entry.getValue().doubleValue(); if (block.getType().equals(Material.SMOOTH_BRICK))
boolean air = distance <= _airChance || (Math.random() > (distance) / 3.65d);
if (block.getState() instanceof Chest) continue;
if (block.getType() == Material.AIR) continue;
if (air)
{ {
_blocks.add(new CraterBlock(block.getLocation(), distance, Material.AIR)); charred = false;
}
Block above = block; if (block.getType().equals(Material.BEDROCK))
while (!UtilItem.isBoundless((above = above.getRelative(BlockFace.UP)).getType()))
{ {
_blocks.add(new CraterBlock(above.getLocation(), distance, Material.AIR)); charred = false;
} }
if (!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType())) if (charred)
{ {
if (_fire && Math.random() >= .5) CraterBlock charredBlock = new CraterBlock(block.getLocation(), dist, CHARRED_TYPE, (byte) 0);
{
_blocks.add(new CraterBlock(block.getLocation(), distance, Material.FIRE)); charredBlock.set();
_blocks.add(charredBlock);
} }
} }
} }
} }
_blocks.forEach(CraterBlock::set);
for (Entry<Block, Double> entry : blockList.entrySet())
{
Block block = entry.getKey();
ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation());
if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner))
{
continue;
}
double distance = entry.getValue().doubleValue();
if (block.getType() == Material.AIR) continue;
if (block.getState() instanceof Chest)
{
Chest chest = (Chest) block.getState();
for (ItemStack item : chest.getBlockInventory().getContents())
{
if (item == null)
{
continue;
}
if (item.getType() == Material.AIR)
{
continue;
}
_origin.getWorld().dropItemNaturally(_origin, item);
}
}
if (
distance > _airChance &&
Math.random() > .75 &&
UtilItem.isBoundless(block.getRelative(BlockFace.UP).getType()) &&
!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()) &&
!block.getRelative(BlockFace.UP).getType().equals(CHARRED_TYPE) &&
!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE))
{
_blocks.add(new CraterBlock(block.getLocation(), distance, CHARRED_TYPE));
if (_fire)
{
_blocks.add(new CraterBlock(block.getRelative(BlockFace.UP).getLocation(), distance, Material.FIRE));
}
}
}
_blocks.forEach(CraterBlock::set);
}
} }

View File

@ -1,75 +0,0 @@
package mineplex.game.clans.clans.siege.weapon.projectile;
import org.bukkit.Material;
public class ProjectileAttributes
{
protected boolean _isFallingBlock;
protected Material _fallingBlockType;
protected byte _fallingBlockData;
protected boolean _isPrimedTnt;
protected boolean _doCrater;
protected int _craterSize;
protected double _craterChanceOfAir;
protected boolean _craterDoFire;
public ProjectileAttributes setFallingBlock()
{
_isFallingBlock = true;
return this;
}
public ProjectileAttributes setFallingBlockType(Material type)
{
_fallingBlockType = type;
return this;
}
public ProjectileAttributes setFallingBlockData(byte data)
{
_fallingBlockData = data;
return this;
}
public ProjectileAttributes setPrimedTnt()
{
_isPrimedTnt = true;
return this;
}
public ProjectileAttributes setDoCrater()
{
_doCrater = true;
return this;
}
public ProjectileAttributes craterSize(int size)
{
_craterSize = size;
return this;
}
public ProjectileAttributes craterDoFire(boolean doFire)
{
_craterDoFire = doFire;
return this;
}
public ProjectileAttributes craterChanceOfAir(double chance)
{
_craterChanceOfAir = chance;
return this;
}
}

View File

@ -23,55 +23,33 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
public class WeaponProjectile implements Listener public abstract class WeaponProjectile implements Listener
{ {
private ProjectileAttributes _attributes; protected Location _origin;
private Location _origin; protected Entity _projectileEntity;
private Entity _projectileEntity;
private SiegeWeapon _weapon; protected SiegeWeapon _weapon;
private double _yRot; protected double _yawRot;
private double _xMulti; protected double _xMulti;
private double _yVel; protected double _yVel;
private boolean _dead; protected boolean _dead;
private Player _shooter; protected Player _shooter;
public WeaponProjectile(SiegeWeapon weapon, Location origin, ProjectileAttributes attributes, double yRot, double yVel, double xMulti) public WeaponProjectile(SiegeWeapon weapon, Location origin, double yawRot, double yVel, double xMulti)
{ {
_shooter = weapon.getRider(); _shooter = weapon.getRider();
_weapon = weapon; _weapon = weapon;
_origin = origin; _origin = origin;
_attributes = attributes; _yawRot = yawRot;
_yRot = yRot;
_yVel = yVel; _yVel = yVel;
_xMulti = xMulti; _xMulti = xMulti;
UtilServer.getPluginManager().registerEvents(this, weapon.getClans().getPlugin()); UtilServer.getPluginManager().registerEvents(this, weapon.getClans().getPlugin());
spawn(); _projectileEntity = spawn();
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onTntExplode(EntityExplodeEvent event)
{
if (event.getEntity().equals(_projectileEntity))
{
((TNTPrimed) event.getEntity()).setFuseTicks(60);
event.setCancelled(true);
}
}
@EventHandler
public void onBlockFall(EntityChangeBlockEvent event)
{
if (!_dead && event.getEntity().equals(_projectileEntity))
{
die();
event.setCancelled(true);
}
} }
@EventHandler @EventHandler
@ -82,38 +60,29 @@ public class WeaponProjectile implements Listener
return; return;
} }
if (_projectileEntity.isDead()) if (_projectileEntity == null || _projectileEntity.isDead())
{ {
die(); die();
return; return;
} }
if (_dead || _projectileEntity == null) if (_projectileEntity.getTicksLived() <= 10)
{ {
die();
return; return;
} }
((TNTPrimed) _projectileEntity).setFuseTicks(60); boolean moving = Math.abs(_projectileEntity.getVelocity().getX()) > 0.01 || Math.abs(_projectileEntity.getVelocity().getZ()) > 0.01;
if ((Math.abs(_projectileEntity.getVelocity().getX()) < 0.01 // Some rough collision detection. Not perfect, but the best I could conjure up myself.
|| Math.abs(_projectileEntity.getVelocity().getZ()) < 0.01) if (!moving && !UtilBlock.boundless(_projectileEntity.getLocation(), 2))
&& UtilBlock.getInRadius(_projectileEntity.getLocation(), 2)
.keySet()
.stream()
.filter(block -> !UtilItem.isBoundless(block.getType()))
.iterator().hasNext() && _projectileEntity.getTicksLived() >= 10)
{ {
SiegeWeaponExplodeEvent newEvent = new SiegeWeaponExplodeEvent(_weapon, this); SiegeWeaponExplodeEvent newEvent = UtilServer.CallEvent(new SiegeWeaponExplodeEvent(_weapon, this));
UtilServer.CallEvent(newEvent);
if (!newEvent.isCancelled()) if (!newEvent.isCancelled())
{ {
new Crater(_weapon, this, _projectileEntity.getLocation(), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire); new Crater(_weapon, this, _projectileEntity.getLocation());
}
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f)); UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f));
}
die(); die();
} }
@ -147,48 +116,7 @@ public class WeaponProjectile implements Listener
_dead = true; _dead = true;
} }
private void spawn() public abstract Entity spawn();
{
if (_attributes._isFallingBlock)
{
FallingBlock fallingBlock = _origin.getWorld().spawnFallingBlock(_origin, _attributes._fallingBlockType, _attributes._fallingBlockData);
_projectileEntity = fallingBlock;
Vector velocity = UtilAlg.getTrajectory(
_origin,
UtilAlg.moveForward(
_origin,
2.,
(float) Math.toDegrees(_yRot), false))
.multiply(_xMulti)
.setY(_yVel);
fallingBlock.setVelocity(velocity);
}
else if (_attributes._isPrimedTnt)
{
TNTPrimed tnt = _origin.getWorld().spawn(_origin, TNTPrimed.class);
_projectileEntity = tnt;
Vector velocity = UtilAlg.getTrajectory(
_origin,
UtilAlg.moveForward(
_origin,
2.,
(float) Math.toDegrees(_yRot), false))
.multiply(_xMulti)
.setY(_yVel);
tnt.setVelocity(velocity);
}
}
public int getCraterSize()
{
return _attributes._craterSize;
}
public Player getShooter() public Player getShooter()
{ {

View File

@ -1,37 +0,0 @@
package mineplex.game.clans.clans.staff;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import mineplex.core.common.util.UtilServer;
public class SilentChestInventory implements Listener
{
private Chest _chest;
private Inventory _inventory;
private Player _viewer;
public SilentChestInventory(Chest chest, Player viewer)
{
_chest = chest;
viewer.openInventory(_chest.getBlockInventory());
UtilServer.RegisterEvents(this);
}
@EventHandler
public void closeInventory(InventoryCloseEvent event)
{
if (event.getInventory().equals(_inventory) && event.getPlayer().equals(_viewer))
{
UtilServer.Unregister(this);
}
}
}

View File

@ -1,49 +0,0 @@
package mineplex.game.clans.clans.staff;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilServer;
import mineplex.core.incognito.IncognitoManager;
import mineplex.game.clans.clans.ClansManager;
public class SilentChestOpen extends MiniPlugin
{
private ClansManager _clansManager;
public SilentChestOpen(ClansManager clansManager)
{
super("Silent Chest", clansManager.getPlugin());
_clansManager = clansManager;
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status)
return;
if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.CMOD))
return;
if (event.getClickedBlock() == null)
return;
BlockState block = event.getClickedBlock().getState();
if (!(block instanceof Chest))
return;
Chest chest = (Chest) block;
UtilServer.RegisterEvents(new SilentChestInventory(chest, event.getPlayer()));
event.setCancelled(true);
}
}

View File

@ -52,9 +52,15 @@ public class EventTerrainFinder
loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation()); loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation());
}); });
if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size * 2, vert, size * 2), loc.Get().clone().add(size * 2, vert, size * 2)))
{
continue;
}
if (loc.Get() == null) if (loc.Get() == null)
{
continue; continue;
}
System.out.println("Done finding area... [success]"); System.out.println("Done finding area... [success]");
@ -62,7 +68,7 @@ public class EventTerrainFinder
return loc.Get(); return loc.Get();
} }
System.out.println("Done finding area..."); System.out.println("Failed to find area...");
return null; return null;
} }

View File

@ -77,6 +77,19 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
} }
} }
public boolean isInEvent(Location location)
{
for (WorldEvent event : _runningEvents)
{
if (event.isInBounds(location))
{
return true;
}
}
return false;
}
@EventHandler @EventHandler
public void update(UpdateEvent event) public void update(UpdateEvent event)
{ {
@ -124,6 +137,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
} }
} }
public void randomEvent()
{
if (_runningEvents.size() == 0)
{
if (UtilServer.getPlayers().length > 0)
{
tryStartEvent();
}
}
}
private void tryStartEvent() private void tryStartEvent()
{ {
WorldEventType[] types = WorldEventType.values(); WorldEventType[] types = WorldEventType.values();

View File

@ -0,0 +1,28 @@
package mineplex.game.clans.clans.worldevent.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.clans.worldevent.WorldEventType;
import mineplex.minecraft.game.core.boss.WorldEvent;
/**
* Command for spawning a random world event in the world.
*/
public class RandomCommand extends CommandBase<WorldEventManager>
{
public RandomCommand(WorldEventManager plugin)
{
super(plugin, Rank.JNR_DEV, "random", "rand");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.randomEvent();
}
}

View File

@ -14,6 +14,7 @@ public class WorldEventCommand extends MultiCommandBase<WorldEventManager>
AddCommand(new StartCommand(Plugin)); AddCommand(new StartCommand(Plugin));
AddCommand(new ClearCommand(Plugin)); AddCommand(new ClearCommand(Plugin));
AddCommand(new RandomCommand(Plugin));
} }
@Override @Override

View File

@ -41,7 +41,7 @@ import mineplex.game.clans.shop.bank.BankShop;
public class GoldManager extends MiniPlugin public class GoldManager extends MiniPlugin
{ {
public static final double GEM_CONVERSION_RATE = 32; // The number of gold coins when converted from a single gem public static final double GEM_CONVERSION_RATE = 16; // The number of gold coins when converted from a single gem
public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death
public static final String META_STRING = "clans.goldAmount"; public static final String META_STRING = "clans.goldAmount";

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