3
0
Fork 0

Updated to 1.18.1, a lot of cleanup, and working on ParkPlusMC hook.

This commit is contained in:
stijnb1234 2022-01-17 19:27:57 +01:00
parent 6567cea624
commit d20f7376de
34 changed files with 684 additions and 758 deletions

107
pom.xml
View file

@ -54,41 +54,41 @@
<shadedPattern>nl.sbdeveloper.themeparkplus.libs.bstats</shadedPattern> <shadedPattern>nl.sbdeveloper.themeparkplus.libs.bstats</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>com.samjakob.spigui</pattern> <pattern>fr.minuskube.inv</pattern>
<shadedPattern>nl.sbdeveloper.themeparkplus.libs.spigui</shadedPattern> <shadedPattern>nl.sbdeveloper.themeparkplus.libs.smartinvs</shadedPattern>
</relocation> </relocation>
</relocations> </relocations>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Delombok the source for the javadoc --> <!-- &lt;!&ndash; Delombok the source for the javadoc &ndash;&gt;-->
<plugin> <!-- <plugin>-->
<groupId>org.projectlombok</groupId> <!-- <groupId>org.projectlombok</groupId>-->
<artifactId>lombok-maven-plugin</artifactId> <!-- <artifactId>lombok-maven-plugin</artifactId>-->
<version>1.18.12.0</version> <!-- <version>1.18.12.0</version>-->
<executions> <!-- <executions>-->
<execution> <!-- <execution>-->
<phase>generate-sources</phase> <!-- <phase>generate-sources</phase>-->
<goals> <!-- <goals>-->
<goal>delombok</goal> <!-- <goal>delombok</goal>-->
</goals> <!-- </goals>-->
</execution> <!-- </execution>-->
</executions> <!-- </executions>-->
</plugin> <!-- </plugin>-->
<!-- Build the javadoc --> <!-- &lt;!&ndash; Build the javadoc &ndash;&gt;-->
<plugin> <!-- <plugin>-->
<artifactId>maven-javadoc-plugin</artifactId> <!-- <artifactId>maven-javadoc-plugin</artifactId>-->
<version>3.2.0</version> <!-- <version>3.2.0</version>-->
<configuration> <!-- <configuration>-->
<release>11</release> <!-- <release>11</release>-->
<sourceFileIncludes> <!-- <sourceFileIncludes>-->
<include>nl/sbdeveloper/themeparkplus/api/*.java</include> <!-- <include>nl/sbdeveloper/themeparkplus/api/*.java</include>-->
<include>nl/sbdeveloper/themeparkplus/api/enums/*.java</include> <!-- <include>nl/sbdeveloper/themeparkplus/api/enums/*.java</include>-->
<include>nl/sbdeveloper/themeparkplus/api/objects/*.java</include> <!-- <include>nl/sbdeveloper/themeparkplus/api/objects/*.java</include>-->
</sourceFileIncludes> <!-- </sourceFileIncludes>-->
</configuration> <!-- </configuration>-->
</plugin> <!-- </plugin>-->
</plugins> </plugins>
<resources> <resources>
<resource> <resource>
@ -115,37 +115,39 @@
<id>sk89q-repo</id> <id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url> <url>https://maven.enginehub.org/repo/</url>
</repository> </repository>
<repository>
<name>jcenter</name>
<id>bintray-jcenter</id>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version> <version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.paradoxpixel</groupId> <groupId>me.paradoxpixel</groupId>
<artifactId>themepark</artifactId> <artifactId>themepark</artifactId>
<version>3.0.0</version> <version>3.1.1</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${pom.basedir}/src/lib/themepark-3.0.0.jar</systemPath> <systemPath>${pom.basedir}/src/lib/themepark-3.1.1.jar</systemPath>
</dependency>
<dependency>
<groupId>me.paradoxpixel</groupId>
<artifactId>parkplusmc</artifactId>
<version>1.4</version>
<scope>system</scope>
<systemPath>${pom.basedir}/src/lib/parkplus-1.4.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.12</version> <version>1.18.22</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>de.tr7zw</groupId> <groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId> <artifactId>item-nbt-api</artifactId>
<version>2.7.1</version> <version>2.8.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.MilkBowl</groupId> <groupId>com.github.MilkBowl</groupId>
@ -156,38 +158,23 @@
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>3.4.5</version> <version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>
<version>1.7</version> <version>2.2.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codemc.worldguardwrapper</groupId> <groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper</artifactId> <artifactId>worldguardwrapper</artifactId>
<version>1.1.9-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.samjakob</groupId> <groupId>fr.minuskube.inv</groupId>
<artifactId>SpiGUI</artifactId> <artifactId>smart-invs</artifactId>
<version>v1.1</version> <version>1.2.7</version>
<exclusions>
<exclusion>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

BIN
src/lib/parkplus-1.4.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
src/lib/themepark-3.1.1.jar Normal file

Binary file not shown.

View file

@ -1,20 +1,18 @@
package nl.sbdeveloper.themeparkplus; package nl.sbdeveloper.themeparkplus;
import com.samjakob.spigui.SpiGUI;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import nl.sbdeveloper.themeparkplus.commands.TPPCMD; import nl.sbdeveloper.themeparkplus.commands.TPPCMD;
import nl.sbdeveloper.themeparkplus.commands.TPPTabComplete;
import nl.sbdeveloper.themeparkplus.listeners.*; import nl.sbdeveloper.themeparkplus.listeners.*;
import nl.sbdeveloper.themeparkplus.managers.DBManager; import nl.sbdeveloper.themeparkplus.managers.DBManager;
import nl.sbdeveloper.themeparkplus.sbutils.UpdateManager; import nl.sbdeveloper.themeparkplus.sbutils.UpdateManager;
import nl.sbdeveloper.themeparkplus.sbutils.YamlFile; import nl.sbdeveloper.themeparkplus.sbutils.YamlFile;
import nl.sbdeveloper.themeparkplus.util.Inventory;
import nl.sbdeveloper.themeparkplus.util.License; import nl.sbdeveloper.themeparkplus.util.License;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
@ -24,7 +22,6 @@ import java.util.HashMap;
import java.util.Objects; import java.util.Objects;
public final class ThemeParkPlus extends JavaPlugin { public final class ThemeParkPlus extends JavaPlugin {
private static ThemeParkPlus instance; private static ThemeParkPlus instance;
private static YamlFile config; private static YamlFile config;
private static DBManager data; private static DBManager data;
@ -33,11 +30,9 @@ public final class ThemeParkPlus extends JavaPlugin {
private static Economy econ = null; private static Economy econ = null;
private static String webhookURL; private static String webhookURL;
private static SpiGUI spiGUI;
private final int configVersion = 3; private final int configVersion = 3;
private static boolean hasTPHook = false; private static boolean hasParkHook = false;
@Override @Override
public void onEnable() { public void onEnable() {
@ -107,7 +102,6 @@ public final class ThemeParkPlus extends JavaPlugin {
Bukkit.getLogger().info("[ThemeParkPlus] Loading commands..."); Bukkit.getLogger().info("[ThemeParkPlus] Loading commands...");
getCommand("themeparkplus").setExecutor(new TPPCMD()); getCommand("themeparkplus").setExecutor(new TPPCMD());
getCommand("themeparkplus").setTabCompleter(new TPPTabComplete());
Bukkit.getLogger().info("[ThemeParkPlus] Loading listeners..."); Bukkit.getLogger().info("[ThemeParkPlus] Loading listeners...");
Bukkit.getPluginManager().registerEvents(new DirectionalGateListener(), this); Bukkit.getPluginManager().registerEvents(new DirectionalGateListener(), this);
@ -117,14 +111,17 @@ public final class ThemeParkPlus extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new AntiFreerunListener(), this); Bukkit.getPluginManager().registerEvents(new AntiFreerunListener(), this);
} }
if (Bukkit.getPluginManager().getPlugin("ThemePark") == null) { if (Bukkit.getPluginManager().getPlugin("ThemePark") == null && Bukkit.getPluginManager().getPlugin("ParkPlusMC") == null) {
Bukkit.getLogger().severe("[ThemeParkPlus] Missing ThemePark! Some functions will not work without it!"); getLogger().severe("ThemePark or ParkPlusMC not found! Some functions will not work without it!");
} else { } else if (Bukkit.getPluginManager().getPlugin("ThemePark") != null) {
Bukkit.getLogger().severe("[ThemeParkPlus] Enabling ThemePark hook..."); getLogger().severe("Enabling ThemePark hook...");
hasTPHook = true; hasParkHook = true;
} else if (Bukkit.getPluginManager().getPlugin("ParkPlusMC") != null) {
getLogger().severe("Enabling ParkPlusMC hook...");
hasParkHook = true;
} }
if (hasTPHook) { if (hasParkHook) {
Bukkit.getPluginManager().registerEvents(new FastpassListeners(), this); Bukkit.getPluginManager().registerEvents(new FastpassListeners(), this);
Bukkit.getPluginManager().registerEvents(new MalfunctionListener(), this); Bukkit.getPluginManager().registerEvents(new MalfunctionListener(), this);
@ -142,8 +139,7 @@ public final class ThemeParkPlus extends JavaPlugin {
} }
Bukkit.getLogger().info("[ThemeParkPlus] Loading GUI helper..."); Bukkit.getLogger().info("[ThemeParkPlus] Loading GUI helper...");
spiGUI = new SpiGUI(this); Inventory.init(this);
spiGUI.setEnableAutomaticPagination(false);
Bukkit.getLogger().info("[ThemeParkPlus] Loading data..."); Bukkit.getLogger().info("[ThemeParkPlus] Loading data...");
try { try {
@ -232,12 +228,8 @@ public final class ThemeParkPlus extends JavaPlugin {
return webhookURL; return webhookURL;
} }
public static SpiGUI getSpiGUI() { public static boolean hasParkHook() {
return spiGUI; return hasParkHook;
}
public static boolean hasTPHook() {
return hasTPHook;
} }
private boolean setupEconomy() { private boolean setupEconomy() {
@ -266,7 +258,6 @@ public final class ThemeParkPlus extends JavaPlugin {
} }
} }
@NotNull
private HashMap<String, Object> getConfigVals() { private HashMap<String, Object> getConfigVals() {
HashMap<String, Object> var = new HashMap <>(); HashMap<String, Object> var = new HashMap <>();
Reader defConfigStream = new InputStreamReader(Objects.requireNonNull(getResource("config.yml")), StandardCharsets.UTF_8); Reader defConfigStream = new InputStreamReader(Objects.requireNonNull(getResource("config.yml")), StandardCharsets.UTF_8);

View file

@ -12,8 +12,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.codemc.worldguardwrapper.WorldGuardWrapper; import org.codemc.worldguardwrapper.WorldGuardWrapper;
import org.codemc.worldguardwrapper.region.IWrappedRegion; import org.codemc.worldguardwrapper.region.IWrappedRegion;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
@ -56,7 +54,7 @@ public class PlusAPI {
* *
* @param gate The gate * @param gate The gate
*/ */
public static void removeGate(@NotNull Gate gate) { public static void removeGate(Gate gate) {
gates.remove(gate.getLoc()); gates.remove(gate.getLoc());
} }
@ -103,7 +101,7 @@ public class PlusAPI {
* *
* @param row The row * @param row The row
*/ */
public static void removeRow(@NotNull WaitingRow row) { public static void removeRow(WaitingRow row) {
rows.remove(row.getRideID()); rows.remove(row.getRideID());
} }
@ -133,7 +131,6 @@ public class PlusAPI {
* @param loc The location * @param loc The location
* @return The row * @return The row
*/ */
@Nullable
public static WaitingRow getRow(Location loc) { public static WaitingRow getRow(Location loc) {
if (loc == null) return null; if (loc == null) return null;
Set<IWrappedRegion> set = WorldGuardWrapper.getInstance().getRegions(loc); Set<IWrappedRegion> set = WorldGuardWrapper.getInstance().getRegions(loc);
@ -151,7 +148,6 @@ public class PlusAPI {
* @param signLoc The sign location * @param signLoc The sign location
* @return The row * @return The row
*/ */
@NotNull
public static Optional<WaitingRow> getRowBySign(Location signLoc) { public static Optional<WaitingRow> getRowBySign(Location signLoc) {
return rows.values().stream().filter(row -> row.getSignLocations().contains(signLoc)).findFirst(); return rows.values().stream().filter(row -> row.getSignLocations().contains(signLoc)).findFirst();
} }
@ -172,9 +168,8 @@ public class PlusAPI {
* *
* @return The ticket as ItemStack * @return The ticket as ItemStack
*/ */
@Nullable
public static ItemStack getFastpassTicket(nl.iobyte.themepark.api.attraction.objects.Attraction att) { public static ItemStack getFastpassTicket(nl.iobyte.themepark.api.attraction.objects.Attraction att) {
String ticketName = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.Item.DisplayName")); String ticketName = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.Item.DisplayName"));
ItemStack ticket = XMaterial.PAPER.parseItem(); ItemStack ticket = XMaterial.PAPER.parseItem();
if (ticket == null) return null; if (ticket == null) return null;

View file

@ -7,7 +7,6 @@ import lombok.Setter;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
import java.util.Objects; import java.util.Objects;
@ -33,7 +32,7 @@ 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(@NotNull Location loc, WalkingDirection direction) { public Gate(Location loc, WalkingDirection direction) {
this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName(); this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName();
this.x = loc.getBlockX(); this.x = loc.getBlockX();
this.y = loc.getBlockY(); this.y = loc.getBlockY();
@ -48,7 +47,7 @@ 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(@NotNull Location loc, int maxCount) { public Gate(Location loc, int maxCount) {
this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName(); this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName();
this.x = loc.getBlockX(); this.x = loc.getBlockX();
this.y = loc.getBlockY(); this.y = loc.getBlockY();
@ -64,7 +63,7 @@ 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(@NotNull Location loc, int maxCount, WalkingDirection direction) { public Gate(Location loc, int maxCount, WalkingDirection direction) {
this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName(); this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName();
this.x = loc.getBlockX(); this.x = loc.getBlockX();
this.y = loc.getBlockY(); this.y = loc.getBlockY();

View file

@ -1,5 +1,6 @@
package nl.sbdeveloper.themeparkplus.commands; package nl.sbdeveloper.themeparkplus.commands;
import nl.iobyte.themepark.ThemePark;
import nl.sbdeveloper.themeparkplus.ThemeParkPlus; import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import nl.sbdeveloper.themeparkplus.api.PlusAPI; import nl.sbdeveloper.themeparkplus.api.PlusAPI;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
@ -15,18 +16,18 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.bukkit.util.StringUtil;
import java.util.Collections; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
public class TPPCMD implements CommandExecutor { public class TPPCMD implements TabExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) { if (args.length == 0) {
return helpCommand(sender); return helpCommand(sender);
} else if (args[0].equalsIgnoreCase("info") && args.length == 1) { } else if (args[0].equalsIgnoreCase("info") && args.length == 1) {
@ -194,7 +195,7 @@ public class TPPCMD implements CommandExecutor {
} }
private boolean giveFPTicketCommand(CommandSender sender, String[] args) { private boolean giveFPTicketCommand(CommandSender sender, String[] args) {
if (!ThemeParkPlus.hasTPHook()) { if (!ThemeParkPlus.hasParkHook()) {
sender.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark")); sender.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark"));
return true; return true;
} }
@ -231,7 +232,7 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
private boolean infoCommand(@NotNull CommandSender sender) { private boolean infoCommand(CommandSender sender) {
sender.sendMessage("§1=================================="); sender.sendMessage("§1==================================");
sender.sendMessage("§6ThemeParkPlus plugin made by §aSBDeveloper"); sender.sendMessage("§6ThemeParkPlus plugin made by §aSBDeveloper");
sender.sendMessage("§6Version: " + ThemeParkPlus.getInstance().getDescription().getVersion()); sender.sendMessage("§6Version: " + ThemeParkPlus.getInstance().getDescription().getVersion());
@ -240,7 +241,7 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
private boolean helpCommand(@NotNull CommandSender sender) { private boolean helpCommand(CommandSender sender) {
sender.sendMessage("§8ThemeParkPlus commands:"); sender.sendMessage("§8ThemeParkPlus commands:");
sender.sendMessage("§6/themeparkplus info§f: Gives you information about the plugin."); sender.sendMessage("§6/themeparkplus info§f: Gives you information about the plugin.");
sender.sendMessage("§6/themeparkplus help§f: Gives you this help page."); sender.sendMessage("§6/themeparkplus help§f: Gives you this help page.");
@ -259,7 +260,7 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
private boolean openGate(CommandSender sender, @NotNull String[] args, int amount, WalkingDirection dir) { private boolean openGate(CommandSender sender, String[] args, int amount, WalkingDirection dir) {
World bworld = Bukkit.getWorld(args[1]); World bworld = Bukkit.getWorld(args[1]);
double bx = Double.parseDouble(args[2]); double bx = Double.parseDouble(args[2]);
double by = Double.parseDouble(args[3]); double by = Double.parseDouble(args[3]);
@ -307,7 +308,7 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
private boolean closeGate(CommandSender sender, @NotNull String[] args) { private boolean closeGate(CommandSender sender, String[] args) {
World bworld = Bukkit.getWorld(args[1]); World bworld = Bukkit.getWorld(args[1]);
double bx = Double.parseDouble(args[2]); double bx = Double.parseDouble(args[2]);
double by = Double.parseDouble(args[3]); double by = Double.parseDouble(args[3]);
@ -336,7 +337,7 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
private boolean lampTurnOnCommand(CommandSender sender, @NotNull String[] args, int secOn) { private boolean lampTurnOnCommand(CommandSender sender, String[] args, int secOn) {
World bworld = Bukkit.getWorld(args[1]); World bworld = Bukkit.getWorld(args[1]);
double bx = Double.parseDouble(args[2]); double bx = Double.parseDouble(args[2]);
double by = Double.parseDouble(args[3]); double by = Double.parseDouble(args[3]);
@ -357,13 +358,13 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
Bukkit.getScheduler().runTaskLater(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampUit(block), secOn * 20); Bukkit.getScheduler().runTaskLater(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampUit(block), secOn * 20L);
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamp.TurnedOnSec", Collections.singletonMap("%sec%", String.valueOf(secOn)))); if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamp.TurnedOnSec", Collections.singletonMap("%sec%", String.valueOf(secOn))));
} }
return true; return true;
} }
private boolean lampTurnOffCommand(CommandSender sender, @NotNull String[] args) { private boolean lampTurnOffCommand(CommandSender sender, String[] args) {
World bworld = Bukkit.getWorld(args[1]); World bworld = Bukkit.getWorld(args[1]);
double bx = Double.parseDouble(args[2]); double bx = Double.parseDouble(args[2]);
double by = Double.parseDouble(args[3]); double by = Double.parseDouble(args[3]);
@ -379,7 +380,7 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
private boolean lampsTurnOnCommand(CommandSender sender, @NotNull String[] args, int secOn) { private boolean lampsTurnOnCommand(CommandSender sender, String[] args, int secOn) {
World bworld = Bukkit.getWorld(args[1]); World bworld = Bukkit.getWorld(args[1]);
double bx = Double.parseDouble(args[2]); double bx = Double.parseDouble(args[2]);
@ -413,7 +414,7 @@ public class TPPCMD implements CommandExecutor {
return true; return true;
} }
private boolean lampsTurnOffCommand(@NotNull CommandSender sender, @NotNull String[] args) { private boolean lampsTurnOffCommand(CommandSender sender, String[] args) {
World bworld = Bukkit.getWorld(args[1]); World bworld = Bukkit.getWorld(args[1]);
double bx = Double.parseDouble(args[2]); double bx = Double.parseDouble(args[2]);
@ -436,4 +437,82 @@ public class TPPCMD implements CommandExecutor {
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOff")); if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOff"));
return true; return true;
} }
private static final List<String> COMMANDS = Arrays.asList("info", "help", "opengate", "closegate", "lampon", "lampoff", "lampson", "lampsoff", "redstonetimer", "givefpticket");
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
//Aliases
if (label.equalsIgnoreCase("themeparkplus") || label.equalsIgnoreCase("tpp") || label.equalsIgnoreCase("themeparkp")) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], COMMANDS, new ArrayList<>());
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[1], Collections.singletonList("" + targetLoc.getWorld().getName()), new ArrayList<>());
}
} else if (args[0].equalsIgnoreCase("givefpticket")) {
return StringUtil.copyPartialMatches(args[1], ThemePark.getInstance().getAPI().getAttractionService().getAttractions().keySet(), new ArrayList<>());
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[2], Collections.singletonList("" + targetLoc.getBlockX()), new ArrayList<>());
}
} else if (args[0].equalsIgnoreCase("givefpticket")) {
return StringUtil.copyPartialMatches(args[1], Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()), new ArrayList<>());
}
} else if (args.length == 4) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[3], Collections.singletonList("" + targetLoc.getBlockY()), new ArrayList<>());
}
}
} else if (args.length == 5) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[4], Collections.singletonList("" + targetLoc.getBlockZ()), new ArrayList<>());
}
}
} else if (args.length == 6) {
if (args[0].equalsIgnoreCase("opengate")) {
return StringUtil.copyPartialMatches(args[5], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>());
}
} else if (args.length == 7) {
if (args[0].equalsIgnoreCase("opengate")) {
return StringUtil.copyPartialMatches(args[6], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>());
}
}
}
return null;
}
private Block getTarget(Player p) {
return p.getTargetBlock(null, 200);
}
} }

