formatting

This commit is contained in:
NK 2022-12-16 21:20:13 +00:00
parent f9a5fdbb74
commit a85e749fc5
14 changed files with 35 additions and 36 deletions

View file

@ -23,6 +23,7 @@ public class ArmorCommand extends Command {
if (sender instanceof Player player) { if (sender instanceof Player player) {
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta helmetdata = (LeatherArmorMeta) helmet.getItemMeta(); LeatherArmorMeta helmetdata = (LeatherArmorMeta) helmet.getItemMeta();
if (helmetdata == null) return;
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);
@ -31,6 +32,7 @@ public class ArmorCommand extends Command {
ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE); ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta(); LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta();
if (cpdata == null) return;
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);
@ -39,6 +41,7 @@ public class ArmorCommand extends Command {
ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS); ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta(); LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta();
if (legdata == null) return;
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);
@ -47,6 +50,7 @@ public class ArmorCommand extends Command {
ItemStack boot = new ItemStack(Material.LEATHER_BOOTS); ItemStack boot = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta(); LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta();
if (bootdata == null) return;
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);

View file

@ -19,9 +19,8 @@ public class HologramCommand extends Command {
String[] ar = new String[]{ChatColor.AQUA + "Hi", ChatColor.DARK_PURPLE + "What", ChatColor.GOLD + "Hello World"}; String[] ar = new String[]{ChatColor.AQUA + "Hi", ChatColor.DARK_PURPLE + "What", 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.setVisible(false); stand.setVisible(false);
});
stand.setGravity(false); stand.setGravity(false);
stand.setInvulnerable(true); stand.setInvulnerable(true);
stand.setCustomNameVisible(true); stand.setCustomNameVisible(true);

View file

@ -1,5 +1,6 @@
package me.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -22,13 +23,13 @@ public class VanishCommand extends Command {
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(Main.getPlugin(Main.class), player);
} }
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(Main.getPlugin(Main.class), player);
} }
player.sendMessage(ChatColor.GREEN + "You are now vanished"); player.sendMessage(ChatColor.GREEN + "You are now vanished");
} }

View file

