Clean up a bunch

Mostly checked with IntelliJ, but manually performed. The only issue I possibly anticipate is item name/lore issues, but the new method should be technically better.
This commit is contained in:
Camotoy 2021-06-20 21:42:22 -04:00
parent 683ac1c763
commit 3a2cff7864
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
43 changed files with 125 additions and 190 deletions

View file

@ -32,17 +32,16 @@ import org.geysermc.connector.common.serializer.AsteriskSerializer;
import org.geysermc.connector.dump.BootstrapDumpInfo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@Getter
public class GeyserBungeeDumpInfo extends BootstrapDumpInfo {
private String platformName;
private String platformVersion;
private boolean onlineMode;
private List<ListenerInfo> listeners;
private List<PluginInfo> plugins;
private final String platformName;
private final String platformVersion;
private final boolean onlineMode;
private final List<ListenerInfo> listeners;
private final List<PluginInfo> plugins;
GeyserBungeeDumpInfo(ProxyServer proxy) {
super();
@ -63,7 +62,7 @@ public class GeyserBungeeDumpInfo extends BootstrapDumpInfo {
}
for (Plugin plugin : proxy.getPluginManager().getPlugins()) {
this.plugins.add(new PluginInfo(true, plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getMain(), Arrays.asList(plugin.getDescription().getAuthor())));
this.plugins.add(new PluginInfo(true, plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getMain(), Collections.singletonList(plugin.getDescription().getAuthor())));
}
}
}

View file

@ -37,7 +37,6 @@ import net.md_5.bungee.protocol.ProtocolConstants;
import org.geysermc.connector.common.ping.GeyserPingInfo;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Arrays;
@ -64,9 +63,8 @@ public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, List
new GeyserPingInfo.Version(response.getVersion().getName(), response.getVersion().getProtocol())
);
if (event.getResponse().getPlayers().getSample() != null) {
Arrays.stream(event.getResponse().getPlayers().getSample()).forEach(proxiedPlayer -> {
geyserPingInfo.getPlayerList().add(proxiedPlayer.getName());
});
Arrays.stream(event.getResponse().getPlayers().getSample()).forEach(proxiedPlayer ->
geyserPingInfo.getPlayerList().add(proxiedPlayer.getName()));
}
return geyserPingInfo;
}

View file