View file

@ -1,8 +1,9 @@
package nl.sbdeveloper.themeparkplus.gui; package nl.sbdeveloper.themeparkplus.gui;
import com.samjakob.spigui.SGMenu; import fr.minuskube.inv.ClickableItem;
import com.samjakob.spigui.buttons.SGButton; import fr.minuskube.inv.content.InventoryContents;
import com.samjakob.spigui.item.ItemBuilder; import fr.minuskube.inv.content.SlotPos;
import nl.iobyte.menuapi.item.ItemBuilder;
import nl.iobyte.themepark.ThemePark; import nl.iobyte.themepark.ThemePark;
import nl.iobyte.themepark.api.attraction.enums.Status; import nl.iobyte.themepark.api.attraction.enums.Status;
import nl.iobyte.themepark.api.attraction.objects.Attraction; import nl.iobyte.themepark.api.attraction.objects.Attraction;
@ -10,10 +11,10 @@ import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import nl.sbdeveloper.themeparkplus.api.PlusAPI; import nl.sbdeveloper.themeparkplus.api.PlusAPI;
import nl.sbdeveloper.themeparkplus.api.objects.MalfunctionReport; import nl.sbdeveloper.themeparkplus.api.objects.MalfunctionReport;
import nl.sbdeveloper.themeparkplus.util.ConfigUtil; import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
import nl.sbdeveloper.themeparkplus.util.Inventory;
import nl.sbdeveloper.themeparkplus.util.XMaterial; import nl.sbdeveloper.themeparkplus.util.XMaterial;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -22,46 +23,50 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
public class MalfunctionGUI { import static nl.sbdeveloper.themeparkplus.util.ConfigUtil.__;
public static void open(Attraction att, Player p) {
SGMenu menu = ThemeParkPlus.getSpiGUI().create(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.GUI.Title").replace("%ridename%", att.getName())), 1);
SGButton report = new SGButton(getItem("Report", ConfigUtil.makecolored(att.getName()))).withListener((InventoryClickEvent e) -> { public class MalfunctionGUI extends Inventory {
private final Attraction att;
public MalfunctionGUI(Attraction att, Player p) {
super(1, __(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.GUI.Title").replace("%ridename%", att.getName())));
this.att = att;
open(p);
}
@Override
public void init(Player player, InventoryContents contents) {
contents.set(getSlot("Report"), ClickableItem.of(getItem("Report", __(att.getName())), e -> {
if (!PlusAPI.isReported(att.getID())) { if (!PlusAPI.isReported(att.getID())) {
MalfunctionReport malfunctionReport = new MalfunctionReport(att.getID(), p.getUniqueId()); MalfunctionReport malfunctionReport = new MalfunctionReport(att.getID(), player.getUniqueId());
PlusAPI.addReport(malfunctionReport); PlusAPI.addReport(malfunctionReport);
att.setStatus(Status.MALFUNCTION); att.setStatus(Status.MALFUNCTION);
p.sendMessage(ConfigUtil.getMessage("Malfunction.Reported", Collections.singletonMap("%ride%", att.getName()))); player.sendMessage(ConfigUtil.getMessage("Malfunction.Reported", Collections.singletonMap("%ride%", att.getName())));
} else { } else {
p.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyReported", Collections.singletonMap("%ride%", att.getName()))); player.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyReported", Collections.singletonMap("%ride%", att.getName())));
} }
p.closeInventory(); close(player);
}); }));
menu.setButton(getSlot("Report"), report);
SGButton fix = new SGButton(getItem("Fix", PlusAPI.getReport(att.getID()))).withListener((InventoryClickEvent e) -> { contents.set(getSlot("Fix"), ClickableItem.of(getItem("Fix", PlusAPI.getReport(att.getID())), e -> {
if (PlusAPI.isReported(att.getID())) { if (PlusAPI.isReported(att.getID())) {
PlusAPI.removeReport(att.getID()); PlusAPI.removeReport(att.getID());
att.setStatus(Status.CLOSED); att.setStatus(Status.CLOSED);
p.sendMessage(ConfigUtil.getMessage("Malfunction.Fixed", Collections.singletonMap("%ride%", att.getName()))); player.sendMessage(ConfigUtil.getMessage("Malfunction.Fixed", Collections.singletonMap("%ride%", att.getName())));
} else { } else {
p.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyFixed", Collections.singletonMap("%ride%", att.getName()))); player.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyFixed", Collections.singletonMap("%ride%", att.getName())));
} }
p.closeInventory(); close(player);
}); }));
menu.setButton(getSlot("Fix"), fix);
SGButton cancel = new SGButton(getItem("Cancel")).withListener((InventoryClickEvent e) -> p.closeInventory()); contents.set(getSlot("Cancel"), ClickableItem.of(getItem("Cancel"), e -> close(player)));
menu.setButton(getSlot("Cancel"), cancel);
p.openInventory(menu.getInventory());
} }
private static int getSlot(String type) { private static SlotPos getSlot(String type) {
return ThemeParkPlus.getSConfig().getFile().getInt("Malfunction.GUI.Buttons." + type + ".Slot"); return new SlotPos(0, ThemeParkPlus.getSConfig().getFile().getInt("Malfunction.GUI.Buttons." + type + ".Slot")-1);
} }
private static ItemStack getItem(String type, Object... data) { //data is a string or a report private static ItemStack getItem(String type, Object... data) { //data is a string or a report
@ -97,6 +102,6 @@ public class MalfunctionGUI {
} }
Optional<XMaterial> stack = XMaterial.matchXMaterial(material); Optional<XMaterial> stack = XMaterial.matchXMaterial(material);
return stack.map(xMaterial -> new ItemBuilder(xMaterial.parseItem()).name(name).lore(loresFormatted).build()).orElse(null); return stack.map(xMaterial -> new ItemBuilder(xMaterial.parseItem()).setName(name).setLore(loresFormatted).getItem()).orElse(null);
} }
} }

