mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 00:45:27 +01:00
Summon the kraken at will!
This commit is contained in:
parent
b07cf6bdde
commit
8e0a1f4f70
65
src/main/java/com/gmail/nossr50/commands/KrakenCommand.java
Normal file
65
src/main/java/com/gmail/nossr50/commands/KrakenCommand.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
public class KrakenCommand implements TabExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.kraken(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserManager.getPlayer(sender.getName()).getFishingManager().unleashTheKraken();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (!Permissions.krakenOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getFishingManager().unleashTheKraken();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||||
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
|
default:
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -50,7 +50,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
|
|||||||
public class FishingManager extends SkillManager {
|
public class FishingManager extends SkillManager {
|
||||||
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
||||||
|
|
||||||
private int fishingTries = 1;
|
private int fishingTries = 0;
|
||||||
private long fishingTimestamp = 0L;
|
private long fishingTimestamp = 0L;
|
||||||
|
|
||||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@ -65,12 +65,12 @@ public class FishingManager extends SkillManager {
|
|||||||
return Permissions.masterAngler(getPlayer());
|
return Permissions.masterAngler(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// public boolean unleashTheKraken() {
|
public boolean unleashTheKraken() {
|
||||||
//
|
return unleashTheKraken(true);
|
||||||
// }
|
}
|
||||||
|
|
||||||
private boolean unleashTheKraken() {
|
private boolean unleashTheKraken(boolean forceSpawn) {
|
||||||
if (fishingTries < AdvancedConfig.getInstance().getKrakenTriesBeforeRelease() || fishingTries <= Misc.getRandom().nextInt(200)) {
|
if (!forceSpawn && (fishingTries < AdvancedConfig.getInstance().getKrakenTriesBeforeRelease() || fishingTries <= Misc.getRandom().nextInt(200))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,10 @@ public class FishingManager extends SkillManager {
|
|||||||
int attackInterval = AdvancedConfig.getInstance().getKrakenAttackInterval() * 20;
|
int attackInterval = AdvancedConfig.getInstance().getKrakenAttackInterval() * 20;
|
||||||
new KrakenAttackTask(kraken, player, player.getLocation()).runTaskTimer(mcMMO.p, attackInterval, attackInterval);
|
new KrakenAttackTask(kraken, player, player.getLocation()).runTaskTimer(mcMMO.p, attackInterval, attackInterval);
|
||||||
|
|
||||||
fishingTries = 1;
|
if (!forceSpawn) {
|
||||||
|
fishingTries = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +131,10 @@ public class FishingManager extends SkillManager {
|
|||||||
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);
|
||||||
|
|
||||||
fishingTries = 1;
|
if (!forceSpawn) {
|
||||||
|
fishingTries = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,9 +146,9 @@ public class FishingManager extends SkillManager {
|
|||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
boolean hasFished = currentTime < fishingTimestamp + FISHING_COOLDOWN_SECONDS;
|
boolean hasFished = currentTime < fishingTimestamp + FISHING_COOLDOWN_SECONDS;
|
||||||
|
|
||||||
fishingTries = hasFished ? fishingTries + 1 : fishingTries - 1;
|
fishingTries = hasFished ? fishingTries + 1 : Math.max(fishingTries - 1, 0);
|
||||||
fishingTimestamp = currentTime;
|
fishingTimestamp = currentTime;
|
||||||
return unleashTheKraken();
|
return unleashTheKraken(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canIceFish(Block block) {
|
public boolean canIceFish(Block block) {
|
||||||
|
@ -49,6 +49,9 @@ public final class Permissions {
|
|||||||
public static boolean inspectFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.far")); }
|
public static boolean inspectFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.far")); }
|
||||||
public static boolean inspectOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.offline")); }
|
public static boolean inspectOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.offline")); }
|
||||||
|
|
||||||
|
public static boolean kraken(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.kraken"); }
|
||||||
|
public static boolean krakenOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.kraken.others"); }
|
||||||
|
|
||||||
public static boolean mcability(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability")); }
|
public static boolean mcability(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability")); }
|
||||||
public static boolean mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); }
|
public static boolean mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); }
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.commands.KrakenCommand;
|
||||||
import com.gmail.nossr50.commands.McabilityCommand;
|
import com.gmail.nossr50.commands.McabilityCommand;
|
||||||
import com.gmail.nossr50.commands.McgodCommand;
|
import com.gmail.nossr50.commands.McgodCommand;
|
||||||
import com.gmail.nossr50.commands.McmmoCommand;
|
import com.gmail.nossr50.commands.McmmoCommand;
|
||||||
@ -391,8 +392,18 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McscoreboardCommand());
|
command.setExecutor(new McscoreboardCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void registerKrakenCommand() {
|
||||||
|
PluginCommand command = mcMMO.p.getCommand("kraken");
|
||||||
|
command.setDescription("Unleash the kraken!"); //TODO: Localize
|
||||||
|
command.setPermission("mcmmo.commands.kraken;mcmmo.commands.kraken.others");
|
||||||
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "kraken", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||||
|
command.setExecutor(new KrakenCommand());
|
||||||
|
}
|
||||||
|
|
||||||
public static void registerCommands() {
|
public static void registerCommands() {
|
||||||
// Generic Commands
|
// Generic Commands
|
||||||
|
registerKrakenCommand();
|
||||||
registerMcabilityCommand();
|
registerMcabilityCommand();
|
||||||
registerMcgodCommand();
|
registerMcgodCommand();
|
||||||
registerMcmmoCommand();
|
registerMcmmoCommand();
|
||||||
|
@ -109,6 +109,9 @@ commands:
|
|||||||
description: Change the style of the mob healthbar
|
description: Change the style of the mob healthbar
|
||||||
mcscoreboard:
|
mcscoreboard:
|
||||||
description: Change the current mcMMO scoreboard being displayed
|
description: Change the current mcMMO scoreboard being displayed
|
||||||
|
kraken:
|
||||||
|
aliases: [mckraken]
|
||||||
|
description: Unleash the kraken!
|
||||||
permissions:
|
permissions:
|
||||||
mcmmo.*:
|
mcmmo.*:
|
||||||
default: false
|
default: false
|
||||||
@ -695,6 +698,8 @@ permissions:
|
|||||||
mcmmo.commands.hardcore.all: true
|
mcmmo.commands.hardcore.all: true
|
||||||
mcmmo.commands.inspect.far: true
|
mcmmo.commands.inspect.far: true
|
||||||
mcmmo.commands.inspect.offline: true
|
mcmmo.commands.inspect.offline: true
|
||||||
|
mcmmo.commands.kraken: true
|
||||||
|
mcmmo.commands.kraken.others: true
|
||||||
mcmmo.commands.mcability.others: true
|
mcmmo.commands.mcability.others: true
|
||||||
mcmmo.commands.mcgod: true
|
mcmmo.commands.mcgod: true
|
||||||
mcmmo.commands.mcgod.others: true
|
mcmmo.commands.mcgod.others: true
|
||||||
@ -770,6 +775,10 @@ permissions:
|
|||||||
description: Allows access to the inspect command for far players
|
description: Allows access to the inspect command for far players
|
||||||
mcmmo.commands.inspect.offline:
|
mcmmo.commands.inspect.offline:
|
||||||
description: Allows access to the inspect command for offline players
|
description: Allows access to the inspect command for offline players
|
||||||
|
mcmmo.commands.kraken:
|
||||||
|
description: Allows access to the kraken command
|
||||||
|
mcmmo.commands.kraken.others:
|
||||||
|
description: Allows access to the kraken command for other players
|
||||||
mcmmo.commands.mcability:
|
mcmmo.commands.mcability:
|
||||||
description: Allows access to the mcability command
|
description: Allows access to the mcability command
|
||||||
mcmmo.commands.mcability.others:
|
mcmmo.commands.mcability.others:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user