From c3d41dc99da4e801cf59d23d991202146050c97f Mon Sep 17 00:00:00 2001 From: JustBru00 Date: Sat, 6 Jan 2024 19:50:53 -0500 Subject: [PATCH] Version 2.4.0 Release Candidate 1 Closes #1 --- .gitignore | 2 ++ .settings/.gitignore | 3 +++ README.md | 7 +++++-- pom.xml | 6 +++--- .../java/me/pigalala/pigstops/OinkCommand.java | 4 ++-- .../java/me/pigalala/pigstops/OinkConfig.java | 11 +++++------ .../me/pigalala/pigstops/OinkListener.java | 14 ++++++++++++-- .../me/pigalala/pigstops/OinkMessages.java | 6 +++--- .../java/me/pigalala/pigstops/PigStops.java | 18 +++++++++++++----- .../pigstops/pit/management/pitmodes/Pit.java | 12 +++++++----- src/main/resources/plugin.yml | 2 +- 11 files changed, 56 insertions(+), 29 deletions(-) create mode 100644 .settings/.gitignore diff --git a/.gitignore b/.gitignore index 4788b4b..45cc01c 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,5 @@ buildNumber.properties # Common working directory run/ +/.classpath +/.project diff --git a/.settings/.gitignore b/.settings/.gitignore new file mode 100644 index 0000000..1de83a6 --- /dev/null +++ b/.settings/.gitignore @@ -0,0 +1,3 @@ +/org.eclipse.core.resources.prefs +/org.eclipse.jdt.core.prefs +/org.eclipse.m2e.core.prefs diff --git a/README.md b/README.md index 02cd11a..4481549 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ -> [!IMPORTANT] -> pigstops +### PigStops + +This plugin adds a simple inventory game to pit stops in [TimingSystem](https://github.com/Makkuusen/TimingSystem) races. + +PigStops was created by @Pigalala. It is now maintained by @JustBru00 on this repository. \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2a9b352..5d862c1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.pigalala PigStops - 2.3.0 + 2.4.0-RC1 jar PigStops @@ -83,13 +83,13 @@ com.github.Makkuusen TimingSystem - 1.6 + 2.0.2 provided io.papermc.paper paper-api - 1.20-R0.1-SNAPSHOT + 1.20.1-R0.1-SNAPSHOT provided diff --git a/src/main/java/me/pigalala/pigstops/OinkCommand.java b/src/main/java/me/pigalala/pigstops/OinkCommand.java index 91a342e..86cb34f 100644 --- a/src/main/java/me/pigalala/pigstops/OinkCommand.java +++ b/src/main/java/me/pigalala/pigstops/OinkCommand.java @@ -5,8 +5,8 @@ import co.aikar.commands.InvalidCommandArgument; import co.aikar.commands.annotation.*; import co.aikar.commands.contexts.ContextResolver; -import me.makkuusen.timing.system.TPlayer; import me.makkuusen.timing.system.api.TimingSystemAPI; +import me.makkuusen.timing.system.tplayer.TPlayer; import me.pigalala.pigstops.pit.management.pitmodes.Pit; import me.pigalala.pigstops.pit.management.*; import org.bukkit.Material; @@ -86,7 +86,7 @@ public static void togglePracticeMode(Player player) { pp.practiceModeStart.setPitch(pp.getPlayer().getLocation().getPitch()); TPlayer tPlayer = TimingSystemAPI.getTPlayer(pp.getPlayer().getUniqueId()); if(!isInBoat(player)) { - Boat boat = spawnBoat(pp.practiceModeStart, tPlayer.getBoat(), tPlayer.isChestBoat()); + Boat boat = spawnBoat(pp.practiceModeStart, tPlayer.getSettings().getBoat(), tPlayer.getSettings().isChestBoat()); boat.addPassenger(pp.getPlayer()); } } diff --git a/src/main/java/me/pigalala/pigstops/OinkConfig.java b/src/main/java/me/pigalala/pigstops/OinkConfig.java index 375bc9b..2028ff8 100644 --- a/src/main/java/me/pigalala/pigstops/OinkConfig.java +++ b/src/main/java/me/pigalala/pigstops/OinkConfig.java @@ -1,16 +1,15 @@ package me.pigalala.pigstops; -import me.pigalala.pigstops.pit.management.PitGame; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; +import static me.pigalala.pigstops.PigStops.defaultPitGame; import java.io.File; import java.util.Arrays; -import java.util.List; import java.util.logging.Level; -import static me.pigalala.pigstops.PigStops.defaultPitGame; -import static me.pigalala.pigstops.PigStops.pitGames; +import org.bukkit.Material; +import org.bukkit.configuration.file.FileConfiguration; + +import me.pigalala.pigstops.pit.management.PitGame; public abstract class OinkConfig { diff --git a/src/main/java/me/pigalala/pigstops/OinkListener.java b/src/main/java/me/pigalala/pigstops/OinkListener.java index f0b1bcd..da51316 100644 --- a/src/main/java/me/pigalala/pigstops/OinkListener.java +++ b/src/main/java/me/pigalala/pigstops/OinkListener.java @@ -4,7 +4,11 @@ import me.makkuusen.timing.system.api.TimingSystemAPI; import me.pigalala.pigstops.pit.management.pitmodes.Pit; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; + +import java.util.logging.Level; + import org.bukkit.entity.Boat; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -46,8 +50,14 @@ public void onMove(PlayerMoveEvent e) { } else { if(pp.isInPracticeMode()) pp.togglePracticeMode(); } - - if(driver.get().getHeat().isActive() && driver.get().getCurrentLap() != null && !driver.get().getCurrentLap().isPitted()) pp.newPit(Pit.Type.REAL); + + // Prevent NullPointerException if no default pit game has been selected. + if (PigStops.defaultPitGame == null) { + PigStops.getPlugin().getLogger().log(Level.SEVERE, "The default pit game has not been set. PigStops will not work correctly until a default pit game is set."); + e.getPlayer().sendMessage(Component.text().append(Component.text("The PigStop did not work as the default pit game is not set. Please ask an administrator to set the default pit game.", NamedTextColor.RED))); + } else { + if(driver.get().getHeat().isActive() && driver.get().getCurrentLap() != null && !driver.get().getCurrentLap().isPitted()) pp.newPit(Pit.Type.REAL); + } } @EventHandler diff --git a/src/main/java/me/pigalala/pigstops/OinkMessages.java b/src/main/java/me/pigalala/pigstops/OinkMessages.java index e9bbc24..f66edf8 100644 --- a/src/main/java/me/pigalala/pigstops/OinkMessages.java +++ b/src/main/java/me/pigalala/pigstops/OinkMessages.java @@ -1,6 +1,6 @@ package me.pigalala.pigstops; -import me.makkuusen.timing.system.TPlayer; +import me.makkuusen.timing.system.tplayer.TPlayer; import me.pigalala.pigstops.pit.management.PitGame; import me.pigalala.pigstops.pit.management.pitmodes.Pit; import net.kyori.adventure.text.Component; @@ -31,7 +31,7 @@ public static TextComponent getSoloFinishText(String time, int accuracy, int mis public static TextComponent getRaceFinishText(TPlayer player, String pitName, int pit, String time, int accuracy, int misclicks, Pit.PitMode pm) { return Component.text().content("").color(NamedTextColor.GREEN) - .append(Component.text("|| ", player.getTextColor(), TextDecoration.BOLD, TextDecoration.ITALIC)) + .append(Component.text("|| ", player.getSettings().getTextColor(), TextDecoration.BOLD, TextDecoration.ITALIC)) .append(Component.text(player.getName(), NamedTextColor.WHITE)) .append(Component.text(" has completed PigStop ")) .append(Component.text(pit).color(NamedTextColor.GOLD)) @@ -39,7 +39,7 @@ public static TextComponent getRaceFinishText(TPlayer player, String pitName, in .append(Component.text(time).color(NamedTextColor.GOLD)) .hoverEvent( Component.text().content("").color(TextColor.color(0xF38AFF)) - .append(Component.text("|| ", player.getTextColor(), TextDecoration.BOLD, TextDecoration.ITALIC)) + .append(Component.text("|| ", player.getSettings().getTextColor(), TextDecoration.BOLD, TextDecoration.ITALIC)) .append(Component.text(player.getName(), NamedTextColor.WHITE)) .appendNewline().append(Component.text("----------").color(NamedTextColor.GRAY)) .appendNewline().append(Component.text(pitName)).append(Component.text(".pigstop").color(NamedTextColor.GRAY)) diff --git a/src/main/java/me/pigalala/pigstops/PigStops.java b/src/main/java/me/pigalala/pigstops/PigStops.java index b4e599a..1702a55 100644 --- a/src/main/java/me/pigalala/pigstops/PigStops.java +++ b/src/main/java/me/pigalala/pigstops/PigStops.java @@ -1,15 +1,21 @@ package me.pigalala.pigstops; -import co.aikar.commands.PaperCommandManager; -import com.google.common.collect.ImmutableList; -import me.pigalala.pigstops.pit.management.PitGame; -import me.pigalala.pigstops.pit.management.pitmodes.Pit; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.logging.Level; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import java.util.*; +import com.google.common.collect.ImmutableList; + +import co.aikar.commands.PaperCommandManager; +import me.pigalala.pigstops.pit.management.PitGame; +import me.pigalala.pigstops.pit.management.pitmodes.Pit; public final class PigStops extends JavaPlugin { @@ -27,6 +33,8 @@ public void onEnable() { new OinkListener(); OinkConfig.onStartup(); setupCommands(); + getLogger().log(Level.INFO, "Enabled PigStops v" + getPluginMeta().getVersion() + " created by Pigalala."); + getLogger().log(Level.INFO, "PigStops is now maintained by JustBru00. For bug reports and the latest releases, please check out the GitHub page at: https://github.com/JustBru00/PigStops"); } private void setupCommands() { diff --git a/src/main/java/me/pigalala/pigstops/pit/management/pitmodes/Pit.java b/src/main/java/me/pigalala/pigstops/pit/management/pitmodes/Pit.java index 8260ad9..73a36b4 100644 --- a/src/main/java/me/pigalala/pigstops/pit/management/pitmodes/Pit.java +++ b/src/main/java/me/pigalala/pigstops/pit/management/pitmodes/Pit.java @@ -3,11 +3,11 @@ import co.aikar.commands.BukkitCommandExecutionContext; import co.aikar.commands.InvalidCommandArgument; import co.aikar.commands.contexts.ContextResolver; -import me.makkuusen.timing.system.TPlayer; import me.makkuusen.timing.system.api.TimingSystemAPI; -import me.makkuusen.timing.system.event.EventDatabase; +import me.makkuusen.timing.system.database.EventDatabase; import me.makkuusen.timing.system.heat.Heat; import me.makkuusen.timing.system.participant.Driver; +import me.makkuusen.timing.system.tplayer.TPlayer; import me.pigalala.pigstops.OinkMessages; import me.pigalala.pigstops.PigStops; import me.pigalala.pigstops.PitPlayer; @@ -131,7 +131,8 @@ private void registerSpectators() { spectators.forEach(p -> p.pit = this); } - private void setItemMetas() { + @SuppressWarnings("deprecation") + private void setItemMetas() { ItemMeta backgroundMeta = defaultBackground.getItemMeta(); backgroundMeta.setDisplayName(" "); defaultBackground.setItemMeta(backgroundMeta); @@ -170,7 +171,8 @@ public void finishPit() { } } - @EventHandler + @SuppressWarnings("deprecation") + @EventHandler public void itemClickedEvent(InventoryClickEvent e) { if(e.getWhoClicked() != pp.getPlayer() || !e.getView().getTitle().startsWith("§dPigStops")) return; e.setCancelled(true); @@ -223,7 +225,7 @@ private void end() { if(pp.getPlayer().getVehicle() instanceof Boat b) b.remove(); pp.practiceModeStart.setPitch(pp.getPlayer().getLocation().getPitch()); TPlayer tPlayer = TimingSystemAPI.getTPlayer(pp.getPlayer().getUniqueId()); - Boat boat = spawnBoat(pp.practiceModeStart, tPlayer.getBoat(), tPlayer.isChestBoat()); + Boat boat = spawnBoat(pp.practiceModeStart, tPlayer.getSettings().getBoat(), tPlayer.getSettings().isChestBoat()); boat.addPassenger(pp.getPlayer()); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3c336d6..a706b46 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ version: '${project.version}' main: me.pigalala.pigstops.PigStops api-version: '1.20' prefix: PigStops -authors: [ Pigalala ] +authors: [Pigalala, JustBru00] depend: [ TimingSystem ] commands: