Browse Source

Reworking Arrow Configuration

RedstoneFuture 2 years ago
parent
commit
cdb76e6a99

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/wrapper/abstracts/Arena.java

@@ -50,7 +50,7 @@ public class Arena {
     @SerializedName("game_duration") private int gameDuration = 30;
     @SerializedName("fireball") private FireballConfiguration fireballConfiguration = new FireballConfiguration();
     @SerializedName("shield") private ShieldConfiguration shieldConfiguration = new ShieldConfiguration();
-    @SerializedName("arrow_occurrence") private int arrowOccurrence = 2;
+    @SerializedName("arrow") private ArrowConfiguration arrowConfiguration = new ArrowConfiguration();
     @SerializedName("save_statistics") private boolean saveStatistics = true;
     @SerializedName("fall_protection") private FallProtectionConfiguration fallProtection = new FallProtectionConfiguration();
     @SerializedName("money") private MoneyConfiguration money = new MoneyConfiguration();

+ 32 - 0
missilewars-plugin/src/main/java/de/butzlabben/missilewars/wrapper/abstracts/arena/ArrowConfiguration.java

@@ -0,0 +1,32 @@
+/*
+ * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
+ * Copyright (c) 2018-2021 Daniel Nägele.
+ *
+ * MissileWars is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MissileWars is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package de.butzlabben.missilewars.wrapper.abstracts.arena;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.ToString;
+
+@Getter
+@ToString
+@RequiredArgsConstructor
+public class ArrowConfiguration {
+
+    private int occurrence = 2;
+    private int amount = 3;
+}

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/wrapper/abstracts/arena/ShieldConfiguration.java

@@ -31,5 +31,5 @@ public class ShieldConfiguration {
     private String name = "Shield";
     private String schematic = "shield.schematic";
     private int occurrence = 1;
-    @SerializedName("serialized_name") private int flyTime = 20;
+    @SerializedName("fly_time") private int flyTime = 20;
 }

+ 3 - 2
missilewars-plugin/src/main/java/de/butzlabben/missilewars/wrapper/game/SpecialGameEquipment.java

@@ -59,11 +59,12 @@ public class SpecialGameEquipment {
      * This method goes through all configured special equipment items
      * and adds them to the list. The higher the defined spawn-occurrence
      * of an item type being set, the more often it will be added to the list.
+     * If the spawn-occurrence is 0, the equipment is skipped.
      */
     private void createSpecialEquipmentList() {
 
         int shieldOccurrence = game.getArena().getShieldConfiguration().getOccurrence();
-        int arrowOccurrence = game.getArena().getArrowOccurrence();
+        int arrowOccurrence = game.getArena().getArrowConfiguration().getOccurrence();
         int fireballOccurrence = game.getArena().getFireballConfiguration().getOccurrence();
 
         for (int i = shieldOccurrence; i > 0; i--) {
@@ -94,7 +95,7 @@ public class SpecialGameEquipment {
      * This method creates the arrow item stack.
      */
     private void createArrow() {
-        arrow = new ItemStack(Material.ARROW, 3);
+        arrow = new ItemStack(Material.ARROW, game.getArena().getArrowConfiguration().getAmount());
     }
 
     /**