浏览代码

Merge pull request #143 from RedstoneFuture/improvements/misc

Misc Improvements and Bugfixes
RedstoneFuture 2 周之前
父节点
当前提交
0b815300b1

+ 18 - 12
.github/workflows/java-ci.yaml

@@ -1,25 +1,31 @@
 name: Java CI
 name: Java CI
 
 
 on:
 on:
-  pull_request:
   push:
   push:
+    branches: [master]         # Trigger the workflow when pushing to the master branch
+  pull_request:
+    branches: [master]         # Trigger the workflow for pull requests targeting the master branch
 
 
 jobs:
 jobs:
   build:
   build:
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-latest     # Use the latest available Ubuntu runner
 
 
     steps:
     steps:
-      - uses: actions/checkout@v3
+      - name: Checkout Repository
+        uses: actions/checkout@v4  # Check out the source code from the repository
+
       - name: Set up JDK 17
       - name: Set up JDK 17
-        uses: actions/setup-java@v3
+        uses: actions/setup-java@v4  # Set up the Java Development Kit
         with:
         with:
-          java-version: '17'
-          distribution: 'adopt'
-          cache: 'maven'
+          java-version: '17'         # Specify Java version 17
+          distribution: 'temurin'    # Use Temurin distribution (successor to AdoptOpenJDK)
+          cache: 'maven'             # Enable Maven dependency caching for faster builds
+
       - name: Build with Maven
       - name: Build with Maven
-        run: mvn --batch-mode --update-snapshots package
-      - name: Archive artifacts
-        uses: actions/upload-artifact@v3
+        run: mvn --batch-mode --update-snapshots package  # Compile the project and create the JAR
+
+      - name: Upload JAR Artifact
+        uses: actions/upload-artifact@v4  # Upload the built JAR file as a workflow artifact
         with:
         with:
-          name: MissileWars jar
-          path: missilewars-plugin/target/MissileWars-*.jar
+          name: missilewars-jar           # Name of the uploaded artifact
+          path: missilewars-plugin/target/MissileWars-*.jar  # Path to the JAR file(s) to upload

+ 1 - 1
missilewars-plugin/pom.xml

@@ -123,7 +123,7 @@
         <dependency>
         <dependency>
             <groupId>com.github.stefvanschie.inventoryframework</groupId>
             <groupId>com.github.stefvanschie.inventoryframework</groupId>
             <artifactId>IF</artifactId>
             <artifactId>IF</artifactId>
-            <version>0.10.19</version>
+            <version>0.11.2</version>
         </dependency>
         </dependency>
     </dependencies>
     </dependencies>
 
 

+ 11 - 6
missilewars-plugin/src/main/java/de/butzlabben/missilewars/MissileWars.java

@@ -49,17 +49,18 @@ import java.util.Date;
 @Getter
 @Getter
 public class MissileWars extends JavaPlugin {
 public class MissileWars extends JavaPlugin {
 
 
-    @Getter
-    private static MissileWars instance;
+    @Getter private static MissileWars instance;
     
     
     public final String version = getDescription().getVersion();
     public final String version = getDescription().getVersion();
     private SignRepository signRepository;
     private SignRepository signRepository;
     public PaperCommandManager commandManager;
     public PaperCommandManager commandManager;
     
     
-    @Getter private PlayerListener playerListener;
-    @Getter private SignListener signListener;
+    private PlayerListener playerListener;
+    private SignListener signListener;
     
     
-    @Getter private Paster schematicPaster;
+    private Paster schematicPaster;
+    
+    private boolean isPapiInstalled;
     
     
     public MissileWars() {
     public MissileWars() {
         instance = this;
         instance = this;
@@ -131,7 +132,11 @@ public class MissileWars extends JavaPlugin {
     private void initialPapiSupport() {
     private void initialPapiSupport() {
         if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
         if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
             new MissileWarsPlaceholder(this).register();
             new MissileWarsPlaceholder(this).register();
-            Logger.NORMAL.log("The PlaceholderAPI is installed. New placeholders are provided by MissileWars.");
+            isPapiInstalled = true;
+            Logger.NORMAL.log("PlaceholderAPI is installed. New placeholders are provided by MissileWars.");
+        } else {
+            isPapiInstalled = false;
+            Logger.NORMAL.log("PlaceholderAPI is not installed. Placeholders arent working for now.");
         }
         }
     }
     }
     
     

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/MWCommands.java

@@ -416,7 +416,7 @@ public class MWCommands extends BaseCommand {
             return;
             return;
         }
         }
 
 
-        ConfigLoader.loadConfigs();
+        ConfigLoader.loadMainConfigs();
         Arenas.load();
         Arenas.load();
 
 
         player.sendMessage(PluginMessages.getMessage(true, PluginMessages.MessageEnum.DEBUG_RELOAD_CONFIG));
         player.sendMessage(PluginMessages.getMessage(true, PluginMessages.MessageEnum.DEBUG_RELOAD_CONFIG));

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/configuration/Config.java

@@ -81,7 +81,7 @@ public class Config {
 
 
         cfg.addDefault("games.multiple_games", false);
         cfg.addDefault("games.multiple_games", false);
         cfg.addDefault("games.folder", "plugins/MissileWars/games");
         cfg.addDefault("games.folder", "plugins/MissileWars/games");
-        cfg.addDefault("games.default_game", "game0.yml");
+        cfg.addDefault("games.default_game", "game1.yml");
 
 
         cfg.addDefault("missiles.folder", "plugins/MissileWars/schematics/missiles");
         cfg.addDefault("missiles.folder", "plugins/MissileWars/schematics/missiles");
         cfg.addDefault("shields.folder", "plugins/MissileWars/schematics/shields");
         cfg.addDefault("shields.folder", "plugins/MissileWars/schematics/shields");

+ 3 - 0
missilewars-plugin/src/main/java/de/butzlabben/missilewars/configuration/PluginMessages.java

@@ -263,6 +263,9 @@ public class PluginMessages {
     }
     }
     
     
     public static String getPapiMessage(String message, Player player) {
     public static String getPapiMessage(String message, Player player) {
+        // Is PAPI (soft-depend) installed on the server?
+        if (!MissileWars.getInstance().isPapiInstalled()) return message;
+        
         return ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, message));
         return ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, message));
     }
     }
 }
 }

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/configuration/arena/ArenaConfig.java

