mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-02-18 04:21:21 +01:00
feat!: delete v1_21_0 sub module
Spigot 1.21.0 can no longer be built and points to 1.21.1 1.21.0 should not be used anyways, as 1.21.1 contains a security fix. This workaround is no longer supported and needed in my eyes.
This commit is contained in:
parent
597796b3fd
commit
874ecf63b2
@ -1,89 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>CraftaroCore-Modules</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>CraftaroCore-NMS-v1_21_0</artifactId>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<java.release>21</java.release>
|
||||
|
||||
<nms.ver>1.21-R0.1-SNAPSHOT</nms.ver>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>specialsource-maven-plugin</artifactId>
|
||||
<version>2.0.3</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>remap-obf</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<srgIn>org.spigotmc:minecraft-server:${nms.ver}:txt:maps-mojang</srgIn>
|
||||
<reverse>true</reverse>
|
||||
<remappedDependencies>org.spigotmc:spigot:${nms.ver}:jar:remapped-mojang</remappedDependencies>
|
||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||
<remappedClassifierName>remapped-obf</remappedClassifierName>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>remap-spigot</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
||||
<srgIn>org.spigotmc:minecraft-server:${nms.ver}:csrg:maps-spigot</srgIn>
|
||||
<remappedDependencies>org.spigotmc:spigot:${nms.ver}:jar:remapped-obf</remappedDependencies>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!--suppress VulnerableLibrariesLocal -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>${nms.ver}</version>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--suppress VulnerableLibrariesLocal -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>CraftaroCore-NMS-API</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>CraftaroCore-Compatibility</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,21 +0,0 @@
|
||||
package com.craftaro.core.nms.v1_21_0.anvil;
|
||||
|
||||
import com.craftaro.core.nms.anvil.CustomAnvil;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class AnvilCore implements com.craftaro.core.nms.anvil.AnvilCore {
|
||||
@Override
|
||||
public CustomAnvil createAnvil(Player player) {
|
||||
ServerPlayer p = ((CraftPlayer) player).getHandle();
|
||||
return new AnvilView(p.nextContainerCounter(), p, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomAnvil createAnvil(Player player, InventoryHolder holder) {
|
||||
ServerPlayer p = ((CraftPlayer) player).getHandle();
|
||||
return new AnvilView(p.nextContainerCounter(), p, holder);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.craftaro.core.nms.v1_21_0.anvil;
|
||||
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryAnvil;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class AnvilInventoryCustom extends CraftInventoryAnvil {
|
||||
final InventoryHolder holder;
|
||||
|
||||
public AnvilInventoryCustom(InventoryHolder holder, Location location, Container inventory, Container resultInventory, AnvilMenu container) {
|
||||
super(location, inventory, resultInventory, container);
|
||||
|
||||
this.holder = holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryHolder getHolder() {
|
||||
return this.holder;
|
||||
}
|
||||
}
|
@ -1,200 +0,0 @@
|
||||
package com.craftaro.core.nms.v1_21_0.anvil;
|
||||
|
||||
import com.craftaro.core.nms.anvil.CustomAnvil;
|
||||
import com.craftaro.core.nms.anvil.methods.AnvilTextChange;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryView;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AnvilView extends AnvilMenu implements CustomAnvil {
|
||||
private final ServerPlayer entity;
|
||||
private final Inventory inventory;
|
||||
private String customTitle = "Repairing";
|
||||
private int cost = -1;
|
||||
private boolean canUse = true;
|
||||
private AnvilTextChange textChange;
|
||||
|
||||
static Field mc_Container_title;
|
||||
static Field mc_ContainerAnvil_bukkitEntity;
|
||||
|
||||
static {
|
||||
try {
|
||||
mc_Container_title = AbstractContainerMenu.class.getDeclaredField("title");
|
||||
mc_Container_title.setAccessible(true);
|
||||
|
||||
mc_ContainerAnvil_bukkitEntity = AnvilMenu.class.getDeclaredField("bukkitEntity");
|
||||
mc_ContainerAnvil_bukkitEntity.setAccessible(true);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public AnvilView(int id, ServerPlayer entity, InventoryHolder holder) {
|
||||
super(entity.nextContainerCounter(), entity.getInventory(), ContainerLevelAccess.create(entity.level(), new BlockPos(0, 0, 0)));
|
||||
|
||||
this.setTitle(MutableComponent.create(new TranslatableContents(this.customTitle != null ? this.customTitle : "", this.customTitle != null ? this.customTitle : "", new Object[0])));
|
||||
this.checkReachable = false;
|
||||
this.entity = entity;
|
||||
|
||||
if (holder != null) {
|
||||
this.inventory = getBukkitView(entity, holder).getTopInventory();
|
||||
} else {
|
||||
this.inventory = getBukkitView().getTopInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public CraftInventoryView getBukkitView(Player player, InventoryHolder holder) {
|
||||
try {
|
||||
AnvilInventoryCustom craftInventory = new AnvilInventoryCustom(holder,
|
||||
new Location(this.entity.level().getWorld(), 0, 0, 0),
|
||||
this.inputSlots,
|
||||
this.resultSlots,
|
||||
this);
|
||||
CraftInventoryView view = new CraftInventoryView(player.getBukkitEntity(), craftInventory, this);
|
||||
mc_ContainerAnvil_bukkitEntity.set(this, view);
|
||||
|
||||
return view;
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
} catch (NoSuchMethodError err) {
|
||||
//1.21 support
|
||||
|
||||
}
|
||||
|
||||
return getBukkitView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player entityhuman) {
|
||||
return this.canUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastFullState() {
|
||||
super.broadcastFullState();
|
||||
|
||||
if (this.cost >= 0) {
|
||||
this.setLevelCost(this.cost);
|
||||
}
|
||||
|
||||
this.textChange.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
broadcastFullState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRenameText() {
|
||||
return this.itemName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenameText(String text) {
|
||||
this.setItemName(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnChange(AnvilTextChange handler) {
|
||||
this.textChange = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomTitle() {
|
||||
return this.customTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomTitle(String title) {
|
||||
this.customTitle = title;
|
||||
|
||||
try {
|
||||
mc_Container_title.set(this, MutableComponent.create(new TranslatableContents(this.customTitle != null ? this.customTitle : "", this.customTitle != null ? this.customTitle : "", new Object[0])));
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevelCost(int cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevelCost() {
|
||||
if (this.cost >= 0) {
|
||||
return this.cost;
|
||||
}
|
||||
|
||||
return this.getLevelCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanUse(boolean bool) {
|
||||
this.canUse = bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLeftInput() {
|
||||
return this.inventory.getItem(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRightInput() {
|
||||
return this.inventory.getItem(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
return this.inventory.getItem(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeftInput(ItemStack item) {
|
||||
this.inventory.setItem(0, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRightInput(ItemStack item) {
|
||||
this.inventory.setItem(1, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutput(ItemStack item) {
|
||||
this.inventory.setItem(2, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
// Send the packet
|
||||
this.entity.connection.send(new ClientboundOpenScreenPacket(super.containerId, MenuType.ANVIL, MutableComponent.create(new TranslatableContents(this.customTitle != null ? this.customTitle : "", this.customTitle != null ? this.customTitle : "", new Object[0]))));
|
||||
|
||||
// Set their active container to this anvil
|
||||
this.entity.containerMenu = this;
|
||||
|
||||
// Add the slot listener
|
||||
this.entity.initMenu(this.entity.containerMenu);
|
||||
}
|
||||
}
|
@ -62,13 +62,6 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<version>${project.version}</version>
|
||||
<artifactId>CraftaroCore-NMS-v1_21_0</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--suppress VulnerableLibrariesLocal -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
|
@ -16,19 +16,7 @@ public class AnvilCore implements com.craftaro.core.nms.anvil.AnvilCore {
|
||||
|
||||
@Override
|
||||
public CustomAnvil createAnvil(Player player, InventoryHolder holder) {
|
||||
try {
|
||||
ServerPlayer p = ((CraftPlayer) player).getHandle();
|
||||
return new AnvilView(p.nextContainerCounter(), p, holder);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
//1.21 support
|
||||
try {
|
||||
Class<?> clazz = Class.forName("com.craftaro.core.nms.v1_21_0.anvil.AnvilCore");
|
||||
Object anvilCore = clazz.newInstance();
|
||||
|
||||
return (CustomAnvil) anvilCore.getClass().getMethod("createAnvil", Player.class, InventoryHolder.class).invoke(anvilCore, player, holder);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
ServerPlayer p = ((CraftPlayer) player).getHandle();
|
||||
return new AnvilView(p.nextContainerCounter(), p, holder);
|
||||
}
|
||||
}
|
||||
|
@ -75,22 +75,6 @@ public class AnvilView extends AnvilMenu implements CustomAnvil {
|
||||
return view;
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
} catch (NoSuchMethodError err) {
|
||||
//1.21 support
|
||||
try {
|
||||
Class<?> clazz = Class.forName("com.craftaro.core.nms.v1_21_0.anvil.AnvilInventoryCustom");
|
||||
Object craftInventory = clazz.getConstructor(InventoryHolder.class, Location.class, net.minecraft.world.Container.class, net.minecraft.world.Container.class, AnvilMenu.class)
|
||||
.newInstance(holder, new Location(this.entity.level().getWorld(), 0, 0, 0), this.inputSlots, this.resultSlots, this);
|
||||
|
||||
Class<?> craftInventoryViewClass = Class.forName("org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryView");
|
||||
//(HumanEntity player, Inventory viewing, AbstractContainerMenu container)
|
||||
Object view = craftInventoryViewClass.getConstructor(HumanEntity.class, Inventory.class, AbstractContainerMenu.class).newInstance(player.getBukkitEntity(), (Inventory) craftInventory, this);
|
||||
mc_ContainerAnvil_bukkitEntity.set(this, view);
|
||||
|
||||
return (CraftAbstractInventoryView) view;
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return getBukkitView();
|
||||
|
Loading…
Reference in New Issue
Block a user