Tidy up code to make it consistent

This commit is contained in:
Myles 2018-10-27 12:25:42 +01:00
parent 2da9b99789
commit 0fb08be6e9
48 changed files with 1695 additions and 1707 deletions

View File

@ -6,7 +6,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import us.myles.ViaVersion.api.minecraft.item.Item;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class HandItemCache extends BukkitRunnable {

View File

@ -13,12 +13,12 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
import us.myles.ViaVersion.bukkit.listeners.UpdateListener;
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.*;
import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider;
import us.myles.ViaVersion.bukkit.providers.BukkitViaBulkChunkTranslator;
import us.myles.ViaVersion.bukkit.providers.BukkitViaMovementTransmitter;
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider;

View File

@ -1,19 +1,10 @@
package us.myles.ViaVersion.bukkit.providers;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
@ -25,6 +16,14 @@ import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQui
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage.ItemTransaction;
import us.myles.ViaVersion.util.ReflectionUtil;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider {
private static Map<UUID, BukkitInventoryUpdateTask> updateTasks = new ConcurrentHashMap<UUID, BukkitInventoryUpdateTask>();

View File

@ -1,16 +1,15 @@
package us.myles.ViaVersion.bukkit.tasks.protocol1_12to1_11_1;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage.ItemTransaction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage.ItemTransaction;
public class BukkitInventoryUpdateTask implements Runnable {
private BukkitInventoryQuickMoveProvider provider;

View File

@ -4,7 +4,6 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.MessageToMessageDecoder;
import us.myles.ViaVersion.api.Via;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

View File

@ -278,8 +278,8 @@ public class PacketWrapper {
* Be careful not to send packets twice.
* (Sends it after current)
*
* @param packetProtocol - The protocol version of the packet.
* @param skipCurrentPipeline - Skip the current pipeline
* @param packetProtocol The protocol version of the packet.
* @param skipCurrentPipeline Skip the current pipeline
* @throws Exception if it fails to write
*/
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
@ -291,9 +291,9 @@ public class PacketWrapper {
* Be careful not to send packets twice.
* (Sends it after current)
*
* @param packetProtocol - The protocol version of the packet.
* @param skipCurrentPipeline - Skip the current pipeline
* @param currentThread - Run in the same thread
* @param packetProtocol The protocol version of the packet.
* @param skipCurrentPipeline Skip the current pipeline
* @param currentThread Run in the same thread
* @throws Exception if it fails to write
*/
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
@ -306,8 +306,8 @@ public class PacketWrapper {
/**
* Let the packet go through the protocol pipes and write it to ByteBuf
*
* @param packetProtocol - The protocol version of the packet.
* @param skipCurrentPipeline - Skip the current pipeline
* @param packetProtocol The protocol version of the packet.
* @param skipCurrentPipeline Skip the current pipeline
* @return Packet buffer
* @throws Exception if it fails to write
*/
@ -343,7 +343,7 @@ public class PacketWrapper {
* Be careful not to send packets twice.
* (Sends it after current)
*
* @param packetProtocol - The protocol version of the packet.
* @param packetProtocol The protocol version of the packet.
* @throws Exception if it fails to write
*/
public void send(Class<? extends Protocol> packetProtocol) throws Exception {
@ -356,7 +356,7 @@ public class PacketWrapper {
* (Sends it after current)
* Also returns the packets ChannelFuture
*
* @param packetProtocol - The protocol version of the packet.
* @param packetProtocol The protocol version of the packet.
* @return The packets ChannelFuture
* @throws Exception if it fails to write
*/
@ -486,9 +486,9 @@ public class PacketWrapper {
/**
* Send this packet to the server.
*
* @param packetProtocol - The protocol version of the packet.
* @param skipCurrentPipeline - Skip the current pipeline
* @param currentThread - Run in the same thread
* @param packetProtocol The protocol version of the packet.
* @param skipCurrentPipeline Skip the current pipeline
* @param currentThread Run in the same thread
* @throws Exception if it fails to write
*/
public void sendToServer(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {

View File

@ -244,5 +244,7 @@ public class UserConnection {
*
* @param packet Raw packet to be sent
*/
public void sendRawPacketToServer(ByteBuf packet) { sendRawPacketToServer(packet, false); }
public void sendRawPacketToServer(ByteBuf packet) {
sendRawPacketToServer(packet, false);
}
}

View File

@ -8,12 +8,7 @@ import us.myles.ViaVersion.api.Via;
public class Entity1_14Types {
public static EntityType getTypeFromId(int typeID, boolean isObject) {
Optional<EntityType> type;
if (isObject)
type = ObjectTypes.getPCEntity(typeID);
else
type = EntityType.findById(typeID);
Optional<EntityType> type = isObject ? ObjectTypes.getPCEntity(typeID) : EntityType.findById(typeID);
if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID + " isObject=" + isObject);

View File

@ -13,6 +13,7 @@ import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.Protocol1_12_1TO1_12;
import us.myles.ViaVersion.protocols.protocol1_12_2to1_12_1.Protocol1_12_2TO1_12_1;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
@ -21,7 +22,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3TO1_9_1_2;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_9_1.Protocol1_9TO1_9_1;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

View File

@ -1,6 +1,5 @@
package us.myles.ViaVersion.api.type.types.minecraft;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.type.Type;

View File

@ -11,8 +11,8 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.MetadataRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
public class EntityPackets {

View File

@ -97,7 +97,6 @@ public class Protocol1_13To1_12_2 extends Protocol {
}
};
// @formatter:off
// These are arbitrary rewrite values, it just needs an invalid color code character.
protected static EnumMap<ChatColor, String> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<ChatColor, String>(ChatColor.class) {{
put(ChatColor.BLACK, ChatColor.COLOR_CHAR + "g");
@ -117,7 +116,6 @@ public class Protocol1_13To1_12_2 extends Protocol {
put(ChatColor.YELLOW, ChatColor.COLOR_CHAR + "!");
put(ChatColor.WHITE, ChatColor.COLOR_CHAR + "?");
}};
// @formatter:on
static {
MappingData.init();

View File

@ -6,97 +6,93 @@ import com.google.common.base.Optional;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
// Constant type changes to stop depending on names (the EntityTypes1_13 will be auto-generated so some fields can be obfuscated)
public class EntityTypeRewriter {
private static Map<Integer, Integer> entityTypes = new ConcurrentHashMap<>();
static {
// Generated by codename Bevet
// Entities 1.12 -> 18w15a
regEnt(1, 32); // item - ajl
regEnt(2, 22); // xp_orb - abx
regEnt(3, 0); // area_effect_cloud - abp
regEnt(4, 15); // elder_guardian - aju
regEnt(5, 84); // wither_skeleton - aku
regEnt(6, 71); // stray - akq
regEnt(7, 74); // egg - alz
regEnt(8, 35); // leash_knot - ajb
regEnt(9, 49); // painting - ajd
regEnt(10, 2); // arrow - all
regEnt(11, 67); // snowball - alw
regEnt(12, 34); // fireball - alq
regEnt(13, 65); // small_fireball - alv
regEnt(14, 75); // ender_pearl - ama
regEnt(15, 23); // eye_of_ender_signal - alo
regEnt(16, 77); // potion - amc
regEnt(17, 76); // xp_bottle - amb
regEnt(18, 33); // item_frame - aja
regEnt(19, 85); // wither_skull - ame
regEnt(20, 55); // tnt - ajm
regEnt(21, 24); // falling_block - ajk
regEnt(22, 25); // fireworks_rocket - alp
regEnt(23, 30); // husk - akc
regEnt(24, 68); // spectral_arrow - alx
regEnt(25, 60); // shulker_bullet - alu
regEnt(26, 13); // dragon_fireball - alm
regEnt(27, 89); // zombie_villager - akw
regEnt(28, 63); // skeleton_horse - aht
regEnt(29, 88); // zombie_horse - ahv
regEnt(30, 1); // armor_stand - aiy
regEnt(31, 11); // donkey - aho
regEnt(32, 46); // mule - ahs
regEnt(33, 20); // evocation_fangs - aln
regEnt(34, 21); // evocation_illager - ajy
regEnt(35, 78); // vex - akr
regEnt(36, 81); // vindication_illager - aks
regEnt(37, 31); // illusion_illager - akd
regEnt(40, 41); // commandblock_minecart - aml
regEnt(41, 5); // boat - ami
regEnt(42, 39); // minecart - amj
regEnt(43, 40); // chest_minecart - amk
regEnt(44, 42); // furnace_minecart - amm
regEnt(45, 45); // tnt_minecart - amp
regEnt(46, 43); // hopper_minecart - amn
regEnt(47, 44); // spawner_minecart - amo
regEnt(50, 10); // creeper - ajs
regEnt(51, 62); // skeleton - akm
regEnt(52, 69); // spider - akp
regEnt(53, 27); // giant - aka
regEnt(54, 87); // zombie - akv
regEnt(55, 64); // slime - akn
regEnt(56, 26); // ghast - ajz
regEnt(57, 53); // zombie_pigman - akh
regEnt(58, 18); // enderman - ajv
regEnt(59, 6); // cave_spider - ajr
regEnt(60, 61); // silverfish - akl
regEnt(61, 4); // blaze - ajq
regEnt(62, 38); // magma_cube - ake
regEnt(63, 17); // ender_dragon - aic
regEnt(64, 83); // wither - aiw
regEnt(65, 3); // bat - agl
regEnt(66, 82); // witch - akt
regEnt(67, 19); // endermite - ajw
regEnt(68, 28); // guardian - akb
regEnt(69, 59); // shulker - akk
regEnt(200, 16); // ender_crystal - aib
regEnt(90, 51); // pig - agy
regEnt(91, 58); // sheep - ahd
regEnt(92, 9); // cow - ags
regEnt(93, 7); // chicken - agq
regEnt(94, 70); // squid - ahg
regEnt(95, 86); // wolf - ahl
regEnt(96, 47); // mooshroom - agv
regEnt(97, 66); // snowman - ahf
regEnt(98, 48); // ocelot - agw
regEnt(99, 80); // villager_golem - ahj
regEnt(100, 29); // horse - ahp
regEnt(101, 56); // rabbit - ahb
regEnt(102, 54); // polar_bear - agz
regEnt(103, 36); // llama - ahr
regEnt(104, 37); // llama_spit - alr
regEnt(105, 50); // parrot - agx
regEnt(120, 79); // villager - ala
registerEntity(1, 32); // item - ajl
registerEntity(2, 22); // xp_orb - abx
registerEntity(3, 0); // area_effect_cloud - abp
registerEntity(4, 15); // elder_guardian - aju
registerEntity(5, 84); // wither_skeleton - aku
registerEntity(6, 71); // stray - akq
registerEntity(7, 74); // egg - alz
registerEntity(8, 35); // leash_knot - ajb
registerEntity(9, 49); // painting - ajd
registerEntity(10, 2); // arrow - all
registerEntity(11, 67); // snowball - alw
registerEntity(12, 34); // fireball - alq
registerEntity(13, 65); // small_fireball - alv
registerEntity(14, 75); // ender_pearl - ama
registerEntity(15, 23); // eye_of_ender_signal - alo
registerEntity(16, 77); // potion - amc
registerEntity(17, 76); // xp_bottle - amb
registerEntity(18, 33); // item_frame - aja
registerEntity(19, 85); // wither_skull - ame
registerEntity(20, 55); // tnt - ajm
registerEntity(21, 24); // falling_block - ajk
registerEntity(22, 25); // fireworks_rocket - alp
registerEntity(23, 30); // husk - akc
registerEntity(24, 68); // spectral_arrow - alx
registerEntity(25, 60); // shulker_bullet - alu
registerEntity(26, 13); // dragon_fireball - alm
registerEntity(27, 89); // zombie_villager - akw
registerEntity(28, 63); // skeleton_horse - aht
registerEntity(29, 88); // zombie_horse - ahv
registerEntity(30, 1); // armor_stand - aiy
registerEntity(31, 11); // donkey - aho
registerEntity(32, 46); // mule - ahs
registerEntity(33, 20); // evocation_fangs - aln
registerEntity(34, 21); // evocation_illager - ajy
registerEntity(35, 78); // vex - akr
registerEntity(36, 81); // vindication_illager - aks
registerEntity(37, 31); // illusion_illager - akd
registerEntity(40, 41); // commandblock_minecart - aml
registerEntity(41, 5); // boat - ami
registerEntity(42, 39); // minecart - amj
registerEntity(43, 40); // chest_minecart - amk
registerEntity(44, 42); // furnace_minecart - amm
registerEntity(45, 45); // tnt_minecart - amp
registerEntity(46, 43); // hopper_minecart - amn
registerEntity(47, 44); // spawner_minecart - amo
registerEntity(50, 10); // creeper - ajs
registerEntity(51, 62); // skeleton - akm
registerEntity(52, 69); // spider - akp
registerEntity(53, 27); // giant - aka
registerEntity(54, 87); // zombie - akv
registerEntity(55, 64); // slime - akn
registerEntity(56, 26); // ghast - ajz
registerEntity(57, 53); // zombie_pigman - akh
registerEntity(58, 18); // enderman - ajv
registerEntity(59, 6); // cave_spider - ajr
registerEntity(60, 61); // silverfish - akl
registerEntity(61, 4); // blaze - ajq
registerEntity(62, 38); // magma_cube - ake
registerEntity(63, 17); // ender_dragon - aic
registerEntity(64, 83); // wither - aiw
registerEntity(65, 3); // bat - agl
registerEntity(66, 82); // witch - akt
registerEntity(67, 19); // endermite - ajw
registerEntity(68, 28); // guardian - akb
registerEntity(69, 59); // shulker - akk
registerEntity(200, 16); // ender_crystal - aib
registerEntity(90, 51); // pig - agy
registerEntity(91, 58); // sheep - ahd
registerEntity(92, 9); // cow - ags
registerEntity(93, 7); // chicken - agq
registerEntity(94, 70); // squid - ahg
registerEntity(95, 86); // wolf - ahl
registerEntity(96, 47); // mooshroom - agv
registerEntity(97, 66); // snowman - ahf
registerEntity(98, 48); // ocelot - agw
registerEntity(99, 80); // villager_golem - ahj
registerEntity(100, 29); // horse - ahp
registerEntity(101, 56); // rabbit - ahb
registerEntity(102, 54); // polar_bear - agz
registerEntity(103, 36); // llama - ahr
registerEntity(104, 37); // llama_spit - alr
registerEntity(105, 50); // parrot - agx
registerEntity(120, 79); // villager - ala
// OBJECTS
@ -104,7 +100,7 @@ public class EntityTypeRewriter {
}
private static void regEnt(int type1_12, int type1_13) {
private static void registerEntity(int type1_12, int type1_13) {
entityTypes.put(type1_12, type1_13);
}

View File

@ -56,7 +56,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
if (groundUp) {
for (int i = 0; i < 256; i++) {
// todo use int in Chunk?
biomeData[i] = (byte) input.readInt();;
biomeData[i] = (byte) input.readInt();
}
}

View File

@ -7,6 +7,7 @@ import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
@ -16,7 +17,6 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.CommandBlockProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds.Effect;

View File

@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.type.PartialType;
import us.myles.ViaVersion.api.type.Type;
@ -12,7 +13,6 @@ import us.myles.ViaVersion.api.type.types.version.Types1_8;
import us.myles.ViaVersion.api.type.types.version.Types1_9;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import java.util.ArrayList;

View File

@ -42,7 +42,8 @@
<configuration>
<!-- We only run lombok and not sponge in-built mcmod.info generator due to issues with multiversion -->
<annotationProcessors>
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor
</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>

View File

@ -17,7 +17,6 @@ import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.scheduler.Task;
import org.spongepowered.api.text.serializer.TextSerializers;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaAPI;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
import us.myles.ViaVersion.api.platform.TaskId;
@ -32,10 +31,8 @@ import us.myles.ViaVersion.util.GsonUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
@Plugin(id = "viaversion",