Explorar o código

Changed kraken default behavior

It will no longer broadcast chat messages globally by default, as well as strike lightning on it's target. Instead it will spawn explosion effects.
TfT_02 %!s(int64=11) %!d(string=hai) anos
pai
achega
d410251595

+ 1 - 0
Changelog.txt

@@ -52,6 +52,7 @@ Version 1.4.07-dev
  ! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
  ! Changed default XP multiplier for repairing shears
  ! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
+ ! Changed fishing exploit prevention, by default it will no longer send global sounds, effects and messages.
  ! Changed various values to double in advanced.yml for the sake of consistency.
  ! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
  ! Nerfed Archery damage to eliminate constant one-hit kills.

+ 4 - 4
src/main/java/com/gmail/nossr50/config/AdvancedConfig.java

@@ -786,15 +786,15 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
 
     /* KRAKEN STUFF */
     public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
-    public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }
-    public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
     public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
     public double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
     public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
+    public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
+    public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
+    public boolean getKrakenGlobalEffectsEnabled() { return config.getBoolean("Kraken.Global_Effects", false); }
+    public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
     public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", ""); }
     public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", ""); }
     public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", ""); }
     public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", ""); }
-    public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
-    public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
 }

+ 16 - 21
src/main/java/com/gmail/nossr50/runnables/skills/KrakenAttackTask.java

@@ -14,7 +14,7 @@ public class KrakenAttackTask extends BukkitRunnable {
     private Creature kraken;
     private Player player;
     private Location location;
-    private final boolean GLOBAL_SOUNDS = AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled();
+    private final boolean GLOBAL_EFFECTS = AdvancedConfig.getInstance().getKrakenGlobalEffectsEnabled();
     private final String DEFEAT_MESSAGE = AdvancedConfig.getInstance().getPlayerDefeatMessage();
     private final String ESCAPE_MESSAGE = AdvancedConfig.getInstance().getPlayerEscapeMessage();
 
@@ -37,16 +37,7 @@ public class KrakenAttackTask extends BukkitRunnable {
             if (player.isValid() && playerLocation.getBlock().isLiquid()) {
                 World world = player.getWorld();
 
-                player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
-
-                if (GLOBAL_SOUNDS) {
-                    world.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
-                }
-                else {
-                    player.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
-                }
-
-                world.strikeLightningEffect(playerLocation);
+                krakenAttack(playerLocation, world);
             }
             else {
                 player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
@@ -83,20 +74,24 @@ public class KrakenAttackTask extends BukkitRunnable {
             World world = player.getWorld();
 
             kraken.teleport(player);
-            player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
-
-            if (GLOBAL_SOUNDS) {
-                world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
-            }
-            else {
-                player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
-            }
-
-            world.strikeLightningEffect(location);
+            krakenAttack(location, world);
         }
         else {
             kraken.remove();
             cancel();
         }
     }
+
+    private void krakenAttack(Location playerLocation, World world) {
+        player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
+
+        if (GLOBAL_EFFECTS) {
+            world.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
+            world.strikeLightningEffect(playerLocation);
+        }
+        else {
+            player.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
+            world.createExplosion(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), 0F, false, false);
+        }
+    }
 }

+ 13 - 13
src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java

@@ -103,29 +103,29 @@ public class FishingManager extends SkillManager {
 
         player.teleport(player.getTargetBlock(null, 100).getLocation(), TeleportCause.PLUGIN);
 
-        Location location = player.getLocation();
-
-        world.strikeLightningEffect(location);
-        world.strikeLightningEffect(location);
-        world.strikeLightningEffect(location);
-
         String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage();
 
         if (!unleashMessage.isEmpty()) {
             player.sendMessage(unleashMessage);
         }
 
-        if (AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled()) {
+        Location location = player.getLocation();
+        boolean globalEffectsEnabled = AdvancedConfig.getInstance().getKrakenGlobalEffectsEnabled();
+
+        if (globalEffectsEnabled) {
+            world.strikeLightningEffect(location);
+            world.strikeLightningEffect(location);
+            world.strikeLightningEffect(location);
+
             world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
+            mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
         }
         else {
-            player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
-        }
+            world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
+            world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
+            world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
 
-        String globalMessage = AdvancedConfig.getInstance().getServerUnleashMessage();
-
-        if (!globalMessage.isEmpty()) {
-            mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
+            player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
         }
 
         if (player.getItemInHand().getType() == Material.FISHING_ROD) {

+ 2 - 2
src/main/resources/advanced.yml

@@ -499,11 +499,11 @@ Kraken:
     Name: The Kraken
     Attack_Interval_Seconds: 1
     Attack_Damage: 1.0
-    Global_Sounds: true
+    Global_Effects: false
     Allow_Escaping: false
     Unleashed_Message:
         Server: (PLAYER) has unleashed the kraken!
         Player: THE KRAKEN HAS BEEN UNLEASHED!
     Defeated_Message:
         Escape: You have escaped from the kraken!
-        Killed: You have slain the kraken!
+        Killed: You have slain the kraken!