diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index b5a9b55..92ec00e 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -7,11 +7,13 @@
+
+
@@ -19,12 +21,13 @@
+
+
-
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index eb01761..d8596c3 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -27,6 +27,12 @@
+
+
+
+
+
+
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index acf30f2..32d1c05 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -6,11 +6,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -21,6 +36,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 45df124..2f5b1f1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,3 +1,4 @@
+
@@ -11,7 +12,6 @@
-
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index a54855d..464b262 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -15,7 +15,11 @@
+
+
+
+
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/1_14_R1/pom.xml b/1_14_R1/pom.xml
index 6eb403f..d872246 100644
--- a/1_14_R1/pom.xml
+++ b/1_14_R1/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_14_R1
diff --git a/1_15_R1/pom.xml b/1_15_R1/pom.xml
index 702ed3b..c99012d 100644
--- a/1_15_R1/pom.xml
+++ b/1_15_R1/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_15_R1
diff --git a/1_16_R1/pom.xml b/1_16_R1/pom.xml
index c920397..4878bdf 100644
--- a/1_16_R1/pom.xml
+++ b/1_16_R1/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_16_R1
diff --git a/1_16_R2/pom.xml b/1_16_R2/pom.xml
index d0c0956..2cb24d8 100644
--- a/1_16_R2/pom.xml
+++ b/1_16_R2/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_16_R2
diff --git a/1_16_R3/pom.xml b/1_16_R3/pom.xml
index 4240b78..819828d 100644
--- a/1_16_R3/pom.xml
+++ b/1_16_R3/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_16_R3
diff --git a/1_17_R1/pom.xml b/1_17_R1/pom.xml
index dd90bfe..5ba5f5f 100644
--- a/1_17_R1/pom.xml
+++ b/1_17_R1/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_17_R1
diff --git a/1_18_R1/pom.xml b/1_18_R1/pom.xml
index 8edaff4..d430adb 100644
--- a/1_18_R1/pom.xml
+++ b/1_18_R1/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_18_R1
diff --git a/1_18_R2/pom.xml b/1_18_R2/pom.xml
index bec8b6b..5e22da4 100644
--- a/1_18_R2/pom.xml
+++ b/1_18_R2/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_18_R2
diff --git a/1_19_R1/pom.xml b/1_19_R1/pom.xml
index af8271c..9351817 100644
--- a/1_19_R1/pom.xml
+++ b/1_19_R1/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_19_R1
diff --git a/1_19_R2/pom.xml b/1_19_R2/pom.xml
index 21afa2f..1d07aa5 100644
--- a/1_19_R2/pom.xml
+++ b/1_19_R2/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_19_R2
diff --git a/1_19_R3/pom.xml b/1_19_R3/pom.xml
index f24ec30..4837d20 100644
--- a/1_19_R3/pom.xml
+++ b/1_19_R3/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_19_R3
diff --git a/1_20_R1/pom.xml b/1_20_R1/pom.xml
index 314f83d..9521acd 100644
--- a/1_20_R1/pom.xml
+++ b/1_20_R1/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_20_R1
@@ -20,7 +20,7 @@
org.spigotmc
spigot
- 1.20-R0.1-SNAPSHOT
+ 1.20.1-R0.1-SNAPSHOT
provided
diff --git a/1_20_R2/pom.xml b/1_20_R2/pom.xml
index 91273c3..15a7e10 100644
--- a/1_20_R2/pom.xml
+++ b/1_20_R2/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_20_R2
diff --git a/1_20_R3/1_20_R3.iml b/1_20_R3/1_20_R3.iml
new file mode 100644
index 0000000..662e239
--- /dev/null
+++ b/1_20_R3/1_20_R3.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ SPIGOT
+
+ 1
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1_20_R3/pom.xml b/1_20_R3/pom.xml
index fcbb855..6fd0e15 100644
--- a/1_20_R3/pom.xml
+++ b/1_20_R3/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
1_20_R3
diff --git a/1_20_R3/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_20_R3.java b/1_20_R3/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_20_R3.java
index 0d9ae8d..4fb7f48 100644
--- a/1_20_R3/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_20_R3.java
+++ b/1_20_R3/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_20_R3.java
@@ -34,11 +34,11 @@ public void openBeaconMenu(Block beacon, Player player) {
BlockPosition blockPosition = new BlockPosition(beaconLoc.getBlockX(), beaconLoc.getBlockY(), beaconLoc.getBlockZ());
EntityPlayer playerHandle = ((CraftPlayer) player).getHandle();
net.minecraft.world.level.block.Block beaconHandle = ((CraftBlock) beacon).getNMS().b(); //b(): getBlock()
- ItemStack itemStackHandle = playerHandle.fS().f(); //fN().f(): getInventory().getSelected()
+ ItemStack itemStackHandle = playerHandle.fS().f(); //fS().f(): getInventory().getSelected()
MovingObjectPositionBlock blockHitResult = new MovingObjectPositionBlock(blockLocVec3D, EnumDirection.b, blockPosition, true); //EnumDirection.b: EnumDirection.UP
BlockActionContext blockPlaceContext = new BlockActionContext(playerHandle, EnumHand.a, itemStackHandle, blockHitResult); //EnumHand.a: EnumHand.MAIN_HAND
IBlockData blockState = beaconHandle.a(blockPlaceContext); //a(): getPlacedState()
- World levelHandle = playerHandle.dM(); //x(): getWorld()
+ World levelHandle = playerHandle.dM(); //dM(): getWorld()
beaconHandle.a(blockState, levelHandle, blockPosition, playerHandle, EnumHand.a, blockHitResult); //a(): interact(), EnumHand.a: EnumHand.MAIN_HAND
}
diff --git a/1_20_R4.iml b/1_20_R4.iml
new file mode 100644
index 0000000..b6c607e
--- /dev/null
+++ b/1_20_R4.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ MCP
+
+ 1
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1_20_R4/pom.xml b/1_20_R4/pom.xml
new file mode 100644
index 0000000..3550979
--- /dev/null
+++ b/1_20_R4/pom.xml
@@ -0,0 +1,44 @@
+
+ 4.0.0
+
+
+ BeaconWaypoints
+ com.github.dawsonvilamaa
+ 1.7
+
+
+ 1_20_R4
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+
+
+
+ org.spigotmc
+ spigot
+ 1.20.6-R0.1-SNAPSHOT
+ provided
+
+
+ com.github.dawsonvilamaa
+ core
+ ${project.parent.version}
+ compile
+
+
+ com.github.dawsonvilamaa
+ VersionWrapper
+ ${project.parent.version}
+ compile
+
+
+
+
+ 17
+ 17
+
+
\ No newline at end of file
diff --git a/1_20_R4/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_20_R4.java b/1_20_R4/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_20_R4.java
new file mode 100644
index 0000000..24f217c
--- /dev/null
+++ b/1_20_R4/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_20_R4.java
@@ -0,0 +1,47 @@
+package com.github.dawsonvilamaa.beaconwaypoint.version;
+
+
+import net.minecraft.core.BlockPosition;
+import net.minecraft.server.level.EntityPlayer;
+import net.minecraft.world.inventory.Container;
+import net.minecraft.world.level.World;
+import net.minecraft.world.level.block.entity.TileEntity;
+import net.minecraft.world.level.block.entity.TileEntityBeacon;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class Version_1_20_R4 implements VersionWrapper{
+ /**
+ * Opens the vanilla beacon GUI for a player
+ *
+ * @param beacon
+ * @param player
+ */
+ @Override
+ public void openBeaconMenu(Block beacon, Player player) {
+ Location beaconLoc = beacon.getLocation();
+ BlockPosition blockPosition = new BlockPosition(beaconLoc.getBlockX(), beaconLoc.getBlockY(), beaconLoc.getBlockZ());
+ EntityPlayer playerHandle = ((CraftPlayer) player).getHandle();
+ World levelHandle = playerHandle.dP(); //dP(): getWorld()
+ TileEntity beaconTileHandle = levelHandle.getBlockEntity(blockPosition, false);
+ Container containerHandle = ((TileEntityBeacon) beaconTileHandle).createMenu(playerHandle.nextContainerCounter(), playerHandle.gc(), playerHandle); //gc(): getInventory()
+ playerHandle.a(containerHandle); //a(): initMenu()
+ playerHandle.a((TileEntityBeacon) beaconTileHandle); //a(): openMenu()
+ }
+
+ /**
+ * Returns the blocks available to be used in a beacon pyramid
+ *
+ * @return
+ */
+ @Override
+ public List getPyramidBlocks() {
+ return Arrays.asList(Material.IRON_BLOCK, Material.GOLD_BLOCK, Material.DIAMOND_BLOCK, Material.EMERALD_BLOCK, Material.NETHERITE_BLOCK);
+ }
+}
\ No newline at end of file
diff --git a/1_21_R1.iml b/1_21_R1.iml
new file mode 100644
index 0000000..b6c607e
--- /dev/null
+++ b/1_21_R1.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ MCP
+
+ 1
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1_21_R1/pom.xml b/1_21_R1/pom.xml
new file mode 100644
index 0000000..addb740
--- /dev/null
+++ b/1_21_R1/pom.xml
@@ -0,0 +1,44 @@
+
+ 4.0.0
+
+
+ BeaconWaypoints
+ com.github.dawsonvilamaa
+ 1.7
+
+
+ 1_21_R1
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+
+
+
+ org.spigotmc
+ spigot
+ 1.21-R0.1-SNAPSHOT
+ provided
+
+
+ com.github.dawsonvilamaa
+ core
+ ${project.parent.version}
+ compile
+
+
+ com.github.dawsonvilamaa
+ VersionWrapper
+ ${project.parent.version}
+ compile
+
+
+
+
+ 17
+ 17
+
+
\ No newline at end of file
diff --git a/1_21_R1/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_21_R1.java b/1_21_R1/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_21_R1.java
new file mode 100644
index 0000000..fa1742d
--- /dev/null
+++ b/1_21_R1/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/Version_1_21_R1.java
@@ -0,0 +1,55 @@
+package com.github.dawsonvilamaa.beaconwaypoint.version;
+
+import net.minecraft.core.BlockPosition;
+import net.minecraft.core.EnumDirection;
+import net.minecraft.server.level.EntityPlayer;
+import net.minecraft.world.EnumHand;
+import net.minecraft.world.entity.player.EntityHuman;
+import net.minecraft.world.inventory.Container;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.context.BlockActionContext;
+import net.minecraft.world.level.World;
+import net.minecraft.world.level.block.entity.TileEntity;
+import net.minecraft.world.level.block.entity.TileEntityBeacon;
+import net.minecraft.world.level.block.state.IBlockData;
+import net.minecraft.world.phys.MovingObjectPositionBlock;
+import net.minecraft.world.phys.Vec3D;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_21_R1.block.CraftBlock;
+import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class Version_1_21_R1 implements VersionWrapper{
+ /**
+ * Opens the vanilla beacon GUI for a player
+ *
+ * @param beacon
+ * @param player
+ */
+ @Override
+ public void openBeaconMenu(Block beacon, Player player) {
+ Location beaconLoc = beacon.getLocation();
+ BlockPosition blockPosition = new BlockPosition(beaconLoc.getBlockX(), beaconLoc.getBlockY(), beaconLoc.getBlockZ());
+ EntityPlayer playerHandle = ((CraftPlayer) player).getHandle();
+ World levelHandle = playerHandle.dO(); //dO(): getWorld()
+ TileEntity beaconTileHandle = levelHandle.getBlockEntity(blockPosition, false);
+ Container containerHandle = ((TileEntityBeacon) beaconTileHandle).createMenu(playerHandle.nextContainerCounter(), playerHandle.fY(), playerHandle); //fY(): getInventory()
+ playerHandle.a(containerHandle); //a(): initMenu()
+ playerHandle.a((TileEntityBeacon) beaconTileHandle); //a(): openMenu()
+ }
+
+ /**
+ * Returns the blocks available to be used in a beacon pyramid
+ *
+ * @return
+ */
+ @Override
+ public List getPyramidBlocks() {
+ return Arrays.asList(Material.IRON_BLOCK, Material.GOLD_BLOCK, Material.DIAMOND_BLOCK, Material.EMERALD_BLOCK, Material.NETHERITE_BLOCK);
+ }
+}
\ No newline at end of file
diff --git a/Build/Build.iml b/Build/Build.iml
new file mode 100644
index 0000000..a589521
--- /dev/null
+++ b/Build/Build.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ SPIGOT
+
+ 1
+
+
+
+
\ No newline at end of file
diff --git a/Build/dependency-reduced-pom.xml b/Build/dependency-reduced-pom.xml
index 85eed83..a3d2da4 100644
--- a/Build/dependency-reduced-pom.xml
+++ b/Build/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.4
+ 1.7
4.0.0
Build
diff --git a/Build/pom.xml b/Build/pom.xml
index 6ec749a..ffe58dc 100644
--- a/Build/pom.xml
+++ b/Build/pom.xml
@@ -5,7 +5,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
4.0.0
@@ -108,6 +108,18 @@
${project.parent.version}
compile
+
+ com.github.dawsonvilamaa
+ 1_20_R4
+ ${project.parent.version}
+ compile
+
+
+ com.github.dawsonvilamaa
+ 1_21_R1
+ ${project.parent.version}
+ compile
+
diff --git a/README.md b/README.md
index 5e1a338..74d5749 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
[CurseForge page](https://www.curseforge.com/minecraft/bukkit-plugins/beaconwaypoints)
-Supports versions 1.14-1.20.4
+Supports versions 1.14-1.20.6
This plugin uses bStats.
@@ -20,6 +20,7 @@ This plugin uses bStats.
## Commands
- /waypoint - Create a public or private waypoint for the beacon the player is standing on
- /waypoints reload - Reloads the config
+- /waypoint share - share private waypoints with other players
## Demo
@@ -73,6 +74,20 @@ Note: If WorldEdit is used to delete a beacon, the waypoint will not be deleted.
## Changelog
+### 1.7
+Changes:
+- Added support for 1.20.6
+- Added private waypoint sharing
+- Usage: /waypoint share
+- Shared private waypoints will appear in the other player's private waypoint list
+- Remove player access in the waypoint options menu
+- Added more checks and default fallbacks for any missing plugin data or config items
+- A beacon no longer needs a public waypoint associated with it to open the waypoint menu, though it still requires at least one public or private waypoint. This may change to have no restrictions in a future update so that any beacon can be used to teleport, even if it doesn't have any waypoint set
+
+Fixes:
+- Messages are now properly sent to waypoint owner(s) when a beacon with waypoints is broken
+- Players are no able to take items from inventory menus if there is an error on a click event
+
### 1.6.5
Changes:
- Added support for 1.20.4
diff --git a/VersionWrapper/pom.xml b/VersionWrapper/pom.xml
index 271141c..aba745d 100644
--- a/VersionWrapper/pom.xml
+++ b/VersionWrapper/pom.xml
@@ -5,7 +5,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
4.0.0
@@ -14,7 +14,7 @@
org.spigotmc
- spigot
+ spigot-api
1.14-R0.1-SNAPSHOT
provided
diff --git a/VersionWrapper/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/VersionMatcher.java b/VersionWrapper/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/VersionMatcher.java
index 3fba8a8..e232de0 100644
--- a/VersionWrapper/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/VersionMatcher.java
+++ b/VersionWrapper/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/version/VersionMatcher.java
@@ -5,14 +5,53 @@
//based on AnvilGUI VersionMatcher: https://github.com/WesJD/AnvilGUI/blob/master/api/src/main/java/net/wesjd/anvilgui/version/VersionMatcher.java
public class VersionMatcher {
public VersionWrapper match() {
- final String serverVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].substring(1);
+ String serverVersion = Bukkit.getServer().getBukkitVersion();
+ String nmsVersion = "";
+ if (serverVersion.startsWith("1.14"))
+ nmsVersion = "1_14_R1";
+ else if (serverVersion.startsWith("1.15"))
+ nmsVersion = "1_14_R1";
+ else if (serverVersion.startsWith("1.16.1"))
+ nmsVersion = "1_16_R1";
+ else if (serverVersion.startsWith("1.16.2") || serverVersion.startsWith("1.16.3"))
+ nmsVersion = "1_16_R2";
+ else if (serverVersion.startsWith("1.16.4") || serverVersion.startsWith("1.16.5"))
+ nmsVersion = "1_16_R3";
+ else if (serverVersion.startsWith("1.17"))
+ nmsVersion = "1_17_R1";
+ else if (serverVersion.startsWith("1.18-") || serverVersion.startsWith("1.18.1"))
+ nmsVersion = "1_18_R1";
+ else if (serverVersion.startsWith("1.18.2"))
+ nmsVersion = "1_18_R2";
+ else if (serverVersion.startsWith("1.19-") || serverVersion.startsWith("1.19.1") || serverVersion.startsWith("1.19.2"))
+ nmsVersion = "1_19_R1";
+ else if (serverVersion.startsWith("1.19.3"))
+ nmsVersion = "1_19_R2";
+ else if (serverVersion.startsWith("1.19.4"))
+ nmsVersion = "1_19_R3";
+ else if (serverVersion.startsWith("1.20-") || serverVersion.startsWith("1.20.1"))
+ nmsVersion = "1_20_R1";
+ else if (serverVersion.startsWith("1.20.2"))
+ nmsVersion = "1_20_R2";
+ else if (serverVersion.startsWith("1.20.3") || serverVersion.startsWith("1.20.4"))
+ nmsVersion = "1_20_R3";
+ else if (serverVersion.startsWith("1.20.6"))
+ nmsVersion = "1_20_R4";
+ else if (serverVersion.startsWith("1.21"))
+ nmsVersion = "1_21_R1";
+ else {
+ Bukkit.getLogger().severe("BeaconWaypoints does not support version " + serverVersion);
+ return null;
+ }
+
+ //final String serverVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].substring(1);
Bukkit.getLogger().info("[BeaconWaypoints] Loading module for version " + serverVersion);
try {
- return (VersionWrapper) Class.forName(getClass().getPackage().getName() + ".Version_" + serverVersion).newInstance();
+ return (VersionWrapper) Class.forName(getClass().getPackage().getName() + ".Version_" + nmsVersion).newInstance();
} catch (IllegalAccessException | InstantiationException exception) {
- throw new IllegalStateException("Failed to instantiate version wrapper for version " + serverVersion, exception);
+ throw new IllegalStateException("[BeaconWaypoints] Failed to instantiate version wrapper for version " + serverVersion + " (" + nmsVersion + ")", exception);
} catch (ClassNotFoundException exception) {
- throw new IllegalStateException("BeaconWaypoints does not support server version \"" + serverVersion + "\"", exception);
+ throw new IllegalStateException("BeaconWaypoints does not support server version " + serverVersion + " (" + nmsVersion + ")", exception);
}
}
}
diff --git a/changelog.txt b/changelog.txt
index b068ccf..807aa06 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,4 +1,17 @@
Changes:
-- Added support for 1.20.2
-- The compass is no longer visible if a multi-page menu only has one page
-- Changed the wording of the message given when a player cannot teleport to make more sense
\ No newline at end of file
+ - Added support for 1.20.6*
+ - Added private waypoint sharing
+ - Usage: /waypoint share
+ - Shared private waypoints will appear in the other player's private waypoint list
+ - Remove player access in the waypoint options menu
+ - Added more checks and default fallbacks for any missing plugin data or config items
+ - A beacon no longer needs a public waypoint associated with it to open the waypoint menu, though it still requires at least one public or private waypoint. This may change to have no restrictions in a future update so that any beacon can be used to teleport, even if it doesn't have any waypoint set
+
+Fixes:
+ - Messages are now properly sent to waypoint owner(s) when a beacon with waypoints is broken
+ - Players are no able to take items from inventory menus if there is an error on a click event
+
+NOTE:
+*This update also adds support for 1.21, but player heads will show as default skins. This will affect back and forward menu buttons as well as player heads in the waypoint sharing menu. I will try to find an alternative way to load player skulls for 1.21+.
+
+I recommend backing your plugin data in case upgrading to this version breaks something. I thoroughly tested upgrading versions and making sure it filled in missing language and config values wherever it could, but you should probably back up just in case.
\ No newline at end of file
diff --git a/core/dependency-reduced-pom.xml b/core/dependency-reduced-pom.xml
index 6c380f1..f757d75 100644
--- a/core/dependency-reduced-pom.xml
+++ b/core/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.4
+ 1.7
4.0.0
core
@@ -44,6 +44,18 @@
paper-repo
https://papermc.io/repo/repository/maven-public/
+
+ md_5-snapshots
+ https://repo.md-5.net/content/repositories/snapshots/
+
+
+ md_5-releases
+ https://repo.md-5.net/content/repositories/releases/
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/groups/public/
+
@@ -67,7 +79,7 @@
org.bstats
bstats-bukkit
- 3.0.0
+ 3.0.2
provided
diff --git a/core/pom.xml b/core/pom.xml
index f06257f..a52f0ad 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -4,7 +4,7 @@
BeaconWaypoints
com.github.dawsonvilamaa
- 1.6.5
+ 1.7
core
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/BWCommandExecutor.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/BWCommandExecutor.java
index 3207863..41bc0bc 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/BWCommandExecutor.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/BWCommandExecutor.java
@@ -62,8 +62,6 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (args.length < 2)
return false;
- //CHECK IF THE PLAYER ALREADY HAS THIS WAYPOINT SHARED
-
UUID playerUUID;
//username
@@ -132,14 +130,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
//check if public waypoint list is full
if (!plugin.getConfig().contains("max-public-waypoints"))
plugin.getConfig().set("max-public-waypoints", 100);
- else {
- int maxPublicWaypoints = plugin.getConfig().getInt("max-public-waypoints");
- if (maxPublicWaypoints < 0)
- maxPublicWaypoints = 0;
- if (waypointManager.getPublicWaypoints().values().size() == maxPublicWaypoints) {
- player.sendMessage(ChatColor.RED + languageManager.getString("public-list-full"));
- return true;
- }
+
+ int maxPublicWaypoints = plugin.getConfig().getInt("max-public-waypoints");
+ if (maxPublicWaypoints < 0)
+ maxPublicWaypoints = 0;
+ if (waypointManager.getPublicWaypoints().values().size() == maxPublicWaypoints) {
+ player.sendMessage(ChatColor.RED + languageManager.getString("public-list-full"));
+ return true;
}
if (waypointManager.getPublicWaypoint(playerLoc) != null)
@@ -148,17 +145,16 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
//check if private waypoint list is full
if (!plugin.getConfig().contains("max-private-waypoints"))
plugin.getConfig().set("max-private-waypoints", 30);
- else {
- int maxPrivateWaypoints = plugin.getConfig().getInt("max-private-waypoints");
- if (maxPrivateWaypoints < 0)
- maxPrivateWaypoints = 0;
- if (waypointManager.getPrivateWaypoints(player.getUniqueId()).values().size() == maxPrivateWaypoints) {
- player.sendMessage(ChatColor.RED + languageManager.getString("private-list-full"));
- return true;
- }
- if (waypointManager.getPrivateWaypoint(player.getUniqueId(), playerLoc) != null)
- waypointExists = true;
+
+ int maxPrivateWaypoints = plugin.getConfig().getInt("max-private-waypoints");
+ if (maxPrivateWaypoints < 0)
+ maxPrivateWaypoints = 0;
+ if (waypointManager.getPrivateWaypoints(player.getUniqueId()).values().size() == maxPrivateWaypoints) {
+ player.sendMessage(ChatColor.RED + languageManager.getString("private-list-full"));
+ return true;
}
+ if (waypointManager.getPrivateWaypoint(player.getUniqueId(), playerLoc) != null)
+ waypointExists = true;
}
if (waypointExists) {
@@ -207,6 +203,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
else {
newWaypoint = new Waypoint(player.getUniqueId(), new WaypointCoord(playerLoc));
+ newWaypoint.addPlayerDiscovered(player);
}
newWaypoint.setName(fullWaypointName.toString());
newWaypoint.setIsWaypoint(true);
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/ConfigUpdater.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/ConfigUpdater.java
index aa8a08e..8c04d25 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/ConfigUpdater.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/ConfigUpdater.java
@@ -67,7 +67,7 @@ public static void checkConfig(FileConfiguration config) throws IOException {
"disable-group-teleporting: false";
}
if (!configStr.contains("allow-beacon-break-by-owner:")) {
- configStr += "\n\n# If the BeaconWaypoints.removeWaypoints permission is disabled for a player, this will still allow them to break\n" +
+ configStr += "\n\n# If the BeaconWaypoints.breakWaypointBeacons permission is disabled for a player, this will still allow them to break\n" +
"# a beacon if all waypoints attached to it are owned by them. The owner of a beacon is the player who placed it.\n" +
"allow-beacon-break-by-owner: true";
}
@@ -335,6 +335,10 @@ public static void checkLanguageConfig(FileConfiguration config) throws IOExcept
configStr += "\ndistance: Distance";
if (!configStr.contains("download-link:"))
configStr += "\ndownload-link: Download link";
+ if (!configStr.contains("error-reading-players-discovered:"))
+ configStr += "\nerror-reading-players-discovered: Error while reading players discovered. Check the save files for incorrect player UUIDs";
+ if (!configStr.contains("error-reading-shared-player:"))
+ configStr += "\nerror-reading-shared-player: Error while reading shared player. Check the save files for incorrect player UUIDs";
if (!configStr.contains("essentials-not-installed"))
configStr += "\nessentials-not-installed: EssentialsX is not installed, ignoring Essentials money cost for teleporting.";
if (!configStr.contains("has-banned-items:"))
@@ -351,12 +355,18 @@ public static void checkLanguageConfig(FileConfiguration config) throws IOExcept
configStr += "\ninvalid-name-alphanumeric: Waypoint names must be 30 characters or fewer and can only contain letters, numbers, spaces, underscores, and hyphens.";
if (!configStr.contains("manage-access:"))
configStr += "\nmanage-access: Manage access";
+ if (!configStr.contains("missing-attribute:"))
+ configStr += "\nmissing-attribute: Waypoint is missing attribute";
+ if (!configStr.contains("missing-attributes:"))
+ configStr += "\nmissing-attributes: A waypoint is missing one or more attributes. Check the save files";
if (!configStr.contains("name-taken:"))
configStr += "\nname-taken: There is already a public waypoint of that name";
if (!configStr.contains("new-version-available:"))
configStr += "\nnew-version-available: A new version of Beacon Waypoints is available!";
if (!configStr.contains("next-page:"))
configStr += "\nnext-page: Next Page";
+ if (!configStr.contains("no-access-to-private-waypoint:"))
+ configStr += "\nno-access-to-private-waypoint: You do not have access to the private waypoint";
if (!configStr.contains("no-break-permission:"))
configStr += "\nno-break-permission: You do not have permission to break beacons that have waypoints set";
if (!configStr.contains("no-command-permission:"))
@@ -379,10 +389,14 @@ public static void checkLanguageConfig(FileConfiguration config) throws IOExcept
configStr += "\npayment-mode-not-found: Payment mode not recognized, defaulting to \"none\"";
if (!configStr.contains("pinned:"))
configStr += "\npinned: pinned";
+ if (!configStr.contains("pinned-default:"))
+ configStr += "\npinned-default: Waypoint is missing attribute 'pinned', setting to default false";
if (!configStr.contains("pin-waypoint:"))
configStr += "\npin-waypoint: Pin waypoint";
if (!configStr.contains("player-not-found:"))
configStr += "\nplayer-not-found: That player cannot be found or is offline";
+ if (!configStr.contains("players-discovered-default:"))
+ configStr += "\nplayers-discovered-default: Waypoint is missing attribute 'playersDiscovered', setting to default empty list";
if (!configStr.contains("previous-page:"))
configStr += "\nprevious-page: Previous Page";
if (!configStr.contains("private-list-full:"))
@@ -400,7 +414,7 @@ public static void checkLanguageConfig(FileConfiguration config) throws IOExcept
if (!configStr.contains("public-waypoints:"))
configStr += "\npublic-waypoints: Public Waypoints";
if (!configStr.contains("click-to-remove-access:"))
- configStr += "\nremove-access: Click to remove access";
+ configStr += "\nclick-to-remove-access: Click to remove access";
if (!configStr.contains("remove-access:"))
configStr += "\nremove-access-for-player: Remove access";
if (!configStr.contains("removed-private-waypoint:"))
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/Main.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/Main.java
index 1366409..9ebfb5b 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/Main.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/Main.java
@@ -53,78 +53,84 @@ public void onEnable() {
//get version wrapper
versionWrapper = new VersionMatcher().match();
+ if (versionWrapper == null) {
+ this.setEnabled(false);
+ }
+ else {
+ //bStats
+ Metrics metrics = new Metrics(this, 14276);
+ metrics.addCustomChart(new Metrics.SingleLineChart("waypoints", new Callable() {
+ @Override
+ public Integer call() throws Exception {
+ return waypointManager.getPublicWaypoints().size() + waypointManager.getNumPrivateWaypoints();
+ }
+ }));
- //bStats
- Metrics metrics = new Metrics(this, 14276);
- metrics.addCustomChart(new Metrics.SingleLineChart("waypoints", new Callable() {
- @Override
- public Integer call() throws Exception {
- return waypointManager.getPublicWaypoints().size() + waypointManager.getNumPrivateWaypoints();
- }
- }));
+ //register commands
+ BWCommandExecutor commandExecutor = new BWCommandExecutor(this);
+ Objects.requireNonNull(getCommand("waypoint")).setExecutor(commandExecutor);
- //register commands
- BWCommandExecutor commandExecutor = new BWCommandExecutor(this);
- Objects.requireNonNull(getCommand("waypoint")).setExecutor(commandExecutor);
+ //register events
+ PluginManager pm = getServer().getPluginManager();
+ pm.registerEvents(worldListener, this);
+ pm.registerEvents(inventoryListener, this);
- //register events
- PluginManager pm = getServer().getPluginManager();
- pm.registerEvents(worldListener, this);
- pm.registerEvents(inventoryListener, this);
+ //create data folder if it doesn't exist
+ if (!getDataFolder().exists())
+ getDataFolder().mkdirs();
- //create data folder if it doesn't exist
- if (!getDataFolder().exists())
- getDataFolder().mkdirs();
+ //create config file if it doesn't exist
+ if (!new File(getDataFolder(), "config.yml").exists())
+ saveDefaultConfig();
- //create config file if it doesn't exist
- if (!new File(getDataFolder(), "config.yml").exists())
- saveDefaultConfig();
+ //load language config
+ loadLanguage();
- //load language config
- loadLanguage();
+ //config update checker
+ try {
+ ConfigUpdater.checkConfig(getConfig());
+ } catch (IOException e) {
+ getLogger().warning("Unable to run the update checker for config.yml");
+ }
- //config update checker
- try {
- ConfigUpdater.checkConfig(getConfig());
- } catch (IOException e) {
- getLogger().warning("Unable to run the update checker for config.yml");
- }
+ try {
+ ConfigUpdater.checkLanguageConfig(languageManager.getDefaults());
+ } catch (IOException e) {
+ getLogger().warning("Unable to run the update checker for language.yml");
+ }
- try {
- ConfigUpdater.checkLanguageConfig(languageManager.getDefaults());
- } catch (IOException e) {
- getLogger().warning("Unable to run the update checker for language.yml");
+ //create folder for player waypoints if it doesn't exist
+ File playerDir = new File(getDataFolder() + File.separator + "players");
+ if (!playerDir.exists())
+ playerDir.mkdirs();
+
+ loadData();
+ autoSave.runTaskTimer(plugin, 6000, 6000);
+
+ //update checker
+ new UpdateChecker(this, 99866).getVersion(version -> {
+ if (!this.getDescription().getVersion().equals(version))
+ this.getLogger().info("\n=======================================================================\n"
+ + ChatColor.AQUA + languageManager.getString("new-version-available") + "\n"
+ + ChatColor.YELLOW + languageManager.getString("current-version") + ": " + Main.plugin.getDescription().getVersion() + "\n"
+ + languageManager.getString("updated-version") + ": " + version + "\n"
+ + ChatColor.WHITE +languageManager.getString("download-link") + ": " + ChatColor.UNDERLINE + "https://www.spigotmc.org/resources/beaconwaypoints.99866\n"
+ + ChatColor.RESET + "=======================================================================");
+ });
+
+ //check if EssentialsX is installed
+ IEssentials essentials = (IEssentials) Bukkit.getPluginManager().getPlugin("Essentials");
+ if (essentials == null)
+ this.getLogger().warning(languageManager.getString("essentials-not-installed"));
}
-
- //create folder for player waypoints if it doesn't exist
- File playerDir = new File(getDataFolder() + File.separator + "players");
- if (!playerDir.exists())
- playerDir.mkdirs();
-
- loadData();
- autoSave.runTaskTimer(plugin, 6000, 6000);
-
- //update checker
- new UpdateChecker(this, 99866).getVersion(version -> {
- if (!this.getDescription().getVersion().equals(version))
- this.getLogger().info("\n=======================================================================\n"
- + ChatColor.AQUA + languageManager.getString("new-version-available") + "\n"
- + ChatColor.YELLOW + languageManager.getString("current-version") + ": " + Main.plugin.getDescription().getVersion() + "\n"
- + languageManager.getString("updated-version") + ": " + version + "\n"
- + ChatColor.WHITE +languageManager.getString("download-link") + ": " + ChatColor.UNDERLINE + "https://www.spigotmc.org/resources/beaconwaypoints.99866\n"
- + ChatColor.RESET + "=======================================================================");
- });
-
- //check if EssentialsX is installed
- IEssentials essentials = (IEssentials) Bukkit.getPluginManager().getPlugin("Essentials");
- if (essentials == null)
- this.getLogger().warning(languageManager.getString("essentials-not-installed"));
}
@Override
public void onDisable() {
- autoSave.cancel();
- saveData();
+ if (versionWrapper != null) {
+ autoSave.cancel();
+ saveData();
+ }
}
public void loadData() {
@@ -136,9 +142,11 @@ public void loadData() {
JSONArray jsonWaypoints = (JSONArray) parser.parse(new InputStreamReader(Files.newInputStream(Paths.get("plugins/" + File.separator + "BeaconWaypoints/" + File.separator + "public.json")), StandardCharsets.UTF_8));
for (JSONObject jsonWaypoint : (Iterable) jsonWaypoints) {
Waypoint waypoint = new Waypoint(jsonWaypoint);
- if (waypoint.isPinned())
- waypointManager.addPinnedWaypoint(waypoint);
- else waypointManager.addPublicWaypoint(new Waypoint(jsonWaypoint));
+ if (waypoint.getName() != null) {
+ if (waypoint.isPinned())
+ waypointManager.addPinnedWaypoint(waypoint);
+ else waypointManager.addPublicWaypoint(waypoint);
+ }
}
} catch(IOException | ParseException e) {
getLogger().info(e.getMessage());
@@ -156,7 +164,9 @@ public void loadData() {
waypointManager.addPlayer(UUID.fromString(uuid.toString()), username.toString());
}
for (JSONObject jsonWaypoint : (Iterable) jsonPlayer.get("waypoints")) {
- waypointManager.addPrivateWaypoint(UUID.fromString(jsonPlayer.get("uuid").toString()), username != null ? username.toString() : null, new Waypoint(jsonWaypoint));
+ Waypoint waypoint = new Waypoint(jsonWaypoint);
+ if (waypoint.getName() != null)
+ waypointManager.addPrivateWaypoint(UUID.fromString(jsonPlayer.get("uuid").toString()), username != null ? username.toString() : null, waypoint);
}
}
}
@@ -167,8 +177,11 @@ public void loadData() {
//load inactive waypoints
try {
JSONArray jsonInactiveWaypoints = (JSONArray) parser.parse(new FileReader("plugins/" + File.separator + "BeaconWaypoints/" + File.separator + "inactive.json"));
- for (JSONObject jsonWaypoint : (Iterable) jsonInactiveWaypoints)
- waypointManager.addInactiveWaypoint(new Waypoint(jsonWaypoint));
+ for (JSONObject jsonWaypoint : (Iterable) jsonInactiveWaypoints) {
+ Waypoint waypoint = new Waypoint(jsonWaypoint);
+ if (waypoint.getName() != null)
+ waypointManager.addInactiveWaypoint(waypoint);
+ }
} catch(IOException | ParseException e) {
getLogger().info(e.getMessage());
}
@@ -250,7 +263,7 @@ public void loadLanguage() {
try {
defaultLanguageConfig.save(languageConfigFile);
} catch (IOException e) {
- Bukkit.getLogger().severe(languageConfig.getString("cannot-save-default-language-config"));
+ Main.getPlugin().getLogger().severe(languageConfig.getString("cannot-save-default-language-config"));
throw new RuntimeException(e);
}
}
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/GUIs.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/GUIs.java
index 449ee4c..2d64f0b 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/GUIs.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/GUIs.java
@@ -3,7 +3,6 @@
import com.github.dawsonvilamaa.beaconwaypoint.LanguageManager;
import com.github.dawsonvilamaa.beaconwaypoint.Main;
import com.github.dawsonvilamaa.beaconwaypoint.waypoints.*;
-import com.mojang.authlib.GameProfile;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -39,7 +38,7 @@ public static void waypointIconPickerMenu(Player player, Waypoint waypoint, Inve
});
gui.addButton(iconButton);
} catch (IllegalArgumentException e) {
- Bukkit.getLogger().warning(languageManager.getString("waypoint-icon-not-found") + " " + iconStr);
+ Main.getPlugin().getLogger().warning(languageManager.getString("waypoint-icon-not-found") + " " + iconStr);
}
}
@@ -112,13 +111,12 @@ public static void publicWaypointsMenu(Player player, Waypoint waypoint, Invento
int numRows = 0;
if (!config.contains("public-waypoint-menu-rows"))
config.set("public-waypoint-menu-rows", 3);
- else {
- numRows = config.getInt("public-waypoint-menu-rows");
- if (numRows <= 0)
- numRows = 1;
- else if (numRows > 5)
- numRows = 5;
- }
+
+ numRows = config.getInt("public-waypoint-menu-rows");
+ if (numRows <= 0)
+ numRows = 1;
+ else if (numRows > 5)
+ numRows = 5;
MultiPageInventoryGUI gui = new MultiPageInventoryGUI(player, languageManager.getString("public-waypoints"), numRows, previousGUI);
@@ -127,7 +125,7 @@ else if (numRows > 5)
Collection allPublicWaypoints = waypointManager.getPinnedWaypointsSortedAlphabetically();
allPublicWaypoints.addAll(waypointManager.getPublicWaypointsSortedAlphabetically());
for (Waypoint publicWaypoint : allPublicWaypoints) {
- if ((!discoveryModeEnabled || publicWaypoint.playerDiscoveredWaypoint(player)) && !publicWaypoint.getCoord().equals(waypoint.getCoord())) {
+ if ((!discoveryModeEnabled || publicWaypoint.playerDiscoveredWaypoint(player) || publicWaypoint.getOwnerUUID().equals(player.getUniqueId())) && !publicWaypoint.getCoord().equals(waypoint.getCoord())) {
WaypointCoord coord = publicWaypoint.getCoord();
String waypointName = publicWaypoint.getName();
if (publicWaypoint.isPinned())
@@ -197,14 +195,18 @@ public static void privateWaypointsMenu(Player player, Waypoint waypoint, Invent
waypointButton.setOnClick(e -> {
player.closeInventory();
if (player.getLocation().distance(waypoint.getCoord().getLocation()) <= 5.5) {
- boolean waypointExists = waypointManager.getPrivateWaypoint(player.getUniqueId(), coord) == null;
+ boolean waypointExists = waypointManager.getPrivateWaypoint(player.getUniqueId(), coord) != null;
if (!waypointExists) {
for (Waypoint sharedWaypoint : waypointManager.getPrivateWaypointsAtCoord(coord)) {
- if (sharedWaypoint.sharedWithPlayer(player.getUniqueId()))
+ if (sharedWaypoint.sharedWithPlayer(player.getUniqueId())) {
waypointExists = true;
+ break;
+ }
}
}
- if (!waypointExists)
+ if (!privateWaypoint.getOwnerUUID().equals(player.getUniqueId()) && !privateWaypoint.sharedWithPlayer(player.getUniqueId()))
+ player.sendMessage(ChatColor.RED + languageManager.getString("no-access-to-private-waypoint") + " " + ChatColor.BOLD + privateWaypoint.getName());
+ else if (!waypointExists)
player.sendMessage(ChatColor.RED + languageManager.getString("waypoint-does-not-exist"));
else if (privateWaypoint.getBeaconStatus() == 0)
player.sendMessage(ChatColor.RED + languageManager.getString("beacon-obstructed"));
@@ -255,13 +257,12 @@ public static int getNumPrivateWaypointMenuRows() {
int numRows = 0;
if (!config.contains("private-waypoint-menu-rows"))
config.set("private-waypoint-menu-rows", 2);
- else {
- numRows = config.getInt("private-waypoint-menu-rows");
- if (numRows <= 0)
- numRows = 1;
- else if (numRows > 5)
- numRows = 5;
- }
+
+ numRows = config.getInt("private-waypoint-menu-rows");
+ if (numRows <= 0)
+ numRows = 1;
+ else if (numRows > 5)
+ numRows = 5;
return numRows;
}
@@ -337,7 +338,7 @@ public static void sharePrivateWaypointMenu(Player player, UUID sharedPlayerUUID
MultiPageInventoryGUI gui = new MultiPageInventoryGUI(player, languageManager.getString("private-waypoints"), getNumPrivateWaypointMenuRows(), null);
//add buttons for all private waypoints
- for (Waypoint privateWaypoint : waypointManager.getPrivateWaypointsSortedAlphabetically(player.getUniqueId())) {
+ for (Waypoint privateWaypoint : waypointManager.getPrivateOwnedWaypointsSortedAlphabetically(player.getUniqueId(), sharedPlayerUUID)) {
if (!privateWaypoint.sharedWithPlayer(player.getUniqueId())) {
InventoryGUIButton waypointButton = new InventoryGUIButton(gui.getGUI(), privateWaypoint.getName(), null, privateWaypoint.getIcon());
waypointButton.setOnClick(e -> {
@@ -401,6 +402,9 @@ public static void managePrivateWaypointAccessMenu(Player player, Waypoint waypo
LanguageManager languageManager = Main.getLanguageManager();
FileConfiguration config = Main.getPlugin().getConfig();
+ if (!config.contains("private-waypoint-menu-rows"))
+ config.set("private-waypoint-menu-rows", 2);
+
MultiPageInventoryGUI gui = new MultiPageInventoryGUI(player, languageManager.getString("manage-access"), config.getInt("private-waypoint-menu-rows"), previousGUI);
for (UUID uuid : waypoint.getSharedPlayers()) {
InventoryGUIButton playerButton = createHeadButton(gui.getGUI(), Main.getWaypointManager().getPlayerUsername(uuid), ChatColor.RED + languageManager.getString("click-to-remove-access"), Main.getWaypointManager().getPlayerUsername(uuid));
@@ -465,10 +469,4 @@ public static InventoryGUIButton createHeadButton(InventoryGUI gui, String name,
button.setDescription(description);
return button;
}
-
- //creates an inventory GUI button with a player's head
- //the OfflinePlayer's username must not be null
- public static InventoryGUIButton createHeadButton(InventoryGUI gui, String name, String description, OfflinePlayer player) {
- return createHeadButton(gui, name, description, player.getName());
- }
}
\ No newline at end of file
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/InventoryGUIButton.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/InventoryGUIButton.java
index 501cc53..fc78e60 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/InventoryGUIButton.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/gui/InventoryGUIButton.java
@@ -1,5 +1,7 @@
package com.github.dawsonvilamaa.beaconwaypoint.gui;
+import com.github.dawsonvilamaa.beaconwaypoint.Main;
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag;
@@ -151,8 +153,19 @@ public InventoryGUI getParentGUI() {
* @param e
*/
public void onClick(InventoryClickEvent e) {
- if (this.onClick != null)
- this.onClick.accept(e);
+ if (this.onClick != null) {
+ try {
+ this.onClick.accept(e);
+ }
+ catch (Exception ex) {
+ e.setCancelled(true);
+ StringBuilder stackTraceStr = new StringBuilder(ex.getMessage()).append("\n");
+ for (StackTraceElement frame : ex.getStackTrace()) {
+ stackTraceStr.append(frame.toString()).append("\n");
+ }
+ Main.getPlugin().getLogger().severe(stackTraceStr.toString());
+ }
+ }
}
/**
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/listeners/WorldListener.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/listeners/WorldListener.java
index 23a2198..aeb95ce 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/listeners/WorldListener.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/listeners/WorldListener.java
@@ -139,17 +139,21 @@ public void onPlayerInteract(PlayerInteractEvent e) {
WaypointManager waypointManager = Main.getWaypointManager();
WaypointCoord waypointCoord = new WaypointCoord(e.getClickedBlock().getLocation());
Waypoint waypoint = waypointManager.getPinnedWaypoint(waypointCoord);
+ boolean isWaypointPublic = true;
if (waypoint == null)
waypoint = waypointManager.getPublicWaypoint(waypointCoord);
- if (waypoint == null)
- waypoint = waypointManager.getPrivateWaypoint(player.getUniqueId(), waypointCoord);
+ if (waypoint == null) {
+ isWaypointPublic = false;
+ waypoint = waypointManager.getPlayer(player.getUniqueId()).getWaypoint(waypointCoord);
+ }
if (waypoint != null) {
e.setCancelled(true);
if (Main.getPlugin().getConfig().getBoolean("discovery-mode")) {
//discovery mode
- if (!waypoint.playerDiscoveredWaypoint(player)) {
+ if (isWaypointPublic && !waypoint.playerDiscoveredWaypoint(player)) {
waypoint.addPlayerDiscovered(player);
- player.sendMessage(ChatColor.GREEN + Main.getLanguageManager().getString("discovered-waypoint") + ": " + ChatColor.BOLD + waypoint.getName());
+ if (!waypoint.getOwnerUUID().equals(player.getUniqueId()))
+ player.sendMessage(ChatColor.GREEN + Main.getLanguageManager().getString("discovered-waypoint") + ": " + ChatColor.BOLD + waypoint.getName());
}
}
GUIs.beaconMenu(player, waypoint);
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/Waypoint.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/Waypoint.java
index f669303..ada720d 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/Waypoint.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/Waypoint.java
@@ -56,29 +56,108 @@ public Waypoint(UUID ownerUUID, WaypointCoord coord) {
* @param jsonWaypoint
*/
public Waypoint(JSONObject jsonWaypoint) {
+ LanguageManager languageManager = Main.getLanguageManager();
+ boolean dataError = false;
+
Object jsonName = jsonWaypoint.get("name");
- this.name = jsonName == null ? null : jsonName.toString();
- int x = Integer.parseInt(jsonWaypoint.get("x").toString());
- int y = Integer.parseInt(jsonWaypoint.get("y").toString());
- int z = Integer.parseInt(jsonWaypoint.get("z").toString());
- String worldName = jsonWaypoint.get("world").toString();
- this.coord = new WaypointCoord(x, y, z, worldName);
- this.icon = Material.valueOf(jsonWaypoint.get("icon").toString());
- this.ownerUUID = UUID.fromString(jsonWaypoint.get("ownerUUID").toString());
- this.isWaypoint = Boolean.parseBoolean(jsonWaypoint.get("isWaypoint").toString());
- Object jsonPinned = (Object) jsonWaypoint.get("pinned");
- this.pinned = jsonPinned == null ? false : Boolean.parseBoolean(jsonWaypoint.get("pinned").toString());
- JSONArray jsonPlayersDiscovered = (JSONArray) jsonWaypoint.get("playersDiscovered");
- this.playersDiscovered = new ArrayList<>();
- if (jsonPlayersDiscovered != null) {
- for (Object jsonPlayer : jsonPlayersDiscovered)
- this.playersDiscovered.add(UUID.fromString((String) jsonPlayer));
+ if (jsonName == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"name\"");
}
- JSONArray jsonSharedPlayers = (JSONArray) jsonWaypoint.get("sharedPlayers");
- this.sharedPlayers = new ArrayList<>();
- if (jsonSharedPlayers != null) {
- for (Object jsonPlayer : jsonSharedPlayers)
- this.sharedPlayers.add(UUID.fromString((String) jsonPlayer));
+ else this.name = jsonName.toString();
+
+ int x = 0, y = 0, z = 0;
+
+ Object jsonX = jsonWaypoint.get("x");
+ if (jsonX == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"x'\"");
+ }
+ else x = Integer.parseInt(jsonX.toString());
+
+ Object jsonY = jsonWaypoint.get("y");
+ if (jsonY == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"y\"");
+ }
+ else y = Integer.parseInt(jsonY.toString());
+
+ Object jsonZ = jsonWaypoint.get("z");
+ if (jsonZ == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"z\"");
+ }
+ else z = Integer.parseInt(jsonZ.toString());
+
+ Object jsonWorldName = jsonWaypoint.get("world");
+ if (jsonWorldName == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"world\"");
+ }
+ else {
+ this.coord = new WaypointCoord(x, y, z, jsonWorldName.toString());
+ }
+
+ Object jsonIcon = jsonWaypoint.get("icon");
+ if (jsonIcon == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"icon\"");
+ }
+ else this.icon = Material.valueOf(jsonIcon.toString());
+
+ Object jsonOwnerUUID = jsonWaypoint.get("ownerUUID");
+ if (jsonOwnerUUID == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"ownerUUID\"");
+ }
+ else this.ownerUUID = UUID.fromString(jsonOwnerUUID.toString());
+
+ Object jsonIsWaypoint = jsonWaypoint.get("isWaypoint");
+ if (jsonIsWaypoint == null) {
+ dataError = true;
+ Main.getPlugin().getLogger().warning(languageManager.getString("missing-attribute") + " \"isWaypoint\"");
+ }
+ else this.isWaypoint = Boolean.parseBoolean(jsonIsWaypoint.toString());
+
+ if (dataError) {
+ Main.getPlugin().getLogger().severe(languageManager.getString("missing-attributes"));
+ }
+ else {
+ Object jsonPinned = jsonWaypoint.get("pinned");
+ if (jsonPinned == null) {
+ Main.getPlugin().getLogger().warning(languageManager.getString("pinned-default"));
+ this.pinned = false;
+ }
+ else this.pinned = Boolean.parseBoolean(jsonPinned.toString());
+
+ Object jsonPlayersDiscovered = jsonWaypoint.get("playersDiscovered");
+ if (jsonPlayersDiscovered == null) {
+ Main.getPlugin().getLogger().warning(languageManager.getString("players-discovered-default"));
+ }
+ JSONArray jsonPlayersDiscoveredArr = (JSONArray) jsonWaypoint.get("playersDiscovered");
+ this.playersDiscovered = new ArrayList<>();
+ if (jsonPlayersDiscoveredArr != null) {
+ for (Object jsonPlayer : jsonPlayersDiscoveredArr) {
+ try {
+ this.playersDiscovered.add(UUID.fromString((String) jsonPlayer));
+ }
+ catch (Exception e) {
+ Main.getPlugin().getLogger().severe(languageManager.getString("error-reading-players-discovered"));
+ }
+ }
+ }
+ JSONArray jsonSharedPlayers = (JSONArray) jsonWaypoint.get("sharedPlayers");
+ this.sharedPlayers = new ArrayList<>();
+ if (jsonSharedPlayers != null) {
+ for (Object jsonPlayer : jsonSharedPlayers) {
+ try {
+ this.sharedPlayers.add(UUID.fromString((String) jsonPlayer));
+ }
+ catch (Exception e) {
+ Main.getPlugin().getLogger().severe(languageManager.getString("error-reading-shared-player"));
+ }
+ }
+ }
}
}
@@ -310,22 +389,26 @@ public void setSharedPlayers(ArrayList sharedPlayers) {
*/
public JSONObject toJSON() {
JSONObject jsonWaypoint = new JSONObject();
- jsonWaypoint.put("name", this.name);
- jsonWaypoint.put("x", String.valueOf(this.coord.getX()));
- jsonWaypoint.put("y", String.valueOf(this.coord.getY()));
- jsonWaypoint.put("z", String.valueOf(this.coord.getZ()));
- jsonWaypoint.put("world", this.coord.getWorldName());
- jsonWaypoint.put("icon", this.icon.toString());
- jsonWaypoint.put("ownerUUID", this.ownerUUID.toString());
+ jsonWaypoint.put("name", this.name == null ? null : this.name);
+ jsonWaypoint.put("x", this.coord == null ? null : String.valueOf(this.coord.getX()));
+ jsonWaypoint.put("y", this.coord == null ? null : String.valueOf(this.coord.getY()));
+ jsonWaypoint.put("z", this.coord == null ? null : String.valueOf(this.coord.getZ()));
+ jsonWaypoint.put("world", this.coord == null ? null : this.coord.getWorldName());
+ jsonWaypoint.put("icon", this.icon == null ? null : this.icon.toString());
+ jsonWaypoint.put("ownerUUID", this.ownerUUID == null ? null : this.ownerUUID.toString());
jsonWaypoint.put("isWaypoint", String.valueOf(this.isWaypoint));
jsonWaypoint.put("pinned", String.valueOf(this.pinned));
JSONArray jsonPlayersDiscovered = new JSONArray();
- for (UUID uuid : this.playersDiscovered)
- jsonPlayersDiscovered.add(uuid.toString());
+ if (this.playersDiscovered != null) {
+ for (UUID uuid : this.playersDiscovered)
+ jsonPlayersDiscovered.add(uuid.toString());
+ }
jsonWaypoint.put("playersDiscovered", jsonPlayersDiscovered);
JSONArray jsonSharedPlayers = new JSONArray();
- for (UUID uuid : this.sharedPlayers)
- jsonSharedPlayers.add(uuid.toString());
+ if (this.sharedPlayers != null) {
+ for (UUID uuid : this.sharedPlayers)
+ jsonSharedPlayers.add(uuid.toString());
+ }
jsonWaypoint.put("sharedPlayers", jsonSharedPlayers);
return jsonWaypoint;
}
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointHelper.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointHelper.java
index 4c5c107..a7555f2 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointHelper.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointHelper.java
@@ -315,7 +315,7 @@ public static boolean checkPaymentRequirements(Player player, Waypoint startWayp
String paymentMode = config.getString("payment-mode");
if (!(paymentMode.equals("xp") || paymentMode.equals("money") || paymentMode.equals("none"))) {
- Bukkit.getLogger().warning(languageManager.getString("payment-mode-not-found"));
+ Main.getPlugin().getLogger().warning(languageManager.getString("payment-mode-not-found"));
paymentMode = "none";
}
if (!paymentMode.equals("none")) {
@@ -516,7 +516,7 @@ public static String getWaypointDescription(Waypoint startWaypoint, Waypoint des
String paymentMode = config.getString("payment-mode");
if (!(paymentMode.equals("xp") || paymentMode.equals("money") || paymentMode.equals("none"))) {
- Bukkit.getLogger().warning(languageManager.getString("payment-mode-not-found"));
+ Main.getPlugin().getLogger().warning(languageManager.getString("payment-mode-not-found"));
paymentMode = "none";
}
IEssentials essentials = (IEssentials) Bukkit.getPluginManager().getPlugin("Essentials");
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointManager.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointManager.java
index 5be4776..8d92e86 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointManager.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointManager.java
@@ -230,6 +230,22 @@ public Collection getPrivateWaypointsSortedAlphabetically(UUID uuid) {
return sortWaypointsAlphabetically(waypoints);
}
+ /**
+ * Returns a collection of private waypoints owned by the player that are not already shared with the other player
+ * @param ownerUUID
+ * @param shareUUID
+ * @return waypoints
+ */
+ public Collection getPrivateOwnedWaypointsSortedAlphabetically(UUID ownerUUID, UUID shareUUID) {
+ ArrayList waypoints = new ArrayList<>();
+ for (Waypoint waypoint : waypointPlayers.get(ownerUUID).getWaypoints().values()) {
+ if (!waypoint.sharedWithPlayer(shareUUID)) {
+ waypoints.add(waypoint);
+ }
+ }
+ return sortWaypointsAlphabetically(waypoints);
+ }
+
/**
* Returns a HashMap of all waypoints where the beacon has been placed, but a waypoint has not been created
* @return
diff --git a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointPlayer.java b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointPlayer.java
index bacbb08..f6df901 100644
--- a/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointPlayer.java
+++ b/core/src/main/java/com/github/dawsonvilamaa/beaconwaypoint/waypoints/WaypointPlayer.java
@@ -30,8 +30,11 @@ public WaypointPlayer(JSONObject jsonPlayer) {
this.waypoints = new HashMap<>();
JSONArray jsonWaypoints = (JSONArray) jsonPlayer.get("waypoints");
- for (JSONObject jsonWaypoint : (Iterable) jsonWaypoints)
- this.waypoints.put(new WaypointCoord(jsonWaypoint), new Waypoint(jsonWaypoint));
+ for (JSONObject jsonWaypoint : (Iterable) jsonWaypoints) {
+ Waypoint waypoint = new Waypoint(jsonWaypoint);
+ if (waypoint.getName() != null)
+ this.waypoints.put(new WaypointCoord(jsonWaypoint), waypoint);
+ }
this.isTeleporting = false;
}
diff --git a/core/src/main/resources/language.yml b/core/src/main/resources/language.yml
index dfdf8e1..562f79f 100644
--- a/core/src/main/resources/language.yml
+++ b/core/src/main/resources/language.yml
@@ -20,6 +20,8 @@ delete-waypoint: Delete Waypoint
discovered-waypoint: Discovered waypoint
distance: Distance
download-link: Download link
+error-reading-players-discovered: Error while reading players discovered. Check the save files for incorrect player UUIDs
+error-reading-shared-player: Error while reading shared player. Check the save files for incorrect player UUIDs
essentials-not-installed: EssentialsX is not installed, ignoring Essentials money cost for teleporting.
has-banned-items: You cannot teleport because you have these items in your inventory
insufficient-items: You are missing items that are required to teleport
@@ -28,9 +30,12 @@ insufficient-xp: You do not have enough XP to teleport to that waypoint. Additio
invalid-name: Waypoint names must be 30 characters or fewer
invalid-name-alphanumeric: Waypoint names must be 30 characters or fewer and can only contain letters, numbers, spaces, underscores, and hyphens.
manage-access: Manage access
+missing-attribute: Waypoint is missing attribute
+missing-attributes: A waypoint is missing one or more attributes. Check the save files
name-taken: There is already a public waypoint of that name
new-version-available: A new version of Beacon Waypoints is available!
next-page: Next Page
+no-access-to-private-waypoint: You do not have access to the private waypoint
no-break-permission: You do not have permission to break beacons that have waypoints set
no-command-permission: You don't have permission to use that command
no-longer-has-access: no longer has access to the private waypoint
@@ -42,8 +47,10 @@ options: Options
owner: Owner
payment-mode-not-found: Payment mode not recognized, defaulting to "none"
pinned: pinned
+pinned-default: Waypoint is missing attribute "pinned", setting to default false
pin-waypoint: Pin waypoint
player-not-found: That player cannot be found or is offline
+players-discovered-default: Waypoint is missing attribute "playersDiscovered", setting to default empty list
previous-page: Previous Page
private-list-full: Private waypoint list is full!
private-name-taken: There is already a private waypoint of that name
diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml
index b31b585..eea4b16 100644
--- a/core/src/main/resources/plugin.yml
+++ b/core/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
main: com.github.dawsonvilamaa.beaconwaypoint.Main
name: BeaconWaypoints
-version: 1.6.5
+version: 1.7
api-version: 1.14
author: Dawson Vilamaa
description: Allows players to set fast travel waypoints at beacons
diff --git a/pom.xml b/pom.xml
index fa83285..00f30d4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.github.dawsonvilamaa
BeaconWaypoints
- 1.6.5
+ 1.7
pom
@@ -22,6 +22,8 @@
1_20_R1
1_20_R2
1_20_R3
+ 1_20_R4
+ 1_21_R1
Build
diff --git a/todo.txt b/todo.txt
index e10ed27..b9762f4 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,17 +1,18 @@
-- update to 1.20.2 (done)
+- update to 1.20.6 (done)
- make player skull button creation function (done)
-- fix messages not being sent when a waypoint beacon is broken
-
-- share private waypoints with other players
+- fix messages not being sent when a waypoint beacon is broken (done)
+- share private waypoints with other players (done)
- don't allow sharing if it is already shared with that player (done)
- make sure player usernames are updated in player save files when their usernames are changed (done)
-- fix messages not being sent when a waypoint beacon is broken
- make function for confirmation menus (including option for center item)
- make function for adding white stained glass panes in menus quickly
-- only show compass in multi-page inventory menus when there is more than one page (done)
- structure ConfigUpdater better
-- prevent player from taking items on onclick errors
-- add failsafes if any field is missing from save files
+- prevent player from taking items on onclick errors (done)
+- add failsafes if any field is missing from save files (done)
+- check for shared private waypoint status on click so already open menus don't allow travel to waypoints that are no longer shared (done)
+- test upgrading from old version (done)
+- don't show waypoints in share GUI if they are already shared with the given player (done)
+- allow player to open waypoint menu if they have a private waypoint set at that beacon but if there are no public waypoints (done)
MAYBE:
- add a GUI option for creating beacons