mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 07:59:28 +00:00
Updated to new eco command system and 5.2.0
This commit is contained in:
@@ -2,7 +2,7 @@ package com.willfp.ecobosses;
|
||||
|
||||
import com.willfp.eco.core.AbstractPacketAdapter;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.command.AbstractCommand;
|
||||
import com.willfp.eco.core.command.impl.PluginCommand;
|
||||
import com.willfp.eco.core.integrations.IntegrationLoader;
|
||||
import com.willfp.ecobosses.bosses.EcoBosses;
|
||||
import com.willfp.ecobosses.bosses.listeners.AttackListeners;
|
||||
@@ -11,11 +11,8 @@ import com.willfp.ecobosses.bosses.listeners.DeathListeners;
|
||||
import com.willfp.ecobosses.bosses.listeners.PassiveListeners;
|
||||
import com.willfp.ecobosses.bosses.listeners.SpawnListeners;
|
||||
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||
import com.willfp.ecobosses.commands.CommandEbdrop;
|
||||
import com.willfp.ecobosses.commands.CommandEbkillall;
|
||||
import com.willfp.ecobosses.commands.CommandEbreload;
|
||||
import com.willfp.ecobosses.commands.CommandEbspawn;
|
||||
import com.willfp.ecobosses.commands.TabCompleterEbspawn;
|
||||
import com.willfp.ecobosses.commands.CommandEcobosses;
|
||||
import com.willfp.ecobosses.commands.CommandSpawn;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@@ -98,18 +95,10 @@ public class EcoBossesPlugin extends EcoPlugin {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* EcoEnchants-specific commands.
|
||||
*
|
||||
* @return A list of all commands.
|
||||
*/
|
||||
@Override
|
||||
public List<AbstractCommand> getCommands() {
|
||||
public List<PluginCommand> getPluginCommands() {
|
||||
return Arrays.asList(
|
||||
new CommandEbreload(this),
|
||||
new CommandEbdrop(this),
|
||||
new CommandEbspawn(this),
|
||||
new CommandEbkillall(this)
|
||||
new CommandEcobosses(this)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,7 +131,7 @@ public class EcoBossesPlugin extends EcoPlugin {
|
||||
public List<Class<?>> getUpdatableClasses() {
|
||||
return Arrays.asList(
|
||||
EcoBosses.class,
|
||||
TabCompleterEbspawn.class
|
||||
CommandSpawn.class
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,19 @@ import com.willfp.ecobosses.bosses.effects.Effect;
|
||||
import com.willfp.ecobosses.bosses.effects.Effects;
|
||||
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
||||
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
||||
import com.willfp.ecobosses.bosses.util.obj.*;
|
||||
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties;
|
||||
import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions;
|
||||
import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions;
|
||||
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||
import com.willfp.ecobosses.bosses.util.obj.SpawnTotem;
|
||||
import com.willfp.ecobosses.bosses.util.obj.TargetMode;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
@@ -23,7 +32,14 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EcoBoss extends PluginDependent {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
public class CommandBase64 extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebdrop.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandBase64(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "base64", "ecobosses.command.base64", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
Player player = (Player) sender;
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
String key = "drop-key";
|
||||
YamlConfiguration jank = new YamlConfiguration();
|
||||
jank.set(key, itemStack);
|
||||
String configString = jank.saveToString();
|
||||
String dropString = Base64.getEncoder().encodeToString(configString.getBytes());
|
||||
|
||||
Bukkit.getLogger().info("Copy this into the drops section of your boss yml!");
|
||||
Bukkit.getLogger().info("\n" + dropString);
|
||||
|
||||
player.sendMessage(this.getPlugin().getLangYml().getMessage("sent-drop"));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.AbstractCommand;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandEbdrop extends AbstractCommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebdrop.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandEbdrop(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "ebdrop", "ecobosses.ebdrop", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull final CommandSender sender,
|
||||
@NotNull final List<String> args) {
|
||||
Player player = (Player) sender;
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
String key = "drop-key";
|
||||
YamlConfiguration jank = new YamlConfiguration();
|
||||
jank.set(key, itemStack);
|
||||
String configString = jank.saveToString();
|
||||
String dropString = Base64.getEncoder().encodeToString(configString.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
Bukkit.getLogger().info("Copy this into the drops section of your boss yml!");
|
||||
Bukkit.getLogger().info("\n" + dropString);
|
||||
|
||||
player.sendMessage(this.getPlugin().getLangYml().getMessage("sent-drop"));
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.AbstractCommand;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandEbkillall extends AbstractCommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebspawn.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandEbkillall(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "ebkillall", "ecobosses.killall", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull final CommandSender sender,
|
||||
@NotNull final List<String> args) {
|
||||
boolean force = false;
|
||||
if (args.size() == 1) {
|
||||
force = args.get(0).equalsIgnoreCase("force");
|
||||
}
|
||||
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(BossUtils.killAllBosses(force))));
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.AbstractCommand;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandEbreload extends AbstractCommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebreload.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandEbreload(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "ebreload", "ecobosses.reload", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull final CommandSender sender,
|
||||
@NotNull final List<String> args) {
|
||||
this.getPlugin().reload();
|
||||
this.getPlugin().reload();
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded"));
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.AbstractCommand;
|
||||
import com.willfp.eco.core.command.AbstractTabCompleter;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||
import com.willfp.ecobosses.bosses.EcoBosses;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandEbspawn extends AbstractCommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebspawn.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandEbspawn(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "ebspawn", "ecobosses.ebspawn", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AbstractTabCompleter getTab() {
|
||||
return new TabCompleterEbspawn(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull final CommandSender sender,
|
||||
@NotNull final List<String> args) {
|
||||
if (args.isEmpty()) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
|
||||
return;
|
||||
}
|
||||
|
||||
String bossName = args.get(0);
|
||||
|
||||
EcoBoss boss = EcoBosses.getByName(bossName.toLowerCase());
|
||||
|
||||
if (boss == null) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = null;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
location = ((Player) sender).getLocation();
|
||||
}
|
||||
|
||||
if (args.size() >= 4) {
|
||||
String xString = args.get(1);
|
||||
String yString = args.get(2);
|
||||
String zString = args.get(3);
|
||||
|
||||
double xPos;
|
||||
double yPos;
|
||||
double zPos;
|
||||
|
||||
if (xString.startsWith("~") && sender instanceof Player) {
|
||||
String xDiff = xString.replace("~", "");
|
||||
String yDiff = yString.replace("~", "");
|
||||
String zDiff = zString.replace("~", "");
|
||||
|
||||
if (xDiff.isEmpty()) {
|
||||
xPos = ((Player) sender).getLocation().getX();
|
||||
} else {
|
||||
try {
|
||||
xPos = ((Player) sender).getLocation().getX() + Double.parseDouble(xDiff);
|
||||
} catch (NumberFormatException e) {
|
||||
xPos = ((Player) sender).getLocation().getX();
|
||||
}
|
||||
}
|
||||
|
||||
if (yDiff.isEmpty()) {
|
||||
yPos = ((Player) sender).getLocation().getY();
|
||||
} else {
|
||||
try {
|
||||
yPos = ((Player) sender).getLocation().getY() + Double.parseDouble(yDiff);
|
||||
} catch (NumberFormatException e) {
|
||||
yPos = ((Player) sender).getLocation().getY();
|
||||
}
|
||||
}
|
||||
|
||||
if (zDiff.isEmpty()) {
|
||||
zPos = ((Player) sender).getLocation().getZ();
|
||||
} else {
|
||||
try {
|
||||
zPos = ((Player) sender).getLocation().getZ() + Double.parseDouble(yDiff);
|
||||
} catch (NumberFormatException e) {
|
||||
zPos = ((Player) sender).getLocation().getZ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
xPos = Double.parseDouble(xString);
|
||||
yPos = Double.parseDouble(yString);
|
||||
zPos = Double.parseDouble(zString);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
location = new Location(null, xPos, yPos, zPos);
|
||||
}
|
||||
|
||||
World world = null;
|
||||
if (sender instanceof Player) {
|
||||
world = ((Player) sender).getWorld();
|
||||
}
|
||||
|
||||
if (args.size() >= 5) {
|
||||
world = Bukkit.getWorld(args.get(4));
|
||||
}
|
||||
|
||||
if (location == null) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
|
||||
return;
|
||||
}
|
||||
|
||||
location.setWorld(world);
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-world"));
|
||||
return;
|
||||
}
|
||||
|
||||
boss.spawn(location);
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("spawned"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.PluginCommand;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandEcobosses extends PluginCommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebdrop.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandEcobosses(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "ecobosses", "ecobosses.command.ecobosses", true);
|
||||
this.addSubcommand(new CommandReload(plugin))
|
||||
.addSubcommand(new CommandKillall(plugin))
|
||||
.addSubcommand(new CommandSpawn(plugin))
|
||||
.addSubcommand(new CommandBase64(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-command"));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandKillall extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebspawn.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandKillall(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "killall", "ecobosses.command.killall", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
boolean force = false;
|
||||
if (args.size() == 1) {
|
||||
force = args.get(0).equalsIgnoreCase("force");
|
||||
}
|
||||
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(BossUtils.killAllBosses(force))));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandReload extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new executor for /ebreload.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandReload(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "reload", "ecobosses.command.reload", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
this.getPlugin().reload();
|
||||
this.getPlugin().reload();
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded"));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.TabCompleteHandler;
|
||||
import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.eco.core.config.ConfigUpdater;
|
||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||
import com.willfp.ecobosses.bosses.EcoBosses;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandSpawn extends Subcommand {
|
||||
/**
|
||||
* The cached names.
|
||||
*/
|
||||
private static final List<String> BOSS_NAMES = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The cached numbers.
|
||||
*/
|
||||
private static final List<String> TILDE = Arrays.asList(
|
||||
"~"
|
||||
);
|
||||
|
||||
/**
|
||||
* Instantiate a new executor for /ebspawn.
|
||||
*
|
||||
* @param plugin The plugin to manage the execution for.
|
||||
*/
|
||||
public CommandSpawn(@NotNull final EcoBossesPlugin plugin) {
|
||||
super(plugin, "spawn", "ecobosses.command.spawn", false);
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on reload.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void reload() {
|
||||
BOSS_NAMES.clear();
|
||||
BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
if (args.isEmpty()) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
|
||||
return;
|
||||
}
|
||||
|
||||
String bossName = args.get(0);
|
||||
|
||||
EcoBoss boss = EcoBosses.getByName(bossName.toLowerCase());
|
||||
|
||||
if (boss == null) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = null;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
location = ((Player) sender).getLocation();
|
||||
}
|
||||
|
||||
if (args.size() >= 4) {
|
||||
String xString = args.get(1);
|
||||
String yString = args.get(2);
|
||||
String zString = args.get(3);
|
||||
|
||||
double xPos;
|
||||
double yPos;
|
||||
double zPos;
|
||||
|
||||
if (xString.startsWith("~") && sender instanceof Player) {
|
||||
String xDiff = xString.replace("~", "");
|
||||
String yDiff = yString.replace("~", "");
|
||||
String zDiff = zString.replace("~", "");
|
||||
|
||||
if (xDiff.isEmpty()) {
|
||||
xPos = ((Player) sender).getLocation().getX();
|
||||
} else {
|
||||
try {
|
||||
xPos = ((Player) sender).getLocation().getX() + Double.parseDouble(xDiff);
|
||||
} catch (NumberFormatException e) {
|
||||
xPos = ((Player) sender).getLocation().getX();
|
||||
}
|
||||
}
|
||||
|
||||
if (yDiff.isEmpty()) {
|
||||
yPos = ((Player) sender).getLocation().getY();
|
||||
} else {
|
||||
try {
|
||||
yPos = ((Player) sender).getLocation().getY() + Double.parseDouble(yDiff);
|
||||
} catch (NumberFormatException e) {
|
||||
yPos = ((Player) sender).getLocation().getY();
|
||||
}
|
||||
}
|
||||
|
||||
if (zDiff.isEmpty()) {
|
||||
zPos = ((Player) sender).getLocation().getZ();
|
||||
} else {
|
||||
try {
|
||||
zPos = ((Player) sender).getLocation().getZ() + Double.parseDouble(yDiff);
|
||||
} catch (NumberFormatException e) {
|
||||
zPos = ((Player) sender).getLocation().getZ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
xPos = Double.parseDouble(xString);
|
||||
yPos = Double.parseDouble(yString);
|
||||
zPos = Double.parseDouble(zString);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
location = new Location(null, xPos, yPos, zPos);
|
||||
}
|
||||
|
||||
World world = null;
|
||||
if (sender instanceof Player) {
|
||||
world = ((Player) sender).getWorld();
|
||||
}
|
||||
|
||||
if (args.size() >= 5) {
|
||||
world = Bukkit.getWorld(args.get(4));
|
||||
}
|
||||
|
||||
if (location == null) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
|
||||
return;
|
||||
}
|
||||
|
||||
location.setWorld(world);
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-world"));
|
||||
return;
|
||||
}
|
||||
|
||||
boss.spawn(location);
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("spawned"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabCompleteHandler getTabCompleter() {
|
||||
return (sender, args) -> {
|
||||
|
||||
List<String> completions = new ArrayList<>();
|
||||
|
||||
if (args.isEmpty()) {
|
||||
// Currently, this case is not ever reached
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
StringUtil.copyPartialMatches(args.get(0), BOSS_NAMES, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 2) {
|
||||
StringUtil.copyPartialMatches(args.get(1), TILDE, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 3) {
|
||||
StringUtil.copyPartialMatches(args.get(2), TILDE, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 4) {
|
||||
StringUtil.copyPartialMatches(args.get(3), TILDE, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 5) {
|
||||
StringUtil.copyPartialMatches(args.get(4), Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
return new ArrayList<>(0);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.willfp.ecobosses.commands;
|
||||
|
||||
import com.willfp.eco.core.command.AbstractTabCompleter;
|
||||
import com.willfp.eco.core.config.ConfigUpdater;
|
||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||
import com.willfp.ecobosses.bosses.EcoBosses;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TabCompleterEbspawn extends AbstractTabCompleter {
|
||||
/**
|
||||
* The cached names.
|
||||
*/
|
||||
private static final List<String> BOSS_NAMES = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The cached numbers.
|
||||
*/
|
||||
private static final List<String> TILDE = Arrays.asList(
|
||||
"~"
|
||||
);
|
||||
|
||||
/**
|
||||
* Instantiate a new tab-completer for /ebspawn.
|
||||
*
|
||||
* @param command Instance of /ebspawn.
|
||||
*/
|
||||
public TabCompleterEbspawn(@NotNull final CommandEbspawn command) {
|
||||
super(command);
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on reload.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void reload() {
|
||||
BOSS_NAMES.clear();
|
||||
BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The execution of the tabcompleter.
|
||||
*
|
||||
* @param sender The sender of the command.
|
||||
* @param args The arguments of the command.
|
||||
* @return A list of tab-completions.
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTab(@NotNull final CommandSender sender,
|
||||
@NotNull final List<String> args) {
|
||||
List<String> completions = new ArrayList<>();
|
||||
|
||||
if (args.isEmpty()) {
|
||||
// Currently, this case is not ever reached
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
StringUtil.copyPartialMatches(args.get(0), BOSS_NAMES, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 2) {
|
||||
StringUtil.copyPartialMatches(args.get(1), TILDE, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 3) {
|
||||
StringUtil.copyPartialMatches(args.get(2), TILDE, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 4) {
|
||||
StringUtil.copyPartialMatches(args.get(3), TILDE, completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
if (args.size() == 5) {
|
||||
StringUtil.copyPartialMatches(args.get(4), Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), completions);
|
||||
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ rewards:
|
||||
# Use %player% as the placeholder for the player name
|
||||
commands: []
|
||||
|
||||
# Get items to add here by copying the console output for /ebdrop
|
||||
# Get items to add here by copying the console output for /ecobosses base64
|
||||
# To set the chance for a drop, put <chance>::<base64>
|
||||
drops: []
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ rewards:
|
||||
# Use %player% as the placeholder for the player name
|
||||
commands: []
|
||||
|
||||
# Get items to add here by copying the console output for /ebdrop
|
||||
# Get items to add here by copying the console output for /ecobosses base64
|
||||
# To set the chance for a drop, put <chance>::<base64>
|
||||
drops: []
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ rewards:
|
||||
# Use %player% as the placeholder for the player name
|
||||
commands: []
|
||||
|
||||
# Get items to add here by copying the console output for /ebdrop
|
||||
# Get items to add here by copying the console output for /ecobosses base64
|
||||
# To set the chance for a drop, put <chance>::<base64>
|
||||
drops: []
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ rewards:
|
||||
# Use %player% as the placeholder for the player name
|
||||
commands: []
|
||||
|
||||
# Get items to add here by copying the console output for /ebdrop
|
||||
# Get items to add here by copying the console output for /ecobosses base64
|
||||
# To set the chance for a drop, put <chance>::<base64>
|
||||
drops: []
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
messages:
|
||||
prefix: "&9&lEcoBosses &f» "
|
||||
no-permission: "&cYou don't have permission to do this!"
|
||||
invalid-command: "&cUnknown subcommand!"
|
||||
not-player: "&cThis command must be run by a player"
|
||||
reloaded: "Reloaded!"
|
||||
sent-drop: "Check console for the drop!"
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 5.1.4
|
||||
version = 5.2.0
|
||||
plugin-name = EcoBosses
|
||||
Reference in New Issue
Block a user