Implement new API

This commit is contained in:
fullwall 2023-01-05 20:05:15 +08:00
parent d9e7ec4ca3
commit 98c5c48c23
14 changed files with 238 additions and 140 deletions

View File

@ -10,7 +10,10 @@ import java.util.UUID;
import java.util.concurrent.Callable;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.inventory.InventoryType;
@ -34,9 +37,8 @@ import net.byteflux.libby.logging.LogLevel;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.CitizensPlugin;
import net.citizensnpcs.api.InventoryHelper;
import net.citizensnpcs.api.LocationLookup;
import net.citizensnpcs.api.SkullMetaProvider;
import net.citizensnpcs.api.NMSHelper;
import net.citizensnpcs.api.ai.speech.SpeechFactory;
import net.citizensnpcs.api.command.CommandManager;
import net.citizensnpcs.api.command.Injector;
@ -86,30 +88,15 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
private final CommandManager commands = new CommandManager();
private Settings config;
private boolean enabled;
private final InventoryHelper inventoryHelper = new InventoryHelper() {
@Override
public InventoryView openAnvilInventory(Player player, Inventory inventory, String title) {
return NMS.openAnvilInventory(player, inventory, title);
}
private LocationLookup locationLookup;
private final NMSHelper nmsHelper = new NMSHelper() {
private boolean SUPPORT_OWNER_PROFILE = true;
@Override
public void updateInventoryTitle(Player player, InventoryView view, String newTitle) {
if (view.getTopInventory().getType() == InventoryType.CRAFTING
|| view.getTopInventory().getType() == InventoryType.CREATIVE
|| view.getTopInventory().getType() == InventoryType.PLAYER)
return;
NMS.updateInventoryTitle(player, view, newTitle);
public OfflinePlayer getPlayer(BlockCommandSender sender) {
Entity entity = NMS.getSource(sender);
return entity != null && entity instanceof OfflinePlayer ? (OfflinePlayer) entity : null;
}
};
private LocationLookup locationLookup;
private CitizensNPCRegistry npcRegistry;
private ProtocolLibListener protocolListener;
private boolean saveOnDisable = true;
private NPCDataStore saves;
private NPCSelector selector;
private StoredShops shops;
private final SkullMetaProvider skullMetaProvider = new SkullMetaProvider() {
private boolean SUPPORT_OWNER_PROFILE = true;
@Override
public String getTexture(SkullMeta meta) {
@ -118,6 +105,11 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
: Iterables.getFirst(profile.getProperties().get("textures"), new Property("", "")).getValue();
}
@Override
public InventoryView openAnvilInventory(Player player, Inventory inventory, String title) {
return NMS.openAnvilInventory(player, inventory, title);
}
@Override
public void setTexture(String texture, SkullMeta meta) {
GameProfile profile = NMS.getProfile(meta);
@ -137,7 +129,22 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
profile.getProperties().put("textures", new Property("textures", texture));
NMS.setProfile(meta, profile);
}
@Override
public void updateInventoryTitle(Player player, InventoryView view, String newTitle) {
if (view.getTopInventory().getType() == InventoryType.CRAFTING
|| view.getTopInventory().getType() == InventoryType.CREATIVE
|| view.getTopInventory().getType() == InventoryType.PLAYER)
return;
NMS.updateInventoryTitle(player, view, newTitle);
}
};
private CitizensNPCRegistry npcRegistry;
private ProtocolLibListener protocolListener;
private boolean saveOnDisable = true;
private NPCDataStore saves;
private NPCSelector selector;
private StoredShops shops;
private CitizensSpeechFactory speechFactory;
private final Map<String, NPCRegistry> storedRegistries = Maps.newHashMap();
private CitizensTraitFactory traitFactory;
@ -229,11 +236,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
return selector;
}
@Override
public InventoryHelper getInventoryHelper() {
return inventoryHelper;
}
@Override
public LocationLookup getLocationLookup() {
return locationLookup;
@ -246,6 +248,11 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
return storedRegistries.get(name);
}
@Override
public NMSHelper getNMSHelper() {
return nmsHelper;
}
@Override
public Iterable<NPCRegistry> getNPCRegistries() {
return new Iterable<NPCRegistry>() {
@ -302,11 +309,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
return shops;
}
@Override
public SkullMetaProvider getSkullMetaProvider() {
return skullMetaProvider;
}
@Override
public SpeechFactory getSpeechFactory() {
return speechFactory;

View File

@ -11,6 +11,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
@ -379,6 +380,10 @@ public class NMS {
return BRIDGE.getSound(flag);
}
public static Entity getSource(BlockCommandSender sender) {
return BRIDGE.getSource(sender);
}
public static float getSpeedFor(NPC npc) {
return BRIDGE.getSpeedFor(npc);
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
@ -91,6 +92,8 @@ public interface NMSBridge {
public String getSound(String flag) throws CommandException;
public Entity getSource(BlockCommandSender sender);
public float getSpeedFor(NPC npc);
public float getStepHeight(Entity entity);
@ -146,9 +149,9 @@ public interface NMSBridge {
public void removeFromWorld(org.bukkit.entity.Entity entity);
public void removeHookIfNecessary(NPCRegistry npcRegistry, FishHook entity);
public void removeHookIfNecessary(NPCRegistry npcRegistry, FishHook entity);;
public void replaceTrackerEntry(Player player);;
public void replaceTrackerEntry(Player player);
public void sendPositionUpdate(Player excluding, Entity from, Location location);
@ -164,25 +167,25 @@ public interface NMSBridge {
public default void setAllayDancing(Entity entity, boolean dancing) {
throw new UnsupportedOperationException();
}
};
public void setBodyYaw(Entity entity, float yaw);;
public void setBodyYaw(Entity entity, float yaw);
public void setBoundingBox(Entity entity, BoundingBox box);
public default void setCamelPose(Entity entity, CamelPose pose) {
throw new UnsupportedOperationException();
}
};
public void setCustomName(Entity entity, Object component, String string);;
public void setDestination(Entity entity, double x, double y, double z, float speed);;
public void setDimensions(Entity entity, EntityDim desired);;
public void setDimensions(Entity entity, EntityDim desired);
public void setEndermanAngry(Enderman enderman, boolean angry);
public void setEndermanAngry(Enderman enderman, boolean angry);;
public void setHeadYaw(Entity entity, float yaw);;
public void setHeadYaw(Entity entity, float yaw);
public void setKnockbackResistance(LivingEntity entity, double d);

View File

@ -26,10 +26,12 @@ import org.bukkit.block.BlockFace;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
import org.bukkit.craftbukkit.v1_10_R1.CraftSound;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_10_R1.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWither;
@ -336,15 +338,6 @@ public class NMSImpl implements NMSBridge {
tracker.trackedPlayers.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -356,6 +349,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
tracker.trackedPlayers.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -534,6 +536,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getTileEntity().f();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))

View File

@ -26,10 +26,12 @@ import org.bukkit.block.BlockFace;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.CraftSound;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_11_R1.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftWither;
@ -357,15 +359,6 @@ public class NMSImpl implements NMSBridge {
tracker.trackedPlayers.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -377,6 +370,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
tracker.trackedPlayers.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -555,6 +557,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getTileEntity().f();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))

View File

@ -26,10 +26,12 @@ import org.bukkit.block.BlockFace;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.CraftSound;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_12_R1.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftWither;
@ -362,15 +364,6 @@ public class NMSImpl implements NMSBridge {
tracker.trackedPlayers.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -382,6 +375,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
tracker.trackedPlayers.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -554,6 +556,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getTileEntity().f();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))

View File

@ -27,11 +27,13 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
import org.bukkit.craftbukkit.v1_13_R2.CraftSound;
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_13_R2.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_13_R2.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftWither;
@ -383,15 +385,6 @@ public class NMSImpl implements NMSBridge {
tracker.trackedPlayers.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -403,6 +396,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
tracker.trackedPlayers.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -583,6 +585,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))

View File

@ -26,11 +26,13 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
import org.bukkit.craftbukkit.v1_14_R1.CraftSound;
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_14_R1.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_14_R1.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftWither;
@ -424,15 +426,6 @@ public class NMSImpl implements NMSBridge {
linked.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(linked)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -444,6 +437,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
linked.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(linked)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -620,6 +622,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))

