3
0
Fork 0

Fixed some issues

This commit is contained in:
stijnb1234 2020-04-22 21:26:31 +02:00
parent ddde487295
commit 95cf389a69
5 changed files with 49 additions and 21 deletions

View file

@ -1,13 +1,22 @@
package nl.sbdeveloper.themeparkplus.api.objects; package nl.sbdeveloper.themeparkplus.api.objects;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
@Getter @Setter import java.util.Objects;
@Getter @Setter @NoArgsConstructor @AllArgsConstructor
public class Gate { public class Gate {
private final Location loc; private String world;
private int x;
private int y;
private int z;
/* If max count */ /* If max count */
private boolean hasMaxCount = false; private boolean hasMaxCount = false;
@ -24,8 +33,11 @@ public class Gate {
* @param loc The gate location * @param loc The gate location
* @param direction The walking direction * @param direction The walking direction
*/ */
public Gate(Location loc, WalkingDirection direction) { public Gate(@NotNull Location loc, WalkingDirection direction) {
this.loc = loc; this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName();
this.x = loc.getBlockX();
this.y = loc.getBlockY();
this.z = loc.getBlockZ();
this.isDirectional = true; this.isDirectional = true;
this.direction = direction; this.direction = direction;
} }
@ -36,8 +48,11 @@ public class Gate {
* @param loc The gate location * @param loc The gate location
* @param maxCount The max player count * @param maxCount The max player count
*/ */
public Gate(Location loc, int maxCount) { public Gate(@NotNull Location loc, int maxCount) {
this.loc = loc; this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName();
this.x = loc.getBlockX();
this.y = loc.getBlockY();
this.z = loc.getBlockZ();
this.hasMaxCount = true; this.hasMaxCount = true;
this.maxCount = maxCount; this.maxCount = maxCount;
} }
@ -49,11 +64,18 @@ public class Gate {
* @param maxCount The max player count * @param maxCount The max player count
* @param direction The walking direction * @param direction The walking direction
*/ */
public Gate(Location loc, int maxCount, WalkingDirection direction) { public Gate(@NotNull Location loc, int maxCount, WalkingDirection direction) {
this.loc = loc; this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName();
this.x = loc.getBlockX();
this.y = loc.getBlockY();
this.z = loc.getBlockZ();
this.hasMaxCount = true; this.hasMaxCount = true;
this.isDirectional = true; this.isDirectional = true;
this.maxCount = maxCount; this.maxCount = maxCount;
this.direction = direction; this.direction = direction;
} }
public Location getLoc() {
return new Location(Bukkit.getWorld(this.world), this.x, this.y, this.z);
}
} }

View file

@ -1,22 +1,17 @@
package nl.sbdeveloper.themeparkplus.api.objects; package nl.sbdeveloper.themeparkplus.api.objects;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.UUID; import java.util.UUID;
@Getter @Setter @Getter @Setter @NoArgsConstructor @AllArgsConstructor
public class MalfunctionReport { public class MalfunctionReport {
private String rideID; private String rideID;
private UUID reporterUUID; private UUID reporterUUID;
private LocalDateTime reportDate; private LocalDateTime reportDate;
private String reason; private String reason;
public MalfunctionReport(String rideID, UUID reporterUUID, LocalDateTime reportDate, String reason) {
this.rideID = rideID;
this.reporterUUID = reporterUUID;
this.reportDate = reportDate;
this.reason = reason;
}
} }

View file

@ -1,12 +1,15 @@
package nl.sbdeveloper.themeparkplus.api.objects; package nl.sbdeveloper.themeparkplus.api.objects;
import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.AbstractRegion;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.bukkit.Location; import org.bukkit.Location;
import java.util.ArrayList; import java.util.ArrayList;
@NoArgsConstructor @AllArgsConstructor
public class WaitingRow { public class WaitingRow {
@Getter @Setter private String rideID; @Getter @Setter private String rideID;
@Getter @Setter private AbstractRegion region; @Getter @Setter private AbstractRegion region;

View file

@ -34,6 +34,9 @@ public class FastpassListeners implements Listener {
Player p = e.getPlayer(); Player p = e.getPlayer();
String[] lines = e.getLines(); String[] lines = e.getLines();
//Only check themeparkplus signs!
if (!lines[0].equalsIgnoreCase("[ThemeParkPlus]")) return;
if (!p.hasPermission("tpp.fastpass.create")) { if (!p.hasPermission("tpp.fastpass.create")) {
p.sendMessage(ConfigUtil.getMessage("General.NoPermission")); p.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return; return;
@ -49,10 +52,10 @@ public class FastpassListeners implements Listener {
String sLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1")); String sLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1"));
String sLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2")); String sLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2"));
if (lines[0].equalsIgnoreCase("[ThemeParkPlus]") && lines[1].equalsIgnoreCase("Machine") && !lines[2].isEmpty() && !lines[3].isEmpty()) { if (lines[1].equalsIgnoreCase("Machine") && !lines[2].isEmpty() && !lines[3].isEmpty()) {
e.setLine(0, mLineOne); e.setLine(0, mLineOne);
e.setLine(1, mLineTwo); e.setLine(1, mLineTwo);
} else if (lines[0].equalsIgnoreCase("[ThemeParkPlus]") && lines[1].equalsIgnoreCase("Scanner") && !lines[2].isEmpty() && !lines[3].isEmpty()) { } else if (lines[1].equalsIgnoreCase("Scanner") && !lines[2].isEmpty() && !lines[3].isEmpty()) {
e.setLine(0, sLineOne); e.setLine(0, sLineOne);
e.setLine(1, sLineTwo); e.setLine(1, sLineTwo);
} else { } else {
@ -132,9 +135,14 @@ public class FastpassListeners implements Listener {
Attraction att = API.getAttraction(sign.getLine(2)); Attraction att = API.getAttraction(sign.getLine(2));
ItemStack content = e.getPlayer().getInventory().getItemInMainHand(); ItemStack content = e.getPlayer().getInventory().getItemInMainHand();
NBTItem nbtContent = new NBTItem(content);
if (content.getType() == Material.AIR if (content.getType() == Material.AIR
|| !content.hasItemMeta() || !nbtContent.hasKey("RideID")) { || !content.hasItemMeta()) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.NoTicket"));
return;
}
NBTItem nbtContent = new NBTItem(content);
if (!nbtContent.hasKey("RideID")) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.NoTicket")); e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.NoTicket"));
return; return;
} }

View file

@ -13,7 +13,7 @@ Gates:
Closed: '&aThe gate is closed!' Closed: '&aThe gate is closed!'
Fastpass: Fastpass:
IncorrectSign: '&cThis sign is incorrect. Please read the wiki for more information.' IncorrectSign: '&cThis sign is incorrect. Please read the wiki for more information.'
UnknownRide: '&cThe ride %ridename% &cdoes''nt exists.' UnknownRide: '&cThe ride %ridename% &cdoesn''t exists.'
NotEnoughMoney: '&cYou can''t pay this ticket.' NotEnoughMoney: '&cYou can''t pay this ticket.'
AlreadyHaveTicket: '&cYou''ve already got a ticket for this ride.' AlreadyHaveTicket: '&cYou''ve already got a ticket for this ride.'
Bought: '&aYou''ve successfully bought a ticket for the ride %ridename%&a. You''ve paid &f%price% &afor it.' Bought: '&aYou''ve successfully bought a ticket for the ride %ridename%&a. You''ve paid &f%price% &afor it.'