@ -37,13 +37,13 @@ import java.util.List;
@Getter
public class GeyserSpigotDumpInfo extends BootstrapDumpInfo {
private String platformName;
private String platformVersion;
private String platformAPIVersion;
private boolean onlineMode;
private String serverIP;
private int serverPort;
private List<PluginInfo> plugins;
private final String platformName;
private final String platformVersion;
private final String platformAPIVersion;
private final boolean onlineMode;
private final String serverIP;
private final int serverPort;
private final List<PluginInfo> plugins;
GeyserSpigotDumpInfo() {
super();

View file

@ -34,6 +34,7 @@ import org.bukkit.util.CachedServerIcon;
import org.geysermc.connector.common.ping.GeyserPingInfo;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import javax.annotation.Nonnull;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Collections;
@ -72,9 +73,10 @@ public class GeyserSpigotPingPassthrough implements IGeyserPingPassthrough {
public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
}
@Nonnull
@Override
public Iterator<Player> iterator() throws UnsupportedOperationException {
return Collections.EMPTY_LIST.iterator();
return Collections.emptyIterator();
}
}

View file

@ -150,7 +150,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
this.geyserSpigotPingPassthrough = new GeyserSpigotPingPassthrough(geyserLogger);
}
this.geyserCommandManager = new GeyserSpigotCommandManager(this, connector);
this.geyserCommandManager = new GeyserSpigotCommandManager(connector);
boolean isViaVersion = Bukkit.getPluginManager().getPlugin("ViaVersion") != null;
if (isViaVersion) {

View file

@ -30,7 +30,6 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandManager;
import org.geysermc.platform.spigot.GeyserSpigotPlugin;
import java.lang.reflect.Field;
@ -48,12 +47,8 @@ public class GeyserSpigotCommandManager extends CommandManager {
}
}
private GeyserSpigotPlugin plugin;
public GeyserSpigotCommandManager(GeyserSpigotPlugin plugin, GeyserConnector connector) {
public GeyserSpigotCommandManager(GeyserConnector connector) {
super(connector);
this.plugin = plugin;
}
@Override

View file

@ -93,7 +93,6 @@ public class GeyserSpigot1_12WorldManager extends GeyserSpigotWorldManager {
* @param z Z coordinate of block
* @return the block state updated to the latest Minecraft version
*/
@SuppressWarnings("deprecation")
public int getLegacyBlock(BlockStorage storage, int blockId, int x, int y, int z) {
// Convert block state from old version (1.12.2) -> 1.13 -> 1.13.1 -> 1.14 -> 1.15 -> 1.16 -> 1.16.2
blockId = mappingData1_12to1_13.getNewBlockId(blockId);

View file

@ -36,13 +36,12 @@ import java.util.List;
@Getter
public class GeyserSpongeDumpInfo extends BootstrapDumpInfo {
private String platformName;
private String platformVersion;
private boolean onlineMode;
private String serverIP;
private int serverPort;
private List<PluginInfo> plugins;
private final String platformName;
private final String platformVersion;
private final boolean onlineMode;
private final String serverIP;
private final int serverPort;
private final List<PluginInfo> plugins;
GeyserSpongeDumpInfo() {
super();

View file

@ -33,7 +33,6 @@ import org.geysermc.connector.common.ChatColor;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.LanguageUtils;
import org.spongepowered.api.command.CommandCallable;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.text.Text;
@ -81,7 +80,7 @@ public class GeyserSpongeCommandExecutor extends CommandExecutor implements Comm
}
@Override
public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException {
public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) {
if (arguments.split(" ").length == 1) {
return connector.getCommandManager().getCommandNames();
}

View file

@ -32,8 +32,7 @@ import org.spongepowered.api.command.CommandMapping;
import org.spongepowered.api.text.Text;
public class GeyserSpongeCommandManager extends CommandManager {
private org.spongepowered.api.command.CommandManager handle;
private final org.spongepowered.api.command.CommandManager handle;
public GeyserSpongeCommandManager(org.spongepowered.api.command.CommandManager handle, GeyserConnector connector) {
super(connector);
@ -43,6 +42,8 @@ public class GeyserSpongeCommandManager extends CommandManager {
@Override
public String getDescription(String command) {
return handle.get(command).map(CommandMapping::getCallable).map(callable -> callable.getShortDescription(Sponge.getServer().getConsole()).orElse(Text.EMPTY)).orElse(Text.EMPTY).toPlain();
return handle.get(command).map(CommandMapping::getCallable)
.map(callable -> callable.getShortDescription(Sponge.getServer().getConsole()).orElse(Text.EMPTY))
.orElse(Text.EMPTY).toPlain();
}
}

View file

@ -30,8 +30,7 @@ import org.geysermc.connector.dump.BootstrapDumpInfo;
@Getter
public class GeyserStandaloneDumpInfo extends BootstrapDumpInfo {
private boolean isGui;
private final boolean isGui;
GeyserStandaloneDumpInfo(GeyserStandaloneBootstrap bootstrap) {
super();

View file

@ -30,7 +30,6 @@ import org.geysermc.connector.utils.LanguageUtils;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Paths;
public class LoopbackUtil {
@ -54,7 +53,7 @@ public class LoopbackUtil {
String result = sb.toString();
if (!result.contains("minecraftuwp")) {
Files.write(Paths.get(System.getenv("temp") + "/loopback_minecraft.bat"), loopbackCommand.getBytes(), new OpenOption[0]);
Files.write(Paths.get(System.getenv("temp") + "/loopback_minecraft.bat"), loopbackCommand.getBytes());
Runtime.getRuntime().exec(startScript);
geyserLogger.info(ChatColor.AQUA + LanguageUtils.getLocaleStringLog("geyser.bootstrap.loopback.added"));

View file

@ -60,8 +60,8 @@ public class ColorPane extends JTextPane {
*/
public void appendANSI(String s) { // convert ANSI color codes first
int aPos = 0; // current char position in addString
int aIndex = 0; // index of next Escape sequence
int mIndex = 0; // index of "m" terminating Escape sequence
int aIndex; // index of next Escape sequence
int mIndex; // index of "m" terminating Escape sequence
String tmpString = "";
boolean stillSearching = true; // true until no more Escape sequences
String addString = remaining + s;
@ -83,7 +83,6 @@ public class ColorPane extends JTextPane {
// while there's text in the input buffer
stillSearching = true;
while (stillSearching) {
mIndex = addString.indexOf("m", aPos); // find the end of the escape sequence
if (mIndex < 0) { // the buffer ends halfway through the ansi string!

View file

@ -46,7 +46,7 @@ public final class GraphPanel extends JPanel {
private final static Color pointColor = new Color(100, 100, 100, 255);
private final static Color gridColor = new Color(200, 200, 200, 255);
private static final Stroke graphStroke = new BasicStroke(2f);
private List<Integer> values = new ArrayList<>(10);
private final List<Integer> values = new ArrayList<>(10);
@Setter
private String xLabel = "";
@ -172,6 +172,7 @@ public final class GraphPanel extends JPanel {
for (Point graphPoint : graphPoints) {
final int x = graphPoint.x - pointWidth / 2;
final int y = graphPoint.y - pointWidth / 2;
//noinspection SuspiciousNameCombination
g.fillOval(x, y, pointWidth, pointWidth);
}
}

View file

@ -37,13 +37,13 @@ import java.util.List;
@Getter
public class GeyserVelocityDumpInfo extends BootstrapDumpInfo {
private String platformName;
private String platformVersion;
private String platformVendor;
private boolean onlineMode;
private String serverIP;
private int serverPort;
private List<PluginInfo> plugins;
private final String platformName;
private final String platformVersion;
private final String platformVendor;
private final boolean onlineMode;
private final String serverIP;
private final int serverPort;
private final List<PluginInfo> plugins;
GeyserVelocityDumpInfo(ProxyServer proxy) {
super();