formatted code on commands

This commit is contained in:
NK 2022-11-17 11:03:45 +00:00
parent 8b6cd099fd
commit abbaff1d0a
13 changed files with 82 additions and 84 deletions

View file

@ -1,15 +1,11 @@
package me.night.nullvalkyrie.commands;
import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.network.PlayerConnection;
import net.minecraft.world.inventory.Containers;
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.util.CraftChatMessage;
import org.bukkit.entity.Player;

View file

@ -25,12 +25,12 @@ public class ArmorCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta helmetdata = (LeatherArmorMeta) helmet.getItemMeta();
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);
helmet.setItemMeta(helmetdata);
player.getInventory().addItem(helmet);
@ -38,7 +38,7 @@ public class ArmorCommand extends Command {
ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta();
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);
cp.setItemMeta(cpdata);
player.getInventory().addItem(cp);
@ -46,7 +46,7 @@ public class ArmorCommand extends Command {
ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta();
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);
leg.setItemMeta(legdata);
player.getInventory().addItem(leg);
@ -54,7 +54,7 @@ public class ArmorCommand extends Command {
ItemStack boot = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta();
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);
boot.setItemMeta(legdata);
player.getInventory().addItem(boot);
@ -63,11 +63,11 @@ public class ArmorCommand extends Command {
@Override
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<>());
} else if(args.length == 2) {
} else if (args.length == 2) {
List<String> names = new ArrayList<>();
for(Player player: Bukkit.getOnlinePlayers()) {
for (Player player : Bukkit.getOnlinePlayers()) {
names.add(player.getName());
}
return StringUtil.copyPartialMatches(args[1], names, new ArrayList<>());

View file

@ -1,6 +1,5 @@
package me.night.nullvalkyrie.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -19,7 +18,7 @@ public class CraftCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.openWorkbench(null, true);
}

View file

@ -17,7 +17,7 @@ public class EnchantingCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.openEnchanting(player.getLocation(), true);
}

View file

