From 1c053d819d72df4e2de06c832a6dd733a91db470 Mon Sep 17 00:00:00 2001 From: night0721 Date: Sat, 16 Jul 2022 15:27:25 +0100 Subject: [PATCH] playing with nms(failed) --- pom.xml | 34 +++++++++++++++++++ .../java/com/night/nullvalkyrie/Main.java | 2 +- .../nullvalkyrie/commands/AnvilCommand.java | 19 ++++++++--- .../nullvalkyrie/commands/SpawnCommand.java | 4 +-- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index d3018a2..e4289cd 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,39 @@ D:\Server\plugins + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -78,6 +111,7 @@ org.spigotmc spigot 1.18.1-R0.1-SNAPSHOT + provided diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index e28b043..4a0cb69 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -49,7 +49,7 @@ public final class Main extends JavaPlugin implements Listener { Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new MenuListener(), this); Bukkit.getPluginManager().registerEvents(new ScoreboardListener(this), this); - Bukkit.getPluginManager().registerEvents(new CustomItemEvents(), this); + Bukkit.getPluginManager().registerEvents(new CustomItemEvents(this), this); Bukkit.getPluginManager().registerEvents(new SpawnCommand(this), this); new EnchantmentManager(); customItemManager = new CustomItemManager(this); diff --git a/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java b/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java index 7744dad..ed1f040 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java @@ -1,9 +1,15 @@ package com.night.nullvalkyrie.commands; -import org.bukkit.Bukkit; + +//import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow; +//import net.minecraft.server.level.EntityPlayer; +//import net.minecraft.server.network.PlayerConnection; +//import net.minecraft.world.inventory.Containers; import org.bukkit.command.CommandSender; +//import org.bukkit.craftbukkit.v1_18_R1.entity.CraftHumanEntity; +//import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; +//import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryType; import java.util.List; @@ -21,8 +27,13 @@ public class AnvilCommand extends Command { @Override public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { - Player player = (Player) sender; - player.openInventory(Bukkit.createInventory(player, InventoryType.ANVIL)); +// Player player = (Player) sender; +// CraftPlayer craftPlayer = (CraftPlayer) player; +// EntityPlayer entityPlayer = craftPlayer.getHandle(); +// int id = 0; +// PacketPlayOutOpenWindow OpenWindow = new PacketPlayOutOpenWindow(id, Containers.h, CraftChatMessage.fromStringOrNull("Test")); +// PlayerConnection playerConnection = entityPlayer.b; +// playerConnection.a(OpenWindow); } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java b/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java index e65b871..ec95e48 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java @@ -98,7 +98,7 @@ public class SpawnCommand extends Command implements Listener { }.runTaskTimer(main, 0L, spawnTime); } - private 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(); return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid() && upperBlock.isPassable() && !upperBlock.isLiquid(); } @@ -109,7 +109,7 @@ public class SpawnCommand extends Command implements Listener { return random; } - private static int getRandomWithNeg(int size) { + public static int getRandomWithNeg(int size) { int random = (int) (Math.random() * (size + 1)); if (Math.random() > 0.5) random *= -1; return random;