Skip to content

Commit aa650fe

Browse files
committed
Fix NMS code for setting chest inventory title in 1.13
1 parent 633bb54 commit aa650fe

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/main/java/codes/biscuit/sellchest/events/PlayerEvents.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void onVoidChestPlace(PlayerInteractEvent e) {
8282
Chest chest = new Chest(main.getUtils().getOppositeDirection(p));
8383
state.setData(chest);
8484
state.update();
85+
state = newBlock.getState();
8586
try {
8687
if (ReflectionUtils.getVersion().contains("1_8") || ReflectionUtils.getVersion().contains("1_9") || ReflectionUtils.getVersion().contains("1_10") || ReflectionUtils.getVersion().contains("1_11")) {
8788
Method getTileEntity = ReflectionUtils.getMethod(state.getClass(), "getTileEntity");//newBlock.getState().getClass().getDeclaredMethod("getTileEntity");
@@ -99,12 +100,10 @@ public void onVoidChestPlace(PlayerInteractEvent e) {
99100
customName.setAccessible(true);
100101
customName.set(tileEntityObject, main.getConfigValues().getChestTitle());
101102
} else {
102-
Method getTileEntity = ReflectionUtils.getMethod(state.getClass(), "getTileEntity");//newBlock.getState().getClass().getDeclaredMethod("getTileEntity");
103-
if (!getTileEntity.isAccessible()) {
104-
getTileEntity.setAccessible(true);
105-
}
103+
Method getTileEntity = ReflectionUtils.getMethod(state.getClass().getSuperclass().getSuperclass().getSuperclass(), "getTileEntity");//newBlock.getState().getClass().getDeclaredMethod("getTileEntity");
104+
getTileEntity.setAccessible(true);
106105
Object tileEntityChest = getTileEntity.invoke(newBlock.getState());
107-
Method setDisplayName = ReflectionUtils.getMethod(tileEntityChest.getClass(), "setCustomName", ReflectionUtils.getNMSClass("IChatBaseComponent")); //tileEntityChest.getClass().getMethod("setCustomName", ReflectionUtils.getNMSClass("IChatBaseComponent"));
106+
Method setDisplayName = ReflectionUtils.getMethod(tileEntityChest.getClass().getSuperclass(), "setCustomName", ReflectionUtils.getNMSClass("IChatBaseComponent")); //tileEntityChest.getClass().getMethod("setCustomName", ReflectionUtils.getNMSClass("IChatBaseComponent"));
108107
Constructor newChatComponentText = ReflectionUtils.getConstructor(ReflectionUtils.getNMSClass("ChatComponentText"), String.class); //ReflectionUtils.getNMSClass("ChatComponentText").getConstructor(String.class);
109108
Object chatComponentText = newChatComponentText.newInstance(main.getConfigValues().getChestTitle());
110109
setDisplayName.invoke(tileEntityChest, chatComponentText);

src/main/resources/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ sell-time: 1.0
1515
save-time: 300.0
1616

1717
# How often players should be notified of their recent earnings. This will display the amount earned since the last message.
18-
# For example, if the interval is 5 minutes (300s), then it will display the earnings in the past 5 minutes.
18+
# For example, if the interval is 5 minutes (300s), then it will display the earnings in the past 5 minutes. Set to 0 to disable.
1919
recent-earnings-time: 300.0
2020

2121
# Set to false if you don't want unsellable items to be cleared.

0 commit comments

Comments
 (0)