Archiviert
13
0

Fix nonexistent field messages

Dieser Commit ist enthalten in:
Dan Mulloy 2015-01-31 00:54:55 -05:00
Ursprung bfb0683b1f
Commit 391970b185
2 geänderte Dateien mit 16 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -2,16 +2,16 @@
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland * Copyright (C) 2012 Kristian S. Stangeland
* *
* This program is free software; you can redistribute it and/or modify it under the terms of the * This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of * GNU General Public License as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along with this program; * You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
*/ */
@ -48,4 +48,10 @@ public class FieldAccessException extends RuntimeException {
public static FieldAccessException fromFormat(String message, Object... params) { public static FieldAccessException fromFormat(String message, Object... params) {
return new FieldAccessException(String.format(message, params)); return new FieldAccessException(String.format(message, params));
} }
@Override
public String toString() {
String message = getMessage();
return "FieldAccessException" + (message != null ? ": " + message : "");
}
} }

Datei anzeigen

@ -194,8 +194,8 @@ public class StructureModifier<TField> {
throw new FieldAccessException(String.format("Field index (%s) cannot be negative.", fieldIndex)); throw new FieldAccessException(String.format("Field index (%s) cannot be negative.", fieldIndex));
if (data.size() == 0) if (data.size() == 0)
throw new FieldAccessException(String.format("No field with type %s exists in class %s.", targetType.getName(), throw new FieldAccessException(String.format("No field with type %s exists in class %s.", fieldType.getName(),
target.getClass().getName())); target.getClass().getSimpleName()));
if (fieldIndex >= data.size()) if (fieldIndex >= data.size())
throw new FieldAccessException(String.format("Field index out of bounds. (Index: %s, Size: %s)", fieldIndex, data.size())); throw new FieldAccessException(String.format("Field index out of bounds. (Index: %s, Size: %s)", fieldIndex, data.size()));
@ -295,8 +295,8 @@ public class StructureModifier<TField> {
throw new FieldAccessException(String.format("Field index (%s) cannot be negative.", fieldIndex)); throw new FieldAccessException(String.format("Field index (%s) cannot be negative.", fieldIndex));
if (data.size() == 0) if (data.size() == 0)
throw new FieldAccessException(String.format("No field with type %s exists in class %s.", targetType.getName(), throw new FieldAccessException(String.format("No field with type %s exists in class %s.", fieldType.getName(),
target.getClass().getName())); target.getClass().getSimpleName()));
if (fieldIndex >= data.size()) if (fieldIndex >= data.size())
throw new FieldAccessException(String.format("Field index out of bounds. (Index: %s, Size: %s)", fieldIndex, data.size())); throw new FieldAccessException(String.format("Field index out of bounds. (Index: %s, Size: %s)", fieldIndex, data.size()));