Fix some more things picked up by static analysis.

This commit is contained in:
md_5 2014-07-12 19:30:00 +10:00
parent a6095c680f
commit 215b70dcd7
12 changed files with 25 additions and 54 deletions

View File

@ -7,10 +7,7 @@ import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;

View File

@ -8,8 +8,10 @@ import net.md_5.bungee.api.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.ToString;
@Setter @Setter
@ToString
@NoArgsConstructor @NoArgsConstructor
public abstract class BaseComponent public abstract class BaseComponent
{ {
@ -370,10 +372,4 @@ public abstract class BaseComponent
} }
} }
} }
@Override
public String toString()
{
return String.format( "BaseComponent{color=%s, bold=%b, italic=%b, underlined=%b, strikethrough=%b, obfuscated=%b, clickEvent=%s, hoverEvent=%s, extra=%s}", getColor().getName(), isBold(), isItalic(), isUnderlined(), isStrikethrough(), isObfuscated(), getClickEvent(), getHoverEvent(), getExtra() );
}
} }

View File

@ -1,14 +1,14 @@
package net.md_5.bungee.api.chat; package net.md_5.bungee.api.chat;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.ToString;
import net.md_5.bungee.api.chat.ClickEvent.Action; import net.md_5.bungee.api.chat.ClickEvent.Action;
@Getter @Getter
@AllArgsConstructor @ToString
final public class ClickEvent @RequiredArgsConstructor
public final class ClickEvent
{ {
/** /**
@ -42,15 +42,9 @@ final public class ClickEvent
RUN_COMMAND, RUN_COMMAND,
/** /**
* Inserts the string given by * Inserts the string given by
* {@link net.md_5.bungee.api.chat.ClickEvent#value} into the * {@link net.md_5.bungee.api.chat.ClickEvent#value} into the players
* players text box * text box
*/ */
SUGGEST_COMMAND SUGGEST_COMMAND
} }
@Override
public String toString()
{
return String.format( "ClickEvent{action=%s, value=%s}", action, value );
}
} }

View File

