9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-31 12:56:35 +00:00

Merge remote-tracking branch 'upstream/master' into DecreeCommands

This commit is contained in:
CocoTheOwner
2021-08-14 22:08:00 +02:00
10 changed files with 29 additions and 48 deletions

View File

@@ -1,23 +0,0 @@
/*
* 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 interface DecreeCommand {
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.decree;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.ChronoLatch;

View File

@@ -21,7 +21,10 @@ package com.volmit.iris.util.decree;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
<<<<<<< HEAD
import com.volmit.iris.util.format.C;
=======
>>>>>>> master
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -62,9 +65,12 @@ public interface DecreeExecutor {
default Engine engine()
{
if(sender().isPlayer())
if(sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null)
{
return IrisToolbelt.access(sender().player().getWorld()).getEngine();
PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld());
if (gen != null){
return gen.getEngine();
}
}
return null;

View File

@@ -37,6 +37,11 @@ public interface DecreeParameterHandler<T> {
*/
String toString(T t);
/**
* Forces conversion to the designated type before converting to a string using {@link #toString(T t)}
* @param t The object to convert to string (that should be of this type)
* @return The resulting string.
*/
default String toStringForce(Object t)
{
return toString((T)t);

View File

@@ -36,6 +36,10 @@ import java.util.List;
public interface DecreeSystem extends CommandExecutor, TabCompleter {
KList<DecreeParameterHandler<?>> handlers = Iris.initialize("com.volmit.iris.util.decree.handlers", null).convert((i) -> (DecreeParameterHandler<?>) i);
/**
* The root class to start command searching from
* @return
*/
VirtualDecreeCommand getRoot();
default boolean call(VolmitSender sender, String[] args)

View File

@@ -1,12 +0,0 @@
package com.volmit.iris.util.decree;
import com.volmit.iris.util.decree.annotations.Decree;
@Decree(name = "boop", aliases = {"b", "bp"}, description = "Sub example with another name!")
// the boop command in here can be called with (/super) boop beep, b beep and bp beep
public class SubExample implements DecreeCommand {
@Decree(name = "beep", description = "Boops the sender") // Origin is not defined so both console & player senders can run this command (Default)
public void boop() { // Called with "beep" because name = "beep", "boop" will not work in the command
DecreeContext.get().sendMessage("Boop");
}
}

View File

@@ -265,7 +265,7 @@ public class Violator {
T f = c.getDeclaredAnnotation(a);
p(id(f, c), f);
System.out.println("Set as " + id(f, c) + " as " + ("@" + a.getCanonicalName() + "[" + id(c, null) + "]"));
Iris.debug("Set as " + id(f, c) + " as " + ("@" + a.getCanonicalName() + "[" + id(c, null) + "]"));
}
return (T) g("@" + a.getCanonicalName() + "[" + id(c, null) + "]");

View File

@@ -65,7 +65,7 @@ public class J {
a.run();
} catch (Throwable e) {
Iris.reportError(e);
System.out.println("Failed to run async task");
Iris.error("Failed to run async task");
e.printStackTrace();
}
});
@@ -77,7 +77,7 @@ public class J {
a.run();
} catch (Throwable e) {
Iris.reportError(e);
System.out.println("Failed to run async task");
Iris.error("Failed to run async task");
e.printStackTrace();
}
});