Merge pull request #539 from CocoTheOwner/DecreeFixes

This commit is contained in:
Dan 2021-08-14 13:07:18 -04:00 committed by GitHub
commit c921b7bb1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 40 deletions

View File

@ -38,8 +38,6 @@ import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.decree.DecreeCommand;
import com.volmit.iris.util.decree.DecreeSystem;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.NastyRunnable;

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

@ -20,6 +20,7 @@ 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;
import com.volmit.iris.util.plugin.VolmitSender;
public interface DecreeExecutor {
@ -30,9 +31,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");
}
}