@ -27,7 +27,7 @@ public class CustomWeaponsDataManager {
abi.put("Name", ability.getString("Name")); abi.put("Name", ability.getString("Name"));
List<String> details = new ArrayList<>(); List<String> details = new ArrayList<>();
if (ability.get("Details") != null) if (ability.get("Details") != null)
for (String s : (List<String>) ability.get("Details")) details.add(s); details.addAll((List<String>) ability.get("Details"));
abi.put("Details", details); abi.put("Details", details);
for (String a : properties.keySet()) prop.put(a, properties.get(a)); for (String a : properties.keySet()) prop.put(a, properties.get(a));
lores.put("Ability", abi); lores.put("Ability", abi);
@ -49,7 +49,7 @@ public class CustomWeaponsDataManager {
for (String i : ing.keySet()) for (String i : ing.keySet())
ingredients.put(i, ing.getString(i)); ingredients.put(i, ing.getString(i));
List<String> shapes = new ArrayList<>(); List<String> shapes = new ArrayList<>();
if (recipe.get("Shapes") != null) for (String s : (List<String>) recipe.get("Shapes")) shapes.add(s); if (recipe.get("Shapes") != null) shapes.addAll((List<String>) recipe.get("Shapes"));
recipes.put("Shape", shapes); recipes.put("Shape", shapes);
recipes.put("Amount", recipe.getInteger("Amount")); recipes.put("Amount", recipe.getInteger("Amount"));
recipes.put("Ingredients", ingredients); recipes.put("Ingredients", ingredients);
@ -83,7 +83,7 @@ public class CustomWeaponsDataManager {
abi.put("Name", ability.getString("Name")); abi.put("Name", ability.getString("Name"));
List<String> details = new ArrayList<>(); List<String> details = new ArrayList<>();
if (ability.get("Details") != null) if (ability.get("Details") != null)
for (String s : (List<String>) ability.get("Details")) details.add(s); details.addAll((List<String>) ability.get("Details"));
abi.put("Details", details); abi.put("Details", details);
for (String a : properties.keySet()) prop.put(a, properties.get(a)); for (String a : properties.keySet()) prop.put(a, properties.get(a));
lores.put("Ability", abi); lores.put("Ability", abi);

View file

@ -1,7 +1,6 @@
package me.night.nullvalkyrie.database; package me.night.nullvalkyrie.database;
import com.mongodb.client.MongoCursor; import com.mongodb.client.MongoCursor;
import com.mongodb.client.model.Filters;
import me.night.nullvalkyrie.entities.miners.CryptoMiner; import me.night.nullvalkyrie.entities.miners.CryptoMiner;
import org.bson.Document; import org.bson.Document;
import org.bson.conversions.Bson; import org.bson.conversions.Bson;
@ -32,24 +31,20 @@ public class MinerDataManager {
} }
public static long getLastClaim(long id) { public static long getLastClaim(long id) {
try (MongoCursor<Document> cursor = DatabaseManager.getMinersDB().find(Filters.eq("ID", id)).cursor()) { Document doc = DatabaseManager.getMinersDB().find(new Document("ID", id)).first();
while (cursor.hasNext()) { if (doc != null) {
Document doc = cursor.next();
for (String key : doc.keySet()) { for (String key : doc.keySet()) {
if (key.equals("LastClaim")) return (long) doc.get(key); if (key.equals("LastClaim")) return (long) doc.get(key);
} }
} }
}
return 0; return 0;
} }
public static CryptoMiner getMiner(long id) { public static CryptoMiner getMiner(long id) {
try (MongoCursor<Document> cursor = DatabaseManager.getMinersDB().find(Filters.eq("ID", id)).cursor()) { Document doc = DatabaseManager.getMinersDB().find(new Document("ID", id)).first();
while (cursor.hasNext()) { if (doc != null) {
Document doc = cursor.next();
return new CryptoMiner(doc.getString("Name"), Material.matchMaterial(doc.getString("Material")), doc.getInteger("Level"), doc.getDouble("Rate"), doc.getLong("LastClaim")); return new CryptoMiner(doc.getString("Name"), Material.matchMaterial(doc.getString("Material")), doc.getInteger("Level"), doc.getDouble("Rate"), doc.getLong("LastClaim"));
} }
}
return null; return null;
} }

View file

@ -9,7 +9,6 @@ import javax.security.auth.login.LoginException;
public class DiscordClientManager { public class DiscordClientManager {
private JDA jda;
public DiscordClientManager() { public DiscordClientManager() {
register(); register();
@ -19,7 +18,7 @@ public class DiscordClientManager {
JDABuilder builder = JDABuilder.createDefault(Main.env.get("DISCORD_TOKEN")); JDABuilder builder = JDABuilder.createDefault(Main.env.get("DISCORD_TOKEN"));
builder.setActivity(Activity.streaming("cath.exe", "https://www.youtube.com/watch?v=YSKDu1gKntY")); builder.setActivity(Activity.streaming("cath.exe", "https://www.youtube.com/watch?v=YSKDu1gKntY"));
try { try {
jda = builder.build(); JDA jda = builder.build();
} catch (LoginException e) { } catch (LoginException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -8,8 +8,8 @@ import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class InteractHologramEvent extends Event implements Cancellable { public class InteractHologramEvent extends Event implements Cancellable {
private boolean isCancelled; private boolean isCancelled;
public Player player; public final Player player;
public ArmorStand hologram; public final ArmorStand hologram;
private static final HandlerList HANDLERS = new HandlerList(); private static final HandlerList HANDLERS = new HandlerList();
public InteractHologramEvent(Player player, ArmorStand hologram) { public InteractHologramEvent(Player player, ArmorStand hologram) {
this.player = player; this.player = player;

View file

@ -230,8 +230,7 @@ public class CustomItemEvents implements Listener {
@EventHandler @EventHandler
public void onDamage(EntityDamageByEntityEvent e) { public void onDamage(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Player) { if (e.getEntity() instanceof Player player) {
Player player = (Player) e.getEntity();
// if ((player.getHealth() - e.getDamage()) <= 0) { // if ((player.getHealth() - e.getDamage()) <= 0) {
// e.setCancelled(true); // e.setCancelled(true);
// Location loc = player.getWorld().getBlockAt(-3, 23, -3).getLocation(); // Location loc = player.getWorld().getBlockAt(-3, 23, -3).getLocation();
@ -335,7 +334,7 @@ public class CustomItemEvents implements Listener {
} }
} }
ProtocolManager manager = ProtocolLibrary.getProtocolManager(); final ProtocolManager manager = ProtocolLibrary.getProtocolManager();
public void sendBlockDamage(Player player, Block block) { public void sendBlockDamage(Player player, Block block) {
Location location = block.getLocation(); Location location = block.getLocation();

View file

@ -18,7 +18,7 @@ import java.text.DecimalFormat;
import java.util.*; import java.util.*;
public class DamageEffectEvents implements Listener { public class DamageEffectEvents implements Listener {
public World world = Bukkit.getWorld("world"); public final World world = Bukkit.getWorld("world");
public final Map<Entity, Integer> indicators = new HashMap<>(); public final Map<Entity, Integer> indicators = new HashMap<>();
private final DecimalFormat formatter = new DecimalFormat("#"); private final DecimalFormat formatter = new DecimalFormat("#");

View file

@ -15,8 +15,8 @@ import org.bukkit.event.weather.WeatherChangeEvent;
import java.io.File; import java.io.File;
public class ServerEvents implements Listener { public class ServerEvents implements Listener {
public BossBar bossbar; public final BossBar bossbar;
public PacketInjector injector; public final PacketInjector injector;
public ServerEvents() { public ServerEvents() {
bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12); bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
this.injector = new PacketInjector(); this.injector = new PacketInjector();

View file

@ -21,7 +21,7 @@ import java.util.*;
import static me.night.nullvalkyrie.database.CustomWeaponsDataManager.getWeapon; import static me.night.nullvalkyrie.database.CustomWeaponsDataManager.getWeapon;
public class CustomItemManager { public class CustomItemManager {
public static HashMap<String, NamespacedKey> keys = new HashMap<>(); public static final HashMap<String, NamespacedKey> keys = new HashMap<>();
public static ItemStack produceItem(String itemName) { public static ItemStack produceItem(String itemName) {
HashMap<String, Object> weapon = getWeapon(itemName); HashMap<String, Object> weapon = getWeapon(itemName);

View file

@ -7,8 +7,8 @@ import org.bukkit.inventory.ItemStack;
import java.util.HashMap; import java.util.HashMap;
public class Pickaxe { public class Pickaxe {
public ArrayListMultimap<Material, Material> multimap = ArrayListMultimap.create(); public final ArrayListMultimap<Material, Material> multimap = ArrayListMultimap.create();
public HashMap<Material, Long> phases = new HashMap<>(); public final HashMap<Material, Long> phases = new HashMap<>();
private final ItemStack itemStack; private final ItemStack itemStack;
public Pickaxe(ItemStack item) { public Pickaxe(ItemStack item) {
multimap.put(Material.STONE_PICKAXE, Material.IRON_ORE); //put some blocks and pickaxe to mine multimap.put(Material.STONE_PICKAXE, Material.IRON_ORE); //put some blocks and pickaxe to mine

View file

@ -21,6 +21,7 @@ public class InventoryListener implements Listener {
player.sendMessage(ChatColor.RED + "又做兵 抵死"); player.sendMessage(ChatColor.RED + "又做兵 抵死");
break; break;
case 22: case 22:
player.teleport(player.getWorld().getSpawnLocation());
break; break;
case 24: case 24:
player.closeInventory(); player.closeInventory();

View file

@ -6,6 +6,8 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.*; import org.bukkit.scoreboard.*;
import java.util.Objects;
public class NameTagManager { public class NameTagManager {
public void setNametags(Player player) { public void setNametags(Player player) {
Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
@ -27,8 +29,7 @@ public class NameTagManager {
public void newTag(Player player) { public void newTag(Player player) {
Rank rank = RankDataManager.getRank(player.getUniqueId()); Rank rank = RankDataManager.getRank(player.getUniqueId());
for (Player target : Bukkit.getOnlinePlayers()) { for (Player target : Bukkit.getOnlinePlayers()) {
if (rank == null) target.getScoreboard().getTeam(Rank.ROOKIE.name()).addEntry(player.getName()); target.getScoreboard().getTeam(Objects.requireNonNullElse(rank, Rank.ROOKIE).name()).addEntry(player.getName());
else target.getScoreboard().getTeam(rank.name()).addEntry(player.getName());
} }
} }