From aeec6cc1cde2a451213e67623913a0464ed0d35d Mon Sep 17 00:00:00 2001
From: Hempfest <64885225+Hempfest@users.noreply.github.com>
Date: Tue, 20 Jun 2023 14:26:57 -0700
Subject: [PATCH] * Updated to 1.20 * Refactored the regions api making it
cleaner and more efficient. * Refactored naming scheme for skull api. *
Updated version
---
labyrinth-common/pom.xml | 2 +-
labyrinth-gui/pom.xml | 2 +-
labyrinth-loci/pom.xml | 2 +-
labyrinth-perms/pom.xml | 2 +-
labyrinth-plugin/pom.xml | 2 +-
.../data/RegionServicesManagerImpl.java | 28 +-
.../src/main/resources/lib/1_20_R1.jar | Bin 0 -> 4068 bytes
labyrinth-regions/pom.xml | 2 +-
.../sanctum/labyrinth/data/CuboidAxis.java | 69 ++++
.../labyrinth/data/CuboidLocation.java | 34 ++
.../labyrinth/data/CuboidSelection.java | 152 ++++++++
.../sanctum/labyrinth/data/DefaultCuboid.java | 40 ++
.../{RegionFlag.java => DefaultFlag.java} | 11 +-
.../sanctum/labyrinth/data/FlagManager.java | 85 +++++
.../labyrinth/data/RegionServicesManager.java | 27 +-
.../{library => data/container}/Cuboid.java | 357 +-----------------
.../data/{ => container}/Region.java | 245 +++++-------
.../labyrinth/event/CuboidSelectEvent.java | 6 +-
.../labyrinth/event/RegionBuildEvent.java | 2 +-
.../labyrinth/event/RegionDestroyEvent.java | 2 +-
.../labyrinth/event/RegionInteractEvent.java | 2 +-
.../event/RegionInteractionEvent.java | 2 +-
.../labyrinth/event/RegionPVPEvent.java | 2 +-
.../labyrinth/event/RegionTraverseEvent.java | 2 +-
labyrinth-skulls/pom.xml | 2 +-
.../com/github/sanctum/skulls/CustomHead.java | 46 +--
.../sanctum/skulls/CustomHeadLoader.java | 22 +-
...abyrinthHeadImpl.java => DefaultHead.java} | 6 +-
.../{HeadText.java => HeadContext.java} | 4 +-
...{OnlineHeadSearch.java => HeadLookup.java} | 6 +-
pom.xml | 2 +-
31 files changed, 601 insertions(+), 565 deletions(-)
create mode 100644 labyrinth-plugin/src/main/resources/lib/1_20_R1.jar
create mode 100644 labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidAxis.java
create mode 100644 labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidLocation.java
create mode 100644 labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidSelection.java
create mode 100644 labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/DefaultCuboid.java
rename labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/{RegionFlag.java => DefaultFlag.java} (77%)
create mode 100644 labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/FlagManager.java
rename labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/{library => data/container}/Cuboid.java (50%)
rename labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/{ => container}/Region.java (61%)
rename labyrinth-skulls/src/main/java/com/github/sanctum/skulls/{LabyrinthHeadImpl.java => DefaultHead.java} (71%)
rename labyrinth-skulls/src/main/java/com/github/sanctum/skulls/{HeadText.java => HeadContext.java} (78%)
rename labyrinth-skulls/src/main/java/com/github/sanctum/skulls/{OnlineHeadSearch.java => HeadLookup.java} (97%)
diff --git a/labyrinth-common/pom.xml b/labyrinth-common/pom.xml
index 72664daa..5e389a2d 100644
--- a/labyrinth-common/pom.xml
+++ b/labyrinth-common/pom.xml
@@ -5,7 +5,7 @@
labyrinth
com.github.the-h-team
- 1.9.1
+ 1.9.2
4.0.0
diff --git a/labyrinth-gui/pom.xml b/labyrinth-gui/pom.xml
index 8d03a8f9..ff2bb315 100644
--- a/labyrinth-gui/pom.xml
+++ b/labyrinth-gui/pom.xml
@@ -5,7 +5,7 @@
labyrinth
com.github.the-h-team
- 1.9.1
+ 1.9.2
4.0.0
diff --git a/labyrinth-loci/pom.xml b/labyrinth-loci/pom.xml
index 00cfed59..5a2b1bd9 100644
--- a/labyrinth-loci/pom.xml
+++ b/labyrinth-loci/pom.xml
@@ -5,7 +5,7 @@
labyrinth
com.github.the-h-team
- 1.9.1
+ 1.9.2
4.0.0
diff --git a/labyrinth-perms/pom.xml b/labyrinth-perms/pom.xml
index 1cb326f1..95b945b4 100644
--- a/labyrinth-perms/pom.xml
+++ b/labyrinth-perms/pom.xml
@@ -5,7 +5,7 @@
labyrinth
com.github.the-h-team
- 1.9.1
+ 1.9.2
4.0.0
diff --git a/labyrinth-plugin/pom.xml b/labyrinth-plugin/pom.xml
index 3c274de4..43858385 100644
--- a/labyrinth-plugin/pom.xml
+++ b/labyrinth-plugin/pom.xml
@@ -5,7 +5,7 @@
labyrinth
com.github.the-h-team
- 1.9.1
+ 1.9.2
4.0.0
diff --git a/labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManagerImpl.java b/labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManagerImpl.java
index f8cb6d43..c0fa1afb 100644
--- a/labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManagerImpl.java
+++ b/labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManagerImpl.java
@@ -2,6 +2,7 @@
import com.github.sanctum.labyrinth.Labyrinth;
import com.github.sanctum.labyrinth.LabyrinthProvider;
+import com.github.sanctum.labyrinth.data.container.Region;
import com.github.sanctum.labyrinth.event.CuboidSelectEvent;
import com.github.sanctum.labyrinth.event.LabyrinthVentCall;
import com.github.sanctum.labyrinth.event.RegionBuildEvent;
@@ -9,7 +10,6 @@
import com.github.sanctum.labyrinth.event.RegionInteractionEvent;
import com.github.sanctum.labyrinth.event.RegionPVPEvent;
import com.github.sanctum.labyrinth.event.DefaultEvent;
-import com.github.sanctum.labyrinth.library.Cuboid;
import com.github.sanctum.labyrinth.library.Items;
import com.github.sanctum.labyrinth.task.TaskScheduler;
import com.github.sanctum.panther.container.ImmutablePantherCollection;
@@ -25,6 +25,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.block.Action;
+import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.ServicePriority;
import org.jetbrains.annotations.NotNull;
@@ -34,7 +35,8 @@
public final class RegionServicesManagerImpl extends RegionServicesManager {
final PantherCollection cache = new PantherList<>();
- final Cuboid.FlagManager flagManager = new Cuboid.FlagManager(this);
+ final FlagManager flagManager = new FlagManager(this);
+ private ItemStack wand = new ItemStack(Material.STICK);
public static void initialize(Labyrinth instance) {
@@ -102,7 +104,7 @@ public static void initialize(Labyrinth instance) {
if (!e.getPlayer().hasPermission("labyrinth.selection"))
return;
- Cuboid.Selection selection = Cuboid.Selection.source(e.getPlayer());
+ CuboidSelection selection = CuboidSelection.get(e.getPlayer());
if (e.getItem().getType() == selection.getWand().getType()) {
if (e.getResult() != Event.Result.DENY) {
@@ -144,7 +146,7 @@ public static void initialize(Labyrinth instance) {
}
if (e.getItem().getType() == mat) {
- Cuboid.Selection selection = Cuboid.Selection.source(e.getPlayer());
+ CuboidSelection selection = CuboidSelection.get(e.getPlayer());
if (e.getResult() != Event.Result.DENY) {
e.setResult(Event.Result.DENY);
}
@@ -213,17 +215,17 @@ public Region get(@NotNull String name) {
@Override
public Region get(@NotNull Location location, boolean passthrough) {
- return cache.stream().filter(region -> region.contains(location) && region.isPassthrough() == passthrough).findFirst().orElse(null);
+ return cache.stream().filter(region -> region.contains(location) && region.isDominant() == passthrough).findFirst().orElse(null);
}
@Override
public Region get(@NotNull Player player, boolean passthrough) {
- return cache.stream().filter(region -> region.contains(player) && region.isPassthrough() == passthrough).findFirst().orElse(null);
+ return cache.stream().filter(region -> region.contains(player) && region.isDominant() == passthrough).findFirst().orElse(null);
}
@Override
public Region get(@NotNull String name, boolean passthrough) {
- return cache.stream().filter(region -> region.getName().equals(name) && region.isPassthrough() == passthrough).findFirst().orElse(null);
+ return cache.stream().filter(region -> region.getName().equals(name) && region.isDominant() == passthrough).findFirst().orElse(null);
}
@Override
@@ -239,7 +241,17 @@ public boolean unload(@NotNull Region region) {
}
@Override
- public Cuboid.FlagManager getFlagManager() {
+ public FlagManager getFlagManager() {
return flagManager;
}
+
+ @Override
+ public ItemStack getWand() {
+ return wand;
+ }
+
+ @Override
+ public void setWand(@NotNull ItemStack itemStack) {
+ this.wand = itemStack;
+ }
}
diff --git a/labyrinth-plugin/src/main/resources/lib/1_20_R1.jar b/labyrinth-plugin/src/main/resources/lib/1_20_R1.jar
new file mode 100644
index 0000000000000000000000000000000000000000..b19667d16293f3f4f80e94a64bcc2db0679fe486
GIT binary patch
literal 4068
zcmb7HcT`jB@(lvg55TI5bovc}`R@siNDEJ7*8u-%#29
z8`To&f&70y4S<-K_&;Nmqlr?J1W@REu8GsFK#J)%*A@?g
zBwoDOzvsLOU_yS7#Y>9IjiGuCWI005#^r;1@%d+8i*0w4eVcxe^g6cXs@OzKc&3`U
zkBy;{ZBLjkmA`vj&P1YGs%V)0)arP#K(n#NQF&KMtYtCN$Es4J5C_y~4|O?AIO$M=
zDEYx*vN`$X(kXiGh`Eh9|K;Km;J|(9&uZVbUxa#IlqjOp?7X^H_x_1mKr|PA4*xe+
zR;xV5?~+UI&_{usbZ?B5fG#YqN4Z;^VG>lF{J}Z;Q->!zV0#6)HJgX|(t)QV)iz_6
zn?*6^gHSkFyKtBcwH}io$P?(PJ$T4LU1>)}=*Kx?D@Yd28@-&7PdccvFY^qB?{F0H
z!!u$9l%ADOyY;wLV}(C2l2nw(ZSlY-Vv)z2Y#fZs6FD%nKMHlvz<*t`bW0%F?F-qO
z;JJ{P*RS`A6l}a&z&rbGLJG
z=8$#vvU8MoarQvkIa|5?tNaGrx{Qi6$4N33s^q0L2IWS1bzj{c^C4uNs%pCpG}ze?
zRkl621(k}137B`9$4CZO6roLvQW4BA
ztuqp7iFOd`w{6I^A)7=?N`%hlFxRXFH+kW_4t@}GNAwlBlJgMS(SnPCAKotY3RKs>
ztolg39L0it!d`KRfhL#%D;04;g9A1KAzw)EYHwfT1Q#|6Zi-(ayrFFD1XqZNp((`)
zn7p};?aQXn;Y;LoQ<=NKr`mIutNz50r+O;ZfV-a&_{U-#RJ!UQdewB#Q`#eZ&fiXb
z<~HrHPt4VZHJ^B_JoOua*gHI7^%(uF_-OC#D_xG#@6y>rd^+~SRhv4baMfK8LsEcp
ztJgj0#{*m`djd|}G8j_gdqtWnryJGbD6Ff2OXUI<=%2bx)r(SzZqOmUX-zYs1&c`o
z)P-Q~tr5;qYGKj13?BXC4KEJY
z?IrlMt2va=xQW8gUfHF)YT(sfbe_yyGHoZ(c$br1RQ0TB^kW
zj9j@0qm{(RX!s4|UFa}0C4_xSA|@~Q^B~BSul1bF@0Xz4$Y{hqk6L%_vf+Jucniqb6|wB#oIZh6Ww*+>Q?|xR)aX01O7`jd
z;JbYMhm*T$Ay(4pd=2Ve2$qKsr3FeTC#wKQcok1`ecxuxjVJgP0KpWn`+#tUgo33Q2a|$8Y{hUwDO+DoXxNQ1tZ&*ix<_WsR&r
z(x70|w!}r^*8FW!8ismIw|p$>frXQN*Zv4LsGaRfj!Kgs6NxzzYEd0t`CLPCevPr5
zDly#&K}}*(kTx;nlkAm0iVccP*qy3UXOfm8k&^u!tU7H~T$QV3zcxtHQ+3}(0uh5@
zd6og-V4rL0+tz9J?Z;f|O+1p210fEdQsh3AqSPS3#EJQ{&aX)%Ds#S&AL>S=XS%t>
zQZ=36$by{>1yRiHmvr>v6Sml;7R({cO^<`VOP{qBUAE57<wIR(hd1#0LrFK4>{SyE4cxTs(JL4@rGN01>ch#+wn7Rg
zL$ZoSgXFhAw9P)*SPMp_$V`Xy_uufp=fCMZ=hk;Cpp)M5SO$wioo`uxo_1lC`#O9i@dfJ-YJkfPAFm%8NicACjzH0xWHpm
z$J9mTD^f;s+stFFT3gsLCg=9YFYY+t@OI7m{D`_;;3vv!_2F0RMih0&XEiLiom_M1
zfHAA_U-gO=Hy$_Sr8f89_8g<#gXAqK@rJUK`k^1s%--6&><2x*!{G$Cian!xfqDjC7
zc4i75{Gw~{hd`K2?ouxgVG#uUXbM+|CiBW(6@
zfKLA2B#77QmA;8;su!k-O~JI8Z{+qk>;-ML=mhJJNEIU0$KCy$*0qA_u)ND_8)gC)4l?#ENdTDT!M8ZOny)LI%Y*a*?hd
zG5}>4r!28D@@3X?dU&CA$!>aZme9U?#nbHNFrcU*G7?il>(6cksV#g-wbOr~&{5>m
zJ*W(T-w|4LQ1-coL;F<hMQXm&0aot2IlU#YYt|Fx@71if*@45awNQVK=GR>hf$kQ^D<;>-s
z5YI~$cy(n&idgl-6j7x5&Dq`PRv;V45C>zK2LXMNh57+-Z78tLrOZc^Lc%dLbVnc-58Iypp%Xpsnk%!;F9&YqGsdZP^E_XH7T&v
zc!YO*P*F0S?=2(?=qWwrH;4qP~VhVW)tFwB1p;xA8L=W`(+Udk)O)B=p&Dsdw<^
zO|M*BukTB%rVv>U!e3{vL_0F}-Yb)5D3`UTcsLfw5n*GrkFj3zRoRGZl{*o=xDwd7
z#FnvVDW|gYMxn#XfifxK#-2$wKf3U>-pHrRklN=`VOCY!-4Ae>>(6$X&@;!~2g#9@
z8Q<}{Q2c0LBE$OayDcHE>D}QDh>yA;Adn!F0)d~^G=z`V$|nXBsI|V+A9@7aH;9`w
zk*E!m0F|2+zz=H~GX3x!T0&~?PBF;enC4L&(rN3honcfvzQ4Z;;y{P%++8T+5*Vc3
zs*PH_wHA7$sh(63qvG2#1=t}U9ny@R}g1)%r{
z+^4P)1VmNJWyU8K>EZV4VTPN_yz@Vbo)^)g-`bEIi?otR?)l{pcbQGRR0~Y&A4QLW
z+r7S50jFjqSRCVTnlL1^D4dK%a(qR(9lY>sFJO>H;URbt!V#M#Lzdo0)Aq-aSrg*R
zfSjan;CCl@XJetM6r7GFJRJ!XXJY~H0x96v&gyhF{DgC#^=sCd(>e#|Y4{i4^=smp
z^E!v-Y4{WI+=u;I;LM4gBltA@8-bsF*{`L}oY^^=PQ%|y{mZA}U7!J+ukJrD^=D4)
z9EYdjf7kn~Z#yg0&+0$VcA0bO(`e
labyrinth
com.github.the-h-team
- 1.9.1
+ 1.9.2
4.0.0
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidAxis.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidAxis.java
new file mode 100644
index 00000000..293fab6d
--- /dev/null
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidAxis.java
@@ -0,0 +1,69 @@
+package com.github.sanctum.labyrinth.data;
+
+public class CuboidAxis {
+
+ private final int xMin;
+ private final int xMax;
+ private final int yMin;
+ private final int yMax;
+ private final int zMin;
+ private final int zMax;
+ private final int height;
+ private final int zWidth;
+ private final int xWidth;
+ private final int totalSize;
+
+ public CuboidAxis(int x1, int x2, int y1, int y2, int z1, int z2) {
+ this.xMin = Math.min(x1, x2);
+ this.xMax = Math.max(x1, x2);
+ this.yMin = Math.min(y1, y2);
+ this.yMax = Math.max(y1, y2);
+ this.zMin = Math.min(z1, z2);
+ this.zMax = Math.max(z1, z2);
+ this.height = this.yMax - this.yMin + 1;
+ this.xWidth = this.xMax - this.xMin + 1;
+ this.zWidth = this.zMax - this.zMin + 1;
+ this.totalSize = height * xWidth * zWidth;
+ }
+
+ public int getTotalSize() {
+ return totalSize;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public int getxWidth() {
+ return xWidth;
+ }
+
+ public int getzWidth() {
+ return zWidth;
+ }
+
+ public int getxMax() {
+ return xMax;
+ }
+
+ public int getxMin() {
+ return xMin;
+ }
+
+ public int getyMax() {
+ return yMax;
+ }
+
+ public int getyMin() {
+ return yMin;
+ }
+
+ public int getzMax() {
+ return zMax;
+ }
+
+ public int getzMin() {
+ return zMin;
+ }
+
+}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidLocation.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidLocation.java
new file mode 100644
index 00000000..2bc6ec84
--- /dev/null
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidLocation.java
@@ -0,0 +1,34 @@
+package com.github.sanctum.labyrinth.data;
+
+import java.util.Random;
+import org.bukkit.Location;
+import org.bukkit.World;
+
+public class CuboidLocation {
+
+ private final World world;
+ private final CuboidAxis axis;
+ private final Location center;
+
+ public CuboidLocation(CuboidAxis axis, World world) {
+ this.world = world;
+ this.axis = axis;
+ this.center = new Location(getWorld(), (double) (this.axis.getxMax() - this.axis.getxMin()) / 2 + this.axis.getxMin(), (double) (this.axis.getyMax() - this.axis.getyMin()) / 2 + this.axis.getyMin(), (double) (this.axis.getzMax() - this.axis.getzMin()) / 2 + this.axis.getzMin());
+ }
+
+ public Location getCenter() {
+ return center;
+ }
+
+ public Location getRandom() {
+ Random r = new Random();
+ int x = r.nextInt(Math.abs(this.axis.getxMax() - this.axis.getxMin()) + 1) + this.axis.getxMin();
+ int y = r.nextInt(Math.abs(this.axis.getyMax() - this.axis.getyMin()) + 1) + this.axis.getyMin();
+ int z = r.nextInt(Math.abs(this.axis.getzMax() - this.axis.getzMin()) + 1) + this.axis.getzMin();
+ return new Location(getWorld(), x, y, z);
+ }
+
+ public World getWorld() {
+ return world;
+ }
+}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidSelection.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidSelection.java
new file mode 100644
index 00000000..d298e7b4
--- /dev/null
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/CuboidSelection.java
@@ -0,0 +1,152 @@
+package com.github.sanctum.labyrinth.data;
+
+import com.github.sanctum.labyrinth.data.container.Cuboid;
+import java.util.HashSet;
+import java.util.Set;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+/**
+ * Represents that of a cuboid selection in emphasis. It contains area data for easy manipulation with regions.
+ */
+public class CuboidSelection {
+
+ private static final Set cache = new HashSet<>();
+
+ private final Player wizard;
+ private ItemStack wand;
+ private Location pos1;
+ private Location pos2;
+
+ protected CuboidSelection(Player wizard) {
+ this.wizard = wizard;
+ this.wand = RegionServicesManager.getInstance().getWand();
+ }
+
+ public Player getPlayer() {
+ return wizard;
+ }
+
+ public ItemStack getWand() {
+ return wand;
+ }
+
+ public boolean isEmpty() {
+ return getPos1() == null || getPos2() == null;
+ }
+
+ public void setWand(ItemStack wand) {
+ this.wand = wand;
+ }
+
+ public Location getPos1() {
+ return pos1;
+ }
+
+ public Location getPos2() {
+ return pos2;
+ }
+
+ public Location getHighest() {
+ return getPos1().getBlockY() > getPos2().getBlockY() ? getPos1() : getPos2();
+ }
+
+ public Location getLowest() {
+ return getPos2().getBlockY() < getPos1().getBlockY() ? getPos2() : getPos1();
+ }
+
+ public Location expand(BlockFace direction) {
+ Location update;
+ switch (direction) {
+ case UP:
+ update = getHighest().getBlock().getRelative(BlockFace.UP).getLocation();
+ setPos1(update);
+ return update;
+ case DOWN:
+ update = getHighest().getBlock().getRelative(BlockFace.DOWN).getLocation();
+ setPos2(update);
+ return update;
+ case EAST:
+ update = getHighest().getBlock().getRelative(BlockFace.EAST).getLocation();
+ setPos1(update);
+ return update;
+ case WEST:
+ update = getHighest().getBlock().getRelative(BlockFace.WEST).getLocation();
+ setPos2(update);
+ return update;
+ case NORTH:
+ update = getHighest().getBlock().getRelative(BlockFace.NORTH).getLocation();
+ setPos1(update);
+ return update;
+ case SOUTH:
+ update = getHighest().getBlock().getRelative(BlockFace.SOUTH).getLocation();
+ setPos2(update);
+ return update;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public Location expand(BlockFace direction, int distance) {
+ Location update;
+ switch (direction) {
+ case UP:
+ update = getHighest().getBlock().getRelative(BlockFace.UP, distance).getLocation();
+ setPos1(update);
+ return update;
+ case DOWN:
+ update = getHighest().getBlock().getRelative(BlockFace.DOWN, distance).getLocation();
+ setPos2(update);
+ return update;
+ case EAST:
+ update = getHighest().getBlock().getRelative(BlockFace.EAST, distance).getLocation();
+ setPos1(update);
+ return update;
+ case WEST:
+ update = getHighest().getBlock().getRelative(BlockFace.WEST, distance).getLocation();
+ setPos2(update);
+ return update;
+ case NORTH:
+ update = getHighest().getBlock().getRelative(BlockFace.NORTH, distance).getLocation();
+ setPos1(update);
+ return update;
+ case SOUTH:
+ update = getHighest().getBlock().getRelative(BlockFace.SOUTH, distance).getLocation();
+ setPos2(update);
+ return update;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public void setPos1(Location pos1) {
+ this.pos1 = pos1;
+ }
+
+ public void setPos2(Location pos2) {
+ this.pos2 = pos2;
+ }
+
+ public Cuboid toCuboid() {
+ return Cuboid.fromPoints(getPos1(), getPos2());
+ }
+
+ public static boolean has(Player p) {
+ return cache.stream().anyMatch(s -> s.getPlayer().equals(p));
+ }
+
+ public static CuboidSelection get(Player p) {
+ for (CuboidSelection r : cache) {
+ if (r.getPlayer().equals(p)) {
+ return r;
+ }
+ }
+ CuboidSelection r = new CuboidSelection(p);
+ cache.add(r);
+ return r;
+ }
+
+}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/DefaultCuboid.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/DefaultCuboid.java
new file mode 100644
index 00000000..8f624c52
--- /dev/null
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/DefaultCuboid.java
@@ -0,0 +1,40 @@
+package com.github.sanctum.labyrinth.data;
+
+import com.github.sanctum.labyrinth.data.container.Cuboid;
+import com.github.sanctum.panther.util.Check;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+
+public class DefaultCuboid implements Cuboid {
+
+ private final CuboidAxis axis;
+ private final CuboidLocation location;
+
+ public DefaultCuboid(Location start, Location end) throws NullPointerException {
+ Check.forNull(start, "Starting point cannot be null!");
+ Check.forNull(end, "End point cannot be null!");
+ Check.argument(start.getWorld().getName().equals(end.getWorld().getName()), "The locations must both be from the same realm!");
+ this.axis = new CuboidAxis(start.getBlockX(), end.getBlockX(), start.getBlockY(), end.getBlockY(), start.getBlockZ(), end.getBlockZ());
+ this.location = new CuboidLocation(axis, start.getWorld());
+ }
+
+ @Override
+ public VisualBoundary getBoundary(Player target) {
+ return new VisualBoundary(axis.getxMax(), axis.getxMin(), axis.getyMax(), axis.getyMin(), axis.getzMax(), axis.getzMin()).setViewer(target);
+ }
+
+ @Override
+ public int getTotalBlocks() {
+ return axis.getTotalSize();
+ }
+
+ @Override
+ public CuboidAxis getAxis() {
+ return axis;
+ }
+
+ @Override
+ public CuboidLocation getLocation() {
+ return location;
+ }
+}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/RegionFlag.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/DefaultFlag.java
similarity index 77%
rename from labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/RegionFlag.java
rename to labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/DefaultFlag.java
index 4f4f0ce7..36e00c9c 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/RegionFlag.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/DefaultFlag.java
@@ -1,17 +1,16 @@
package com.github.sanctum.labyrinth.data;
import com.github.sanctum.labyrinth.LabyrinthProvider;
-import com.github.sanctum.labyrinth.library.Cuboid;
+import com.github.sanctum.labyrinth.data.container.Cuboid;
import com.github.sanctum.panther.event.Vent;
-public class RegionFlag extends Cuboid.Flag {
+public class DefaultFlag extends Cuboid.Flag {
public static class Builder {
private Vent.Subscription> subscription;
private String id;
protected Builder() {
-
}
public static Builder initialize() {
@@ -32,17 +31,17 @@ public Cuboid.Flag finish() {
if (this.subscription != null) {
LabyrinthProvider.getInstance().getEventMap().subscribe(subscription);
}
- return new RegionFlag(this.id);
+ return new DefaultFlag(this.id);
}
}
- public RegionFlag(Cuboid.Flag flag) {
+ public DefaultFlag(Cuboid.Flag flag) {
super(flag);
}
- public RegionFlag(String id) {
+ public DefaultFlag(String id) {
super(id);
}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/FlagManager.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/FlagManager.java
new file mode 100644
index 00000000..1c0d1944
--- /dev/null
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/FlagManager.java
@@ -0,0 +1,85 @@
+package com.github.sanctum.labyrinth.data;
+
+import com.github.sanctum.labyrinth.LabyrinthProvider;
+import com.github.sanctum.labyrinth.data.container.Cuboid;
+import com.github.sanctum.labyrinth.data.container.Region;
+import com.github.sanctum.labyrinth.task.TaskScheduler;
+import com.github.sanctum.panther.event.Vent;
+import com.github.sanctum.panther.event.VentMap;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+import org.bukkit.plugin.Plugin;
+
+public class FlagManager {
+
+ private final Plugin plugin = LabyrinthProvider.getInstance().getPluginInstance();
+ private final Set CACHE = new HashSet<>();
+ private final RegionServicesManager regionServices;
+
+
+ public FlagManager(RegionServicesManager manager) {
+ this.regionServices = manager;
+ Cuboid.Flag BREAK = DefaultFlag.Builder
+ .initialize()
+ .label("break")
+ .finish();
+
+ Cuboid.Flag BUILD = DefaultFlag.Builder
+ .initialize()
+ .label("build")
+ .finish();
+
+ Cuboid.Flag PVP = DefaultFlag.Builder
+ .initialize()
+ .label("pvp")
+ .finish();
+
+ register(PVP);
+ register(BREAK);
+ register(BUILD);
+
+ }
+
+ public Optional getFlag(String id) {
+ return CACHE.stream().filter(f -> f.getId().equals(id)).findFirst();
+ }
+
+ public Set getFlags() {
+ return Collections.unmodifiableSet(CACHE);
+ }
+
+ public boolean isRegistered(Cuboid.Flag flag) {
+ return CACHE.stream().anyMatch(f -> f.getId().equals(flag.getId()));
+ }
+
+ public boolean unregister(Cuboid.Flag flag) {
+ for (Region r : regionServices.getAll()) {
+ r.getFlags().forEach(f -> {
+ if (f.getId().equals(flag.getId())) {
+ TaskScheduler.of(() -> r.removeFlag(f)).schedule();
+ }
+ });
+ }
+ return CACHE.removeIf(f -> f.getId().equals(flag.getId()));
+ }
+
+ public boolean register(Cuboid.Flag flag) {
+ if (!getFlag(flag.getId()).isPresent()) {
+ regionServices.getAll().forEach(region -> region.addFlag(flag));
+ return CACHE.add(flag);
+ }
+ return false;
+ }
+
+ public boolean registerControlling(Cuboid.Flag flag) {
+ if (!getFlag(flag.getId()).isPresent()) {
+ VentMap.getInstance().subscribe((Vent.Host) plugin, flag);
+ regionServices.getAll().forEach(region -> region.addFlag(flag));
+ return CACHE.add(flag);
+ }
+ return false;
+ }
+
+}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManager.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManager.java
index 4aee60a7..3a3b9e27 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManager.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManager.java
@@ -1,10 +1,11 @@
package com.github.sanctum.labyrinth.data;
-import com.github.sanctum.labyrinth.library.Cuboid;
+import com.github.sanctum.labyrinth.data.container.Region;
import com.github.sanctum.panther.container.PantherCollection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
@@ -12,15 +13,6 @@
*/
public abstract class RegionServicesManager {
- /**
- * Get the main region service manager instance.
- *
- * @return the region services manager
- */
- public static RegionServicesManager getInstance() {
- return Bukkit.getServicesManager().load(RegionServicesManager.class);
- }
-
public abstract PantherCollection getAll();
public abstract Region get(@NotNull Location location);
@@ -44,6 +36,19 @@ public static RegionServicesManager getInstance() {
*
* @return this manager's flag manager
*/
- public abstract Cuboid.FlagManager getFlagManager();
+ public abstract FlagManager getFlagManager();
+
+ public abstract ItemStack getWand();
+
+ public abstract void setWand(@NotNull ItemStack itemStack);
+
+ /**
+ * Get the main region service manager instance.
+ *
+ * @return the region services manager
+ */
+ public static RegionServicesManager getInstance() {
+ return Bukkit.getServicesManager().load(RegionServicesManager.class);
+ }
}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/library/Cuboid.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/container/Cuboid.java
similarity index 50%
rename from labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/library/Cuboid.java
rename to labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/container/Cuboid.java
index 3e262003..990f4da6 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/library/Cuboid.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/container/Cuboid.java
@@ -1,299 +1,50 @@
-package com.github.sanctum.labyrinth.library;
+package com.github.sanctum.labyrinth.data.container;
-import com.github.sanctum.labyrinth.LabyrinthProvider;
-import com.github.sanctum.labyrinth.api.Service;
-import com.github.sanctum.labyrinth.data.Region;
-import com.github.sanctum.labyrinth.data.RegionFlag;
+import com.github.sanctum.labyrinth.data.CuboidAxis;
+import com.github.sanctum.labyrinth.data.CuboidLocation;
+import com.github.sanctum.labyrinth.data.DefaultCuboid;
+import com.github.sanctum.labyrinth.data.DefaultFlag;
import com.github.sanctum.labyrinth.data.RegionServicesManager;
import com.github.sanctum.labyrinth.data.SimpleKeyedValue;
+import com.github.sanctum.labyrinth.library.StringUtils;
import com.github.sanctum.labyrinth.task.TaskScheduler;
-import com.github.sanctum.panther.event.Vent;
-import com.github.sanctum.panther.event.VentMap;
-import com.github.sanctum.panther.util.Check;
import com.github.sanctum.panther.util.HUID;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
import java.util.function.Function;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
-import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
-import java.util.Optional;
import java.util.Random;
/**
+ * An interface for capturing cubic or rectangular areas.
+ *
* @author Hempfest
*/
public interface Cuboid {
static Cuboid fromPoints(Location start, Location end) {
- Check.forNull(start, "Starting point cannot be null!");
- Check.forNull(end, "End point cannot be null!");
- return new Cuboid() {
-
- private final int xMin;
- private final int xMax;
- private final int yMin;
- private final int yMax;
- private final int zMin;
- private final int zMax;
- private final int height;
- private final int zWidth;
- private final int xWidth;
- private final int totalSize;
- private final World world;
-
- {
- this.xMin = Math.min(start.getBlockX(), end.getBlockX());
- this.xMax = Math.max(start.getBlockX(), end.getBlockX());
- this.yMin = Math.min(start.getBlockY(), end.getBlockY());
- this.yMax = Math.max(start.getBlockY(), end.getBlockY());
- this.zMin = Math.min(start.getBlockZ(), end.getBlockZ());
- this.zMax = Math.max(start.getBlockZ(), end.getBlockZ());
- this.world = start.getWorld();
- this.height = this.yMax - this.yMin + 1;
- this.xWidth = this.xMax - this.xMin + 1;
- this.zWidth = this.zMax - this.zMin + 1;
- this.totalSize = height * xWidth * zWidth;
- }
-
- @Override
- public Boundary getBoundary(Player target) {
- return new Boundary(xMax, xMin, yMax, yMin, zMax, zMin).target(target);
- }
-
- @Override
- public World getWorld() {
- return world;
- }
-
- @Override
- public int getTotalBlocks() {
- return totalSize;
- }
-
- @Override
- public int getXWidth() {
- return xWidth;
- }
-
- @Override
- public int getZWidth() {
- return zWidth;
- }
-
- @Override
- public int getHeight() {
- return height;
- }
-
- @Override
- public int xMax() {
- return xMax;
- }
-
- @Override
- public int xMin() {
- return xMin;
- }
-
- @Override
- public int yMax() {
- return yMax;
- }
-
- @Override
- public int yMin() {
- return yMin;
- }
-
- @Override
- public int zMax() {
- return zMax;
- }
-
- @Override
- public int zMin() {
- return zMin;
- }
- };
+ return new DefaultCuboid(start, end);
}
- Boundary getBoundary(Player target);
-
- World getWorld();
+ VisualBoundary getBoundary(Player target);
int getTotalBlocks();
- int getXWidth();
+ CuboidAxis getAxis();
- int getZWidth();
-
- int getHeight();
-
- int xMax();
-
- int xMin();
-
- int yMax();
-
- int yMin();
-
- int zMax();
-
- int zMin();
+ CuboidLocation getLocation();
default Region toRegion() {
- return new Region(getWorld(), xMin(), xMax(), yMin(), yMax(), zMin(), zMax(), HUID.randomID()){};
+ return new Region(getLocation().getWorld(), getAxis().getxMin(), getAxis().getxMax(), getAxis().getyMin(), getAxis().getyMax(), getAxis().getzMin(), getAxis().getzMax(), HUID.randomID()){};
}
default R toRegion(Function>, R> function) {
- return function.apply(SimpleKeyedValue.of(this, SimpleKeyedValue.of(new Location(getWorld(), xMin(), yMin(), zMin()), new Location(getWorld(), xMax(), yMax(), this.zMax()))));
- }
-
- class Selection {
-
- private static final Set cache = new HashSet<>();
-
- private final Player wizard;
-
- private ItemStack wand = new ItemStack(Material.WOODEN_AXE);
-
- private Location pos1;
-
- private Location pos2;
-
- protected Selection(Player wizard) {
- this.wizard = wizard;
- }
-
- public static boolean contains(Player p) {
- return cache.stream().anyMatch(s -> s.getPlayer().equals(p));
- }
-
- public static Selection source(Player p) {
- for (Selection r : cache) {
- if (r.getPlayer().equals(p)) {
- return r;
- }
- }
- Selection r = new Selection(p);
- cache.add(r);
- return r;
- }
-
- public Player getPlayer() {
- return wizard;
- }
-
- public ItemStack getWand() {
- return wand;
- }
-
- public void setWand(ItemStack wand) {
- this.wand = wand;
- }
-
- public Location getPos1() {
- return pos1;
- }
-
- public Location getPos2() {
- return pos2;
- }
-
- public Location getHighest() {
- return getPos1().getBlockY() > getPos2().getBlockY() ? getPos1() : getPos2();
- }
-
- public Location getLowest() {
- return getPos2().getBlockY() < getPos1().getBlockY() ? getPos2() : getPos1();
- }
-
- public Location expand(BlockFace direction) {
- Location update;
- switch (direction) {
- case UP:
- update = getHighest().getBlock().getRelative(BlockFace.UP).getLocation();
- setPos1(update);
- return update;
- case DOWN:
- update = getHighest().getBlock().getRelative(BlockFace.DOWN).getLocation();
- setPos2(update);
- return update;
- case EAST:
- update = getHighest().getBlock().getRelative(BlockFace.EAST).getLocation();
- setPos1(update);
- return update;
- case WEST:
- update = getHighest().getBlock().getRelative(BlockFace.WEST).getLocation();
- setPos2(update);
- return update;
- case NORTH:
- update = getHighest().getBlock().getRelative(BlockFace.NORTH).getLocation();
- setPos1(update);
- return update;
- case SOUTH:
- update = getHighest().getBlock().getRelative(BlockFace.SOUTH).getLocation();
- setPos2(update);
- return update;
- default:
- throw new IllegalStateException();
- }
- }
-
- public Location expand(BlockFace direction, int distance) {
- Location update;
- switch (direction) {
- case UP:
- update = getHighest().getBlock().getRelative(BlockFace.UP, distance).getLocation();
- setPos1(update);
- return update;
- case DOWN:
- update = getHighest().getBlock().getRelative(BlockFace.DOWN, distance).getLocation();
- setPos2(update);
- return update;
- case EAST:
- update = getHighest().getBlock().getRelative(BlockFace.EAST, distance).getLocation();
- setPos1(update);
- return update;
- case WEST:
- update = getHighest().getBlock().getRelative(BlockFace.WEST, distance).getLocation();
- setPos2(update);
- return update;
- case NORTH:
- update = getHighest().getBlock().getRelative(BlockFace.NORTH, distance).getLocation();
- setPos1(update);
- return update;
- case SOUTH:
- update = getHighest().getBlock().getRelative(BlockFace.SOUTH, distance).getLocation();
- setPos2(update);
- return update;
- default:
- throw new IllegalStateException();
- }
- }
-
- public void setPos1(Location pos1) {
- this.pos1 = pos1;
- }
-
- public void setPos2(Location pos2) {
- this.pos2 = pos2;
- }
-
- public Cuboid toCuboid() {
- return fromPoints(getPos1(), getPos2());
- }
-
+ return function.apply(SimpleKeyedValue.of(this, SimpleKeyedValue.of(new Location(getLocation().getWorld(), getAxis().getxMin(), getAxis().getyMin(), getAxis().getzMin()), new Location(getLocation().getWorld(), getAxis().getxMax(), getAxis().getyMax(), getAxis().getzMax()))));
}
abstract class Flag implements Listener {
@@ -312,7 +63,7 @@ public Flag(String id) {
}
public Flag clone() {
- return new RegionFlag(this);
+ return new DefaultFlag(this);
}
public final void setEnabled(boolean allowed) {
@@ -337,79 +88,7 @@ public String getId() {
}
- class FlagManager {
-
- private final Plugin plugin = LabyrinthProvider.getInstance().getPluginInstance();
- private final Set CACHE = new HashSet<>();
- private final RegionServicesManager regionServices;
-
- @SuppressWarnings("OptionalGetWithoutIsPresent") // TODO: Refactor to avoid unchecked #get/safely operate on Optionals
- public FlagManager(RegionServicesManager manager) {
- this.regionServices = manager;
- Flag BREAK = RegionFlag.Builder
- .initialize()
- .label("break")
- .finish();
-
- Flag BUILD = RegionFlag.Builder
- .initialize()
- .label("build")
- .finish();
-
- Flag PVP = RegionFlag.Builder
- .initialize()
- .label("pvp")
- .finish();
-
- register(PVP);
- register(BREAK);
- register(BUILD);
-
- }
-
- public Optional getFlag(String id) {
- return CACHE.stream().filter(f -> f.getId().equals(id)).findFirst();
- }
-
- public Set getFlags() {
- return Collections.unmodifiableSet(CACHE);
- }
-
- public boolean isRegistered(Cuboid.Flag flag) {
- return CACHE.stream().anyMatch(f -> f.getId().equals(flag.getId()));
- }
-
- public boolean unregister(Cuboid.Flag flag) {
- for (Region r : regionServices.getAll()) {
- r.getFlags().forEach(f -> {
- if (f.getId().equals(flag.getId())) {
- TaskScheduler.of(() -> r.removeFlag(f)).schedule();
- }
- });
- }
- return CACHE.removeIf(f -> f.getId().equals(flag.getId()));
- }
-
- public boolean register(Cuboid.Flag flag) {
- if (!getFlag(flag.getId()).isPresent()) {
- regionServices.getAll().forEach(region -> region.addFlag(flag));
- return CACHE.add(flag);
- }
- return false;
- }
-
- public boolean registerControlling(Cuboid.Flag flag) {
- if (!getFlag(flag.getId()).isPresent()) {
- VentMap.getInstance().subscribe((Vent.Host) plugin, flag);
- regionServices.getAll().forEach(region -> region.addFlag(flag));
- return CACHE.add(flag);
- }
- return false;
- }
-
- }
-
- class Boundary {
+ class VisualBoundary {
private final double xMax;
private final double xMin;
@@ -420,7 +99,7 @@ class Boundary {
private Player p;
- public Boundary(double xMax, double xMin, double yMax, double yMin, double zMax, double zMin) {
+ public VisualBoundary(double xMax, double xMin, double yMax, double yMin, double zMax, double zMin) {
this.xMax = xMax;
this.zMax = zMax;
this.yMax = yMax;
@@ -429,7 +108,7 @@ public Boundary(double xMax, double xMin, double yMax, double yMin, double zMax,
this.yMin = yMin;
}
- public Boundary target(Player target) {
+ public VisualBoundary setViewer(Player target) {
this.p = target;
return this;
}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/Region.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/container/Region.java
similarity index 61%
rename from labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/Region.java
rename to labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/container/Region.java
index 61d3a4c5..0a79f33a 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/Region.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/data/container/Region.java
@@ -1,16 +1,20 @@
-package com.github.sanctum.labyrinth.data;
+package com.github.sanctum.labyrinth.data.container;
import com.github.sanctum.labyrinth.LabyrinthProvider;
+import com.github.sanctum.labyrinth.data.CuboidAxis;
+import com.github.sanctum.labyrinth.data.CuboidLocation;
+import com.github.sanctum.labyrinth.data.RegionServicesManager;
import com.github.sanctum.labyrinth.formatting.UniformedComponents;
import com.github.sanctum.labyrinth.interfacing.Catchable;
import com.github.sanctum.labyrinth.interfacing.Snapshot;
-import com.github.sanctum.labyrinth.library.Cuboid;
+import com.github.sanctum.panther.container.ImmutablePantherCollection;
+import com.github.sanctum.panther.container.PantherCollection;
+import com.github.sanctum.panther.container.PantherList;
import com.github.sanctum.panther.util.HUID;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.Random;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@@ -25,60 +29,67 @@
public abstract class Region implements Cuboid, Snapshot, Catchable {
private Region parent;
- private final int xMin;
- private final int xMax;
- private final int yMin;
- private final int yMax;
- private final int zMin;
- private final int zMax;
- private final int totalSize;
private final double distanceBetweenPoints;
- private final World world;
private final Location point1;
private final Location point2;
+ private final CuboidAxis axis;
+ private final CuboidLocation location;
private final HUID id;
- private final int height;
- private final int xWidth;
- private final int zWidth;
private UUID owner;
private String name;
- private boolean passthrough;
+ private boolean dominant;
private final Plugin plugin;
protected final List FLAGS;
private final List MEMBERS;
- private final List list;
+ private final PantherList list;
+
+ protected Region(Cuboid cuboid) {
+ if (cuboid instanceof Region) {
+ this.parent = ((Region) cuboid);
+ this.axis = ((Region) cuboid).axis;
+ this.id = ((Region) cuboid).id;
+ this.FLAGS = ((Region) cuboid).FLAGS;
+ this.MEMBERS = ((Region) cuboid).MEMBERS;
+ this.plugin = ((Region) cuboid).plugin;
+ this.list = ((Region) cuboid).list;
+ this.owner = ((Region) cuboid).owner;
+ this.name = ((Region) cuboid).name;
+ this.dominant = ((Region) cuboid).dominant;
+ this.point1 = ((Region) cuboid).point1;
+ this.point2 = ((Region) cuboid).point2;
+ this.distanceBetweenPoints = ((Region) cuboid).distanceBetweenPoints;
+ this.location = ((Region) cuboid).location;
+ } else {
+ this.axis = cuboid.getAxis();
+ this.location = cuboid.getLocation();
+ this.id = HUID.randomID();
+ this.FLAGS = new ArrayList<>();
+ this.MEMBERS = new ArrayList<>();
+ this.plugin = LabyrinthProvider.getInstance().getPluginInstance();
+ this.list = new PantherList<>(axis.getTotalSize());
+ for (int x = axis.getxMin(); x <= axis.getxMax(); x++) {
+ for (int y = axis.getyMin(); y <= axis.getyMax(); y++) {
+ for (int z = axis.getzMin(); z <= axis.getzMax(); z++) {
+ Block b = location.getWorld().getBlockAt(x, y, z);
+ list.add(b);
+ }
+ }
+ }
+ this.point1 = new Location(location.getWorld(), axis.getxMin(), axis.getyMin(), axis.getzMin());
+ this.point2 = new Location(location.getWorld(), axis.getxMax(), axis.getyMax(), axis.getzMax());
+ this.distanceBetweenPoints = this.getStartingPoint().distance(this.getEndingPoint());
+ for (Flag registered : RegionServicesManager.getInstance().getFlagManager().getFlags()) {
+ addFlag(registered);
+ }
+ }
+
+ }
protected Region(Region cuboid, Region parent) {
this(cuboid);
this.parent = parent;
}
- protected Region(Region cuboid) {
- this.parent = cuboid.parent;
- this.xMin = cuboid.xMin;
- this.xMax = cuboid.xMax;
- this.yMin = cuboid.yMin;
- this.yMax = cuboid.yMax;
- this.zMin = cuboid.zMin;
- this.zMax = cuboid.zMax;
- this.height = this.yMax - this.yMin + 1;
- this.xWidth = this.xMax - this.xMin + 1;
- this.zWidth = this.zMax - this.zMin + 1;
- this.totalSize = this.getHeight() * this.getXWidth() * this.getZWidth();
- this.world = cuboid.world;
- this.id = cuboid.id;
- this.FLAGS = cuboid.FLAGS;
- this.MEMBERS = cuboid.MEMBERS;
- this.plugin = cuboid.plugin;
- this.list = cuboid.list;
- this.owner = cuboid.owner;
- this.name = cuboid.name;
- this.passthrough = cuboid.passthrough;
- this.point1 = new Location(this.world, this.xMin, this.yMin, this.zMin);
- this.point2 = new Location(this.world, this.xMax, this.yMax, this.zMax);
- this.distanceBetweenPoints = this.getStartingPoint().distance(this.getEndingPoint());
- }
-
protected Region(final Location point1, final Location point2) {
this(point1, point2, HUID.randomID());
}
@@ -100,32 +111,23 @@ protected Region(World world, int xMin, int xMax, int yMin, int yMax, int zMin,
}
protected Region(World world, int xMin, int xMax, int yMin, int yMax, int zMin, int zMax, Plugin plugin, HUID id) {
- this.xMin = xMin;
- this.xMax = xMax;
- this.yMin = yMin;
- this.yMax = yMax;
- this.zMin = zMin;
- this.zMax = zMax;
- this.height = this.yMax - this.yMin + 1;
- this.xWidth = this.xMax - this.xMin + 1;
- this.zWidth = this.zMax - this.zMin + 1;
- this.totalSize = this.getHeight() * this.getXWidth() * this.getZWidth();
- this.world = world;
+ this.axis = new CuboidAxis(xMax, xMin, yMax, yMin, zMax, zMin);
+ this.location = new CuboidLocation(axis, world);
this.id = id;
this.FLAGS = new ArrayList<>();
this.MEMBERS = new ArrayList<>();
this.plugin = plugin;
- this.list = new ArrayList<>(this.getTotalBlocks());
- for (int x = this.xMin; x <= this.xMax; x++) {
- for (int y = this.yMin; y <= this.yMax; y++) {
- for (int z = this.zMin; z <= this.zMax; z++) {
- Block b = this.world.getBlockAt(x, y, z);
+ this.list = new PantherList<>(axis.getTotalSize());
+ for (int x = axis.getxMin(); x <= axis.getxMax(); x++) {
+ for (int y = axis.getyMin(); y <= axis.getyMax(); y++) {
+ for (int z = axis.getzMin(); z <= axis.getzMax(); z++) {
+ Block b = location.getWorld().getBlockAt(x, y, z);
list.add(b);
}
}
}
- this.point1 = new Location(this.world, this.xMin, this.yMin, this.zMin);
- this.point2 = new Location(this.world, this.xMax, this.yMax, this.zMax);
+ this.point1 = new Location(location.getWorld(), axis.getxMin(), axis.getyMin(), axis.getzMin());
+ this.point2 = new Location(location.getWorld(), axis.getxMax(), axis.getyMax(), axis.getzMax());
this.distanceBetweenPoints = this.getStartingPoint().distance(this.getEndingPoint());
for (Flag registered : RegionServicesManager.getInstance().getFlagManager().getFlags()) {
addFlag(registered);
@@ -172,22 +174,20 @@ public HUID getId() {
return this.id;
}
- public List getBlocks() {
- return Collections.unmodifiableList(list);
+ public PantherCollection getBlocks() {
+ return ImmutablePantherCollection.of(list);
}
public List getLaced() {
- return CompletableFuture.supplyAsync(() -> {
- List list = new ArrayList<>();
- RegionServicesManager.getInstance().getAll().forEach(c -> {
- for (Block b : this.list) {
- if (c.contains(b.getLocation()) && !c.getId().equals(getId())) {
- list.add(c);
- }
+ List list = new ArrayList<>();
+ RegionServicesManager.getInstance().getAll().forEach(c -> {
+ for (Block b : this.list) {
+ if (c.contains(b.getLocation()) && !c.getId().equals(getId())) {
+ list.add(c);
}
- });
- return list;
- }).join();
+ }
+ });
+ return list;
}
public Location getHighpoint() {
@@ -198,10 +198,6 @@ public Location getLowpoint() {
return getEndingPoint().getBlockY() < getStartingPoint().getBlockY() ? getEndingPoint() : getStartingPoint();
}
- public Location getCenter() {
- return new Location(this.world, (double) (this.xMax - this.xMin) / 2 + this.xMin, (double) (this.yMax - this.yMin) / 2 + this.yMin, (double) (this.zMax - this.zMin) / 2 + this.zMin);
- }
-
public double getDistanceBetweenPoints() {
return this.distanceBetweenPoints;
}
@@ -214,14 +210,6 @@ public Location getEndingPoint() {
return point2;
}
- public Location getRandomWithin() {
- Random r = new Random();
- int x = r.nextInt(Math.abs(this.xMax - this.xMin) + 1) + this.xMin;
- int y = r.nextInt(Math.abs(this.yMax - this.yMin) + 1) + this.yMin;
- int z = r.nextInt(Math.abs(this.zMax - this.zMin) + 1) + this.zMin;
- return new Location(this.world, x, y, z);
- }
-
public void setName(String name) {
this.name = name;
}
@@ -231,63 +219,23 @@ public String getName() {
}
@Override
- public Boundary getBoundary(Player target) {
- return new Boundary(xMax + 0.5, xMin + 0.5, yMax + 0.5, yMin + 0.5, zMax + 0.5, zMin + 0.5).target(target);
+ public VisualBoundary getBoundary(Player target) {
+ return new VisualBoundary(this.axis.getxMax() + 0.5, this.axis.getxMin() + 0.5, this.axis.getyMax() + 0.5, this.axis.getyMin() + 0.5, this.axis.getzMax() + 0.5, this.axis.getzMin() + 0.5).setViewer(target);
}
@Override
- public World getWorld() {
- return this.world;
+ public CuboidAxis getAxis() {
+ return this.axis;
}
@Override
- public int getHeight() {
- return height;
+ public CuboidLocation getLocation() {
+ return this.location;
}
@Override
public int getTotalBlocks() {
- return totalSize;
- }
-
- @Override
- public int getXWidth() {
- return xWidth;
- }
-
- @Override
- public int getZWidth() {
- return zWidth;
- }
-
- @Override
- public int xMax() {
- return xMax;
- }
-
- @Override
- public int xMin() {
- return xMin;
- }
-
- @Override
- public int yMax() {
- return yMax;
- }
-
- @Override
- public int yMin() {
- return yMin;
- }
-
- @Override
- public int zMax() {
- return zMax;
- }
-
- @Override
- public int zMin() {
- return zMin;
+ return this.axis.getTotalSize();
}
public OfflinePlayer getOwner() {
@@ -329,12 +277,12 @@ public boolean addFlag(Flag flag) {
return false;
}
- public boolean isPassthrough() {
- return passthrough;
+ public boolean isDominant() {
+ return this.dominant;
}
- public void setPassthrough(boolean passthrough) {
- this.passthrough = passthrough;
+ public void setDominant(boolean dominant) {
+ this.dominant = dominant;
}
public boolean addFlag(Flag... flag) {
@@ -387,18 +335,31 @@ public boolean removeMember(OfflinePlayer... p) {
return true;
}
- public boolean contains(final Location loc) {
- return loc.getWorld() == this.world && loc.getBlockX() >= this.xMin && loc.getBlockX() <= this.xMax && loc.getBlockY() >= this.yMin && loc.getBlockY() <= this.yMax && loc
- .getBlockZ() >= this.zMin && loc.getBlockZ() <= this.zMax;
+ public boolean contains(Block block) {
+ return block.getWorld() == this.location.getWorld() && block.getX() >= this.axis.getxMin() && block.getX() <= this.axis.getxMax() && block.getY() >= this.axis.getyMin() && block.getY() <= this.axis.getyMax() && block
+ .getZ() >= this.axis.getzMin() && block.getZ() <= this.axis.getzMax();
}
- public boolean contains(final Player player) {
+ public boolean contains(Location loc) {
+ return loc.getWorld() == this.location.getWorld() && loc.getBlockX() >= this.axis.getxMin() && loc.getBlockX() <= this.axis.getxMax() && loc.getBlockY() >= this.axis.getyMin() && loc.getBlockY() <= this.axis.getyMax() && loc
+ .getBlockZ() >= this.axis.getzMin() && loc.getBlockZ() <= this.axis.getzMax();
+ }
+
+ public boolean contains(Player player) {
return this.contains(player.getLocation());
}
- public boolean contains(final Location loc, double precision) {
- return loc.getWorld() == this.world && loc.getX() >= (xMin() + 0.5) - precision && loc.getX() <= (xMax() + 0.5) + precision && loc.getY() >= (yMin() + 0.5) - precision && loc
- .getY() <= (yMax() + 0.5) + precision && loc.getZ() >= (zMin() + 0.5) - precision && loc.getZ() <= (zMax() + 0.5) + precision;
+ public boolean contains(Block b, double precision) {
+ return contains(b.getLocation(), precision);
+ }
+
+ public boolean contains(Player p, double precision) {
+ return contains(p.getLocation(), precision);
+ }
+
+ public boolean contains(Location loc, double precision) {
+ return loc.getWorld() == this.location.getWorld() && loc.getX() >= (axis.getxMin() + 0.5) - precision && loc.getX() <= (axis.getxMax() + 0.5) + precision && loc.getY() >= (axis.getyMin() + 0.5) - precision && loc
+ .getY() <= (axis.getyMax() + 0.5) + precision && loc.getZ() >= (axis.getzMin() + 0.5) - precision && loc.getZ() <= (axis.getzMax() + 0.5) + precision;
}
public final boolean remove() {
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/CuboidSelectEvent.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/CuboidSelectEvent.java
index f889e410..01ac294a 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/CuboidSelectEvent.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/CuboidSelectEvent.java
@@ -1,6 +1,6 @@
package com.github.sanctum.labyrinth.event;
-import com.github.sanctum.labyrinth.library.Cuboid;
+import com.github.sanctum.labyrinth.data.CuboidSelection;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
@@ -9,9 +9,9 @@
public abstract class CuboidSelectEvent extends DefaultEvent.Player {
- private final Cuboid.Selection selection;
+ private final CuboidSelection selection;
- public CuboidSelectEvent(Cuboid.Selection selection) {
+ public CuboidSelectEvent(CuboidSelection selection) {
super(selection.getPlayer(), false);
this.selection = selection;
}
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionBuildEvent.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionBuildEvent.java
index 0ae2be78..975b1c2f 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionBuildEvent.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionBuildEvent.java
@@ -1,6 +1,6 @@
package com.github.sanctum.labyrinth.event;
-import com.github.sanctum.labyrinth.data.Region;
+import com.github.sanctum.labyrinth.data.container.Region;
import org.bukkit.block.Block;
public class RegionBuildEvent extends RegionInteractEvent {
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionDestroyEvent.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionDestroyEvent.java
index 12087bac..ec179266 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionDestroyEvent.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionDestroyEvent.java
@@ -1,6 +1,6 @@
package com.github.sanctum.labyrinth.event;
-import com.github.sanctum.labyrinth.data.Region;
+import com.github.sanctum.labyrinth.data.container.Region;
import org.bukkit.block.Block;
public class RegionDestroyEvent extends RegionInteractEvent {
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractEvent.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractEvent.java
index b93a15ac..01d8245c 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractEvent.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractEvent.java
@@ -1,6 +1,6 @@
package com.github.sanctum.labyrinth.event;
-import com.github.sanctum.labyrinth.data.Region;
+import com.github.sanctum.labyrinth.data.container.Region;
public abstract class RegionInteractEvent extends DefaultEvent.Player {
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractionEvent.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractionEvent.java
index ebaa33e1..3da06194 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractionEvent.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionInteractionEvent.java
@@ -1,6 +1,6 @@
package com.github.sanctum.labyrinth.event;
-import com.github.sanctum.labyrinth.data.Region;
+import com.github.sanctum.labyrinth.data.container.Region;
import org.bukkit.block.Block;
public class RegionInteractionEvent extends RegionInteractEvent {
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionPVPEvent.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionPVPEvent.java
index 16811c2f..61fb73c8 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionPVPEvent.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionPVPEvent.java
@@ -1,6 +1,6 @@
package com.github.sanctum.labyrinth.event;
-import com.github.sanctum.labyrinth.data.Region;
+import com.github.sanctum.labyrinth.data.container.Region;
import org.bukkit.inventory.ItemStack;
import java.util.Optional;
diff --git a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionTraverseEvent.java b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionTraverseEvent.java
index 06c0158c..29e7ca2e 100644
--- a/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionTraverseEvent.java
+++ b/labyrinth-regions/src/main/java/com/github/sanctum/labyrinth/event/RegionTraverseEvent.java
@@ -1,6 +1,6 @@
package com.github.sanctum.labyrinth.event;
-import com.github.sanctum.labyrinth.data.Region;
+import com.github.sanctum.labyrinth.data.container.Region;
public class RegionTraverseEvent extends DefaultEvent {
diff --git a/labyrinth-skulls/pom.xml b/labyrinth-skulls/pom.xml
index 75eec371..ea745c4e 100644
--- a/labyrinth-skulls/pom.xml
+++ b/labyrinth-skulls/pom.xml
@@ -5,7 +5,7 @@
labyrinth
com.github.the-h-team
- 1.9.1
+ 1.9.2
4.0.0
diff --git a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHead.java b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHead.java
index 1e94897f..e4ec6a16 100644
--- a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHead.java
+++ b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHead.java
@@ -120,17 +120,17 @@ static List loadOffline() {
if (players.length >= 500) {
Counter count = Counter.newInstance();
CollectionTask cache = CollectionTask.process(players, "USER-CACHE", 20, player -> {
- OnlineHeadSearch search = new OnlineHeadSearch(player.getUniqueId());
+ HeadLookup search = new HeadLookup(player.getUniqueId());
if (search.getResult() != null) {
if (player.getName() != null) {
- list.add(new LabyrinthHeadImpl(player.getName(), "Human", search.getResult(), player.getUniqueId()));
+ list.add(new DefaultHead(player.getName(), "Human", search.getResult(), player.getUniqueId()));
}
} else {
count.add();
- OnlineHeadSearch search2 = new OnlineHeadSearch(player.getName());
+ HeadLookup search2 = new HeadLookup(player.getName());
if (search2.getResult() != null) {
if (player.getName() != null) {
- list.add(new LabyrinthHeadImpl(player.getName(), "Deceased", search2.getResult()));
+ list.add(new DefaultHead(player.getName(), "Deceased", search2.getResult()));
}
}
}
@@ -152,17 +152,17 @@ static List loadOffline() {
TaskScheduler.of(() -> {
int count = 0;
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
- OnlineHeadSearch search = new OnlineHeadSearch(player.getUniqueId());
+ HeadLookup search = new HeadLookup(player.getUniqueId());
if (search.getResult() != null) {
if (player.getName() != null) {
- list.add(new LabyrinthHeadImpl(player.getName(), "Human", search.getResult(), player.getUniqueId()));
+ list.add(new DefaultHead(player.getName(), "Human", search.getResult(), player.getUniqueId()));
}
} else {
count++;
- OnlineHeadSearch search2 = new OnlineHeadSearch(player.getName());
+ HeadLookup search2 = new HeadLookup(player.getName());
if (search2.getResult() != null) {
if (player.getName() != null) {
- list.add(new LabyrinthHeadImpl(player.getName(), "Deceased", search2.getResult()));
+ list.add(new DefaultHead(player.getName(), "Deceased", search2.getResult()));
}
}
}
@@ -184,11 +184,11 @@ static List loadOffline() {
*/
public static void load(CustomHeadLoader loader) {
if (loader.isLoaded()) {
- for (Map.Entry entry : loader.getHeads().entrySet()) {
+ for (Map.Entry entry : loader.getHeads().entrySet()) {
load(entry.getKey().getName(), entry.getKey().getCategory(), entry.getValue());
}
} else {
- for (Map.Entry entry : loader.load().getHeads().entrySet()) {
+ for (Map.Entry entry : loader.load().getHeads().entrySet()) {
load(entry.getKey().getName(), entry.getKey().getCategory(), entry.getValue());
}
}
@@ -205,9 +205,9 @@ public static void load(CustomHeadLoader loader) {
public static @Nullable ItemStack get(OfflinePlayer player) {
return HEADS.stream().filter(h -> h.id().isPresent() && h.id().get().equals(player.getUniqueId())).map(CustomHead::get).findFirst().orElseGet(() -> {
- OnlineHeadSearch search = new OnlineHeadSearch(player.getUniqueId());
+ HeadLookup search = new HeadLookup(player.getUniqueId());
if (search.getResult() != null) {
- CustomHead head = new LabyrinthHeadImpl(player.getName(), "Human", search.getResult(), player.getUniqueId());
+ CustomHead head = new DefaultHead(player.getName(), "Human", search.getResult(), player.getUniqueId());
HEADS.add(head);
return head.get();
}
@@ -226,9 +226,9 @@ public static void load(CustomHeadLoader loader) {
public static @Nullable ItemStack get(UUID id) {
return HEADS.stream().filter(h -> h.id().isPresent() && h.id().get().equals(id)).map(CustomHead::get).findFirst().orElseGet(() -> {
- OnlineHeadSearch search = new OnlineHeadSearch(id);
+ HeadLookup search = new HeadLookup(id);
if (search.getResult() != null) {
- CustomHead head = new LabyrinthHeadImpl(Bukkit.getOfflinePlayer(id).getName(), "Human", search.getResult(), id);
+ CustomHead head = new DefaultHead(Bukkit.getOfflinePlayer(id).getName(), "Human", search.getResult(), id);
HEADS.add(head);
return head.get();
}
@@ -248,9 +248,9 @@ public static void load(CustomHeadLoader loader) {
return HEADS.stream().filter(h -> h.name().equals(name)).map(CustomHead::get).findFirst().orElseGet(() -> {
- OnlineHeadSearch search = new OnlineHeadSearch(name);
+ HeadLookup search = new HeadLookup(name);
if (search.getResult() != null) {
- CustomHead head = new LabyrinthHeadImpl(name, "Human", search.getResult());
+ CustomHead head = new DefaultHead(name, "Human", search.getResult());
HEADS.add(head);
return head.get();
}
@@ -269,9 +269,9 @@ public static void load(CustomHeadLoader loader) {
public static @Nullable CustomHead pick(String name) {
return HEADS.stream().filter(h -> h.name().equals(name)).findFirst().orElseGet(() -> {
- OnlineHeadSearch search = new OnlineHeadSearch(name);
+ HeadLookup search = new HeadLookup(name);
if (search.getResult() != null) {
- CustomHead head = new LabyrinthHeadImpl(name, "Human", search.getResult());
+ CustomHead head = new DefaultHead(name, "Human", search.getResult());
HEADS.add(head);
return head;
}
@@ -290,9 +290,9 @@ public static void load(CustomHeadLoader loader) {
public static @Nullable CustomHead pick(UUID id) {
return HEADS.stream().filter(h -> h.id().isPresent() && h.id().get().equals(id)).findFirst().orElseGet(() -> {
- OnlineHeadSearch search = new OnlineHeadSearch(id);
+ HeadLookup search = new HeadLookup(id);
if (search.getResult() != null) {
- CustomHead head = new LabyrinthHeadImpl(Bukkit.getOfflinePlayer(id).getName(), "Human", search.getResult(), id);
+ CustomHead head = new DefaultHead(Bukkit.getOfflinePlayer(id).getName(), "Human", search.getResult(), id);
HEADS.add(head);
return head;
}
@@ -311,9 +311,9 @@ public static void load(CustomHeadLoader loader) {
public static @Nullable CustomHead pick(OfflinePlayer player) {
return HEADS.stream().filter(h -> h.id().isPresent() && h.id().get().equals(player.getUniqueId())).findFirst().orElseGet(() -> {
- OnlineHeadSearch search = new OnlineHeadSearch(player.getUniqueId());
+ HeadLookup search = new HeadLookup(player.getUniqueId());
if (search.getResult() != null) {
- CustomHead head = new LabyrinthHeadImpl(player.getName(), "Human", search.getResult(), player.getUniqueId());
+ CustomHead head = new DefaultHead(player.getName(), "Human", search.getResult(), player.getUniqueId());
HEADS.add(head);
return head;
}
@@ -392,7 +392,7 @@ protected static void load(String name, String category, ItemStack item) {
if (item.getType() != type)
throw new IllegalStateException(item.getType().name() + " is not a direct representation of " + type.name());
- load(new LabyrinthHeadImpl(name, category, item));
+ load(new DefaultHead(name, category, item));
}
/**
diff --git a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHeadLoader.java b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHeadLoader.java
index 45afa11c..541d4025 100644
--- a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHeadLoader.java
+++ b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/CustomHeadLoader.java
@@ -24,18 +24,18 @@ public final class CustomHeadLoader {
private final MemorySpace memory;
private boolean loaded;
- private final Map que;
- private final Map additions;
+ private final Map queue;
+ private final Map additions;
- protected CustomHeadLoader(MemorySpace memory) {
+ public CustomHeadLoader(MemorySpace memory) {
this.memory = memory;
- this.que = new HashMap<>();
+ this.queue = new HashMap<>();
this.additions = new HashMap<>();
}
- protected CustomHeadLoader(Plugin plugin, String fileName, String directory) {
+ public CustomHeadLoader(Plugin plugin, String fileName, String directory) {
this.memory = FileList.search(plugin).get(fileName, directory).getRoot();
- this.que = new HashMap<>();
+ this.queue = new HashMap<>();
this.additions = new HashMap<>();
}
@@ -64,7 +64,7 @@ public CustomHeadLoader look(String section) {
}
if (value != null) {
- additions.put(new HeadText(name, category), provide(value));
+ additions.put(new HeadContext(name, category), provide(value));
} else {
LabyrinthProvider.getInstance().getLogger().severe("- Custom head #" + id + " has no value to use.");
}
@@ -77,9 +77,9 @@ public CustomHeadLoader look(String section) {
boolean isID = user != null && user.contains("-");
if (isID) {
- que.put(new HeadText(name, category), new OnlineHeadSearch(UUID.fromString(user)));
+ queue.put(new HeadContext(name, category), new HeadLookup(UUID.fromString(user)));
} else {
- que.put(new HeadText(name, category), new OnlineHeadSearch(user));
+ queue.put(new HeadContext(name, category), new HeadLookup(user));
}
}
}
@@ -92,7 +92,7 @@ public CustomHeadLoader look(String section) {
*/
public CustomHeadLoader load() {
this.loaded = true;
- for (Map.Entry entry : this.que.entrySet()) {
+ for (Map.Entry entry : this.queue.entrySet()) {
ItemStack result = entry.getValue().getResult();
if (result != null) {
this.additions.put(entry.getKey(), result);
@@ -114,7 +114,7 @@ public void complete() {
}
}
- Map getHeads() {
+ Map getHeads() {
return this.additions;
}
diff --git a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/LabyrinthHeadImpl.java b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/DefaultHead.java
similarity index 71%
rename from labyrinth-skulls/src/main/java/com/github/sanctum/skulls/LabyrinthHeadImpl.java
rename to labyrinth-skulls/src/main/java/com/github/sanctum/skulls/DefaultHead.java
index 42bc09fe..561390f4 100644
--- a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/LabyrinthHeadImpl.java
+++ b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/DefaultHead.java
@@ -5,7 +5,7 @@
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("SameParameterValue")
-final class LabyrinthHeadImpl extends CustomHead {
+final class DefaultHead extends CustomHead {
private final String name;
@@ -13,13 +13,13 @@ final class LabyrinthHeadImpl extends CustomHead {
private final ItemStack item;
- LabyrinthHeadImpl(@NotNull String name, @NotNull String category, @NotNull ItemStack item) {
+ DefaultHead(@NotNull String name, @NotNull String category, @NotNull ItemStack item) {
this.name = name;
this.category = category;
this.item = item;
}
- LabyrinthHeadImpl(@NotNull String name,@NotNull String category, @NotNull ItemStack item, @NotNull UUID owner) {
+ DefaultHead(@NotNull String name, @NotNull String category, @NotNull ItemStack item, @NotNull UUID owner) {
super(owner);
this.category = category;
this.name = name;
diff --git a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadText.java b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadContext.java
similarity index 78%
rename from labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadText.java
rename to labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadContext.java
index d0c058a3..3dfad6de 100644
--- a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadText.java
+++ b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadContext.java
@@ -1,12 +1,12 @@
package com.github.sanctum.skulls;
-final class HeadText {
+final class HeadContext {
private final String name;
private final String category;
- HeadText(String name, String category) {
+ HeadContext(String name, String category) {
this.name = name;
this.category = category;
}
diff --git a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/OnlineHeadSearch.java b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadLookup.java
similarity index 97%
rename from labyrinth-skulls/src/main/java/com/github/sanctum/skulls/OnlineHeadSearch.java
rename to labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadLookup.java
index aae37220..f37b7430 100644
--- a/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/OnlineHeadSearch.java
+++ b/labyrinth-skulls/src/main/java/com/github/sanctum/skulls/HeadLookup.java
@@ -15,14 +15,14 @@
/**
* Encapsulate player data and search online for skin results.
*/
-public class OnlineHeadSearch {
+public class HeadLookup {
protected String name = null;
protected String id = null;
protected String value = null;
// TODO: throw to prevent invalid object state and allow field finality
- public OnlineHeadSearch(String name) {
+ public HeadLookup(String name) {
this.name = name;
try {
Gson g = new Gson();
@@ -42,7 +42,7 @@ public OnlineHeadSearch(String name) {
}
// TODO: throw to prevent invalid object state and allow field finality
- public OnlineHeadSearch(UUID id) {
+ public HeadLookup(UUID id) {
try {
Gson g = new Gson();
String signature = getSessionContent(id.toString());
diff --git a/pom.xml b/pom.xml
index d6847a5f..09e4c5ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.github.the-h-team
labyrinth
- 1.9.1
+ 1.9.2
labyrinth-common
labyrinth-gui