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;
|
import java.util.Collections;
|
||||||
|
|
||||||
public abstract class AbstractPacketAdapter extends PacketAdapter {
|
public abstract class AbstractPacketAdapter extends PacketAdapter {
|
||||||
protected static AbstractPacketAdapter instance;
|
|
||||||
|
|
||||||
private final PacketType type;
|
private final PacketType type;
|
||||||
|
|
||||||
protected AbstractPacketAdapter(PacketType type) {
|
protected AbstractPacketAdapter(PacketType type) {
|
||||||
super(EcoEnchantsPlugin.getInstance(), Collections.singletonList(type));
|
super(EcoEnchantsPlugin.getInstance(), Collections.singletonList(type));
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
instance = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReceive(PacketContainer packet) {}
|
public void onReceive(PacketContainer packet) {}
|
||||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
||||||
private PacketOpenWindowMerchant() {
|
public PacketOpenWindowMerchant() {
|
||||||
super(PacketType.Play.Server.OPEN_WINDOW_MERCHANT);
|
super(PacketType.Play.Server.OPEN_WINDOW_MERCHANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,11 +38,4 @@ public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
|||||||
|
|
||||||
packet.getMerchantRecipeLists().writeSafely(0, newList);
|
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;
|
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||||
|
|
||||||
public final class PacketSetCreativeSlot extends AbstractPacketAdapter {
|
public final class PacketSetCreativeSlot extends AbstractPacketAdapter {
|
||||||
private PacketSetCreativeSlot() {
|
public PacketSetCreativeSlot() {
|
||||||
super(PacketType.Play.Client.SET_CREATIVE_SLOT);
|
super(PacketType.Play.Client.SET_CREATIVE_SLOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,11 +17,4 @@ public final class PacketSetCreativeSlot extends AbstractPacketAdapter {
|
|||||||
return item;
|
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;
|
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||||
|
|
||||||
public final class PacketSetSlot extends AbstractPacketAdapter {
|
public final class PacketSetSlot extends AbstractPacketAdapter {
|
||||||
private PacketSetSlot() {
|
public PacketSetSlot() {
|
||||||
super(PacketType.Play.Server.SET_SLOT);
|
super(PacketType.Play.Server.SET_SLOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,11 +17,4 @@ public final class PacketSetSlot extends AbstractPacketAdapter {
|
|||||||
return item;
|
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;
|
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||||
|
|
||||||
public final class PacketWindowItems extends AbstractPacketAdapter {
|
public final class PacketWindowItems extends AbstractPacketAdapter {
|
||||||
private PacketWindowItems() {
|
public PacketWindowItems() {
|
||||||
super(PacketType.Play.Server.WINDOW_ITEMS);
|
super(PacketType.Play.Server.WINDOW_ITEMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,11 +17,4 @@ public final class PacketWindowItems extends AbstractPacketAdapter {
|
|||||||
return itemStacks;
|
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...");
|
Bukkit.getLogger().info("Loading ProtocolLib...");
|
||||||
EcoEnchantsPlugin.getInstance().protocolManager = ProtocolLibrary.getProtocolManager();
|
EcoEnchantsPlugin.getInstance().protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
PacketOpenWindowMerchant.getInstance().register();
|
new PacketOpenWindowMerchant().register();
|
||||||
PacketSetCreativeSlot.getInstance().register();
|
new PacketSetCreativeSlot().register();
|
||||||
PacketSetSlot.getInstance().register();
|
new PacketSetSlot().register();
|
||||||
PacketWindowItems.getInstance().register();
|
new PacketWindowItems().register();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Load land management support
|
Load land management support
|
||||||
|
Loading…
Reference in New Issue
Block a user