View File

@ -26,11 +26,13 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
import org.bukkit.craftbukkit.v1_15_R1.CraftSound;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_15_R1.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_15_R1.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftWither;
@ -439,15 +441,6 @@ public class NMSImpl implements NMSBridge {
linked.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(linked)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -459,6 +452,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
linked.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(linked)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -635,6 +637,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))

View File

@ -26,11 +26,13 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
import org.bukkit.craftbukkit.v1_16_R3.CraftSound;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R3.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_16_R3.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftWither;
@ -448,15 +450,6 @@ public class NMSImpl implements NMSBridge {
linked.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(linked)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -468,6 +461,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
linked.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(linked)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -653,6 +655,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))

View File

@ -26,11 +26,13 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
import org.bukkit.craftbukkit.v1_17_R1.CraftSound;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_17_R1.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_17_R1.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftWither;
@ -464,15 +466,6 @@ public class NMSImpl implements NMSBridge {
linked.add(p.connection);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (ServerPlayerConnection link : Lists.newArrayList(linked)) {
Player entity = link.getPlayer().getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.sendChanges();
@ -484,6 +477,15 @@ public class NMSImpl implements NMSBridge {
tracker.removePairing(p);
linked.remove(p.connection);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (ServerPlayerConnection link : Lists.newArrayList(linked)) {
Player entity = link.getPlayer().getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -660,6 +662,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof org.bukkit.entity.LivingEntity))

View File

@ -25,11 +25,13 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
import org.bukkit.craftbukkit.v1_18_R2.CraftSound;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_18_R2.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_18_R2.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftWither;
@ -468,15 +470,6 @@ public class NMSImpl implements NMSBridge {
linked.add(p.connection);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (ServerPlayerConnection link : Lists.newArrayList(linked)) {
Player entity = link.getPlayer().getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.sendChanges();
@ -488,6 +481,15 @@ public class NMSImpl implements NMSBridge {
tracker.removePairing(p);
linked.remove(p.connection);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (ServerPlayerConnection link : Lists.newArrayList(linked)) {
Player entity = link.getPlayer().getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -666,6 +668,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof org.bukkit.entity.LivingEntity))

View File

@ -26,11 +26,13 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.CraftSound;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_19_R2.boss.CraftBossBar;
import org.bukkit.craftbukkit.v1_19_R2.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftWither;
@ -488,15 +490,6 @@ public class NMSImpl implements NMSBridge {
linked.add(p.connection);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (ServerPlayerConnection link : Lists.newArrayList(linked)) {
Player entity = link.getPlayer().getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.sendChanges();
@ -508,6 +501,15 @@ public class NMSImpl implements NMSBridge {
tracker.removePairing(p);
linked.remove(p.connection);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (ServerPlayerConnection link : Lists.newArrayList(linked)) {
Player entity = link.getPlayer().getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -686,6 +688,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getWrapper().getEntity();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof org.bukkit.entity.LivingEntity))

View File

@ -23,10 +23,12 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.CraftSound;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_8_R3.command.CraftBlockCommandSender;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWither;
@ -319,15 +321,6 @@ public class NMSImpl implements NMSBridge {
tracker.trackedPlayers.add(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
@Override
public void run() {
tracker.a();
@ -339,6 +332,15 @@ public class NMSImpl implements NMSBridge {
tracker.a(p);
tracker.trackedPlayers.remove(p);
}
@Override
public void unlinkAll(Consumer<Player> callback) {
for (EntityPlayer link : Lists.newArrayList(tracker.trackedPlayers)) {
Player entity = link.getBukkitEntity();
unlink(entity);
callback.accept(entity);
}
}
};
}
@ -487,6 +489,12 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public org.bukkit.entity.Entity getSource(BlockCommandSender sender) {
Entity source = ((CraftBlockCommandSender) sender).getTileEntity().f();
return source != null ? source.getBukkitEntity() : null;
}
@Override
public float getSpeedFor(NPC npc) {
if (!npc.isSpawned() || !(npc.getEntity() instanceof LivingEntity))