Command Handler
This commit is contained in:
parent
8b17d36069
commit
21975d62b1
15 changed files with 262 additions and 149 deletions
|
@ -44,21 +44,8 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
public SideBarManager getSideBarManager() { return sideBarManager; }
|
public SideBarManager getSideBarManager() { return sideBarManager; }
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Plugin startup logic
|
new VanishCommand();new TestCommand();new GunCommand();new AnvilCommand();new ArmorCommand();new MenuCommand();new RankCommand(this);
|
||||||
System.out.println("PREPARING TO DESTROY HYPIXEL");
|
new MessageCommand();new HologramCommand();new CraftCommand();new EnchantingCommand();
|
||||||
|
|
||||||
getCommand("test").setExecutor(new TestCommand());
|
|
||||||
getCommand("vanish").setExecutor(new VanishCommand());
|
|
||||||
getCommand("armor").setExecutor(new ArmorCommand());
|
|
||||||
getCommand("armor").setTabCompleter(new ArmorTab());
|
|
||||||
getCommand("gun").setExecutor(new GunCommand());
|
|
||||||
getCommand("msg").setExecutor(new MessageCommand());
|
|
||||||
getCommand("menu").setExecutor(new MenuCommand());
|
|
||||||
getCommand("rank").setExecutor(new RankCommand(this));
|
|
||||||
getCommand("hologram").setExecutor(new HologramCommand());
|
|
||||||
getCommand("craft").setExecutor(new CraftCommand());
|
|
||||||
getCommand("anvil").setExecutor(new AnvilCommand());
|
|
||||||
getCommand("enchant").setExecutor(new EnchantingCommand());
|
|
||||||
bossbar = Bukkit.createBossBar(
|
bossbar = Bukkit.createBossBar(
|
||||||
ChatColor.GOLD + "Kuudra",
|
ChatColor.GOLD + "Kuudra",
|
||||||
BarColor.RED,
|
BarColor.RED,
|
||||||
|
@ -105,7 +92,7 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
e.setJoinMessage(rankManager.getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!");
|
e.setJoinMessage(rankManager.getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!");
|
||||||
|
|
||||||
e.getPlayer().sendTitle(ChatColor.RED +"Welcome to Operation Valkyrie!", ChatColor.GREEN + "LOL", 20, 100, 20);
|
e.getPlayer().sendTitle(ChatColor.RED +"Welcome to Apache!", ChatColor.GREEN + "LOL", 20, 100, 20);
|
||||||
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER"));
|
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER"));
|
||||||
|
|
||||||
bossbar.addPlayer(e.getPlayer());
|
bossbar.addPlayer(e.getPlayer());
|
||||||
|
@ -127,8 +114,8 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPing(ServerListPingEvent e) {
|
public void onPing(ServerListPingEvent e) {
|
||||||
e.setMaxPlayers(8964);
|
e.setMaxPlayers(8964);
|
||||||
String s = centerText("Operation Valkyrie\n", 45);
|
String s = centerText("Apache\n", 45);
|
||||||
String s2 = centerText("Support 1.18 & 1.8.9",45);
|
String s2 = centerText("Support 1.18 & 1.8.9",15);
|
||||||
e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + ChatColor.GOLD + ChatColor.BOLD + s2);
|
e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + ChatColor.GOLD + ChatColor.BOLD + s2);
|
||||||
try {
|
try {
|
||||||
e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png")));
|
e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png")));
|
||||||
|
|
|
@ -1,21 +1,33 @@
|
||||||
package com.night.nullvalkyrie.commands;
|
package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
|
||||||
public class AnvilCommand implements CommandExecutor {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AnvilCommand extends Command {
|
||||||
|
|
||||||
|
public AnvilCommand() {
|
||||||
|
super(
|
||||||
|
"anvil",
|
||||||
|
new String[]{"av"},
|
||||||
|
"Open anvil",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.openInventory(Bukkit.createInventory(player, InventoryType.ANVIL));
|
player.openInventory(Bukkit.createInventory(player, InventoryType.ANVIL));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
return false;
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,17 +2,29 @@ package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
public class ArmorCommand implements CommandExecutor {
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ArmorCommand extends Command {
|
||||||
|
|
||||||
|
public ArmorCommand() {
|
||||||
|
super(
|
||||||
|
"armor",
|
||||||
|
new String[]{},
|
||||||
|
"Give you a set of armor",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
|
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
|
||||||
|
@ -47,8 +59,19 @@ public class ArmorCommand implements CommandExecutor {
|
||||||
boot.setItemMeta(legdata);
|
boot.setItemMeta(legdata);
|
||||||
player.getInventory().addItem(boot);
|
player.getInventory().addItem(boot);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
return false;
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
if(args.length == 1) {
|
||||||
|
return StringUtil.copyPartialMatches(args[0], Arrays.asList("angeles", "widow"), new ArrayList<>());
|
||||||
|
} else if(args.length == 2) {
|
||||||
|
List<String> names = new ArrayList<>();
|
||||||
|
for(Player player: Bukkit.getOnlinePlayers()) {
|
||||||
|
names.add(player.getName());
|
||||||
|
}
|
||||||
|
return StringUtil.copyPartialMatches(args[1], names, new ArrayList<>());
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
|
|
||||||
package com.night.nullvalkyrie.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ArmorTab implements TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if(args.length == 1) {
|
|
||||||
return StringUtil.copyPartialMatches(args[0], Arrays.asList("angeles", "widow"), new ArrayList<>());
|
|
||||||
} else if(args.length == 2) {
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
for(Player player: Bukkit.getOnlinePlayers()) {
|
|
||||||
names.add(player.getName());
|
|
||||||
}
|
|
||||||
return StringUtil.copyPartialMatches(args[1], names, new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
46
src/main/java/com/night/nullvalkyrie/commands/Command.java
Normal file
46
src/main/java/com/night/nullvalkyrie/commands/Command.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.defaults.BukkitCommand;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class Command extends BukkitCommand {
|
||||||
|
|
||||||
|
public Command(String command, String[] aliases, String description, String permission) {
|
||||||
|
super(command);
|
||||||
|
this.setAliases(Arrays.asList(aliases));
|
||||||
|
this.setDescription(description);
|
||||||
|
this.setPermission(permission);
|
||||||
|
this.setPermission(ChatColor.RED + "You must have" + permission + "in order to use this command");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Field field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||||
|
field.setAccessible(true);
|
||||||
|
CommandMap map = (CommandMap) field.get(Bukkit.getServer());
|
||||||
|
map.register(command, this);
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||||
|
onCommand(sender, args);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||||
|
return onTabComplete(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onCommand(CommandSender sender, String[] args);
|
||||||
|
public abstract List<String> onTabComplete(CommandSender sender, String[] args);
|
||||||
|
}
|
|
@ -1,19 +1,32 @@
|
||||||
package com.night.nullvalkyrie.commands;
|
package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CraftCommand implements CommandExecutor {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CraftCommand extends Command {
|
||||||
|
|
||||||
|
public CraftCommand() {
|
||||||
|
super(
|
||||||
|
"craft",
|
||||||
|
new String[]{"ct", "crafting", "craftingtable"},
|
||||||
|
"Open crafting table",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.openWorkbench(null, true);
|
player.openWorkbench(null, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
return false;
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,30 @@
|
||||||
package com.night.nullvalkyrie.commands;
|
package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import java.util.List;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
public class EnchantingCommand extends Command {
|
||||||
|
public EnchantingCommand() {
|
||||||
|
super(
|
||||||
|
"enchant",
|
||||||
|
new String[]{"et", "enchanting", "enchantingtable"},
|
||||||
|
"Open enchanting table",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public class EnchantingCommand implements CommandExecutor {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.openEnchanting(null, true);
|
player.openEnchanting(null, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
return false;
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,19 +2,29 @@ package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GunCommand extends Command {
|
||||||
|
|
||||||
|
public GunCommand() {
|
||||||
|
super(
|
||||||
|
"gun",
|
||||||
|
new String[]{},
|
||||||
|
"Give you a gun",
|
||||||
|
""
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class GunCommand implements CommandExecutor {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
ItemStack hoe = new ItemStack(Material.DIAMOND_HOE);
|
ItemStack hoe = new ItemStack(Material.DIAMOND_HOE);
|
||||||
ItemMeta hoedata = hoe.getItemMeta();
|
ItemMeta hoedata = hoe.getItemMeta();
|
||||||
|
@ -23,6 +33,10 @@ public class GunCommand implements CommandExecutor {
|
||||||
hoedata.setLore(Arrays.asList(ChatColor.GOLD + "Shoot Snowball!"));
|
hoedata.setLore(Arrays.asList(ChatColor.GOLD + "Shoot Snowball!"));
|
||||||
hoe.setItemMeta(hoedata);
|
hoe.setItemMeta(hoedata);
|
||||||
player.getInventory().addItem(hoe);
|
player.getInventory().addItem(hoe);
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,24 @@ package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class HologramCommand implements CommandExecutor {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HologramCommand extends Command {
|
||||||
|
public HologramCommand() {
|
||||||
|
super(
|
||||||
|
"hologram",
|
||||||
|
new String[]{},
|
||||||
|
"Spawn a hologram",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String[] ar = new String[]{
|
String[] ar = new String[]{
|
||||||
|
@ -30,7 +38,10 @@ public class HologramCommand implements CommandExecutor {
|
||||||
stand.setCustomName(line);
|
stand.setCustomName(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ package com.night.nullvalkyrie.commands;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
@ -12,12 +10,22 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MenuCommand implements CommandExecutor {
|
public class MenuCommand extends Command {
|
||||||
public static Inventory inv = Bukkit.createInventory(null, 45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
|
public static Inventory inv = Bukkit.createInventory(null, 45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
|
|
||||||
|
public MenuCommand() {
|
||||||
|
super(
|
||||||
|
"menu",
|
||||||
|
new String[]{"m"},
|
||||||
|
"Open the menu",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
inv = Bukkit.createInventory(player,45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
|
inv = Bukkit.createInventory(player,45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
|
||||||
|
@ -58,6 +66,10 @@ public class MenuCommand implements CommandExecutor {
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,23 @@ package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class MessageCommand implements CommandExecutor {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MessageCommand extends Command {
|
||||||
|
public MessageCommand() {
|
||||||
|
super(
|
||||||
|
"message",
|
||||||
|
new String[]{"msg"},
|
||||||
|
"Send message to someone",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
|
@ -29,7 +37,10 @@ public class MessageCommand implements CommandExecutor {
|
||||||
player.sendMessage(ChatColor.RED + "Invalid parameter, use /msg <Player> <Message>");
|
player.sendMessage(ChatColor.RED + "Invalid parameter, use /msg <Player> <Message>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,26 +7,34 @@ import com.night.nullvalkyrie.RankSys.Rank;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
//92.0.69.141:25565
|
//92.0.69.141:25565
|
||||||
public class RankCommand implements CommandExecutor {
|
public class RankCommand extends Command {
|
||||||
private Main main;
|
private Main main;
|
||||||
public RankCommand(Main main) {
|
public RankCommand(Main main) {
|
||||||
|
super(
|
||||||
|
"rank",
|
||||||
|
new String[]{},
|
||||||
|
"Set rank of players",
|
||||||
|
""
|
||||||
|
);
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
private Cache<UUID, Long> cooldown = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS).build();
|
private Cache<UUID, Long> cooldown = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS).build();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if(!cooldown.asMap().containsKey(player.getUniqueId())) {if(player.isOp()) {
|
if(!cooldown.asMap().containsKey(player.getUniqueId())) {
|
||||||
|
if(player.isOp()) {
|
||||||
if(args.length == 2) {
|
if(args.length == 2) {
|
||||||
if(Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
|
if(Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
|
||||||
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
|
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
|
||||||
|
@ -37,8 +45,9 @@ public class RankCommand implements CommandExecutor {
|
||||||
if(target.isOnline()) {
|
if(target.isOnline()) {
|
||||||
target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay());
|
target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay());
|
||||||
}
|
}
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
|
player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,12 +59,16 @@ public class RankCommand implements CommandExecutor {
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
|
player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
|
||||||
}
|
}
|
||||||
cooldown.put(player.getUniqueId(), System.currentTimeMillis() + 5000);
|
cooldown.put(player.getUniqueId(), System.currentTimeMillis() + 5000);
|
||||||
} else {
|
} else {
|
||||||
long distance = cooldown.asMap().get(player.getUniqueId()) - System.currentTimeMillis();
|
long distance = cooldown.asMap().get(player.getUniqueId()) - System.currentTimeMillis();
|
||||||
player.sendMessage(ChatColor.RED + "You are on a " + TimeUnit.MILLISECONDS.toSeconds(distance) + " seconds cooldown to use the command again");
|
player.sendMessage(ChatColor.RED + "You are on a " + TimeUnit.MILLISECONDS.toSeconds(distance) + " seconds cooldown to use the command again");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,34 @@
|
||||||
package com.night.nullvalkyrie.commands;
|
package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TestCommand implements CommandExecutor {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TestCommand extends Command {
|
||||||
|
public TestCommand() {
|
||||||
|
super(
|
||||||
|
"test",
|
||||||
|
new String[]{},
|
||||||
|
"Test",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
if(args[0].equalsIgnoreCase("hello")) {
|
if(args[0].equalsIgnoreCase("hello")) {
|
||||||
Player player = ((Player) sender);
|
Player player = (Player) sender;
|
||||||
Command.broadcastCommandMessage(player,player.getAddress().getHostString());
|
player.sendMessage(player.getAddress().getHostString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -11,10 +9,18 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class VanishCommand implements CommandExecutor {
|
public class VanishCommand extends Command {
|
||||||
private List<UUID> vanished = new ArrayList<>();
|
private List<UUID> vanished = new ArrayList<>();
|
||||||
|
public VanishCommand() {
|
||||||
|
super(
|
||||||
|
"vanish",
|
||||||
|
new String[]{},
|
||||||
|
"Turn yourself into invisible",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
if(vanished.contains(player.getUniqueId())) {
|
if(vanished.contains(player.getUniqueId())) {
|
||||||
|
@ -31,8 +37,10 @@ public class VanishCommand implements CommandExecutor {
|
||||||
player.sendMessage(ChatColor.GREEN + "You are now vanished");
|
player.sendMessage(ChatColor.GREEN + "You are now vanished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
return false;
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,30 +4,4 @@ main: com.night.nullvalkyrie.Main
|
||||||
api-version: 1.18
|
api-version: 1.18
|
||||||
authors: [ NightKaly, Leocthl ]
|
authors: [ NightKaly, Leocthl ]
|
||||||
description: Null Valkyrie
|
description: Null Valkyrie
|
||||||
website: https://github.com/night0721/nullvalkyrie
|
website: https://github.com/night0721/nullvalkyrie
|
||||||
commands:
|
|
||||||
test:
|
|
||||||
description: "Test"
|
|
||||||
vanish:
|
|
||||||
description: "Turn yourself into invisible"
|
|
||||||
armor:
|
|
||||||
description: "Give you a set of armor"
|
|
||||||
gun:
|
|
||||||
description: "Give you a gun"
|
|
||||||
msg:
|
|
||||||
description: "Send message to someone"
|
|
||||||
menu:
|
|
||||||
description: "Open the menu"
|
|
||||||
rank:
|
|
||||||
description: "Set rank of players"
|
|
||||||
hologram:
|
|
||||||
description: "Spawn a hologram"
|
|
||||||
craft:
|
|
||||||
aliases: ["ct", "crafting", "craftingtable"]
|
|
||||||
description: "Open crafting table"
|
|
||||||
anvil:
|
|
||||||
aliases: [ "av", "anvil" ]
|
|
||||||
description: "Open anvil"
|
|
||||||
enchant:
|
|
||||||
aliases: [ "et", "enchanting", "enchantingtable"]
|
|
||||||
description: "Open enchanting table"
|
|
Loading…
Reference in a new issue