@ -1,8 +1,6 @@
package net.md_5.bungee.api.chat; package net.md_5.bungee.api.chat;
import lombok.NoArgsConstructor;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -28,7 +26,7 @@ public class ComponentBuilder
{ {
private TextComponent current; private TextComponent current;
private List<BaseComponent> parts = new ArrayList<>(); private final List<BaseComponent> parts = new ArrayList<>();
/** /**
* Creates a ComponentBuilder with the given text as the first part. * Creates a ComponentBuilder with the given text as the first part.

View File

@ -1,12 +1,12 @@
package net.md_5.bungee.api.chat; package net.md_5.bungee.api.chat;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.ToString;
@Getter @Getter
@AllArgsConstructor @ToString
@RequiredArgsConstructor
final public class HoverEvent final public class HoverEvent
{ {
@ -20,10 +20,4 @@ final public class HoverEvent
SHOW_ACHIEVEMENT, SHOW_ACHIEVEMENT,
SHOW_ITEM SHOW_ITEM
} }
@Override
public String toString()
{
return String.format( "HoverEvent{action=%s, value=%s}", action, value );
}
} }

View File

@ -121,8 +121,8 @@ public class TextComponent extends BaseComponent
components.add( component ); components.add( component );
} }
//The client will crash if the array is empty // The client will crash if the array is empty
if ( components.size() == 0 ) if ( components.isEmpty() )
{ {
components.add( new TextComponent( "" ) ); components.add( new TextComponent( "" ) );
} }

View File

@ -4,16 +4,16 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import lombok.ToString;
@Getter @Getter
@Setter @Setter
@ToString
@NoArgsConstructor @NoArgsConstructor
public class TranslatableComponent extends BaseComponent public class TranslatableComponent extends BaseComponent
{ {
@ -104,6 +104,7 @@ public class TranslatableComponent extends BaseComponent
protected void toPlainText(StringBuilder builder) protected void toPlainText(StringBuilder builder)
{ {
String trans = locales.getString( translate ); String trans = locales.getString( translate );
// TODO: Yell @ Thinkofdeath, this is impossible. getString(..) actually throws an exception when there is no string.
if ( trans == null ) if ( trans == null )
{ {
builder.append( translate ); builder.append( translate );
@ -212,10 +213,4 @@ public class TranslatableComponent extends BaseComponent
builder.append( ChatColor.MAGIC ); builder.append( ChatColor.MAGIC );
} }
} }
@Override
public String toString()
{
return String.format( "TranslatableComponent{translate=%s, with=%s, %s}", translate, with, super.toString() );
}
} }

View File

@ -5,7 +5,6 @@ import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.logging.Logger; import java.util.logging.Logger;
import lombok.Getter; import lombok.Getter;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;

View File

@ -49,8 +49,8 @@ public class PluginManager
private final Map<String, Plugin> plugins = new LinkedHashMap<>(); private final Map<String, Plugin> plugins = new LinkedHashMap<>();
private final Map<String, Command> commandMap = new HashMap<>(); private final Map<String, Command> commandMap = new HashMap<>();
private Map<String, PluginDescription> toLoad = new HashMap<>(); private Map<String, PluginDescription> toLoad = new HashMap<>();
private Multimap<Plugin, Command> commandsByPlugin = ArrayListMultimap.create(); private final Multimap<Plugin, Command> commandsByPlugin = ArrayListMultimap.create();
private Multimap<Plugin, Listener> listenersByPlugin = ArrayListMultimap.create(); private final Multimap<Plugin, Listener> listenersByPlugin = ArrayListMultimap.create();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public PluginManager(ProxyServer proxy) public PluginManager(ProxyServer proxy)
@ -191,7 +191,7 @@ public class PluginManager
PluginDescription plugin = entry.getValue(); PluginDescription plugin = entry.getValue();
if ( !enablePlugin( pluginStatuses, new Stack<PluginDescription>(), plugin ) ) if ( !enablePlugin( pluginStatuses, new Stack<PluginDescription>(), plugin ) )
{ {
ProxyServer.getInstance().getLogger().warning( "Failed to enable " + entry.getKey() ); ProxyServer.getInstance().getLogger().log( Level.WARNING, "Failed to enable {0}", entry.getKey() );
} }
} }
toLoad.clear(); toLoad.clear();
@ -247,7 +247,7 @@ public class PluginManager
dependencyGraph.append( element.getName() ).append( " -> " ); dependencyGraph.append( element.getName() ).append( " -> " );
} }
dependencyGraph.append( plugin.getName() ).append( " -> " ).append( dependName ); dependencyGraph.append( plugin.getName() ).append( " -> " ).append( dependName );
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Circular dependency detected: " + dependencyGraph ); ProxyServer.getInstance().getLogger().log( Level.WARNING, "Circular dependency detected: {0}", dependencyGraph );
status = false; status = false;
} else } else
{ {

View File

@ -11,7 +11,7 @@ public class GroupedThreadFactory implements ThreadFactory
private final ThreadGroup group; private final ThreadGroup group;
public class BungeeGroup extends ThreadGroup public static class BungeeGroup extends ThreadGroup
{ {
private BungeeGroup(String name) private BungeeGroup(String name)

View File

@ -7,8 +7,6 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.TranslatableComponent; import net.md_5.bungee.api.chat.TranslatableComponent;

View File

@ -31,7 +31,7 @@ public class TextComponentSerializer extends BaseComponentSerializer implements
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context) public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
{ {
List<BaseComponent> extra = src.getExtra(); List<BaseComponent> extra = src.getExtra();
if ( !src.hasFormatting() && ( extra == null || extra.size() == 0 ) ) if ( !src.hasFormatting() && ( extra == null || extra.isEmpty() ) )
{ {
return new JsonPrimitive( src.getText() ); return new JsonPrimitive( src.getText() );
} }