It's now possible to run away from the Kraken.

This commit is contained in:
GJ 2013-05-03 15:49:29 -04:00
parent 7ed218ee7f
commit b07cf6bdde
4 changed files with 68 additions and 7 deletions

View File

@ -289,6 +289,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); } public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", "(PLAYER) has unleashed the kraken!"); } public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", "(PLAYER) has unleashed the kraken!"); }
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", "THE KRAKEN HAS BEEN UNLEASHED!"); } public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", "THE KRAKEN HAS BEEN UNLEASHED!"); }
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", "You have slain the kraken!"); }
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", "You have escaped from the kraken!"); }
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); } public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
public int getKrakenAttackDamage() { return config.getInt("Kraken.Attack_Damage", 1); } public int getKrakenAttackDamage() { return config.getInt("Kraken.Attack_Damage", 1); }
} }

View File

@ -13,6 +13,7 @@ import com.gmail.nossr50.util.Misc;
public class KrakenAttackTask extends BukkitRunnable { public class KrakenAttackTask extends BukkitRunnable {
private Squid kraken; private Squid kraken;
private Player player; private Player player;
private Location location;
private final boolean GLOBAL_SOUNDS = AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled(); private final boolean GLOBAL_SOUNDS = AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled();
public KrakenAttackTask(Squid kraken, Player player) { public KrakenAttackTask(Squid kraken, Player player) {
@ -20,15 +21,57 @@ public class KrakenAttackTask extends BukkitRunnable {
this.player = player; this.player = player;
} }
public KrakenAttackTask(Squid kraken, Player player, Location location) {
this.kraken = kraken;
this.player = player;
this.location = location;
}
@Override @Override
public void run() { public void run() {
if (location != null) {
Location playerLocation = player.getLocation();
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);
}
else {
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
player.resetPlayerWeather();
cancel();
}
return;
}
if (!kraken.isValid()) { if (!kraken.isValid()) {
player.sendMessage(AdvancedConfig.getInstance().getPlayerDefeatMessage());
player.resetPlayerWeather(); player.resetPlayerWeather();
this.cancel(); cancel();
} }
if (player.isValid()) { if (player.isValid()) {
Location location = player.getLocation(); Location location = player.getLocation();
if (!location.getBlock().isLiquid()) {
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
kraken.remove();
player.resetPlayerWeather();
cancel();
return;
}
World world = player.getWorld(); World world = player.getWorld();
kraken.teleport(player); kraken.teleport(player);
@ -41,12 +84,11 @@ public class KrakenAttackTask extends BukkitRunnable {
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
} }
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
world.strikeLightningEffect(location); world.strikeLightningEffect(location);
} }
else { else {
kraken.remove(); kraken.remove();
this.cancel(); cancel();
} }
} }
} }

View File

@ -5,7 +5,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -66,6 +65,10 @@ public class FishingManager extends SkillManager {
return Permissions.masterAngler(getPlayer()); return Permissions.masterAngler(getPlayer());
} }
// public boolean unleashTheKraken() {
//
// }
private boolean unleashTheKraken() { private boolean unleashTheKraken() {
if (fishingTries < AdvancedConfig.getInstance().getKrakenTriesBeforeRelease() || fishingTries <= Misc.getRandom().nextInt(200)) { if (fishingTries < AdvancedConfig.getInstance().getKrakenTriesBeforeRelease() || fishingTries <= Misc.getRandom().nextInt(200)) {
return false; return false;
@ -102,14 +105,25 @@ public class FishingManager extends SkillManager {
String globalMessage = AdvancedConfig.getInstance().getServerUnleashMessage(); String globalMessage = AdvancedConfig.getInstance().getServerUnleashMessage();
if (!globalMessage.isEmpty()) { if (!globalMessage.isEmpty()) {
mcMMO.p.getServer().broadcastMessage(AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName() + ChatColor.RED)); mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
} }
player.setItemInHand(null);
Squid kraken = (Squid) world.spawnEntity(player.getEyeLocation(), EntityType.SQUID); Squid kraken = (Squid) world.spawnEntity(player.getEyeLocation(), EntityType.SQUID);
kraken.setCustomName(AdvancedConfig.getInstance().getKrakenName()); kraken.setCustomName(AdvancedConfig.getInstance().getKrakenName());
kraken.remove();
if (!kraken.isValid()) {
int attackInterval = AdvancedConfig.getInstance().getKrakenAttackInterval() * 20;
new KrakenAttackTask(kraken, player, player.getLocation()).runTaskTimer(mcMMO.p, attackInterval, attackInterval);
fishingTries = 1;
return true;
}
kraken.setMaxHealth(AdvancedConfig.getInstance().getKrakenHealth()); kraken.setMaxHealth(AdvancedConfig.getInstance().getKrakenHealth());
kraken.setHealth(kraken.getMaxHealth()); kraken.setHealth(kraken.getMaxHealth());
player.setItemInHand(null);
int attackInterval = AdvancedConfig.getInstance().getKrakenAttackInterval() * 20; int attackInterval = AdvancedConfig.getInstance().getKrakenAttackInterval() * 20;
new KrakenAttackTask(kraken, player).runTaskTimer(mcMMO.p, attackInterval, attackInterval); new KrakenAttackTask(kraken, player).runTaskTimer(mcMMO.p, attackInterval, attackInterval);

View File

@ -426,3 +426,6 @@ Kraken:
Unleashed_Message: Unleashed_Message:
Server: (PLAYER) has unleashed the kraken! Server: (PLAYER) has unleashed the kraken!
Player: THE KRAKEN HAS BEEN UNLEASHED! Player: THE KRAKEN HAS BEEN UNLEASHED!
Defeated_Message:
Escape: You have escaped from the kraken!
Killed: You have slain the kraken!