diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml
new file mode 100644
index 000000000..03814a265
--- /dev/null
+++ b/.github/workflows/maven-build.yml
@@ -0,0 +1,46 @@
+name: ZonePractice Build
+
+on:
+ push:
+ branches: [ "master", "main" ]
+ pull_request:
+ branches: [ "master", "main" ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ with:
+ lfs: true
+
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4
+ with:
+ java-version: '21'
+ distribution: 'temurin'
+ cache: 'maven'
+
+ - name: Install Local Dependencies
+ run: |
+ mvn install:install-file \
+ -Dfile=libs/PaperSpigot-1.8.8-R0.1-SNAPSHOT.jar \
+ -DgroupId=org.github.paperspigot \
+ -DartifactId=paperspigot-api \
+ -Dversion=1.8.8-R0.1-SNAPSHOT \
+ -Dpackaging=jar \
+ -DgeneratePom=true
+
+ - name: Build with Maven
+ run: mvn -B clean install --file pom.xml
+
+ - name: Upload Build Artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ZonePractice-Plugin
+ path: |
+ distribution/target/*.jar
+ !distribution/target/original-*.jar
+ retention-days: 5
\ No newline at end of file
diff --git a/.github/workflows/qodana_code_quality.yml b/.github/workflows/qodana_code_quality.yml
new file mode 100644
index 000000000..27e29c403
--- /dev/null
+++ b/.github/workflows/qodana_code_quality.yml
@@ -0,0 +1,35 @@
+name: Qodana
+on:
+ workflow_dispatch:
+ pull_request:
+ push:
+ branches:
+ - dev
+ - master
+
+jobs:
+ qodana:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: write
+ checks: write
+ security-events: write
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ fetch-depth: 0
+ lfs: true
+
+ - name: 'Qodana Scan'
+ uses: JetBrains/qodana-action@v2024.3
+ env:
+ QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
+ with:
+ pr-mode: false
+ use-caches: true
+ post-pr-comment: true
+ use-annotations: true
+ upload-result: false
\ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 000000000..5eec07b6e
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,75 @@
+name: Auto Release on Version Change
+
+on:
+ push:
+ branches: [ "master", "main" ]
+ paths: [ "pom.xml" ]
+
+jobs:
+ check-and-release:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ with:
+ lfs: true
+ fetch-depth: 2
+
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4
+ with:
+ java-version: '21'
+ distribution: 'temurin'
+ cache: 'maven'
+
+ - name: Install Local Dependencies
+ run: |
+ mvn install:install-file \
+ -Dfile=libs/PaperSpigot-1.8.8-R0.1-SNAPSHOT.jar \
+ -DgroupId=org.github.paperspigot \
+ -DartifactId=paperspigot-api \
+ -Dversion=1.8.8-R0.1-SNAPSHOT \
+ -Dpackaging=jar \
+ -DgeneratePom=true
+
+ - name: Check for Version Change
+ id: check_version
+ run: |
+ # Get current version (-N = non-recursive, only main pom)
+ NEW_VERSION=$(mvn -N help:evaluate -Dexpression=project.version -q -DforceStdout)
+
+ # Get previous version (save previous pom to a temp file)
+ git show HEAD^:pom.xml > pom_old.xml
+ OLD_VERSION=$(mvn -N -f pom_old.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
+ rm pom_old.xml
+
+ echo "Previous version: $OLD_VERSION"
+ echo "Current version: $NEW_VERSION"
+
+ # Compare versions
+ if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
+ echo "changed=true" >> $GITHUB_OUTPUT
+ echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
+ echo "Version change detected! ($OLD_VERSION -> $NEW_VERSION)"
+ else
+ echo "changed=false" >> $GITHUB_OUTPUT
+ echo "Version number did not change. Skipping release."
+ fi
+
+ - name: Build with Maven
+ if: steps.check_version.outputs.changed == 'true'
+ run: mvn -B clean install --file pom.xml
+
+ - name: Create GitHub Release
+ if: steps.check_version.outputs.changed == 'true'
+ uses: softprops/action-gh-release@v1
+ with:
+ tag_name: v${{ steps.check_version.outputs.version }}
+ name: ZonePractice v${{ steps.check_version.outputs.version }}
+ files: |
+ distribution/target/*.jar
+ !distribution/target/original-*.jar
+ generate_release_notes: true
\ No newline at end of file
diff --git a/.github/workflows/sync-dev.yml b/.github/workflows/sync-dev.yml
new file mode 100644
index 000000000..8d11f0e8a
--- /dev/null
+++ b/.github/workflows/sync-dev.yml
@@ -0,0 +1,25 @@
+name: Sync Dev with Master
+
+on:
+ pull_request:
+ types: [ closed ]
+ branches: [ "master", "main" ]
+
+jobs:
+ sync-branch:
+ runs-on: ubuntu-latest
+ if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'dev'
+
+ permissions:
+ contents: write
+
+ steps:
+ - name: Checkout Master/Main
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event.pull_request.base.ref }}
+ fetch-depth: 0
+
+ - name: Force Sync Dev
+ run: |
+ git push origin HEAD:dev --force
\ No newline at end of file
diff --git a/README.md b/README.md
index 9b53aa792..abd308513 100644
--- a/README.md
+++ b/README.md
@@ -73,8 +73,16 @@ system before cloning or pulling updates:
## Building
-1. Install JDK (Java 17+ recommended for modern builds) and Maven
-2. Run: `mvn clean package`
+1. **Prerequisites:** Install JDK (Java 17+ recommended for modern builds) and Maven.
+2. **Install Local Dependencies:**
+ Since the PaperSpigot API is not available in public repositories, install it manually from the `libs` folder:
+ ```bash
+ mvn install:install-file -Dfile=libs/PaperSpigot-1.8.8-R0.1-SNAPSHOT.jar -DgroupId=org.github.paperspigot -DartifactId=paperspigot-api -Dversion=1.8.8-R0.1-SNAPSHOT -Dpackaging=jar -DgeneratePom=true
+ ```
+3. **Build the Project:**
+ ```bash
+ mvn clean package
+ ```
## Installation (Server)
@@ -140,4 +148,4 @@ Copyright © **ZonePractice contributors**
## Contact
-For issues, feature requests or contributions, use the project’s GitHub issue tracker.
\ No newline at end of file
+For issues, feature requests or contributions, use the project’s GitHub issue tracker.
diff --git a/core/pom.xml b/core/pom.xml
index 3e8f6f179..ed2ea47ff 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -7,7 +7,7 @@
dev.nandi0813
practice-parent
- 6.22-SNAPSHOT
+ 6.22.1-SNAPSHOT
practice-core
@@ -45,8 +45,7 @@
org.github.paperspigot
paperspigot-api
1.8.8-R0.1-SNAPSHOT
- system
- ${basedir}/../libs/PaperSpigot-1.8.8-R0.1-SNAPSHOT.jar
+ provided
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/FFA/LMS/LMSData.java b/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/FFA/LMS/LMSData.java
index 9e19797f9..3f0a371ae 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/FFA/LMS/LMSData.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/FFA/LMS/LMSData.java
@@ -19,17 +19,21 @@ public LMSData() {
@Override
protected void setCustomData() {
- kitData.saveData(config, "kit");
+ if (kitData != null) {
+ kitData.saveData(config, "kit");
+ }
}
@Override
protected void getCustomData() {
- kitData.getData(config, "kit");
+ if (kitData != null) {
+ kitData.getData(config, "kit");
+ }
}
@Override
protected void enable() throws NullPointerException, IOException {
- if (!kitData.isSet()) {
+ if (kitData != null && !kitData.isSet()) {
throw new IOException("Kit data is not set.");
}
}
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/OneVsAll/Juggernaut/JuggernautData.java b/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/OneVsAll/Juggernaut/JuggernautData.java
index b04e562e8..75aec8971 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/OneVsAll/Juggernaut/JuggernautData.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Event/Events/OneVsAll/Juggernaut/JuggernautData.java
@@ -20,21 +20,33 @@ public JuggernautData() {
@Override
protected void setCustomData() {
- juggernautKitData.saveData(this.config, "juggernaut-kit");
- playerKitData.saveData(this.config, "player-kit");
+ if (juggernautKitData != null) {
+ juggernautKitData.saveData(this.config, "juggernaut-kit");
+ }
+
+ if (playerKitData != null) {
+ playerKitData.saveData(this.config, "player-kit");
+ }
}
@Override
protected void getCustomData() {
- juggernautKitData.getData(this.config, "juggernaut-kit");
- playerKitData.getData(this.config, "player-kit");
+ if (juggernautKitData != null) {
+ juggernautKitData.getData(this.config, "juggernaut-kit");
+ }
+
+ if (playerKitData != null) {
+ playerKitData.getData(this.config, "player-kit");
+ }
}
@Override
protected void enable() throws IOException {
- if (!juggernautKitData.isSet()) {
+ if (juggernautKitData == null || !juggernautKitData.isSet()) {
throw new IOException("Juggernaut kit data is not set.");
- } else if (!playerKitData.isSet()) {
+ }
+
+ if (playerKitData == null || !playerKitData.isSet()) {
throw new IOException("Player kit data is not set.");
}
}
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Util/EntityHiderListener.java b/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Util/EntityHiderListener.java
index 17b5ae3df..53a7302fd 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Util/EntityHiderListener.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/Fight/Util/EntityHiderListener.java
@@ -121,10 +121,6 @@ public void onPlayerMove(PlayerMoveEvent e) {
public void onPacketSend(PacketSendEvent e) {
Player player = e.getPlayer();
- if (player == null) {
- return;
- }
-
if (!this.checkPlayer(player)) {
effectTo.remove(player);
entityLocations.remove(player.getEntityId());
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/GUIs/CustomLadder/PremadeCustom/CustomLadderEditorGui.java b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/GUIs/CustomLadder/PremadeCustom/CustomLadderEditorGui.java
index 22e47b218..78e7175fa 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/GUIs/CustomLadder/PremadeCustom/CustomLadderEditorGui.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/GUIs/CustomLadder/PremadeCustom/CustomLadderEditorGui.java
@@ -36,10 +36,7 @@
import org.bukkit.potion.PotionEffect;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class CustomLadderEditorGui extends GUI {
@@ -138,7 +135,7 @@ public void update() {
if (inventory.getItem(i) == null)
inventory.setItem(i, fillerItem);
- if (VersionChecker.getBukkitVersion().isSecondHand()) {
+ if (Objects.requireNonNull(VersionChecker.getBukkitVersion()).isSecondHand()) {
if (customKit.getExtra() != null) {
if (customKit.getExtra().length > 0) {
inventory.setItem(14, customKit.getExtra()[0]);
@@ -212,7 +209,7 @@ public void handleCloseEvent(InventoryCloseEvent e) {
if (ladder.isEnabled() && ladder.isEditable() && !ladder.isFrozen()) {
ItemStack[] inventoryStorageContent = ClassImport.getClasses().getPlayerUtil().getInventoryStorageContent(player);
customKit.setInventory(inventoryStorageContent);
- if (VersionChecker.getBukkitVersion().isSecondHand()) {
+ if (Objects.requireNonNull(VersionChecker.getBukkitVersion()).isSecondHand()) {
customKit.setExtra(new ItemStack[]{this.gui.get(1).getItem(14)});
}
}
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Arena/ArenaSetupManager.java b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Arena/ArenaSetupManager.java
index 2110fffb6..097fc28c5 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Arena/ArenaSetupManager.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Arena/ArenaSetupManager.java
@@ -65,17 +65,17 @@ public void loadGUIs() {
{
GUIManager.getInstance().addGUI(new ArenaSummaryGui());
- for (DisplayArena arena : ArenaManager.getInstance().getArenaList())
+ for (DisplayArena arena : ArenaManager.getInstance().getArenaList()) {
buildArenaSetupGUIs(arena);
+ }
});
}
public void removeArenaGUIs(DisplayArena arena) {
for (GUI gui : arenaSetupGUIs.get(arena).values()) {
- for (Player player : gui.getInGuiPlayers().keySet())
+ for (Player player : gui.getInGuiPlayers().keySet()) {
GUIManager.getInstance().searchGUI(GUIType.Arena_Summary).open(player);
-
- GUIManager.getInstance().getGuis().remove(gui);
+ }
}
arenaSetupGUIs.remove(arena);
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Hologram/HologramSetupManager.java b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Hologram/HologramSetupManager.java
index 33cb5bf97..17e31cd7c 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Hologram/HologramSetupManager.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Hologram/HologramSetupManager.java
@@ -49,10 +49,9 @@ public void loadGUIs() {
public void removeHologramGUIs(Hologram hologram) {
for (GUI gui : hologramSetupGUIs.get(hologram).values()) {
- for (Player player : gui.getInGuiPlayers().keySet())
+ for (Player player : gui.getInGuiPlayers().keySet()) {
GUIManager.getInstance().searchGUI(GUIType.Setup_Hub).open(player);
-
- GUIManager.getInstance().getGuis().remove(gui);
+ }
}
hologramSetupGUIs.remove(hologram);
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSettings/InventoryGui.java b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSettings/InventoryGui.java
index 06a22d258..6420145ac 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSettings/InventoryGui.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSettings/InventoryGui.java
@@ -29,14 +29,13 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
public class InventoryGui extends GUI {
- private static final boolean secondHand = VersionChecker.getBukkitVersion().isSecondHand();
+ private static final boolean secondHand = Optional.ofNullable(VersionChecker.getBukkitVersion())
+ .map(VersionChecker.BukkitVersion::isSecondHand)
+ .orElse(false);
@Getter
private final NormalLadder ladder;
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSetupManager.java b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSetupManager.java
index dc87b6f78..ad230d076 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSetupManager.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/GUI/Setup/Ladder/LadderSetupManager.java
@@ -64,10 +64,9 @@ public void loadGUIs() {
public void removeLadderGUIs(Ladder ladder) {
for (GUI gui : ladderSetupGUIs.get(ladder).values()) {
- for (Player player : gui.getInGuiPlayers().keySet())
+ for (Player player : gui.getInGuiPlayers().keySet()) {
GUIManager.getInstance().searchGUI(GUIType.Setup_Hub).open(player);
-
- GUIManager.getInstance().getGuis().remove(gui);
+ }
}
ladderSetupGUIs.remove(ladder);
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/Inventory/InventoryManager.java b/core/src/main/java/dev/nandi0813/practice/Manager/Inventory/InventoryManager.java
index 3a6c47530..6c2207822 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/Inventory/InventoryManager.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/Inventory/InventoryManager.java
@@ -20,10 +20,7 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Getter
@@ -169,7 +166,7 @@ public void getData() {
if (inventory == null) continue;
inventory.getInvArmor().setArmorContent(
- ItemSerializationUtil.itemStackArrayFromBase64(BackendManager.getConfig().getString("INV-ARMORS." + key))
+ Objects.requireNonNull(ItemSerializationUtil.itemStackArrayFromBase64(BackendManager.getConfig().getString("INV-ARMORS." + key)))
);
}
}
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/Ladder/Abstraction/Normal/NormalLadder.java b/core/src/main/java/dev/nandi0813/practice/Manager/Ladder/Abstraction/Normal/NormalLadder.java
index 50d340cc0..71f6a27b1 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/Ladder/Abstraction/Normal/NormalLadder.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/Ladder/Abstraction/Normal/NormalLadder.java
@@ -59,7 +59,9 @@ public void getData() {
}
public void deleteData() {
- ladderFile.getFile().delete();
+ if (!ladderFile.getFile().delete()) {
+ System.out.println("Could not delete ladder file for ladder: " + this.getName());
+ }
}
public boolean isReadyToEnable() {
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/Party/Party.java b/core/src/main/java/dev/nandi0813/practice/Manager/Party/Party.java
index 186e7b333..d75e9016d 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/Party/Party.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/Party/Party.java
@@ -11,6 +11,7 @@
import dev.nandi0813.practice.Manager.Profile.Profile;
import dev.nandi0813.practice.Manager.Profile.ProfileManager;
import dev.nandi0813.practice.Util.Common;
+import dev.nandi0813.practice.Util.PlayerUtil.PlayerUtil;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.Player;
@@ -132,8 +133,6 @@ public void disband() {
}
GUIManager.getInstance().searchGUI(GUIType.Party_OtherParties).update();
- GUIManager.getInstance().getGuis().remove(partySettingsGui);
-
PartyManager.getInstance().getParties().remove(this);
}
@@ -143,10 +142,7 @@ public void sendMessage(String message) {
}
public List getMemberNames() {
- List memberNames = new ArrayList<>();
- for (Player player : members)
- memberNames.add(player.getName());
- return memberNames;
+ return PlayerUtil.getPlayerNames(members);
}
}
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Nametag/FakeTeam.java b/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Nametag/FakeTeam.java
index 620eb55cb..6b9af69d0 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Nametag/FakeTeam.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Nametag/FakeTeam.java
@@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
@Data
public class FakeTeam {
@@ -33,7 +34,7 @@ public FakeTeam(Component prefix, NamedTextColor nameColor, Component suffix, in
}
this.name = generatedName;
- if (VersionChecker.getBukkitVersion().equals(VersionChecker.BukkitVersion.v1_8_R3)) {
+ if (Objects.equals(VersionChecker.getBukkitVersion(), VersionChecker.BukkitVersion.v1_8_R3)) {
this.name = this.name.length() > 16 ? this.name.substring(0, 16) : this.name;
} else {
this.name = this.name.length() > 256 ? this.name.substring(0, 256) : this.name;
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Tab/TabList.java b/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Tab/TabList.java
index 201e2a8b8..af4ba5b34 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Tab/TabList.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/PlayerDisplay/Tab/TabList.java
@@ -23,9 +23,7 @@ public void setTab() {
);
User user = PacketEvents.getAPI().getPlayerManager().getUser(player);
- if (user != null) {
- user.sendPacket(packet);
- }
+ user.sendPacket(packet);
}
}
diff --git a/core/src/main/java/dev/nandi0813/practice/Manager/PlayerKit/KitItems.java b/core/src/main/java/dev/nandi0813/practice/Manager/PlayerKit/KitItems.java
index b1825efc3..0e5b929a8 100644
--- a/core/src/main/java/dev/nandi0813/practice/Manager/PlayerKit/KitItems.java
+++ b/core/src/main/java/dev/nandi0813/practice/Manager/PlayerKit/KitItems.java
@@ -6,15 +6,12 @@
import lombok.Getter;
import org.bukkit.inventory.ItemStack;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Getter
public class KitItems {
- private static final boolean SECOND_HAND = VersionChecker.getBukkitVersion().isSecondHand();
+ private static final boolean SECOND_HAND = Objects.requireNonNull(VersionChecker.getBukkitVersion()).isSecondHand();
private final KitData kitData;
diff --git a/core/src/main/java/dev/nandi0813/practice/Module/Interfaces/EntityHider.java b/core/src/main/java/dev/nandi0813/practice/Module/Interfaces/EntityHider.java
index 1f1068b49..1937a9242 100644
--- a/core/src/main/java/dev/nandi0813/practice/Module/Interfaces/EntityHider.java
+++ b/core/src/main/java/dev/nandi0813/practice/Module/Interfaces/EntityHider.java
@@ -14,6 +14,7 @@
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
+import org.jspecify.annotations.NonNull;
import java.util.Map;
@@ -161,15 +162,13 @@ public void onPlayerQuit(PlayerQuitEvent e) {
private PacketListener constructProtocol() {
return new PacketListener() {
@Override
- public void onPacketSend(PacketSendEvent event) {
+ public void onPacketSend(@NonNull PacketSendEvent event) {
PacketListener.super.onPacketSend(event);
int entityID = event.getPacketId();
- if (event.getPlayer() != null) {
- if (!isVisible(event.getPlayer(), entityID)) {
- event.setCancelled(true);
- }
+ if (!isVisible(event.getPlayer(), entityID)) {
+ event.setCancelled(true);
}
}
};
diff --git a/core/src/main/java/dev/nandi0813/practice/Module/Util/ClassImport.java b/core/src/main/java/dev/nandi0813/practice/Module/Util/ClassImport.java
index 11b81da3b..3caf15074 100644
--- a/core/src/main/java/dev/nandi0813/practice/Module/Util/ClassImport.java
+++ b/core/src/main/java/dev/nandi0813/practice/Module/Util/ClassImport.java
@@ -11,6 +11,7 @@
import org.bukkit.event.block.BlockPlaceEvent;
import java.lang.reflect.Constructor;
+import java.util.Objects;
public enum ClassImport {
;
@@ -101,7 +102,7 @@ public static ActionBar createActionBarClass(Profile profile) {
private static Class> getNamedClass() {
- String version = VersionChecker.getBukkitVersion().getModuleVersionExtension();
+ String version = Objects.requireNonNull(VersionChecker.getBukkitVersion()).getModuleVersionExtension();
if (version == null) {
return null;
}
diff --git a/core/src/main/java/dev/nandi0813/practice/Util/Cuboid.java b/core/src/main/java/dev/nandi0813/practice/Util/Cuboid.java
index 18e521dc8..6c02d89cb 100644
--- a/core/src/main/java/dev/nandi0813/practice/Util/Cuboid.java
+++ b/core/src/main/java/dev/nandi0813/practice/Util/Cuboid.java
@@ -117,7 +117,7 @@ public Cuboid(Map map) {
@Override
public Map serialize() {
- Map map = new HashMap();
+ Map map = new HashMap<>();
map.put("worldName", this.worldName);
map.put("x1", this.x1);
map.put("y1", this.y1);
@@ -153,7 +153,7 @@ public Location getUpperSW() {
*/
public List getBlocks() {
Iterator blockI = this.iterator();
- List copy = new ArrayList();
+ List copy = new ArrayList<>();
while (blockI.hasNext())
copy.add(blockI.next());
return copy;
@@ -291,22 +291,15 @@ public Block[] corners() {
* @return A new Cuboid expanded by the given direction and amount
*/
public Cuboid expand(CuboidDirection dir, int amount) {
- switch (dir) {
- case North:
- return new Cuboid(this.worldName, this.x1 - amount, this.y1, this.z1, this.x2, this.y2, this.z2);
- case South:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2 + amount, this.y2, this.z2);
- case East:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1 - amount, this.x2, this.y2, this.z2);
- case West:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z2 + amount);
- case Down:
- return new Cuboid(this.worldName, this.x1, this.y1 - amount, this.z1, this.x2, this.y2, this.z2);
- case Up:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2 + amount, this.z2);
- default:
- throw new IllegalArgumentException("Invalid direction " + dir);
- }
+ return switch (dir) {
+ case North -> new Cuboid(this.worldName, this.x1 - amount, this.y1, this.z1, this.x2, this.y2, this.z2);
+ case South -> new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2 + amount, this.y2, this.z2);
+ case East -> new Cuboid(this.worldName, this.x1, this.y1, this.z1 - amount, this.x2, this.y2, this.z2);
+ case West -> new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z2 + amount);
+ case Down -> new Cuboid(this.worldName, this.x1, this.y1 - amount, this.z1, this.x2, this.y2, this.z2);
+ case Up -> new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2 + amount, this.z2);
+ default -> throw new IllegalArgumentException("Invalid direction " + dir);
+ };
}
/**
@@ -328,20 +321,13 @@ public Cuboid shift(CuboidDirection dir, int amount) {
* @return A new Cuboid outset by the given direction and amount
*/
public Cuboid outset(CuboidDirection dir, int amount) {
- Cuboid c;
- switch (dir) {
- case Horizontal:
- c = expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount);
- break;
- case Vertical:
- c = expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount);
- break;
- case Both:
- c = outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount);
- break;
- default:
- throw new IllegalArgumentException("Invalid direction " + dir);
- }
+ Cuboid c = switch (dir) {
+ case Horizontal ->
+ expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount);
+ case Vertical -> expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount);
+ case Both -> outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount);
+ default -> throw new IllegalArgumentException("Invalid direction " + dir);
+ };
return c;
}
@@ -434,40 +420,45 @@ public Cuboid contract() {
*/
public Cuboid contract(CuboidDirection dir) {
Cuboid face = getFace(dir.opposite());
- switch (dir) {
- case Down:
+ return switch (dir) {
+ case Down -> {
while (face.containsOnly(0) && face.getLowerY() > this.getLowerY()) {
face = face.shift(CuboidDirection.Down, 1);
}
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, face.getUpperY(), this.z2);
- case Up:
+ yield new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, face.getUpperY(), this.z2);
+ }
+ case Up -> {
while (face.containsOnly(0) && face.getUpperY() < this.getUpperY()) {
face = face.shift(CuboidDirection.Up, 1);
}
- return new Cuboid(this.worldName, this.x1, face.getLowerY(), this.z1, this.x2, this.y2, this.z2);
- case North:
+ yield new Cuboid(this.worldName, this.x1, face.getLowerY(), this.z1, this.x2, this.y2, this.z2);
+ }
+ case North -> {
while (face.containsOnly(0) && face.getLowerX() > this.getLowerX()) {
face = face.shift(CuboidDirection.North, 1);
}
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, face.getUpperX(), this.y2, this.z2);
- case South:
+ yield new Cuboid(this.worldName, this.x1, this.y1, this.z1, face.getUpperX(), this.y2, this.z2);
+ }
+ case South -> {
while (face.containsOnly(0) && face.getUpperX() < this.getUpperX()) {
face = face.shift(CuboidDirection.South, 1);
}
- return new Cuboid(this.worldName, face.getLowerX(), this.y1, this.z1, this.x2, this.y2, this.z2);
- case East:
+ yield new Cuboid(this.worldName, face.getLowerX(), this.y1, this.z1, this.x2, this.y2, this.z2);
+ }
+ case East -> {
while (face.containsOnly(0) && face.getLowerZ() > this.getLowerZ()) {
face = face.shift(CuboidDirection.East, 1);
}
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, face.getUpperZ());
- case West:
+ yield new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, face.getUpperZ());
+ }
+ case West -> {
while (face.containsOnly(0) && face.getUpperZ() < this.getUpperZ()) {
face = face.shift(CuboidDirection.West, 1);
}
- return new Cuboid(this.worldName, this.x1, this.y1, face.getLowerZ(), this.x2, this.y2, this.z2);
- default:
- throw new IllegalArgumentException("Invalid direction " + dir);
- }
+ yield new Cuboid(this.worldName, this.x1, this.y1, face.getLowerZ(), this.x2, this.y2, this.z2);
+ }
+ default -> throw new IllegalArgumentException("Invalid direction " + dir);
+ };
}
/**
@@ -477,22 +468,15 @@ public Cuboid contract(CuboidDirection dir) {
* @return The Cuboid representing this Cuboid's requested face
*/
public Cuboid getFace(CuboidDirection dir) {
- switch (dir) {
- case Down:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y1, this.z2);
- case Up:
- return new Cuboid(this.worldName, this.x1, this.y2, this.z1, this.x2, this.y2, this.z2);
- case North:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x1, this.y2, this.z2);
- case South:
- return new Cuboid(this.worldName, this.x2, this.y1, this.z1, this.x2, this.y2, this.z2);
- case East:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z1);
- case West:
- return new Cuboid(this.worldName, this.x1, this.y1, this.z2, this.x2, this.y2, this.z2);
- default:
- throw new IllegalArgumentException("Invalid direction " + dir);
- }
+ return switch (dir) {
+ case Down -> new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y1, this.z2);
+ case Up -> new Cuboid(this.worldName, this.x1, this.y2, this.z1, this.x2, this.y2, this.z2);
+ case North -> new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x1, this.y2, this.z2);
+ case South -> new Cuboid(this.worldName, this.x2, this.y1, this.z1, this.x2, this.y2, this.z2);
+ case East -> new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z1);
+ case West -> new Cuboid(this.worldName, this.x1, this.y1, this.z2, this.x2, this.y2, this.z2);
+ default -> throw new IllegalArgumentException("Invalid direction " + dir);
+ };
}
/**
@@ -611,7 +595,11 @@ public Iterator iterator() {
@Override
public Cuboid clone() {
- return new Cuboid(this);
+ try {
+ return (Cuboid) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError();
+ }
}
@Override
diff --git a/core/src/main/java/dev/nandi0813/practice/Util/SaveResource.java b/core/src/main/java/dev/nandi0813/practice/Util/SaveResource.java
index 6998acb7f..2d5e9d0b0 100644
--- a/core/src/main/java/dev/nandi0813/practice/Util/SaveResource.java
+++ b/core/src/main/java/dev/nandi0813/practice/Util/SaveResource.java
@@ -14,6 +14,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Objects;
public class SaveResource {
@@ -95,7 +96,7 @@ private void saveResource(@NotNull File document, @NotNull InputStream defaults)
}
private String getVersionPath() {
- return VersionChecker.getBukkitVersion().getFilePath();
+ return Objects.requireNonNull(VersionChecker.getBukkitVersion()).getFilePath();
}
private static void saveLadder(ZonePractice practice, String path, String fileName) {
diff --git a/distribution/pom.xml b/distribution/pom.xml
index ea075cbd1..b9272baa1 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -10,7 +10,7 @@
dev.nandi0813
practice-parent
- 6.22-SNAPSHOT
+ 6.22.1-SNAPSHOT
@@ -23,9 +23,9 @@
clean install
- ZonePractice Pro v6.22-SNAPSHOT
+ ZonePractice Pro v6.22.1-SNAPSHOT
-
+
org.apache.maven.plugins
maven-shade-plugin
@@ -37,9 +37,6 @@
shade
- false
- ${project.build.finalName}.jar
-
false
diff --git a/pom.xml b/pom.xml
index 67206f020..ad9809c03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
dev.nandi0813
practice-parent
- 6.22-SNAPSHOT
+ 6.22.1-SNAPSHOT
pom
ZonePractice Pro
@@ -93,7 +93,7 @@
net.wesjd
anvilgui
- 1.10.10-SNAPSHOT
+ 1.10.11-SNAPSHOT
diff --git a/qodana.yaml b/qodana.yaml
new file mode 100644
index 000000000..e3761a1c9
--- /dev/null
+++ b/qodana.yaml
@@ -0,0 +1,8 @@
+version: "1.0"
+
+profile:
+ name: qodana.starter
+
+projectJDK: "17"
+
+linter: jetbrains/qodana-jvm-community:2025.3
\ No newline at end of file
diff --git a/spigot_1_8_8/pom.xml b/spigot_1_8_8/pom.xml
index c2fa1dca4..6d3f2a411 100644
--- a/spigot_1_8_8/pom.xml
+++ b/spigot_1_8_8/pom.xml
@@ -7,7 +7,7 @@
dev.nandi0813
practice-parent
- 6.22-SNAPSHOT
+ 6.22.1-SNAPSHOT
practice-spigot_1_8_8
@@ -18,8 +18,7 @@
org.github.paperspigot
paperspigot-api
1.8.8-R0.1-SNAPSHOT
- system
- ${basedir}/../libs/PaperSpigot-1.8.8-R0.1-SNAPSHOT.jar
+ provided
diff --git a/spigot_modern/pom.xml b/spigot_modern/pom.xml
index 4044e89b8..8549102f1 100644
--- a/spigot_modern/pom.xml
+++ b/spigot_modern/pom.xml
@@ -7,7 +7,7 @@
dev.nandi0813
practice-parent
- 6.22-SNAPSHOT
+ 6.22.1-SNAPSHOT
practice-spigot_modern