mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-16 20:31:30 +01:00
Fix viabackwards on 1.19.3
This commit is contained in:
parent
3ee17c6dae
commit
2e3ba077cf
@ -65,6 +65,7 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
@ -844,6 +845,15 @@ public class NMSImpl implements NMSBridge {
|
||||
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||
registerTraitWithCommand(manager, VillagerTrait.class);
|
||||
|
||||
if (VIA_ENABLED == null) {
|
||||
try {
|
||||
Via.getAPI();
|
||||
VIA_ENABLED = true;
|
||||
} catch (Throwable t) {
|
||||
VIA_ENABLED = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadEntityTypes() {
|
||||
@ -1234,7 +1244,12 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
NMSImpl.sendPacket(recipient, packet);
|
||||
return false;
|
||||
if (VIA_ENABLED == false)
|
||||
return false;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
int version = Via.getAPI().getPlayerVersion(recipient);
|
||||
return version < 761;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1258,9 +1273,8 @@ public class NMSImpl implements NMSBridge {
|
||||
Preconditions.checkNotNull(recipient);
|
||||
Preconditions.checkNotNull(listPlayer);
|
||||
|
||||
ServerPlayer entity = ((CraftPlayer) listPlayer).getHandle();
|
||||
|
||||
NMSImpl.sendPacket(recipient, new ClientboundPlayerInfoRemovePacket(Arrays.asList(entity.getUUID())));
|
||||
NMSImpl.sendPacket(recipient,
|
||||
new ClientboundPlayerInfoRemovePacket(Arrays.asList(getHandle(listPlayer).getUUID())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2334,6 +2348,7 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
private static final MethodHandle ADVANCEMENTS_PLAYER_FIELD = NMS.getFinalSetter(ServerPlayer.class, "cq");
|
||||
|
||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE,
|
||||
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
|
||||
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
|
||||
@ -2391,6 +2406,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getFirstSetter(Entity.class, EntityDimensions.class);
|
||||
private static Field SKULL_PROFILE_FIELD;
|
||||
private static MethodHandle TEAM_FIELD;
|
||||
private static Boolean VIA_ENABLED = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
|
@ -5,8 +5,6 @@ import java.lang.invoke.MethodHandle;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.nms.v1_19_R2.entity.EntityHumanNPC;
|
||||
@ -25,15 +23,6 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
||||
public PlayerlistTracker(ChunkMap map, Entity entity, int i, int j, boolean flag) {
|
||||
map.super(entity, i, j, flag);
|
||||
this.tracker = entity;
|
||||
|
||||
if (VIA_ENABLED == null) {
|
||||
try {
|
||||
Via.getAPI();
|
||||
VIA_ENABLED = true;
|
||||
} catch (Throwable t) {
|
||||
VIA_ENABLED = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerlistTracker(ChunkMap map, TrackedEntity entry) {
|
||||
@ -46,7 +35,7 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||
if (entityplayer == null)
|
||||
return;
|
||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||
boolean sendTabRemove = NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -54,12 +43,7 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
||||
}
|
||||
}, 1);
|
||||
|
||||
if (VIA_ENABLED == false || !Setting.DISABLE_TABLIST.asBoolean())
|
||||
return;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
int version = Via.getAPI().getPlayerVersion(entityplayer.getBukkitEntity());
|
||||
if (version >= 761 /* 1.19.3 */)
|
||||
if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean())
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@ -119,5 +103,4 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
||||
private static final MethodHandle TRACKER = NMS.getFirstGetter(TrackedEntity.class, Entity.class);
|
||||
private static final MethodHandle TRACKER_ENTRY = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class);
|
||||
private static final MethodHandle TRACKING_DISTANCE = NMS.getFirstGetter(TrackedEntity.class, int.class);
|
||||
private static Boolean VIA_ENABLED = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user