mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 20:16:02 +01:00
commit
da7a57026d
@ -67,9 +67,10 @@ public class PlayerSneakListener extends ViaBukkitListener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UserConnection userConnection = getUserConnection(player);
|
UserConnection userConnection = getUserConnection(player);
|
||||||
if (userConnection == null) return;
|
if (userConnection == null) return;
|
||||||
if (!userConnection.has(ProtocolInfo.class)) return;
|
ProtocolInfo info = userConnection.get(ProtocolInfo.class);
|
||||||
|
if (info == null) return;
|
||||||
|
|
||||||
int protocolVersion = userConnection.get(ProtocolInfo.class).getProtocolVersion();
|
int protocolVersion = info.getProtocolVersion();
|
||||||
if (is1_14Fix && protocolVersion >= ProtocolVersion.v1_14.getId()) {
|
if (is1_14Fix && protocolVersion >= ProtocolVersion.v1_14.getId()) {
|
||||||
setHeight(player, event.isSneaking() ? HEIGHT_1_14 : STANDING_HEIGHT);
|
setHeight(player, event.isSneaking() ? HEIGHT_1_14 : STANDING_HEIGHT);
|
||||||
if (!useCache) return;
|
if (!useCache) return;
|
||||||
|
@ -9,6 +9,7 @@ import us.myles.ViaVersion.ViaVersionPlugin;
|
|||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.ViaVersion;
|
import us.myles.ViaVersion.api.ViaVersion;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
@ -38,8 +39,9 @@ public class DeathListener extends ViaBukkitListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// If online
|
// If online
|
||||||
if (getUserConnection(p) != null) {
|
UserConnection userConnection = getUserConnection(p);
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
|
if (userConnection != null) {
|
||||||
|
PacketWrapper wrapper = new PacketWrapper(0x2C, null, userConnection);
|
||||||
try {
|
try {
|
||||||
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
|
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
|
||||||
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
|
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package us.myles.ViaVersion.bukkit.platform;
|
package us.myles.ViaVersion.bukkit.platform;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -116,8 +117,9 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
|||||||
@Override
|
@Override
|
||||||
public Item call() throws Exception {
|
public Item call() throws Exception {
|
||||||
UUID playerUUID = info.get(ProtocolInfo.class).getUuid();
|
UUID playerUUID = info.get(ProtocolInfo.class).getUuid();
|
||||||
if (Bukkit.getPlayer(playerUUID) != null) {
|
Player player = Bukkit.getPlayer(playerUUID);
|
||||||
return HandItemCache.convert(Bukkit.getPlayer(playerUUID).getItemInHand());
|
if (player != null) {
|
||||||
|
return HandItemCache.convert(player.getItemInHand());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
// 1.10 Entity / Object ids
|
// 1.10 Entity / Object ids
|
||||||
public class Entity1_10Types {
|
public class Entity1_10Types {
|
||||||
|
|
||||||
@ -113,6 +116,8 @@ public class Entity1_10Types {
|
|||||||
PLAYER(-1, ENTITY_HUMAN),
|
PLAYER(-1, ENTITY_HUMAN),
|
||||||
COMPLEX_PART(-1, ENTITY);
|
COMPLEX_PART(-1, ENTITY);
|
||||||
|
|
||||||
|
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType parent;
|
private final EntityType parent;
|
||||||
|
|
||||||
@ -121,15 +126,16 @@ public class Entity1_10Types {
|
|||||||
this.parent = null;
|
this.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (EntityType type : EntityType.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
public static Optional<EntityType> findById(int id) {
|
||||||
if (id == -1) // Check if this is called
|
if (id == -1) // Check if this is called
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,18 +168,21 @@ public class Entity1_10Types {
|
|||||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||||
|
|
||||||
|
private static final Map<Integer, ObjectTypes> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType type;
|
private final EntityType type;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (ObjectTypes type : ObjectTypes.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<ObjectTypes> findById(int id) {
|
public static Optional<ObjectTypes> findById(int id) {
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (ObjectTypes ent : ObjectTypes.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
public static Optional<EntityType> getPCEntity(int id) {
|
||||||
|
@ -5,6 +5,9 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
// 1.11 Entity / Object ids TODO maybe in the future instead of copying it, some api.
|
// 1.11 Entity / Object ids TODO maybe in the future instead of copying it, some api.
|
||||||
public class Entity1_11Types {
|
public class Entity1_11Types {
|
||||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||||
@ -140,6 +143,8 @@ public class Entity1_11Types {
|
|||||||
COMPLEX_PART(-1, ENTITY),
|
COMPLEX_PART(-1, ENTITY),
|
||||||
LIAMA_SPIT(-1, ENTITY);
|
LIAMA_SPIT(-1, ENTITY);
|
||||||
|
|
||||||
|
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType parent;
|
private final EntityType parent;
|
||||||
|
|
||||||
@ -148,15 +153,16 @@ public class Entity1_11Types {
|
|||||||
this.parent = null;
|
this.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (EntityType type : EntityType.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
public static Optional<EntityType> findById(int id) {
|
||||||
if (id == -1) // Check if this is called
|
if (id == -1) // Check if this is called
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is(EntityType... types) {
|
public boolean is(EntityType... types) {
|
||||||
@ -215,18 +221,21 @@ public class Entity1_11Types {
|
|||||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||||
|
|
||||||
|
private static final Map<Integer, ObjectTypes> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType type;
|
private final EntityType type;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (ObjectTypes type : ObjectTypes.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<ObjectTypes> findById(int id) {
|
public static Optional<ObjectTypes> findById(int id) {
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (ObjectTypes ent : ObjectTypes.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
public static Optional<EntityType> getPCEntity(int id) {
|
||||||
|
@ -15,6 +15,9 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
// 1.12 Entity / Object taken from https://github.com/Matsv/ViaBackwards/blob/master/core/src/main/java/nl/matsv/viabackwards/api/entities/types/EntityType1_12.java
|
// 1.12 Entity / Object taken from https://github.com/Matsv/ViaBackwards/blob/master/core/src/main/java/nl/matsv/viabackwards/api/entities/types/EntityType1_12.java
|
||||||
public class Entity1_12Types {
|
public class Entity1_12Types {
|
||||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||||
@ -153,6 +156,8 @@ public class Entity1_12Types {
|
|||||||
COMPLEX_PART(-1, ENTITY),
|
COMPLEX_PART(-1, ENTITY),
|
||||||
LIAMA_SPIT(-1, ENTITY);
|
LIAMA_SPIT(-1, ENTITY);
|
||||||
|
|
||||||
|
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType parent;
|
private final EntityType parent;
|
||||||
|
|
||||||
@ -161,15 +166,16 @@ public class Entity1_12Types {
|
|||||||
this.parent = null;
|
this.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (EntityType type : EntityType.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
public static Optional<EntityType> findById(int id) {
|
||||||
if (id == -1) // Check if this is called
|
if (id == -1) // Check if this is called
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is(EntityType... types) {
|
public boolean is(EntityType... types) {
|
||||||
@ -228,18 +234,21 @@ public class Entity1_12Types {
|
|||||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||||
|
|
||||||
|
private static final Map<Integer, ObjectTypes> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType type;
|
private final EntityType type;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (ObjectTypes type : ObjectTypes.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<ObjectTypes> findById(int id) {
|
public static Optional<ObjectTypes> findById(int id) {
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (ObjectTypes ent : ObjectTypes.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
public static Optional<EntityType> getPCEntity(int id) {
|
||||||
|
@ -5,6 +5,9 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
// TODO auto generate 18w11a with PAaaS
|
// TODO auto generate 18w11a with PAaaS
|
||||||
public class Entity1_13Types {
|
public class Entity1_13Types {
|
||||||
@ -196,6 +199,7 @@ public class Entity1_13Types {
|
|||||||
SPAWNER_MINECART(44, MINECART_ABSTRACT), // amb
|
SPAWNER_MINECART(44, MINECART_ABSTRACT), // amb
|
||||||
BOAT(5, ENTITY); // alv
|
BOAT(5, ENTITY); // alv
|
||||||
|
|
||||||
|
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType parent;
|
private final EntityType parent;
|
||||||
@ -205,15 +209,16 @@ public class Entity1_13Types {
|
|||||||
this.parent = null;
|
this.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (EntityType type : EntityType.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
public static Optional<EntityType> findById(int id) {
|
||||||
if (id == -1) // Check if this is called
|
if (id == -1) // Check if this is called
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is(EntityType... types) {
|
public boolean is(EntityType... types) {
|
||||||
@ -273,18 +278,21 @@ public class Entity1_13Types {
|
|||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
|
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
|
||||||
TRIDENT(94, EntityType.TRIDENT);
|
TRIDENT(94, EntityType.TRIDENT);
|
||||||
|
|
||||||
|
private static final Map<Integer, ObjectTypes> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType type;
|
private final EntityType type;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (ObjectTypes type : ObjectTypes.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<ObjectTypes> findById(int id) {
|
public static Optional<ObjectTypes> findById(int id) {
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (ObjectTypes ent : ObjectTypes.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
public static Optional<EntityType> getPCEntity(int id) {
|
||||||
|
@ -5,6 +5,9 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class Entity1_14Types {
|
public class Entity1_14Types {
|
||||||
public static EntityType getTypeFromId(int typeID) {
|
public static EntityType getTypeFromId(int typeID) {
|
||||||
@ -196,6 +199,8 @@ public class Entity1_14Types {
|
|||||||
BOAT(5, ENTITY),
|
BOAT(5, ENTITY),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final EntityType parent;
|
private final EntityType parent;
|
||||||
|
|
||||||
@ -204,15 +209,16 @@ public class Entity1_14Types {
|
|||||||
this.parent = null;
|
this.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (EntityType type : EntityType.values()) {
|
||||||
|
TYPES.put(type.id, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
public static Optional<EntityType> findById(int id) {
|
||||||
if (id == -1) // Check if this is called
|
if (id == -1)
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
|
return Optional.fromNullable(TYPES.get(id));
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is(EntityType... types) {
|
public boolean is(EntityType... types) {
|
||||||
|
@ -4,6 +4,7 @@ import lombok.Getter;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@ -31,7 +32,7 @@ public enum ArmorType {
|
|||||||
GOLD_BOOTS(1, 317, "minecraft:gold_boots"),
|
GOLD_BOOTS(1, 317, "minecraft:gold_boots"),
|
||||||
NONE(0, 0, "none");
|
NONE(0, 0, "none");
|
||||||
|
|
||||||
private static HashMap<Integer, ArmorType> armor;
|
private static Map<Integer, ArmorType> armor;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
armor = new HashMap<>();
|
armor = new HashMap<>();
|
||||||
@ -51,10 +52,8 @@ public enum ArmorType {
|
|||||||
* @return Return the ArmourType, ArmourType.NONE if not found
|
* @return Return the ArmourType, ArmourType.NONE if not found
|
||||||
*/
|
*/
|
||||||
public static ArmorType findById(int id) {
|
public static ArmorType findById(int id) {
|
||||||
for (ArmorType a : ArmorType.values())
|
ArmorType type = armor.get(id);
|
||||||
if (a.getId() == id)
|
return type == null ? ArmorType.NONE : type;
|
||||||
return a;
|
|
||||||
return ArmorType.NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,10 +76,7 @@ public enum ArmorType {
|
|||||||
* @return True if the item is a piece of armour
|
* @return True if the item is a piece of armour
|
||||||
*/
|
*/
|
||||||
public static boolean isArmor(int id) {
|
public static boolean isArmor(int id) {
|
||||||
for (ArmorType a : ArmorType.values())
|
return armor.containsKey(id);
|
||||||
if (a.getId() == id)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,8 @@ public class ViaIdleThread implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (UserConnection info : Via.getManager().getPortedPlayers().values()) {
|
for (UserConnection info : Via.getManager().getPortedPlayers().values()) {
|
||||||
if (info.has(ProtocolInfo.class) && info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9To1_8.class)) {
|
ProtocolInfo protocolInfo = info.get(ProtocolInfo.class);
|
||||||
|
if (protocolInfo != null && protocolInfo.getPipeline().contains(Protocol1_9To1_8.class)) {
|
||||||
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
||||||
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
||||||
if (info.getChannel().isOpen()) {
|
if (info.getChannel().isOpen()) {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Effect {
|
public class Effect {
|
||||||
|
|
||||||
private final static HashMap<Integer, Integer> effects;
|
private static final Map<Integer, Integer> effects;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
effects = new HashMap<>();
|
effects = new HashMap<>();
|
||||||
@ -29,9 +30,8 @@ public class Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getNewId(int id) {
|
public static int getNewId(int id) {
|
||||||
if (!contains(id))
|
Integer newId = effects.get(id);
|
||||||
return id;
|
return newId != null ? newId : id;
|
||||||
return effects.get(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean contains(int oldId) {
|
public static boolean contains(int oldId) {
|
||||||
|
@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum SoundEffect {
|
public enum SoundEffect {
|
||||||
@ -259,7 +260,7 @@ public enum SoundEffect {
|
|||||||
private final SoundCategory category;
|
private final SoundCategory category;
|
||||||
private final boolean breaksound;
|
private final boolean breaksound;
|
||||||
|
|
||||||
private static HashMap<String, SoundEffect> effects;
|
private static Map<String, SoundEffect> effects;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
effects = new HashMap<>();
|
effects = new HashMap<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user