Utility function extension

This commit is contained in:
CocoTheOwner 2021-08-14 15:34:34 +02:00
parent 12b1016d66
commit e328bf616f
2 changed files with 39 additions and 31 deletions

View File

@ -48,7 +48,7 @@ import java.io.File;
import java.util.function.Supplier; import java.util.function.Supplier;
@Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true)
public class DecIrisStudio implements DecreeExecutor { public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension {
@Decree(description = "Open a new studio world", aliases = "o", sync = true) @Decree(description = "Open a new studio world", aliases = "o", sync = true)
public void open( public void open(
@Param(name = "dimension", defaultValue = "overworld", description = "The dimension to open a studio for", aliases = "dim") @Param(name = "dimension", defaultValue = "overworld", description = "The dimension to open a studio for", aliases = "dim")
@ -227,34 +227,4 @@ public class DecIrisStudio implements DecreeExecutor {
Iris.proj.compilePackage(sender(), dimension, obfuscate, minify); Iris.proj.compilePackage(sender(), dimension, obfuscate, minify);
}); });
} }
/**
* @return true if server GUIs are not enabled
*/
private boolean noGUI() {
if (!IrisSettings.get().isUseServerLaunchedGuis()){
error("You must have server launched GUIs enabled in the settings!");
return true;
}
return false;
}
/**
* @return true if no studio is open & the player
*/
private boolean noStudio(){
if (!sender().isPlayer()){
error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER)");
return true;
}
if (!Iris.proj.isProjectOpen()){
error("No studio world is open!");
return true;
}
if (!engine().isStudio()){
error("You must be in a studio world!");
return true;
}
return false;
}
} }

View File

@ -0,0 +1,38 @@
package com.volmit.iris.core.decrees;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.decree.DecreeExecutor;
public interface DecreeStudioExtension extends DecreeExecutor {
/**
* @return true if server GUIs are not enabled
*/
default boolean noGUI() {
if (!IrisSettings.get().isUseServerLaunchedGuis()){
error("You must have server launched GUIs enabled in the settings!");
return true;
}
return false;
}
/**
* @return true if no studio is open & the player
*/
default boolean noStudio(){
if (!sender().isPlayer()){
error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER)");
return true;
}
if (!Iris.proj.isProjectOpen()){
error("No studio world is open!");
return true;
}
if (!engine().isStudio()){
error("You must be in a studio world!");
return true;
}
return false;
}
}