3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Checkstyle fixes and warnings.

Should get 'working' builds now.
Dieser Commit ist enthalten in:
wizjany 2019-03-11 00:02:51 -04:00
Ursprung bb33897221
Commit 6192ba8dc1
7 geänderte Dateien mit 37 neuen und 31 gelöschten Zeilen

Datei anzeigen

@ -5,8 +5,9 @@
<module name="Checker"> <module name="Checker">
<!-- Tabs are strictly banned --> <!-- Tabs are strictly banned -->
<module name="FileTabCharacter"/> <module name="FileTabCharacter"/>
<module name="SuppressWarningsFilter" />
<module name="TreeWalker"> <module name="TreeWalker">
<module name="SuppressWarningsHolder" /> <!-- allows for @SuppressWarnings annotation -->
<!-- Important basics --> <!-- Important basics -->
<!-- <module name="PackageDeclaration"/> Unlikely that we would miss this in a PR --> <!-- <module name="PackageDeclaration"/> Unlikely that we would miss this in a PR -->
<module name="OuterTypeFilename"/> <!-- TypeName -> TypeName.java --> <module name="OuterTypeFilename"/> <!-- TypeName -> TypeName.java -->

Datei anzeigen

@ -53,6 +53,7 @@
<allow pkg="org.lwjgl"/> <allow pkg="org.lwjgl"/>
<allow pkg="io.netty.buffer"/> <allow pkg="io.netty.buffer"/>
<allow pkg="org.spongepowered.api" /> <allow pkg="org.spongepowered.api" />
<allow pkg="com.mojang.brigadier" />
</subpackage> </subpackage>
<subpackage name="sponge"> <subpackage name="sponge">

Datei anzeigen

