Remove ProtocolLib integration. Was only used by the Vampire plugin for which I will use ambient potion effects.
This commit is contained in:
parent
a071fd5058
commit
eb24a9d574
@ -26,7 +26,6 @@ import com.massivecraft.massivecore.cmd.massivecore.CmdMassiveCoreUsys;
|
||||
import com.massivecraft.massivecore.event.EventMassiveCoreUuidUpdate;
|
||||
import com.massivecraft.massivecore.fetcher.Fetcher;
|
||||
import com.massivecraft.massivecore.fetcher.IdAndName;
|
||||
import com.massivecraft.massivecore.integration.protocollib.IntegrationProtocolLib;
|
||||
import com.massivecraft.massivecore.integration.vault.IntegrationVault;
|
||||
import com.massivecraft.massivecore.mixin.EngineTeleportMixinCause;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
@ -192,7 +191,6 @@ public class MassiveCore extends MassivePlugin
|
||||
|
||||
// Integration
|
||||
this.integrate(
|
||||
IntegrationProtocolLib.get(),
|
||||
IntegrationVault.get()
|
||||
);
|
||||
|
||||
|
@ -1,92 +0,0 @@
|
||||
package com.massivecraft.massivecore.integration.protocollib;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import com.massivecraft.massivecore.MassiveCore;
|
||||
|
||||
public class EntityPotionColorPacketAdapter extends PacketAdapter
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private EntityPotionColorPacketAdapter()
|
||||
{
|
||||
super(PacketAdapter.params().plugin(MassiveCore.get()).serverSide().listenerPriority(ListenerPriority.NORMAL).types(PacketType.Play.Server.ENTITY_METADATA));
|
||||
}
|
||||
private static EntityPotionColorPacketAdapter i = new EntityPotionColorPacketAdapter();
|
||||
public static EntityPotionColorPacketAdapter get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// SETUP
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void setup()
|
||||
{
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the server is sending a meta-data packet to a sendee player...
|
||||
// NOTE: That must be the case. We are listening to no other situation.
|
||||
final PacketContainer packet = event.getPacket();
|
||||
final Player sendee = event.getPlayer();
|
||||
|
||||
// ... fetch the entity ...
|
||||
// NOTE: MetaData packets are only sent to players in the same world.
|
||||
final Entity entity = packet.getEntityModifier(sendee.getWorld()).read(0);
|
||||
|
||||
// Fireworks cannot have potion effects! They also reuse index 8
|
||||
// for sending their item stack, causing a crash if we don't bail out now.
|
||||
// We could have done: if (entity instanceof Firework) return;
|
||||
// But it's actually more safe to use a whitelist than a blacklist.
|
||||
if (!(entity instanceof LivingEntity)) return;
|
||||
|
||||
// ... fetch the metadata ...
|
||||
final List<WrappedWatchableObject> metadata = packet.getWatchableCollectionModifier().read(0);
|
||||
|
||||
// ... for each watchable in the metadata ...
|
||||
for (WrappedWatchableObject watchable : metadata)
|
||||
{
|
||||
// If the watchable is about potion effect color ...
|
||||
if (watchable.getIndex() != 7) continue;
|
||||
|
||||
// ... run our custom async event to allow changing it ...
|
||||
int oldColor = (Integer) watchable.getValue();
|
||||
EventMassiveCoreEntityPotionColor colorEvent = new EventMassiveCoreEntityPotionColor(sendee, entity, oldColor);
|
||||
colorEvent.run();
|
||||
int newColor = colorEvent.getColor();
|
||||
|
||||
// ... alter if changed.
|
||||
if (newColor != oldColor) watchable.setValue(newColor, false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Caught "+e.getClass().getName()+" exception in EntityPotionColorPacketAdapter#onPacketSending");
|
||||
System.out.println("Message: "+e.getMessage());
|
||||
System.out.println("Stack Trace:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.massivecraft.massivecore.integration.protocollib;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class EventMassiveCoreEntityPotionColor extends Event implements Runnable
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// REQUIRED EVENT CODE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@Override public HandlerList getHandlers() { return handlers; }
|
||||
public static HandlerList getHandlerList() { return handlers; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS & RAWDATA GET/SET
|
||||
// -------------------------------------------- //
|
||||
|
||||
private final Player sendee;
|
||||
public Player getSendee() { return this.sendee; }
|
||||
|
||||
// TODO: Should probably be made a LivingEntity instead?
|
||||
private final Entity entity;
|
||||
public Entity getEntity() { return this.entity; }
|
||||
|
||||
// http://www.wiki.vg/Entities#Index_8.2C_int:_Potion_effects
|
||||
private int color;
|
||||
public int getColor() { return this.color; }
|
||||
public void setColor(int color) { this.color = color; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public EventMassiveCoreEntityPotionColor(Player sendee, Entity entity, int color)
|
||||
{
|
||||
this.sendee = sendee;
|
||||
this.entity = entity;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// RUN
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getPluginManager().callEvent(this);
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.massivecraft.massivecore.integration.protocollib;
|
||||
|
||||
import com.massivecraft.massivecore.integration.IntegrationAbstract;
|
||||
|
||||
public class IntegrationProtocolLib extends IntegrationAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private IntegrationProtocolLib() { super("ProtocolLib"); }
|
||||
private static IntegrationProtocolLib i = new IntegrationProtocolLib();
|
||||
public static IntegrationProtocolLib get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
{
|
||||
EntityPotionColorPacketAdapter.get().setup();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user