forked from SteamWar/SteamWar
Fix REntity.getEquipmentPacket
Fix FightSchematic.pasteTeamName
This commit is contained in:
@@ -203,13 +203,23 @@ public class FightSchematic extends StateDependent {
|
|||||||
for(int i = 0; i < chars.length; i++){
|
for(int i = 0; i < chars.length; i++){
|
||||||
Clipboard character;
|
Clipboard character;
|
||||||
try {
|
try {
|
||||||
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
if (Character.isLowerCase(chars[i])) {
|
||||||
|
character = WorldeditWrapper.impl.loadChar("lower/" + chars[i]);
|
||||||
|
} else if (Character.isUpperCase(chars[i])) {
|
||||||
|
character = WorldeditWrapper.impl.loadChar("upper/" + chars[i]);
|
||||||
|
} else {
|
||||||
|
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", chars[i]);
|
|
||||||
try {
|
try {
|
||||||
character = WorldeditWrapper.impl.loadChar("");
|
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
||||||
}catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new SecurityException("Could not load text", ex);
|
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", chars[i]);
|
||||||
|
try {
|
||||||
|
character = WorldeditWrapper.impl.loadChar("");
|
||||||
|
}catch (IOException exc) {
|
||||||
|
throw new SecurityException("Could not load text", exc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ package de.steamwar.core;
|
|||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -33,8 +31,6 @@ import org.bukkit.GameMode;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.LongSupplier;
|
|
||||||
|
|
||||||
public class ProtocolWrapper21 implements ProtocolWrapper {
|
public class ProtocolWrapper21 implements ProtocolWrapper {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -443,12 +443,14 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Field<Integer> equipmentEntity = Reflection.getField(ProtocolWrapper.equipmentPacket, int.class, 0);
|
private static final Reflection.Field<Integer> equipmentEntity = Reflection.getField(ProtocolWrapper.equipmentPacket, int.class, 0);
|
||||||
|
private static final Reflection.Field<List> equipmentSlots = Reflection.getField(ProtocolWrapper.equipmentPacket, List.class, 0);
|
||||||
|
|
||||||
private static final Class<?> craftItemStack = Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack");
|
private static final Class<?> craftItemStack = Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack");
|
||||||
protected static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", ProtocolWrapper.itemStack, ItemStack.class);
|
protected static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", ProtocolWrapper.itemStack, ItemStack.class);
|
||||||
protected Object getEquipmentPacket(Object slot, ItemStack stack){
|
protected Object getEquipmentPacket(Object slot, ItemStack stack){
|
||||||
Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket);
|
Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket);
|
||||||
equipmentEntity.set(packet, entityId);
|
equipmentEntity.set(packet, entityId);
|
||||||
|
equipmentSlots.set(packet, new ArrayList<>());
|
||||||
ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack));
|
ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack));
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user