change to linux

This commit is contained in:
night0721 2022-08-02 11:23:16 +01:00
parent b6cb03bba4
commit 3425352908
39 changed files with 2262 additions and 2045 deletions

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.night</groupId> <groupId>me.night</groupId>
<artifactId>NullValkyrie</artifactId> <artifactId>NullValkyrie</artifactId>
<version>1.0.1</version> <version>1.0.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
@ -51,7 +51,7 @@
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.4</version> <version>2.4</version>
<configuration> <configuration>
<outputDirectory>D:\Server\plugins</outputDirectory> <outputDirectory>media/night0721/Data/Network/Lobby/plugins</outputDirectory>
</configuration> </configuration>
</plugin> </plugin>
<!-- <plugin>--> <!-- <plugin>-->
@ -109,7 +109,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version> <version>1.18.1-R0.1-SNAPSHOT</version>
<!-- <classifier>remapped-mojang</classifier>--> <!-- <classifier>remapped-mojang</classifier>-->
<scope>provided</scope> <scope>provided</scope>

View file

@ -1,37 +1,37 @@
package com.night.nullvalkyrie.Chests; package me.night.nullvalkyrie.Chests;
import com.night.nullvalkyrie.commands.MenuCommand; import me.night.nullvalkyrie.commands.MenuCommand;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
public class MenuListener implements Listener { public class MenuListener implements Listener {
@EventHandler @EventHandler
public void onClick(InventoryClickEvent e) { public void onClick(InventoryClickEvent e) {
if(e.getInventory().equals(MenuCommand.inv) && e.getCurrentItem() != null) { if(e.getInventory().equals(MenuCommand.inv) && e.getCurrentItem() != null) {
e.setCancelled(true); e.setCancelled(true);
Player player = (Player) e.getWhoClicked(); Player player = (Player) e.getWhoClicked();
switch (e.getRawSlot()) { switch (e.getRawSlot()) {
case 0: case 0:
break; break;
case 20: case 20:
player.setHealth(0); player.setHealth(0);
player.sendMessage(ChatColor.RED + "又做兵 抵死"); player.sendMessage(ChatColor.RED + "又做兵 抵死");
break; break;
case 22: case 22:
break; break;
case 24: case 24:
player.closeInventory(); player.closeInventory();
player.openInventory(WitherChest.witherchest); player.openInventory(WitherChest.witherchest);
return; return;
default: default:
return; return;
} }
player.closeInventory(); player.closeInventory();
}else { return; } }else { return; }
} }
} }

View file

@ -1,9 +1,9 @@
package com.night.nullvalkyrie.Chests; package me.night.nullvalkyrie.Chests;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
public class WitherChest { public class WitherChest {
public static Inventory witherchest = Bukkit.createInventory(null,54, ChatColor.DARK_AQUA + "Whiter Chest"); public static Inventory witherchest = Bukkit.createInventory(null,54, ChatColor.DARK_AQUA + "Whiter Chest");
} }

View file

