Răsfoiți Sursa

Fun with arrows

nossr50 1 an în urmă
părinte
comite
9360e147ac

+ 1 - 5
src/main/java/com/gmail/nossr50/commands/skills/TridentsCommand.java

@@ -2,11 +2,7 @@ package com.gmail.nossr50.commands.skills;
 
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
 import com.gmail.nossr50.datatypes.skills.SubSkillType;
-import com.gmail.nossr50.mcMMO;
-import com.gmail.nossr50.util.Permissions;
-import com.gmail.nossr50.util.random.ProbabilityUtil;
 import com.gmail.nossr50.util.skills.CombatUtils;
-import com.gmail.nossr50.util.skills.RankUtils;
 import com.gmail.nossr50.util.text.TextComponentFactory;
 import net.kyori.adventure.text.Component;
 import org.bukkit.entity.Player;
@@ -31,7 +27,7 @@ public class TridentsCommand extends SkillCommand {
     protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
         List<String> messages = new ArrayList<>();
 
-        if (canUseSubskill(player, SubSkillType.TRIDENTS_TRIDENTS_SUPER_ABILITY)) {
+        if (canUseSubskill(player, SubSkillType.TRIDENTS_SUPER)) {
             messages.add("Tridents Super Ability");
             //TODO: Implement Tridents Super
         }

+ 2 - 1
src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java

@@ -35,6 +35,7 @@ public enum SubSkillType {
     /* CROSSBOWS */
     CROSSBOWS_SUPER_SHOTGUN(1),
     CROSSBOWS_CROSSBOWS_LIMIT_BREAK(10),
+    CROSSBOWS_TRICK_SHOT(5),
 
     /* Excavation */
     EXCAVATION_ARCHAEOLOGY(8),
@@ -99,7 +100,7 @@ public enum SubSkillType {
     TAMING_THICK_FUR(1),
 
     /* Tridents */
-    TRIDENTS_TRIDENTS_SUPER_ABILITY(1),
+    TRIDENTS_SUPER(1),
     TRIDENTS_TRIDENTS_LIMIT_BREAK(10),
 
     /* Unarmed */

+ 1 - 1
src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java

@@ -112,7 +112,7 @@ public enum SuperAbilityType {
         TREE_FELLER.subSkillTypeDefinition          = SubSkillType.WOODCUTTING_TREE_FELLER;
         SERRATED_STRIKES.subSkillTypeDefinition     = SubSkillType.SWORDS_SERRATED_STRIKES;
         BLAST_MINING.subSkillTypeDefinition         = SubSkillType.MINING_BLAST_MINING;
-        TRIDENTS_SUPER_ABILITY.subSkillTypeDefinition = SubSkillType.TRIDENTS_TRIDENTS_SUPER_ABILITY;
+        TRIDENTS_SUPER_ABILITY.subSkillTypeDefinition = SubSkillType.TRIDENTS_SUPER;
         SUPER_SHOTGUN.subSkillTypeDefinition = SubSkillType.CROSSBOWS_SUPER_SHOTGUN;
     }
 

+ 47 - 4
src/main/java/com/gmail/nossr50/listeners/EntityListener.java

@@ -27,10 +27,7 @@ import com.gmail.nossr50.util.random.ProbabilityUtil;
 import com.gmail.nossr50.util.skills.CombatUtils;
 import com.gmail.nossr50.worldguard.WorldGuardManager;
 import com.gmail.nossr50.worldguard.WorldGuardUtils;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.NamespacedKey;
-import org.bukkit.OfflinePlayer;
+import org.bukkit.*;
 import org.bukkit.attribute.Attribute;
 import org.bukkit.block.Block;
 import org.bukkit.enchantments.Enchantment;
@@ -48,6 +45,7 @@ import org.bukkit.metadata.FixedMetadataValue;
 import org.bukkit.potion.PotionEffect;
 import org.bukkit.potion.PotionEffectType;
 import org.bukkit.projectiles.ProjectileSource;
+import org.bukkit.util.Vector;
 import org.jetbrains.annotations.NotNull;
 
 public class EntityListener implements Listener {
@@ -1111,5 +1109,50 @@ public class EntityListener implements Listener {
         }
     }
 
+    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
+    public void onProjectileHitEvent(ProjectileHitEvent event) {
+        /* WORLD BLACKLIST CHECK */
+        if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
+            return;
+
+        if(event.getEntity() instanceof Arrow originalArrow && event.getHitBlock() != null) {
+            if (originalArrow.getShooter() instanceof Player) {
+                // Avoid infinite spawning of arrows
+                if (originalArrow.hasMetadata(MetadataConstants.METADATA_KEY_SPAWNED_ARROW)) {
+                    return;
+                }
 
+                // Spawn a new arrow shooting in a random direction
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+                spawnArrow(originalArrow, originalArrow.getLocation());
+            }
+        }
+    }
+
+    private void spawnArrow(Arrow originalArrow, Location origin) {
+        // TODO: Add an event for this for plugins to hook into
+        // Spawn a new arrow shooting in a random direction
+        ProjectileSource originalArrowShooter = originalArrow.getShooter();
+        Arrow arrow = originalArrow.getWorld().spawnArrow(origin,
+                new Vector(
+                        // TODO: Spawn arrow away from surface
+                        Math.random() * 2 - 1,
+                        Math.random() * 2 - 1,
+                        Math.random() * 2 - 1), 1, 1);
+        arrow.setShooter(originalArrowShooter);
+        arrow.setMetadata(MetadataConstants.METADATA_KEY_SPAWNED_ARROW,
+                new FixedMetadataValue(pluginRef, originalArrowShooter));
+        arrow.setMetadata(MetadataConstants.METADATA_KEY_BOW_TYPE,
+                new FixedMetadataValue(pluginRef, originalArrow.getMetadata(
+                        MetadataConstants.METADATA_KEY_BOW_TYPE).get(0)));
+    }
 }

+ 1 - 1
src/main/java/com/gmail/nossr50/mcMMO.java

@@ -98,7 +98,7 @@ public class mcMMO extends JavaPlugin {
     private static CommandManager commandManager; //ACF
     private static TransientEntityTracker transientEntityTracker;
 
-    private @NotNull SkillTools skillTools;
+    private SkillTools skillTools;
 
     private static boolean serverShutdownExecuted = false;
 

+ 1 - 0
src/main/java/com/gmail/nossr50/util/MetadataConstants.java

@@ -14,6 +14,7 @@ public class MetadataConstants {
      * Take great care if you ever modify the value of these keys
      */
     public static final @NotNull String METADATA_KEY_REPLANT = "mcMMO: Recently Replanted";
+    public static final @NotNull String METADATA_KEY_SPAWNED_ARROW = "mcMMO: Spawned Arrow";
     public static final @NotNull String METADATA_KEY_BOW_TYPE = "mcMMO: Bow Type";
     public static final @NotNull String METADATA_KEY_EXPLOSION_FROM_RUPTURE = "mcMMO: Rupture Explosion";
     public static final @NotNull String METADATA_KEY_FISH_HOOK_REF = "mcMMO: Fish Hook Tracker";

+ 1 - 0
src/main/resources/locale/locale_en_US.properties

@@ -182,6 +182,7 @@ Archery.SubSkill.ArcheryLimitBreak.Description=Breaking your limits. Increased d
 Archery.SubSkill.ArcheryLimitBreak.Stat=Limit Break Max DMG
 Archery.Listener=Archery:
 Archery.SkillName=ARCHERY
+Archery.SubSkill.ExplosiveShot.Name=Explosive Shot
 Archery.Skills.ExplosiveShot.Off=
 Archery.Skills.ExplosiveShot.On=&a**EXPLOSIVE SHOT ACTIVATED**
 Archery.Skills.ExplosiveShot.Other.Off=Explosive Shot&a has worn off for &e{0}