View file

@ -6,14 +6,13 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
/** /**
* Anti-Freerun effect * Anti-Freerun effect
*/ */
public class AntiFreerunListener implements Listener { public class AntiFreerunListener implements Listener {
@EventHandler @EventHandler
public void onJoin(@NotNull PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (!p.hasPermission("tpp.bypassantifreerun")) { if (!p.hasPermission("tpp.bypassantifreerun")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, -2, false, false)); p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, -2, false, false));

View file

@ -12,14 +12,13 @@ import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.jetbrains.annotations.NotNull;
/** /**
* Gate move listeners (directional and count checks) * Gate move listeners (directional and count checks)
*/ */
public class DirectionalGateListener implements Listener { public class DirectionalGateListener implements Listener {
@EventHandler @EventHandler
public void onWalkThroughFenceGate(@NotNull PlayerMoveEvent e) { public void onWalkThroughFenceGate(PlayerMoveEvent e) {
if (e.getTo() != null if (e.getTo() != null
&& (e.getFrom().getBlockX() != e.getTo().getBlockX() && (e.getFrom().getBlockX() != e.getTo().getBlockX()
|| e.getFrom().getBlockY() != e.getTo().getBlockY() || e.getFrom().getBlockY() != e.getTo().getBlockY()

View file

@ -21,7 +21,6 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -31,13 +30,13 @@ import java.util.HashMap;
*/ */
public class FastpassListeners implements Listener { public class FastpassListeners implements Listener {
@EventHandler @EventHandler
public void onSignClick(@NotNull PlayerInteractEvent e) { public void onSignClick(PlayerInteractEvent e) {
if (e.getClickedBlock() == null || e.getAction() != Action.RIGHT_CLICK_BLOCK || !(e.getClickedBlock().getState() instanceof Sign) || e.getHand() != EquipmentSlot.HAND) return; if (e.getClickedBlock() == null || e.getAction() != Action.RIGHT_CLICK_BLOCK || !(e.getClickedBlock().getState() instanceof Sign) || e.getHand() != EquipmentSlot.HAND) return;
String mLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1"))); String mLineOne = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1")));
String mLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2"))); String mLineTwo = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2")));
String sLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1"))); String sLineOne = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1")));
String sLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2"))); String sLineTwo = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2")));
Sign sign = (Sign) e.getClickedBlock().getState(); Sign sign = (Sign) e.getClickedBlock().getState();
if (!ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mLineOne) && !ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(sLineOne)) return; if (!ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mLineOne) && !ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(sLineOne)) return;
@ -65,7 +64,7 @@ public class FastpassListeners implements Listener {
} }
for (ItemStack content : e.getPlayer().getInventory().getContents()) { for (ItemStack content : e.getPlayer().getInventory().getContents()) {
if (content == null || content.getType() == null || content.getType() == Material.AIR) continue; if (content == null || content.getType() == Material.AIR) continue;
NBTItem nbtContent = new NBTItem(content); NBTItem nbtContent = new NBTItem(content);
if (content.getType() == XMaterial.PAPER.parseMaterial() && content.hasItemMeta() && nbtContent.hasKey("RideID") && nbtContent.getString("RideID").equalsIgnoreCase(attID)) { if (content.getType() == XMaterial.PAPER.parseMaterial() && content.hasItemMeta() && nbtContent.hasKey("RideID") && nbtContent.getString("RideID").equalsIgnoreCase(attID)) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.AlreadyHaveTicket")); e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.AlreadyHaveTicket"));

View file

@ -18,8 +18,8 @@ public class MalfunctionListener implements Listener {
public void onClickSign(PlayerInteractEvent e) { public void onClickSign(PlayerInteractEvent e) {
if (e.getClickedBlock() == null || e.getAction() != Action.RIGHT_CLICK_BLOCK || !(e.getClickedBlock().getState() instanceof Sign) || e.getHand() != EquipmentSlot.HAND) return; if (e.getClickedBlock() == null || e.getAction() != Action.RIGHT_CLICK_BLOCK || !(e.getClickedBlock().getState() instanceof Sign) || e.getHand() != EquipmentSlot.HAND) return;
String mrLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1"))); String mrLineOne = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1")));
String mrLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2"))); String mrLineTwo = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2")));
Sign sign = (Sign) e.getClickedBlock().getState(); Sign sign = (Sign) e.getClickedBlock().getState();
if (ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mrLineOne) && ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(mrLineTwo)) { if (ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mrLineOne) && ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(mrLineTwo)) {
@ -27,7 +27,7 @@ public class MalfunctionListener implements Listener {
if (!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(attID)) return; if (!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(attID)) return;
Attraction att = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(attID); Attraction att = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(attID);
MalfunctionGUI.open(att, e.getPlayer()); new MalfunctionGUI(att, e.getPlayer());
} }
} }
} }