@ -1,25 +1,25 @@
package com.night.nullvalkyrie.Discord; package me.night.nullvalkyrie.Discord;
import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Activity;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
public class DiscordClientManager { public class DiscordClientManager {
private JDA jda; private JDA jda;
public DiscordClientManager() { public DiscordClientManager() {
register(); register();
} }
public void register() { public void register() {
JDABuilder builder = JDABuilder.createDefault("OTk3ODczMzgyNjM0ODM2MDQ5.GTalga.2uMZE-S0t2yL-3jsglrpG9lMbIHHBMAedVZA4U"); JDABuilder builder = JDABuilder.createDefault("OTk3ODczMzgyNjM0ODM2MDQ5.GTalga.2uMZE-S0t2yL-3jsglrpG9lMbIHHBMAedVZA4U");
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 = builder.build();
} catch (LoginException e) { } catch (LoginException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View file

@ -1,56 +1,56 @@
package com.night.nullvalkyrie.Enchantments; package me.night.nullvalkyrie.Enchantments;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class CustomEnchantment extends Enchantment { public class CustomEnchantment extends Enchantment {
private final String name; private final String name;
private final int maxlvl; private final int maxlvl;
public CustomEnchantment(String namespace, String name, int lvl) { public CustomEnchantment(String namespace, String name, int lvl) {
super(NamespacedKey.minecraft(namespace)); super(NamespacedKey.minecraft(namespace));
this.name = name; this.name = name;
this.maxlvl = lvl; this.maxlvl = lvl;
} }
@Override @Override
public String getName() { public String getName() {
return name; return name;
} }
@Override @Override
public int getMaxLevel() { public int getMaxLevel() {
return maxlvl; return maxlvl;
} }
@Override @Override
public int getStartLevel() { public int getStartLevel() {
return 1; return 1;
} }
@Override @Override
public EnchantmentTarget getItemTarget() { public EnchantmentTarget getItemTarget() {
return null; return null;
} }
@Override @Override
public boolean isTreasure() { public boolean isTreasure() {
return false; return false;
} }
@Override @Override
public boolean isCursed() { public boolean isCursed() {
return false; return false;
} }
@Override @Override
public boolean conflictsWith(Enchantment other) { public boolean conflictsWith(Enchantment other) {
return false; return false;
} }
@Override @Override
public boolean canEnchantItem(ItemStack item) { public boolean canEnchantItem(ItemStack item) {
return true; return true;
} }
} }

View file

@ -1,38 +1,38 @@
package com.night.nullvalkyrie.Enchantments; package me.night.nullvalkyrie.Enchantments;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class EnchantmentManager { public class EnchantmentManager {
public EnchantmentManager() { public EnchantmentManager() {
register(); register();
} }
public static final Enchantment ThunderBolt = new CustomEnchantment("thunderbolt", "ThunderBolt", 5); public static final Enchantment ThunderBolt = new CustomEnchantment("thunderbolt", "ThunderBolt", 5);
public static final Enchantment SmeltingTouch = new CustomEnchantment("smelting-touch", "Smelting Touch", 1); public static final Enchantment SmeltingTouch = new CustomEnchantment("smelting-touch", "Smelting Touch", 1);
public static void register() { public static void register() {
boolean registered = Arrays.stream(Enchantment.values()).collect(Collectors.toList()).contains(ThunderBolt); boolean registered = Arrays.stream(Enchantment.values()).collect(Collectors.toList()).contains(ThunderBolt);
if(!registered) { if(!registered) {
registerEnchantment(ThunderBolt); registerEnchantment(ThunderBolt);
registerEnchantment(SmeltingTouch); registerEnchantment(SmeltingTouch);
} }
} }
public static void registerEnchantment(Enchantment en) { public static void registerEnchantment(Enchantment en) {
try { try {
try { try {
Field f = Enchantment.class.getDeclaredField("acceptingNew"); Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true); f.setAccessible(true);
f.set(null, true); f.set(null, true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Enchantment.registerEnchantment(en); Enchantment.registerEnchantment(en);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View file

@ -1,281 +1,318 @@
package com.night.nullvalkyrie.Events; package me.night.nullvalkyrie.Events;
import com.night.nullvalkyrie.Items.Rarity; import me.night.nullvalkyrie.Items.CustomItemManager;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Items.Rarity;
import org.bukkit.*; import me.night.nullvalkyrie.Main;
import org.bukkit.block.Block; import me.night.nullvalkyrie.commands.SpawnCommand;
import org.bukkit.entity.*; import org.bukkit.*;
import org.bukkit.event.EventHandler; import org.bukkit.block.Block;
import org.bukkit.event.Listener; import org.bukkit.entity.*;
import org.bukkit.event.block.Action; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.*; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.entity.*;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import java.util.Set; import org.bukkit.event.player.PlayerInteractEvent;
import java.util.concurrent.atomic.AtomicInteger; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Merchant;
import static com.night.nullvalkyrie.Items.CustomItemManager.loadConfig; import org.bukkit.inventory.MerchantRecipe;
import static com.night.nullvalkyrie.commands.SpawnCommand.getRandomWithNeg; import org.bukkit.scheduler.BukkitRunnable;
public class CustomItemEvents implements Listener { import java.util.*;
private Main main;
public CustomItemEvents(Main main) { public class CustomItemEvents implements Listener {
this.main = main; private Main main;
} public CustomItemEvents(Main main) {
@EventHandler this.main = main;
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) { }
if (e.getDamager().getType().equals(EntityType.SNOWBALL)) { @EventHandler
Snowball sb = (Snowball) e.getDamager(); public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
Player pl = (Player) sb.getShooter(); if (e.getDamager().getType().equals(EntityType.SNOWBALL)) {
if (pl.getInventory().getItemInMainHand().getItemMeta() != null) { Snowball sb = (Snowball) e.getDamager();
String name = pl.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player pl = (Player) sb.getShooter();
if (name.equalsIgnoreCase(Rarity.ULTRA.getColor() + "Snow Gun")) { if (pl.getInventory().getItemInMainHand().getItemMeta() != null) {
((Snowball) e.getDamager()).setShooter(pl.getPlayer()); String name = pl.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
e.setDamage(2000); if (name.equalsIgnoreCase(Rarity.ULTRA.getColor() + "Snow Gun")) {
} else if (name.equalsIgnoreCase("AA-12")) { ((Snowball) e.getDamager()).setShooter(pl.getPlayer());
e.setDamage(7); e.setDamage(2000);
} else { } else if (name.equalsIgnoreCase("AA-12")) {
e.setDamage(0); e.setDamage(7);
} } else {
} e.setDamage(0);
} else if (e.getDamager() instanceof Player) { }
Player player = (Player) e.getDamager(); }
if (player.getInventory().getItemInMainHand().getItemMeta() != null) { } else if (e.getDamager() instanceof Player) {
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player player = (Player) e.getDamager();
if(name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Fabled Widow Sword")) { if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
if (e.getEntity() instanceof Zombie) { String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
int zombie = loadConfig("ItemData\\WidowSword.yml").getInt("zombie"); if(name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Fabled Widow Sword")) {
e.setDamage(e.getDamage() * (1 + zombie / 100)); if (e.getEntity() instanceof Zombie) {
} else if (e.getEntity() instanceof Skeleton) { int zombie = CustomItemManager.loadConfig("ItemData\\WidowSword.yml").getInt("zombie");
int skeleton = loadConfig("ItemData\\WidowSword.yml").getInt("skeleton"); e.setDamage(e.getDamage() * (1 + zombie / 100));
e.setDamage(e.getDamage() * (1 + skeleton / 100)); } else if (e.getEntity() instanceof Skeleton) {
} else if (e.getEntity() instanceof Spider) { int skeleton = CustomItemManager.loadConfig("ItemData\\WidowSword.yml").getInt("skeleton");
int spider = loadConfig("ItemData\\WidowSword.yml").getInt("spider"); e.setDamage(e.getDamage() * (1 + skeleton / 100));
e.setDamage(e.getDamage() * (1 + spider / 100)); } else if (e.getEntity() instanceof Spider) {
} int spider = CustomItemManager.loadConfig("ItemData\\WidowSword.yml").getInt("spider");
} e.setDamage(e.getDamage() * (1 + spider / 100));
} }
} }
} }
}
@EventHandler }
public void onPlayerFish(PlayerFishEvent e) {
Player player = e.getPlayer(); @EventHandler
if (player.getInventory().getItemInMainHand().getItemMeta() != null) { public void onPlayerFish(PlayerFishEvent e) {
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player player = e.getPlayer();
if (name.equalsIgnoreCase(Rarity.RARE.getColor() + "Grappling Hook")) { if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
if(e.getState().equals(PlayerFishEvent.State.REEL_IN)) { String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
Location change = e.getHook().getLocation().subtract(player.getLocation()); if (name.equalsIgnoreCase(Rarity.RARE.getColor() + "Grappling Hook")) {
player.setVelocity(change.toVector().multiply(0.4)); if(e.getState().equals(PlayerFishEvent.State.REEL_IN)) {
} Location change = e.getHook().getLocation().subtract(player.getLocation());
} player.setVelocity(change.toVector().multiply(0.4));
} }
} }
@EventHandler }
public void onPlayerInteract(PlayerInteractEvent e) { }
Player player = e.getPlayer(); @EventHandler
if (player.getInventory().getItemInMainHand().getItemMeta() != null) { public void onPlayerInteract(PlayerInteractEvent e) {
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player player = e.getPlayer();
if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
if (name.equalsIgnoreCase(Rarity.GRAND.getColor() + "Teleport Door")) { String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
Block block = player.getTargetBlock((Set<Material>) null, 12); if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
Location l = block.getLocation(); if (name.equalsIgnoreCase(Rarity.GRAND.getColor() + "Teleport Door")) {
l.add(0, 1, 0); Block block = player.getTargetBlock((Set<Material>) null, 12);
float yaw = player.getEyeLocation().getYaw(); Location l = block.getLocation();
float pitch = player.getEyeLocation().getPitch(); l.add(0, 1, 0);
l.setYaw(yaw); float yaw = player.getEyeLocation().getYaw();
l.setPitch(pitch); float pitch = player.getEyeLocation().getPitch();
player.teleport(l); l.setYaw(yaw);
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 10, 10); l.setPitch(pitch);
} else if (name.equalsIgnoreCase(Rarity.ULTRA.getColor() + "Snow Gun")) { player.teleport(l);
Snowball s = player.launchProjectile(Snowball.class, player.getLocation().getDirection()); player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 10, 10);
s.setVelocity(player.getLocation().getDirection().multiply(10)); } else if (name.equalsIgnoreCase(Rarity.ULTRA.getColor() + "Snow Gun")) {
} else if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) { Snowball s = player.launchProjectile(Snowball.class, player.getLocation().getDirection());
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); s.setVelocity(player.getLocation().getDirection().multiply(10));
arrow.setVelocity(arrow.getVelocity().multiply(5)); } else if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
arrow.setPickupStatus(Arrow.PickupStatus.DISALLOWED); Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
arrow.setShooter(player); arrow.setVelocity(arrow.getVelocity().multiply(5));
arrow.setDamage(50); arrow.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
Arrow a1 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); arrow.setShooter(player);
a1.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(5)).multiply(5)); arrow.setDamage(50);
a1.setPickupStatus(Arrow.PickupStatus.DISALLOWED); Arrow a1 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
a1.setShooter(player); a1.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(5)).multiply(5));
a1.setDamage(50); a1.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
Arrow a2 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); a1.setShooter(player);
a2.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(-5)).multiply(5)); a1.setDamage(50);
a2.setPickupStatus(Arrow.PickupStatus.DISALLOWED); Arrow a2 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
a2.setShooter(player); a2.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(-5)).multiply(5));
a2.setDamage(50); a2.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
e.setCancelled(true); a2.setShooter(player);
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) { a2.setDamage(50);
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); e.setCancelled(true);
arrow.setVelocity(arrow.getVelocity().multiply(5)); } else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
arrow.setShooter(player); Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
arrow.setDamage(50); arrow.setVelocity(arrow.getVelocity().multiply(5));
e.setCancelled(true); arrow.setShooter(player);
} arrow.setDamage(50);
} else if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)) { e.setCancelled(true);
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) { }
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); } else if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
arrow.setVelocity(arrow.getVelocity().multiply(5)); if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
arrow.setPickupStatus(Arrow.PickupStatus.DISALLOWED); Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
arrow.setShooter(player); arrow.setVelocity(arrow.getVelocity().multiply(5));
arrow.setDamage(50); arrow.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
Arrow a1 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); arrow.setShooter(player);
a1.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(5)).multiply(5)); arrow.setDamage(50);
a1.setPickupStatus(Arrow.PickupStatus.DISALLOWED); Arrow a1 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
a1.setShooter(player); a1.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(5)).multiply(5));
a1.setDamage(50); a1.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
Arrow a2 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); a1.setShooter(player);
a2.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(-5)).multiply(5)); a1.setDamage(50);
a2.setPickupStatus(Arrow.PickupStatus.DISALLOWED); Arrow a2 = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
a2.setShooter(player); a2.setVelocity(arrow.getVelocity().rotateAroundY(Math.toRadians(-5)).multiply(5));
a2.setDamage(50); a2.setPickupStatus(Arrow.PickupStatus.DISALLOWED);
e.setCancelled(true); a2.setShooter(player);
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) { a2.setDamage(50);
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection()); e.setCancelled(true);
arrow.setVelocity(arrow.getVelocity().multiply(5)); } else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
arrow.setShooter(player); Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
arrow.setDamage(50); arrow.setVelocity(arrow.getVelocity().multiply(5));
e.setCancelled(true); arrow.setShooter(player);
} arrow.setDamage(50);
} e.setCancelled(true);
} }
} }
@EventHandler }
public void onEntityShoot(EntityShootBowEvent e) { }
if (e.getProjectile() instanceof Arrow) { @EventHandler
if (e.getEntity() instanceof Player) { public void onEntityShoot(EntityShootBowEvent e) {
Player player = (Player) e.getEntity(); if (e.getProjectile() instanceof Arrow) {
if (player.getInventory().getItemInMainHand().getItemMeta() != null) { if (e.getEntity() instanceof Player) {
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player player = (Player) e.getEntity();
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) { if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
e.setCancelled(true); String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) { if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
e.setCancelled(true); e.setCancelled(true);
} } else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
} e.setCancelled(true);
} }
} }
} }
@EventHandler }
public void onProjectileHit(ProjectileHitEvent e) { }
if(e.getEntity().getShooter() instanceof Player) { @EventHandler
Player shooter = (Player) e.getEntity().getShooter(); public void onProjectileHit(ProjectileHitEvent e) {
if(shooter.getInventory().getItemInMainHand().getItemMeta() != null) { if(e.getEntity().getShooter() instanceof Player) {
String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player shooter = (Player) e.getEntity().getShooter();
if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) { if(shooter.getInventory().getItemInMainHand().getItemMeta() != null) {
if(e.getHitBlock() == null) { String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
Location l = e.getHitEntity().getLocation(); if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
e.getEntity().setShooter(shooter); if(e.getHitBlock() == null) {
e.getHitEntity().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false); Location l = e.getHitEntity().getLocation();
} else if(e.getHitEntity() == null) { e.getEntity().setShooter(shooter);
Location l = e.getHitBlock().getLocation(); e.getHitEntity().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
e.getHitBlock().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false); } else if(e.getHitEntity() == null) {
} Location l = e.getHitBlock().getLocation();
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) { e.getHitBlock().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
Arrow arrow = (Arrow) e.getEntity(); }
Location al = arrow.getLocation(); } else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
arrow.setShooter(shooter); Arrow arrow = (Arrow) e.getEntity();
shooter.getWorld().createExplosion(al, 100, false, false); Location al = arrow.getLocation();
} arrow.setShooter(shooter);
} shooter.getWorld().createExplosion(al, 100, false, false);
}
} }
}
@EventHandler }
public void onCreatureSpawn(CreatureSpawnEvent event) { }
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.EGG) { @EventHandler
event.setCancelled(true); public void onCreatureSpawn(CreatureSpawnEvent event) {
} if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.EGG) {
} event.setCancelled(true);
@EventHandler }
public void Projectile(ProjectileLaunchEvent e) { }
if(e.getEntity().getShooter() instanceof Player) { @EventHandler
Player player = (Player) e.getEntity().getShooter(); public void Projectile(ProjectileLaunchEvent e) {
if(player.getInventory().getItemInMainHand().getItemMeta() != null) { if(e.getEntity().getShooter() instanceof Player) {
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player player = (Player) e.getEntity().getShooter();
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) { if(player.getInventory().getItemInMainHand().getItemMeta() != null) {
Egg s = (Egg) e.getEntity(); String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
s.setVelocity(player.getLocation().getDirection().multiply(10)); if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
} Egg s = (Egg) e.getEntity();
} s.setVelocity(player.getLocation().getDirection().multiply(10));
} }
} }
@EventHandler }
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent e) { }
int x = e.getBlockClicked().getX() + e.getBlockFace().getModX(); @EventHandler
int y = e.getBlockClicked().getY() + e.getBlockFace().getModY(); public void onPlayerBucketEmpty(PlayerBucketEmptyEvent e) {
int z = e.getBlockClicked().getZ() + e.getBlockFace().getModZ(); int x = e.getBlockClicked().getX() + e.getBlockFace().getModX();
Player player = e.getPlayer(); int y = e.getBlockClicked().getY() + e.getBlockFace().getModY();
if(player.getInventory().getItemInMainHand().getItemMeta() != null) { int z = e.getBlockClicked().getZ() + e.getBlockFace().getModZ();
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); Player player = e.getPlayer();
if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite Water Bucket")) { if(player.getInventory().getItemInMainHand().getItemMeta() != null) {
e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.WATER); String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
e.setCancelled(true); if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite Water Bucket")) {
} else if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite LAVA Bucket")) { e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.WATER);
e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.LAVA); e.setCancelled(true);
e.setCancelled(true); } else if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite LAVA Bucket")) {
} e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.LAVA);
} e.setCancelled(true);
} }
private Location l; }
private boolean spawnable = false; }
@EventHandler private Location l;
public void onDamage(EntityDamageByEntityEvent e) { private boolean spawnable = false;
if(e.getEntity() instanceof Player) { @EventHandler
Player player = (Player) e.getEntity(); public void onDamage(EntityDamageByEntityEvent e) {
if((player.getHealth() - e.getDamage()) <= 0) { if(e.getEntity() instanceof Player) {
e.setCancelled(true); Player player = (Player) e.getEntity();
Location loc = player.getWorld().getBlockAt(-3,23,-3).getLocation(); if((player.getHealth() - e.getDamage()) <= 0) {
player.teleport(loc); e.setCancelled(true);
for (Player p : Bukkit.getOnlinePlayers()) { Location loc = player.getWorld().getBlockAt(-3,23,-3).getLocation();
p.sendMessage(e.getDamager() instanceof Player ? ChatColor.RED + player.getName() + " has been killed by " + e.getDamager().getName() : ChatColor.RED + player.getName() + " died"); player.teleport(loc);
p.hidePlayer(player); for (Player p : Bukkit.getOnlinePlayers()) {
} p.sendMessage(e.getDamager() instanceof Player ? ChatColor.RED + player.getName() + " has been killed by " + e.getDamager().getName() : ChatColor.RED + player.getName() + " died");
new BukkitRunnable() { p.hidePlayer(player);
@Override }
public void run() { new BukkitRunnable() {
for (Player p : Bukkit.getOnlinePlayers()) { @Override
p.showPlayer(player); public void run() {
} for (Player p : Bukkit.getOnlinePlayers()) {
player.setHealth(20); p.showPlayer(player);
// while(!spawnable) { }
// l = generateRandomCoord(9, Bukkit.getWorld("world")); player.setHealth(20);
// if(isSpawnable(l)) { // while(!spawnable) {
// spawnable = true; // l = generateRandomCoord(9, Bukkit.getWorld("world"));
// player.teleport(l); // if(isSpawnable(l)) {
// } // spawnable = true;
// } // player.teleport(l);
player.teleport(generateRandomCoord(9, Bukkit.getWorld("world"))); // }
} // }
}.runTaskLater(main, 100L); player.teleport(generateRandomCoord(9, Bukkit.getWorld("world")));
run(player, new int[]{5}); }
} }.runTaskLater(main, 100L);
} run(player, new int[]{5});
}
} }
public Location generateRandomCoord(int size, World world) {
int ranX = getRandomWithNeg(size), ranZ = getRandomWithNeg(size); }
Block block = world.getHighestBlockAt(ranX, ranZ); public Location generateRandomCoord(int size, World world) {
return block.getLocation(); int ranX = SpawnCommand.getRandomWithNeg(size), ranZ = SpawnCommand.getRandomWithNeg(size);
} Block block = world.getHighestBlockAt(ranX, ranZ);
public boolean isSpawnable(Location loc) { return block.getLocation();
Block feetBlock = loc.getBlock(), headBlock = loc.clone().add(0, 1, 0).getBlock(), upperBlock = loc.clone().add(0, 2, 0).getBlock(); }
return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid() && upperBlock.isPassable() && !upperBlock.isLiquid(); public boolean isSpawnable(Location loc) {
} Block feetBlock = loc.getBlock(), headBlock = loc.clone().add(0, 1, 0).getBlock(), upperBlock = loc.clone().add(0, 2, 0).getBlock();
private int taskID; return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid() && upperBlock.isPassable() && !upperBlock.isLiquid();
public void run(Player player, int[] a) { }
taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, () -> { private int taskID;
player.sendTitle(ChatColor.RED +"YOU DIED!",ChatColor.GREEN +"You will revive in " + a[0] + " seconds",0,20,0); public void run(Player player, int[] a) {
a[0]--; taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, () -> {
if (a[0] == 0) { player.sendTitle(ChatColor.RED +"YOU DIED!",ChatColor.GREEN +"You will revive in " + a[0] + " seconds",0,20,0);
Bukkit.getScheduler().cancelTask(taskID); a[0]--;
} if (a[0] == 0) {
}, 0L, 20L); Bukkit.getScheduler().cancelTask(taskID);
} }
}, 0L, 20L);
}
private final Map<UUID, Merchant> villagerlist = new HashMap<>();
@EventHandler
public void onClick(PlayerInteractEntityEvent e) {
Player p = e.getPlayer();
Entity clickedEntity = e.getRightClicked();
if (clickedEntity instanceof Creeper) {
if (p.getInventory().getItemInMainHand().getType() != Material.STICK) return;
clickedEntity.remove();
Location loc = clickedEntity.getLocation();
Villager villager = (Villager) p.getWorld().spawnEntity(loc, EntityType.VILLAGER);
villager.setProfession(Villager.Profession.TOOLSMITH);
List<MerchantRecipe> recipes = new ArrayList<>();
MerchantRecipe bread = new MerchantRecipe(new ItemStack(Material.BREAD, 3), 10);
bread.addIngredient(new ItemStack(Material.EMERALD, 10));
recipes.add(bread);
MerchantRecipe tntStick = new MerchantRecipe(CustomItemManager.getItem("Terminator"), 10);
tntStick.addIngredient(CustomItemManager.getItem("Widow Sword"));
recipes.add(tntStick);
Merchant merchant = Bukkit.createMerchant("Yum Yum In The Tum Tum");
merchant.setRecipes(recipes);
villagerlist.put(villager.getUniqueId(), merchant);
p.spawnParticle(Particle.END_ROD, loc, 30, 0, 1, 0, 0.2);
p.openMerchant(merchant, true);
}
if (e.getRightClicked() instanceof Villager) {
Merchant merchant = villagerlist.get(clickedEntity.getUniqueId());
if (merchant == null) return;
e.setCancelled(true);
p.openMerchant(merchant, true);
}
}
} }

