Skip to content

Commit

Permalink
Version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Mar 28, 2022
1 parent db4aed3 commit 68530b4
Show file tree
Hide file tree
Showing 22 changed files with 292 additions and 85 deletions.
14 changes: 14 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:\Users\dfrog\Documents\Coding\BeaconWaypoints\1_17_R1\src\main\java\com\github\dawsonvilamaa\beaconwaypoint\version\Version_1_17_R1.java
D:\User\Documents\Coding\BeaconWaypoints\1_17_R1\src\main\java\com\github\dawsonvilamaa\beaconwaypoint\version\Version_1_17_R1.java
2 changes: 1 addition & 1 deletion 1_18_R1/target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Thu Mar 24 13:19:11 EDT 2022
#Mon Mar 28 15:34:13 EDT 2022
groupId=com.github.dawsonvilamaa
artifactId=1_18_R1
version=1.3.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:\Users\dfrog\Documents\Coding\BeaconWaypoints\1_18_R1\src\main\java\com\github\dawsonvilamaa\beaconwaypoint\version\Version_1_18_R1.java
D:\User\Documents\Coding\BeaconWaypoints\1_18_R1\src\main\java\com\github\dawsonvilamaa\beaconwaypoint\version\Version_1_18_R1.java
18 changes: 14 additions & 4 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
Changes:
- Added support for versions 1.14-1.17.1 and 1.18.2
- Added bStats metric for the total number of waypoints
- The default waypoint type is now public, so typing out "public" is no longer required when creating a new waypoint
- Changed permissions
- Removed waypoint permission
- Added createWaypoints permission
- Added useWaypoints permission
- Added usePrivateWaypoints permission
- Added breakWaypointBeacons permission
- Added manageAllWaypoints permission
- Changed config.yml
- Added launch-player option
- Added allow-beacon-break-by-owner option
- Added allow-all-worlds option

Bug Fixes:
- config.yml would not be created automatically (bruh moment)
- Players could activate beacon teleportation if they opened the menu, got moved away, and selected a destination
- The back arrow player texture for the player skull in the waypoint options menu would not load
- A waypoint would be removed if a beacon became obstructed and then unobstructed
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
boolean privateWaypoint = false;
if (args[args.length - 1].equalsIgnoreCase("private")) {
privateWaypoint = true;
if (!player.hasPermission("BeaconWaypoints.createPrivateWaypoints")) {
if (!player.hasPermission("BeaconWaypoints.createWaypoints") || !player.hasPermission("BeaconWaypoints.usePrivateWaypoints")) {
player.sendMessage(ChatColor.RED + "You don't have permission to create private waypoints");
privateWaypoint = false;
return true;
}
}
Expand All @@ -67,7 +66,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}

//check if the beacon is in an allowed world
if (!plugin.getConfig().getStringList("allowed-worlds").contains(player.getWorld().getName())) {
if (!plugin.getConfig().contains("allow-all-worlds"))
plugin.getConfig().set("allow-all-worlds", true);
if (!plugin.getConfig().contains("allowed-worlds"))
plugin.getConfig().set("allowed-worlds", Waypoint.DEFAULT_ALLOWED_WORLDS);
if (!plugin.getConfig().getBoolean("allow-all-worlds") && !plugin.getConfig().getStringList("allowed-worlds").contains(player.getWorld().getName())) {
player.sendMessage(ChatColor.RED + "You cannot set a waypoint in this world");
return true;
}
Expand All @@ -83,27 +86,35 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}

//check if public waypoint list is full
int maxPublicWaypoints = plugin.getConfig().getInt("max-public-waypoints");
if (maxPublicWaypoints < 0)
maxPublicWaypoints = 0;
if (Main.waypointManager.getPublicWaypoints().values().size() == maxPublicWaypoints) {
player.sendMessage(ChatColor.RED + "Public waypoint list is full!");
return true;
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 (Main.waypointManager.getPublicWaypoints().values().size() == maxPublicWaypoints) {
player.sendMessage(ChatColor.RED + "Public waypoint list is full!");
return true;
}
}

if (Main.waypointManager.getPublicWaypoint(playerLoc) != null)
waypointExists = true;
} else {
//check if private waypoint list is full
int maxPrivateWaypoints = plugin.getConfig().getInt("max-private-waypoints");
if (maxPrivateWaypoints < 0)
maxPrivateWaypoints = 0;
if (Main.waypointManager.getPrivateWaypoints(player.getUniqueId()).values().size() == maxPrivateWaypoints) {
player.sendMessage(ChatColor.RED + "Private waypoint list is full!");
return true;
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 (Main.waypointManager.getPrivateWaypoints(player.getUniqueId()).values().size() == maxPrivateWaypoints) {
player.sendMessage(ChatColor.RED + "Private waypoint list is full!");
return true;
}
if (Main.waypointManager.getPrivateWaypoint(player.getUniqueId(), playerLoc) != null)
waypointExists = true;
}
if (Main.waypointManager.getPrivateWaypoint(player.getUniqueId(), playerLoc) != null)
waypointExists = true;
}

