playing with nms(failed)

This commit is contained in:
night0721 2022-07-16 15:27:25 +01:00
parent 16ca041b4b
commit 1c053d819d
4 changed files with 52 additions and 7 deletions

34
pom.xml
View file

@ -54,6 +54,39 @@
<outputDirectory>D:\Server\plugins</outputDirectory>
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <groupId>net.md-5</groupId>-->
<!-- <artifactId>specialsource-maven-plugin</artifactId>-->
<!-- <version>1.2.2</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>remap</goal>-->
<!-- </goals>-->
<!-- <id>remap-obf</id>-->
<!-- <configuration>-->
<!-- <srgIn>org.spigotmc:minecraft-server:1.18-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>-->
<!-- <reverse>true</reverse>-->
<!-- <remappedDependencies>org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>-->
<!-- <remappedArtifactAttached>true</remappedArtifactAttached>-->
<!-- <remappedClassifierName>remapped-obf</remappedClassifierName>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>remap</goal>-->
<!-- </goals>-->
<!-- <id>remap-spigot</id>-->
<!-- <configuration>-->
<!-- <inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>-->
<!-- <srgIn>org.spigotmc:minecraft-server:1.18-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>-->
<!-- <remappedDependencies>org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
</plugins>
<resources>
<resource>
@ -78,6 +111,7 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<!-- <classifier>remapped-mojang</classifier>-->
<scope>provided</scope>
</dependency>
</dependencies>

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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;