View file

@ -1,205 +1,206 @@
package com.night.nullvalkyrie.Items; package me.night.nullvalkyrie.Items;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
import org.bukkit.configuration.MemorySection; import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
public class CustomItemManager { public class CustomItemManager {
private static HashMap<String, ItemStack> a = new HashMap<>(); private static HashMap<String, ItemStack> a = new HashMap<>();
private static Main main; private static Main main;
public CustomItemManager(Main main) { public CustomItemManager(Main main) {
this.main = main; this.main = main;
if(!main.getDataFolder().exists()) { if(!main.getDataFolder().exists()) {
main.getDataFolder().mkdir(); main.getDataFolder().mkdir();
} }
createItemDataDirectory("ItemData"); createDirectoryInPluginFolder("ItemData");
createFilesFromConfig(main.getConfig()); createFilesFromConfig(main.getConfig());
register(); register();
} }
public void register() { public void register() {
List<String> hh = getAllFilesFromDirectory("ItemData"); List<String> hh = getAllFilesFromDirectory("ItemData");
for(int kk = 0; kk < hh.size(); kk++) { for(int kk = 0; kk < hh.size(); kk++) {
FileConfiguration c = loadConfig("ItemData\\" + hh.get(kk)); FileConfiguration c = loadConfig("ItemData/" + hh.get(kk));
ItemStack i = new ItemStack(Material.matchMaterial(c.getString("material"))); ItemStack i = new ItemStack(Material.matchMaterial(c.getString("material")));
HashMap<String, List<String>> d = new HashMap<>(); HashMap<String, List<String>> d = new HashMap<>();
List<String> pr = new ArrayList<>(); List<String> pr = new ArrayList<>();
List<String> ia = new ArrayList<>(); List<String> ia = new ArrayList<>();
HashMap<String, Double> aa = new HashMap<>(); HashMap<String, Double> aa = new HashMap<>();
for (String key : c.getKeys(true)) { for (String key : c.getKeys(true)) {
if (key.startsWith("enchants.")) { if (key.startsWith("enchants.")) {
i.addUnsafeEnchantment(Enchantment.getByKey(NamespacedKey.minecraft(Arrays.asList(key.split("\\.")).get(1))), c.getInt(key)); i.addUnsafeEnchantment(Enchantment.getByKey(NamespacedKey.minecraft(Arrays.asList(key.split("\\.")).get(1))), c.getInt(key));
} else if (key.startsWith("lore.properties.")) { } else if (key.startsWith("lore.properties.")) {
String property = Arrays.asList(key.split("\\.")).get(2); String property = Arrays.asList(key.split("\\.")).get(2);
if (property.equals("damage") && c.getInt(key) > 0) { if (property.equals("damage") && c.getInt(key) > 0) {
pr.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+" + c.getInt(key)); pr.add(ChatColor.GRAY + "Damage: " + ChatColor.RED + "+" + c.getInt(key));
} else if (property.equals("speed") && c.getInt(key) > 0) { } else if (property.equals("speed") && c.getInt(key) > 0) {
pr.add(ChatColor.GRAY + "Speed: " + ChatColor.RED + "+" + c.getInt(key)); pr.add(ChatColor.GRAY + "Speed: " + ChatColor.RED + "+" + c.getInt(key));
} }
} else if (key.startsWith("lore.ability.")) { } else if (key.startsWith("lore.ability.")) {
String a = Arrays.asList(key.split("\\.")).get(2); String a = Arrays.asList(key.split("\\.")).get(2);
if (a.equals("name")) { if (a.equals("name")) {
ia.add(ChatColor.GOLD + "Item Ability: " + c.getString(key)); ia.add(ChatColor.GOLD + "Item Ability: " + c.getString(key));
} else if (a.equals("details")) { } else if (a.equals("details")) {
for (Object line : c.getList(key)) { for (Object line : c.getList(key)) {
ia.add(ChatColor.GRAY.toString() + line); ia.add(ChatColor.GRAY.toString() + line);
} }
} }
} else if (key.startsWith("attributes.")) { } else if (key.startsWith("attributes.")) {
if (c.getDouble(key) > 0.0) { if (c.getDouble(key) > 0.0) {
aa.put(Arrays.asList(key.split("\\.")).get(1), c.getDouble(key)); aa.put(Arrays.asList(key.split("\\.")).get(1), c.getDouble(key));
} }
} else if (key.startsWith("recipe.")) { } else if (key.startsWith("recipe.")) {
} }
} }
d.put("properties", pr); d.put("properties", pr);
d.put("ability", ia); d.put("ability", ia);
d.put("attributes", pr); d.put("attributes", pr);
ItemMeta im = i.getItemMeta(); ItemMeta im = i.getItemMeta();
im.setDisplayName(Rarity.getRarity(c.getString("rarity")).getColor() + c.getString("name")); im.setDisplayName(Rarity.getRarity(c.getString("rarity")).getColor() + c.getString("name"));
im.setUnbreakable(true); im.setUnbreakable(true);
ArrayList<String> l = new ArrayList<>(); ArrayList<String> l = new ArrayList<>();
l.addAll(d.get("properties")); l.addAll(d.get("properties"));
l.add(""); l.add("");
ArrayList<String> e = new ArrayList<>(); ArrayList<String> e = new ArrayList<>();
for (Enchantment ee : i.getEnchantments().keySet()) { for (Enchantment ee : i.getEnchantments().keySet()) {
List<String> splitted = Arrays.asList(Arrays.asList(ee.getKey().toString().split(":")).get(1).split("_")); List<String> splitted = Arrays.asList(Arrays.asList(ee.getKey().toString().split(":")).get(1).split("_"));
StringBuilder n = new StringBuilder(); StringBuilder n = new StringBuilder();
for (String ii : splitted) { for (String ii : splitted) {
String s = ii.substring(0, 1).toUpperCase() + ii.substring(1); String s = ii.substring(0, 1).toUpperCase() + ii.substring(1);
if (splitted.size() > 1) { if (splitted.size() > 1) {
if (ii.equals(splitted.get(splitted.size() - 1))) { if (ii.equals(splitted.get(splitted.size() - 1))) {
n.append(s); n.append(s);
} else { } else {
n.append(s); n.append(s);
n.append(" "); n.append(" ");
} }
} else n.append(s); } else n.append(s);
} }
e.add(n + " " + i.getEnchantmentLevel(ee)); e.add(n + " " + i.getEnchantmentLevel(ee));
} }
l.add(ChatColor.BLUE + String.join(", ", e)); l.add(ChatColor.BLUE + String.join(", ", e));
l.add(""); l.add("");
l.addAll(ia); l.addAll(ia);
l.add(""); l.add("");
l.add(Rarity.getRarity(c.getString("rarity")).getDisplay()); l.add(Rarity.getRarity(c.getString("rarity")).getDisplay());
im.setLore(l); im.setLore(l);
for (String q : aa.keySet()) { for (String q : aa.keySet()) {
if (q.equals("damage")) { if (q.equals("damage")) {
AttributeModifier p = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", aa.get(q), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND); AttributeModifier p = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", aa.get(q), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
im.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, p); im.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, p);
} else if (q.equals("moveSpeed")) { } else if (q.equals("moveSpeed")) {
AttributeModifier s = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", aa.get(q), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND); AttributeModifier s = new AttributeModifier(UUID.randomUUID(), "generic.movementSpeed", aa.get(q), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
im.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, s); im.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, s);
} }
} }
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS); im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
i.setItemMeta(im); i.setItemMeta(im);
a.put(c.getString("name"), i); a.put(c.getString("name"), i);
} }
} }
public static void setItemRecipe(NamespacedKey key, ItemStack i, int ingredient, String shape1, String shape2, String shape3, List<Material> ingredients) { public static void setItemRecipe(NamespacedKey key, ItemStack i, int ingredient, String shape1, String shape2, String shape3, List<Material> ingredients) {
// ShapedRecipe wither_sword_recipe = new ShapedRecipe(new NamespacedKey(main, "widow_sword"), widow_sword); // ShapedRecipe wither_sword_recipe = new ShapedRecipe(new NamespacedKey(main, "widow_sword"), widow_sword);
// wither_sword_recipe.shape(" A ", " A "," B "); // wither_sword_recipe.shape(" A ", " A "," B ");
// wither_sword_recipe.setIngredient('A', Material.IRON_INGOT); // wither_sword_recipe.setIngredient('A', Material.IRON_INGOT);
// wither_sword_recipe.setIngredient('B', Material.STICK); // wither_sword_recipe.setIngredient('B', Material.STICK);
// Bukkit.addRecipe(wither_sword_recipe); // Bukkit.addRecipe(wither_sword_recipe);
} }
public static YamlConfiguration loadConfig(String path) { public static YamlConfiguration loadConfig(String path) {
File f = new File(main.getDataFolder(), path); File f = new File(main.getDataFolder(), path);
if(!f.exists()) { if(!f.exists()) {
try { try {
f.createNewFile(); f.createNewFile();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return YamlConfiguration.loadConfiguration(f); return YamlConfiguration.loadConfiguration(f);
} }
public static File loadFile(String path) { public static File loadFile(String path) {
File f = new File(main.getDataFolder(), path); File f = new File(main.getDataFolder(), path);
if(!f.exists()) { if(!f.exists()) {
try { try {
f.createNewFile(); f.createNewFile();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return f; return f;
} }
private static void createItemDataDirectory(String path) { public static void createDirectoryInPluginFolder(String path) {
File f = new File(main.getDataFolder(), path); File f = new File(main.getDataFolder(), path);
if(!f.exists()) { if(!f.exists()) {
try { try {
if(!f.mkdir()) { if(!f.mkdir()) {
try { try {
f.mkdir(); f.mkdir();
} catch (SecurityException e) { } catch (SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} catch (SecurityException e) { } catch (SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
public static List<String> getAllFilesFromDirectory(String path) { public static List<String> getAllFilesFromDirectory(String path) {
ArrayList<String> ns = new ArrayList<>(); ArrayList<String> ns = new ArrayList<>();
try { try {
File f = new File(main.getDataFolder(), path); File f = new File(main.getDataFolder(), path);
File[] files = f.listFiles(); File[] files = f.listFiles();
for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
ns.add(files[i].getName()); System.out.println(files[i].getName());
} ns.add(files[i].getName());
} catch (Exception e) { }
e.printStackTrace(); } catch (Exception e) {
} e.printStackTrace();
return ns; }
} return ns;
public void createFilesFromConfig(FileConfiguration config) { }
for(String a : config.getKeys(false)) { public void createFilesFromConfig(FileConfiguration config) {
FileConfiguration c = loadConfig("ItemData\\" + a + ".yml"); for(String a : config.getKeys(false)) {
for(String b : config.getKeys(true)) { FileConfiguration c = loadConfig("ItemData/" + a + ".yml");
if(b.startsWith(a)) { for(String b : config.getKeys(true)) {
List<String> d = new ArrayList<>(Arrays.asList(b.split("\\."))); if(b.startsWith(a)) {
if(d.size() != 1) { List<String> d = new ArrayList<>(Arrays.asList(b.split("\\.")));
d.remove(0); if(d.size() != 1) {
if(d.size() == 1) { d.remove(0);
c.set(d.get(0), config.get(b)); if(d.size() == 1) {
} else { c.set(d.get(0), config.get(b));
c.set(String.join(".", d), config.get(b)); } else {
} c.set(String.join(".", d), config.get(b));
try { }
c.save(loadFile("ItemData\\" + a + ".yml")); try {
} catch (IOException e) { c.save(loadFile("ItemData/" + a + ".yml"));
e.printStackTrace(); } catch (IOException e) {
} e.printStackTrace();
} }
}
}
} }
} }
} }
public static ItemStack getItem(String name){ }
return a.get(name); public static ItemStack getItem(String name){
} return a.get(name);
} }
}

View file

@ -1,47 +1,47 @@
package com.night.nullvalkyrie.Items; package me.night.nullvalkyrie.Items;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
public enum Rarity { public enum Rarity {
COMMON(ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON", ChatColor.WHITE.toString()), COMMON(ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON", ChatColor.WHITE.toString()),
UNCOMMON(net.md_5.bungee.api.ChatColor.of("#31ff09").toString() + ChatColor.BOLD + "UNCOMMON", net.md_5.bungee.api.ChatColor.of("#31ff09").toString()), UNCOMMON(net.md_5.bungee.api.ChatColor.of("#31ff09").toString() + ChatColor.BOLD + "UNCOMMON", net.md_5.bungee.api.ChatColor.of("#31ff09").toString()),
RARE(net.md_5.bungee.api.ChatColor.of("#2f57ae").toString() + ChatColor.BOLD + "RARE", net.md_5.bungee.api.ChatColor.of("#2f57ae").toString()), RARE(net.md_5.bungee.api.ChatColor.of("#2f57ae").toString() + ChatColor.BOLD + "RARE", net.md_5.bungee.api.ChatColor.of("#2f57ae").toString()),
EPIC(net.md_5.bungee.api.ChatColor.of("#b201b2").toString() + ChatColor.BOLD + "EPIC", net.md_5.bungee.api.ChatColor.of("#b201b2").toString()), EPIC(net.md_5.bungee.api.ChatColor.of("#b201b2").toString() + ChatColor.BOLD + "EPIC", net.md_5.bungee.api.ChatColor.of("#b201b2").toString()),
LEGENDARY(net.md_5.bungee.api.ChatColor.of("#ffa21b").toString() + ChatColor.BOLD + "LEGENDARY", net.md_5.bungee.api.ChatColor.of("#ffa21b").toString()), LEGENDARY(net.md_5.bungee.api.ChatColor.of("#ffa21b").toString() + ChatColor.BOLD + "LEGENDARY", net.md_5.bungee.api.ChatColor.of("#ffa21b").toString()),
MYTHIC(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC", net.md_5.bungee.api.ChatColor.of("#ff23ff").toString()), MYTHIC(net.md_5.bungee.api.ChatColor.of("#ff23ff").toString() + ChatColor.BOLD + "MYTHIC", net.md_5.bungee.api.ChatColor.of("#ff23ff").toString()),
ULTRA(ChatColor.RED.toString() + ChatColor.BOLD + "ULTRA", ChatColor.RED.toString()), ULTRA(ChatColor.RED.toString() + ChatColor.BOLD + "ULTRA", ChatColor.RED.toString()),
GRAND(net.md_5.bungee.api.ChatColor.of("#00fdff").toString() + ChatColor.BOLD + "GRAND", net.md_5.bungee.api.ChatColor.of("#00fdff").toString()); GRAND(net.md_5.bungee.api.ChatColor.of("#00fdff").toString() + ChatColor.BOLD + "GRAND", net.md_5.bungee.api.ChatColor.of("#00fdff").toString());
private String display; private String display;
private String color; private String color;
Rarity(String display, String color) { Rarity(String display, String color) {
this.display = display; this.display = display;
this.color = color; this.color = color;
} }
public String getDisplay() { public String getDisplay() {
return display; return display;
} }
public String getColor() { public String getColor() {
return color; return color;
} }
public static Rarity getRarity(String str) { public static Rarity getRarity(String str) {
switch(str) { switch(str) {
case "COMMON": case "COMMON":
return COMMON; return COMMON;
case "UNCOMMON": case "UNCOMMON":
return UNCOMMON; return UNCOMMON;
case "RARE": case "RARE":
return RARE; return RARE;
case "EPIC": case "EPIC":
return EPIC; return EPIC;
case "LEGENDARY": case "LEGENDARY":
return LEGENDARY; return LEGENDARY;
case "MYTHIC": case "MYTHIC":
return MYTHIC; return MYTHIC;
case "ULTRA": case "ULTRA":
return ULTRA; return ULTRA;
case "GRAND": case "GRAND":
return GRAND; return GRAND;
default: default:
return COMMON; return COMMON;
} }
} }
} }

View file

@ -1,13 +1,13 @@
package com.night.nullvalkyrie; package me.night.nullvalkyrie;
import com.night.nullvalkyrie.Chests.MenuListener; import me.night.nullvalkyrie.Chests.MenuListener;
import com.night.nullvalkyrie.Discord.DiscordClientManager; import me.night.nullvalkyrie.Discord.DiscordClientManager;
import com.night.nullvalkyrie.Enchantments.EnchantmentManager; import me.night.nullvalkyrie.Enchantments.EnchantmentManager;
import com.night.nullvalkyrie.Events.CustomItemEvents; import me.night.nullvalkyrie.Events.CustomItemEvents;
import com.night.nullvalkyrie.Items.CustomItemManager; import me.night.nullvalkyrie.Items.CustomItemManager;
import com.night.nullvalkyrie.Rank.*; import me.night.nullvalkyrie.Rank.ScoreboardListener;
import com.night.nullvalkyrie.Util.Util; import me.night.nullvalkyrie.Util.Util;
import com.night.nullvalkyrie.commands.*; import me.night.nullvalkyrie.commands.*;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*; import org.bukkit.*;
@ -45,6 +45,7 @@ public final class Main extends JavaPlugin implements Listener {
new RankCommand(this); new RankCommand(this);
new UtilCommand(this); new UtilCommand(this);
new WeaponCommand(this); new WeaponCommand(this);
new MinerCommand(this);
bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12); bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new MenuListener(), this); Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
@ -53,7 +54,6 @@ public final class Main extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(new SpawnCommand(this), this); Bukkit.getPluginManager().registerEvents(new SpawnCommand(this), this);
new EnchantmentManager(); new EnchantmentManager();
new DiscordClientManager(); new DiscordClientManager();
customItemManager = new CustomItemManager(this); customItemManager = new CustomItemManager(this);
} }

View file

@ -1,3 +1,3 @@
name: Zombie name: Zombie
level: 69 level: 69
health: 1000 health: 1000

View file

@ -1,18 +1,18 @@
package com.night.nullvalkyrie.Rank; package me.night.nullvalkyrie.Rank;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
public class BelowNameManager { public class BelowNameManager {
public void setBelowName(Player player) { public void setBelowName(Player player) {
Scoreboard board = player.getScoreboard(); Scoreboard board = player.getScoreboard();
Objective obj = board.registerNewObjective("HealthBar", "health"); Objective obj = board.registerNewObjective("HealthBar", "health");
obj.setDisplaySlot(DisplaySlot.BELOW_NAME); obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
obj.setDisplayName(ChatColor.RED + ""); obj.setDisplayName(ChatColor.RED + "");
player.setScoreboard(board); player.setScoreboard(board);
player.setHealth(player.getHealth()); player.setHealth(player.getHealth());
} }
} }

View file

@ -1,47 +1,45 @@
package com.night.nullvalkyrie.Rank; package me.night.nullvalkyrie.Rank;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import static com.night.nullvalkyrie.Rank.ScoreboardListener.rankManager; public class NameTagManager {
private Main main;
public class NameTagManager {
private Main main; public NameTagManager(Main main) {
this.main = main;
public NameTagManager(Main main) { }
this.main = main; @SuppressWarnings("deprecation")
} public void setNametags(Player player) {
@SuppressWarnings("deprecation") Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
public void setNametags(Player player) { Objective obj = newScoreboard.registerNewObjective("TabList", "dummy");
Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); obj.setDisplaySlot(DisplaySlot.PLAYER_LIST);
Objective obj = newScoreboard.registerNewObjective("TabList", "dummy"); player.setScoreboard(newScoreboard);
obj.setDisplaySlot(DisplaySlot.PLAYER_LIST); for (Rank rank : Rank.values()) {
player.setScoreboard(newScoreboard); Team team = player.getScoreboard().registerNewTeam(rank.name());
for (Rank rank : Rank.values()) { team.setPrefix(rank.getDisplay() + " ");
Team team = player.getScoreboard().registerNewTeam(rank.name()); }
team.setPrefix(rank.getDisplay() + " "); for (Player target : Bukkit.getOnlinePlayers()) {
} if (player.getUniqueId() != target.getUniqueId()) {
for (Player target : Bukkit.getOnlinePlayers()) { Rank rank = ScoreboardListener.rankManager.getRank(target.getUniqueId());
if (player.getUniqueId() != target.getUniqueId()) { player.getScoreboard().getTeam(rank.name()).addEntry(target.getName());
Rank rank = rankManager.getRank(target.getUniqueId()); }
player.getScoreboard().getTeam(rank.name()).addEntry(target.getName()); }
} }
} public void newTag(Player player) {
} Rank rank = ScoreboardListener.rankManager.getRank(player.getUniqueId());
public void newTag(Player player) { for(Player target : Bukkit.getOnlinePlayers()) {
Rank rank = rankManager.getRank(player.getUniqueId()); target.getScoreboard().getTeam(rank.name()).addEntry(player.getName());
for(Player target : Bukkit.getOnlinePlayers()) { }
target.getScoreboard().getTeam(rank.name()).addEntry(player.getName()); }
} public void removeTag(Player player) {
} for(Player target : Bukkit.getOnlinePlayers()) {
public void removeTag(Player player) { target.getScoreboard().getEntryTeam(player.getName()).removeEntry(player.getName());
for(Player target : Bukkit.getOnlinePlayers()) { }
target.getScoreboard().getEntryTeam(player.getName()).removeEntry(player.getName()); }
} }
}
}

View file

@ -1,20 +1,20 @@
package com.night.nullvalkyrie.Rank; package me.night.nullvalkyrie.Rank;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
public enum Rank { public enum Rank {
OWNER(ChatColor.DARK_RED + "{OWNER}"), OWNER(ChatColor.DARK_RED + "{OWNER}"),
ADMIN(ChatColor.RED + "{ADMIN}"), ADMIN(ChatColor.RED + "{ADMIN}"),
SPECIAL(ChatColor.GOLD + "{SPECIAL}"), SPECIAL(ChatColor.GOLD + "{SPECIAL}"),
ROOKIE(ChatColor.DARK_GREEN + "{ROOKIE}"); ROOKIE(ChatColor.DARK_GREEN + "{ROOKIE}");
private String display; private String display;
Rank(String display) { Rank(String display) {
this.display = display; this.display = display;
} }
public String getDisplay() { public String getDisplay() {
return display; return display;
} }
} }

View file

@ -1,52 +1,52 @@
package com.night.nullvalkyrie.Rank; package me.night.nullvalkyrie.Rank;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import static com.night.nullvalkyrie.Rank.ScoreboardListener.nameTagManager; import static me.night.nullvalkyrie.Rank.ScoreboardListener.nameTagManager;
public class RankManager { public class RankManager {
private File file; private File file;
private YamlConfiguration config; private YamlConfiguration config;
private Main main; private Main main;
public RankManager(Main main) { public RankManager(Main main) {
this.main = main; this.main = main;
if(!main.getDataFolder().exists()) { if(!main.getDataFolder().exists()) {
main.getDataFolder().mkdir(); main.getDataFolder().mkdir();
} }
file = new File(main.getDataFolder(), "ranks.yml"); file = new File(main.getDataFolder(), "ranks.yml");
if(!file.exists()) { if(!file.exists()) {
try { try {
file.createNewFile(); file.createNewFile();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
config = YamlConfiguration.loadConfiguration(file); config = YamlConfiguration.loadConfiguration(file);
} }
public void setRank(UUID uuid, Rank rank) { public void setRank(UUID uuid, Rank rank) {
config.set(uuid.toString(), rank.name()); config.set(uuid.toString(), rank.name());
try { try {
config.save(file); config.save(file);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
for(Player player : Bukkit.getOnlinePlayers()) { for(Player player : Bukkit.getOnlinePlayers()) {
if(player.hasPlayedBefore()) { if(player.hasPlayedBefore()) {
nameTagManager.removeTag(player); nameTagManager.removeTag(player);
nameTagManager.newTag(player); nameTagManager.newTag(player);
} }
} }
} }
public Rank getRank(UUID uuid) { public Rank getRank(UUID uuid) {
return Rank.valueOf(config.getString(uuid.toString())); return Rank.valueOf(config.getString(uuid.toString()));
} }
} }

View file

@ -1,61 +1,61 @@
package com.night.nullvalkyrie.Rank; package me.night.nullvalkyrie.Rank;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
public class ScoreboardListener implements Listener { public class ScoreboardListener implements Listener {
public static RankManager rankManager; public static RankManager rankManager;
public static NameTagManager nameTagManager; public static NameTagManager nameTagManager;
private SideBarManager sideBarManager; private SideBarManager sideBarManager;
private BelowNameManager belowNameManager; private BelowNameManager belowNameManager;
public ScoreboardListener(Main main) { public ScoreboardListener(Main main) {
nameTagManager = new NameTagManager(main); nameTagManager = new NameTagManager(main);
rankManager = new RankManager(main); rankManager = new RankManager(main);
sideBarManager = new SideBarManager(); sideBarManager = new SideBarManager();
belowNameManager = new BelowNameManager(); belowNameManager = new BelowNameManager();
} }
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
if(!player.hasPlayedBefore()) { if(!player.hasPlayedBefore()) {
e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20); e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20);
rankManager.setRank(player.getUniqueId(), Rank.ROOKIE); rankManager.setRank(player.getUniqueId(), Rank.ROOKIE);
} }
e.getPlayer().setPlayerListHeaderFooter(ChatColor.AQUA + "You are playing on " + ChatColor.GREEN + "127.0.0.1", ChatColor.GOLD + "Ranks, boosters, & more!" + ChatColor.AQUA + "127.0.0.1"); e.getPlayer().setPlayerListHeaderFooter(ChatColor.AQUA + "You are playing on " + ChatColor.GREEN + "127.0.0.1", ChatColor.GOLD + "Ranks, boosters, & more!" + ChatColor.AQUA + "127.0.0.1");
nameTagManager.setNametags(player); nameTagManager.setNametags(player);
nameTagManager.newTag(player); nameTagManager.newTag(player);
sideBarManager.setSideBar(player); sideBarManager.setSideBar(player);
belowNameManager.setBelowName(player); belowNameManager.setBelowName(player);
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!");
} }
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent e) { public void onQuit(PlayerQuitEvent e) {
e.setQuitMessage(ChatColor.RED + "bozo " + e.getPlayer().getName() + " has left."); e.setQuitMessage(ChatColor.RED + "bozo " + e.getPlayer().getName() + " has left.");
nameTagManager.removeTag(e.getPlayer()); nameTagManager.removeTag(e.getPlayer());
e.getPlayer().setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); e.getPlayer().setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
} }
@EventHandler @EventHandler
public void onChat(AsyncPlayerChatEvent e) { public void onChat(AsyncPlayerChatEvent e) {
e.setCancelled(true); e.setCancelled(true);
Player player = e.getPlayer(); Player player = e.getPlayer();
Bukkit.broadcastMessage(rankManager.getRank(player.getUniqueId()).getDisplay() + " " + player.getName() + ChatColor.WHITE + ": " + e.getMessage()); Bukkit.broadcastMessage(rankManager.getRank(player.getUniqueId()).getDisplay() + " " + player.getName() + ChatColor.WHITE + ": " + e.getMessage());
} }
//Death changing in sidebar //Death changing in sidebar
@EventHandler @EventHandler
public void onDeath(PlayerDeathEvent e) { public void onDeath(PlayerDeathEvent e) {
sideBarManager.changeOnDeath(e.getEntity().getPlayer()); sideBarManager.changeOnDeath(e.getEntity().getPlayer());
} }
} }

View file

@ -1,51 +1,50 @@
package com.night.nullvalkyrie.Rank; package me.night.nullvalkyrie.Rank;
import com.night.nullvalkyrie.Main; import org.bukkit.Bukkit;
import org.bukkit.Bukkit; import org.bukkit.ChatColor;
import org.bukkit.ChatColor; import org.bukkit.entity.Player;
import org.bukkit.entity.Player; import org.bukkit.scoreboard.*;
import org.bukkit.scoreboard.*; import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Scoreboard;
import java.util.HashMap;
import java.util.HashMap; import java.util.UUID;
import java.util.UUID;
public class SideBarManager {
public class SideBarManager { private final HashMap<UUID, Integer> deaths = new HashMap<>();
private final HashMap<UUID, Integer> deaths = new HashMap<>(); @SuppressWarnings("deprecation")
@SuppressWarnings("deprecation") public void setSideBar(Player player) {
public void setSideBar(Player player) { Scoreboard board = player.getScoreboard();
Scoreboard board = player.getScoreboard(); Objective obj = board.registerNewObjective("Pluto", "dummy");
Objective obj = board.registerNewObjective("Pluto", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR);
obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + "Pluto");
obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + "Pluto"); Score name = obj.getScore(ChatColor.BLUE + "Player Name: ");
Score name = obj.getScore(ChatColor.BLUE + "Player Name: "); name.setScore(8);
name.setScore(8); Score name2 = obj.getScore(ChatColor.WHITE + player.getName());
Score name2 = obj.getScore(ChatColor.WHITE + player.getName()); name2.setScore(7);
name2.setScore(7); Score space1 = obj.getScore(" ");
Score space1 = obj.getScore(" "); space1.setScore(6);
space1.setScore(6); Score players = obj.getScore(ChatColor.LIGHT_PURPLE + "Players Online:");
Score players = obj.getScore(ChatColor.LIGHT_PURPLE + "Players Online:"); players.setScore(5);
players.setScore(5); Score playercount = obj.getScore(ChatColor.YELLOW.toString() + Bukkit.getServer().getOnlinePlayers().size());
Score playercount = obj.getScore(ChatColor.YELLOW.toString() + Bukkit.getServer().getOnlinePlayers().size()); playercount.setScore(4);
playercount.setScore(4); Score space2 = obj.getScore(" ");
Score space2 = obj.getScore(" "); space2.setScore(2);
space2.setScore(2); Score website = obj.getScore(ChatColor.YELLOW + "cath.js.org");
Score website = obj.getScore(ChatColor.YELLOW + "cath.js.org"); website.setScore(1);
website.setScore(1);
Team playersOnline = board.registerNewTeam("deathsTotal");
Team playersOnline = board.registerNewTeam("deathsTotal"); playersOnline.addEntry(ChatColor.BOLD.toString());
playersOnline.addEntry(ChatColor.BOLD.toString()); playersOnline.setPrefix(ChatColor.BLUE + "Deaths: ");
playersOnline.setPrefix(ChatColor.BLUE + "Deaths: "); playersOnline.setSuffix(ChatColor.YELLOW + "0");
playersOnline.setSuffix(ChatColor.YELLOW + "0"); obj.getScore(ChatColor.BOLD.toString()).setScore(3);
obj.getScore(ChatColor.BOLD.toString()).setScore(3); player.setScoreboard(board);
player.setScoreboard(board); deaths.put(player.getUniqueId(), 0);
deaths.put(player.getUniqueId(), 0); }
}
public void changeOnDeath(Player player) {
public void changeOnDeath(Player player) { int amount = deaths.get(player.getUniqueId());
int amount = deaths.get(player.getUniqueId()); amount++;
amount++; deaths.put(player.getUniqueId(), amount++);
deaths.put(player.getUniqueId(), amount++); player.getScoreboard().getTeam("deathsTotal").setSuffix(ChatColor.YELLOW.toString() + amount);
player.getScoreboard().getTeam("deathsTotal").setSuffix(ChatColor.YELLOW.toString() + amount); }
} }
}

View file

@ -1,17 +1,17 @@
package com.night.nullvalkyrie.Util; package me.night.nullvalkyrie.Util;
public class Util { public class Util {
public static String centerText(String text, int lineLength) { public static String centerText(String text, int lineLength) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
char space = ' '; char space = ' ';
int distance = (lineLength - text.length()) / 2; int distance = (lineLength - text.length()) / 2;
for (int ii = 0; ii < distance; ii++) { for (int ii = 0; ii < distance; ii++) {
builder.append(space); builder.append(space);
} }
builder.append(text); builder.append(text);
for (int i = 0; i < distance; ++i) { for (int i = 0; i < distance; ++i) {
builder.append(space); builder.append(space);
} }
return builder.toString(); return builder.toString();
} }
} }

View file

@ -1,49 +1,49 @@
package com.night.nullvalkyrie.Util; package me.night.nullvalkyrie.Util;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Utils { public class Utils {
public static String color(String string) { public static String color(String string) {
return ChatColor.translateAlternateColorCodes('&', string); return ChatColor.translateAlternateColorCodes('&', string);
} }
public static ItemStack createItem(Material type, int amount, String name, String... lines) { public static ItemStack createItem(Material type, int amount, String name, String... lines) {
ItemStack item = new ItemStack(type, amount); ItemStack item = new ItemStack(type, amount);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setUnbreakable(true); meta.setUnbreakable(true);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS); meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
if (name != null) meta.setDisplayName(color(name)); if (name != null) meta.setDisplayName(color(name));
if (lines != null) { if (lines != null) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
for (String line : lines) { for (String line : lines) {
lore.add(color(line)); lore.add(color(line));
} }
meta.setLore(lore); meta.setLore(lore);
} }
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
public static ItemStack enchantItem(ItemStack item, Enchantment enchant, int level) { public static ItemStack enchantItem(ItemStack item, Enchantment enchant, int level) {
item.addUnsafeEnchantment(enchant, level); item.addUnsafeEnchantment(enchant, level);
return item; return item;
} }
public static ItemStack[] makeArmorSet(ItemStack helmet, ItemStack chestplate, ItemStack leggings, ItemStack boots) { public static ItemStack[] makeArmorSet(ItemStack helmet, ItemStack chestplate, ItemStack leggings, ItemStack boots) {
ItemStack[] armor = new ItemStack[4]; ItemStack[] armor = new ItemStack[4];
armor[3] = helmet; armor[3] = helmet;
armor[2] = chestplate; armor[2] = chestplate;
armor[1] = leggings; armor[1] = leggings;
armor[0] = boots; armor[0] = boots;
return armor; return armor;
} }
} }

View file

@ -1,111 +1,111 @@
package com.night.nullvalkyrie.Util.components; package me.night.nullvalkyrie.Util.components;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static com.night.nullvalkyrie.Util.Utils.color; import static me.night.nullvalkyrie.Util.Utils.color;
import static com.night.nullvalkyrie.Util.Utils.*; import static me.night.nullvalkyrie.Util.Utils.*;
public enum CustomMob { public enum CustomMob {
DESERT_RISEN( DESERT_RISEN(
"&6Desert Risen", "&6Desert Risen",
2048, 2048,
60, 60,
EntityType.HUSK, EntityType.HUSK,
null, null,
null, null,
new LootItem(createItem(Material.ROTTEN_FLESH, 1, "&fPreserved Flesh", "&7A preserved flesh from a rotting corpse", "&7Not sure what you'd want this for, though", "&7", "&9Foodstuff"), 1, 3, 100)), new LootItem(createItem(Material.ROTTEN_FLESH, 1, "&fPreserved Flesh", "&7A preserved flesh from a rotting corpse", "&7Not sure what you'd want this for, though", "&7", "&9Foodstuff"), 1, 3, 100)),
SKELETAL_MAGE( SKELETAL_MAGE(
"&dSkeletal Mage", "&dSkeletal Mage",
2048, 2048,
15, 15,
EntityType.SKELETON, EntityType.SKELETON,
createItem(Material.BONE, 1, null), makeArmorSet(new ItemStack(Material.IRON_HELMET), createItem(Material.BONE, 1, null), makeArmorSet(new ItemStack(Material.IRON_HELMET),
null, null,
null, null,
null), null),
new LootItem(createItem(Material.BONE, 1, "&dBone Wand", "&7A wand made from skeletal bones"), 30), new LootItem(createItem(Material.BONE, 1, "&dBone Wand", "&7A wand made from skeletal bones"), 30),
new LootItem(new ItemStack(Material.BONE), 1, 3, 100)), new LootItem(new ItemStack(Material.BONE), 1, 3, 100)),
ZOMBIE_SQUIRE( ZOMBIE_SQUIRE(
"&bZombie Squire", "&bZombie Squire",
2048, 2048,
12, 12,
EntityType.ZOMBIE, EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD), new ItemStack(Material.IRON_SWORD),
makeArmorSet(new ItemStack(Material.CHAINMAIL_HELMET), new ItemStack(Material.CHAINMAIL_CHESTPLATE), new ItemStack(Material.CHAINMAIL_LEGGINGS), new ItemStack(Material.IRON_BOOTS)), new LootItem(new ItemStack(Material.CHAINMAIL_CHESTPLATE), 35), new LootItem(new ItemStack(Material.CHAINMAIL_LEGGINGS), 35), new LootItem(new ItemStack(Material.CHAINMAIL_HELMET), 35), new LootItem(new ItemStack(Material.IRON_BOOTS), 25), new LootItem(new ItemStack(Material.IRON_SWORD), 40)), makeArmorSet(new ItemStack(Material.CHAINMAIL_HELMET), new ItemStack(Material.CHAINMAIL_CHESTPLATE), new ItemStack(Material.CHAINMAIL_LEGGINGS), new ItemStack(Material.IRON_BOOTS)), new LootItem(new ItemStack(Material.CHAINMAIL_CHESTPLATE), 35), new LootItem(new ItemStack(Material.CHAINMAIL_LEGGINGS), 35), new LootItem(new ItemStack(Material.CHAINMAIL_HELMET), 35), new LootItem(new ItemStack(Material.IRON_BOOTS), 25), new LootItem(new ItemStack(Material.IRON_SWORD), 40)),
CHARRED_ARCHER( CHARRED_ARCHER(
"&8Charred Archer", "&8Charred Archer",
2048, 2048,
3, 3,
EntityType.WITHER_SKELETON, EntityType.WITHER_SKELETON,
enchantItem(new ItemStack(Material.BOW), Enchantment.ARROW_KNOCKBACK, 2), enchantItem(new ItemStack(Material.BOW), Enchantment.ARROW_KNOCKBACK, 2),
null, new LootItem(enchantItem(enchantItem(createItem(Material.BOW, 1, "&cBurnt Bow", "&7This bow is burnt to a crisp but remains intact", "&8due to special enchantments"), Enchantment.ARROW_FIRE, 1), Enchantment.ARROW_KNOCKBACK, 2), 100), null, new LootItem(enchantItem(enchantItem(createItem(Material.BOW, 1, "&cBurnt Bow", "&7This bow is burnt to a crisp but remains intact", "&8due to special enchantments"), Enchantment.ARROW_FIRE, 1), Enchantment.ARROW_KNOCKBACK, 2), 100),
new LootItem(new ItemStack(Material.BONE), 1, 5, 100)), new LootItem(new ItemStack(Material.BONE), 1, 5, 100)),
; ;
private String name; private String name;
private double maxHealth, spawnChance; private double maxHealth, spawnChance;
private EntityType type; private EntityType type;
private ItemStack mainItem; private ItemStack mainItem;
private ItemStack[] armor; private ItemStack[] armor;
private List<LootItem> lootTable; private List<LootItem> lootTable;
CustomMob(String name, double maxHealth, double spawnChance, EntityType type, ItemStack mainItem, ItemStack[] armor, LootItem... lootItems) { CustomMob(String name, double maxHealth, double spawnChance, EntityType type, ItemStack mainItem, ItemStack[] armor, LootItem... lootItems) {
this.name = name; this.name = name;
this.maxHealth = maxHealth; this.maxHealth = maxHealth;
this.spawnChance = spawnChance; this.spawnChance = spawnChance;
this.type = type; this.type = type;
this.mainItem = mainItem; this.mainItem = mainItem;
this.armor = armor; this.armor = armor;
lootTable = Arrays.asList(lootItems); lootTable = Arrays.asList(lootItems);
} }
public LivingEntity spawn(Location location) { public LivingEntity spawn(Location location) {
LivingEntity entity = (LivingEntity) location.getWorld().spawnEntity(location, type); LivingEntity entity = (LivingEntity) location.getWorld().spawnEntity(location, type);
entity.setCustomNameVisible(true); entity.setCustomNameVisible(true);
entity.setCustomName(color(name + " &r&c" + (int) maxHealth + "/" + (int) maxHealth + "")); entity.setCustomName(color(name + " &r&c" + (int) maxHealth + "/" + (int) maxHealth + ""));
entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(maxHealth); entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(maxHealth);
entity.setHealth(maxHealth); entity.setHealth(maxHealth);
EntityEquipment inv = entity.getEquipment(); EntityEquipment inv = entity.getEquipment();
if (armor != null) inv.setArmorContents(armor); if (armor != null) inv.setArmorContents(armor);
inv.setHelmetDropChance(0f); inv.setHelmetDropChance(0f);
inv.setChestplateDropChance(0f); inv.setChestplateDropChance(0f);
inv.setLeggingsDropChance(0f); inv.setLeggingsDropChance(0f);
inv.setBootsDropChance(0f); inv.setBootsDropChance(0f);
inv.setItemInMainHand(mainItem); inv.setItemInMainHand(mainItem);
inv.setItemInMainHandDropChance(0f); inv.setItemInMainHandDropChance(0f);
return entity; return entity;
} }
public void tryDropLoot(Location location) { public void tryDropLoot(Location location) {
for (LootItem item : lootTable) { for (LootItem item : lootTable) {
item.tryDropItem(location); item.tryDropItem(location);
} }
} }
public String getName() { public String getName() {
return name; return name;
} }
public double getMaxHealth() { public double getMaxHealth() {
return maxHealth; return maxHealth;
} }
public double getSpawnChance() { public double getSpawnChance() {
return spawnChance; return spawnChance;
} }
} }

View file

@ -1,36 +1,36 @@
package com.night.nullvalkyrie.Util.components; package me.night.nullvalkyrie.Util.components;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Random; import java.util.Random;
public class LootItem { public class LootItem {
private ItemStack item; private ItemStack item;
private int min = 1, max = 1; private int min = 1, max = 1;
private double dropRate; private double dropRate;
private static Random randomiser = new Random(); private static Random randomiser = new Random();
public LootItem(ItemStack item, double dropRate) { public LootItem(ItemStack item, double dropRate) {
this.item = item; this.item = item;
this.dropRate = dropRate; this.dropRate = dropRate;
} }
public LootItem(ItemStack item, int min, int max, double dropRate) { public LootItem(ItemStack item, int min, int max, double dropRate) {
this.item = item; this.item = item;
this.min = min; this.min = min;
this.max = max; this.max = max;
this.dropRate = dropRate; this.dropRate = dropRate;
} }
public void tryDropItem(Location loc) { public void tryDropItem(Location loc) {
if (Math.random() * 101 > dropRate) return; if (Math.random() * 101 > dropRate) return;
int amount = randomiser.nextInt(max - min + 1) + min; int amount = randomiser.nextInt(max - min + 1) + min;
if (amount == 0) return; if (amount == 0) return;
ItemStack item = this.item.clone(); ItemStack item = this.item.clone();
item.setAmount(amount); item.setAmount(amount);
loc.getWorld().dropItemNaturally(loc, item); loc.getWorld().dropItemNaturally(loc, item);
} }
} }

View file

@ -1,44 +1,44 @@
package com.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.CraftHumanEntity;
//import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; //import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
//import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage; //import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class AnvilCommand extends Command { public class AnvilCommand extends Command {
public AnvilCommand() { public AnvilCommand() {
super( super(
"anvil", "anvil",
new String[]{"av"}, new String[]{"av"},
"Open anvil", "Open anvil",
"" ""
); );
} }
@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;
// CraftPlayer craftPlayer = (CraftPlayer) player; // CraftPlayer craftPlayer = (CraftPlayer) player;
// EntityPlayer entityPlayer = craftPlayer.getHandle(); // EntityPlayer entityPlayer = craftPlayer.getHandle();
// int id = 0; // int id = 0;
// PacketPlayOutOpenWindow OpenWindow = new PacketPlayOutOpenWindow(id, Containers.h, CraftChatMessage.fromStringOrNull("Test")); // PacketPlayOutOpenWindow OpenWindow = new PacketPlayOutOpenWindow(id, Containers.h, CraftChatMessage.fromStringOrNull("Test"));
// PlayerConnection playerConnection = entityPlayer.b; // PlayerConnection playerConnection = entityPlayer.b;
// playerConnection.a(OpenWindow); // playerConnection.a(OpenWindow);
} }
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
return null; return null;
} }
} }

View file

@ -1,77 +1,77 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
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; import org.bukkit.util.StringUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class ArmorCommand extends Command { public class ArmorCommand extends Command {
public ArmorCommand() { public ArmorCommand() {
super( super(
"armor", "armor",
new String[]{}, new String[]{},
"Give you a set of armor", "Give you a set of armor",
"" ""
); );
} }
@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);
} }
} }
@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<>());
} }
return new ArrayList<>(); return new ArrayList<>();
} }
} }

