3
0
Fork 0

Added support for ThemePark v3.x

This commit is contained in:
stijnb1234 2021-07-02 11:12:02 +02:00
parent e53c6cc892
commit 1478ca2ee6
10 changed files with 832 additions and 808 deletions

14
pom.xml
View file

@ -6,14 +6,13 @@
<groupId>nl.SBDeveloper</groupId> <groupId>nl.SBDeveloper</groupId>
<artifactId>ThemeParkPlus</artifactId> <artifactId>ThemeParkPlus</artifactId>
<version>2.1.4</version> <version>3.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ThemeParkPlus</name> <name>ThemeParkPlus</name>
<description>Plus version of ThemePark!</description> <description>Plus version of ThemePark!</description>
<properties> <properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<url>https://sbdplugins.nl</url> <url>https://sbdplugins.nl</url>
@ -26,8 +25,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
<source>${java.version}</source> <release>11</release>
<target>${java.version}</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -83,7 +81,7 @@
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
<configuration> <configuration>
<source>8</source> <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>
@ -128,15 +126,15 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version> <version>1.17-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>2.1.3</version> <version>3.0.0</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${pom.basedir}/src/lib/themepark-2.1.3.jar</systemPath> <systemPath>${pom.basedir}/src/lib/themepark-3.0.0.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

Binary file not shown.

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

Binary file not shown.

View file

