From 391970b185432eb692d51954e0c2c711fdf455e2 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sat, 31 Jan 2015 00:54:55 -0500 Subject: [PATCH] Fix nonexistent field messages --- .../protocol/reflect/FieldAccessException.java | 18 ++++++++++++------ .../protocol/reflect/StructureModifier.java | 8 ++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldAccessException.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldAccessException.java index 3abec315..48bdac97 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldAccessException.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldAccessException.java @@ -2,16 +2,16 @@ * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. * Copyright (C) 2012 Kristian S. Stangeland * - * 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 + * 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 * 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; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * 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. * 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; - * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 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 * 02111-1307 USA */ @@ -48,4 +48,10 @@ public class FieldAccessException extends RuntimeException { public static FieldAccessException fromFormat(String message, Object... params) { return new FieldAccessException(String.format(message, params)); } + + @Override + public String toString() { + String message = getMessage(); + return "FieldAccessException" + (message != null ? ": " + message : ""); + } } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java index f3007930..92111264 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java @@ -194,8 +194,8 @@ public class StructureModifier { throw new FieldAccessException(String.format("Field index (%s) cannot be negative.", fieldIndex)); if (data.size() == 0) - throw new FieldAccessException(String.format("No field with type %s exists in class %s.", targetType.getName(), - target.getClass().getName())); + throw new FieldAccessException(String.format("No field with type %s exists in class %s.", fieldType.getName(), + target.getClass().getSimpleName())); if (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 { throw new FieldAccessException(String.format("Field index (%s) cannot be negative.", fieldIndex)); if (data.size() == 0) - throw new FieldAccessException(String.format("No field with type %s exists in class %s.", targetType.getName(), - target.getClass().getName())); + throw new FieldAccessException(String.format("No field with type %s exists in class %s.", fieldType.getName(), + target.getClass().getSimpleName())); if (fieldIndex >= data.size()) throw new FieldAccessException(String.format("Field index out of bounds. (Index: %s, Size: %s)", fieldIndex, data.size()));