View file

@ -1,45 +1,45 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.command.defaults.BukkitCommand;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public abstract class Command extends BukkitCommand { public abstract class Command extends BukkitCommand {
public Command(String command, String[] aliases, String description, String permission) { public Command(String command, String[] aliases, String description, String permission) {
super(command); super(command);
this.setAliases(Arrays.asList(aliases)); this.setAliases(Arrays.asList(aliases));
this.setDescription(description); this.setDescription(description);
this.setPermission(permission); this.setPermission(permission);
this.setPermission(ChatColor.RED + "You must have" + permission + "in order to use this command"); this.setPermission(ChatColor.RED + "You must have" + permission + "in order to use this command");
try { try {
Field field = Bukkit.getServer().getClass().getDeclaredField("commandMap"); Field field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
field.setAccessible(true); field.setAccessible(true);
CommandMap map = (CommandMap) field.get(Bukkit.getServer()); CommandMap map = (CommandMap) field.get(Bukkit.getServer());
map.register(command, this); map.register(command, this);
} catch (NoSuchFieldException | IllegalAccessException e) { } catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Override @Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) { public boolean execute(CommandSender sender, String commandLabel, String[] args) {
onCommand(sender, args); onCommand(sender, args);
return false; return false;
} }
@Override @Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
return onTabComplete(sender, args); return onTabComplete(sender, args);
} }
public abstract void onCommand(CommandSender sender, String[] args); public abstract void onCommand(CommandSender sender, String[] args);
public abstract List<String> onTabComplete(CommandSender sender, String[] args); public abstract List<String> onTabComplete(CommandSender sender, String[] args);
} }