@ -173,7 +173,7 @@ public class PlusAPI {
* @return The ticket as ItemStack * @return The ticket as ItemStack
*/ */
@Nullable @Nullable
public static ItemStack getFastpassTicket(nl.iobyte.themepark.api.attraction.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.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.Item.DisplayName"));
ItemStack ticket = XMaterial.PAPER.parseItem(); ItemStack ticket = XMaterial.PAPER.parseItem();
@ -186,7 +186,7 @@ public class PlusAPI {
ticket.setItemMeta(meta); ticket.setItemMeta(meta);
NBTItem item = new NBTItem(ticket); NBTItem item = new NBTItem(ticket);
item.setString("RideID", att.getId()); item.setString("RideID", att.getID());
ticket = item.getItem(); ticket = item.getItem();
return ticket; return ticket;
} }

View file

@ -1,6 +1,6 @@
package nl.sbdeveloper.themeparkplus.commands; package nl.sbdeveloper.themeparkplus.commands;
import nl.iobyte.themepark.api.API; import nl.iobyte.themepark.ThemePark;
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;
@ -40,7 +40,7 @@ public class TPPTabComplete implements TabCompleter {
return StringUtil.copyPartialMatches(args[1], Collections.singletonList("" + targetLoc.getWorld().getName()), new ArrayList<>()); return StringUtil.copyPartialMatches(args[1], Collections.singletonList("" + targetLoc.getWorld().getName()), new ArrayList<>());
} }
} else if (args[0].equalsIgnoreCase("givefpticket")) { } else if (args[0].equalsIgnoreCase("givefpticket")) {
return StringUtil.copyPartialMatches(args[1], API.getAttractions().keySet(), new ArrayList<>()); return StringUtil.copyPartialMatches(args[1], ThemePark.getInstance().getAPI().getAttractionService().getAttractions().keySet(), new ArrayList<>());
} }
} else if (args.length == 3) { } else if (args.length == 3) {
if (args[0].equalsIgnoreCase("opengate") if (args[0].equalsIgnoreCase("opengate")

View file

@ -3,9 +3,9 @@ package nl.sbdeveloper.themeparkplus.gui;
import com.samjakob.spigui.SGMenu; import com.samjakob.spigui.SGMenu;
import com.samjakob.spigui.buttons.SGButton; import com.samjakob.spigui.buttons.SGButton;
import com.samjakob.spigui.item.ItemBuilder; import com.samjakob.spigui.item.ItemBuilder;
import nl.iobyte.themepark.api.API; import nl.iobyte.themepark.ThemePark;
import nl.iobyte.themepark.api.attraction.Attraction; import nl.iobyte.themepark.api.attraction.enums.Status;
import nl.iobyte.themepark.api.attraction.component.Status; import nl.iobyte.themepark.api.attraction.objects.Attraction;
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.objects.MalfunctionReport; import nl.sbdeveloper.themeparkplus.api.objects.MalfunctionReport;
@ -24,13 +24,13 @@ import java.util.Optional;
public class MalfunctionGUI { public class MalfunctionGUI {
public static void open(Attraction att, Player p) { 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.getId())), 1); 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) -> { SGButton report = new SGButton(getItem("Report", ConfigUtil.makecolored(att.getName()))).withListener((InventoryClickEvent 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(), p.getUniqueId());
PlusAPI.addReport(malfunctionReport); PlusAPI.addReport(malfunctionReport);
att.setStatus(Status.MALFUNCTION, null); //Player must be null, otherwise we will get a loop in the listener att.setStatus(Status.MALFUNCTION);
p.sendMessage(ConfigUtil.getMessage("Malfunction.Reported", Collections.singletonMap("%ride%", att.getName()))); p.sendMessage(ConfigUtil.getMessage("Malfunction.Reported", Collections.singletonMap("%ride%", att.getName())));
} else { } else {
@ -40,11 +40,11 @@ public class MalfunctionGUI {
}); });
menu.setButton(getSlot("Report"), report); menu.setButton(getSlot("Report"), report);
SGButton fix = new SGButton(getItem("Fix", PlusAPI.getReport(att.getId()))).withListener((InventoryClickEvent e) -> { SGButton fix = new SGButton(getItem("Fix", PlusAPI.getReport(att.getID()))).withListener((InventoryClickEvent e) -> {
if (PlusAPI.isReported(att.getId())) { if (PlusAPI.isReported(att.getID())) {
PlusAPI.removeReport(att.getId()); PlusAPI.removeReport(att.getID());
att.setStatus(Status.CLOSED, null); //Player must be null, otherwise we will get a loop in the listener att.setStatus(Status.CLOSED);
p.sendMessage(ConfigUtil.getMessage("Malfunction.Fixed", Collections.singletonMap("%ride%", att.getName()))); p.sendMessage(ConfigUtil.getMessage("Malfunction.Fixed", Collections.singletonMap("%ride%", att.getName())));
} else { } else {
@ -82,7 +82,7 @@ public class MalfunctionGUI {
String date = "-"; String date = "-";
String reason = "-"; String reason = "-";
if (data[0] != null) { if (data[0] != null) {
ridename = API.getAttraction(((MalfunctionReport) data[0]).getRideID()).getName(); ridename = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(((MalfunctionReport) data[0]).getRideID()).getName();
reporter = Bukkit.getOfflinePlayer(((MalfunctionReport) data[0]).getReporterUUID()).getName(); reporter = Bukkit.getOfflinePlayer(((MalfunctionReport) data[0]).getReporterUUID()).getName();
date = ((MalfunctionReport) data[0]).getReportDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss")); date = ((MalfunctionReport) data[0]).getReportDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"));
reason = ((MalfunctionReport) data[0]).getReason(); reason = ((MalfunctionReport) data[0]).getReason();

View file

@ -1,9 +1,9 @@
package nl.sbdeveloper.themeparkplus.listeners; package nl.sbdeveloper.themeparkplus.listeners;
import de.tr7zw.changeme.nbtapi.NBTItem; import de.tr7zw.changeme.nbtapi.NBTItem;
import nl.iobyte.themepark.api.API; import nl.iobyte.themepark.ThemePark;
import nl.iobyte.themepark.api.attraction.Attraction; import nl.iobyte.themepark.api.attraction.enums.Status;
import nl.iobyte.themepark.api.attraction.component.Status; import nl.iobyte.themepark.api.attraction.objects.Attraction;
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.util.ConfigUtil; import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
@ -45,8 +45,8 @@ public class FastpassListeners implements Listener {
if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(mLineTwo)) { if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(mLineTwo)) {
//Buy a ticket //Buy a ticket
String attID = sign.getLine(2); String attID = sign.getLine(2);
if (!API.isAttraction(attID)) return; if (!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(attID)) return;
Attraction att = API.getAttraction(attID); Attraction att = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(attID);
double price; double price;
try { try {
@ -83,11 +83,11 @@ public class FastpassListeners implements Listener {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.Bought", vars)); e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.Bought", vars));
} else if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(sLineTwo)) { } else if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(sLineTwo)) {
//Scan a ticket //Scan a ticket
if (!API.isAttraction(sign.getLine(2))) { if (!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(sign.getLine(2))) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.UnknownRide", Collections.singletonMap("%ridename%", sign.getLine(2)))); e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.UnknownRide", Collections.singletonMap("%ridename%", sign.getLine(2))));
return; return;
} }
Attraction att = API.getAttraction(sign.getLine(2)); Attraction att = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(sign.getLine(2));
ItemStack content = e.getPlayer().getInventory().getItemInMainHand(); ItemStack content = e.getPlayer().getInventory().getItemInMainHand();
if (content.getType() == Material.AIR if (content.getType() == Material.AIR
@ -102,12 +102,12 @@ public class FastpassListeners implements Listener {
return; return;
} }
if (!nbtContent.getString("RideID").equals(att.getId())) { if (!nbtContent.getString("RideID").equals(att.getID())) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.IncorrectTicket")); e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.IncorrectTicket"));
return; return;
} }
if (att.getStatus() != Status.OPEN && att.getStatus() != Status.ACTIVE) { if (att.getStatus() != Status.OPEN) {
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.RideClosed")); e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.RideClosed"));
return; return;
} }

View file

@ -1,7 +1,7 @@
package nl.sbdeveloper.themeparkplus.listeners; package nl.sbdeveloper.themeparkplus.listeners;
import nl.iobyte.themepark.api.API; import nl.iobyte.themepark.ThemePark;
import nl.iobyte.themepark.api.attraction.Attraction; import nl.iobyte.themepark.api.attraction.objects.Attraction;
import nl.sbdeveloper.themeparkplus.ThemeParkPlus; import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import nl.sbdeveloper.themeparkplus.gui.MalfunctionGUI; import nl.sbdeveloper.themeparkplus.gui.MalfunctionGUI;
import nl.sbdeveloper.themeparkplus.util.ConfigUtil; import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
@ -24,8 +24,8 @@ public class MalfunctionListener implements Listener {
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)) {
String attID = sign.getLine(2); String attID = sign.getLine(2);
if (!API.isAttraction(attID)) return; if (!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(attID)) return;
Attraction att = API.getAttraction(attID); Attraction att = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(attID);
MalfunctionGUI.open(att, e.getPlayer()); MalfunctionGUI.open(att, e.getPlayer());
} }