@@ -35,7 +35,7 @@ import java.io.IOException;
 public class ArenaConfig implements Cloneable {
 public class ArenaConfig implements Cloneable {
 
 
     // The values defined here are only valid if there is no Config yet.
     // The values defined here are only valid if there is no Config yet.
-    private String name = "arena0";
+    private String name = "arena1";
     @SerializedName("display_name") private String displayName = "&eDefault map";
     @SerializedName("display_name") private String displayName = "&eDefault map";
     @SerializedName("display_material") private String displayMaterial = "STONE";
     @SerializedName("display_material") private String displayMaterial = "STONE";
     @SerializedName("template_world") private String templateWorld = "default_map";
     @SerializedName("template_world") private String templateWorld = "default_map";

+ 2 - 2
missilewars-plugin/src/main/java/de/butzlabben/missilewars/configuration/game/GameConfig.java

@@ -45,7 +45,7 @@ import java.util.stream.Collectors;
 public class GameConfig {
 public class GameConfig {
 
 
     // The values defined here are only valid if there is no Config yet.
     // The values defined here are only valid if there is no Config yet.
-    private String name = "game0";
+    private String name = "game1";
     @SerializedName("display_name") private String displayName = "&eDefault game";
     @SerializedName("display_name") private String displayName = "&eDefault game";
     @SerializedName("auto_load") private boolean autoLoad = true;
     @SerializedName("auto_load") private boolean autoLoad = true;
     @SerializedName("min_players") private int minPlayers = 2;
     @SerializedName("min_players") private int minPlayers = 2;
@@ -59,7 +59,7 @@ public class GameConfig {
     @SerializedName("rejoin_ongoing_game") private RejoinIngameBehavior rejoinIngameBehavior = RejoinIngameBehavior.LAST_TEAM;
     @SerializedName("rejoin_ongoing_game") private RejoinIngameBehavior rejoinIngameBehavior = RejoinIngameBehavior.LAST_TEAM;
     @SerializedName("lobby") private LobbyConfig lobbyConfig = new LobbyConfig();
     @SerializedName("lobby") private LobbyConfig lobbyConfig = new LobbyConfig();
     @SerializedName("possible_arenas") private List<String> possibleArenas = new ArrayList<>() {{
     @SerializedName("possible_arenas") private List<String> possibleArenas = new ArrayList<>() {{
-        add("arena0");
+        add("arena1");
     }};
     }};
 
 
     // These values are only set after the Config has been read.
     // These values are only set after the Config has been read.

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Arenas.java

@@ -48,7 +48,7 @@ public class Arenas {
         // Get all arena files or create a new one
         // Get all arena files or create a new one
         File[] arenaFiles = folder.listFiles();
         File[] arenaFiles = folder.listFiles();
         if (arenaFiles.length == 0) {
         if (arenaFiles.length == 0) {
-            File defaultConfig = new File(folder, "arena0.yml");
+            File defaultConfig = new File(folder, "arena1.yml");
             try {
             try {
                 defaultConfig.createNewFile();
                 defaultConfig.createNewFile();
                 Serializer.serialize(defaultConfig, new ArenaConfig());
                 Serializer.serialize(defaultConfig, new ArenaConfig());

+ 2 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Game.java

@@ -476,7 +476,6 @@ public class Game {
         }
         }
         
         
         itemStack.setAmount(itemStack.getAmount() - 1);
         itemStack.setAmount(itemStack.getAmount() - 1);
-        player.setItemInHand(itemStack);
         missile.paste(this, player);
         missile.paste(this, player);
     }
     }
 
 
@@ -756,6 +755,8 @@ public class Game {
      */
      */
     public void checkPortals() {
     public void checkPortals() {
         
         
+        // Note: The 'BlockDestroyEvent' is only available on PaperMC.
+        
         for (Location location : portalBlocks) {
         for (Location location : portalBlocks) {
             
             
             if (location.getBlock().getType() == Material.NETHER_PORTAL) continue;
             if (location.getBlock().getType() == Material.NETHER_PORTAL) continue;

+ 1 - 0
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/objects/Shield.java

@@ -30,6 +30,7 @@ public class Shield extends SchematicObject {
             Vector pastePos = new Vector(loc.getX(), loc.getY(), loc.getZ());
             Vector pastePos = new Vector(loc.getX(), loc.getY(), loc.getZ());
             
             
             MissileWars.getInstance().getSchematicPaster().pasteSchematic(getSchematic(), pastePos, 0, loc.getWorld());
             MissileWars.getInstance().getSchematicPaster().pasteSchematic(getSchematic(), pastePos, 0, loc.getWorld());
+            ball.remove();
         } catch (Exception e) {
         } catch (Exception e) {
             Logger.ERROR.log("Could not load " + getDisplayName());
             Logger.ERROR.log("Could not load " + getDisplayName());
             e.printStackTrace();
             e.printStackTrace();

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/timer/LobbyTimer.java

@@ -28,7 +28,7 @@ import org.bukkit.Sound;
  * @author Butzlabben
  * @author Butzlabben
  * @since 11.01.2018
  * @since 11.01.2018
  */
  */
-public class LobbyTimer extends Timer implements Runnable {
+public class LobbyTimer extends Timer {
 
 
     private final int startTime;
     private final int startTime;
     private int remaining = 90; // for sending messages
     private int remaining = 90; // for sending messages

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/initialization/ConfigLoader.java

@@ -10,7 +10,7 @@ import java.nio.charset.StandardCharsets;
 
 
 public class ConfigLoader {
 public class ConfigLoader {
     
     
-    public static void loadConfigs() {
+    public static void loadMainConfigs() {
         
         
         Config.load();
         Config.load();
         PluginMessages.load();
         PluginMessages.load();

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/initialization/FileManager.java

@@ -23,7 +23,7 @@ public class FileManager {
         
         
         deleteTempWorlds();
         deleteTempWorlds();
         
         
-        ConfigLoader.loadConfigs();
+        ConfigLoader.loadMainConfigs();
         
         
         saveDefaultResource(Config.getMissilesFolder(), "missiles.zip", MissileWars.getInstance());
         saveDefaultResource(Config.getMissilesFolder(), "missiles.zip", MissileWars.getInstance());
         saveDefaultResource(Config.getShieldsFolder(), "shields.zip", MissileWars.getInstance());
         saveDefaultResource(Config.getShieldsFolder(), "shields.zip", MissileWars.getInstance());

+ 4 - 0
missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/GameListener.java

@@ -101,6 +101,10 @@ public class GameListener extends GameBoundListener {
         // missile spawn with using of a missile spawn egg
         // missile spawn with using of a missile spawn egg
         if (Missile.isSpawnEgg(itemStack.getType())) {
         if (Missile.isSpawnEgg(itemStack.getType())) {
             event.setCancelled(true);
             event.setCancelled(true);
+            
+            // prevent spam with the event handling
+            if (isInteractDelay(player)) return;
+            setInteractDelay(player);
 
 
             // Can missiles only be spawned if the item interaction was performed on a block (no air)?
             // Can missiles only be spawned if the item interaction was performed on a block (no air)?
             boolean isOnlyBlockPlaceable = getGame().getArenaConfig().getMissileConfig().isOnlyBlockPlaceable();
             boolean isOnlyBlockPlaceable = getGame().getArenaConfig().getMissileConfig().isOnlyBlockPlaceable();

二进制
missilewars-plugin/src/main/resources/shields.zip


+ 11 - 2
pom.xml

@@ -58,6 +58,11 @@
             <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
             <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
         </repository>
         </repository>
 
 
+        <repository>
+            <id>redstoneworld-RedUtilities</id>
+            <url>https://dl.cloudsmith.io/public/redstoneworld/RedUtilities/maven/</url>
+        </repository>
+
     </repositories>
     </repositories>
 
 
     <dependencies>
     <dependencies>
@@ -140,11 +145,15 @@
                     <relocations>
                     <relocations>
                         <relocation>
                         <relocation>
                             <pattern>org.bstats</pattern>
                             <pattern>org.bstats</pattern>
-                            <shadedPattern>de.butzlabben.missilewars</shadedPattern>
+                            <shadedPattern>de.butzlabben.missilewars.shaded.bstats</shadedPattern>
                         </relocation>
                         </relocation>
                         <relocation>
                         <relocation>
                             <pattern>com.github.stefvanschie.inventoryframework</pattern>
                             <pattern>com.github.stefvanschie.inventoryframework</pattern>
-                            <shadedPattern>de.butzlabben.missilewars.MissileWars.inventoryframework</shadedPattern>
+                            <shadedPattern>de.butzlabben.missilewars.shaded.inventoryframework</shadedPattern>
+                        </relocation>
+                        <relocation>
+                            <pattern>com.fasterxml.jackson</pattern>
+                            <shadedPattern>de.butzlabben.missilewars.shaded.jackson</shadedPattern>
                         </relocation>
                         </relocation>
                     </relocations>
                     </relocations>