@ -20,7 +20,7 @@ public class HologramCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
String[] ar = new String[]{
ChatColor.AQUA + "Hi",
@ -28,8 +28,8 @@ public class HologramCommand extends Command {
ChatColor.GOLD + "Hello World"
};
Location location = player.getLocation();
for(String line: ar) {
ArmorStand stand = location.getWorld().spawn(location.subtract(0,0.3,0), ArmorStand.class, armorStand -> {
for (String line : ar) {
ArmorStand stand = location.getWorld().spawn(location.subtract(0, 0.3, 0), ArmorStand.class, armorStand -> {
armorStand.setVisible(false);
});
stand.setGravity(false);

View file

@ -26,9 +26,9 @@ public class MenuCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
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);
ItemMeta KYSmeta = KYS.getItemMeta();
@ -59,10 +59,9 @@ public class MenuCommand extends Command {
inv.setItem(0, close);
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);
}
player.openInventory(inv);
}

View file

@ -21,14 +21,14 @@ public class MessageCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (args.length >= 2) {
if(Bukkit.getPlayerExact(args[0]) != null) {
if (Bukkit.getPlayerExact(args[0]) != null) {
Player target = Bukkit.getPlayerExact(args[0]);
if(!target.equals(player)) {
if (!target.equals(player)) {
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(" ");
}
player.sendMessage(ChatColor.DARK_AQUA + "TO " + ChatColor.RED + target.getName() + ChatColor.WHITE + " : " + builder);
@ -47,9 +47,9 @@ public class MessageCommand extends Command {
@Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
if(args.length == 1) {
if (args.length == 1) {
List<String> names = new ArrayList<>();
for(Player player: Bukkit.getOnlinePlayers()) {
for (Player player : Bukkit.getOnlinePlayers()) {
names.add(player.getName());
}
return StringUtil.copyPartialMatches(args[0], names, new ArrayList<>());

View file

@ -13,6 +13,7 @@ import static me.night.nullvalkyrie.miners.CryptoMiner.getMiner;
public class MinerCommand extends Command {
private final Main main;
public MinerCommand(Main main) {
super(
"miner",
@ -25,10 +26,10 @@ public class MinerCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
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);
generate(50, seconds);
}

View file

@ -18,35 +18,34 @@ import java.util.concurrent.TimeUnit;
import static me.night.nullvalkyrie.rank.ScoreboardListener.rankManager;
//92.0.69.141:25565
public class RankCommand extends Command {
private Main main;
public RankCommand(Main main) {
public RankCommand() {
super(
"rank",
new String[]{},
"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
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(!cooldown.asMap().containsKey(player.getUniqueId())) {
if(player.isOp()) {
if(args.length == 2) {
if(Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
if (!cooldown.asMap().containsKey(player.getUniqueId())) {
if (player.isOp()) {
if (args.length == 2) {
if (Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
for(Rank rank : Rank.values()) {
if(rank.name().equalsIgnoreCase(args[1])) {
for (Rank rank : Rank.values()) {
if (rank.name().equalsIgnoreCase(args[1])) {
rankManager.setRank(target.getUniqueId(), rank);
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());
}
return;
@ -73,15 +72,15 @@ public class RankCommand extends Command {
@Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
if(args.length == 1) {
if (args.length == 1) {
List<String> names = new ArrayList<>();
for(Player player: Bukkit.getOnlinePlayers()) {
for (Player player : Bukkit.getOnlinePlayers()) {
names.add(player.getName());
}
return StringUtil.copyPartialMatches(args[0], names, new ArrayList<>());
} else if(args.length == 2) {
} else if (args.length == 2) {
List<String> roles = new ArrayList<>();
for(Rank rank : Rank.values()){
for (Rank rank : Rank.values()) {
roles.add(rank.name());
}
return StringUtil.copyPartialMatches(args[1], roles, new ArrayList<>());

View file

@ -13,9 +13,10 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class ShopCommand extends Command{
public class ShopCommand extends Command {
private FileConfiguration file;
private Inventory inv;
public ShopCommand() {
super("7elven",
new String[]{"711", "seven", "7ven"},
@ -24,10 +25,11 @@ public class ShopCommand extends Command{
);
file = CustomItemManager.loadConfig("miners.yml");
}
@Override
public void onCommand(CommandSender sender, String[] args) {
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")));
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(file.getString(c + ".name"));

View file

@ -1,6 +1,5 @@
package me.night.nullvalkyrie.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -15,11 +14,12 @@ public class TestCommand extends Command {
""
);
}
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if(args.length == 1) {
if(args[0].equalsIgnoreCase("hello")) {
if (sender instanceof Player) {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("hello")) {
Player player = (Player) sender;
player.sendMessage(player.getAddress().getHostString());
}

View file

@ -15,8 +15,8 @@ import java.util.List;
import java.util.Objects;
public class UtilCommand extends Command {
private Main main;
public UtilCommand(Main main) {
public UtilCommand() {
super(
"util",
new String[]{},
@ -24,15 +24,15 @@ public class UtilCommand extends Command {
""
);
this.main = main;
}
@Override
public void onCommand(CommandSender sender, String[] args) {
Player player = (Player) sender;
StringBuilder s = new StringBuilder();
List<String> b = Arrays.asList(args);
for(String a: args) {
if(a.equals(b.get(b.size() - 1))) {
for (String a : args) {
if (a.equals(b.get(b.size() - 1))) {
s.append(a);
} else {
s.append(a);
@ -40,8 +40,8 @@ public class UtilCommand extends Command {
}
}
ItemStack item = main.getCustomItemManager().getItem(s.toString());
if(item.hasItemMeta()) {
ItemStack item = CustomItemManager.getItem(s.toString());
if (item.hasItemMeta()) {
player.getInventory().addItem(item);
} else {
player.sendMessage(ChatColor.RED + "This item doesn't exist");
@ -50,12 +50,12 @@ public class UtilCommand extends Command {
@Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
if(args.length == 1) {
if (args.length == 1) {
List<String> hh = CustomItemManager.getAllFilesFromDirectory("ItemData");
ArrayList<String> cc = new ArrayList<>();
for(int kk = 0; kk < hh.size(); kk++) {
FileConfiguration c = CustomItemManager.loadConfig("ItemData\\" + hh.get(kk));
if(Objects.equals(c.getString("type"), "Util")) {
for (String s : hh) {
FileConfiguration c = CustomItemManager.loadConfig("ItemData\\" + s);
if (Objects.equals(c.getString("type"), "Util")) {
cc.add(c.getString("name"));
}
}

View file

@ -11,6 +11,7 @@ import java.util.UUID;
public class VanishCommand extends Command {
private final List<UUID> vanished = new ArrayList<>();
public VanishCommand() {
super(
"vanish",
@ -19,11 +20,12 @@ public class VanishCommand extends Command {
""
);
}
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(vanished.contains(player.getUniqueId())) {
if (vanished.contains(player.getUniqueId())) {
vanished.remove(player.getUniqueId());
for (Player target : Bukkit.getOnlinePlayers()) {
target.showPlayer(player);
@ -31,7 +33,7 @@ public class VanishCommand extends Command {
player.sendMessage(ChatColor.GREEN + "You are now seen by people");
} else {
vanished.add(player.getUniqueId());
for (Player target: Bukkit.getOnlinePlayers()){
for (Player target : Bukkit.getOnlinePlayers()) {
target.hidePlayer(player);
}
player.sendMessage(ChatColor.GREEN + "You are now vanished");