View file

@ -1,10 +1,9 @@
package nl.sbdeveloper.themeparkplus.listeners; package nl.sbdeveloper.themeparkplus.listeners;
import nl.iobyte.themepark.api.attraction.Attraction; import nl.iobyte.themepark.api.attraction.enums.Status;
import nl.iobyte.themepark.api.attraction.component.Status; import nl.iobyte.themepark.api.attraction.objects.Attraction;
import nl.iobyte.themepark.api.attraction.manager.StatusManager; import nl.iobyte.themepark.api.event.attraction.AttractionPreStatusChangeEvent;
import nl.iobyte.themepark.api.events.attraction.ChangeStatusEvent; import nl.iobyte.themepark.api.event.attraction.AttractionStatusChangeEvent;
import nl.iobyte.themepark.api.events.attraction.PreChangeStatusEvent;
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.objects.MalfunctionReport; import nl.sbdeveloper.themeparkplus.api.objects.MalfunctionReport;
@ -14,7 +13,6 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
@ -24,12 +22,12 @@ import java.io.IOException;
*/ */
public class StatusChangeListener implements Listener { public class StatusChangeListener implements Listener {
@EventHandler @EventHandler
public void onStatusChange(PreChangeStatusEvent e) { public void onStatusChange(AttractionPreStatusChangeEvent e) {
Attraction att = e.getAttraction(); Attraction att = e.getAttraction();
if (!PlusAPI.isReported(att.getId()) && e.getAfter() == Status.MALFUNCTION && e.getPlayer() != null) { if (!PlusAPI.isReported(att.getID()) && e.getCurrent() == Status.MALFUNCTION && e.getPlayer() != null) {
if (ThemeParkPlus.getSConfig().getFile().getBoolean("Malfunction.AllowCommandReport")) { if (ThemeParkPlus.getSConfig().getFile().getBoolean("Malfunction.AllowCommandReport")) {
MalfunctionReport malfunctionReport = new MalfunctionReport(att.getId(), e.getPlayer().getUniqueId()); MalfunctionReport malfunctionReport = new MalfunctionReport(att.getID(), e.getPlayer().getUniqueId());
PlusAPI.addReport(malfunctionReport); PlusAPI.addReport(malfunctionReport);
} else { } else {
e.setCancelled(true); e.setCancelled(true);
@ -37,9 +35,9 @@ public class StatusChangeListener implements Listener {
} }
} }
if (PlusAPI.isReported(att.getId()) && e.getAfter() != Status.MALFUNCTION && e.getPlayer() != null) { if (PlusAPI.isReported(att.getID()) && e.getCurrent() != Status.MALFUNCTION && e.getPlayer() != null) {
if (ThemeParkPlus.getSConfig().getFile().getBoolean("Malfunction.AllowCommandFix")) { if (ThemeParkPlus.getSConfig().getFile().getBoolean("Malfunction.AllowCommandFix")) {
PlusAPI.removeReport(att.getId()); PlusAPI.removeReport(att.getID());
} else { } else {
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().sendMessage(ConfigUtil.getMessage("Malfunction.NoCommand")); e.getPlayer().sendMessage(ConfigUtil.getMessage("Malfunction.NoCommand"));
@ -48,37 +46,35 @@ public class StatusChangeListener implements Listener {
} }
@EventHandler @EventHandler
public void onStatusChange(@NotNull ChangeStatusEvent e) { public void onStatusChange(AttractionStatusChangeEvent e) {
if (e.getAfter() != Status.GLOBAL) { 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.makecolored(e.getAttraction().getName()));
String regionName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getRegion().getName())); String regionName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getRegionID()));
String statusAfter = ChatColor.stripColor(ConfigUtil.makecolored(StatusManager.getName(e.getAfter()))); String statusAfter = ChatColor.stripColor(ConfigUtil.makecolored(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);
String copy = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Copyright"); String copy = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Copyright");
String copyimg = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.CopyrightImage"); String copyimg = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.CopyrightImage");
Color color = new Color(ThemeParkPlus.getSConfig().getFile().getInt("DiscordWebhook.Embed.Colors." + e.getAfter().toString())); Color color = new Color(ThemeParkPlus.getSConfig().getFile().getInt("DiscordWebhook.Embed.Colors." + e.getCurrent().name()));
if (copy == null || copyimg == null) return; if (copy == null || copyimg == null) return;
DiscordWebhook webhook = new DiscordWebhook(ThemeParkPlus.getWebhookURL()); DiscordWebhook webhook = new DiscordWebhook(ThemeParkPlus.getWebhookURL());
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject() DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setTitle(title) .setTitle(title)
.setFooter(copy, copyimg) .setFooter(copy, copyimg)
.setColor(color) .setColor(color)
.addField(rideName, statusAfter, false); .addField(rideName, statusAfter, false);
webhook.addEmbed(embed); webhook.addEmbed(embed);
try { try {
webhook.execute(); webhook.execute();
} catch (IOException ex) { } catch (IOException ex) {
Bukkit.getLogger().severe("[ThemeParkPlus] Could not send the status update to Discord! See the error below:"); Bukkit.getLogger().severe("[ThemeParkPlus] Could not send the status update to Discord! See the error below:");
ex.printStackTrace(); ex.printStackTrace();
}
} }
} }
} }