diff --git a/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java b/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java index a16f4a1..8447bcc 100644 --- a/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java +++ b/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java @@ -1,7 +1,7 @@ package io.github.paldiu.simplexcore; import io.github.paldiu.simplexcore.command.defaults.Command_info; -import io.github.paldiu.simplexcore.future.Announcer; +import io.github.paldiu.simplexcore.concurrent.Announcer; import io.github.paldiu.simplexcore.listener.ServerPluginListener; import io.github.paldiu.simplexcore.listener.SimplexListener; import io.github.paldiu.simplexcore.plugin.SimplexAddon; diff --git a/src/main/java/io/github/paldiu/simplexcore/ban/Ban.java b/src/main/java/io/github/paldiu/simplexcore/ban/Ban.java index 729db59..2a490bb 100644 --- a/src/main/java/io/github/paldiu/simplexcore/ban/Ban.java +++ b/src/main/java/io/github/paldiu/simplexcore/ban/Ban.java @@ -58,7 +58,7 @@ public abstract class Ban implements IBan { if (separateFiles) { Yaml yaml = new YamlFactory(Constants.getPlugin()).from(null, fileLocation, player.getName() + ".yml"); yaml.getConfig().createSection(getOffender().toString()); - ConfigurationSection section = yaml.getConfigurationSection(getOffender().toString()); + ConfigurationSection section = yaml.getConfigurationSection(getOffender()::toString); section.set("name", player.getName()); section.set("ban_id", banId); section.set("sender", sender.getName()); @@ -74,6 +74,7 @@ public abstract class Ban implements IBan { yaml.reload(); } else { // TODO: Write to a single file as separate sections per UUID. + Yaml yaml = new YamlFactory(Constants.getPlugin()).from(null, fileLocation, "bans.yml"); } } } diff --git a/src/main/java/io/github/paldiu/simplexcore/future/Announcer.java b/src/main/java/io/github/paldiu/simplexcore/concurrent/Announcer.java similarity index 94% rename from src/main/java/io/github/paldiu/simplexcore/future/Announcer.java rename to src/main/java/io/github/paldiu/simplexcore/concurrent/Announcer.java index 0955332..994c587 100644 --- a/src/main/java/io/github/paldiu/simplexcore/future/Announcer.java +++ b/src/main/java/io/github/paldiu/simplexcore/concurrent/Announcer.java @@ -1,4 +1,4 @@ -package io.github.paldiu.simplexcore.future; +package io.github.paldiu.simplexcore.concurrent; import io.github.paldiu.simplexcore.chat.Messages; import io.github.paldiu.simplexcore.utils.Constants; diff --git a/src/main/java/io/github/paldiu/simplexcore/future/SimplexTask.java b/src/main/java/io/github/paldiu/simplexcore/concurrent/SimplexTask.java similarity index 97% rename from src/main/java/io/github/paldiu/simplexcore/future/SimplexTask.java rename to src/main/java/io/github/paldiu/simplexcore/concurrent/SimplexTask.java index 8963614..2f234a3 100644 --- a/src/main/java/io/github/paldiu/simplexcore/future/SimplexTask.java +++ b/src/main/java/io/github/paldiu/simplexcore/concurrent/SimplexTask.java @@ -1,4 +1,4 @@ -package io.github.paldiu.simplexcore.future; +package io.github.paldiu.simplexcore.concurrent; import io.github.paldiu.simplexcore.plugin.SimplexAddon; import io.github.paldiu.simplexcore.utils.Constants; diff --git a/src/main/java/io/github/paldiu/simplexcore/config/IConfig.java b/src/main/java/io/github/paldiu/simplexcore/config/IConfig.java new file mode 100644 index 0000000..04aa275 --- /dev/null +++ b/src/main/java/io/github/paldiu/simplexcore/config/IConfig.java @@ -0,0 +1,41 @@ +package io.github.paldiu.simplexcore.config; + +import org.bukkit.configuration.ConfigurationSection; + +import java.util.List; + +public interface IConfig { + void set(Path path, Object value); + + boolean contains(Path path); + + ConfigurationSection getConfigurationSection(Path path); + + List getStringList(Path path); + + long getLong(Path path); + + List getList(Path path); + + boolean getBoolean(Path path); + + int getInt(Path path); + + double getDouble(Path path); + + String getString(Path path); + + long getLong(Path path, long def); + + List getList(Path path, List def); + + boolean getBoolean(Path path, boolean def); + + int getInt(Path path, int def); + + double getDouble(Path path, double def); + + String getString(Path path, String def); + + Object get(Path path, Object def); +} diff --git a/src/main/java/io/github/paldiu/simplexcore/config/Json.java b/src/main/java/io/github/paldiu/simplexcore/config/Json.java index 6a2944c..658ccf1 100644 --- a/src/main/java/io/github/paldiu/simplexcore/config/Json.java +++ b/src/main/java/io/github/paldiu/simplexcore/config/Json.java @@ -1,5 +1,94 @@ package io.github.paldiu.simplexcore.config; -public class Json { +import org.bukkit.configuration.ConfigurationSection; + +import java.util.List; + +public class Json implements IConfig { // TODO: Write actual JSON implementations. + + @Override + public void set(Path path, Object value) { + + } + + @Override + public boolean contains(Path path) { + return false; + } + + @Override + public ConfigurationSection getConfigurationSection(Path path) { + return null; + } + + @Override + public List getStringList(Path path) { + return null; + } + + @Override + public long getLong(Path path) { + return 0; + } + + @Override + public List getList(Path path) { + return null; + } + + @Override + public boolean getBoolean(Path path) { + return false; + } + + @Override + public int getInt(Path path) { + return 0; + } + + @Override + public double getDouble(Path path) { + return 0; + } + + @Override + public String getString(Path path) { + return null; + } + + @Override + public long getLong(Path path, long def) { + return 0; + } + + @Override + public List getList(Path path, List def) { + return null; + } + + @Override + public boolean getBoolean(Path path, boolean def) { + return false; + } + + @Override + public int getInt(Path path, int def) { + return 0; + } + + @Override + public double getDouble(Path path, double def) { + return 0; + } + + @Override + public String getString(Path path, String def) { + return null; + } + + @Override + public Object get(Path path, Object def) { + return null; + } } diff --git a/src/main/java/io/github/paldiu/simplexcore/config/Path.java b/src/main/java/io/github/paldiu/simplexcore/config/Path.java new file mode 100644 index 0000000..ea08ec1 --- /dev/null +++ b/src/main/java/io/github/paldiu/simplexcore/config/Path.java @@ -0,0 +1,6 @@ +package io.github.paldiu.simplexcore.config; + +@FunctionalInterface +public interface Path { + String getPath(); +} diff --git a/src/main/java/io/github/paldiu/simplexcore/config/Yaml.java b/src/main/java/io/github/paldiu/simplexcore/config/Yaml.java index 56aacef..329360f 100644 --- a/src/main/java/io/github/paldiu/simplexcore/config/Yaml.java +++ b/src/main/java/io/github/paldiu/simplexcore/config/Yaml.java @@ -14,7 +14,7 @@ import java.io.IOException; import java.nio.file.NotDirectoryException; import java.util.List; -public final class Yaml { +public final class Yaml implements IConfig { private final SimplexAddon plugin; private final String fileName; private final File directory; @@ -37,72 +37,73 @@ public final class Yaml { this.resourcePath = resourcePath; } - public final void set(String path, Object value) { - this.getConfig().set(path, value); + @Override + public final void set(Path path, Object value) { + this.getConfig().set(path.getPath(), value); } - public boolean contains(String path) { - return this.getConfig().contains(path); + public boolean contains(Path path) { + return this.getConfig().contains(path.getPath()); } - public ConfigurationSection getConfigurationSection(String path) { - return this.getConfig().getConfigurationSection(path); + public ConfigurationSection getConfigurationSection(Path path) { + return this.getConfig().getConfigurationSection(path.getPath()); } - public List getStringList(String path) { - return this.getConfig().getStringList(path); + public List getStringList(Path path) { + return this.getConfig().getStringList(path.getPath()); } - public long getLong(String path) { - return this.getConfig().getLong(path); + public long getLong(Path path) { + return this.getConfig().getLong(path.getPath()); } - public List getList(String path) { - return this.getConfig().getList(path); + public List getList(Path path) { + return this.getConfig().getList(path.getPath()); } - public boolean getBoolean(String path) { - return this.getConfig().getBoolean(path); + public boolean getBoolean(Path path) { + return this.getConfig().getBoolean(path.getPath()); } - public int getInt(String path) { - return this.getConfig().getInt(path); + public int getInt(Path path) { + return this.getConfig().getInt(path.getPath()); } - public double getDouble(String path) { - return this.getConfig().getDouble(path); + public double getDouble(Path path) { + return this.getConfig().getDouble(path.getPath()); } - public String getString(String path) { - return this.getConfig().getString(path); + public String getString(Path path) { + return this.getConfig().getString(path.getPath()); } - public long getLong(String path, long def) { - return this.getConfig().getLong(path, def); + public long getLong(Path path, long def) { + return this.getConfig().getLong(path.getPath(), def); } - public List getList(String path, List def) { - return this.getConfig().getList(path, def); + public List getList(Path path, List def) { + return this.getConfig().getList(path.getPath(), def); } - public boolean getBoolean(String path, boolean def) { - return this.getConfig().getBoolean(path, def); + public boolean getBoolean(Path path, boolean def) { + return this.getConfig().getBoolean(path.getPath(), def); } - public int getInt(String path, int def) { - return this.getConfig().getInt(path, def); + public int getInt(Path path, int def) { + return this.getConfig().getInt(path.getPath(), def); } - public double getDouble(String path, double def) { - return this.getConfig().getDouble(path, def); + public double getDouble(Path path, double def) { + return this.getConfig().getDouble(path.getPath(), def); } - public String getString(String path, String def) { - return this.getConfig().getString(path, def); + public String getString(Path path, String def) { + return this.getConfig().getString(path.getPath(), def); } - public Object get(String path, Object def) { - return this.getConfig().get(path, def); + public Object get(Path path, Object def) { + return this.getConfig().get(path.getPath(), def); } public final void reload() { @@ -115,6 +116,7 @@ public final class Yaml { } } } else { // Directory doesn't exist. + //noinspection ResultOfMethodCallIgnored this.directory.mkdir(); // Make directory } this.file = new File(this.directory, this.fileName); diff --git a/src/main/java/io/github/paldiu/simplexcore/particle/IParticleEffect.java b/src/main/java/io/github/paldiu/simplexcore/particle/IParticleEffect.java new file mode 100644 index 0000000..87af799 --- /dev/null +++ b/src/main/java/io/github/paldiu/simplexcore/particle/IParticleEffect.java @@ -0,0 +1,14 @@ +package io.github.paldiu.simplexcore.particle; + +import org.bukkit.Color; +import org.bukkit.Particle; + +public interface IParticleEffect { + Particle[] getParticles(); + + Color[] getParticleColors(); + + Float getSize(); + + Long getDuration(); +}