diff --git a/pom.xml b/pom.xml
index 383e56f..7651256 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,16 +6,23 @@
mikeshafter
OldThrottle
- 1.17.1b1
+ 1.17.1b2
jar
OldThrottle
- 1.8
+ 16
UTF-8
+
+
+ apache.snapshots
+ https://repository.apache.org/snapshots/
+
+
+
@@ -30,7 +37,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 3.2.4
+ 3.3.0-SNAPSHOT
package
@@ -83,13 +90,13 @@
com.bergerkiller.bukkit
TrainCarts
- 1.16.5-v2-SNAPSHOT
+ 1.17.1-v2-SNAPSHOT
provided
com.bergerkiller.bukkit
BKCommonLib
- 1.16.5-v2-SNAPSHOT
+ 1.17.1-v2-SNAPSHOT
provided
diff --git a/src/main/java/mikeshafter/oldthrottle/Throttle.java b/src/main/java/mikeshafter/oldthrottle/Throttle.java
index aba4d56..7bd0546 100644
--- a/src/main/java/mikeshafter/oldthrottle/Throttle.java
+++ b/src/main/java/mikeshafter/oldthrottle/Throttle.java
@@ -191,9 +191,8 @@ public void emergencyBrake(Player player) {
@EventHandler
public void dismount(EntityDismountEvent event) {
- if (event.getEntity() instanceof Player) {
-
- Player player = (Player) event.getEntity();
+ if (event.getEntity() instanceof Player player) {
+
if (speedHashMap.containsKey(player)) {
emergencyBrake(player);
}
diff --git a/src/main/java/mikeshafter/oldthrottle/TrainAnnounce.java b/src/main/java/mikeshafter/oldthrottle/TrainAnnounce.java
index 7bf854f..8d7786c 100644
--- a/src/main/java/mikeshafter/oldthrottle/TrainAnnounce.java
+++ b/src/main/java/mikeshafter/oldthrottle/TrainAnnounce.java
@@ -30,8 +30,7 @@ public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNul
if (command.getName().equalsIgnoreCase("ta")) {
// If sent from player
- if (sender instanceof Player && sender.hasPermission("OldThrottle.ta")) {
- Player player = (Player) sender;
+ if (sender instanceof Player player && sender.hasPermission("OldThrottle.ta")) {
String message = colourise(String.join(" ", args));
player.sendMessage("Sent message: "+message);
@@ -50,14 +49,12 @@ public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNul
// If sent from command block
- } else if (sender instanceof BlockCommandSender) {
- BlockCommandSender commandSender = (BlockCommandSender) sender;
+ } else if (sender instanceof BlockCommandSender commandSender) {
Block commandBlock = commandSender.getBlock();
AdvancedMessage message = advancedMessage(args);
// Check if message has flags
- if (message instanceof RadiusMessage) {
- RadiusMessage radiusMessage = (RadiusMessage) message;
+ if (message instanceof RadiusMessage radiusMessage) {
Location location = radiusMessage instanceof RadiusMessageCoordinates ?
new Location(commandBlock.getWorld(), ((RadiusMessageCoordinates) radiusMessage).getX(), ((RadiusMessageCoordinates) radiusMessage).getY(), ((RadiusMessageCoordinates) radiusMessage).getZ())
: commandBlock.getLocation();
@@ -76,8 +73,7 @@ public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNul
return true;
}
}
- } else if (message instanceof AdvancedMessageBox) {
- AdvancedMessageBox messageBox = (AdvancedMessageBox) message;
+ } else if (message instanceof AdvancedMessageBox messageBox) {
int x = messageBox.getX();
int y = messageBox.getY();
int z = messageBox.getZ();
@@ -113,31 +109,28 @@ public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNul
else if (command.getName().equalsIgnoreCase("tj")) {
// If sent from player
- if (sender instanceof Player && sender.hasPermission("OldThrottle.tj")) {
- Player player = (Player) sender;
+ if (sender instanceof Player player && sender.hasPermission("OldThrottle.tj")) {
String message = String.join(" ", args);
player.sendMessage("Sent message:");
sendJsonMessage(player, message);
// Get the train the player is in
for (MinecartMember> member : MinecartGroupStore.get(player.getVehicle())) {
-
+
// Get every player passenger
for (Player passenger : member.getEntity().getPlayerPassengers()) {
sendJsonMessage(passenger, message);
}
}
return true;
-
+
// If sent from command block
- } else if (sender instanceof BlockCommandSender) {
- BlockCommandSender commandSender = (BlockCommandSender) sender;
+ } else if (sender instanceof BlockCommandSender commandSender) {
Block commandBlock = commandSender.getBlock();
AdvancedMessage message = advancedMessage(args);
// Check if message has flags
- if (message instanceof RadiusMessage) {
- RadiusMessage radiusMessage = (RadiusMessage) message;
+ if (message instanceof RadiusMessage radiusMessage) {
Location location = radiusMessage instanceof RadiusMessageCoordinates ?
new Location(commandBlock.getWorld(), ((RadiusMessageCoordinates) radiusMessage).getX(), ((RadiusMessageCoordinates) radiusMessage).getY(), ((RadiusMessageCoordinates) radiusMessage).getZ())
: commandBlock.getLocation();
@@ -156,8 +149,7 @@ else if (command.getName().equalsIgnoreCase("tj")) {
return true;
}
}
- } else if (message instanceof AdvancedMessageBox) {
- AdvancedMessageBox messageBox = (AdvancedMessageBox) message;
+ } else if (message instanceof AdvancedMessageBox messageBox) {
int x = messageBox.getX();
int y = messageBox.getY();
int z = messageBox.getZ();
@@ -192,7 +184,7 @@ else if (command.getName().equalsIgnoreCase("tj")) {
public static String colourise(String message) {
Matcher matcher = HEX_PATTERN.matcher(ChatColor.translateAlternateColorCodes('&', message));
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
while (matcher.find()) {
matcher.appendReplacement(buffer, ChatColor.of(matcher.group(1)).toString());
@@ -202,22 +194,18 @@ public static String colourise(String message) {
}
private AdvancedMessage advancedMessage(String[] args) {
- switch (args[0]) {
- case "-r":
- return new RadiusMessage(String.join(" ", Arrays.copyOfRange(args, 2, args.length)), Integer.parseUnsignedInt(args[1]));
- case "-rxyz":
- return new RadiusMessageCoordinates(
- String.join(" ", Arrays.copyOfRange(args, 2, args.length)),
- Integer.parseUnsignedInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4])
- );
- case "-d":
- return new AdvancedMessageBox(
- String.join(" ", Arrays.copyOfRange(args, 2, args.length)),
- Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6])
- );
- default:
- return new AdvancedMessage(String.join(" ", args));
- }
+ return switch (args[0]) {
+ case "-r" -> new RadiusMessage(String.join(" ", Arrays.copyOfRange(args, 2, args.length)), Integer.parseUnsignedInt(args[1]));
+ case "-rxyz" -> new RadiusMessageCoordinates(
+ String.join(" ", Arrays.copyOfRange(args, 2, args.length)),
+ Integer.parseUnsignedInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4])
+ );
+ case "-d" -> new AdvancedMessageBox(
+ String.join(" ", Arrays.copyOfRange(args, 2, args.length)),
+ Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6])
+ );
+ default -> new AdvancedMessage(String.join(" ", args));
+ };
}
private void sendJsonMessage(Player player, String message) {