formatted code on commands
This commit is contained in:
parent
8b6cd099fd
commit
abbaff1d0a
13 changed files with 82 additions and 84 deletions
|
@ -1,15 +1,11 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow;
|
import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
import net.minecraft.server.network.PlayerConnection;
|
import net.minecraft.server.network.PlayerConnection;
|
||||||
import net.minecraft.world.inventory.Containers;
|
import net.minecraft.world.inventory.Containers;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
//import org.bukkit.craftbukkit.v1_18_R1.entity.CraftHumanEntity;
|
|
||||||
//import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
|
|
||||||
//import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
|
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
|
@ -25,36 +25,36 @@ public class ArmorCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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);
|
||||||
LeatherArmorMeta helmetdata = (LeatherArmorMeta) helmet.getItemMeta();
|
LeatherArmorMeta helmetdata = (LeatherArmorMeta) helmet.getItemMeta();
|
||||||
helmetdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Helmet");
|
helmetdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Helmet");
|
||||||
helmetdata.setColor(org.bukkit.Color.fromRGB(2,2,58));
|
helmetdata.setColor(org.bukkit.Color.fromRGB(2, 2, 58));
|
||||||
helmetdata.setUnbreakable(true);
|
helmetdata.setUnbreakable(true);
|
||||||
helmet.setItemMeta(helmetdata);
|
helmet.setItemMeta(helmetdata);
|
||||||
player.getInventory().addItem(helmet);
|
player.getInventory().addItem(helmet);
|
||||||
|
|
||||||
ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE);
|
ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||||
LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta();
|
LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta();
|
||||||
cpdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Chestplate");
|
cpdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Chestplate");
|
||||||
cpdata.setColor(org.bukkit.Color.fromRGB(2,2,58));
|
cpdata.setColor(org.bukkit.Color.fromRGB(2, 2, 58));
|
||||||
cpdata.setUnbreakable(true);
|
cpdata.setUnbreakable(true);
|
||||||
cp.setItemMeta(cpdata);
|
cp.setItemMeta(cpdata);
|
||||||
player.getInventory().addItem(cp);
|
player.getInventory().addItem(cp);
|
||||||
|
|
||||||
ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS);
|
ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||||
LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta();
|
LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta();
|
||||||
legdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Leggings");
|
legdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Leggings");
|
||||||
legdata.setColor(org.bukkit.Color.fromRGB(2,2,58));
|
legdata.setColor(org.bukkit.Color.fromRGB(2, 2, 58));
|
||||||
legdata.setUnbreakable(true);
|
legdata.setUnbreakable(true);
|
||||||
leg.setItemMeta(legdata);
|
leg.setItemMeta(legdata);
|
||||||
player.getInventory().addItem(leg);
|
player.getInventory().addItem(leg);
|
||||||
|
|
||||||
ItemStack boot = new ItemStack(Material.LEATHER_BOOTS);
|
ItemStack boot = new ItemStack(Material.LEATHER_BOOTS);
|
||||||
LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta();
|
LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta();
|
||||||
bootdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Boots");
|
bootdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Boots");
|
||||||
bootdata.setColor(org.bukkit.Color.fromRGB(2,2,58));
|
bootdata.setColor(org.bukkit.Color.fromRGB(2, 2, 58));
|
||||||
bootdata.setUnbreakable(true);
|
bootdata.setUnbreakable(true);
|
||||||
boot.setItemMeta(legdata);
|
boot.setItemMeta(legdata);
|
||||||
player.getInventory().addItem(boot);
|
player.getInventory().addItem(boot);
|
||||||
|
@ -63,11 +63,11 @@ public class ArmorCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
if (args.length == 1) {
|
||||||
return StringUtil.copyPartialMatches(args[0], Arrays.asList("angeles", "widow"), new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[0], Arrays.asList("angeles", "widow"), new ArrayList<>());
|
||||||
} else if(args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
for(Player player: Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
names.add(player.getName());
|
names.add(player.getName());
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(args[1], names, new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[1], names, new ArrayList<>());
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ public class CraftCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class EnchantingCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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(player.getLocation(), true);
|
player.openEnchanting(player.getLocation(), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class HologramCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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[]{
|
||||||
ChatColor.AQUA + "Hi",
|
ChatColor.AQUA + "Hi",
|
||||||
|
@ -28,8 +28,8 @@ public class HologramCommand extends Command {
|
||||||
ChatColor.GOLD + "Hello World"
|
ChatColor.GOLD + "Hello World"
|
||||||
};
|
};
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
for(String line: ar) {
|
for (String line : ar) {
|
||||||
ArmorStand stand = location.getWorld().spawn(location.subtract(0,0.3,0), ArmorStand.class, armorStand -> {
|
ArmorStand stand = location.getWorld().spawn(location.subtract(0, 0.3, 0), ArmorStand.class, armorStand -> {
|
||||||
armorStand.setVisible(false);
|
armorStand.setVisible(false);
|
||||||
});
|
});
|
||||||
stand.setGravity(false);
|
stand.setGravity(false);
|
||||||
|
|
|
@ -26,9 +26,9 @@ public class MenuCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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;
|
||||||
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");
|
||||||
|
|
||||||
ItemStack KYS = new ItemStack(Material.WOODEN_SWORD);
|
ItemStack KYS = new ItemStack(Material.WOODEN_SWORD);
|
||||||
ItemMeta KYSmeta = KYS.getItemMeta();
|
ItemMeta KYSmeta = KYS.getItemMeta();
|
||||||
|
@ -59,10 +59,9 @@ public class MenuCommand extends Command {
|
||||||
inv.setItem(0, close);
|
inv.setItem(0, close);
|
||||||
|
|
||||||
ItemStack frame = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
|
ItemStack frame = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
|
||||||
for(int i : new int[]{1,2,3,4,5,6,7,8,9,17,18,26,27,35,36,37,38,39,40,41,42,43,44}) {
|
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44}) {
|
||||||
inv.setItem(i, frame);
|
inv.setItem(i, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,14 @@ public class MessageCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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) {
|
||||||
if(Bukkit.getPlayerExact(args[0]) != null) {
|
if (Bukkit.getPlayerExact(args[0]) != null) {
|
||||||
Player target = Bukkit.getPlayerExact(args[0]);
|
Player target = Bukkit.getPlayerExact(args[0]);
|
||||||
if(!target.equals(player)) {
|
if (!target.equals(player)) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for(int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
builder.append(args[i]).append(" ");
|
builder.append(args[i]).append(" ");
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.DARK_AQUA + "TO " + ChatColor.RED + target.getName() + ChatColor.WHITE + " : " + builder);
|
player.sendMessage(ChatColor.DARK_AQUA + "TO " + ChatColor.RED + target.getName() + ChatColor.WHITE + " : " + builder);
|
||||||
|
@ -47,9 +47,9 @@ public class MessageCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
for(Player player: Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
names.add(player.getName());
|
names.add(player.getName());
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(args[0], names, new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[0], names, new ArrayList<>());
|
||||||
|
|
|
@ -13,6 +13,7 @@ import static me.night.nullvalkyrie.miners.CryptoMiner.getMiner;
|
||||||
|
|
||||||
public class MinerCommand extends Command {
|
public class MinerCommand extends Command {
|
||||||
private final Main main;
|
private final Main main;
|
||||||
|
|
||||||
public MinerCommand(Main main) {
|
public MinerCommand(Main main) {
|
||||||
super(
|
super(
|
||||||
"miner",
|
"miner",
|
||||||
|
@ -25,10 +26,10 @@ public class MinerCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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;
|
||||||
new MinerGUI(main, player);
|
new MinerGUI(main, player);
|
||||||
int seconds = Math.round((new Date().getTime() - (long) getMiner("1").get("lastclaim")) / 1000);
|
int seconds = (int) (new Date().getTime() - (long) getMiner("1").get("lastclaim")) / 1000;
|
||||||
System.out.println("Seconds" + seconds);
|
System.out.println("Seconds" + seconds);
|
||||||
generate(50, seconds);
|
generate(50, seconds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,53 +18,52 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static me.night.nullvalkyrie.rank.ScoreboardListener.rankManager;
|
import static me.night.nullvalkyrie.rank.ScoreboardListener.rankManager;
|
||||||
|
|
||||||
//92.0.69.141:25565
|
|
||||||
public class RankCommand extends Command {
|
public class RankCommand extends Command {
|
||||||
private Main main;
|
|
||||||
public RankCommand(Main main) {
|
public RankCommand() {
|
||||||
super(
|
super(
|
||||||
"rank",
|
"rank",
|
||||||
new String[]{},
|
new String[]{},
|
||||||
"Set rank of players",
|
"Set rank of players",
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
this.main = main;
|
|
||||||
}
|
}
|
||||||
private Cache<UUID, Long> cooldown = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS).build();
|
|
||||||
|
private final Cache<UUID, Long> cooldown = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS).build();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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 (!cooldown.asMap().containsKey(player.getUniqueId())) {
|
||||||
if(player.isOp()) {
|
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]);
|
||||||
for(Rank rank : Rank.values()) {
|
for (Rank rank : Rank.values()) {
|
||||||
if(rank.name().equalsIgnoreCase(args[1])) {
|
if (rank.name().equalsIgnoreCase(args[1])) {
|
||||||
rankManager.setRank(target.getUniqueId(), rank);
|
rankManager.setRank(target.getUniqueId(), rank);
|
||||||
player.sendMessage(ChatColor.GREEN + "You changed " + target.getName() + "'s rank to " + rank.getDisplay());
|
player.sendMessage(ChatColor.GREEN + "You changed " + target.getName() + "'s rank to " + rank.getDisplay());
|
||||||
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;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
|
||||||
|
} else {
|
||||||
|
player.sendMessage("This player has never played in this server before!");
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
|
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("This player has never played in this server before!");
|
player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>");
|
player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -73,15 +72,15 @@ public class RankCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
for(Player player: Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
names.add(player.getName());
|
names.add(player.getName());
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(args[0], names, new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[0], names, new ArrayList<>());
|
||||||
} else if(args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
List<String> roles = new ArrayList<>();
|
List<String> roles = new ArrayList<>();
|
||||||
for(Rank rank : Rank.values()){
|
for (Rank rank : Rank.values()) {
|
||||||
roles.add(rank.name());
|
roles.add(rank.name());
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(args[1], roles, new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[1], roles, new ArrayList<>());
|
||||||
|
|
|
@ -13,9 +13,10 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ShopCommand extends Command{
|
public class ShopCommand extends Command {
|
||||||
private FileConfiguration file;
|
private FileConfiguration file;
|
||||||
private Inventory inv;
|
private Inventory inv;
|
||||||
|
|
||||||
public ShopCommand() {
|
public ShopCommand() {
|
||||||
super("7elven",
|
super("7elven",
|
||||||
new String[]{"711", "seven", "7ven"},
|
new String[]{"711", "seven", "7ven"},
|
||||||
|
@ -24,10 +25,11 @@ public class ShopCommand extends Command{
|
||||||
);
|
);
|
||||||
file = CustomItemManager.loadConfig("miners.yml");
|
file = CustomItemManager.loadConfig("miners.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
inv = Bukkit.createInventory(null, 45, ChatColor.GREEN + "7-Eleven 24/7");
|
inv = Bukkit.createInventory(null, 45, ChatColor.GREEN + "7-Eleven 24/7");
|
||||||
for(String c : file.getKeys(false)) {
|
for (String c : file.getKeys(false)) {
|
||||||
ItemStack item = new ItemStack(Material.matchMaterial(file.getString(c + ".material")));
|
ItemStack item = new ItemStack(Material.matchMaterial(file.getString(c + ".material")));
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
itemMeta.setDisplayName(file.getString(c + ".name"));
|
itemMeta.setDisplayName(file.getString(c + ".name"));
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -15,11 +14,12 @@ public class TestCommand extends Command {
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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;
|
||||||
player.sendMessage(player.getAddress().getHostString());
|
player.sendMessage(player.getAddress().getHostString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class UtilCommand extends Command {
|
public class UtilCommand extends Command {
|
||||||
private Main main;
|
|
||||||
public UtilCommand(Main main) {
|
public UtilCommand() {
|
||||||
super(
|
super(
|
||||||
"util",
|
"util",
|
||||||
new String[]{},
|
new String[]{},
|
||||||
|
@ -24,15 +24,15 @@ public class UtilCommand extends Command {
|
||||||
""
|
""
|
||||||
|
|
||||||
);
|
);
|
||||||
this.main = main;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
List<String> b = Arrays.asList(args);
|
List<String> b = Arrays.asList(args);
|
||||||
for(String a: args) {
|
for (String a : args) {
|
||||||
if(a.equals(b.get(b.size() - 1))) {
|
if (a.equals(b.get(b.size() - 1))) {
|
||||||
s.append(a);
|
s.append(a);
|
||||||
} else {
|
} else {
|
||||||
s.append(a);
|
s.append(a);
|
||||||
|
@ -40,8 +40,8 @@ public class UtilCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ItemStack item = main.getCustomItemManager().getItem(s.toString());
|
ItemStack item = CustomItemManager.getItem(s.toString());
|
||||||
if(item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "This item doesn't exist");
|
player.sendMessage(ChatColor.RED + "This item doesn't exist");
|
||||||
|
@ -50,12 +50,12 @@ public class UtilCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> hh = CustomItemManager.getAllFilesFromDirectory("ItemData");
|
List<String> hh = CustomItemManager.getAllFilesFromDirectory("ItemData");
|
||||||
ArrayList<String> cc = new ArrayList<>();
|
ArrayList<String> cc = new ArrayList<>();
|
||||||
for(int kk = 0; kk < hh.size(); kk++) {
|
for (String s : hh) {
|
||||||
FileConfiguration c = CustomItemManager.loadConfig("ItemData\\" + hh.get(kk));
|
FileConfiguration c = CustomItemManager.loadConfig("ItemData\\" + s);
|
||||||
if(Objects.equals(c.getString("type"), "Util")) {
|
if (Objects.equals(c.getString("type"), "Util")) {
|
||||||
cc.add(c.getString("name"));
|
cc.add(c.getString("name"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,21 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class VanishCommand extends Command {
|
public class VanishCommand extends Command {
|
||||||
private final List<UUID> vanished = new ArrayList<>();
|
private final List<UUID> vanished = new ArrayList<>();
|
||||||
|
|
||||||
public VanishCommand() {
|
public VanishCommand() {
|
||||||
super(
|
super(
|
||||||
"vanish",
|
"vanish",
|
||||||
new String[]{},
|
new String[]{},
|
||||||
"Turn yourself into invisible",
|
"Turn yourself into invisible",
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, 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(vanished.contains(player.getUniqueId())) {
|
if (vanished.contains(player.getUniqueId())) {
|
||||||
vanished.remove(player.getUniqueId());
|
vanished.remove(player.getUniqueId());
|
||||||
for (Player target : Bukkit.getOnlinePlayers()) {
|
for (Player target : Bukkit.getOnlinePlayers()) {
|
||||||
target.showPlayer(player);
|
target.showPlayer(player);
|
||||||
|
@ -31,7 +33,7 @@ public class VanishCommand extends Command {
|
||||||
player.sendMessage(ChatColor.GREEN + "You are now seen by people");
|
player.sendMessage(ChatColor.GREEN + "You are now seen by people");
|
||||||
} else {
|
} else {
|
||||||
vanished.add(player.getUniqueId());
|
vanished.add(player.getUniqueId());
|
||||||
for (Player target: Bukkit.getOnlinePlayers()){
|
for (Player target : Bukkit.getOnlinePlayers()) {
|
||||||
target.hidePlayer(player);
|
target.hidePlayer(player);
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.GREEN + "You are now vanished");
|
player.sendMessage(ChatColor.GREEN + "You are now vanished");
|
||||||
|
|
Loading…
Reference in a new issue