From 7a12e0ce9ba2f7dc56d0e7254a0f450d5b17ae43 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Wed, 26 Oct 2016 17:04:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E5=91=BD=E5=90=8DNotSave?= =?UTF-8?q?=E4=B8=BAReadOnly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../{NotSave.java => ReadOnly.java} | 38 +++++++++---------- .../config/inject/AbstractInjectConfig.java | 4 +- 2 files changed, 21 insertions(+), 21 deletions(-) rename src/main/java/pw/yumc/YumCore/config/annotation/{NotSave.java => ReadOnly.java} (85%) diff --git a/src/main/java/pw/yumc/YumCore/config/annotation/NotSave.java b/src/main/java/pw/yumc/YumCore/config/annotation/ReadOnly.java similarity index 85% rename from src/main/java/pw/yumc/YumCore/config/annotation/NotSave.java rename to src/main/java/pw/yumc/YumCore/config/annotation/ReadOnly.java index 343410e..4809bc0 100644 --- a/src/main/java/pw/yumc/YumCore/config/annotation/NotSave.java +++ b/src/main/java/pw/yumc/YumCore/config/annotation/ReadOnly.java @@ -1,19 +1,19 @@ -package pw.yumc.YumCore.config.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 忽略配置保存 - * - * @author 喵♂呜 - * @since 2016年10月24日 上午00:11 - */ -@Target(ElementType.FIELD) -@Documented -@Retention(RetentionPolicy.RUNTIME) -public @interface NotSave { -} +package pw.yumc.YumCore.config.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 只读配置 + * + * @author 喵♂呜 + * @since 2016年10月24日 上午00:11 + */ +@Target(ElementType.FIELD) +@Documented +@Retention(RetentionPolicy.RUNTIME) +public @interface ReadOnly { +} diff --git a/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java b/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java index 075b0b8..7cd76e1 100644 --- a/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java +++ b/src/main/java/pw/yumc/YumCore/config/inject/AbstractInjectConfig.java @@ -14,8 +14,8 @@ import pw.yumc.YumCore.bukkit.Log; import pw.yumc.YumCore.commands.exception.CommandParseException; import pw.yumc.YumCore.config.annotation.ConfigNode; import pw.yumc.YumCore.config.annotation.Default; -import pw.yumc.YumCore.config.annotation.NotSave; import pw.yumc.YumCore.config.annotation.Nullable; +import pw.yumc.YumCore.config.annotation.ReadOnly; import pw.yumc.YumCore.config.exception.ConfigParseException; /** @@ -192,7 +192,7 @@ public abstract class AbstractInjectConfig { */ protected void setConfig(String path, Field field) { try { - if (field.getAnnotation(NotSave.class) == null) { + if (field.getAnnotation(ReadOnly.class) == null) { config.set(path, field.get(this)); } } catch (IllegalArgumentException | IllegalAccessException e) {