画饼
This commit is contained in:
35
src/main/java/com/ilummc/tlib/ExampleMain.java
Normal file
35
src/main/java/com/ilummc/tlib/ExampleMain.java
Normal 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() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/ilummc/tlib/annotations/Config.java
Normal file
19
src/main/java/com/ilummc/tlib/annotations/Config.java
Normal 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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ilummc.tlib.annotations;
|
||||
|
||||
public @interface ConfigNode {
|
||||
|
||||
String value();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ilummc.tlib.annotations;
|
||||
|
||||
public @interface Dependencies {
|
||||
|
||||
String[] value();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ilummc.tlib.annotations;
|
||||
|
||||
public @interface PluginInstance {
|
||||
|
||||
String value();
|
||||
}
|
||||
11
src/main/java/com/ilummc/tlib/annotations/db/Database.java
Normal file
11
src/main/java/com/ilummc/tlib/annotations/db/Database.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.ilummc.tlib.annotations.db;
|
||||
|
||||
public @interface Database {
|
||||
|
||||
boolean sharedPool() default true;
|
||||
|
||||
int poolSize() default 8;
|
||||
|
||||
Class<?> configClass();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.ilummc.tlib.annotations.db;
|
||||
|
||||
public @interface DatabasePassword {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.ilummc.tlib.annotations.db;
|
||||
|
||||
public @interface DatabaseType {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.ilummc.tlib.annotations.db;
|
||||
|
||||
public @interface DatabaseUrl {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.ilummc.tlib.annotations.db;
|
||||
|
||||
public @interface DatabaseUser {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ilummc.tlib.annotations.db;
|
||||
|
||||
public @interface SQLTable {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
||||
17
src/main/java/com/ilummc/tlib/bean/BooleanProperty.java
Normal file
17
src/main/java/com/ilummc/tlib/bean/BooleanProperty.java
Normal 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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
4
src/main/java/com/ilummc/tlib/bean/Property.java
Normal file
4
src/main/java/com/ilummc/tlib/bean/Property.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package com.ilummc.tlib.bean;
|
||||
|
||||
public class Property {
|
||||
}
|
||||
Reference in New Issue
Block a user