View file

@ -1,32 +1,32 @@
package com.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;
import java.util.List; import java.util.List;
public class CraftCommand extends Command { public class CraftCommand extends Command {
public CraftCommand() { public CraftCommand() {
super( super(
"craft", "craft",
new String[]{"ct", "crafting", "craftingtable"}, new String[]{"ct", "crafting", "craftingtable"},
"Open crafting table", "Open crafting table",
"" ""
); );
} }
@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);
} }
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
return null; return null;
} }
} }

View file

@ -1,30 +1,30 @@
package com.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;
import java.util.List; import java.util.List;
public class EnchantingCommand extends Command { public class EnchantingCommand extends Command {
public EnchantingCommand() { public EnchantingCommand() {
super( super(
"enchant", "enchant",
new String[]{"et", "enchanting", "enchantingtable"}, new String[]{"et", "enchanting", "enchantingtable"},
"Open enchanting table", "Open enchanting table",
"" ""
); );
} }
@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);
} }
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
return null; return null;
} }
} }

View file

@ -1,47 +1,47 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class HologramCommand extends Command { public class HologramCommand extends Command {
public HologramCommand() { public HologramCommand() {
super( super(
"hologram", "hologram",
new String[]{}, new String[]{},
"Spawn a hologram", "Spawn a hologram",
"" ""
); );
} }
@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",
ChatColor.DARK_PURPLE + "What", ChatColor.DARK_PURPLE + "What",
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);
stand.setInvulnerable(true); stand.setInvulnerable(true);
stand.setCustomNameVisible(true); stand.setCustomNameVisible(true);
stand.setCustomName(line); stand.setCustomName(line);
} }
} }
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
return null; return null;
} }
} }

