mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Fixed packet singletons
This commit is contained in:
parent
bea49ad2e7
commit
6096a37bf9
@ -9,15 +9,11 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import java.util.Collections;
|
||||
|
||||
public abstract class AbstractPacketAdapter extends PacketAdapter {
|
||||
protected static AbstractPacketAdapter instance;
|
||||
|
||||
private final PacketType type;
|
||||
|
||||
protected AbstractPacketAdapter(PacketType type) {
|
||||
super(EcoEnchantsPlugin.getInstance(), Collections.singletonList(type));
|
||||
this.type = type;
|
||||
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void onReceive(PacketContainer packet) {}
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
||||
private PacketOpenWindowMerchant() {
|
||||
public PacketOpenWindowMerchant() {
|
||||
super(PacketType.Play.Server.OPEN_WINDOW_MERCHANT);
|
||||
}
|
||||
|
||||
@ -38,11 +38,4 @@ public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
||||
|
||||
packet.getMerchantRecipeLists().writeSafely(0, newList);
|
||||
}
|
||||
|
||||
public static AbstractPacketAdapter getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new PacketOpenWindowMerchant();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.willfp.ecoenchants.display.AbstractPacketAdapter;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
|
||||
public final class PacketSetCreativeSlot extends AbstractPacketAdapter {
|
||||
private PacketSetCreativeSlot() {
|
||||
public PacketSetCreativeSlot() {
|
||||
super(PacketType.Play.Client.SET_CREATIVE_SLOT);
|
||||
}
|
||||
|
||||
@ -17,11 +17,4 @@ public final class PacketSetCreativeSlot extends AbstractPacketAdapter {
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
public static AbstractPacketAdapter getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new PacketSetCreativeSlot();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.willfp.ecoenchants.display.AbstractPacketAdapter;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
|
||||
public final class PacketSetSlot extends AbstractPacketAdapter {
|
||||
private PacketSetSlot() {
|
||||
public PacketSetSlot() {
|
||||
super(PacketType.Play.Server.SET_SLOT);
|
||||
}
|
||||
|
||||
@ -17,11 +17,4 @@ public final class PacketSetSlot extends AbstractPacketAdapter {
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
public static AbstractPacketAdapter getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new PacketSetSlot();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.willfp.ecoenchants.display.AbstractPacketAdapter;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
|
||||
public final class PacketWindowItems extends AbstractPacketAdapter {
|
||||
private PacketWindowItems() {
|
||||
public PacketWindowItems() {
|
||||
super(PacketType.Play.Server.WINDOW_ITEMS);
|
||||
}
|
||||
|
||||
@ -17,11 +17,4 @@ public final class PacketWindowItems extends AbstractPacketAdapter {
|
||||
return itemStacks;
|
||||
});
|
||||
}
|
||||
|
||||
public static AbstractPacketAdapter getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new PacketWindowItems();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
@ -99,10 +99,10 @@ public class Loader {
|
||||
|
||||
Bukkit.getLogger().info("Loading ProtocolLib...");
|
||||
EcoEnchantsPlugin.getInstance().protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
PacketOpenWindowMerchant.getInstance().register();
|
||||
PacketSetCreativeSlot.getInstance().register();
|
||||
PacketSetSlot.getInstance().register();
|
||||
PacketWindowItems.getInstance().register();
|
||||
new PacketOpenWindowMerchant().register();
|
||||
new PacketSetCreativeSlot().register();
|
||||
new PacketSetSlot().register();
|
||||
new PacketWindowItems().register();
|
||||
|
||||
/*
|
||||
Load land management support
|
||||
|
Loading…
Reference in New Issue
Block a user