mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
RECOVERY
This commit is contained in:
parent
a0b4450e5b
commit
9cf399f956
33
src/main/java/com/volmit/iris/util/decree/Decree.java
Normal file
33
src/main/java/com/volmit/iris/util/decree/Decree.java
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Decree {
|
||||
String name() default "methodName";
|
||||
|
||||
String description() default "No Description Provided";
|
||||
|
||||
DecreeOrigin origin() default DecreeOrigin.BOTH;
|
||||
|
||||
String[] aliases() default "";
|
||||
}
|
22
src/main/java/com/volmit/iris/util/decree/DecreeCommand.java
Normal file
22
src/main/java/com/volmit/iris/util/decree/DecreeCommand.java
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
public class DecreeCommand {
|
||||
}
|
55
src/main/java/com/volmit/iris/util/decree/DecreeContext.java
Normal file
55
src/main/java/com/volmit/iris/util/decree/DecreeContext.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DecreeContext {
|
||||
private static ChronoLatch cl = new ChronoLatch(60000);
|
||||
private static final KMap<Thread, VolmitSender> context = new KMap<>();
|
||||
private final VolmitSender sender;
|
||||
|
||||
public static VolmitSender get() {
|
||||
return context.get(Thread.currentThread());
|
||||
}
|
||||
|
||||
public static void touch(VolmitSender c) {
|
||||
synchronized (context) {
|
||||
context.put(Thread.currentThread(), c);
|
||||
|
||||
if (cl.flip()) {
|
||||
for (Thread i : context.k()) {
|
||||
if (!i.isAlive()) {
|
||||
context.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
84
src/main/java/com/volmit/iris/util/decree/DecreeNode.java
Normal file
84
src/main/java/com/volmit/iris/util/decree/DecreeNode.java
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
public class DecreeNode {
|
||||
private final Method method;
|
||||
|
||||
public DecreeNode(Method method)
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public KList<DecreeParameter> getParameters()
|
||||
{
|
||||
KList<DecreeParameter> p = new KList<>();
|
||||
|
||||
for(Parameter i : method.getParameters())
|
||||
{
|
||||
p.add(new DecreeParameter(i));
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
||||
return p == null || p.name().equals("methodName") ? method.getName() : p.name();
|
||||
}
|
||||
|
||||
public DecreeOrigin getOrigin()
|
||||
{
|
||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
||||
return p == null ? DecreeOrigin.BOTH : p.origin();
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
||||
return p != null ? p.description() : "No Description Provided";
|
||||
}
|
||||
|
||||
public KList<String> getAliases()
|
||||
{
|
||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
||||
KList<String> d = new KList<>();
|
||||
|
||||
if(p != null)
|
||||
{
|
||||
for(String i : p.aliases())
|
||||
{
|
||||
if(i.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
d.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
}
|
25
src/main/java/com/volmit/iris/util/decree/DecreeOrigin.java
Normal file
25
src/main/java/com/volmit/iris/util/decree/DecreeOrigin.java
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
public enum DecreeOrigin {
|
||||
PLAYER,
|
||||
CONSOLE,
|
||||
BOTH
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
public class DecreeParameter {
|
||||
private final Parameter parameter;
|
||||
|
||||
public DecreeParameter(Parameter parameter)
|
||||
{
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
public DecreeParameterHandler<?> getHandler()
|
||||
{
|
||||
return DecreeSystem.handle(getType());
|
||||
}
|
||||
|
||||
public Class<?> getType()
|
||||
{
|
||||
return parameter.getType();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
Param p = parameter.getDeclaredAnnotation(Param.class);
|
||||
return p == null ? parameter.getName() : p.name().isEmpty() ? parameter.getName() : p.name();
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
Param p = parameter.getDeclaredAnnotation(Param.class);
|
||||
return p.name().isEmpty() ? parameter.getName() : p.name();
|
||||
}
|
||||
|
||||
public KList<String> getAliases()
|
||||
{
|
||||
Param p = parameter.getDeclaredAnnotation(Param.class);
|
||||
KList<String> d= new KList<>();
|
||||
|
||||
if(p != null)
|
||||
{
|
||||
for(String i : p.aliases())
|
||||
{
|
||||
if(i.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
d.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public interface DecreeParameterHandler<T> {
|
||||
KList<T> getPossibilities();
|
||||
|
||||
String toString(T t);
|
||||
|
||||
T parse(String in) throws DecreeParsingException, DecreeWhichException;
|
||||
|
||||
boolean supports(Class<?> type);
|
||||
|
||||
default KList<T> getPossibilities(String input)
|
||||
{
|
||||
KList<T> p = getPossibilities();
|
||||
KList<T> m = new KList<>();
|
||||
|
||||
if(p != null)
|
||||
{
|
||||
if(input.trim().isEmpty())
|
||||
{
|
||||
return getPossibilities();
|
||||
}
|
||||
|
||||
KList<String> f = p.convert(this::toString);
|
||||
|
||||
for(int i = 0; i < f.size(); i++)
|
||||
{
|
||||
String g = f.get(i);
|
||||
if(g.equalsIgnoreCase(input))
|
||||
{
|
||||
m.add(p.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < f.size(); i++)
|
||||
{
|
||||
String g = f.get(i);
|
||||
if(g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase()))
|
||||
{
|
||||
m.addIfMissing(p.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
public class DecreeParsingException extends Exception{
|
||||
public DecreeParsingException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
39
src/main/java/com/volmit/iris/util/decree/DecreeSystem.java
Normal file
39
src/main/java/com/volmit/iris/util/decree/DecreeSystem.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
|
||||
public class DecreeSystem {
|
||||
private static final KList<DecreeParameterHandler<?>> handlers = Iris.initialize("com.volmit.iris.util.decree.handlers", null).convert((i) -> (DecreeParameterHandler<?>) i);
|
||||
|
||||
public static DecreeParameterHandler<?> handle(Class<?> type)
|
||||
{
|
||||
for(DecreeParameterHandler<?> i : handlers)
|
||||
{
|
||||
if(i.supports(type))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
public class DecreeWhichException extends Exception{
|
||||
public DecreeWhichException() {
|
||||
super();
|
||||
}
|
||||
}
|
43
src/main/java/com/volmit/iris/util/decree/EXAMPLE.java
Normal file
43
src/main/java/com/volmit/iris/util/decree/EXAMPLE.java
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EXAMPLE
|
||||
{
|
||||
@Decree
|
||||
public void kick(
|
||||
@Param(name = "player", description = "The Player to kick from the server", aliases = "p")
|
||||
Player player,
|
||||
@Param(name = "reason", description = "A reason to kick the player for", aliases = "r")
|
||||
String reason)
|
||||
{
|
||||
player.kickPlayer(reason);
|
||||
DecreeContext.get().sendMessage("Kicked " + player.getName());
|
||||
}
|
||||
|
||||
@Decree
|
||||
public void kick(
|
||||
@Param(name = "player", description = "The Player to kick from the server", aliases = "p")
|
||||
Player player)
|
||||
{
|
||||
kick(player, "No Reason!");
|
||||
}
|
||||
}
|
32
src/main/java/com/volmit/iris/util/decree/Param.java
Normal file
32
src/main/java/com/volmit/iris/util/decree/Param.java
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
public @interface Param {
|
||||
String name();
|
||||
String description() default "No Description Provided";
|
||||
String[] aliases() default "";
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
|
||||
public class ByteHandler implements DecreeParameterHandler<Byte> {
|
||||
@Override
|
||||
public KList<Byte> getPossibilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Byte aByte) {
|
||||
return aByte.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte parse(String in) throws DecreeParsingException {
|
||||
try
|
||||
{
|
||||
return Byte.parseByte(in);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to parse byte \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(Byte.class) || type.equals(byte.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
|
||||
public class DoubleHandler implements DecreeParameterHandler<Double> {
|
||||
@Override
|
||||
public KList<Double> getPossibilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double parse(String in) throws DecreeParsingException {
|
||||
try
|
||||
{
|
||||
return Double.parseDouble(in);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to parse double \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(Double.class) || type.equals(double.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Double f) {
|
||||
return f.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
|
||||
public class FloatHandler implements DecreeParameterHandler<Float> {
|
||||
@Override
|
||||
public KList<Float> getPossibilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float parse(String in) throws DecreeParsingException {
|
||||
try
|
||||
{
|
||||
return Float.parseFloat(in);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to parse float \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(Float.class) || type.equals(float.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Float f) {
|
||||
return f.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
import net.kyori.adventure.text.minimessage.parser.ParsingException;
|
||||
|
||||
public class IntegerHandler implements DecreeParameterHandler<Integer> {
|
||||
@Override
|
||||
public KList<Integer> getPossibilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer parse(String in) throws DecreeParsingException {
|
||||
try
|
||||
{
|
||||
return Integer.parseInt(in);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to parse integer \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(Integer.class) || type.equals(int.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Integer f) {
|
||||
return f.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
|
||||
public class LongHandler implements DecreeParameterHandler<Long> {
|
||||
@Override
|
||||
public KList<Long> getPossibilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long parse(String in) throws DecreeParsingException {
|
||||
try
|
||||
{
|
||||
return Long.parseLong(in);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to parse long \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(Long.class) || type.equals(long.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Long f) {
|
||||
return f.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.DecreeWhichException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PlayerHandler implements DecreeParameterHandler<Player> {
|
||||
@Override
|
||||
public KList<Player> getPossibilities() {
|
||||
return new KList<>(new ArrayList<>(Bukkit.getOnlinePlayers()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Player player) {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||
try
|
||||
{
|
||||
KList<Player> options = getPossibilities(in);
|
||||
|
||||
if(options.isEmpty())
|
||||
{
|
||||
throw new DecreeParsingException("Unable to find Player \"" + in + "\"");
|
||||
}
|
||||
|
||||
else if(options.size() > 1)
|
||||
{
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
|
||||
return options.get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to find Player \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(Player.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
|
||||
public class ShortHandler implements DecreeParameterHandler<Short> {
|
||||
@Override
|
||||
public KList<Short> getPossibilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short parse(String in) throws DecreeParsingException {
|
||||
try
|
||||
{
|
||||
return Short.parseShort(in);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to parse short \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(Short.class) || type.equals(short.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Short f) {
|
||||
return f.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
|
||||
/**
|
||||
* Abstraction can sometimes breed stupidity
|
||||
*/
|
||||
public class StringHandler implements DecreeParameterHandler<String> {
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(String in) throws DecreeParsingException {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(String.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.DecreeWhichException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class WorldHandler implements DecreeParameterHandler<World> {
|
||||
@Override
|
||||
public KList<World> getPossibilities() {
|
||||
return new KList<>(new ArrayList<>(Bukkit.getWorlds()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(World player) {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||
try
|
||||
{
|
||||
KList<World> options = getPossibilities(in);
|
||||
|
||||
if(options.isEmpty())
|
||||
{
|
||||
throw new DecreeParsingException("Unable to find World \"" + in + "\"");
|
||||
}
|
||||
|
||||
else if(options.size() > 1)
|
||||
{
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
|
||||
return options.get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new DecreeParsingException("Unable to find World \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(World.class);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user