View file

@ -1,75 +1,75 @@
package com.night.nullvalkyrie.commands; package me.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.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;
import org.bukkit.inventory.ItemStack; 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; import java.util.List;
public class MenuCommand extends Command { 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");
public MenuCommand() { public MenuCommand() {
super( super(
"menu", "menu",
new String[]{"m"}, new String[]{"m"},
"Open the menu", "Open the menu",
"" ""
); );
} }
@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();
KYSmeta.setDisplayName(ChatColor.RED + "KILL YOURSELF WHEN???"); KYSmeta.setDisplayName(ChatColor.RED + "KILL YOURSELF WHEN???");
KYSmeta.setLore(Arrays.asList(ChatColor.GRAY + "KYS", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); KYSmeta.setLore(Arrays.asList(ChatColor.GRAY + "KYS", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
KYS.setItemMeta(KYSmeta); KYS.setItemMeta(KYSmeta);
inv.setItem(20, KYS); inv.setItem(20, KYS);
ItemStack home = new ItemStack(Material.MAP); ItemStack home = new ItemStack(Material.MAP);
ItemMeta homemeta = home.getItemMeta(); ItemMeta homemeta = home.getItemMeta();
homemeta.setDisplayName(ChatColor.BLUE + "Teleport to home"); homemeta.setDisplayName(ChatColor.BLUE + "Teleport to home");
homemeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to teleport back to home", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); homemeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to teleport back to home", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
home.setItemMeta(homemeta); home.setItemMeta(homemeta);
inv.setItem(22, home); inv.setItem(22, home);
ItemStack chest = new ItemStack(Material.ENDER_CHEST); ItemStack chest = new ItemStack(Material.ENDER_CHEST);
ItemMeta chestmeta = chest.getItemMeta(); ItemMeta chestmeta = chest.getItemMeta();
chestmeta.setDisplayName(ChatColor.GREEN + "Open your chest"); chestmeta.setDisplayName(ChatColor.GREEN + "Open your chest");
chestmeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to open the chest", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); chestmeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to open the chest", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
chest.setItemMeta(chestmeta); chest.setItemMeta(chestmeta);
inv.setItem(24, chest); inv.setItem(24, chest);
ItemStack close = new ItemStack(Material.BARRIER); ItemStack close = new ItemStack(Material.BARRIER);
ItemMeta closemeta = close.getItemMeta(); ItemMeta closemeta = close.getItemMeta();
closemeta.setDisplayName(ChatColor.WHITE + "Close the menu"); closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
closemeta.setLore(Arrays.asList(ChatColor.GRAY + "Close the menu", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); closemeta.setLore(Arrays.asList(ChatColor.GRAY + "Close the menu", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
close.setItemMeta(closemeta); close.setItemMeta(closemeta);
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);
} }
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
return null; return null;
} }
} }