View file

@ -11,7 +11,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Optional; import java.util.Optional;
@ -28,14 +27,14 @@ public class SignListeners implements Listener {
*/ */
@EventHandler @EventHandler
public void onCreate(@NotNull SignChangeEvent e) { public void onCreate(SignChangeEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
String[] lines = e.getLines(); String[] lines = e.getLines();
//Only check themeparkplus signs! //Only check themeparkplus signs!
if (!lines[0].equalsIgnoreCase("[ThemeParkPlus]")) return; if (!lines[0].equalsIgnoreCase("[ThemeParkPlus]")) return;
if (!ThemeParkPlus.hasTPHook()) { if (!ThemeParkPlus.hasParkHook()) {
p.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark")); p.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark"));
return; return;
} }
@ -50,14 +49,14 @@ public class SignListeners implements Listener {
return; return;
} }
String mLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1")); String mLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1"));
String mLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2")); String mLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2"));
String sLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1")); String sLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1"));
String sLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2")); String sLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2"));
String wrLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row1")); String wrLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row1"));
String wrLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row2")); String wrLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row2"));
String mrLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1")); String mrLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1"));
String mrLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2")); String mrLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2"));
if (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);
@ -80,7 +79,7 @@ public class SignListeners implements Listener {
e.setLine(0, wrLineOne); e.setLine(0, wrLineOne);
e.setLine(1, wrLineTwo); e.setLine(1, wrLineTwo);
e.setLine(2, ConfigUtil.makecolored(nl.iobyte.themepark.ThemePark.getInstance().getAPI().getAttractionService().getAttraction(lines[2]).getName())); e.setLine(2, ConfigUtil.__(nl.iobyte.themepark.ThemePark.getInstance().getAPI().getAttractionService().getAttraction(lines[2]).getName()));
e.setLine(3, "0 min."); e.setLine(3, "0 min.");
p.sendMessage(ConfigUtil.getMessage("WaitingRow.SignCreated")); p.sendMessage(ConfigUtil.getMessage("WaitingRow.SignCreated"));
@ -97,7 +96,7 @@ public class SignListeners implements Listener {
BlockState signblocks = e.getBlock().getState(); BlockState signblocks = e.getBlock().getState();
if ((signblocks instanceof Sign)) { if ((signblocks instanceof Sign)) {
Optional<WaitingRow> rowOptional = PlusAPI.getRowBySign(e.getBlock().getLocation()); Optional<WaitingRow> rowOptional = PlusAPI.getRowBySign(e.getBlock().getLocation());
if (!rowOptional.isPresent()) return; if (rowOptional.isEmpty()) return;
WaitingRow row = rowOptional.get(); WaitingRow row = rowOptional.get();
if (row.getSignLocations().size() == 1) { if (row.getSignLocations().size() == 1) {

View file

@ -46,13 +46,13 @@ public class StatusChangeListener implements Listener {
} }
@EventHandler @EventHandler
public void onStatusChange(AttractionStatusChangeEvent e) { public void onStatusChangeTP(AttractionStatusChangeEvent e) {
String title = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Title"); String title = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Title");
if (title == null) return; if (title == null) return;
String rideName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getName())); String rideName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getName()));
String regionName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getRegionID())); String regionName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getRegionID()));
String statusAfter = ChatColor.stripColor(ConfigUtil.makecolored(e.getCurrent().getColor() + e.getCurrent().getName())); String statusAfter = ChatColor.stripColor(ConfigUtil.__(e.getCurrent().getColor() + e.getCurrent().getName()));
title = title.replaceAll("%RideName%", rideName); title = title.replaceAll("%RideName%", rideName);
title = title.replaceAll("%Region%", regionName); title = title.replaceAll("%Region%", regionName);
@ -77,4 +77,37 @@ public class StatusChangeListener implements Listener {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@EventHandler
public void onStatusChangePPMC(nl.iobyte.parkplus.generic.event.attraction.AttractionStatusChangeEvent e) {
String title = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Title");
if (title == null) return;
String rideName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getName()));
String regionName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getRegionID()));
String statusAfter = ChatColor.stripColor(ConfigUtil.__(e.getCurrent().getColor() + e.getCurrent().getName()));
title = title.replaceAll("%RideName%", rideName);
title = title.replaceAll("%Region%", regionName);
String copy = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Copyright");
String copyimg = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.CopyrightImage");
Color color = new Color(ThemeParkPlus.getSConfig().getFile().getInt("DiscordWebhook.Embed.Colors." + e.getCurrent().name()));
if (copy == null || copyimg == null) return;
DiscordWebhook webhook = new DiscordWebhook(ThemeParkPlus.getWebhookURL());
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setTitle(title)
.setFooter(copy, copyimg)
.setColor(color)
.addField(rideName, statusAfter, false);
webhook.addEmbed(embed);
try {
webhook.execute();
} catch (IOException ex) {
Bukkit.getLogger().severe("[ThemeParkPlus] Could not send the status update to Discord! See the error below:");
ex.printStackTrace();
}
}
} }