@ -24,12 +24,7 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode; import com.mojang.brigadier.tree.LiteralCommandNode;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.util.command.CommandMapping; import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Parameter; import com.sk89q.worldedit.util.command.Parameter;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
@ -38,11 +33,12 @@ import net.minecraft.entity.player.EntityPlayerMP;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.function.Predicate; import java.util.function.Predicate;
import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
import static net.minecraft.command.Commands.argument; import static net.minecraft.command.Commands.argument;
import static net.minecraft.command.Commands.literal; import static net.minecraft.command.Commands.literal;
public class CommandWrapper { public final class CommandWrapper {
private CommandWrapper() {
}
public static void register(CommandDispatcher<CommandSource> dispatcher, CommandMapping command) { public static void register(CommandDispatcher<CommandSource> dispatcher, CommandMapping command) {
LiteralArgumentBuilder<CommandSource> base = literal(command.getPrimaryAlias()); LiteralArgumentBuilder<CommandSource> base = literal(command.getPrimaryAlias());

Datei anzeigen

@ -33,10 +33,11 @@ public class GuiReferenceCard extends GuiScreen {
@Override @Override
public void initGui() { public void initGui() {
this.closeButton = new GuiButton(0, (this.width - this.backgroundWidth + 100) / 2, (this.height + this.backgroundHeight - 60) / 2, this.backgroundWidth - 100, 20, "Close") { this.closeButton = new GuiButton(0, (this.width - this.backgroundWidth + 100) / 2,
(this.height + this.backgroundHeight - 60) / 2, this.backgroundWidth - 100, 20, "Close") {
@Override @Override
public void onClick(double p_194829_1_, double p_194829_3_) { public void onClick(double mouseX, double mouseY) {
super.onClick(p_194829_1_, p_194829_3_); super.onClick(mouseX, mouseY);
mc.player.closeScreen(); mc.player.closeScreen();
} }

Datei anzeigen

@ -21,22 +21,25 @@ package com.sk89q.worldedit.forge.net.handler;
import com.sk89q.worldedit.forge.ForgeWorldEdit; import com.sk89q.worldedit.forge.ForgeWorldEdit;
import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage; import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage;
import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage.Handler;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.NetworkRegistry.ChannelBuilder;
import net.minecraftforge.fml.network.simple.SimpleChannel; import net.minecraftforge.fml.network.simple.SimpleChannel;
public class InternalPacketHandler { public final class InternalPacketHandler {
private static final String PROTOCOL_VERSION = Integer.toString(1); private static final String PROTOCOL_VERSION = Integer.toString(1);
public static SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder public static SimpleChannel HANDLER = ChannelBuilder
.named(new ResourceLocation(ForgeWorldEdit.MOD_ID, "internal")) .named(new ResourceLocation(ForgeWorldEdit.MOD_ID, "internal"))
.clientAcceptedVersions(PROTOCOL_VERSION::equals) .clientAcceptedVersions(PROTOCOL_VERSION::equals)
.serverAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals)
.networkProtocolVersion(() -> PROTOCOL_VERSION) .networkProtocolVersion(() -> PROTOCOL_VERSION)
.simpleChannel(); .simpleChannel();
public static void init() { private InternalPacketHandler() {
int disc = 0; }
HANDLER.registerMessage(disc++, LeftClickAirEventMessage.class, LeftClickAirEventMessage::encode, LeftClickAirEventMessage::decode, LeftClickAirEventMessage.Handler::handle); public static void init() {
HANDLER.registerMessage(0, LeftClickAirEventMessage.class,
LeftClickAirEventMessage::encode, LeftClickAirEventMessage::decode, Handler::handle);
} }
} }

Datei anzeigen

@ -26,18 +26,22 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.ThreadQuickExitException; import net.minecraft.network.ThreadQuickExitException;
import net.minecraft.network.play.server.SPacketCustomPayload; import net.minecraft.network.play.server.SPacketCustomPayload;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent.ClientCustomPayloadEvent;
import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.NetworkEvent.ServerCustomPayloadEvent;
import net.minecraftforge.fml.network.NetworkRegistry.ChannelBuilder;
import net.minecraftforge.fml.network.event.EventNetworkChannel; import net.minecraftforge.fml.network.event.EventNetworkChannel;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer; import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
public class WECUIPacketHandler { public final class WECUIPacketHandler {
private WECUIPacketHandler() {
}
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
private static final String PROTOCOL_VERSION = Integer.toString(1); private static final String PROTOCOL_VERSION = Integer.toString(1);
public static EventNetworkChannel HANDLER = NetworkRegistry.ChannelBuilder public static EventNetworkChannel HANDLER = ChannelBuilder
.named(new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) .named(new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL))
.clientAcceptedVersions(PROTOCOL_VERSION::equals) .clientAcceptedVersions(PROTOCOL_VERSION::equals)
.serverAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals)
@ -49,7 +53,7 @@ public class WECUIPacketHandler {
HANDLER.addListener(WECUIPacketHandler::callProcessPacket); HANDLER.addListener(WECUIPacketHandler::callProcessPacket);
} }
public static void onPacketData(NetworkEvent.ServerCustomPayloadEvent event) { public static void onPacketData(ServerCustomPayloadEvent event) {
EntityPlayerMP player = event.getSource().get().getSender(); EntityPlayerMP player = event.getSource().get().getSender();
LocalSession session = ForgeWorldEdit.inst.getSession(player); LocalSession session = ForgeWorldEdit.inst.getSession(player);
@ -62,13 +66,13 @@ public class WECUIPacketHandler {
session.describeCUI(adaptPlayer(player)); session.describeCUI(adaptPlayer(player));
} }
public static void callProcessPacket(NetworkEvent.ClientCustomPayloadEvent event) { public static void callProcessPacket(ClientCustomPayloadEvent event) {
try { try {
new SPacketCustomPayload( new SPacketCustomPayload(
new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL), new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL),
event.getPayload() event.getPayload()
).processPacket(Minecraft.getInstance().player.connection); ).processPacket(Minecraft.getInstance().player.connection);
} catch (ThreadQuickExitException suppress) { } catch (ThreadQuickExitException ignored) {
} }
} }
} }

Datei anzeigen

@ -22,20 +22,20 @@ package com.sk89q.worldedit.forge.net.packet;
import com.sk89q.worldedit.forge.ForgeWorldEdit; import com.sk89q.worldedit.forge.ForgeWorldEdit;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickEmpty;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent.Context;
import java.util.Objects;
import java.util.function.Supplier; import java.util.function.Supplier;
@SuppressWarnings({"NonFinalUtilityClass", "checkstyle:hideutilityclassconstructor"})
public class LeftClickAirEventMessage { public class LeftClickAirEventMessage {
public static final class Handler { public static final class Handler {
public static void handle(final LeftClickAirEventMessage message, Supplier<Context> ctx) {
public static void handle(final LeftClickAirEventMessage message, Supplier<NetworkEvent.Context> ctx) { Context context = ctx.get();
NetworkEvent.Context context = ctx.get(); context.enqueueWork(() -> ForgeWorldEdit.inst.onPlayerInteract(new LeftClickEmpty(Objects.requireNonNull(context.getSender()))));
context.enqueueWork(() -> ForgeWorldEdit.inst.onPlayerInteract(new PlayerInteractEvent.LeftClickEmpty(context.getSender())));
} }
} }
public static LeftClickAirEventMessage decode(ByteBuf buf) { public static LeftClickAirEventMessage decode(ByteBuf buf) {