View file

@ -1,59 +1,59 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
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;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class MessageCommand extends Command { public class MessageCommand extends Command {
public MessageCommand() { public MessageCommand() {
super( super(
"message", "message",
new String[]{"msg"}, new String[]{"msg"},
"Send message to someone", "Send message to someone",
"" ""
); );
} }
@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);
target.sendMessage(ChatColor.DARK_AQUA + "FROM " + ChatColor.RED + player.getName() + ChatColor.WHITE + " : " + builder); target.sendMessage(ChatColor.DARK_AQUA + "FROM " + ChatColor.RED + player.getName() + ChatColor.WHITE + " : " + builder);
} else { } else {
player.sendMessage(ChatColor.RED + "You cannot send message to yourself"); player.sendMessage(ChatColor.RED + "You cannot send message to yourself");
} }
} else { } else {
player.sendMessage(ChatColor.RED + "You cannot send message to offline players"); player.sendMessage(ChatColor.RED + "You cannot send message to offline players");
} }
} else { } else {
player.sendMessage(ChatColor.RED + "Invalid parameter, use /msg <Player> <Message>"); player.sendMessage(ChatColor.RED + "Invalid parameter, use /msg <Player> <Message>");
} }
} }
} }
@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<>());
} }
return new ArrayList<>(); return new ArrayList<>();
} }
} }

View file

@ -0,0 +1,35 @@
package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.miners.MinerGUI;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.night.nullvalkyrie.miners.*;
import java.util.List;
public class MinerCommand extends Command {
private Main main;
public MinerCommand(Main main) {
super(
"miner",
new String[]{"m", "miners"},
"Miner list",
""
);
this.main = main;
}
@Override
public void onCommand(CommandSender sender, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
new MinerGUI(main, player);
}
}
@Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
return null;
}
}

View file

@ -1,91 +1,91 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import com.night.nullvalkyrie.Rank.Rank; import me.night.nullvalkyrie.Rank.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.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static com.night.nullvalkyrie.Rank.ScoreboardListener.rankManager; import static me.night.nullvalkyrie.Rank.ScoreboardListener.rankManager;
//92.0.69.141:25565 //92.0.69.141:25565
public class RankCommand extends Command { public class RankCommand extends Command {
private Main main; private Main main;
public RankCommand(Main main) { public RankCommand(Main main) {
super( super(
"rank", "rank",
new String[]{}, new String[]{},
"Set rank of players", "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 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"); 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("This player has never played in this server before!");
} }
} else { } else {
player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>"); player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>");
} }
} 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");
} }
} }
} }
@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<>());
} }
return new ArrayList<>(); return new ArrayList<>();
} }
} }

View file

@ -1,153 +1,152 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import com.night.nullvalkyrie.Util.components.CustomMob; import me.night.nullvalkyrie.Util.components.CustomMob;
import org.bukkit.Bukkit; import me.night.nullvalkyrie.Util.Utils;
import org.bukkit.Location; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.block.Block;
import org.bukkit.entity.*; import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler; import org.bukkit.entity.*;
import org.bukkit.event.Listener; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.text.DecimalFormat;
import java.util.*; import java.text.DecimalFormat;
import java.util.*;
import static com.night.nullvalkyrie.Util.Utils.color;
public class SpawnCommand extends Command implements Listener {
public class SpawnCommand extends Command implements Listener { private final Main main;
private final Main main; public World world;
public World world; public final Map<Entity, Integer> indicators = new HashMap<>();
public final Map<Entity, Integer> indicators = new HashMap<>(); public final Map<Entity, CustomMob> entities = new HashMap<>();
public final Map<Entity, CustomMob> entities = new HashMap<>(); private final DecimalFormat formatter = new DecimalFormat("#");
private final DecimalFormat formatter = new DecimalFormat("#"); public SpawnCommand(Main main) {
public SpawnCommand(Main main) { super(
super( "spawn",
"spawn", new String[]{},
new String[]{}, "Spawn a custom mob",
"Spawn a custom mob", ""
"" );
); this.main = main;
this.main = main; }
}
@Override
@Override public void onCommand(CommandSender sender, String[] args) {
public void onCommand(CommandSender sender, String[] args) { world = Bukkit.getWorld("world");
world = Bukkit.getWorld("world");
spawnMobs(9, 10, 5 * 20);
spawnMobs(9, 10, 5 * 20); new BukkitRunnable() {
new BukkitRunnable() { final Set<Entity> stands = indicators.keySet();
final Set<Entity> stands = indicators.keySet(); final List<Entity> removal = new ArrayList<>();
final List<Entity> removal = new ArrayList<>(); @Override
@Override public void run() {
public void run() { for (Entity stand : stands) {
for (Entity stand : stands) { int ticksLeft = indicators.get(stand);
int ticksLeft = indicators.get(stand); if (ticksLeft == 0) {
if (ticksLeft == 0) { stand.remove();
stand.remove(); removal.add(stand);
removal.add(stand); continue;
continue; }
} ticksLeft--;
ticksLeft--; indicators.put(stand, ticksLeft);
indicators.put(stand, ticksLeft); }
} stands.removeAll(removal);
stands.removeAll(removal); }
} }.runTaskTimer(main, 0L, 1L);
}.runTaskTimer(main, 0L, 1L);
}
} public void spawnMobs(int size, int mobCap, int spawnTime) {
public void spawnMobs(int size, int mobCap, int spawnTime) { CustomMob[] mobTypes = CustomMob.values();
CustomMob[] mobTypes = CustomMob.values(); new BukkitRunnable() {
new BukkitRunnable() { final Set<Entity> spawned = entities.keySet();
final Set<Entity> spawned = entities.keySet(); final List<Entity> removal = new ArrayList<>();
final List<Entity> removal = new ArrayList<>(); @Override
@Override public void run() {
public void run() { for (Entity entity : spawned) {
for (Entity entity : spawned) { if (!entity.isValid() || entity.isDead()) removal.add(entity);
if (!entity.isValid() || entity.isDead()) removal.add(entity); }
} spawned.removeAll(removal);
spawned.removeAll(removal);
// Spawning Algorithm
// Spawning Algorithm int diff = mobCap - entities.size();
int diff = mobCap - entities.size(); if (diff <= 0) return;
if (diff <= 0) return; int spawnAmount = (int) (Math.random() * (diff + 1)), count = 0;
int spawnAmount = (int) (Math.random() * (diff + 1)), count = 0; while (count <= spawnAmount) {
while (count <= spawnAmount) { count++;
count++; int ranX = getRandomWithNeg(size), ranZ = getRandomWithNeg(size);
int ranX = getRandomWithNeg(size), ranZ = getRandomWithNeg(size); Block block = world.getHighestBlockAt(ranX, ranZ);
Block block = world.getHighestBlockAt(ranX, ranZ); double xOffset = getRandomOffset(), zOffset = getRandomOffset();
double xOffset = getRandomOffset(), zOffset = getRandomOffset(); Location loc = block.getLocation().clone().add(xOffset, 1, zOffset);
Location loc = block.getLocation().clone().add(xOffset, 1, zOffset); if (!isSpawnable(loc)) continue;
if (!isSpawnable(loc)) continue; double random = Math.random() * 101, previous = 0;
double random = Math.random() * 101, previous = 0; CustomMob typeToSpawn = mobTypes[0];
CustomMob typeToSpawn = mobTypes[0]; for (CustomMob type : mobTypes) {
for (CustomMob type : mobTypes) { previous += type.getSpawnChance();
previous += type.getSpawnChance(); if (random <= previous) {
if (random <= previous) { typeToSpawn = type;
typeToSpawn = type; break;
break; }
} }
} entities.put(typeToSpawn.spawn(loc), typeToSpawn);
entities.put(typeToSpawn.spawn(loc), typeToSpawn); }
} }
} }.runTaskTimer(main, 0L, spawnTime);
}.runTaskTimer(main, 0L, spawnTime); }
}
public static boolean isSpawnable(Location loc) {
public static boolean isSpawnable(Location loc) { Block feetBlock = loc.getBlock(), headBlock = loc.clone().add(0, 1, 0).getBlock(), upperBlock = loc.clone().add(0, 2, 0).getBlock();
Block feetBlock = loc.getBlock(), headBlock = loc.clone().add(0, 1, 0).getBlock(), upperBlock = loc.clone().add(0, 2, 0).getBlock(); return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid() && upperBlock.isPassable() && !upperBlock.isLiquid();
return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid() && upperBlock.isPassable() && !upperBlock.isLiquid(); }
}
private static double getRandomOffset() {
private static double getRandomOffset() { double random = Math.random();
double random = Math.random(); if (Math.random() > 0.5) random *= -1;
if (Math.random() > 0.5) random *= -1; return random;
return random; }
}
public static int getRandomWithNeg(int size) {
public static int getRandomWithNeg(int size) { int random = (int) (Math.random() * (size + 1));
int random = (int) (Math.random() * (size + 1)); if (Math.random() > 0.5) random *= -1;
if (Math.random() > 0.5) random *= -1; return random;
return random; }
}
@EventHandler
@EventHandler public void onEntityDamage(EntityDamageEvent event) {
public void onEntityDamage(EntityDamageEvent event) { Entity rawEntity = event.getEntity();
Entity rawEntity = event.getEntity(); if (!entities.containsKey(rawEntity)) return;
if (!entities.containsKey(rawEntity)) return; CustomMob mob = entities.get(rawEntity);
CustomMob mob = entities.get(rawEntity); LivingEntity entity = (LivingEntity) rawEntity;
LivingEntity entity = (LivingEntity) rawEntity; double damage = event.getFinalDamage(), health = entity.getHealth() + entity.getAbsorptionAmount();
double damage = event.getFinalDamage(), health = entity.getHealth() + entity.getAbsorptionAmount(); if (health > damage) {
if (health > damage) { // If the entity survived the hit
// If the entity survived the hit health -= damage;
health -= damage; entity.setCustomName(Utils.color(mob.getName() + " &r&c" + (int) health + "/" + (int) mob.getMaxHealth() + ""));
entity.setCustomName(color(mob.getName() + " &r&c" + (int) health + "/" + (int) mob.getMaxHealth() + "")); }
} Location loc = entity.getLocation().clone().add(getRandomOffset(), 1, getRandomOffset());
Location loc = entity.getLocation().clone().add(getRandomOffset(), 1, getRandomOffset()); world.spawn(loc, ArmorStand.class, armorStand -> {
world.spawn(loc, ArmorStand.class, armorStand -> { armorStand.setMarker(true);
armorStand.setMarker(true); armorStand.setVisible(false);
armorStand.setVisible(false); armorStand.setGravity(false);
armorStand.setGravity(false); armorStand.setSmall(true);
armorStand.setSmall(true); armorStand.setCustomNameVisible(true);
armorStand.setCustomNameVisible(true); armorStand.setCustomName(Utils.color("&c" + formatter.format(damage)));
armorStand.setCustomName(color("&c" + formatter.format(damage))); indicators.put(armorStand, 30);
indicators.put(armorStand, 30); });
}); }
}
@EventHandler
@EventHandler public void onEntityDeath(EntityDeathEvent event) {
public void onEntityDeath(EntityDeathEvent event) { if (!entities.containsKey(event.getEntity())) return;
if (!entities.containsKey(event.getEntity())) return; event.setDroppedExp(0);
event.setDroppedExp(0); event.getDrops().clear();
event.getDrops().clear(); entities.remove(event.getEntity()).tryDropLoot(event.getEntity().getLocation());
entities.remove(event.getEntity()).tryDropLoot(event.getEntity().getLocation()); }
} @Override
@Override public List<String> onTabComplete(CommandSender sender, String[] args) {
public List<String> onTabComplete(CommandSender sender, String[] args) { return null;
return null; }
} }
}

