From 930e81c37e60e042b7ce885b3d1599564a982093 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 24 Mar 2017 15:52:37 +0100 Subject: [PATCH] Disable version field in editor. Softer class name rules. Minor field naming. --- .../command/editor/PropertyReflection.java | 4 ++++ .../store/migration/VersionMigratorRoot.java | 12 ++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/com/massivecraft/massivecore/command/editor/PropertyReflection.java b/src/com/massivecraft/massivecore/command/editor/PropertyReflection.java index 2ad2966e..2393727f 100644 --- a/src/com/massivecraft/massivecore/command/editor/PropertyReflection.java +++ b/src/com/massivecraft/massivecore/command/editor/PropertyReflection.java @@ -12,6 +12,7 @@ import com.massivecraft.massivecore.command.type.Type; import com.massivecraft.massivecore.command.type.TypeWrapper; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.particleeffect.ReflectionUtils; +import com.massivecraft.massivecore.store.migration.VersionMigrationUtil; import com.massivecraft.massivecore.util.ReflectionUtil; import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; @@ -230,6 +231,9 @@ public class PropertyReflection extends Property int modifiers = field.getModifiers(); if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || Modifier.isFinal(modifiers)) ret = false; + // Fill > Version + if (field.getName().equals(VersionMigrationUtil.VERSION_FIELD_NAME)) ret = false; + // Fill > Annotation ret = getAnnotationValue(field, EditorEditable.class, ret); diff --git a/src/com/massivecraft/massivecore/store/migration/VersionMigratorRoot.java b/src/com/massivecraft/massivecore/store/migration/VersionMigratorRoot.java index 9d455f85..e6619b94 100644 --- a/src/com/massivecraft/massivecore/store/migration/VersionMigratorRoot.java +++ b/src/com/massivecraft/massivecore/store/migration/VersionMigratorRoot.java @@ -91,13 +91,9 @@ public class VersionMigratorRoot implements VersionMigrator, Active public int getVersion() { String name = this.getClass().getSimpleName(); - if (!name.startsWith("V")) throw new UnsupportedOperationException(String.format("Name of %s doesn't start with \"V\".", name)); - if (!Character.isDigit(name.charAt(1))) throw new IllegalStateException(String.format("Second character of %s isn't a digit", name)); - Matcher matcher = Txt.PATTERN_NUMBER.matcher(name); if (!matcher.find()) throw new UnsupportedOperationException(String.format("%s doesn't have a version number.", name)); String number = matcher.group(); - return Integer.parseInt(number); } @@ -110,12 +106,12 @@ public class VersionMigratorRoot implements VersionMigrator, Active { if (entity == null) throw new NullPointerException("entity"); - // Get entity version and the expected entity version ... - int entityVersion = VersionMigrationUtil.getVersion(entity); - int expectedEntityVersion = this.getVersion() - 1; + // Get current and expected entity version ... + int entityVersionCurrent = VersionMigrationUtil.getVersion(entity); + int entityVersionExpected = this.getVersion() - 1; // ... make sure they match ... - if (entityVersion != expectedEntityVersion) throw new IllegalArgumentException(String.format("Entiy version: %d Expected: %d", entityVersion, expectedEntityVersion)); + if (entityVersionCurrent != entityVersionExpected) throw new IllegalArgumentException(String.format("Entiy version: %d Expected: %d", entityVersionCurrent, entityVersionExpected)); // ... do the migration. this.migrateInner(entity);