if (waypointExists) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.SkullMeta;

import java.util.List;
import java.util.Objects;
import java.util.UUID;

public class GUIs {

//shows all icons for waypoints
public static void waypointIconPickerMenu(Player player, Waypoint waypoint, InventoryGUI previousGUI) {
FileConfiguration config = Main.plugin.getConfig();

MultiPageInventoryGUI gui = new MultiPageInventoryGUI(player, "Waypoint Icon", 5, previousGUI);

//add waypoint icons
if (!config.contains("waypoint-icons"))
config.set("waypoint-icons", Waypoint.DEFAULT_WAYPOINT_ICONS);
for (String iconStr : Main.plugin.getConfig().getStringList("waypoint-icons")) {
try {
Material icon = Material.valueOf(iconStr);
Expand Down Expand Up @@ -56,7 +62,15 @@ public static void beaconMenu(Player player, Waypoint waypoint) {

//public waypoints button
InventoryGUIButton publicWaypointsButton = new InventoryGUIButton(gui, "Public Waypoints", null, Material.FILLED_MAP);
publicWaypointsButton.setOnClick(f -> publicWaypointsMenu(player, waypoint, gui));
publicWaypointsButton.setOnClick(f -> {
int beaconStatus = waypoint.getBeaconStatus();
if (beaconStatus != 0)
publicWaypointsMenu(player, waypoint, gui);
else {
player.sendMessage(ChatColor.RED + "The destination beacon is not able to be traveled to. It either is not constructed correctly, or something is obstructing the beam.");
player.closeInventory();
}
});
if (canUsePrivateWaypoints)
gui.addButton(publicWaypointsButton);
else {
Expand All @@ -67,7 +81,15 @@ public static void beaconMenu(Player player, Waypoint waypoint) {
//private waypoints button
if (canUsePrivateWaypoints) {
InventoryGUIButton privateWaypointsButton = new InventoryGUIButton(gui, "Private Waypoints", null, Material.TRIPWIRE_HOOK);
privateWaypointsButton.setOnClick(f -> privateWaypointsMenu(player, waypoint, gui));
privateWaypointsButton.setOnClick(f -> {
int beaconStatus = waypoint.getBeaconStatus();
if (beaconStatus != 0)
privateWaypointsMenu(player, waypoint, gui);
else {
player.sendMessage(ChatColor.RED + "The destination beacon is not able to be traveled to. It either is not constructed correctly, or something is obstructing the beam.");
player.closeInventory();
}
});
gui.addButton(privateWaypointsButton);
}

Expand All @@ -78,11 +100,19 @@ public static void beaconMenu(Player player, Waypoint waypoint) {

//shows all public waypoints
public static void publicWaypointsMenu(Player player, Waypoint waypoint, InventoryGUI previousGUI) {
int numRows = Main.plugin.getConfig().getInt("public-waypoint-menu-rows");
if (numRows <= 0)
numRows = 1;
else if (numRows > 5)
numRows = 5;
FileConfiguration config = Main.plugin.getConfig();

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;
}

MultiPageInventoryGUI gui = new MultiPageInventoryGUI(player, "Public Waypoints", numRows, previousGUI);

//add buttons for all public waypoints
Expand All @@ -97,10 +127,14 @@ else if (numRows > 5)
player.sendMessage(ChatColor.RED + "That waypoint doesn't exist!");
else if (publicWaypoint.getBeaconStatus() == 0)
player.sendMessage(ChatColor.RED + "The destination beacon is not able to be traveled to. It either is not constructed correctly, or something is obstructing the beam.");
else Waypoint.teleport(waypoint, publicWaypoint, Main.plugin.getConfig().getBoolean("disable-group-teleporting") ? player : null);
else {
if (!config.contains("disable-group-teleporting"))
config.set("disable-group-teleporting", false);
Waypoint.teleport(waypoint, publicWaypoint, config.getBoolean("disable-group-teleporting") ? player : null);
}
}
});
if (publicWaypoint.getOwnerUUID().equals(player.getUniqueId())) {
if (player.hasPermission("manageAllWaypoints") || publicWaypoint.getOwnerUUID().equals(player.getUniqueId())) {
waypointButton.setOnRightClick(e -> {
waypointOptionsMenu(player, publicWaypoint, waypoint, gui.getGUI(), true);
});
Expand All @@ -113,7 +147,7 @@ else if (publicWaypoint.getBeaconStatus() == 0)

//options button for this waypoint
Waypoint thisWaypoint = Main.waypointManager.getPublicWaypoint(waypoint.getCoord());
if (thisWaypoint != null) {
if (thisWaypoint != null && (waypoint.getOwnerUUID().equals(player.getUniqueId()) || player.hasPermission("manageAllWaypoints"))) {
InventoryGUIButton optionsButton = new InventoryGUIButton(gui.getGUI(), "Options for this public waypoint", null, thisWaypoint.getIcon());
optionsButton.setOnClick(e -> {
waypointOptionsMenu(player, thisWaypoint, waypoint, gui.getGUI(), true);
Expand All @@ -124,11 +158,19 @@ else if (publicWaypoint.getBeaconStatus() == 0)

//shows all private waypoints
public static void privateWaypointsMenu(Player player, Waypoint waypoint, InventoryGUI previousGUI) {
int numRows = Main.plugin.getConfig().getInt("private-waypoint-menu-rows");
if (numRows <= 0)
numRows = 1;
else if (numRows > 5)
numRows = 5;
FileConfiguration config = Main.plugin.getConfig();

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;
}

MultiPageInventoryGUI gui = new MultiPageInventoryGUI(player, "Private Waypoints", numRows, previousGUI);

//add buttons for all private waypoints
Expand All @@ -143,7 +185,11 @@ else if (numRows > 5)
player.sendMessage(ChatColor.RED + "That waypoint doesn't exist!");
else if (privateWaypoint.getBeaconStatus() == 0)
player.sendMessage(ChatColor.RED + "The destination beacon is not able to be traveled to. It either is not constructed correctly, or something is obstructing the beam.");
else Waypoint.teleport(waypoint, privateWaypoint, Main.plugin.getConfig().getBoolean("disable-group-teleporting") ? player : null);
else {
if (!config.contains("disable-group-teleporting"))
config.set("disable-group-teleporting", false);
Waypoint.teleport(waypoint, privateWaypoint, config.getBoolean("disable-group-teleporting") ? player : null);
}
}
});
if (privateWaypoint.getOwnerUUID().equals(player.getUniqueId())) {
Expand All @@ -159,7 +205,7 @@ else if (privateWaypoint.getBeaconStatus() == 0)

//options button for this waypoint
Waypoint thisWaypoint = Main.waypointManager.getPrivateWaypoint(player.getUniqueId(), waypoint.getCoord());
if (thisWaypoint != null) {
if (thisWaypoint != null && (waypoint.getOwnerUUID().equals(player.getUniqueId()) || player.hasPermission("manageAllWaypoints"))) {
InventoryGUIButton optionsButton = new InventoryGUIButton(gui.getGUI(), "Options for this private waypoint", null, thisWaypoint.getIcon());
optionsButton.setOnClick(e -> {
waypointOptionsMenu(player, thisWaypoint, waypoint, gui.getGUI(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
Expand Down Expand Up @@ -76,8 +77,11 @@ public void onBlockBreak(BlockBreakEvent e) {
}
}
}
if (!e.getPlayer().hasPermission("BeaconWaypoints.breakWaypointBeacons")) {
if (ownsWaypoint && !Main.plugin.getConfig().getBoolean("allow-beacon-break-by-owner")) {
if (!e.getPlayer().hasPermission("BeaconWaypoints.manageAllWaypoints") && !e.getPlayer().hasPermission("BeaconWaypoints.breakWaypointBeacons")) {
FileConfiguration config = Main.plugin.getConfig();
if (!config.contains("allow-beacon-break-by-owner"))
config.set("allow-beacon-break-by-owner", true);
if (!(ownsWaypoint && config.getBoolean("allow-beacon-break-by-owner"))) {
e.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to break beacons that have waypoints set");
e.setCancelled(true);
}
Expand Down Expand Up @@ -112,7 +116,7 @@ public void onBlockBreak(BlockBreakEvent e) {
//deletes waypoints if they are removed with fill or setblock commands
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent e) {
if (e.getSourceBlock().getType() == Material.AIR) {
if (e.getBlock().getType() == Material.AIR) {
WaypointCoord waypointCoord = new WaypointCoord(e.getBlock().getLocation());

//remove public waypoint
Expand Down Expand Up @@ -147,10 +151,7 @@ public void onPlayerInteract(PlayerInteractEvent e) {
waypoint = Main.waypointManager.getPrivateWaypoint(e.getPlayer().getUniqueId(), waypointCoord);
if (waypoint != null) {
e.setCancelled(true);
int beaconStatus = waypoint.getBeaconStatus();
if (beaconStatus != 0)
GUIs.beaconMenu(e.getPlayer(), waypoint);
else e.getPlayer().sendMessage(ChatColor.RED + "The destination beacon is not able to be traveled to. It either is not constructed correctly, or something is obstructing the beam.");
GUIs.beaconMenu(e.getPlayer(), waypoint);
}
}
}
Expand Down
Loading

0 comments on commit 68530b4

Please sign in to comment.