Updated a bunch of framework, removed useless functions and fixed possible N(2o) complexity issue.

This commit is contained in:
Paldiu 2021-02-22 08:45:56 -06:00
parent c28c7064a8
commit 267961ab38
9 changed files with 193 additions and 40 deletions

View File

@ -1,7 +1,7 @@
package io.github.paldiu.simplexcore; package io.github.paldiu.simplexcore;
import io.github.paldiu.simplexcore.command.defaults.Command_info; 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.ServerPluginListener;
import io.github.paldiu.simplexcore.listener.SimplexListener; import io.github.paldiu.simplexcore.listener.SimplexListener;
import io.github.paldiu.simplexcore.plugin.SimplexAddon; import io.github.paldiu.simplexcore.plugin.SimplexAddon;

View File

@ -58,7 +58,7 @@ public abstract class Ban implements IBan {
if (separateFiles) { if (separateFiles) {
Yaml yaml = new YamlFactory(Constants.getPlugin()).from(null, fileLocation, player.getName() + ".yml"); Yaml yaml = new YamlFactory(Constants.getPlugin()).from(null, fileLocation, player.getName() + ".yml");
yaml.getConfig().createSection(getOffender().toString()); yaml.getConfig().createSection(getOffender().toString());
ConfigurationSection section = yaml.getConfigurationSection(getOffender().toString()); ConfigurationSection section = yaml.getConfigurationSection(getOffender()::toString);
section.set("name", player.getName()); section.set("name", player.getName());
section.set("ban_id", banId); section.set("ban_id", banId);
section.set("sender", sender.getName()); section.set("sender", sender.getName());
@ -74,6 +74,7 @@ public abstract class Ban implements IBan {
yaml.reload(); yaml.reload();
} else { } else {
// TODO: Write to a single file as separate sections per UUID. // TODO: Write to a single file as separate sections per UUID.
Yaml yaml = new YamlFactory(Constants.getPlugin()).from(null, fileLocation, "bans.yml");
} }
} }
} }

View File

@ -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.chat.Messages;
import io.github.paldiu.simplexcore.utils.Constants; import io.github.paldiu.simplexcore.utils.Constants;

View File

@ -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.plugin.SimplexAddon;
import io.github.paldiu.simplexcore.utils.Constants; import io.github.paldiu.simplexcore.utils.Constants;

View File

@ -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<String> 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);
}

View File

@ -1,5 +1,94 @@
package io.github.paldiu.simplexcore.config; 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. // 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<String> 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;
}
} }

View File

@ -0,0 +1,6 @@
package io.github.paldiu.simplexcore.config;
@FunctionalInterface
public interface Path {
String getPath();
}

View File

@ -14,7 +14,7 @@ import java.io.IOException;
import java.nio.file.NotDirectoryException; import java.nio.file.NotDirectoryException;
import java.util.List; import java.util.List;
public final class Yaml { public final class Yaml implements IConfig {
private final SimplexAddon<?> plugin; private final SimplexAddon<?> plugin;
private final String fileName; private final String fileName;
private final File directory; private final File directory;
@ -37,72 +37,73 @@ public final class Yaml {
this.resourcePath = resourcePath; this.resourcePath = resourcePath;
} }
public final void set(String path, Object value) { @Override
this.getConfig().set(path, value); public final void set(Path path, Object value) {
this.getConfig().set(path.getPath(), value);
} }
public boolean contains(String path) { public boolean contains(Path path) {
return this.getConfig().contains(path); return this.getConfig().contains(path.getPath());
} }
public ConfigurationSection getConfigurationSection(String path) { public ConfigurationSection getConfigurationSection(Path path) {
return this.getConfig().getConfigurationSection(path); return this.getConfig().getConfigurationSection(path.getPath());
} }
public List<String> getStringList(String path) { public List<String> getStringList(Path path) {
return this.getConfig().getStringList(path); return this.getConfig().getStringList(path.getPath());
} }
public long getLong(String path) { public long getLong(Path path) {
return this.getConfig().getLong(path); return this.getConfig().getLong(path.getPath());
} }
public List<?> getList(String path) { public List<?> getList(Path path) {
return this.getConfig().getList(path); return this.getConfig().getList(path.getPath());
} }
public boolean getBoolean(String path) { public boolean getBoolean(Path path) {
return this.getConfig().getBoolean(path); return this.getConfig().getBoolean(path.getPath());
} }
public int getInt(String path) { public int getInt(Path path) {
return this.getConfig().getInt(path); return this.getConfig().getInt(path.getPath());
} }
public double getDouble(String path) { public double getDouble(Path path) {
return this.getConfig().getDouble(path); return this.getConfig().getDouble(path.getPath());
} }
public String getString(String path) { public String getString(Path path) {
return this.getConfig().getString(path); return this.getConfig().getString(path.getPath());
} }
public long getLong(String path, long def) { public long getLong(Path path, long def) {
return this.getConfig().getLong(path, def); return this.getConfig().getLong(path.getPath(), def);
} }
public List<?> getList(String path, List<?> def) { public List<?> getList(Path path, List<?> def) {
return this.getConfig().getList(path, def); return this.getConfig().getList(path.getPath(), def);
} }
public boolean getBoolean(String path, boolean def) { public boolean getBoolean(Path path, boolean def) {
return this.getConfig().getBoolean(path, def); return this.getConfig().getBoolean(path.getPath(), def);
} }
public int getInt(String path, int def) { public int getInt(Path path, int def) {
return this.getConfig().getInt(path, def); return this.getConfig().getInt(path.getPath(), def);
} }
public double getDouble(String path, double def) { public double getDouble(Path path, double def) {
return this.getConfig().getDouble(path, def); return this.getConfig().getDouble(path.getPath(), def);
} }
public String getString(String path, String def) { public String getString(Path path, String def) {
return this.getConfig().getString(path, def); return this.getConfig().getString(path.getPath(), def);
} }
public Object get(String path, Object def) { public Object get(Path path, Object def) {
return this.getConfig().get(path, def); return this.getConfig().get(path.getPath(), def);
} }
public final void reload() { public final void reload() {
@ -115,6 +116,7 @@ public final class Yaml {
} }
} }
} else { // Directory doesn't exist. } else { // Directory doesn't exist.
//noinspection ResultOfMethodCallIgnored
this.directory.mkdir(); // Make directory this.directory.mkdir(); // Make directory
} }
this.file = new File(this.directory, this.fileName); this.file = new File(this.directory, this.fileName);

View File

@ -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();
}