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>
<artifactId>ThemeParkPlus</artifactId>
<version>2.1.4</version>
<version>3.0.0</version>
<packaging>jar</packaging>
<name>ThemeParkPlus</name>
<description>Plus version of ThemePark!</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>https://sbdplugins.nl</url>
@ -26,8 +25,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
@ -83,7 +81,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<source>8</source>
<release>11</release>
<sourceFileIncludes>
<include>nl/sbdeveloper/themeparkplus/api/*.java</include>
<include>nl/sbdeveloper/themeparkplus/api/enums/*.java</include>
@ -128,15 +126,15 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.paradoxpixel</groupId>
<artifactId>themepark</artifactId>
<version>2.1.3</version>
<version>3.0.0</version>
<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>
<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
*/
@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"));
ItemStack ticket = XMaterial.PAPER.parseItem();
@ -186,7 +186,7 @@ public class PlusAPI {
ticket.setItemMeta(meta);
NBTItem item = new NBTItem(ticket);
item.setString("RideID", att.getId());
item.setString("RideID", att.getID());
ticket = item.getItem();
return ticket;
}

View file

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

View file

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

View file

@ -1,7 +1,7 @@
package nl.sbdeveloper.themeparkplus.listeners;
import nl.iobyte.themepark.api.API;
import nl.iobyte.themepark.api.attraction.Attraction;
import nl.iobyte.themepark.ThemePark;
import nl.iobyte.themepark.api.attraction.objects.Attraction;
import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import nl.sbdeveloper.themeparkplus.gui.MalfunctionGUI;
import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
@ -24,8 +24,8 @@ public class MalfunctionListener implements Listener {
Sign sign = (Sign) e.getClickedBlock().getState();
if (ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mrLineOne) && ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(mrLineTwo)) {
String attID = sign.getLine(2);
if (!API.isAttraction(attID)) return;
Attraction att = API.getAttraction(attID);
if (!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(attID)) return;
Attraction att = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(attID);
MalfunctionGUI.open(att, e.getPlayer());
}

View file

@ -1,10 +1,9 @@
package nl.sbdeveloper.themeparkplus.listeners;
import nl.iobyte.themepark.api.attraction.Attraction;
import nl.iobyte.themepark.api.attraction.component.Status;
import nl.iobyte.themepark.api.attraction.manager.StatusManager;
import nl.iobyte.themepark.api.events.attraction.ChangeStatusEvent;
import nl.iobyte.themepark.api.events.attraction.PreChangeStatusEvent;
import nl.iobyte.themepark.api.attraction.enums.Status;
import nl.iobyte.themepark.api.attraction.objects.Attraction;
import nl.iobyte.themepark.api.event.attraction.AttractionPreStatusChangeEvent;
import nl.iobyte.themepark.api.event.attraction.AttractionStatusChangeEvent;
import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import nl.sbdeveloper.themeparkplus.api.PlusAPI;
import nl.sbdeveloper.themeparkplus.api.objects.MalfunctionReport;
@ -14,7 +13,6 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.io.IOException;
@ -24,12 +22,12 @@ import java.io.IOException;
*/
public class StatusChangeListener implements Listener {
@EventHandler
public void onStatusChange(PreChangeStatusEvent e) {
public void onStatusChange(AttractionPreStatusChangeEvent e) {
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")) {
MalfunctionReport malfunctionReport = new MalfunctionReport(att.getId(), e.getPlayer().getUniqueId());
MalfunctionReport malfunctionReport = new MalfunctionReport(att.getID(), e.getPlayer().getUniqueId());
PlusAPI.addReport(malfunctionReport);
} else {
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")) {
PlusAPI.removeReport(att.getId());
PlusAPI.removeReport(att.getID());
} else {
e.setCancelled(true);
e.getPlayer().sendMessage(ConfigUtil.getMessage("Malfunction.NoCommand"));
@ -48,20 +46,19 @@ public class StatusChangeListener implements Listener {
}
@EventHandler
public void onStatusChange(@NotNull ChangeStatusEvent e) {
if (e.getAfter() != Status.GLOBAL) {
public void onStatusChange(AttractionStatusChangeEvent e) {
String title = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Title");
if (title == null) return;
String rideName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getName()));
String regionName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getRegion().getName()));
String statusAfter = ChatColor.stripColor(ConfigUtil.makecolored(StatusManager.getName(e.getAfter())));
String regionName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getRegionID()));
String statusAfter = ChatColor.stripColor(ConfigUtil.makecolored(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.getAfter().toString()));
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());
@ -80,5 +77,4 @@ public class StatusChangeListener implements Listener {
ex.printStackTrace();
}
}
}
}