View file

@ -14,26 +14,24 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.Collections;
public class WaitingTimeListener implements Listener { public class WaitingTimeListener implements Listener {
private static final double PER_PLAYER = ThemeParkPlus.getSConfig().getFile().getDouble("WaitingRow.MinutesPerPlayer"); private static final double PER_PLAYER = ThemeParkPlus.getSConfig().getFile().getDouble("WaitingRow.MinutesPerPlayer");
@EventHandler @EventHandler
public void onPlayerJoin(@NotNull PlayerJoinEvent e) { public void onPlayerJoin(PlayerJoinEvent e) {
doWaitingRowThings(null, e.getPlayer().getLocation().getBlock().getLocation()); doWaitingRowThings(null, e.getPlayer().getLocation().getBlock().getLocation());
} }
@EventHandler @EventHandler
public void onPlayerQuit(@NotNull PlayerQuitEvent e) { public void onPlayerQuit(PlayerQuitEvent e) {
doWaitingRowThings(e.getPlayer().getLocation().getBlock().getLocation(), null); doWaitingRowThings(e.getPlayer().getLocation().getBlock().getLocation(), null);
} }
@EventHandler @EventHandler
public void onTeleport(@NotNull PlayerTeleportEvent e) { public void onTeleport(PlayerTeleportEvent e) {
if (e.getTo() == null) return; if (e.getTo() == null) return;
if ((e.getFrom().getBlockX() != e.getTo().getBlockX()) if ((e.getFrom().getBlockX() != e.getTo().getBlockX())
|| (e.getFrom().getBlockY() != e.getTo().getBlockY()) || (e.getFrom().getBlockY() != e.getTo().getBlockY())
@ -43,7 +41,7 @@ public class WaitingTimeListener implements Listener {
} }
@EventHandler @EventHandler
public void onPlayerMove(@NotNull PlayerMoveEvent e) { public void onPlayerMove(PlayerMoveEvent e) {
if (e.getTo() == null) return; if (e.getTo() == null) return;
if ((e.getFrom().getBlockX() != e.getTo().getBlockX()) if ((e.getFrom().getBlockX() != e.getTo().getBlockX())
|| (e.getFrom().getBlockY() != e.getTo().getBlockY()) || (e.getFrom().getBlockY() != e.getTo().getBlockY())

View file

@ -11,7 +11,6 @@ import nl.sbdeveloper.themeparkplus.sbutils.SQLiteDB;
import nl.sbdeveloper.themeparkplus.util.License; import nl.sbdeveloper.themeparkplus.util.License;
import nl.sbdeveloper.themeparkplus.util.LocationGsonAdapter; import nl.sbdeveloper.themeparkplus.util.LocationGsonAdapter;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -20,6 +19,7 @@ import java.sql.SQLException;
import java.util.Map; import java.util.Map;
public class DBManager { public class DBManager {
private static final Gson gson = new GsonBuilder().registerTypeAdapter(Location.class, new LocationGsonAdapter()).create();
private static SQLiteDB data; private static SQLiteDB data;
private static Connection con; private static Connection con;
@ -46,9 +46,8 @@ public class DBManager {
} }
} }
@NotNull
private Gson getGson() { private Gson getGson() {
return new GsonBuilder().registerTypeAdapter(Location.class, new LocationGsonAdapter()).create(); return gson;
} }
public void load() throws SQLException { public void load() throws SQLException {

View file

@ -2,8 +2,6 @@ package nl.sbdeveloper.themeparkplus.sbutils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class LocationSerializer { public class LocationSerializer {
@ -14,8 +12,7 @@ public class LocationSerializer {
* *
* @return The location or null if error * @return The location or null if error
*/ */
@Nullable public static Location deserialize(String string) {
public static Location deserialize(@NotNull String string) {
String[] split = string.split("_"); String[] split = string.split("_");
if (split.length < 4) return null; if (split.length < 4) return null;
@ -36,8 +33,7 @@ public class LocationSerializer {
* *
* @return The location or null if error * @return The location or null if error
*/ */
@NotNull public static Location deserializePY(String string) {
public static Location deserializePY(@NotNull String string) {
String[] split = string.split("_"); String[] split = string.split("_");
//world_x_y_z //world_x_y_z
@ -58,8 +54,7 @@ public class LocationSerializer {
* *
* @return The serialized string * @return The serialized string
*/ */
@Nullable public static String serialize(Location loc) {
public static String serialize(@NotNull Location loc) {
if (loc.getWorld() == null) return null; if (loc.getWorld() == null) return null;
return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ(); return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ();
} }
@ -71,8 +66,7 @@ public class LocationSerializer {
* *
* @return The serialized string * @return The serialized string
*/ */
@Nullable public static String serializePY(Location loc) {
public static String serializePY(@NotNull Location loc) {
if (loc.getWorld() == null) return null; if (loc.getWorld() == null) return null;
return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ() + "_" + loc.getYaw() + "_" + loc.getPitch(); return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ() + "_" + loc.getYaw() + "_" + loc.getPitch();
} }

View file

@ -12,8 +12,7 @@ import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
public class SQLiteDB { public class SQLiteDB {
private final String dbName;
private String dbName;
private HikariDataSource source; private HikariDataSource source;
private Connection con; private Connection con;

View file

@ -6,8 +6,6 @@ import com.google.gson.JsonParser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import java.io.*; import java.io.*;
@ -51,7 +49,7 @@ public class UpdateManager {
* @param plugin The javaplugin (Main class) * @param plugin The javaplugin (Main class)
* @param resourceID The resourceID on spigot/sbdplugins * @param resourceID The resourceID on spigot/sbdplugins
*/ */
public UpdateManager(@NotNull Plugin plugin, int resourceID) { public UpdateManager(Plugin plugin, int resourceID) {
this.plugin = plugin; this.plugin = plugin;
this.currentVersion = new Version(plugin.getDescription().getVersion()); this.currentVersion = new Version(plugin.getDescription().getVersion());
this.resourceID = resourceID; this.resourceID = resourceID;
@ -66,7 +64,7 @@ public class UpdateManager {
* @param resourceID The resourceID on spigot/sbdplugins * @param resourceID The resourceID on spigot/sbdplugins
* @param license The license for the download * @param license The license for the download
*/ */
public UpdateManager(@NotNull Plugin plugin, int resourceID, String license) { public UpdateManager(Plugin plugin, int resourceID, String license) {
this.plugin = plugin; this.plugin = plugin;
this.currentVersion = new Version(plugin.getDescription().getVersion()); this.currentVersion = new Version(plugin.getDescription().getVersion());
this.resourceID = resourceID; this.resourceID = resourceID;
@ -250,7 +248,6 @@ public class UpdateManager {
}); });
} }
@Nullable
private File getPluginFile() { private File getPluginFile() {
if (!(this.plugin instanceof JavaPlugin)) { return null; } if (!(this.plugin instanceof JavaPlugin)) { return null; }
try { try {
@ -293,7 +290,7 @@ public class UpdateManager {
this.version = version; this.version = version;
} }
private VersionResponse check(@NotNull Version that) { private VersionResponse check(Version that) {
String[] thisParts = this.get().split("\\."); String[] thisParts = this.get().split("\\.");
String[] thatParts = that.get().split("\\."); String[] thatParts = that.get().split("\\.");

View file

@ -17,7 +17,7 @@ public class YamlFile {
private FileConfiguration fileConfiguration; private FileConfiguration fileConfiguration;
private File file; private File file;
private String name; private final String name;
public YamlFile(String name) { public YamlFile(String name) {
this.name = name; this.name = name;

View file

@ -4,7 +4,6 @@ import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -12,36 +11,32 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class ConfigUtil { public class ConfigUtil {
@NotNull public static String __(String str) {
public static String makecolored(String str) {
return ChatColor.translateAlternateColorCodes('&', str); return ChatColor.translateAlternateColorCodes('&', str);
} }
@NotNull
public static List<String> getLore(String path, Map<String, String> vars) { public static List<String> getLore(String path, Map<String, String> vars) {
ArrayList<String> response = new ArrayList<>(); ArrayList<String> response = new ArrayList<>();
for (String str : ThemeParkPlus.getSConfig().getFile().getStringList(path)) { for (String str : ThemeParkPlus.getSConfig().getFile().getStringList(path)) {
for (Map.Entry<String, String> entry : vars.entrySet()) { for (Map.Entry<String, String> entry : vars.entrySet()) {
str = str.replaceAll(entry.getKey(), entry.getValue()); str = str.replaceAll(entry.getKey(), entry.getValue());
} }
response.add(makecolored(str)); response.add(__(str));
} }
return response; return response;
} }
@NotNull
public static String getMessage(String path) { public static String getMessage(String path) {
return getMessage(path, new HashMap<>()); return getMessage(path, new HashMap<>());
} }
@NotNull
public static String getMessage(String path, Map<String, String> vars) { public static String getMessage(String path, Map<String, String> vars) {
String message = ThemeParkPlus.getMessages().getFile().getString(path); String message = ThemeParkPlus.getMessages().getFile().getString(path);
if (message == null) return ""; if (message == null) return "";
for (Map.Entry<String, String> entry : vars.entrySet()) { for (Map.Entry<String, String> entry : vars.entrySet()) {
message = message.replaceAll(entry.getKey(), entry.getValue()); message = message.replaceAll(entry.getKey(), entry.getValue());
} }
return makecolored(message); return __(message);
} }
public static boolean sendConsole(CommandSender sender) { public static boolean sendConsole(CommandSender sender) {

View file

@ -6,8 +6,6 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
@ -16,7 +14,7 @@ public class Cuboid implements Cloneable, ConfigurationSerializable, Iterable<Bl
protected String worldName; protected String worldName;
protected final Vector minimumPoint, maximumPoint; protected final Vector minimumPoint, maximumPoint;
public Cuboid(@NotNull Cuboid cuboid) { public Cuboid(Cuboid cuboid) {
this(cuboid.worldName, cuboid.minimumPoint.getX(), cuboid.minimumPoint.getY(), cuboid.minimumPoint.getZ(), cuboid.maximumPoint.getX(), cuboid.maximumPoint.getY(), cuboid.maximumPoint.getZ()); this(cuboid.worldName, cuboid.minimumPoint.getX(), cuboid.minimumPoint.getY(), cuboid.minimumPoint.getZ(), cuboid.maximumPoint.getX(), cuboid.maximumPoint.getY(), cuboid.maximumPoint.getZ());
} }
@ -155,7 +153,6 @@ public class Cuboid implements Cloneable, ConfigurationSerializable, Iterable<Bl
return serializedCuboid; return serializedCuboid;
} }
@Nullable
public static Cuboid deserialize(Map<String, Object> serializedCuboid) { public static Cuboid deserialize(Map<String, Object> serializedCuboid) {
try { try {
String worldName = (String) serializedCuboid.get("worldName"); String worldName = (String) serializedCuboid.get("worldName");

View file

@ -2,11 +2,8 @@ package nl.sbdeveloper.themeparkplus.util;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.jetbrains.annotations.Nullable;
public class DirectionUtil { public class DirectionUtil {
@Nullable
public static WalkingDirection getDirection(int xoud, int zoud, int xnieuw, int znieuw) { public static WalkingDirection getDirection(int xoud, int zoud, int xnieuw, int znieuw) {
int changeInX = xnieuw - xoud; int changeInX = xnieuw - xoud;
int changeInZ = znieuw - zoud; int changeInZ = znieuw - zoud;

View file

@ -17,7 +17,6 @@ import java.util.Set;
* Class used to execute Discord Webhooks with low effort * Class used to execute Discord Webhooks with low effort
*/ */
public class DiscordWebhook { public class DiscordWebhook {
private final String url; private final String url;
private String content; private String content;
private String username; private String username;

View file

@ -0,0 +1,53 @@
package nl.sbdeveloper.themeparkplus.util;
import fr.minuskube.inv.InventoryManager;
import fr.minuskube.inv.SmartInventory;
import fr.minuskube.inv.content.InventoryContents;
import fr.minuskube.inv.content.InventoryProvider;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import static nl.sbdeveloper.themeparkplus.util.ConfigUtil.__;
public abstract class Inventory implements InventoryProvider {
/*
This file is part of FrogRacing.
Copyright (c) 2018-2021 FrogNetwork - All Rights Reserved
Unauthorized copying of this file, via any medium is strictly prohibited
Proprietary and confidential
Written by Stijn Bannink <stijnbannink23@gmail.com>, March 2020
*/
private static InventoryManager manager;
protected SmartInventory inventory;
public Inventory(int rows, String title) {
this(rows, title, true); //Standaard sluitbaar!
}
public Inventory(int rows, String title, boolean closeable) {
this.inventory = SmartInventory.builder().id(title).provider(this).manager(manager).size(rows, 9).closeable(closeable).title(__("&8" + title)).build();
}
@Override
public void update(Player player, InventoryContents contents) {
// Niet altijd nodig, daarom staat hij hier alvast.
}
protected void open(Player player) {
this.inventory.open(player);
}
protected void open(Player player, int page) {
this.inventory.open(player, page);
}
public void close(Player player) {
this.inventory.close(player);
}
public static void init(JavaPlugin plugin) {
manager = new InventoryManager(plugin);
manager.init();
}
}

View file

@ -1,13 +1,10 @@
package nl.sbdeveloper.themeparkplus.util; package nl.sbdeveloper.themeparkplus.util;
import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -17,11 +14,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
public class LGUtil { public class LGUtil {
private static boolean is113Plus = false;
private static final List<Vector> offsets = new ArrayList<>();
private static final List<Block> nearbyBlocks = new ArrayList<>();
private static boolean nieuweVersie = false;
private static Method getBlockDataMethod; private static Method getBlockDataMethod;
private static Method setBlockDataMethod; private static Method setBlockDataMethod;
@ -30,13 +23,6 @@ public class LGUtil {
private static Object lampUitData; private static Object lampUitData;
static { static {
offsets.add(new Vector(1, 0, 0));
offsets.add(new Vector(-1, 0, 0));
offsets.add(new Vector(0, 1, 0));
offsets.add(new Vector(0, -1, 0));
offsets.add(new Vector(0, 0, 1));
offsets.add(new Vector(0, 0, -1));
try { try {
Class<?> blockDataClass = Class.forName("org.bukkit.block.data.BlockData"); Class<?> blockDataClass = Class.forName("org.bukkit.block.data.BlockData");
Method methodCreateBlockData = Bukkit.class.getMethod("createBlockData", String.class); Method methodCreateBlockData = Bukkit.class.getMethod("createBlockData", String.class);
@ -46,12 +32,12 @@ public class LGUtil {
getAsStringMethod = blockDataClass.getMethod("getAsString"); getAsStringMethod = blockDataClass.getMethod("getAsString");
lampAanData = methodCreateBlockData.invoke(null, "minecraft:redstone_lamp[lit=true]"); lampAanData = methodCreateBlockData.invoke(null, "minecraft:redstone_lamp[lit=true]");
lampUitData = methodCreateBlockData.invoke(null, "minecraft:redstone_lamp[lit=false]"); lampUitData = methodCreateBlockData.invoke(null, "minecraft:redstone_lamp[lit=false]");
nieuweVersie = true; is113Plus = true;
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {}
} }
public static boolean zetLampAan(Block lampBlock) { public static boolean zetLampAan(Block lampBlock) {
if (nieuweVersie) { if (is113Plus) {
if ((isLamp(lampBlock)) && (!isAan(lampBlock))) { if ((isLamp(lampBlock)) && (!isAan(lampBlock))) {
setBlockData(lampBlock, lampAanData); setBlockData(lampBlock, lampAanData);
@ -65,23 +51,11 @@ public class LGUtil {
if (neighbor != null) { if (neighbor != null) {
BlockState neighborState = neighbor.getState(); BlockState neighborState = neighbor.getState();
try { try {
for (org.bukkit.util.Vector offset: offsets) {
Block neighborOfNeighbor = neighbor.getLocation().add(offset).getBlock();
if ((neighborOfNeighbor.getX() != lampBlock.getX()) || (neighborOfNeighbor.getY() != lampBlock.getY()) || (neighborOfNeighbor.getZ() != lampBlock.getZ())) {
nearbyBlocks.add(neighborOfNeighbor);
}
}
neighbor.setType(Material.REDSTONE_BLOCK); neighbor.setType(Material.REDSTONE_BLOCK);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
neighborState.update(true, false); neighborState.update(true, false);
Bukkit.getScheduler().runTaskLater(ThemeParkPlus.getInstance(), () -> {
for (Vector offset: offsets) {
Block neighborOfNeighbor = neighbor.getLocation().add(offset).getBlock();
nearbyBlocks.remove(neighborOfNeighbor);
}
}, 1L);
} }
return true; return true;
} }
@ -91,7 +65,7 @@ public class LGUtil {
} }
public static boolean zetLampUit(Block lampBlock) { public static boolean zetLampUit(Block lampBlock) {
if (nieuweVersie) { if (is113Plus) {
if ((isLamp(lampBlock)) && (isAan(lampBlock))) { if ((isLamp(lampBlock)) && (isAan(lampBlock))) {
setBlockData(lampBlock, lampUitData); setBlockData(lampBlock, lampUitData);
@ -112,7 +86,7 @@ public class LGUtil {
} }
public static boolean openGate(Block b, BlockFace openFace) { public static boolean openGate(Block b, BlockFace openFace) {
if (nieuweVersie) { if (is113Plus) {
org.bukkit.block.data.BlockData blockData = b.getBlockData(); org.bukkit.block.data.BlockData blockData = b.getBlockData();
if (isOpenable(b)) { if (isOpenable(b)) {
org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData; org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData;
@ -145,7 +119,7 @@ public class LGUtil {
} }
public static boolean closeGate(Block b) { public static boolean closeGate(Block b) {
if (nieuweVersie) { if (is113Plus) {
org.bukkit.block.data.BlockData blockData = b.getBlockData(); org.bukkit.block.data.BlockData blockData = b.getBlockData();
if (isOpenable(b)) { if (isOpenable(b)) {
org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData; org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData;
@ -172,9 +146,8 @@ public class LGUtil {
return false; return false;
} }
@Nullable
public static BlockFace getDirection(Block b) { public static BlockFace getDirection(Block b) {
if (nieuweVersie) { if (is113Plus) {
org.bukkit.block.data.BlockData blockData = b.getBlockData(); org.bukkit.block.data.BlockData blockData = b.getBlockData();
if (isOpenable(b)) { if (isOpenable(b)) {
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) blockData; org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) blockData;
@ -191,7 +164,7 @@ public class LGUtil {
} }
public static boolean isOpen(Block b) { public static boolean isOpen(Block b) {
if (nieuweVersie) { if (is113Plus) {
org.bukkit.block.data.BlockData blockData = b.getBlockData(); org.bukkit.block.data.BlockData blockData = b.getBlockData();
if (isOpenable(b)) { if (isOpenable(b)) {
org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData; org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData;
@ -212,7 +185,7 @@ public class LGUtil {
if (b == null) { if (b == null) {
return false; return false;
} }
if (nieuweVersie) { if (is113Plus) {
return b.getBlockData() instanceof org.bukkit.block.data.Openable; return b.getBlockData() instanceof org.bukkit.block.data.Openable;
} else { } else {
return b.getState().getData() instanceof org.bukkit.material.Openable; return b.getState().getData() instanceof org.bukkit.material.Openable;
@ -253,7 +226,7 @@ public class LGUtil {
} }
private static boolean isAan(Block lamp) { private static boolean isAan(Block lamp) {
if (nieuweVersie) { if (is113Plus) {
return getAsString(getBlockData(lamp)).contains("lit=true"); return getAsString(getBlockData(lamp)).contains("lit=true");
} else { } else {
return lamp.getType() == Material.matchMaterial(XMaterial.REDSTONE_LAMP.getLegacy()[0]); return lamp.getType() == Material.matchMaterial(XMaterial.REDSTONE_LAMP.getLegacy()[0]);
@ -261,7 +234,7 @@ public class LGUtil {
} }
private static boolean isLamp(Block lamp) { private static boolean isLamp(Block lamp) {
if (nieuweVersie) { if (is113Plus) {
return lamp.getType() == XMaterial.REDSTONE_LAMP.parseMaterial(); return lamp.getType() == XMaterial.REDSTONE_LAMP.parseMaterial();
} else { } else {
return Arrays.asList(XMaterial.REDSTONE_LAMP.getLegacy()).contains(lamp.getType().name()); return Arrays.asList(XMaterial.REDSTONE_LAMP.getLegacy()).contains(lamp.getType().name());

View file

@ -9,8 +9,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -42,8 +40,8 @@ public class License implements Listener {
private final JavaPlugin plugin; // The plugin instance private final JavaPlugin plugin; // The plugin instance
private final String license; // The license code private final String license; // The license code
private final String prefix; // The correct prefix for this plugin 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! 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! private static Boolean valid; // If true, it's valid, if false, it's not valid, if null it's not checked!
/** /**
* Construct a new license * Construct a new license
@ -84,7 +82,7 @@ public class License implements Listener {
//STEP 2: Send license request //STEP 2: Send license request
String url = "https://sbdplugins.nl/wp-json/lmfwc/v2/licenses/" + this.license; String url = "https://sbdplugins.nl/wp-json/lmfwc/v2/licenses/" + this.license;
@Nullable JsonObject response; JsonObject response;
try { try {
response = sendGETRequestJSON(url); response = sendGETRequestJSON(url);
} catch (IOException e) { } catch (IOException e) {
@ -231,7 +229,6 @@ public class License implements Listener {
* @return The JSONObject * @return The JSONObject
* @throws IOException URL errors * @throws IOException URL errors
*/ */
@Nullable
private JsonObject sendGETRequestJSON(String uri) throws IOException { private JsonObject sendGETRequestJSON(String uri) throws IOException {
URL url = new URL(uri); URL url = new URL(uri);
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
@ -258,7 +255,7 @@ public class License implements Listener {
return parser.parse(response.toString()).getAsJsonObject(); return parser.parse(response.toString()).getAsJsonObject();
} }
private boolean checkPortValue(int input, @NotNull String dataValue) { private boolean checkPortValue(int input, String dataValue) {
//STEP 1: Check wildcard //STEP 1: Check wildcard
if (dataValue.equals("*")) return true; if (dataValue.equals("*")) return true;
@ -309,7 +306,6 @@ public class License implements Listener {
* *
* @return true -> VALID, false -> INVALID, null -> UNCHECKED * @return true -> VALID, false -> INVALID, null -> UNCHECKED
*/ */
@Nullable
public static Boolean isValid() { public static Boolean isValid() {
return valid; return valid;
} }

View file

@ -1,100 +0,0 @@
package nl.sbdeveloper.themeparkplus.commands;
import nl.iobyte.themepark.ThemePark;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class TPPTabComplete implements TabCompleter {
private static final List<String> COMMANDS = Arrays.asList("info", "help", "opengate", "closegate", "lampon", "lampoff", "lampson", "lampsoff", "redstonetimer", "givefpticket");
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
//Aliases
if (label.equalsIgnoreCase("themeparkplus") || label.equalsIgnoreCase("tpp") || label.equalsIgnoreCase("themeparkp")) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], COMMANDS, new ArrayList<>());
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[1], Collections.singletonList("" + targetLoc.getWorld().getName()), new ArrayList<>());
}
} else if (args[0].equalsIgnoreCase("givefpticket")) {
return StringUtil.copyPartialMatches(args[1], ThemePark.getInstance().getAPI().getAttractionService().getAttractions().keySet(), new ArrayList<>());
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[2], Collections.singletonList("" + targetLoc.getBlockX()), new ArrayList<>());
}
} else if (args[0].equalsIgnoreCase("givefpticket")) {
return StringUtil.copyPartialMatches(args[1], Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()), new ArrayList<>());
}
} else if (args.length == 4) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[3], Collections.singletonList("" + targetLoc.getBlockY()), new ArrayList<>());
}
}
} else if (args.length == 5) {
if (args[0].equalsIgnoreCase("opengate")
|| args[0].equalsIgnoreCase("closegate")
|| args[0].equalsIgnoreCase("lampon")
|| args[0].equalsIgnoreCase("lampoff")
|| args[0].equalsIgnoreCase("redstonetimer")) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location targetLoc = getTarget(p).getLocation();
return StringUtil.copyPartialMatches(args[4], Collections.singletonList("" + targetLoc.getBlockZ()), new ArrayList<>());
}
}
} else if (args.length == 6) {
if (args[0].equalsIgnoreCase("opengate")) {
return StringUtil.copyPartialMatches(args[5], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>());
}
} else if (args.length == 7) {
if (args[0].equalsIgnoreCase("opengate")) {
return StringUtil.copyPartialMatches(args[6], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>());
}
}
}
return null;
}
private Block getTarget(Player p) {
return p.getTargetBlock(null, 200);
}
}