mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 09:07:37 +00:00
actually indent array types in toml
add a default config file instead of generation for commenting purposes add a random gradient placeholder and a converter for legacy colorcodes
This commit is contained in:
parent
4e9984f251
commit
f52c8462ae
@ -1,37 +0,0 @@
|
||||
package com.moandjiezana.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.moandjiezana.toml.ArrayValueReader.ARRAY_VALUE_READER;
|
||||
import static com.moandjiezana.toml.BooleanValueReaderWriter.BOOLEAN_VALUE_READER_WRITER;
|
||||
import static com.moandjiezana.toml.DateValueReaderWriter.DATE_VALUE_READER_WRITER;
|
||||
import static com.moandjiezana.toml.InlineTableValueReader.INLINE_TABLE_VALUE_READER;
|
||||
import static com.moandjiezana.toml.LiteralStringValueReader.LITERAL_STRING_VALUE_READER;
|
||||
import static com.moandjiezana.toml.MultilineLiteralStringValueReader.MULTILINE_LITERAL_STRING_VALUE_READER;
|
||||
import static com.moandjiezana.toml.MultilineStringValueReader.MULTILINE_STRING_VALUE_READER;
|
||||
import static com.moandjiezana.toml.NumberValueReaderWriter.NUMBER_VALUE_READER_WRITER;
|
||||
import static com.moandjiezana.toml.StringValueReaderWriter.STRING_VALUE_READER_WRITER;
|
||||
|
||||
class ValueReaders {
|
||||
|
||||
static final ValueReaders VALUE_READERS = new ValueReaders();
|
||||
|
||||
Object convert(String value, AtomicInteger index, Context context) {
|
||||
String substring = value.substring(index.get());
|
||||
for (ValueReader valueParser : READERS) {
|
||||
if (valueParser.canRead(substring)) {
|
||||
return valueParser.read(value, index, context);
|
||||
}
|
||||
}
|
||||
|
||||
Results.Errors errors = new Results.Errors();
|
||||
errors.invalidValue(context.identifier.getName(), substring, context.line.get());
|
||||
return errors;
|
||||
}
|
||||
|
||||
private ValueReaders() {}
|
||||
|
||||
private static final ValueReader[] READERS = {
|
||||
MULTILINE_STRING_VALUE_READER, MULTILINE_LITERAL_STRING_VALUE_READER, LITERAL_STRING_VALUE_READER, STRING_VALUE_READER_WRITER, DATE_VALUE_READER_WRITER, NUMBER_VALUE_READER_WRITER, BOOLEAN_VALUE_READER_WRITER, ARRAY_VALUE_READER, INLINE_TABLE_VALUE_READER
|
||||
};
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.moandjiezana.toml;
|
||||
|
||||
import static com.moandjiezana.toml.MapValueWriter.MAP_VALUE_WRITER;
|
||||
import static com.moandjiezana.toml.NumberValueReaderWriter.NUMBER_VALUE_READER_WRITER;
|
||||
|
||||
class ValueWriters {
|
||||
|
||||
static final ValueWriters WRITERS = new ValueWriters();
|
||||
|
||||
ValueWriter findWriterFor(Object value) {
|
||||
for (ValueWriter valueWriter : VALUE_WRITERS) {
|
||||
if (valueWriter.canWrite(value)) {
|
||||
return valueWriter;
|
||||
}
|
||||
}
|
||||
|
||||
return ObjectValueWriter.OBJECT_VALUE_WRITER;
|
||||
}
|
||||
|
||||
private ValueWriters() {}
|
||||
|
||||
private static DateValueReaderWriter getPlatformSpecificDateConverter() {
|
||||
String specificationVersion = Runtime.class.getPackage().getSpecificationVersion();
|
||||
return specificationVersion != null && specificationVersion.startsWith("1.6") ? DateValueReaderWriter.DATE_PARSER_JDK_6 : DateValueReaderWriter.DATE_VALUE_READER_WRITER;
|
||||
}
|
||||
|
||||
private static final ValueWriter[] VALUE_WRITERS = {
|
||||
StringValueReaderWriter.STRING_VALUE_READER_WRITER, NUMBER_VALUE_READER_WRITER, BooleanValueReaderWriter.BOOLEAN_VALUE_READER_WRITER, getPlatformSpecificDateConverter(),
|
||||
MAP_VALUE_WRITER, PrimitiveArrayValueWriter.PRIMITIVE_ARRAY_VALUE_WRITER, TableArrayValueWriter.TABLE_ARRAY_VALUE_WRITER
|
||||
};
|
||||
}
|
@ -14,9 +14,17 @@ import lombok.Getter;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Credits for TOML library go to https://github.com/mwanji/toml4j
|
||||
* I was unable to add it back to the package without it glitching, so
|
||||
* I kept it in a separate package.
|
||||
*
|
||||
* Modifications: Properly indent arrays in TOML as well as only append
|
||||
* missing object fields into the file
|
||||
*/
|
||||
|
||||
@Plugin(
|
||||
name = "Plex",
|
||||
id = "plex",
|
||||
@ -62,7 +70,7 @@ public class Plex
|
||||
{
|
||||
PlexLog.log("Loaded configuration 'config.toml'");
|
||||
});
|
||||
this.config.create(false);
|
||||
this.config.create(true);
|
||||
this.config.write(new ServerSettings());
|
||||
new ListenerHandler();
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package dev.plex.config;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import com.moandjiezana.toml.Toml;
|
||||
import com.moandjiezana.toml.TomlWriter;
|
||||
import dev.plex.toml.Toml;
|
||||
import dev.plex.toml.TomlWriter;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -31,23 +31,24 @@ public class TomlConfig
|
||||
|
||||
public void create(boolean loadFromFile)
|
||||
{
|
||||
if (loadFromFile)
|
||||
if (!this.file.exists())
|
||||
{
|
||||
try
|
||||
if (loadFromFile)
|
||||
{
|
||||
Files.copy(Plex.get().getClass().getResourceAsStream("/" + this.file.getName()), this.file.toPath());
|
||||
this.load();
|
||||
if (this.onCreate != null)
|
||||
try
|
||||
{
|
||||
this.onCreate.accept(this.toml);
|
||||
Files.copy(Plex.get().getClass().getResourceAsStream("/" + this.file.getName()), this.file.toPath());
|
||||
this.load();
|
||||
if (this.onCreate != null)
|
||||
{
|
||||
this.onCreate.accept(this.toml);
|
||||
}
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
} else if (!this.file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
this.file.createNewFile();
|
||||
@ -81,7 +82,9 @@ public class TomlConfig
|
||||
|
||||
public <T> void write(T object)
|
||||
{
|
||||
TomlWriter writer = new TomlWriter();
|
||||
TomlWriter writer = new TomlWriter.Builder()
|
||||
.indentValuesBy(2)
|
||||
.build();
|
||||
try
|
||||
{
|
||||
writer.write(object, this.file);
|
||||
|
@ -3,6 +3,7 @@ package dev.plex.listener.impl;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.settings.ServerSettings;
|
||||
@ -11,7 +12,11 @@ import dev.plex.util.RandomUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ServerListener extends PlexListener
|
||||
{
|
||||
@ -21,9 +26,8 @@ public class ServerListener extends PlexListener
|
||||
String baseMotd = plugin.getConfig().as(ServerSettings.class).getServer().getMotd();
|
||||
baseMotd = baseMotd.replace("\\n", "\n");
|
||||
baseMotd = baseMotd.replace("%servername%", plugin.getConfig().as(ServerSettings.class).getServer().getName());
|
||||
baseMotd = baseMotd.replace("%mcversion%", plugin.getServer().getVersion().getVersion());
|
||||
|
||||
PlexLog.log(baseMotd);
|
||||
baseMotd = baseMotd.replace("%mcversion%", plugin.getServer().getVersion().getVersion().split(" ")[0]);
|
||||
baseMotd = baseMotd.replace("%randomgradient%", "<gradient:" + RandomUtil.getRandomColor().toString() + ":" + RandomUtil.getRandomColor().toString() + ">");
|
||||
|
||||
if (plugin.getConfig().as(ServerSettings.class).getServer().isColorizeMotd())
|
||||
{
|
||||
@ -33,10 +37,16 @@ public class ServerListener extends PlexListener
|
||||
motd.set(motd.get().append(Component.text(word).color(RandomUtil.getRandomColor())));
|
||||
motd.set(motd.get().append(Component.space()));
|
||||
}
|
||||
event.setPing(event.getPing().asBuilder().description(motd.get()).build());
|
||||
event.setPing(event.getPing().asBuilder().description(motd.get()).samplePlayers(plugin.getConfig().as(ServerSettings.class).getServer().getSample().stream().map(s -> new ServerPing.SamplePlayer(convertColorCodes(s), UUID.randomUUID())).toArray(ServerPing.SamplePlayer[]::new)).build());
|
||||
} else {
|
||||
event.setPing(event.getPing().asBuilder().description(MiniMessage.miniMessage().deserialize(baseMotd)).build());
|
||||
event.setPing(event.getPing().asBuilder().description(MiniMessage.miniMessage().deserialize(baseMotd)).samplePlayers(plugin.getConfig().as(ServerSettings.class).getServer().getSample().stream().map(s -> new ServerPing.SamplePlayer(convertColorCodes(s), UUID.randomUUID())).toArray(ServerPing.SamplePlayer[]::new)).build());
|
||||
}
|
||||
}
|
||||
|
||||
private String convertColorCodes(String code)
|
||||
{
|
||||
Matcher matcher = Pattern.compile("[&][0-9a-fk-or]{1}").matcher(code);
|
||||
return matcher.replaceAll(matchResult -> "§" + matcher.group().substring(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ public class ServerSettings
|
||||
|
||||
@Data
|
||||
public static class Server {
|
||||
private String name = "Plexus";
|
||||
private String motd = "Test MOTD";
|
||||
private String name = "Server";
|
||||
private String motd = "%randomgradient%%servername% - %mcversion%";
|
||||
private boolean colorizeMotd = false;
|
||||
private boolean debug = false;
|
||||
private final List<String> sample = Lists.newArrayList("example", "example");
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -13,14 +13,14 @@ public class ArrayValueReader implements ValueReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(String s, AtomicInteger index, Context context) {
|
||||
public Object read(String s, AtomicInteger index, dev.plex.toml.Context context) {
|
||||
AtomicInteger line = context.line;
|
||||
int startLine = line.get();
|
||||
int startIndex = index.get();
|
||||
List<Object> arrayItems = new ArrayList<Object>();
|
||||
boolean terminated = false;
|
||||
boolean inComment = false;
|
||||
Results.Errors errors = new Results.Errors();
|
||||
dev.plex.toml.Results.Errors errors = new dev.plex.toml.Results.Errors();
|
||||
|
||||
for (int i = index.incrementAndGet(); i < s.length(); i = index.incrementAndGet()) {
|
||||
|
||||
@ -35,8 +35,8 @@ public class ArrayValueReader implements ValueReader {
|
||||
continue;
|
||||
} else if (c == '[') {
|
||||
Object converted = read(s, index, context);
|
||||
if (converted instanceof Results.Errors) {
|
||||
errors.add((Results.Errors) converted);
|
||||
if (converted instanceof dev.plex.toml.Results.Errors) {
|
||||
errors.add((dev.plex.toml.Results.Errors) converted);
|
||||
} else if (!isHomogenousArray(converted, arrayItems)) {
|
||||
errors.heterogenous(context.identifier.getName(), line.get());
|
||||
} else {
|
||||
@ -48,8 +48,8 @@ public class ArrayValueReader implements ValueReader {
|
||||
break;
|
||||
} else {
|
||||
Object converted = ValueReaders.VALUE_READERS.convert(s, index, context);
|
||||
if (converted instanceof Results.Errors) {
|
||||
errors.add((Results.Errors) converted);
|
||||
if (converted instanceof dev.plex.toml.Results.Errors) {
|
||||
errors.add((dev.plex.toml.Results.Errors) converted);
|
||||
} else if (!isHomogenousArray(converted, arrayItems)) {
|
||||
errors.heterogenous(context.identifier.getName(), line.get());
|
||||
} else {
|
@ -1,13 +1,14 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static com.moandjiezana.toml.ValueWriters.WRITERS;
|
||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||
|
||||
public abstract class ArrayValueWriter implements ValueWriter {
|
||||
public abstract class ArrayValueWriter implements dev.plex.toml.ValueWriter
|
||||
{
|
||||
static protected boolean isArrayish(Object value) {
|
||||
return value instanceof Collection || value.getClass().isArray();
|
||||
}
|
||||
@ -20,7 +21,7 @@ public abstract class ArrayValueWriter implements ValueWriter {
|
||||
static boolean isArrayOfPrimitive(Object array) {
|
||||
Object first = peek(array);
|
||||
if (first != null) {
|
||||
ValueWriter valueWriter = WRITERS.findWriterFor(first);
|
||||
dev.plex.toml.ValueWriter valueWriter = WRITERS.findWriterFor(first);
|
||||
return valueWriter.isPrimitiveType() || isArrayish(first);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
@ -1,19 +1,19 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Context {
|
||||
final Identifier identifier;
|
||||
final dev.plex.toml.Identifier identifier;
|
||||
final AtomicInteger line;
|
||||
final Results.Errors errors;
|
||||
|
||||
public Context(Identifier identifier, AtomicInteger line, Results.Errors errors) {
|
||||
public Context(dev.plex.toml.Identifier identifier, AtomicInteger line, Results.Errors errors) {
|
||||
this.identifier = identifier;
|
||||
this.line = line;
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
public Context with(Identifier identifier) {
|
||||
public Context with(dev.plex.toml.Identifier identifier) {
|
||||
return new Context(identifier, line, errors);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
public class Identifier
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
/**
|
||||
* Controls how a {@link TomlWriter} indents tables and key/value pairs.
|
@ -1,9 +1,10 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
class InlineTableValueReader implements ValueReader {
|
||||
class InlineTableValueReader implements dev.plex.toml.ValueReader
|
||||
{
|
||||
|
||||
static final InlineTableValueReader INLINE_TABLE_VALUE_READER = new InlineTableValueReader();
|
||||
|
||||
@ -13,7 +14,7 @@ class InlineTableValueReader implements ValueReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(String s, AtomicInteger sharedIndex, Context context) {
|
||||
public Object read(String s, AtomicInteger sharedIndex, dev.plex.toml.Context context) {
|
||||
AtomicInteger line = context.line;
|
||||
int startLine = line.get();
|
||||
int startIndex = sharedIndex.get();
|
||||
@ -22,16 +23,16 @@ class InlineTableValueReader implements ValueReader {
|
||||
boolean terminated = false;
|
||||
StringBuilder currentKey = new StringBuilder();
|
||||
HashMap<String, Object> results = new HashMap<String, Object>();
|
||||
Results.Errors errors = new Results.Errors();
|
||||
dev.plex.toml.Results.Errors errors = new dev.plex.toml.Results.Errors();
|
||||
|
||||
for (int i = sharedIndex.incrementAndGet(); sharedIndex.get() < s.length(); i = sharedIndex.incrementAndGet()) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
if (inValue && !Character.isWhitespace(c)) {
|
||||
Object converted = ValueReaders.VALUE_READERS.convert(s, sharedIndex, context.with(Identifier.from(currentKey.toString(), context)));
|
||||
Object converted = dev.plex.toml.ValueReaders.VALUE_READERS.convert(s, sharedIndex, context.with(dev.plex.toml.Identifier.from(currentKey.toString(), context)));
|
||||
|
||||
if (converted instanceof Results.Errors) {
|
||||
errors.add((Results.Errors) converted);
|
||||
if (converted instanceof dev.plex.toml.Results.Errors) {
|
||||
errors.add((dev.plex.toml.Results.Errors) converted);
|
||||
return errors;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -12,7 +12,7 @@ public class LiteralStringValueReader implements ValueReader
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(String s, AtomicInteger index, Context context)
|
||||
public Object read(String s, AtomicInteger index, dev.plex.toml.Context context)
|
||||
{
|
||||
int startLine = context.line.get();
|
||||
boolean terminated = false;
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
@ -6,9 +6,9 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class MapValueWriter implements ValueWriter
|
||||
class MapValueWriter implements dev.plex.toml.ValueWriter
|
||||
{
|
||||
static final ValueWriter MAP_VALUE_WRITER = new MapValueWriter();
|
||||
static final dev.plex.toml.ValueWriter MAP_VALUE_WRITER = new MapValueWriter();
|
||||
|
||||
private static final Pattern REQUIRED_QUOTING_PATTERN = Pattern.compile("^.*[^A-Za-z\\d_-].*$");
|
||||
|
||||
@ -75,15 +75,16 @@ class MapValueWriter implements ValueWriter
|
||||
}
|
||||
}
|
||||
|
||||
ValueWriter valueWriter = ValueWriters.WRITERS.findWriterFor(fromValue);
|
||||
dev.plex.toml.ValueWriter valueWriter = dev.plex.toml.ValueWriters.WRITERS.findWriterFor(fromValue);
|
||||
if (valueWriter.isPrimitiveType())
|
||||
{
|
||||
context.indent();
|
||||
context.write(quoteKey(key)).write(" = ");
|
||||
valueWriter.write(fromValue, context);
|
||||
context.write('\n');
|
||||
} else if (valueWriter == PrimitiveArrayValueWriter.PRIMITIVE_ARRAY_VALUE_WRITER)
|
||||
} else if (valueWriter == dev.plex.toml.PrimitiveArrayValueWriter.PRIMITIVE_ARRAY_VALUE_WRITER)
|
||||
{
|
||||
context.indent();
|
||||
context.setArrayKey(key.toString());
|
||||
context.write(quoteKey(key)).write(" = ");
|
||||
valueWriter.write(fromValue, context);
|
||||
@ -109,8 +110,8 @@ class MapValueWriter implements ValueWriter
|
||||
}
|
||||
}
|
||||
|
||||
ValueWriter valueWriter = ValueWriters.WRITERS.findWriterFor(fromValue);
|
||||
if (valueWriter == this || valueWriter == ObjectValueWriter.OBJECT_VALUE_WRITER || valueWriter == TableArrayValueWriter.TABLE_ARRAY_VALUE_WRITER)
|
||||
dev.plex.toml.ValueWriter valueWriter = dev.plex.toml.ValueWriters.WRITERS.findWriterFor(fromValue);
|
||||
if (valueWriter == this || valueWriter == dev.plex.toml.ObjectValueWriter.OBJECT_VALUE_WRITER || valueWriter == dev.plex.toml.TableArrayValueWriter.TABLE_ARRAY_VALUE_WRITER)
|
||||
{
|
||||
WriterContext context1 = context.pushTable(quoteKey(key));
|
||||
context1.parentName = key.toString();
|
||||
@ -149,8 +150,8 @@ class MapValueWriter implements ValueWriter
|
||||
continue;
|
||||
}
|
||||
|
||||
ValueWriter valueWriter = ValueWriters.WRITERS.findWriterFor(fromValue);
|
||||
if (valueWriter.isPrimitiveType() || valueWriter == PrimitiveArrayValueWriter.PRIMITIVE_ARRAY_VALUE_WRITER)
|
||||
dev.plex.toml.ValueWriter valueWriter = dev.plex.toml.ValueWriters.WRITERS.findWriterFor(fromValue);
|
||||
if (valueWriter.isPrimitiveType() || valueWriter == dev.plex.toml.PrimitiveArrayValueWriter.PRIMITIVE_ARRAY_VALUE_WRITER)
|
||||
{
|
||||
return true;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -13,7 +13,7 @@ class MultilineStringValueReader implements ValueReader
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(String s, AtomicInteger index, Context context) {
|
||||
public Object read(String s, AtomicInteger index, dev.plex.toml.Context context) {
|
||||
AtomicInteger line = context.line;
|
||||
int startLine = line.get();
|
||||
int originalStartIndex = index.get();
|
||||
@ -38,15 +38,15 @@ class MultilineStringValueReader implements ValueReader
|
||||
}
|
||||
|
||||
if (endIndex == -1) {
|
||||
Results.Errors errors = new Results.Errors();
|
||||
dev.plex.toml.Results.Errors errors = new dev.plex.toml.Results.Errors();
|
||||
errors.unterminated(context.identifier.getName(), s.substring(originalStartIndex), startLine);
|
||||
return errors;
|
||||
}
|
||||
|
||||
s = s.substring(startIndex, endIndex);
|
||||
s = s.replaceAll("\\\\\\s+", "");
|
||||
s = StringValueReaderWriter.STRING_VALUE_READER_WRITER.replaceUnicodeCharacters(s);
|
||||
s = StringValueReaderWriter.STRING_VALUE_READER_WRITER.replaceSpecialCharacters(s);
|
||||
s = dev.plex.toml.StringValueReaderWriter.STRING_VALUE_READER_WRITER.replaceUnicodeCharacters(s);
|
||||
s = dev.plex.toml.StringValueReaderWriter.STRING_VALUE_READER_WRITER.replaceSpecialCharacters(s);
|
||||
|
||||
return s;
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
class NumberValueReaderWriter implements ValueReader, ValueWriter {
|
||||
class NumberValueReaderWriter implements dev.plex.toml.ValueReader, dev.plex.toml.ValueWriter
|
||||
{
|
||||
static final NumberValueReaderWriter NUMBER_VALUE_READER_WRITER = new NumberValueReaderWriter();
|
||||
|
||||
@Override
|
||||
@ -13,7 +14,7 @@ class NumberValueReaderWriter implements ValueReader, ValueWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(String s, AtomicInteger index, Context context) {
|
||||
public Object read(String s, AtomicInteger index, dev.plex.toml.Context context) {
|
||||
boolean signable = true;
|
||||
boolean dottable = false;
|
||||
boolean exponentable = false;
|
||||
@ -77,7 +78,7 @@ class NumberValueReaderWriter implements ValueReader, ValueWriter {
|
||||
|
||||
return Double.parseDouble(exponentString[0]) * Math.pow(10, Double.parseDouble(exponentString[1]));
|
||||
} else {
|
||||
Results.Errors errors = new Results.Errors();
|
||||
dev.plex.toml.Results.Errors errors = new dev.plex.toml.Results.Errors();
|
||||
errors.invalidValue(context.identifier.getName(), sb.toString(), context.line.get());
|
||||
return errors;
|
||||
}
|
||||
@ -89,7 +90,7 @@ class NumberValueReaderWriter implements ValueReader, ValueWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Object value, WriterContext context) {
|
||||
public void write(Object value, dev.plex.toml.WriterContext context) {
|
||||
context.write(value.toString());
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
|
||||
import static com.moandjiezana.toml.MapValueWriter.MAP_VALUE_WRITER;
|
||||
|
||||
class ObjectValueWriter implements ValueWriter
|
||||
{
|
||||
static final ValueWriter OBJECT_VALUE_WRITER = new ObjectValueWriter();
|
||||
@ -23,7 +21,7 @@ class ObjectValueWriter implements ValueWriter
|
||||
to.put(field.getName(), getFieldValue(field, value));
|
||||
}
|
||||
|
||||
MAP_VALUE_WRITER.write(to, context);
|
||||
MapValueWriter.MAP_VALUE_WRITER.write(to, context);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,9 +1,7 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static com.moandjiezana.toml.ValueWriters.WRITERS;
|
||||
|
||||
class PrimitiveArrayValueWriter extends ArrayValueWriter
|
||||
{
|
||||
static final ValueWriter PRIMITIVE_ARRAY_VALUE_WRITER = new PrimitiveArrayValueWriter();
|
||||
@ -25,10 +23,10 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter
|
||||
|
||||
for (Object value : values) {
|
||||
if (first) {
|
||||
firstWriter = WRITERS.findWriterFor(value);
|
||||
firstWriter = ValueWriters.WRITERS.findWriterFor(value);
|
||||
first = false;
|
||||
} else {
|
||||
ValueWriter writer = WRITERS.findWriterFor(value);
|
||||
ValueWriter writer = ValueWriters.WRITERS.findWriterFor(value);
|
||||
if (writer != firstWriter) {
|
||||
throw new IllegalStateException(
|
||||
context.getContextPath() +
|
||||
@ -39,7 +37,7 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter
|
||||
context.write(", ");
|
||||
}
|
||||
|
||||
WRITERS.findWriterFor(value).write(value, context);
|
||||
ValueWriters.WRITERS.findWriterFor(value).write(value, context);
|
||||
}
|
||||
|
||||
context.writeArrayDelimiterPadding();
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -55,7 +55,7 @@ class Results {
|
||||
.append(key);
|
||||
}
|
||||
|
||||
void invalidTextAfterIdentifier(Identifier identifier, char text, int line) {
|
||||
void invalidTextAfterIdentifier(dev.plex.toml.Identifier identifier, char text, int line) {
|
||||
sb.append("Invalid text after key ")
|
||||
.append(identifier.getName())
|
||||
.append(" on line ")
|
||||
@ -138,9 +138,9 @@ class Results {
|
||||
if (path == null) {
|
||||
startTable(key, line);
|
||||
} else if (path.isEmpty()) {
|
||||
startTables(Identifier.from(key, null), line);
|
||||
startTables(dev.plex.toml.Identifier.from(key, null), line);
|
||||
} else {
|
||||
startTables(Identifier.from(path, null), line);
|
||||
startTables(dev.plex.toml.Identifier.from(path, null), line);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> valueMap = (Map<String, Object>) value;
|
||||
@ -159,13 +159,13 @@ class Results {
|
||||
}
|
||||
}
|
||||
|
||||
void startTableArray(Identifier identifier, AtomicInteger line) {
|
||||
void startTableArray(dev.plex.toml.Identifier identifier, AtomicInteger line) {
|
||||
String tableName = identifier.getBareName();
|
||||
while (stack.size() > 1) {
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
Keys.Key[] tableParts = Keys.split(tableName);
|
||||
dev.plex.toml.Keys.Key[] tableParts = dev.plex.toml.Keys.split(tableName);
|
||||
for (int i = 0; i < tableParts.length; i++) {
|
||||
String tablePart = tableParts[i].name;
|
||||
Container currentContainer = stack.peek();
|
||||
@ -198,14 +198,14 @@ class Results {
|
||||
}
|
||||
}
|
||||
|
||||
void startTables(Identifier id, AtomicInteger line) {
|
||||
void startTables(dev.plex.toml.Identifier id, AtomicInteger line) {
|
||||
String tableName = id.getBareName();
|
||||
|
||||
while (stack.size() > 1) {
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
Keys.Key[] tableParts = Keys.split(tableName);
|
||||
dev.plex.toml.Keys.Key[] tableParts = dev.plex.toml.Keys.split(tableName);
|
||||
for (int i = 0; i < tableParts.length; i++) {
|
||||
String tablePart = tableParts[i].name;
|
||||
Container currentContainer = stack.peek();
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
@ -1,8 +1,8 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static com.moandjiezana.toml.ValueWriters.WRITERS;
|
||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||
|
||||
class TableArrayValueWriter extends ArrayValueWriter
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
@ -139,7 +139,7 @@ public class Toml
|
||||
*/
|
||||
public Toml read(String tomlString) throws IllegalStateException
|
||||
{
|
||||
Results results = TomlParser.run(tomlString);
|
||||
dev.plex.toml.Results results = dev.plex.toml.TomlParser.run(tomlString);
|
||||
if (results.errors.hasErrors())
|
||||
{
|
||||
throw new IllegalStateException(results.errors.toString());
|
||||
@ -443,9 +443,9 @@ public class Toml
|
||||
|
||||
Object current = new HashMap<>(values);
|
||||
|
||||
Keys.Key[] keys = Keys.split(key);
|
||||
dev.plex.toml.Keys.Key[] keys = dev.plex.toml.Keys.split(key);
|
||||
|
||||
for (Keys.Key k : keys)
|
||||
for (dev.plex.toml.Keys.Key k : keys)
|
||||
{
|
||||
if (k.index == -1 && current instanceof Map && ((Map<String, Object>) current).containsKey(k.path))
|
||||
{
|
@ -1,11 +1,11 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
class TomlParser {
|
||||
|
||||
static Results run(String tomlString) {
|
||||
final Results results = new Results();
|
||||
static dev.plex.toml.Results run(String tomlString) {
|
||||
final dev.plex.toml.Results results = new dev.plex.toml.Results();
|
||||
|
||||
if (tomlString.isEmpty()) {
|
||||
return results;
|
||||
@ -14,7 +14,7 @@ class TomlParser {
|
||||
AtomicInteger index = new AtomicInteger();
|
||||
boolean inComment = false;
|
||||
AtomicInteger line = new AtomicInteger(1);
|
||||
Identifier identifier = null;
|
||||
dev.plex.toml.Identifier identifier = null;
|
||||
Object value = null;
|
||||
|
||||
for (int i = index.get(); i < tomlString.length(); i = index.incrementAndGet()) {
|
||||
@ -27,9 +27,9 @@ class TomlParser {
|
||||
if (c == '#' && !inComment) {
|
||||
inComment = true;
|
||||
} else if (!Character.isWhitespace(c) && !inComment && identifier == null) {
|
||||
Identifier id = IdentifierConverter.IDENTIFIER_CONVERTER.convert(tomlString, index, new Context(null, line, results.errors));
|
||||
dev.plex.toml.Identifier id = dev.plex.toml.IdentifierConverter.IDENTIFIER_CONVERTER.convert(tomlString, index, new dev.plex.toml.Context(null, line, results.errors));
|
||||
|
||||
if (id != Identifier.INVALID) {
|
||||
if (id != dev.plex.toml.Identifier.INVALID) {
|
||||
if (id.isKey()) {
|
||||
identifier = id;
|
||||
} else if (id.isTable()) {
|
||||
@ -44,10 +44,10 @@ class TomlParser {
|
||||
value = null;
|
||||
line.incrementAndGet();
|
||||
} else if (!inComment && identifier != null && identifier.isKey() && value == null && !Character.isWhitespace(c)) {
|
||||
value = ValueReaders.VALUE_READERS.convert(tomlString, index, new Context(identifier, line, results.errors));
|
||||
value = ValueReaders.VALUE_READERS.convert(tomlString, index, new dev.plex.toml.Context(identifier, line, results.errors));
|
||||
|
||||
if (value instanceof Results.Errors) {
|
||||
results.errors.add((Results.Errors) value);
|
||||
if (value instanceof dev.plex.toml.Results.Errors) {
|
||||
results.errors.add((dev.plex.toml.Results.Errors) value);
|
||||
} else {
|
||||
results.addValue(identifier.getName(), value, line);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -7,8 +7,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static com.moandjiezana.toml.MapValueWriter.MAP_VALUE_WRITER;
|
||||
import static com.moandjiezana.toml.ValueWriters.WRITERS;
|
||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||
|
||||
/**
|
||||
* <p>Converts Objects to TOML</p>
|
||||
@ -83,7 +82,7 @@ public class TomlWriter
|
||||
}
|
||||
|
||||
private final IndentationPolicy indentationPolicy;
|
||||
private final DatePolicy datePolicy;
|
||||
private final dev.plex.toml.DatePolicy datePolicy;
|
||||
|
||||
/**
|
||||
* Creates a TomlWriter instance.
|
||||
@ -96,7 +95,7 @@ public class TomlWriter
|
||||
private TomlWriter(int keyIndentation, int tableIndentation, int arrayDelimiterPadding, TimeZone timeZone, boolean showFractionalSeconds)
|
||||
{
|
||||
this.indentationPolicy = new IndentationPolicy(keyIndentation, tableIndentation, arrayDelimiterPadding);
|
||||
this.datePolicy = new DatePolicy(timeZone, showFractionalSeconds);
|
||||
this.datePolicy = new dev.plex.toml.DatePolicy(timeZone, showFractionalSeconds);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,8 +161,8 @@ public class TomlWriter
|
||||
*/
|
||||
public void write(Object from, Writer target, @Nullable File file) throws IOException
|
||||
{
|
||||
ValueWriter valueWriter = WRITERS.findWriterFor(from);
|
||||
if (valueWriter == MAP_VALUE_WRITER || valueWriter == ObjectValueWriter.OBJECT_VALUE_WRITER)
|
||||
dev.plex.toml.ValueWriter valueWriter = WRITERS.findWriterFor(from);
|
||||
if (valueWriter == MapValueWriter.MAP_VALUE_WRITER || valueWriter == dev.plex.toml.ObjectValueWriter.OBJECT_VALUE_WRITER)
|
||||
{
|
||||
WriterContext context = new WriterContext(indentationPolicy, datePolicy, target);
|
||||
if (file != null && file.exists())
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -15,7 +15,7 @@ interface ValueReader {
|
||||
* @param s must already have been validated by {@link #canRead(String)}
|
||||
* @param index where to start in s
|
||||
* @param line current line number, used for error reporting
|
||||
* @return a value or a {@link Results.Errors}
|
||||
* @return a value or a {@link dev.plex.toml.Results.Errors}
|
||||
*/
|
||||
Object read(String s, AtomicInteger index, Context context);
|
||||
Object read(String s, AtomicInteger index, dev.plex.toml.Context context);
|
||||
}
|
35
proxy/src/main/java/dev/plex/toml/ValueReaders.java
Normal file
35
proxy/src/main/java/dev/plex/toml/ValueReaders.java
Normal file
@ -0,0 +1,35 @@
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static dev.plex.toml.ArrayValueReader.ARRAY_VALUE_READER;
|
||||
import static dev.plex.toml.BooleanValueReaderWriter.BOOLEAN_VALUE_READER_WRITER;
|
||||
import static dev.plex.toml.DateValueReaderWriter.DATE_VALUE_READER_WRITER;
|
||||
import static dev.plex.toml.LiteralStringValueReader.LITERAL_STRING_VALUE_READER;
|
||||
import static dev.plex.toml.MultilineLiteralStringValueReader.MULTILINE_LITERAL_STRING_VALUE_READER;
|
||||
import static dev.plex.toml.MultilineStringValueReader.MULTILINE_STRING_VALUE_READER;
|
||||
import static dev.plex.toml.StringValueReaderWriter.STRING_VALUE_READER_WRITER;
|
||||
|
||||
class ValueReaders {
|
||||
|
||||
static final ValueReaders VALUE_READERS = new ValueReaders();
|
||||
|
||||
Object convert(String value, AtomicInteger index, dev.plex.toml.Context context) {
|
||||
String substring = value.substring(index.get());
|
||||
for (dev.plex.toml.ValueReader valueParser : READERS) {
|
||||
if (valueParser.canRead(substring)) {
|
||||
return valueParser.read(value, index, context);
|
||||
}
|
||||
}
|
||||
|
||||
dev.plex.toml.Results.Errors errors = new dev.plex.toml.Results.Errors();
|
||||
errors.invalidValue(context.identifier.getName(), substring, context.line.get());
|
||||
return errors;
|
||||
}
|
||||
|
||||
private ValueReaders() {}
|
||||
|
||||
private static final dev.plex.toml.ValueReader[] READERS = {
|
||||
MULTILINE_STRING_VALUE_READER, MULTILINE_LITERAL_STRING_VALUE_READER, LITERAL_STRING_VALUE_READER, STRING_VALUE_READER_WRITER, DATE_VALUE_READER_WRITER, NumberValueReaderWriter.NUMBER_VALUE_READER_WRITER, BOOLEAN_VALUE_READER_WRITER, ARRAY_VALUE_READER, InlineTableValueReader.INLINE_TABLE_VALUE_READER
|
||||
};
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
interface ValueWriter {
|
||||
boolean canWrite(Object value);
|
28
proxy/src/main/java/dev/plex/toml/ValueWriters.java
Normal file
28
proxy/src/main/java/dev/plex/toml/ValueWriters.java
Normal file
@ -0,0 +1,28 @@
|
||||
package dev.plex.toml;
|
||||
|
||||
class ValueWriters {
|
||||
|
||||
static final ValueWriters WRITERS = new ValueWriters();
|
||||
|
||||
ValueWriter findWriterFor(Object value) {
|
||||
for (ValueWriter valueWriter : VALUE_WRITERS) {
|
||||
if (valueWriter.canWrite(value)) {
|
||||
return valueWriter;
|
||||
}
|
||||
}
|
||||
|
||||
return ObjectValueWriter.OBJECT_VALUE_WRITER;
|
||||
}
|
||||
|
||||
private ValueWriters() {}
|
||||
|
||||
private static dev.plex.toml.DateValueReaderWriter getPlatformSpecificDateConverter() {
|
||||
String specificationVersion = Runtime.class.getPackage().getSpecificationVersion();
|
||||
return specificationVersion != null && specificationVersion.startsWith("1.6") ? dev.plex.toml.DateValueReaderWriter.DATE_PARSER_JDK_6 : dev.plex.toml.DateValueReaderWriter.DATE_VALUE_READER_WRITER;
|
||||
}
|
||||
|
||||
private static final ValueWriter[] VALUE_WRITERS = {
|
||||
StringValueReaderWriter.STRING_VALUE_READER_WRITER, NumberValueReaderWriter.NUMBER_VALUE_READER_WRITER, dev.plex.toml.BooleanValueReaderWriter.BOOLEAN_VALUE_READER_WRITER, getPlatformSpecificDateConverter(),
|
||||
MapValueWriter.MAP_VALUE_WRITER, dev.plex.toml.PrimitiveArrayValueWriter.PRIMITIVE_ARRAY_VALUE_WRITER, TableArrayValueWriter.TABLE_ARRAY_VALUE_WRITER
|
||||
};
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.moandjiezana.toml;
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -14,14 +14,14 @@ class WriterContext
|
||||
private final String currentTableIndent;
|
||||
private final String currentFieldIndent;
|
||||
private final Writer output;
|
||||
private final IndentationPolicy indentationPolicy;
|
||||
private final DatePolicy datePolicy;
|
||||
private final dev.plex.toml.IndentationPolicy indentationPolicy;
|
||||
private final dev.plex.toml.DatePolicy datePolicy;
|
||||
|
||||
public File file;
|
||||
public String parentName;
|
||||
public boolean hasRun = false;
|
||||
|
||||
WriterContext(IndentationPolicy indentationPolicy, DatePolicy datePolicy, Writer output)
|
||||
WriterContext(dev.plex.toml.IndentationPolicy indentationPolicy, dev.plex.toml.DatePolicy datePolicy, Writer output)
|
||||
{
|
||||
this("", "", output, indentationPolicy, datePolicy);
|
||||
}
|
||||
@ -135,7 +135,7 @@ class WriterContext
|
||||
}
|
||||
}
|
||||
|
||||
DatePolicy getDatePolicy()
|
||||
dev.plex.toml.DatePolicy getDatePolicy()
|
||||
{
|
||||
return datePolicy;
|
||||
}
|
||||
@ -157,7 +157,7 @@ class WriterContext
|
||||
return key.isEmpty() ? arrayKey : key + "." + arrayKey;
|
||||
}
|
||||
|
||||
private String growIndent(IndentationPolicy indentationPolicy)
|
||||
private String growIndent(dev.plex.toml.IndentationPolicy indentationPolicy)
|
||||
{
|
||||
return currentTableIndent + fillStringWithSpaces(indentationPolicy.getTableIndent());
|
||||
}
|
||||
@ -170,7 +170,7 @@ class WriterContext
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
private WriterContext(String key, String tableIndent, Writer output, IndentationPolicy indentationPolicy, DatePolicy datePolicy)
|
||||
private WriterContext(String key, String tableIndent, Writer output, dev.plex.toml.IndentationPolicy indentationPolicy, dev.plex.toml.DatePolicy datePolicy)
|
||||
{
|
||||
this.key = key;
|
||||
this.output = output;
|
21
proxy/src/main/resources/config.toml
Normal file
21
proxy/src/main/resources/config.toml
Normal file
@ -0,0 +1,21 @@
|
||||
#############################
|
||||
# #
|
||||
# Plex Velocity #
|
||||
# v0.1 #
|
||||
# #
|
||||
#############################
|
||||
|
||||
[server]
|
||||
name = "Plexus"
|
||||
# Placeholders
|
||||
# %mcversion% - The Velocity Version (i.e. 3.1.2-SNAPSHOT)
|
||||
# %servername% - The name provided above
|
||||
# %randomgradient% - Creates a random gradient every ping of two random colors for the whole string
|
||||
# Supports MiniMessage strings, no legacy & and §
|
||||
motd = "%randomgradient%%servername% - %mcversion%"
|
||||
colorizeMotd = false
|
||||
debug = false
|
||||
# Due to game code only supporting legacy color codes for
|
||||
# player samples and not components, you may only use § or & here
|
||||
# for colors.
|
||||
sample = ["example", "example"]
|
@ -4,6 +4,19 @@ import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.storage.StorageType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Month;
|
||||
@ -12,21 +25,6 @@ import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PlexUtils implements PlexBase
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user