View file

@ -1,35 +1,35 @@
package com.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;
import java.util.List; import java.util.List;
public class TestCommand extends Command { public class TestCommand extends Command {
public TestCommand() { public TestCommand() {
super( super(
"test", "test",
new String[]{}, new String[]{},
"Test", "Test",
"" ""
); );
} }
@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());
} }
} }
} }
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
return null; return null;
} }
} }

View file

@ -1,68 +1,66 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import org.bukkit.ChatColor; import me.night.nullvalkyrie.Items.CustomItemManager;
import org.bukkit.command.CommandSender; import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays; import java.util.ArrayList;
import java.util.List; import java.util.Arrays;
import java.util.Objects; import java.util.List;
import java.util.Objects;
import static com.night.nullvalkyrie.Items.CustomItemManager.getAllFilesFromDirectory;
import static com.night.nullvalkyrie.Items.CustomItemManager.loadConfig; public class UtilCommand extends Command {
private Main main;
public class UtilCommand extends Command { public UtilCommand(Main main) {
private Main main; super(
public UtilCommand(Main main) { "util",
super( new String[]{},
"util", "Give you a tool",
new String[]{}, ""
"Give you a tool",
"" );
this.main = main;
); }
this.main = main; @Override
} public void onCommand(CommandSender sender, String[] args) {
@Override Player player = (Player) sender;
public void onCommand(CommandSender sender, String[] args) { StringBuilder s = new StringBuilder();
Player player = (Player) sender; List<String> b = Arrays.asList(args);
StringBuilder s = new StringBuilder(); for(String a: args) {
List<String> b = Arrays.asList(args); if(a.equals(b.get(b.size() - 1))) {
for(String a: args) { s.append(a);
if(a.equals(b.get(b.size() - 1))) { } else {
s.append(a); s.append(a);
} else { s.append(" ");
s.append(a); }
s.append(" ");
} }
ItemStack item = main.getCustomItemManager().getItem(s.toString());
} if(item.hasItemMeta()) {
ItemStack item = main.getCustomItemManager().getItem(s.toString()); player.getInventory().addItem(item);
if(item.hasItemMeta()) { } else {
player.getInventory().addItem(item); player.sendMessage(ChatColor.RED + "This item doesn't exist");
} else { }
player.sendMessage(ChatColor.RED + "This item doesn't exist"); }
}
} @Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
@Override if(args.length == 1) {
public List<String> onTabComplete(CommandSender sender, String[] args) { List<String> hh = CustomItemManager.getAllFilesFromDirectory("ItemData");
if(args.length == 1) { ArrayList<String> cc = new ArrayList<>();
List<String> hh = getAllFilesFromDirectory("ItemData"); for(int kk = 0; kk < hh.size(); kk++) {
ArrayList<String> cc = new ArrayList<>(); FileConfiguration c = CustomItemManager.loadConfig("ItemData\\" + hh.get(kk));
for(int kk = 0; kk < hh.size(); kk++) { if(Objects.equals(c.getString("type"), "Util")) {
FileConfiguration c = loadConfig("ItemData\\" + hh.get(kk)); cc.add(c.getString("name"));
if(Objects.equals(c.getString("type"), "Util")) { }
cc.add(c.getString("name")); }
} return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>());
} }
return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>()); return new ArrayList<>();
} }
return new ArrayList<>(); }
}
}

View file

@ -1,46 +1,46 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
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;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; 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);
} }
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");
} }
} }
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
return null; return null;
} }
} }

View file

@ -1,70 +1,68 @@
package com.night.nullvalkyrie.commands; package me.night.nullvalkyrie.commands;
import com.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
import org.bukkit.ChatColor; import me.night.nullvalkyrie.Items.CustomItemManager;
import org.bukkit.command.CommandSender; import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays; import java.util.ArrayList;
import java.util.List; import java.util.Arrays;
import java.util.Objects; import java.util.List;
import java.util.Objects;
import static com.night.nullvalkyrie.Items.CustomItemManager.getAllFilesFromDirectory;
import static com.night.nullvalkyrie.Items.CustomItemManager.loadConfig; public class WeaponCommand extends Command {
private Main main;
public class WeaponCommand extends Command { public WeaponCommand(Main main) {
private Main main; super(
public WeaponCommand(Main main) { "weapon",
super( new String[]{},
"weapon", "Give you a weapon",
new String[]{}, ""
"Give you a weapon",
"" );
this.main = main;
); }
this.main = main;
}
@Override
public void onCommand(CommandSender sender, String[] args) {
@Override Player player = (Player) sender;
public void onCommand(CommandSender sender, String[] args) { StringBuilder s = new StringBuilder();
Player player = (Player) sender; List<String> b = Arrays.asList(args);
StringBuilder s = new StringBuilder(); for(String a: args) {
List<String> b = Arrays.asList(args); if(a.equals(b.get(b.size() - 1))) {
for(String a: args) { s.append(a);
if(a.equals(b.get(b.size() - 1))) { } else {
s.append(a); s.append(a);
} else { s.append(" ");
s.append(a); }
s.append(" ");
} }
ItemStack item = main.getCustomItemManager().getItem(s.toString());
} if(item.hasItemMeta()) {
ItemStack item = main.getCustomItemManager().getItem(s.toString()); player.getInventory().addItem(item);
if(item.hasItemMeta()) { } else {
player.getInventory().addItem(item); player.sendMessage(ChatColor.RED + "This item doesn't exist");
} else { }
player.sendMessage(ChatColor.RED + "This item doesn't exist"); }
}
} @Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
@Override if(args.length == 1) {
public List<String> onTabComplete(CommandSender sender, String[] args) { List<String> hh = CustomItemManager.getAllFilesFromDirectory("ItemData");
if(args.length == 1) { ArrayList<String> cc = new ArrayList<>();
List<String> hh = getAllFilesFromDirectory("ItemData"); for(int kk = 0; kk < hh.size(); kk++) {
ArrayList<String> cc = new ArrayList<>(); FileConfiguration c = CustomItemManager.loadConfig("ItemData/" + hh.get(kk));
for(int kk = 0; kk < hh.size(); kk++) { if(Objects.equals(c.getString("type"), "Weapon")) {
FileConfiguration c = loadConfig("ItemData\\" + hh.get(kk)); cc.add(c.getString("name"));
if(Objects.equals(c.getString("type"), "Weapon")) { }
cc.add(c.getString("name")); }
} return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>());
} }
return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>()); return new ArrayList<>();
} }
return new ArrayList<>(); }
}
}

View file

@ -0,0 +1,94 @@
package me.night.nullvalkyrie.miners;
import me.night.nullvalkyrie.Main;
import org.bukkit.Material;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import static me.night.nullvalkyrie.Items.CustomItemManager.loadConfig;
import static me.night.nullvalkyrie.Items.CustomItemManager.loadFile;
public class CryptoMiner {
protected Main main;
protected String name;
protected Material type;
protected int level;
protected double rate;
protected int generated;
public CryptoMiner(Main main, String name, Material type, int level, double rate) {
this.main = main;
this.name = name; // Name of the miner
this.type = type; // Material to mine
this.level = level;
this.rate = rate; // Percentage generate chance in each tick 20tick per sec
//generate(70);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getRate() {
return rate;
}
public void setRate(double rate) {
this.rate = rate;
}
public Material getType() {
return type;
}
public void setType(Material type) {
this.type = type;
}
public int getLevel() {
return level;
}
public void setLevel(int level) { this.level = level; }
public void generate(int pp) {
new BukkitRunnable() {
@Override
public void run() {
int count = ThreadLocalRandom.current().nextInt(100);
if(count > pp) generated++;
}
}.runTaskTimer(main, 0L, 1L);
}
public List<CryptoMiner> getMiners() {
List<CryptoMiner> arr = new ArrayList<>();
FileConfiguration file = loadConfig("miners.yml");
for(String c : file.getKeys(false)) {
arr.add(new CryptoMiner(main, file.getString(c + ".name"), Material.matchMaterial(file.getString(c + ".material")), file.getInt(c + ".level"), file.getDouble(c + ".rate")));
}
return arr;
}
public CryptoMiner getMiner(String index) {
FileConfiguration file = loadConfig("miners.yml");
return new CryptoMiner(main, file.getString(index + ".name"), Material.matchMaterial(file.getString(index + ".name")), file.getInt(index + ".level"), file.getDouble(index + ".rate"));
}
public void setMiner(String index, String name, String material, int level, double rate) {
CryptoMiner miner = new CryptoMiner(main, name, Material.matchMaterial(material), level, rate);
FileConfiguration file = loadConfig("miners.yml");
file.createSection(index);
file.set(index + ".name", name);
file.set(index + ".material", material);
file.set(index + ".level", level);
file.set(index + ".rate", rate);
file.set(index + ".enabled", true);
try {
file.save(loadFile("miners.yml"));
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,58 @@
package me.night.nullvalkyrie.miners;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.Items.CustomItemManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class MinerGUI {
private Main main;
private FileConfiguration file;
private Inventory inv;
public MinerGUI(Main main, Player player) {
this.main = main;
if(!main.getDataFolder().exists()) main.getDataFolder().mkdir();
file = CustomItemManager.loadConfig("miners.yml");
createUI();
player.openInventory(inv);
}
public void createUI() {
inv = Bukkit.createInventory(null,45, ChatColor.DARK_AQUA + "Crypto Miners");
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}) {
inv.setItem(i, frame);
}
ItemStack close = new ItemStack(Material.BARRIER);
ItemMeta closemeta = close.getItemMeta();
closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
closemeta.setLore(Arrays.asList(ChatColor.GRAY + "Close the menu"));
close.setItemMeta(closemeta);
inv.setItem(0, close);
int[] a = new int[]{10,11,12,13,14,15,16,19,20,21,22,23,24,25,28,29,30,31,32,33,34};
int ind = 0;
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"));
List<String> lore = new ArrayList<>();
lore.add("Level: " + file.getString(c + ".level"));
lore.add("Rate: " + file.getString(c + ".rate"));
boolean b = file.getBoolean(c + ".rate") ? lore.add(ChatColor.GRAY + "Click to enable miner!") : lore.add(ChatColor.RED + "Click to disable miner!");
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
inv.setItem(a[ind], item);
ind++;
}
}
}

View file

@ -1,6 +1,6 @@
name: NullValkyrie name: NullValkyrie
version: '${project.version}' version: '${project.version}'
main: com.night.nullvalkyrie.Main main: me.night.nullvalkyrie.Main
api-version: 1.18 api-version: 1.18
authors: [ NightKaly, Leocthl ] authors: [ NightKaly, Leocthl ]
description: Null Valkyrie description: Null Valkyrie