This commit is contained in:
Izzel_Aliz
2018-04-01 15:18:57 +08:00
parent f5d1edc9e0
commit 946adbb3eb
14 changed files with 252 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package com.ilummc.tlib;
import com.ilummc.tlib.annotations.Config;
import com.ilummc.tlib.annotations.ConfigNode;
import com.ilummc.tlib.bean.BooleanProperty;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Config(name = "cfg.yml", charset = "GBK")
public class ExampleMain extends JavaPlugin {
@ConfigNode("enableUpdate")
private BooleanProperty update = new BooleanProperty(true);
@Override
public void onEnable() {
update.addListener(((oldVal, newVal) -> {
Bukkit.getLogger().info("配置项 enableUpdate 的值由 " + oldVal + " 变为了 " + newVal);
if (newVal)
Updater.start();
else
Updater.stop();
}));
}
private static class Updater {
public static void start() {
}
public static void stop() {
}
}
}

View File

@@ -0,0 +1,19 @@
package com.ilummc.tlib.annotations;
public @interface Config {
String name() default "config.yml";
boolean fromJar() default true;
boolean saveOnExit() default false;
boolean readOnly() default true;
boolean fixUnicode() default true;
String charset() default "UTF-8";
boolean listenChanges() default false;
}

View File

@@ -0,0 +1,6 @@
package com.ilummc.tlib.annotations;
public @interface ConfigNode {
String value();
}

View File

@@ -0,0 +1,7 @@
package com.ilummc.tlib.annotations;
public @interface Dependencies {
String[] value();
}

View File

@@ -0,0 +1,6 @@
package com.ilummc.tlib.annotations;
public @interface PluginInstance {
String value();
}

View File

@@ -0,0 +1,11 @@
package com.ilummc.tlib.annotations.db;
public @interface Database {
boolean sharedPool() default true;
int poolSize() default 8;
Class<?> configClass();
}

View File

@@ -0,0 +1,4 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabasePassword {
}

View File

@@ -0,0 +1,4 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabaseType {
}

View File

@@ -0,0 +1,4 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabaseUrl {
}

View File

@@ -0,0 +1,4 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabaseUser {
}

View File

@@ -0,0 +1,7 @@
package com.ilummc.tlib.annotations.db;
public @interface SQLTable {
String value();
}

View File

@@ -0,0 +1,17 @@
package com.ilummc.tlib.bean;
import java.util.function.BiConsumer;
public class BooleanProperty {
private boolean property;
public BooleanProperty(boolean property) {
this.property = property;
}
public void addListener(BiConsumer<Boolean, Boolean> consumer) {
}
}

View File

@@ -0,0 +1,4 @@
package com.ilummc.tlib.bean;
public class Property {
}