3
0
Fork 0

v2.1.4 - Fixed bugs with fastpass and directional gates

This commit is contained in:
stijnb1234 2020-11-21 11:29:17 +01:00
parent 127e9bc9f6
commit 3f20b429f8
8 changed files with 51 additions and 21 deletions

View file

@ -6,7 +6,7 @@
<groupId>nl.SBDeveloper</groupId>
<artifactId>ThemeParkPlus</artifactId>
<version>2.1.3</version>
<version>2.1.4</version>
<packaging>jar</packaging>
<name>ThemeParkPlus</name>
@ -143,7 +143,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.4.1</version>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>

View file

@ -82,7 +82,7 @@ public final class ThemeParkPlus extends JavaPlugin {
new License(this, "TP", config.getFile().getString("License"));
if (getSConfig().getFile().getBoolean("UpdateChecker.Enabled")) {
UpdateManager updateManager = new UpdateManager(this, 7, UpdateManager.CheckType.SBDPLUGINS);
UpdateManager updateManager = new UpdateManager(this, 6, UpdateManager.CheckType.SBDPLUGINS);
updateManager.handleResponse((versionResponse, version) -> {
if (versionResponse == UpdateManager.VersionResponse.FOUND_NEW) {

View file

@ -1,23 +1,19 @@
package nl.sbdeveloper.themeparkplus.api.enums;
import nl.sbdeveloper.themeparkplus.util.DirectionUtil;
import org.bukkit.block.BlockFace;
public enum WalkingDirection {
/**
* The walking direction. Removed combinations because those can't be used in the commands.
* The walking direction.
* We can't use BlockFace here, because we only support 4 directions.
*/
NORTH(BlockFace.NORTH),
EAST(BlockFace.EAST),
SOUTH(BlockFace.SOUTH),
WEST(BlockFace.WEST);
private final BlockFace blockFace;
WalkingDirection(BlockFace blockFace) {
this.blockFace = blockFace;
}
NORTH,
EAST,
SOUTH,
WEST;
public BlockFace getBlockFace() {
return blockFace;
return DirectionUtil.convertFacing(this);
}
}

View file

@ -8,7 +8,7 @@ import lombok.Setter;
import java.time.LocalDateTime;
import java.util.UUID;
/** Please don't use! It's not implemented yet. */
/** @deprecated Please don't use! It's not implemented yet. */
@Getter @Setter @NoArgsConstructor @AllArgsConstructor
public class MalfunctionReport {
private String rideID;

View file

@ -103,6 +103,11 @@ public class FastpassListeners implements Listener {
return;
}
if (!nbtContent.getString("RideID").equals(att.getId())) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.IncorrectTicket"));
return;
}
if (att.getStatus() != Status.OPEN && att.getStatus() != Status.ACTIVE) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.RideClosed"));
return;

View file

@ -1,6 +1,7 @@
package nl.sbdeveloper.themeparkplus.util;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
import org.bukkit.block.BlockFace;
import org.jetbrains.annotations.Nullable;
public class DirectionUtil {
@ -25,4 +26,19 @@ public class DirectionUtil {
}
return null;
}
public static BlockFace convertFacing(WalkingDirection dir) {
switch (dir) {
case WEST:
return BlockFace.SOUTH;
case NORTH:
return BlockFace.WEST;
case EAST:
return BlockFace.NORTH;
case SOUTH:
return BlockFace.EAST;
default:
return null;
}
}
}

View file

@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -38,9 +39,9 @@ public class License implements Listener {
Written by Stijn Bannink <stijnbannink23@gmail.com>, January 2020
*/
private JavaPlugin plugin; // The plugin instance
private String license; // The license code
private String prefix; // The correct prefix for this plugin
private final JavaPlugin plugin; // The plugin instance
private final String license; // The license code
private final String prefix; // The correct prefix for this plugin
@Nullable private String invalidReason; // The reason the license is invalid, if null it's not invalid!
@Nullable private static Boolean valid; // If true, it's valid, if false, it's not valid, if null it's not checked!
@ -243,16 +244,19 @@ public class License implements Listener {
disable("404_error");
return null;
}
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8));
String inputLine;
boolean firstLine = true;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
if (firstLine) { inputLine = removeUTF8BOM(inputLine); firstLine = false; }
response.append(inputLine);
}
in.close();
JsonParser parser = new JsonParser();
return parser.parse(response.toString()).getAsJsonObject();
return parser.parse(response.toString().replace("´╗┐", "")).getAsJsonObject();
}
private boolean checkPortValue(int input, @NotNull String dataValue) {
@ -293,6 +297,14 @@ public class License implements Listener {
return false;
}
private String removeUTF8BOM (String s) {
String UTF8_BOM = "\uFEFF";
if (s.startsWith(UTF8_BOM)) {
s = s.substring(1);
}
return s;
}
/**
* Check if the license is valid
*

View file

@ -21,6 +21,7 @@ Fastpass:
Bought: '&aYou''ve successfully bought a ticket for the ride %ridename%&a. You''ve paid &f%price% &afor it.'
Given: '&aYou''ve successfully given a ticket.'
NoTicket: '&cYou need a fastpass ticket to go through the fastpass line.'
IncorrectTicket: '&cThis fastpass ticket is not for this ride.'
RideClosed: '&cThis ride is closed.'
Redeemed: '&aSuccessfully redeemed your fastpass ticket!'
Lamp: