Disable version field in editor. Softer class name rules. Minor field naming.
This commit is contained in:
parent
c7db1cf90d
commit
930e81c37e
@ -12,6 +12,7 @@ import com.massivecraft.massivecore.command.type.Type;
|
|||||||
import com.massivecraft.massivecore.command.type.TypeWrapper;
|
import com.massivecraft.massivecore.command.type.TypeWrapper;
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
import com.massivecraft.massivecore.particleeffect.ReflectionUtils;
|
import com.massivecraft.massivecore.particleeffect.ReflectionUtils;
|
||||||
|
import com.massivecraft.massivecore.store.migration.VersionMigrationUtil;
|
||||||
import com.massivecraft.massivecore.util.ReflectionUtil;
|
import com.massivecraft.massivecore.util.ReflectionUtil;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -230,6 +231,9 @@ public class PropertyReflection<O, V> extends Property<O, V>
|
|||||||
int modifiers = field.getModifiers();
|
int modifiers = field.getModifiers();
|
||||||
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || Modifier.isFinal(modifiers)) ret = false;
|
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
|
// Fill > Annotation
|
||||||
ret = getAnnotationValue(field, EditorEditable.class, ret);
|
ret = getAnnotationValue(field, EditorEditable.class, ret);
|
||||||
|
|
||||||
|
@ -91,13 +91,9 @@ public class VersionMigratorRoot implements VersionMigrator, Active
|
|||||||
public int getVersion()
|
public int getVersion()
|
||||||
{
|
{
|
||||||
String name = this.getClass().getSimpleName();
|
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);
|
Matcher matcher = Txt.PATTERN_NUMBER.matcher(name);
|
||||||
if (!matcher.find()) throw new UnsupportedOperationException(String.format("%s doesn't have a version number.", name));
|
if (!matcher.find()) throw new UnsupportedOperationException(String.format("%s doesn't have a version number.", name));
|
||||||
String number = matcher.group();
|
String number = matcher.group();
|
||||||
|
|
||||||
return Integer.parseInt(number);
|
return Integer.parseInt(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,12 +106,12 @@ public class VersionMigratorRoot implements VersionMigrator, Active
|
|||||||
{
|
{
|
||||||
if (entity == null) throw new NullPointerException("entity");
|
if (entity == null) throw new NullPointerException("entity");
|
||||||
|
|
||||||
// Get entity version and the expected entity version ...
|
// Get current and expected entity version ...
|
||||||
int entityVersion = VersionMigrationUtil.getVersion(entity);
|
int entityVersionCurrent = VersionMigrationUtil.getVersion(entity);
|
||||||
int expectedEntityVersion = this.getVersion() - 1;
|
int entityVersionExpected = this.getVersion() - 1;
|
||||||
|
|
||||||
// ... make sure they match ...
|
// ... 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.
|
// ... do the migration.
|
||||||
this.migrateInner(entity);
|
this.migrateInner(entity);
|
||||||
|
Loading…
Reference in New Issue
Block a user