mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 00:37:36 +00:00
Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
e80e3a5121
@ -1,8 +1,8 @@
|
||||
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.listener.ServerPluginListener;
|
||||
import io.github.paldiu.simplexcore.concurrent.Announcer;
|
||||
import io.github.paldiu.simplexcore.listener.DependencyListener;
|
||||
import io.github.paldiu.simplexcore.listener.SimplexListener;
|
||||
import io.github.paldiu.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.paldiu.simplexcore.utils.Constants;
|
||||
@ -35,7 +35,7 @@ public final class SimplexCore extends SimplexAddon<SimplexCore> {
|
||||
Constants.getCommandLoader().classpath(Command_info.class).load();
|
||||
Constants.getConfig().reload();
|
||||
//
|
||||
SimplexListener.register(new ServerPluginListener(), this);
|
||||
SimplexListener.register(new DependencyListener(), this);
|
||||
new Announcer();
|
||||
} catch (Exception ex) {
|
||||
suspended = true;
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -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;
|
@ -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);
|
||||
}
|
@ -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<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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package io.github.paldiu.simplexcore.config;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Path {
|
||||
String getPath();
|
||||
}
|
@ -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<String> getStringList(String path) {
|
||||
return this.getConfig().getStringList(path);
|
||||
public List<String> 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);
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.event.server.PluginEnableEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class ServerPluginListener extends SimplexListener {
|
||||
public final class DependencyListener extends SimplexListener {
|
||||
public List<String> PAPI_NAMES = new ArrayList<>() {{
|
||||
add("PlaceholderAPI");
|
||||
add("PlaceHolderAPI");
|
@ -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();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package io.github.paldiu.simplexcore.sign;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public interface IUsableSign {
|
||||
Block getBlock();
|
||||
|
||||
Location getSignLocation();
|
||||
|
||||
World getWorld();
|
||||
|
||||
String getSignText();
|
||||
|
||||
void executeOnInteract();
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package io.github.paldiu.simplexcore.structures;
|
||||
|
||||
import io.github.paldiu.simplexcore.math.Size;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public interface IStructure {
|
||||
NamespacedKey getNamespacedKey();
|
||||
|
||||
String getName();
|
||||
|
||||
int getId();
|
||||
|
||||
Location getLocation();
|
||||
|
||||
World getWorld();
|
||||
|
||||
boolean shouldGenerateNaturally();
|
||||
|
||||
void generate(Location location, World world);
|
||||
|
||||
void generate(Location location, World world, boolean generateNaturally);
|
||||
|
||||
Size getApproximateSize();
|
||||
|
||||
Block[] getBlocks();
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package io.github.paldiu.simplexcore.structures;
|
||||
|
||||
public class Structure {
|
||||
// TODO: Write this file to parse schematics.
|
||||
}
|
Loading…
Reference in New Issue
Block a user