Update to 1.18
Rewrite command builders Usercontent api v2
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,7 +3,7 @@
|
||||
|
||||
# Except
|
||||
|
||||
!/src/
|
||||
!/src/main/
|
||||
!/gradle/
|
||||
!/run/config/worldhandler/usercontent/
|
||||
!build.gradle
|
||||
|
||||
@@ -15,11 +15,11 @@ buildscript {
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
version = '1.17.1-2.12.8'
|
||||
version = '1.18-3.0'
|
||||
group = 'exopandora.worldhandler' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'WorldHandler'
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
minecraft {
|
||||
@@ -34,7 +34,7 @@ minecraft {
|
||||
//
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: 'official', version: '1.17.1'
|
||||
mappings channel: 'official', version: '1.18'
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
@@ -106,7 +106,7 @@ dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
minecraft 'net.minecraftforge:forge:1.17.1-37.0.71'
|
||||
minecraft 'net.minecraftforge:forge:1.18-38.0.0'
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -24,7 +24,7 @@ function selected(arg) {
|
||||
}
|
||||
|
||||
function updateText(arg) {
|
||||
api.setCommandArgument(0, 4, arg);
|
||||
api.setArgument("example1", "textfield", arg);
|
||||
}
|
||||
|
||||
function openContent(arg) {
|
||||
|
||||
@@ -1,73 +1,80 @@
|
||||
{
|
||||
"model": {
|
||||
"commands": [
|
||||
{
|
||||
"commands": {
|
||||
"example1": {
|
||||
"label": "textfield",
|
||||
"syntax": {
|
||||
"name": "example",
|
||||
"syntax": [
|
||||
"children": [
|
||||
{
|
||||
"name": "list_button",
|
||||
"type": "resource_location",
|
||||
"required": true
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"name": "page_list",
|
||||
"type": "resource_location",
|
||||
"default": "minecraft:air",
|
||||
"required": false
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"name": "slider",
|
||||
"type": "int",
|
||||
"default": 0,
|
||||
"required": false
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"name": "player",
|
||||
"type": "player",
|
||||
"required": false
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"name": "textfield",
|
||||
"type": "string",
|
||||
"required": false
|
||||
"label": "textfield",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"visible": {
|
||||
"type": "bool",
|
||||
"bool": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"example2": {
|
||||
"label": "arg1",
|
||||
"syntax": {
|
||||
"name": "example2",
|
||||
"syntax": [
|
||||
"children": [
|
||||
{
|
||||
"name": "arg1",
|
||||
"type": "float",
|
||||
"default": 0,
|
||||
"required": true
|
||||
"label": "arg1",
|
||||
"type": "float"
|
||||
}
|
||||
],
|
||||
]
|
||||
},
|
||||
"visible": {
|
||||
"type": "bool",
|
||||
"bool": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"example3": {
|
||||
"label": "arg1",
|
||||
"syntax": {
|
||||
"name": "example3",
|
||||
"syntax": [
|
||||
"children": [
|
||||
{
|
||||
"name": "arg1",
|
||||
"type": "int",
|
||||
"default": "0",
|
||||
"required": false
|
||||
"label": "arg1",
|
||||
"type": "int"
|
||||
}
|
||||
],
|
||||
]
|
||||
},
|
||||
"visible": {
|
||||
"type": "bool",
|
||||
"bool": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"gui": {
|
||||
"title": "Example Title",
|
||||
@@ -84,7 +91,7 @@
|
||||
"layout": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 114,
|
||||
"width": 56,
|
||||
"height": 20
|
||||
},
|
||||
"action": {
|
||||
@@ -105,6 +112,33 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"text": "Send",
|
||||
"type": "button",
|
||||
"layout": {
|
||||
"x": 58,
|
||||
"y": 0,
|
||||
"width": 56,
|
||||
"height": 20
|
||||
},
|
||||
"action": {
|
||||
"type": "run",
|
||||
"attributes": {
|
||||
"command": "example1",
|
||||
"value": "textfield"
|
||||
}
|
||||
},
|
||||
"attributes": {
|
||||
"visible": {
|
||||
"type": "bool",
|
||||
"bool": true
|
||||
},
|
||||
"enabled": {
|
||||
"type": "bool",
|
||||
"bool": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"text": "Textfield",
|
||||
"type": "textfield",
|
||||
@@ -135,7 +169,7 @@
|
||||
{
|
||||
"type": "item_button",
|
||||
"action": {
|
||||
"type": "run",
|
||||
"type": "run_string",
|
||||
"attributes": {
|
||||
"value": "/give @p minecraft:diamond_sword 1"
|
||||
}
|
||||
@@ -193,8 +227,8 @@
|
||||
"action": {
|
||||
"type": "set",
|
||||
"attributes": {
|
||||
"command": 0,
|
||||
"index": 0
|
||||
"command": "example1",
|
||||
"argument": "list_button"
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
@@ -230,8 +264,8 @@
|
||||
"action": {
|
||||
"type": "set",
|
||||
"attributes": {
|
||||
"command": 0,
|
||||
"index": 2
|
||||
"command": "example1",
|
||||
"argument": "slider"
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
@@ -311,8 +345,8 @@
|
||||
"action": {
|
||||
"type": "set",
|
||||
"attributes": {
|
||||
"command": 0,
|
||||
"index": 1
|
||||
"command": "example1",
|
||||
"argument": "page_list"
|
||||
}
|
||||
},
|
||||
"attributes": {
|
||||
|
||||
@@ -11,8 +11,8 @@ public class Main
|
||||
{
|
||||
public static final String NAME = "World Handler";
|
||||
public static final String MODID = "worldhandler";
|
||||
public static final String MC_VERSION = "1.17.1";
|
||||
public static final String MOD_VERSION = "2.12.8";
|
||||
public static final String MC_VERSION = "1.18";
|
||||
public static final String MOD_VERSION = "3.0";
|
||||
public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui";
|
||||
|
||||
public static void main(String[] args)
|
||||
|
||||
@@ -14,6 +14,7 @@ import exopandora.worldhandler.usercontent.UsercontentLoader;
|
||||
import exopandora.worldhandler.util.AdvancementHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.ClientRegistry;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
@@ -28,8 +29,6 @@ import net.minecraftforge.fml.config.ModConfig.Type;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import net.minecraftforge.fmlclient.registry.ClientRegistry;
|
||||
import net.minecraftforge.fmllegacy.network.FMLNetworkConstants;
|
||||
|
||||
@Mod(Main.MODID)
|
||||
public class WorldHandler
|
||||
@@ -37,6 +36,7 @@ public class WorldHandler
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final Path USERCONTENT_PATH = FMLPaths.CONFIGDIR.get().resolve(Main.MODID).resolve("usercontent");
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public WorldHandler()
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
@@ -59,14 +59,14 @@ public class WorldHandler
|
||||
modEventBus.addGenericListener(Category.class, Category::register);
|
||||
}
|
||||
});
|
||||
modLoadingContext.registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (remote, isServer) -> true));
|
||||
modLoadingContext.registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> "ANY", (remote, isServer) -> true));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.addListener(KeyHandler::keyInputEvent);
|
||||
MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::renderWorldLastEvent);
|
||||
MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::renderLevelLastEvent);
|
||||
MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::clientChatEvent);
|
||||
|
||||
ClientRegistry.registerKeyBinding(KeyHandler.KEY_WORLD_HANDLER);
|
||||
|
||||
@@ -1,323 +1,77 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.CommandSyntax.Argument;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.CoordinateDouble;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.builder.types.GreedyString;
|
||||
import exopandora.worldhandler.builder.types.ItemResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public abstract class CommandBuilder implements ICommandBuilderSyntax
|
||||
public abstract class CommandBuilder implements ICommandBuilder
|
||||
{
|
||||
private List<Entry<Argument, String>> command;
|
||||
protected abstract CommandNodeLiteral root();
|
||||
|
||||
public CommandBuilder()
|
||||
public String toCommand(Object label, boolean preview)
|
||||
{
|
||||
this.updateSyntax(this.getSyntax());
|
||||
CommandNode<?> node = this.root().find(label).orElse(this.root());
|
||||
|
||||
if(preview)
|
||||
{
|
||||
return this.buildForward(node, label, CommandNode::toValue).toString();
|
||||
}
|
||||
|
||||
protected void setNode(int index, String node)
|
||||
{
|
||||
this.set(index, node != null && !node.isEmpty() ? node : null, ArgumentType.STRING);
|
||||
return this.buildReverse(node, label, CommandNode::toValue, false).toString();
|
||||
}
|
||||
|
||||
protected void setNode(int index, GreedyString node)
|
||||
protected StringBuilder buildForward(CommandNode<?> node, Object label, BiFunction<CommandNode<?>, Object, String> valueMapper)
|
||||
{
|
||||
this.set(index, node != null && !node.isEmpty() ? node : null, ArgumentType.GREEDY_STRING);
|
||||
StringBuilder builder = this.buildReverse(node, label, valueMapper, true);
|
||||
|
||||
if(builder.isEmpty())
|
||||
{
|
||||
return builder;
|
||||
}
|
||||
|
||||
protected void setNode(int index, boolean node)
|
||||
if(node != null)
|
||||
{
|
||||
this.set(index, node, ArgumentType.BOOLEAN);
|
||||
List<CommandNode<?>> children = node.getChildren();
|
||||
|
||||
while(children != null && children.size() == 1)
|
||||
{
|
||||
node = children.get(0);
|
||||
builder.append(" ");
|
||||
builder.append(valueMapper.apply(children.get(0), label));
|
||||
children = node.getChildren();
|
||||
}
|
||||
|
||||
protected void setNode(int index, short node)
|
||||
if(children != null && children.size() > 0)
|
||||
{
|
||||
this.set(index, node, ArgumentType.SHORT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, byte node)
|
||||
{
|
||||
this.set(index, node, ArgumentType.BYTE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, int node)
|
||||
{
|
||||
this.set(index, node, ArgumentType.INT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, float node)
|
||||
{
|
||||
this.set(index, node, ArgumentType.FLOAT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, double node)
|
||||
{
|
||||
this.set(index, node, ArgumentType.DOUBLE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, long node)
|
||||
{
|
||||
this.set(index, node, ArgumentType.LONG);
|
||||
}
|
||||
|
||||
protected void setNode(int index, ResourceLocation node)
|
||||
{
|
||||
this.set(index, node, ArgumentType.RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
protected void setNode(int index, CoordinateInt coordinate)
|
||||
{
|
||||
this.set(index, coordinate, ArgumentType.COORDINATE_INT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, CoordinateDouble coordinate)
|
||||
{
|
||||
this.set(index, coordinate, ArgumentType.COORDINATE_DOUBLE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, TargetSelector target)
|
||||
{
|
||||
this.set(index, target, ArgumentType.TARGET_SELECTOR);
|
||||
}
|
||||
|
||||
protected void setNode(int index, ItemResourceLocation resource)
|
||||
{
|
||||
this.set(index, resource, ArgumentType.ITEM_RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
protected void setNode(int index, BlockResourceLocation resource)
|
||||
{
|
||||
this.set(index, resource, ArgumentType.BLOCK_RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
protected void setNode(int index, CompoundTag nbt)
|
||||
{
|
||||
this.set(index, nbt, ArgumentType.NBT);
|
||||
}
|
||||
|
||||
protected void setPlayerName(int index, String username)
|
||||
{
|
||||
this.set(index, username != null && !username.isEmpty() ? username : null, ArgumentType.PLAYER);
|
||||
}
|
||||
|
||||
private void set(int index, Object value, ArgumentType type)
|
||||
{
|
||||
if(index < this.command.size())
|
||||
{
|
||||
Argument entry = this.command.get(index).getKey();
|
||||
ArgumentType expectedType = entry.getType();
|
||||
boolean typeMatch = expectedType.equals(type);
|
||||
|
||||
if(value != null && typeMatch)
|
||||
{
|
||||
this.command.get(index).setValue(value.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.command.get(index).setValue(entry.toString());
|
||||
|
||||
if(!typeMatch)
|
||||
{
|
||||
this.warn("set", expectedType, type, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHandler.LOGGER.warn("Tried to set invalid index \"" + index + "\" for command \"" + this.getCommandName() + "\"");
|
||||
builder.append(children.stream().map(child -> valueMapper.apply(child, label)).collect(Collectors.joining("|", " [", "]")));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getNodeAsString(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.STRING);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getNodeAsGreedyString(int index)
|
||||
protected StringBuilder buildReverse(@Nullable CommandNode<?> node, Object label, BiFunction<CommandNode<?>, Object, String> valueMapper, boolean includeOptionals)
|
||||
{
|
||||
return this.get(index, ArgumentType.GREEDY_STRING);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
while(node != null)
|
||||
{
|
||||
CommandNode<?> parent = node.getParent();
|
||||
|
||||
if(parent == null)
|
||||
{
|
||||
builder.insert(0, "/" + valueMapper.apply(node, label));
|
||||
}
|
||||
else if(includeOptionals || !builder.isEmpty() || !node.isOptional(label) || !node.isDefault(label))
|
||||
{
|
||||
builder.insert(0, " " + valueMapper.apply(node, label));
|
||||
}
|
||||
|
||||
protected boolean getNodeAsBoolean(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.BOOLEAN);
|
||||
node = parent;
|
||||
}
|
||||
|
||||
protected short getNodeAsShort(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.SHORT);
|
||||
}
|
||||
|
||||
protected byte getNodeAsByte(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.BYTE);
|
||||
}
|
||||
|
||||
protected int getNodeAsInt(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.INT);
|
||||
}
|
||||
|
||||
protected float getNodeAsFloat(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.FLOAT);
|
||||
}
|
||||
|
||||
protected double getNodeAsDouble(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.DOUBLE);
|
||||
}
|
||||
|
||||
protected long getNodeAsLong(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.LONG);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected CoordinateInt getNodeAsCoordinateInt(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.COORDINATE_INT);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected CoordinateDouble getNodeAsCoordinateDouble(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.COORDINATE_DOUBLE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ResourceLocation getNodeAsResourceLocation(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected TargetSelector getNodeAsTargetSelector(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.TARGET_SELECTOR);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ItemResourceLocation getNodeAsItemResourceLocation(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.ITEM_RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected BlockResourceLocation getNodeAsBlockResourceLocation(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.BLOCK_RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected CompoundTag getNodeAsNBT(int index)
|
||||
{
|
||||
return this.get(index, ArgumentType.NBT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> T get(int index, ArgumentType type)
|
||||
{
|
||||
if(index < this.command.size())
|
||||
{
|
||||
Entry<Argument, String> entry = this.command.get(index);
|
||||
ArgumentType expected = entry.getKey().getType();
|
||||
String value = entry.getValue();
|
||||
|
||||
if(expected.equals(type))
|
||||
{
|
||||
if(value.equals(entry.getKey().toString()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return expected.<T>parse(value);
|
||||
}
|
||||
|
||||
this.warn("get", expected, type, index);
|
||||
|
||||
return type.<T>parse(value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void warn(String function, ArgumentType expected, ArgumentType type, int index)
|
||||
{
|
||||
WorldHandler.LOGGER.warn("[" + function.toUpperCase() + "] Expected \"" + expected + "\" instead of \"" + type + "\" at index \"" + index + "\" for command \"" + this.getCommandName() + "\"");
|
||||
}
|
||||
|
||||
private boolean isDefaultArgument(Argument argument, String value)
|
||||
{
|
||||
return argument.getDefault() != null ? value.equals(argument.getDefault().toString()) : value == null;
|
||||
}
|
||||
|
||||
protected void updateSyntax(CommandSyntax syntax)
|
||||
{
|
||||
if(syntax != null)
|
||||
{
|
||||
this.command = syntax.getArguments().stream().map(entry -> new SimpleEntry<Argument, String>(entry, entry.toString())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
CommandString command = new CommandString(this.getCommandName());
|
||||
|
||||
for(Entry<Argument, String> entry : this.command)
|
||||
{
|
||||
if(this.isDefaultArgument(entry.getKey(), entry.getValue()))
|
||||
{
|
||||
command.append(entry.getKey().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
command.append(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return command.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toActualCommand()
|
||||
{
|
||||
CommandString command = new CommandString(this.getCommandName());
|
||||
|
||||
for(Entry<Argument, String> entry : this.command)
|
||||
{
|
||||
if(!entry.getKey().isRequired() && (entry.getKey().toString().equals(entry.getValue()) || this.isDefaultArgument(entry.getKey(), entry.getValue())))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(entry.getKey().isRequired() && entry.getKey().toString().equals(entry.getValue()) && entry.getKey().getDefault() != null)
|
||||
{
|
||||
command.append(entry.getKey().getDefault().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
command.append(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return command.toString();
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.util.NBTHelper;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public abstract class CommandBuilderNBT extends CommandBuilder implements ICommandBuilderNBT
|
||||
{
|
||||
private final List<IBuilderComponent> TAG_TO_COMPONENT = new ArrayList<IBuilderComponent>();
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return this.toCommand(true);
|
||||
}
|
||||
|
||||
public String toCommand(boolean rebuildNBT)
|
||||
{
|
||||
if(rebuildNBT)
|
||||
{
|
||||
this.setNBT(this.buildNBT());
|
||||
}
|
||||
|
||||
return super.toCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toActualCommand()
|
||||
{
|
||||
return this.toActualCommand(true);
|
||||
}
|
||||
|
||||
public String toActualCommand(boolean rebuildNBT)
|
||||
{
|
||||
if(rebuildNBT)
|
||||
{
|
||||
this.setNBT(this.buildNBT());
|
||||
}
|
||||
|
||||
return super.toActualCommand();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected CompoundTag buildNBT()
|
||||
{
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
|
||||
for(IBuilderComponent component : this.TAG_TO_COMPONENT)
|
||||
{
|
||||
NBTHelper.append(nbt, component);
|
||||
}
|
||||
|
||||
if(nbt.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public <T extends IBuilderComponent> T registerNBTComponent(T component)
|
||||
{
|
||||
this.TAG_TO_COMPONENT.add(component);
|
||||
return component;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
||||
public class CommandString
|
||||
{
|
||||
private final StringBuilder command = new StringBuilder("/");
|
||||
|
||||
public CommandString(String name)
|
||||
{
|
||||
this.command.append(name);
|
||||
}
|
||||
|
||||
public CommandString(String name, String... arguments)
|
||||
{
|
||||
this(name);
|
||||
this.append(arguments);
|
||||
}
|
||||
|
||||
public void append(String argument)
|
||||
{
|
||||
if(argument != null && !argument.isEmpty())
|
||||
{
|
||||
this.command.append(" " + argument);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.command.append(" " + ChatFormatting.RED + "[error]" + ChatFormatting.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
public void append(String... arguments)
|
||||
{
|
||||
if(arguments != null)
|
||||
{
|
||||
for(String argument : arguments)
|
||||
{
|
||||
this.append(argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.command.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class CommandSyntax
|
||||
{
|
||||
private List<Argument> syntax = new ArrayList<Argument>();
|
||||
|
||||
public CommandSyntax()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public CommandSyntax(List<Argument> syntax)
|
||||
{
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
public CommandSyntax addRequired(String key, ArgumentType type)
|
||||
{
|
||||
this.syntax.add(new Argument(key, type, true, null));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandSyntax addRequired(String key, ArgumentType type, Object def)
|
||||
{
|
||||
this.syntax.add(new Argument(key, type, true, def));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandSyntax addOptional(String key, ArgumentType type)
|
||||
{
|
||||
this.syntax.add(new Argument(key, type, false, null));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandSyntax addOptional(String key, ArgumentType type, Object def)
|
||||
{
|
||||
this.syntax.add(new Argument(key, type, false, def));
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Argument> getArguments()
|
||||
{
|
||||
return this.syntax;
|
||||
}
|
||||
|
||||
public static class Argument
|
||||
{
|
||||
@SerializedName("name")
|
||||
private final String key;
|
||||
|
||||
@SerializedName("type")
|
||||
private final ArgumentType type;
|
||||
|
||||
@SerializedName("required")
|
||||
private final boolean required;
|
||||
|
||||
@SerializedName("default")
|
||||
private final Object def;
|
||||
|
||||
public Argument(String key, ArgumentType type, boolean required, Object def)
|
||||
{
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.required = required;
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public ArgumentType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return this.required;
|
||||
}
|
||||
|
||||
public Object getDefault()
|
||||
{
|
||||
return this.def;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.required)
|
||||
{
|
||||
return "<" + this.key + ">";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "[" + this.key + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ public interface ICommandBuilder
|
||||
{
|
||||
static final int MAX_COMMAND_LENGTH = 256;
|
||||
|
||||
String toCommand();
|
||||
String toCommand(Object label, boolean preview);
|
||||
|
||||
default boolean needsCommandBlock()
|
||||
default boolean needsCommandBlock(Object label, boolean preview)
|
||||
{
|
||||
return this.toCommand().length() > MAX_COMMAND_LENGTH;
|
||||
return this.toCommand(label, preview).length() > MAX_COMMAND_LENGTH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public interface ICommandBuilderNBT extends ICommandBuilder
|
||||
{
|
||||
void setNBT(CompoundTag nbt);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
public interface ICommandBuilderSyntax extends ICommandBuilder
|
||||
{
|
||||
String getCommandName();
|
||||
String toActualCommand();
|
||||
CommandSyntax getSyntax();
|
||||
|
||||
@Override
|
||||
default boolean needsCommandBlock()
|
||||
{
|
||||
return this.toActualCommand().length() > MAX_COMMAND_LENGTH;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
public interface INBTWritable
|
||||
{
|
||||
@Nullable
|
||||
Tag serialize();
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package exopandora.worldhandler.builder.argument.tag;
|
||||
|
||||
public class EffectInstance
|
||||
{
|
||||
private byte amplifier;
|
||||
private int seconds;
|
||||
private int minutes;
|
||||
private int hours;
|
||||
private boolean showParticles;
|
||||
private boolean ambient;
|
||||
|
||||
public EffectInstance()
|
||||
{
|
||||
this((byte) 0, 0, 0, 0, true, false);
|
||||
}
|
||||
|
||||
public EffectInstance(byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
this.seconds = seconds;
|
||||
this.minutes = minutes;
|
||||
this.hours = hours;
|
||||
this.showParticles = showParticles;
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public byte getAmplifier()
|
||||
{
|
||||
return this.amplifier;
|
||||
}
|
||||
|
||||
public void setAmplifier(byte amplifier)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return this.seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return this.minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public boolean doShowParticles()
|
||||
{
|
||||
return this.showParticles;
|
||||
}
|
||||
|
||||
public void setShowParticles(boolean showParticles)
|
||||
{
|
||||
this.showParticles = showParticles;
|
||||
}
|
||||
|
||||
public boolean isAmbient()
|
||||
{
|
||||
return this.ambient;
|
||||
}
|
||||
|
||||
public void setAmbient(boolean ambient)
|
||||
{
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public int toTicks()
|
||||
{
|
||||
return EffectInstance.toTicks(this.seconds, this.minutes, this.hours);
|
||||
}
|
||||
|
||||
public int toSeconds()
|
||||
{
|
||||
return EffectInstance.toSeconds(this.seconds, this.minutes, this.hours);
|
||||
}
|
||||
|
||||
public static int toTicks(int seconds, int minutes, int hours)
|
||||
{
|
||||
return seconds * 20 + minutes * 1200 + hours * 72000;
|
||||
}
|
||||
|
||||
public static int toSeconds(int seconds, int minutes, int hours)
|
||||
{
|
||||
return seconds + minutes * 60 + hours * 3600;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component;
|
||||
|
||||
import exopandora.worldhandler.builder.INBTWritable;
|
||||
|
||||
public interface IBuilderComponent extends INBTWritable
|
||||
{
|
||||
String getTag();
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public abstract class ComponentAttribute implements IBuilderComponent
|
||||
{
|
||||
public static final List<Attribute> ATTRIBUTES = ForgeRegistries.ATTRIBUTES.getValues().stream().filter(attribute -> !attribute.getDescriptionId().equals(I18n.get(attribute.getDescriptionId()))).collect(Collectors.toList());
|
||||
|
||||
protected Map<Attribute, Double> attributes = new HashMap<Attribute, Double>();
|
||||
|
||||
public void set(Attribute attribute, double ammount)
|
||||
{
|
||||
this.attributes.put(attribute, ammount);
|
||||
}
|
||||
|
||||
public double getAmmount(Attribute attribute)
|
||||
{
|
||||
if(this.attributes.containsKey(attribute))
|
||||
{
|
||||
return this.attributes.get(attribute);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void remove(Attribute attribute)
|
||||
{
|
||||
this.attributes.remove(attribute);
|
||||
}
|
||||
|
||||
public Set<Attribute> getAttributes()
|
||||
{
|
||||
return this.attributes.keySet();
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
|
||||
public class ComponentAttributeItem extends ComponentAttribute
|
||||
{
|
||||
@Override
|
||||
@Nullable
|
||||
public Tag serialize()
|
||||
{
|
||||
ListTag attributes = new ListTag();
|
||||
|
||||
for(Entry<Attribute, Double> entry : this.attributes.entrySet())
|
||||
{
|
||||
if(entry.getValue() != 0)
|
||||
{
|
||||
CompoundTag attribute = new CompoundTag();
|
||||
String id = entry.getKey().getRegistryName().toString();
|
||||
|
||||
attribute.putString("AttributeName", id);
|
||||
attribute.putDouble("Amount", entry.getValue() / 100);
|
||||
attribute.putInt("Operation", 1); // 0 = additive, 1 = percentage
|
||||
attribute.putUUID("UUID", UUID.nameUUIDFromBytes(id.getBytes()));
|
||||
|
||||
attributes.add(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if(attributes.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "AttributeModifiers";
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
|
||||
public class ComponentAttributeMob extends ComponentAttribute
|
||||
{
|
||||
@Override
|
||||
@Nullable
|
||||
public Tag serialize()
|
||||
{
|
||||
ListTag attributes = new ListTag();
|
||||
|
||||
for(Entry<Attribute, Double> entry : this.attributes.entrySet())
|
||||
{
|
||||
if(entry.getValue() != 0)
|
||||
{
|
||||
CompoundTag attribute = new CompoundTag();
|
||||
String id = entry.getKey().getRegistryName().toString();
|
||||
|
||||
attribute.putString("Name", id);
|
||||
attribute.putDouble("Base", entry.getValue() / 100);
|
||||
|
||||
attributes.add(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if(attributes.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "Attributes";
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
public class ComponentCustom implements IBuilderComponent
|
||||
{
|
||||
private Tag nbt;
|
||||
private String tag;
|
||||
|
||||
public void setNBT(Tag nbt)
|
||||
{
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public void setTag(String tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public void set(String tag, Tag nbt)
|
||||
{
|
||||
this.setTag(tag);
|
||||
this.setNBT(nbt);
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
this.set(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag serialize()
|
||||
{
|
||||
return this.nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return this.tag;
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ComponentDisplay implements IBuilderComponent
|
||||
{
|
||||
private MutableTextComponent name = new MutableTextComponent();
|
||||
private Component[] lore = new Component[2];
|
||||
|
||||
@Override
|
||||
public Tag serialize()
|
||||
{
|
||||
CompoundTag display = new CompoundTag();
|
||||
|
||||
if(this.name.getText() != null && !this.name.getText().isEmpty())
|
||||
{
|
||||
display.putString("Name", Component.Serializer.toJson(this.name));
|
||||
}
|
||||
|
||||
ListTag lore = new ListTag();
|
||||
|
||||
for(int x = 0; x < this.lore.length; x++)
|
||||
{
|
||||
if(this.lore[x] != null && !this.lore[x].getString().isEmpty())
|
||||
{
|
||||
lore.add(StringTag.valueOf(Component.Serializer.toJson(this.lore[x])));
|
||||
}
|
||||
}
|
||||
|
||||
if(!lore.isEmpty())
|
||||
{
|
||||
display.put("Lore", lore);
|
||||
}
|
||||
|
||||
if(!display.isEmpty())
|
||||
{
|
||||
return display;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setName(MutableTextComponent name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public MutableTextComponent getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setLore(Component[] lore)
|
||||
{
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
public Component[] getLore()
|
||||
{
|
||||
return this.lore;
|
||||
}
|
||||
|
||||
public void setLore1(Component lore)
|
||||
{
|
||||
this.lore[0] = lore;
|
||||
}
|
||||
|
||||
public Component getLore1()
|
||||
{
|
||||
return this.lore[0];
|
||||
}
|
||||
|
||||
public void setLore2(Component lore)
|
||||
{
|
||||
this.lore[1] = lore;
|
||||
}
|
||||
|
||||
public Component getLore2()
|
||||
{
|
||||
return this.lore[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "display";
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ComponentEnchantment implements IBuilderComponent
|
||||
{
|
||||
private Map<Enchantment, Short> enchantments = new HashMap<Enchantment, Short>();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Tag serialize()
|
||||
{
|
||||
ListTag enchantments = new ListTag();
|
||||
|
||||
for(Entry<Enchantment, Short> entry : this.enchantments.entrySet())
|
||||
{
|
||||
if(entry.getValue() > 0)
|
||||
{
|
||||
CompoundTag enchantment = new CompoundTag();
|
||||
|
||||
enchantment.putString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString());
|
||||
enchantment.putShort("lvl", entry.getValue());
|
||||
|
||||
enchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
if(enchantments.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
public void setLevel(Enchantment enchantment, short level)
|
||||
{
|
||||
if(level == 0)
|
||||
{
|
||||
this.enchantments.remove(enchantment);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enchantments.put(enchantment, level);
|
||||
}
|
||||
}
|
||||
|
||||
public short getLevel(Enchantment enchantment)
|
||||
{
|
||||
return this.enchantments.get(enchantment);
|
||||
}
|
||||
|
||||
public Set<Enchantment> getEnchantments()
|
||||
{
|
||||
return this.enchantments.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "Enchantments";
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
|
||||
public abstract class ComponentPotion implements IBuilderComponent
|
||||
{
|
||||
protected final Map<MobEffect, EffectNBT> potions = new HashMap<MobEffect, EffectNBT>();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Tag serialize()
|
||||
{
|
||||
ListTag list = new ListTag();
|
||||
|
||||
for(Entry<MobEffect, EffectNBT> entry : this.potions.entrySet())
|
||||
{
|
||||
EffectNBT effect = entry.getValue();
|
||||
|
||||
if(effect.getAmplifier() > 0)
|
||||
{
|
||||
CompoundTag compound = effect.serialize();
|
||||
compound.putByte("Id", (byte) MobEffect.getId(entry.getKey()));
|
||||
list.add(compound);
|
||||
}
|
||||
}
|
||||
|
||||
if(list.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setAmplifier(MobEffect potion, byte amplifier)
|
||||
{
|
||||
this.get(potion).setAmplifier(amplifier);
|
||||
}
|
||||
|
||||
public byte getAmplifier(MobEffect potion)
|
||||
{
|
||||
return this.get(potion).getAmplifier();
|
||||
}
|
||||
|
||||
public void setSeconds(MobEffect potion, int seconds)
|
||||
{
|
||||
this.get(potion).setSeconds(seconds);
|
||||
}
|
||||
|
||||
public int getSeconds(MobEffect potion)
|
||||
{
|
||||
return this.get(potion).getSeconds();
|
||||
}
|
||||
|
||||
public void setMinutes(MobEffect potion, int minutes)
|
||||
{
|
||||
this.get(potion).setMinutes(minutes);
|
||||
}
|
||||
|
||||
public int getMinutes(MobEffect potion)
|
||||
{
|
||||
return this.get(potion).getMinutes();
|
||||
}
|
||||
|
||||
public void setHours(MobEffect potion, int hours)
|
||||
{
|
||||
this.get(potion).setHours(hours);
|
||||
}
|
||||
|
||||
public int getHours(MobEffect potion)
|
||||
{
|
||||
return this.get(potion).getHours();
|
||||
}
|
||||
|
||||
public void setShowParticles(MobEffect potion, boolean showParticles)
|
||||
{
|
||||
this.get(potion).setShowParticles(showParticles);
|
||||
}
|
||||
|
||||
public boolean getShowParticles(MobEffect potion)
|
||||
{
|
||||
return this.get(potion).getShowParticles();
|
||||
}
|
||||
|
||||
public void setAmbient(MobEffect potion, boolean ambient)
|
||||
{
|
||||
this.get(potion).setAmbient(ambient);
|
||||
}
|
||||
|
||||
public boolean getAmbient(MobEffect potion)
|
||||
{
|
||||
return this.get(potion).getAmbient();
|
||||
}
|
||||
|
||||
private EffectNBT get(MobEffect potion)
|
||||
{
|
||||
return this.potions.computeIfAbsent(potion, key -> new EffectNBT());
|
||||
}
|
||||
|
||||
public Set<MobEffect> getMobEffects()
|
||||
{
|
||||
return this.potions.keySet();
|
||||
}
|
||||
|
||||
public void remove(MobEffect potion)
|
||||
{
|
||||
this.potions.remove(potion);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
public class ComponentPotionItem extends ComponentPotion
|
||||
{
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "CustomPotionEffects";
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
public class ComponentPotionMob extends ComponentPotion
|
||||
{
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "ActiveEffects";
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.ByteArrayTag;
|
||||
import net.minecraft.nbt.ByteTag;
|
||||
import net.minecraft.nbt.DoubleTag;
|
||||
import net.minecraft.nbt.FloatTag;
|
||||
import net.minecraft.nbt.IntArrayTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.nbt.LongArrayTag;
|
||||
import net.minecraft.nbt.LongTag;
|
||||
import net.minecraft.nbt.ShortTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
public class ComponentTag<T> implements IBuilderComponent
|
||||
{
|
||||
private final Function<T, Tag> serializer;
|
||||
private final String tag;
|
||||
private T value;
|
||||
|
||||
public ComponentTag(String tag, T value, Function<T, Tag> serializer)
|
||||
{
|
||||
this.tag = tag;
|
||||
this.value = value;
|
||||
this.serializer = serializer;
|
||||
}
|
||||
|
||||
public ComponentTag(String tag, Function<T, Tag> serializer)
|
||||
{
|
||||
this(tag, null, serializer);
|
||||
}
|
||||
|
||||
public ComponentTag(String tag, T value)
|
||||
{
|
||||
this(tag, value, null);
|
||||
}
|
||||
|
||||
public ComponentTag(String tag)
|
||||
{
|
||||
this(tag, null, null);
|
||||
}
|
||||
|
||||
public void setValue(T value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Tag serialize()
|
||||
{
|
||||
if(this.value != null)
|
||||
{
|
||||
if(this.serializer != null)
|
||||
{
|
||||
return this.serializer.apply(this.value);
|
||||
}
|
||||
else if(this.value instanceof String)
|
||||
{
|
||||
String string = (String) this.value;
|
||||
|
||||
if(string.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return StringTag.valueOf(string);
|
||||
}
|
||||
else if(this.value instanceof Tag)
|
||||
{
|
||||
if(this.value instanceof Collection<?>)
|
||||
{
|
||||
Collection<?> collection = (Collection<?>) this.value;
|
||||
|
||||
if(collection.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return (Tag) this.value;
|
||||
}
|
||||
else if(this.value instanceof Integer)
|
||||
{
|
||||
return IntTag.valueOf((Integer) this.value);
|
||||
}
|
||||
else if(this.value instanceof Byte)
|
||||
{
|
||||
return ByteTag.valueOf((Byte) this.value);
|
||||
}
|
||||
else if(this.value instanceof Float)
|
||||
{
|
||||
return FloatTag.valueOf((Float) this.value);
|
||||
}
|
||||
else if(this.value instanceof Double)
|
||||
{
|
||||
return DoubleTag.valueOf((Double) this.value);
|
||||
}
|
||||
else if(this.value instanceof Long)
|
||||
{
|
||||
return LongTag.valueOf((Long) this.value);
|
||||
}
|
||||
else if(this.value instanceof Short)
|
||||
{
|
||||
return ShortTag.valueOf((Short) this.value);
|
||||
}
|
||||
else if(this.value instanceof Byte[])
|
||||
{
|
||||
return new ByteArrayTag((byte[]) this.value);
|
||||
}
|
||||
else if(this.value instanceof Integer[])
|
||||
{
|
||||
return new IntArrayTag((int[]) this.value);
|
||||
}
|
||||
else if(this.value instanceof Long[])
|
||||
{
|
||||
return new LongArrayTag((long[]) this.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHandler.LOGGER.warn("Tag \"" + this.tag + "\" has no serializer");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return this.tag;
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.INBTWritable;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class EffectNBT implements INBTWritable
|
||||
{
|
||||
private byte amplifier;
|
||||
private int seconds;
|
||||
private int minutes;
|
||||
private int hours;
|
||||
private boolean showParticles;
|
||||
private boolean ambient;
|
||||
|
||||
public EffectNBT()
|
||||
{
|
||||
this((byte) 0, 0, 0, 0, true, false);
|
||||
}
|
||||
|
||||
public EffectNBT(byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
this.seconds = seconds;
|
||||
this.minutes = minutes;
|
||||
this.hours = hours;
|
||||
this.showParticles = showParticles;
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public byte getAmplifier()
|
||||
{
|
||||
return this.amplifier;
|
||||
}
|
||||
|
||||
public void setAmplifier(byte amplifier)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return this.seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return this.minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public boolean getShowParticles()
|
||||
{
|
||||
return this.showParticles;
|
||||
}
|
||||
|
||||
public void setShowParticles(boolean showParticles)
|
||||
{
|
||||
this.showParticles = showParticles;
|
||||
}
|
||||
|
||||
public boolean getAmbient()
|
||||
{
|
||||
return this.ambient;
|
||||
}
|
||||
|
||||
public void setAmbient(boolean ambient)
|
||||
{
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public int toTicks()
|
||||
{
|
||||
return EffectNBT.toTicks(this.seconds, this.minutes, this.hours);
|
||||
}
|
||||
|
||||
public int toSeconds()
|
||||
{
|
||||
return EffectNBT.toSeconds(this.seconds, this.minutes, this.hours);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag compound = new CompoundTag();
|
||||
int ticks = this.toTicks();
|
||||
|
||||
compound.putByte("Amplifier", (byte) (this.amplifier - 1));
|
||||
compound.putInt("Duration", ticks > 0 ? ticks : 1000000);
|
||||
compound.putBoolean("Ambient", this.ambient);
|
||||
compound.putBoolean("ShowParticles", this.showParticles);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static int toTicks(int seconds, int minutes, int hours)
|
||||
{
|
||||
return seconds * 20 + minutes * 1200 + hours * 72000;
|
||||
}
|
||||
|
||||
public static int toSeconds(int seconds, int minutes, int hours)
|
||||
{
|
||||
return seconds + minutes * 60 + hours * 3600;
|
||||
}
|
||||
|
||||
public EffectNBT withAmplifier(byte amplifier)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EffectNBT withShowParticles(boolean showParticles)
|
||||
{
|
||||
this.showParticles = showParticles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EffectNBT withSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EffectNBT withMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EffectNBT withHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EffectNBT withAmbient(boolean ambient)
|
||||
{
|
||||
this.ambient = ambient;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "EffectNBT [amplifier=" + amplifier + ", seconds=" + seconds + ", minutes=" + minutes + ", hours=" + hours + ", showParticles=" + showParticles + ", ambient=" + ambient + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,468 +0,0 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import exopandora.worldhandler.util.NBTHelper;
|
||||
import net.minecraft.nbt.ByteTag;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class EntityNBT implements IBuilderComponent
|
||||
{
|
||||
private ResourceLocation id;
|
||||
private String command;
|
||||
private Integer time;
|
||||
private double[] motion = {0.0, 0.0, 0.0};
|
||||
private boolean isBaby;
|
||||
private BlockState blockState;
|
||||
private ComponentCustom entity = new ComponentCustom();
|
||||
private ComponentAttributeMob attribute = new ComponentAttributeMob();
|
||||
private MutableTextComponent customName = new MutableTextComponent();
|
||||
private List<EntityNBT> passengers = new ArrayList<EntityNBT>();
|
||||
private ResourceLocation[] armorItems = {Items.AIR.getRegistryName(), Items.AIR.getRegistryName(), Items.AIR.getRegistryName(), Items.AIR.getRegistryName()};
|
||||
private ResourceLocation[] handItems = {Items.AIR.getRegistryName(), Items.AIR.getRegistryName()};
|
||||
private ComponentPotionMob potion = new ComponentPotionMob();
|
||||
private CompoundTag nbt;
|
||||
|
||||
public EntityNBT()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public EntityNBT(ResourceLocation id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setId(ResourceLocation id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ResourceLocation getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute, double ammount)
|
||||
{
|
||||
this.attribute.set(attribute, ammount);
|
||||
}
|
||||
|
||||
public void removeAttribute(Attribute attribute)
|
||||
{
|
||||
this.attribute.remove(attribute);
|
||||
}
|
||||
|
||||
public double getAttributeAmmount(Attribute attribute)
|
||||
{
|
||||
return this.attribute.getAmmount(attribute);
|
||||
}
|
||||
|
||||
public Set<Attribute> getAttributes()
|
||||
{
|
||||
return this.attribute.getAttributes();
|
||||
}
|
||||
|
||||
public void setCustomName(String name)
|
||||
{
|
||||
this.customName.setText(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MutableTextComponent getCustomName()
|
||||
{
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
public void setPassenger(int index, EntityNBT entity)
|
||||
{
|
||||
if(index < 0 || index >= this.passengers.size())
|
||||
{
|
||||
this.passengers.add(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.passengers.set(index, entity);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPassenger(int index, ResourceLocation id)
|
||||
{
|
||||
this.setPassenger(index, new EntityNBT(id));
|
||||
}
|
||||
|
||||
public void addPassenger(EntityNBT entity)
|
||||
{
|
||||
this.passengers.add(entity);
|
||||
}
|
||||
|
||||
public void addPassenger(int index, EntityNBT entity)
|
||||
{
|
||||
this.passengers.add(index, entity);
|
||||
}
|
||||
|
||||
public void removePassenger(int index)
|
||||
{
|
||||
this.passengers.remove(index);
|
||||
}
|
||||
|
||||
public int getPassengerCount()
|
||||
{
|
||||
return this.passengers.size();
|
||||
}
|
||||
|
||||
public List<EntityNBT> getPassengers()
|
||||
{
|
||||
return this.passengers;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityNBT getPassenger(int index)
|
||||
{
|
||||
if(index >= 0 && index <= this.passengers.size())
|
||||
{
|
||||
return this.passengers.get(index);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasPassengers()
|
||||
{
|
||||
for(EntityNBT entity : this.passengers)
|
||||
{
|
||||
if(entity.serialize() != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Block block)
|
||||
{
|
||||
this.setArmorItem(index, block.getRegistryName());
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Item item)
|
||||
{
|
||||
this.setArmorItem(index, item.getRegistryName());
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, ResourceLocation location)
|
||||
{
|
||||
if(EntityNBT.isArrayIndexValid(this.armorItems, index) && location != null)
|
||||
{
|
||||
this.armorItems[index] = location;
|
||||
}
|
||||
}
|
||||
|
||||
public void setArmorItems(ResourceLocation[] armor)
|
||||
{
|
||||
this.armorItems = armor;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ResourceLocation getArmorItem(int slot)
|
||||
{
|
||||
if(EntityNBT.isArrayIndexValid(this.armorItems, slot))
|
||||
{
|
||||
return this.armorItems[slot];
|
||||
}
|
||||
|
||||
return Blocks.AIR.getRegistryName();
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Block block)
|
||||
{
|
||||
this.setHandItem(index, block.getRegistryName());
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Item item)
|
||||
{
|
||||
this.setHandItem(index, item.getRegistryName());
|
||||
}
|
||||
|
||||
public void setHandItem(int index, ResourceLocation location)
|
||||
{
|
||||
if(EntityNBT.isArrayIndexValid(this.handItems, index) && location != null)
|
||||
{
|
||||
this.handItems[index] = location;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ResourceLocation getHandItem(int slot)
|
||||
{
|
||||
if(EntityNBT.isArrayIndexValid(this.handItems, slot))
|
||||
{
|
||||
return this.handItems[slot];
|
||||
}
|
||||
|
||||
return Blocks.AIR.getRegistryName();
|
||||
}
|
||||
|
||||
public double[] getMotion()
|
||||
{
|
||||
return this.motion;
|
||||
}
|
||||
|
||||
public void setMotion(double x, double y, double z)
|
||||
{
|
||||
this.setMotionX(x);
|
||||
this.setMotionY(y);
|
||||
this.setMotionZ(z);
|
||||
}
|
||||
|
||||
public double getMotionX()
|
||||
{
|
||||
return this.motion[0];
|
||||
}
|
||||
|
||||
public double getMotionY()
|
||||
{
|
||||
return this.motion[1];
|
||||
}
|
||||
|
||||
public double getMotionZ()
|
||||
{
|
||||
return this.motion[2];
|
||||
}
|
||||
|
||||
public void setMotionX(double x)
|
||||
{
|
||||
this.motion[0] = x;
|
||||
}
|
||||
|
||||
public void setMotionY(double y)
|
||||
{
|
||||
this.motion[1] = y;
|
||||
}
|
||||
|
||||
public void setMotionZ(double z)
|
||||
{
|
||||
this.motion[2] = z;
|
||||
}
|
||||
|
||||
public void setAmplifier(MobEffect potion, byte amplifier)
|
||||
{
|
||||
this.potion.setAmplifier(potion, amplifier);
|
||||
}
|
||||
|
||||
public void setSeconds(MobEffect potion, int seconds)
|
||||
{
|
||||
this.potion.setSeconds(potion, seconds);
|
||||
}
|
||||
|
||||
public void setMinutes(MobEffect potion, int minutes)
|
||||
{
|
||||
this.potion.setMinutes(potion, minutes);
|
||||
}
|
||||
|
||||
public void setHours(MobEffect potion, int hours)
|
||||
{
|
||||
this.potion.setHours(potion, hours);
|
||||
}
|
||||
|
||||
public void setShowParticles(MobEffect potion, boolean showParticles)
|
||||
{
|
||||
this.potion.setShowParticles(potion, showParticles);
|
||||
}
|
||||
|
||||
public void setAmbient(MobEffect potion, boolean ambient)
|
||||
{
|
||||
this.potion.setAmbient(potion, ambient);
|
||||
}
|
||||
|
||||
public byte getAmplifier(MobEffect potion)
|
||||
{
|
||||
return this.potion.getAmplifier(potion);
|
||||
}
|
||||
|
||||
public int getSeconds(MobEffect potion)
|
||||
{
|
||||
return this.potion.getSeconds(potion);
|
||||
}
|
||||
|
||||
public int getMinutes(MobEffect potion)
|
||||
{
|
||||
return this.potion.getMinutes(potion);
|
||||
}
|
||||
|
||||
public int getHours(MobEffect potion)
|
||||
{
|
||||
return this.potion.getHours(potion);
|
||||
}
|
||||
|
||||
public boolean getShowParticles(MobEffect potion)
|
||||
{
|
||||
return this.potion.getShowParticles(potion);
|
||||
}
|
||||
|
||||
public boolean getAmbient(MobEffect potion)
|
||||
{
|
||||
return this.potion.getAmbient(potion);
|
||||
}
|
||||
|
||||
public Set<MobEffect> getEffects()
|
||||
{
|
||||
return this.potion.getMobEffects();
|
||||
}
|
||||
|
||||
public void setBlockState(BlockState blockState)
|
||||
{
|
||||
this.blockState = blockState;
|
||||
}
|
||||
|
||||
public BlockState getBlockState()
|
||||
{
|
||||
return this.blockState;
|
||||
}
|
||||
|
||||
public void setTime(int time)
|
||||
{
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public int getTime()
|
||||
{
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public void setCustomComponent(String tag, Tag nbt)
|
||||
{
|
||||
this.entity.set(tag, nbt);
|
||||
}
|
||||
|
||||
public void resetCustomComponent()
|
||||
{
|
||||
this.entity.set(null, null);
|
||||
}
|
||||
|
||||
public void setIsBaby(boolean baby)
|
||||
{
|
||||
this.isBaby = baby;
|
||||
}
|
||||
|
||||
public boolean isBaby()
|
||||
{
|
||||
return this.isBaby;
|
||||
}
|
||||
|
||||
public void setCommand(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public void setNBT(CompoundTag nbt)
|
||||
{
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public CompoundTag getNBT()
|
||||
{
|
||||
return this.nbt;
|
||||
}
|
||||
|
||||
public void setNBT(String nbt)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.nbt = TagParser.parseTag("{" + nbt + "}");
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
this.nbt = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
|
||||
if(this.time != null)
|
||||
{
|
||||
NBTHelper.append(nbt, "Time", IntTag.valueOf(this.time));
|
||||
}
|
||||
|
||||
if(this.command != null)
|
||||
{
|
||||
NBTHelper.append(nbt, "Command", StringTag.valueOf(this.command));
|
||||
}
|
||||
|
||||
if(this.isBaby)
|
||||
{
|
||||
NBTHelper.append(nbt, "IsBaby", ByteTag.valueOf(true));
|
||||
}
|
||||
|
||||
NBTHelper.append(nbt, "id", NBTHelper.serialize(this.id));
|
||||
NBTHelper.append(nbt, "Motion", NBTHelper.serialize(this.motion));
|
||||
NBTHelper.append(nbt, "Passengers", NBTHelper.serialize(this.passengers));
|
||||
NBTHelper.append(nbt, "ArmorItems", NBTHelper.serialize(this.armorItems));
|
||||
NBTHelper.append(nbt, "HandItems", NBTHelper.serialize(this.handItems));
|
||||
NBTHelper.append(nbt, "BlockState", NBTHelper.serialize(this.blockState));
|
||||
|
||||
NBTHelper.append(nbt, "CustomName", this.customName);
|
||||
|
||||
NBTHelper.append(nbt, this.entity);
|
||||
NBTHelper.append(nbt, this.potion);
|
||||
NBTHelper.append(nbt, this.attribute);
|
||||
|
||||
if(this.nbt != null)
|
||||
{
|
||||
nbt.merge(this.nbt);
|
||||
}
|
||||
|
||||
if(nbt.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isArrayIndexValid(Object[] array, int index)
|
||||
{
|
||||
if(array != null && (Array.getLength(array) == 0 || array.length <= index))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return index >= 0;
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class BuilderAdvancement extends CommandBuilder
|
||||
{
|
||||
public BuilderAdvancement(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderAdvancement(EnumActionType action, String player, EnumMode mode, ResourceLocation advancement)
|
||||
{
|
||||
this(mode);
|
||||
this.setActionType(action);
|
||||
this.setPlayer(player);
|
||||
this.setAdvancement(advancement);
|
||||
}
|
||||
|
||||
public void setActionType(EnumActionType action)
|
||||
{
|
||||
this.setNode(0, action != null ? action.toString() : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumActionType getActionType()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(1), EnumActionType.class);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(2, mode != null ? mode.toString() : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(2), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setAdvancement(ResourceLocation advancement)
|
||||
{
|
||||
this.setNode(3, advancement);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getAdvancement()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(3);
|
||||
}
|
||||
|
||||
public BuilderAdvancement build(EnumActionType action)
|
||||
{
|
||||
return this.build(action, this.getMode());
|
||||
}
|
||||
|
||||
public BuilderAdvancement build(EnumActionType action, EnumMode mode)
|
||||
{
|
||||
return new BuilderAdvancement(action, this.getPlayer(), mode, !EnumMode.EVERYTHING.equals(mode) ? this.getAdvancement() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "advancement";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("grant|revoke|test", ArgumentType.STRING);
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("only|until|from|through|everything", ArgumentType.STRING);
|
||||
syntax.addOptional("advancement", ArgumentType.RESOURCE_LOCATION);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumActionType
|
||||
{
|
||||
GRANT,
|
||||
REVOKE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ONLY,
|
||||
UNTIL,
|
||||
FROM,
|
||||
THROUGH,
|
||||
EVERYTHING;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public abstract class BuilderBlockPos extends CommandBuilderNBT
|
||||
{
|
||||
private final int offset;
|
||||
|
||||
public BuilderBlockPos(int offset)
|
||||
{
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public void setPosition(BlockPos pos)
|
||||
{
|
||||
this.setX(pos.getX());
|
||||
this.setY(pos.getY());
|
||||
this.setZ(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.setX(new CoordinateInt(x));
|
||||
}
|
||||
|
||||
public void setY(int y)
|
||||
{
|
||||
this.setY(new CoordinateInt(y));
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.setZ(new CoordinateInt(z));
|
||||
}
|
||||
|
||||
public void setX(CoordinateInt x)
|
||||
{
|
||||
this.setNode(this.offset, x);
|
||||
}
|
||||
|
||||
public void setY(CoordinateInt y)
|
||||
{
|
||||
this.setNode(this.offset + 1, y);
|
||||
}
|
||||
|
||||
public void setZ(CoordinateInt z)
|
||||
{
|
||||
this.setNode(this.offset + 2, z);
|
||||
}
|
||||
|
||||
public CoordinateInt getXCoordinate()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(this.offset);
|
||||
}
|
||||
|
||||
public CoordinateInt getYCoordinate()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(this.offset + 1);
|
||||
}
|
||||
|
||||
public CoordinateInt getZCoordinate()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(this.offset + 2);
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return this.getXCoordinate().getValue();
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return this.getYCoordinate().getValue();
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return this.getZCoordinate().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return new BlockPos(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class BuilderButcher extends CommandBuilder
|
||||
{
|
||||
private final TargetSelector targetSelector = new TargetSelector();
|
||||
|
||||
public BuilderButcher()
|
||||
{
|
||||
this("<entity_name>", 0);
|
||||
}
|
||||
|
||||
public BuilderButcher(ResourceLocation entity, int distance)
|
||||
{
|
||||
this(entity.toString(), distance);
|
||||
}
|
||||
|
||||
private BuilderButcher(String entity, int distance)
|
||||
{
|
||||
this.setEntity(entity);
|
||||
this.setDistance(distance);
|
||||
}
|
||||
|
||||
public void setDistance(int distance)
|
||||
{
|
||||
this.targetSelector.set("distance", "0.." + distance);
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
public int getDistance()
|
||||
{
|
||||
return Integer.parseInt(this.targetSelector.<String>get("distance").substring(3));
|
||||
}
|
||||
|
||||
private void setEntity(String entity)
|
||||
{
|
||||
if(entity != null)
|
||||
{
|
||||
this.targetSelector.set("type", entity);
|
||||
}
|
||||
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
public void setEntity(ResourceLocation entity)
|
||||
{
|
||||
this.setEntity(entity.toString());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.targetSelector.<ResourceLocation>get("type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "kill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("entity_name", ArgumentType.TARGET_SELECTOR);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class BuilderClone extends BuilderDoubleBlockPos
|
||||
{
|
||||
public BuilderClone()
|
||||
{
|
||||
this.setX(new CoordinateInt(EnumType.GLOBAL));
|
||||
this.setY(new CoordinateInt(EnumType.GLOBAL));
|
||||
this.setZ(new CoordinateInt(EnumType.GLOBAL));
|
||||
this.setMask(EnumMask.values()[0]);
|
||||
}
|
||||
|
||||
public void setPosition(BlockPos pos)
|
||||
{
|
||||
this.setX(pos.getX());
|
||||
this.setY(pos.getY());
|
||||
this.setZ(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.setX(new CoordinateInt(x));
|
||||
}
|
||||
|
||||
public void setY(int y)
|
||||
{
|
||||
this.setY(new CoordinateInt(y));
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.setZ(new CoordinateInt(z));
|
||||
}
|
||||
|
||||
public void setX(CoordinateInt x)
|
||||
{
|
||||
this.setNode(6, x);
|
||||
}
|
||||
|
||||
public void setY(CoordinateInt y)
|
||||
{
|
||||
this.setNode(7, y);
|
||||
}
|
||||
|
||||
public void setZ(CoordinateInt z)
|
||||
{
|
||||
this.setNode(8, z);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getXCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(6);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getYCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(7);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getZCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(8);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return this.getXCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return this.getYCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return this.getZCoordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return new BlockPos(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
public void setMask(EnumMask mask)
|
||||
{
|
||||
this.setNode(9, mask != null ? mask.toString() : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMask getMask()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(9), EnumMask.class);
|
||||
}
|
||||
|
||||
public void setFilter(String filter)
|
||||
{
|
||||
if(filter != null)
|
||||
{
|
||||
this.setMask(EnumMask.FILTERED);
|
||||
}
|
||||
|
||||
this.setNode(10, filter);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFilter()
|
||||
{
|
||||
if(EnumMask.FILTERED.equals(this.getMask()))
|
||||
{
|
||||
return this.getNodeAsString(10);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "clone";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("x1", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y1", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z1", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("x2", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y2", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z2", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("x", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z", ArgumentType.COORDINATE_INT);
|
||||
syntax.addOptional("mask", ArgumentType.STRING);
|
||||
syntax.addOptional("filter", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMask
|
||||
{
|
||||
FILTERED,
|
||||
MASKED,
|
||||
REPLACE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttributeItem;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentDisplay;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentEnchantment;
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
||||
public class BuilderCustomItem extends BuilderGive
|
||||
{
|
||||
private final ComponentAttributeItem attribute;
|
||||
private final ComponentDisplay display;
|
||||
private final ComponentEnchantment enchantment;
|
||||
|
||||
public BuilderCustomItem()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public BuilderCustomItem(String player, ResourceLocation item)
|
||||
{
|
||||
super(player, item);
|
||||
this.attribute = this.registerNBTComponent(new ComponentAttributeItem());
|
||||
this.display = this.registerNBTComponent(new ComponentDisplay());
|
||||
this.enchantment = this.registerNBTComponent(new ComponentEnchantment());
|
||||
}
|
||||
|
||||
public void setEnchantment(Enchantment enchantment, short level)
|
||||
{
|
||||
this.enchantment.setLevel(enchantment, level);
|
||||
}
|
||||
|
||||
public short getEnchantmentLevel(Enchantment enchantment)
|
||||
{
|
||||
return this.enchantment.getLevel(enchantment);
|
||||
}
|
||||
|
||||
public Set<Enchantment> getEnchantments()
|
||||
{
|
||||
return this.enchantment.getEnchantments();
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute, double ammount)
|
||||
{
|
||||
this.attribute.set(attribute, ammount);
|
||||
}
|
||||
|
||||
public void removeAttribute(Attribute attribute)
|
||||
{
|
||||
this.attribute.remove(attribute);
|
||||
}
|
||||
|
||||
public double getAttributeAmmount(Attribute attribute)
|
||||
{
|
||||
return this.attribute.getAmmount(attribute);
|
||||
}
|
||||
|
||||
public Set<Attribute> getAttributes()
|
||||
{
|
||||
return this.attribute.getAttributes();
|
||||
}
|
||||
|
||||
public void setName(MutableTextComponent name)
|
||||
{
|
||||
this.display.setName(name);
|
||||
}
|
||||
|
||||
public MutableTextComponent getName()
|
||||
{
|
||||
return this.display.getName();
|
||||
}
|
||||
|
||||
public void setLore1(Component lore)
|
||||
{
|
||||
this.display.setLore1(lore);
|
||||
}
|
||||
|
||||
public Component getLore1()
|
||||
{
|
||||
return this.display.getLore1();
|
||||
}
|
||||
|
||||
public void setLore2(Component lore)
|
||||
{
|
||||
this.display.setLore2(lore);
|
||||
}
|
||||
|
||||
public Component getLore2()
|
||||
{
|
||||
return this.display.getLore2();
|
||||
}
|
||||
}
|
||||
@@ -1,323 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class BuilderData extends BuilderBlockPos
|
||||
{
|
||||
private final TargetSelector targetSelector = new TargetSelector();
|
||||
|
||||
public BuilderData()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
public BuilderData(EnumMode mode, ResourceLocation entity, CompoundTag nbt)
|
||||
{
|
||||
this();
|
||||
this.setMode(mode);
|
||||
this.setEntity(entity);
|
||||
this.setNBT(nbt);
|
||||
}
|
||||
|
||||
public BuilderData(EnumMode mode, BlockPos pos, CompoundTag nbt)
|
||||
{
|
||||
this();
|
||||
this.setMode(mode);
|
||||
this.setPosition(pos);
|
||||
this.setNBT(nbt);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
EnumTarget target = this.getTarget();
|
||||
|
||||
this.updateSyntax(this.getSyntax(mode, target));
|
||||
this.setMode0(mode);
|
||||
this.setTarget0(target);
|
||||
}
|
||||
|
||||
private void setMode0(EnumMode mode)
|
||||
{
|
||||
if(mode != null)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setTarget(EnumTarget target)
|
||||
{
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
this.updateSyntax(this.getSyntax(mode, target));
|
||||
this.setMode0(mode);
|
||||
this.setTarget0(target);
|
||||
}
|
||||
|
||||
private void setTarget0(EnumTarget target)
|
||||
{
|
||||
if(target != null)
|
||||
{
|
||||
this.setNode(1, target.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumTarget getTarget()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(1), EnumTarget.class);
|
||||
}
|
||||
|
||||
private void setEntity(String entity)
|
||||
{
|
||||
this.ensureTarget(EnumTarget.ENTITY);
|
||||
|
||||
if(entity != null)
|
||||
{
|
||||
this.targetSelector.set("type", entity);
|
||||
}
|
||||
|
||||
this.setNode(2, this.targetSelector);
|
||||
}
|
||||
|
||||
public void setEntity(ResourceLocation entity)
|
||||
{
|
||||
this.setEntity(entity.toString());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.targetSelector.<ResourceLocation>get("type");
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals(EnumMode.REMOVE))
|
||||
{
|
||||
this.setMode(EnumMode.REMOVE);
|
||||
}
|
||||
|
||||
switch(this.getTarget())
|
||||
{
|
||||
case BLOCK:
|
||||
this.setNode(5, path);
|
||||
break;
|
||||
case ENTITY:
|
||||
this.setNode(3, path);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(CompoundTag nbt)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals(EnumMode.MERGE))
|
||||
{
|
||||
this.setMode(EnumMode.MERGE);
|
||||
}
|
||||
|
||||
EnumTarget target = this.getTarget();
|
||||
|
||||
if(target != null)
|
||||
{
|
||||
switch(target)
|
||||
{
|
||||
case BLOCK:
|
||||
this.setNode(5, nbt);
|
||||
break;
|
||||
case ENTITY:
|
||||
this.setNode(3, nbt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CompoundTag getNBT()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals(EnumMode.MERGE))
|
||||
{
|
||||
switch(this.getTarget())
|
||||
{
|
||||
case BLOCK:
|
||||
return this.getNodeAsNBT(5);
|
||||
case ENTITY:
|
||||
return this.getNodeAsNBT(3);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "data";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private final CommandSyntax getSyntax(EnumMode mode, EnumTarget target)
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired(mode != null ? mode.toString() : "mode", ArgumentType.STRING);
|
||||
syntax.addRequired(target != null ? target.toString() : "target", ArgumentType.STRING);
|
||||
|
||||
if(target != null)
|
||||
{
|
||||
switch(target)
|
||||
{
|
||||
case BLOCK:
|
||||
syntax.addRequired("x", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z", ArgumentType.COORDINATE_INT);
|
||||
break;
|
||||
case ENTITY:
|
||||
syntax.addRequired("entity", ArgumentType.TARGET_SELECTOR);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case GET:
|
||||
break;
|
||||
case MERGE:
|
||||
syntax.addRequired("nbt", ArgumentType.NBT);
|
||||
break;
|
||||
case REMOVE:
|
||||
syntax.addRequired("path", ArgumentType.STRING);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
syntax.addOptional("...", ArgumentType.STRING);
|
||||
}
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
private void ensureTarget(EnumTarget target)
|
||||
{
|
||||
if(this.getTarget() == null || !target.equals(this.getTarget()))
|
||||
{
|
||||
this.setTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setX(CoordinateInt x)
|
||||
{
|
||||
this.ensureTarget(EnumTarget.BLOCK);
|
||||
super.setX(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setY(CoordinateInt y)
|
||||
{
|
||||
this.ensureTarget(EnumTarget.BLOCK);
|
||||
super.setY(y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZ(CoordinateInt z)
|
||||
{
|
||||
this.ensureTarget(EnumTarget.BLOCK);
|
||||
super.setZ(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public CoordinateInt getXCoordinate()
|
||||
{
|
||||
this.ensureTarget(EnumTarget.BLOCK);
|
||||
return super.getXCoordinate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public CoordinateInt getYCoordinate()
|
||||
{
|
||||
this.ensureTarget(EnumTarget.BLOCK);
|
||||
return super.getYCoordinate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public CoordinateInt getZCoordinate()
|
||||
{
|
||||
this.ensureTarget(EnumTarget.BLOCK);
|
||||
return super.getZCoordinate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
this.ensureTarget(EnumTarget.BLOCK);
|
||||
return super.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("get|merge|remove", ArgumentType.STRING);
|
||||
syntax.addRequired("block|entity", ArgumentType.STRING);
|
||||
syntax.addOptional("...", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
GET,
|
||||
MERGE,
|
||||
REMOVE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumTarget
|
||||
{
|
||||
BLOCK,
|
||||
ENTITY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import net.minecraft.world.Difficulty;
|
||||
|
||||
public class BuilderDifficulty extends CommandBuilder
|
||||
{
|
||||
public BuilderDifficulty()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderDifficulty(Difficulty difficulty)
|
||||
{
|
||||
this.setDifficulty(difficulty);
|
||||
}
|
||||
|
||||
public void setDifficulty(Difficulty difficulty)
|
||||
{
|
||||
if(difficulty != null)
|
||||
{
|
||||
this.setNode(0, difficulty.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "difficulty";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("peaceful|easy|normal|hard", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public abstract class BuilderDoubleBlockPos extends CommandBuilder
|
||||
{
|
||||
public BuilderDoubleBlockPos()
|
||||
{
|
||||
this.setPosition1(BlockHelper.getPos1());
|
||||
this.setPosition2(BlockHelper.getPos2());
|
||||
}
|
||||
|
||||
public void setPosition1(BlockPos pos)
|
||||
{
|
||||
this.setX1(pos.getX());
|
||||
this.setY1(pos.getY());
|
||||
this.setZ1(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX1(int x)
|
||||
{
|
||||
this.setX1(new CoordinateInt(x));
|
||||
}
|
||||
|
||||
public void setY1(int y)
|
||||
{
|
||||
this.setY1(new CoordinateInt(y));
|
||||
}
|
||||
|
||||
public void setZ1(int z)
|
||||
{
|
||||
this.setZ1(new CoordinateInt(z));
|
||||
}
|
||||
|
||||
public void setX1(CoordinateInt x)
|
||||
{
|
||||
this.setNode(0, x);
|
||||
}
|
||||
|
||||
public void setY1(CoordinateInt y)
|
||||
{
|
||||
this.setNode(1, y);
|
||||
}
|
||||
|
||||
public void setZ1(CoordinateInt z)
|
||||
{
|
||||
this.setNode(2, z);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getX1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(0);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getY1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(1);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getZ1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(2);
|
||||
}
|
||||
|
||||
public double getX1()
|
||||
{
|
||||
return this.getX1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY1()
|
||||
{
|
||||
return this.getY1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ1()
|
||||
{
|
||||
return this.getZ1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos1()
|
||||
{
|
||||
return new BlockPos(this.getX1(), this.getY1(), this.getZ1());
|
||||
}
|
||||
|
||||
public void setPosition2(BlockPos pos)
|
||||
{
|
||||
this.setX2(pos.getX());
|
||||
this.setY2(pos.getY());
|
||||
this.setZ2(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX2(int x)
|
||||
{
|
||||
this.setX2(new CoordinateInt(x));
|
||||
}
|
||||
|
||||
public void setY2(int y)
|
||||
{
|
||||
this.setY2(new CoordinateInt(y));
|
||||
}
|
||||
|
||||
public void setZ2(int z)
|
||||
{
|
||||
this.setZ2(new CoordinateInt(z));
|
||||
}
|
||||
|
||||
public void setX2(CoordinateInt x)
|
||||
{
|
||||
this.setNode(3, x);
|
||||
}
|
||||
|
||||
public void setY2(CoordinateInt y)
|
||||
{
|
||||
this.setNode(4, y);
|
||||
}
|
||||
|
||||
public void setZ2(CoordinateInt z)
|
||||
{
|
||||
this.setNode(5, z);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getX2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(3);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getY2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(4);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CoordinateInt getZ2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinateInt(5);
|
||||
}
|
||||
|
||||
public double getX2()
|
||||
{
|
||||
return this.getX2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY2()
|
||||
{
|
||||
return this.getY2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ2()
|
||||
{
|
||||
return this.getZ2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos2()
|
||||
{
|
||||
return new BlockPos(this.getX2(), this.getY2(), this.getZ2());
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
||||
public class BuilderEnchantment extends CommandBuilder
|
||||
{
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getEnchantment()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setEnchantment(Enchantment enchantment)
|
||||
{
|
||||
this.setEnchantment(enchantment.getRegistryName());
|
||||
}
|
||||
|
||||
public void setEnchantment(ResourceLocation enchantment)
|
||||
{
|
||||
this.setNode(1, enchantment);
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.setNode(2, level);
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "enchant";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("enchantment", ArgumentType.RESOURCE_LOCATION);
|
||||
syntax.addOptional("level", ArgumentType.INT, 1);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,506 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.component.impl.EntityNBT;
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import exopandora.worldhandler.util.ResourceHelper;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.nbt.ByteTag;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public abstract class BuilderEntity extends CommandBuilderNBT
|
||||
{
|
||||
private final EntityNBT nbt = new EntityNBT();
|
||||
|
||||
public abstract void setEntity(ResourceLocation entity);
|
||||
|
||||
public abstract ResourceLocation getEntity();
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.setEntity(BuilderEntity.parseEntityName(name));
|
||||
this.updateCustomComponent(name);
|
||||
}
|
||||
|
||||
public void setNameAndId(String name)
|
||||
{
|
||||
this.setName(name);
|
||||
this.nbt.setId(this.getEntity());
|
||||
}
|
||||
|
||||
public void setId(ResourceLocation resource)
|
||||
{
|
||||
this.nbt.setId(resource);
|
||||
}
|
||||
|
||||
public ResourceLocation getId()
|
||||
{
|
||||
return this.nbt.getId();
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute, double ammount)
|
||||
{
|
||||
this.nbt.setAttribute(attribute, ammount);
|
||||
}
|
||||
|
||||
public void removeAttribute(Attribute attribute)
|
||||
{
|
||||
this.nbt.removeAttribute(attribute);
|
||||
}
|
||||
|
||||
public double getAttributeAmmount(Attribute attribute)
|
||||
{
|
||||
return this.nbt.getAttributeAmmount(attribute);
|
||||
}
|
||||
|
||||
public Set<Attribute> getAttributes()
|
||||
{
|
||||
return this.nbt.getAttributes();
|
||||
}
|
||||
|
||||
public void setCustomName(String name)
|
||||
{
|
||||
this.nbt.setCustomName(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MutableTextComponent getCustomName()
|
||||
{
|
||||
return this.nbt.getCustomName();
|
||||
}
|
||||
|
||||
public void setPassenger(int index, String name)
|
||||
{
|
||||
this.nbt.setPassenger(index, BuilderEntity.parseEntityName(name));
|
||||
}
|
||||
|
||||
public void setPassenger(int index, EntityNBT entity)
|
||||
{
|
||||
this.nbt.setPassenger(index, entity);
|
||||
}
|
||||
|
||||
public void setPassenger(int index, ResourceLocation id)
|
||||
{
|
||||
this.setPassenger(index, new EntityNBT(id));
|
||||
}
|
||||
|
||||
public void addPassenger(EntityNBT entity)
|
||||
{
|
||||
this.nbt.addPassenger(entity);
|
||||
}
|
||||
|
||||
public void addPassenger(int index, EntityNBT entity)
|
||||
{
|
||||
this.nbt.addPassenger(index, entity);
|
||||
}
|
||||
|
||||
public void removePassenger(int index)
|
||||
{
|
||||
this.nbt.removePassenger(index);
|
||||
}
|
||||
|
||||
public int getPassengerCount()
|
||||
{
|
||||
return this.nbt.getPassengerCount();
|
||||
}
|
||||
|
||||
public List<EntityNBT> getPassengers()
|
||||
{
|
||||
return this.nbt.getPassengers();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityNBT getPassenger(int index)
|
||||
{
|
||||
return this.nbt.getPassenger(index);
|
||||
}
|
||||
|
||||
public boolean hasPassengers()
|
||||
{
|
||||
return this.nbt.hasPassengers();
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Block block)
|
||||
{
|
||||
this.nbt.setArmorItem(index, block);
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Item item)
|
||||
{
|
||||
this.nbt.setArmorItem(index, item);
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, ResourceLocation location)
|
||||
{
|
||||
this.nbt.setArmorItem(index, location);
|
||||
}
|
||||
|
||||
public void setArmorItems(ResourceLocation[] armor)
|
||||
{
|
||||
this.nbt.setArmorItems(armor);
|
||||
}
|
||||
|
||||
public ResourceLocation getArmorItem(int slot)
|
||||
{
|
||||
return this.nbt.getArmorItem(slot);
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Block block)
|
||||
{
|
||||
this.nbt.setHandItem(index, block);
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Item item)
|
||||
{
|
||||
this.nbt.setHandItem(index, item);
|
||||
}
|
||||
|
||||
public void setHandItem(int index, ResourceLocation location)
|
||||
{
|
||||
this.nbt.setHandItem(index, location);
|
||||
}
|
||||
|
||||
public ResourceLocation getHandItem(int slot)
|
||||
{
|
||||
return this.nbt.getHandItem(slot);
|
||||
}
|
||||
|
||||
public double[] getMotion()
|
||||
{
|
||||
return this.nbt.getMotion();
|
||||
}
|
||||
|
||||
public void setMotion(double x, double y, double z)
|
||||
{
|
||||
this.nbt.setMotion(x, y, z);
|
||||
}
|
||||
|
||||
public double getMotionX()
|
||||
{
|
||||
return this.nbt.getMotionX();
|
||||
}
|
||||
|
||||
public double getMotionY()
|
||||
{
|
||||
return this.nbt.getMotionY();
|
||||
}
|
||||
|
||||
public double getMotionZ()
|
||||
{
|
||||
return this.nbt.getMotionZ();
|
||||
}
|
||||
|
||||
public void setMotionX(double x)
|
||||
{
|
||||
this.nbt.setMotionX(x);
|
||||
}
|
||||
|
||||
public void setMotionY(double y)
|
||||
{
|
||||
this.nbt.setMotionY(y);
|
||||
}
|
||||
|
||||
public void setMotionZ(double z)
|
||||
{
|
||||
this.nbt.setMotionZ(z);
|
||||
}
|
||||
|
||||
public void setAmplifier(MobEffect potion, byte amplifier)
|
||||
{
|
||||
this.nbt.setAmplifier(potion, amplifier);
|
||||
}
|
||||
|
||||
public void setSeconds(MobEffect potion, int seconds)
|
||||
{
|
||||
this.nbt.setSeconds(potion, seconds);
|
||||
}
|
||||
|
||||
public void setMinutes(MobEffect potion, int minutes)
|
||||
{
|
||||
this.nbt.setMinutes(potion, minutes);
|
||||
}
|
||||
|
||||
public void setHours(MobEffect potion, int hours)
|
||||
{
|
||||
this.nbt.setHours(potion, hours);
|
||||
}
|
||||
|
||||
public void setShowParticles(MobEffect potion, boolean showParticles)
|
||||
{
|
||||
this.nbt.setShowParticles(potion, showParticles);
|
||||
}
|
||||
|
||||
public void setAmbient(MobEffect potion, boolean ambient)
|
||||
{
|
||||
this.nbt.setAmbient(potion, ambient);
|
||||
}
|
||||
|
||||
public byte getAmplifier(MobEffect potion)
|
||||
{
|
||||
return this.nbt.getAmplifier(potion);
|
||||
}
|
||||
|
||||
public int getSeconds(MobEffect potion)
|
||||
{
|
||||
return this.nbt.getSeconds(potion);
|
||||
}
|
||||
|
||||
public int getMinutes(MobEffect potion)
|
||||
{
|
||||
return this.nbt.getMinutes(potion);
|
||||
}
|
||||
|
||||
public int getHours(MobEffect potion)
|
||||
{
|
||||
return this.nbt.getHours(potion);
|
||||
}
|
||||
|
||||
public boolean getShowParticles(MobEffect potion)
|
||||
{
|
||||
return this.nbt.getShowParticles(potion);
|
||||
}
|
||||
|
||||
public boolean getAmbient(MobEffect potion)
|
||||
{
|
||||
return this.nbt.getAmbient(potion);
|
||||
}
|
||||
|
||||
public Set<MobEffect> getMobEffects()
|
||||
{
|
||||
return this.nbt.getEffects();
|
||||
}
|
||||
|
||||
public void setBlockState(BlockState blockState)
|
||||
{
|
||||
this.nbt.setBlockState(blockState);
|
||||
}
|
||||
|
||||
public BlockState getBlockState()
|
||||
{
|
||||
return this.nbt.getBlockState();
|
||||
}
|
||||
|
||||
public void setTime(int time)
|
||||
{
|
||||
this.nbt.setTime(time);
|
||||
}
|
||||
|
||||
public int getTime()
|
||||
{
|
||||
return this.nbt.getTime();
|
||||
}
|
||||
|
||||
public void setCommand(String command)
|
||||
{
|
||||
this.nbt.setCommand(command);
|
||||
}
|
||||
|
||||
public String getCommand()
|
||||
{
|
||||
return this.nbt.getCommand();
|
||||
}
|
||||
|
||||
public void setEntityNBT(String nbt)
|
||||
{
|
||||
this.nbt.setNBT(nbt);
|
||||
}
|
||||
|
||||
public void setEntityNBT(CompoundTag nbt)
|
||||
{
|
||||
this.nbt.setNBT(nbt);
|
||||
}
|
||||
|
||||
public CompoundTag getEntityNBT()
|
||||
{
|
||||
return this.nbt.getNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompoundTag buildNBT()
|
||||
{
|
||||
return this.nbt.serialize();
|
||||
}
|
||||
|
||||
private void updateCustomComponent(String name)
|
||||
{
|
||||
ResourceLocation entity = this.getEntity();
|
||||
|
||||
if(name != null && entity != null)
|
||||
{
|
||||
if(entity.equals(EntityType.CAT.getRegistryName()))
|
||||
{
|
||||
this.nbt.setCustomComponent("CatType", IntTag.valueOf(new Random().nextInt(11)));
|
||||
}
|
||||
else if(entity.equals(EntityType.VILLAGER.getRegistryName()))
|
||||
{
|
||||
for(VillagerProfession profession : ForgeRegistries.PROFESSIONS)
|
||||
{
|
||||
if(StringUtils.equalsIgnoreCase(name, profession.toString()))
|
||||
{
|
||||
CompoundTag villagerData = new CompoundTag();
|
||||
villagerData.putString("profession", profession.getRegistryName().toString());
|
||||
|
||||
this.nbt.setCustomComponent("VillagerData", villagerData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(entity.equals(EntityType.ZOMBIE.getRegistryName()))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(name, "Baby"))
|
||||
{
|
||||
this.nbt.setCustomComponent("IsBaby", ByteTag.valueOf((byte) 1));
|
||||
}
|
||||
}
|
||||
else if(entity.equals(EntityType.CHICKEN.getRegistryName()))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(name, "Jockey") && !this.nbt.hasPassengers())
|
||||
{
|
||||
ListTag list = new ListTag();
|
||||
EntityNBT zombie = new EntityNBT(EntityType.ZOMBIE.getRegistryName());
|
||||
|
||||
zombie.setIsBaby(true);
|
||||
list.add(zombie.serialize());
|
||||
this.nbt.setCustomComponent("Passengers", list);
|
||||
}
|
||||
}
|
||||
else if(entity.equals(EntityType.SPIDER.getRegistryName()))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(name, "Jockey") && !this.nbt.hasPassengers())
|
||||
{
|
||||
ListTag list = new ListTag();
|
||||
EntityNBT skeleton = new EntityNBT(EntityType.SKELETON.getRegistryName());
|
||||
|
||||
skeleton.setHandItem(0, Items.BOW);
|
||||
list.add(skeleton.serialize());
|
||||
|
||||
this.nbt.setCustomComponent("Passengers", list);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.nbt.resetCustomComponent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.nbt.resetCustomComponent();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation parseEntityName(String entityName)
|
||||
{
|
||||
String name = ResourceHelper.stripToResourceLocation(entityName);
|
||||
|
||||
if(name == null || name.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for(EntityType<?> type : ForgeRegistries.ENTITIES.getValues())
|
||||
{
|
||||
if(type.canSummon() && entityName.equalsIgnoreCase(I18n.get(type.getDescriptionId())))
|
||||
{
|
||||
return type.getRegistryName();
|
||||
}
|
||||
}
|
||||
|
||||
String entity = name.replaceAll("_", "");
|
||||
|
||||
if("RedCow".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.MOOSHROOM.getRegistryName();
|
||||
}
|
||||
else if("ChickenJockey".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.CHICKEN.getRegistryName();
|
||||
}
|
||||
else if("Pigman".equalsIgnoreCase(entity) || "ZombiePig".equalsIgnoreCase(entity) || "ZombiePigman".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.PIGLIN.getRegistryName();
|
||||
}
|
||||
else if("Dog".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.WOLF.getRegistryName();
|
||||
}
|
||||
else if("Dragon".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.ENDER_DRAGON.getRegistryName();
|
||||
}
|
||||
else if("SnowMan".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.SNOW_GOLEM.getRegistryName();
|
||||
}
|
||||
else if("LavaCube".equalsIgnoreCase(entity)|| "MagmaSlime".equalsIgnoreCase(entity) || "LavaSlime".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.MAGMA_CUBE.getRegistryName();
|
||||
}
|
||||
else if("SpiderJockey".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.SPIDER.getRegistryName();
|
||||
}
|
||||
else if("VillagerGolem".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.IRON_GOLEM.getRegistryName();
|
||||
}
|
||||
else if("Ozelot".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.OCELOT.getRegistryName();
|
||||
}
|
||||
else if("Kitty".equalsIgnoreCase(entity) || "Kitten".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.CAT.getRegistryName();
|
||||
}
|
||||
else if("TESTIFICATE".equalsIgnoreCase(entity) || ForgeRegistries.PROFESSIONS.getKeys().stream().anyMatch(profession -> profession.getPath().equalsIgnoreCase(entity)))
|
||||
{
|
||||
return EntityType.VILLAGER.getRegistryName();
|
||||
}
|
||||
else if("Octopus".equalsIgnoreCase(entity) || "Kraken".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.SQUID.getRegistryName();
|
||||
}
|
||||
else if("Exwife".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.GHAST.getRegistryName();
|
||||
}
|
||||
else if("CommandMinecart".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.COMMAND_BLOCK_MINECART.getRegistryName();
|
||||
}
|
||||
else if("Wizard".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.EVOKER.getRegistryName();
|
||||
}
|
||||
else if("Johnny".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.VINDICATOR.getRegistryName();
|
||||
}
|
||||
else if("BabyZombie".equalsIgnoreCase(entity))
|
||||
{
|
||||
return EntityType.ZOMBIE.getRegistryName();
|
||||
}
|
||||
|
||||
return ResourceHelper.stringToResourceLocation(name);
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
|
||||
public class BuilderExecute extends CommandBuilder
|
||||
{
|
||||
public void setMode1(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode1()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
this.setNode(1, target);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTarget()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMode2(EnumMode mode)
|
||||
{
|
||||
this.setNode(2, mode.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode2()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(2), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setCommand(String command)
|
||||
{
|
||||
if(command != null && command.startsWith("/"))
|
||||
{
|
||||
this.setNode(3, command.substring(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setNode(3, command);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCommand()
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "execute";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("modifier", ArgumentType.STRING);
|
||||
syntax.addRequired("targets", ArgumentType.STRING);
|
||||
syntax.addRequired("action", ArgumentType.STRING);
|
||||
syntax.addRequired("command", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ALIGN,
|
||||
ANCHORED,
|
||||
AS,
|
||||
AT,
|
||||
IN,
|
||||
RUN;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
|
||||
public class BuilderExperience extends CommandBuilder
|
||||
{
|
||||
public BuilderExperience()
|
||||
{
|
||||
this.setLevel(0);
|
||||
}
|
||||
|
||||
public BuilderExperience(EnumMode mode, int level, String player, EnumUnit unit)
|
||||
{
|
||||
this.setMode(mode);
|
||||
this.setLevel(level);
|
||||
this.setPlayer(player);
|
||||
this.setUnit(unit);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.setNode(2, level);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public int getLevel()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
public void setUnit(EnumUnit unit)
|
||||
{
|
||||
this.setNode(3, unit.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumUnit getUnit()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(3), EnumUnit.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "experience";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("add|set|query", ArgumentType.STRING);
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("amount", ArgumentType.INT);
|
||||
syntax.addOptional("levels|points", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public BuilderExperience buildAdd()
|
||||
{
|
||||
return new BuilderExperience(EnumMode.ADD, this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
|
||||
}
|
||||
|
||||
public BuilderExperience buildRemove()
|
||||
{
|
||||
return new BuilderExperience(EnumMode.ADD, -this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
|
||||
}
|
||||
|
||||
public BuilderExperience buildReset()
|
||||
{
|
||||
return new BuilderExperience(EnumMode.SET, 0, this.getPlayer(), EnumUnit.LEVELS);
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
SET,
|
||||
QUERY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumUnit
|
||||
{
|
||||
LEVELS,
|
||||
POINTS;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class BuilderFill extends BuilderDoubleBlockPos
|
||||
{
|
||||
public BuilderFill()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderFill(BlockResourceLocation block1, EnumBlockFilter filter, BlockResourceLocation block2)
|
||||
{
|
||||
this(BlockHelper.getPos1(), BlockHelper.getPos2(), block1, filter, block2);
|
||||
}
|
||||
|
||||
public BuilderFill(BlockPos pos1, BlockPos pos2, BlockResourceLocation block1, EnumBlockFilter handling, BlockResourceLocation block2)
|
||||
{
|
||||
this.setPosition1(pos1);
|
||||
this.setPosition2(pos2);
|
||||
this.setBlock1(block1);
|
||||
this.setBlockHandling(handling);
|
||||
this.setBlock2(block2);
|
||||
}
|
||||
|
||||
public BuilderFill(CoordinateInt x1, CoordinateInt y1, CoordinateInt z1, CoordinateInt x2, CoordinateInt y2, CoordinateInt z2, BlockResourceLocation block1)
|
||||
{
|
||||
this.setX1(x1);
|
||||
this.setY1(y1);
|
||||
this.setZ1(z1);
|
||||
this.setX2(x2);
|
||||
this.setY2(y2);
|
||||
this.setZ2(z2);
|
||||
this.setBlock1(block1);
|
||||
}
|
||||
|
||||
public void setBlock1(String block)
|
||||
{
|
||||
this.setBlock1(BlockResourceLocation.valueOf(block));
|
||||
}
|
||||
|
||||
public void setBlock1(BlockResourceLocation resource)
|
||||
{
|
||||
this.setNode(6, resource);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockResourceLocation getBlock1()
|
||||
{
|
||||
return this.getNodeAsBlockResourceLocation(6);
|
||||
}
|
||||
|
||||
public void setBlockHandling(EnumBlockFilter filter)
|
||||
{
|
||||
this.setNode(7, filter != null ? filter.toString() : null);
|
||||
}
|
||||
|
||||
public void setBlock2(String block)
|
||||
{
|
||||
this.setBlock2(BlockResourceLocation.valueOf(block));
|
||||
}
|
||||
|
||||
public void setBlock2(BlockResourceLocation resource)
|
||||
{
|
||||
this.setNode(8, resource);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockResourceLocation getBlock2()
|
||||
{
|
||||
return this.getNodeAsBlockResourceLocation(8);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumBlockFilter getBlockFilter()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(7), EnumBlockFilter.class);
|
||||
}
|
||||
|
||||
public BuilderFill build()
|
||||
{
|
||||
return new BuilderFill(this.getBlock1(), null, null);
|
||||
}
|
||||
|
||||
public BuilderFill buildReplace()
|
||||
{
|
||||
return new BuilderFill(this.getBlock2(), EnumBlockFilter.REPLACE, this.getBlock1());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "fill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("x1", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y1", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z1", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("x2", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y2", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z2", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("block", ArgumentType.BLOCK_RESOURCE_LOCATION);
|
||||
syntax.addOptional("filter", ArgumentType.STRING);
|
||||
syntax.addOptional("block", ArgumentType.BLOCK_RESOURCE_LOCATION, "block");
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumBlockFilter
|
||||
{
|
||||
REPLACE,
|
||||
DESTROY,
|
||||
KEEP,
|
||||
HOLLOW,
|
||||
OUTLINE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderGamemode extends CommandBuilder
|
||||
{
|
||||
public BuilderGamemode()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderGamemode(EnumGamemode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderGamemode(EnumGamemode mode, String player)
|
||||
{
|
||||
this(mode);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setMode(EnumGamemode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "gamemode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("mode", ArgumentType.STRING);
|
||||
syntax.addOptional("player", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumGamemode
|
||||
{
|
||||
SURVIVAL,
|
||||
CREATIVE,
|
||||
ADVENTURE,
|
||||
SPECTATOR;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderGamerule extends CommandBuilder
|
||||
{
|
||||
public BuilderGamerule()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderGamerule(String rule, String value)
|
||||
{
|
||||
this.setRule(rule);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setRule(String rule)
|
||||
{
|
||||
this.setNode(0, rule);
|
||||
}
|
||||
|
||||
public String getRule()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public BuilderGamerule build(String value)
|
||||
{
|
||||
return new BuilderGamerule(this.getRule(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "gamerule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addOptional("rule", ArgumentType.STRING);
|
||||
syntax.addOptional("true|false|value", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandString;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
|
||||
public class BuilderGeneric implements ICommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
private final String[] arguments;
|
||||
|
||||
public BuilderGeneric(String command, String... arguments)
|
||||
{
|
||||
this.command = command;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return new CommandString(this.command, this.arguments).toString();
|
||||
}
|
||||
|
||||
public String toActualCommand()
|
||||
{
|
||||
return this.toCommand();
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.ItemResourceLocation;
|
||||
import exopandora.worldhandler.util.ResourceHelper;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class BuilderGive extends CommandBuilderNBT
|
||||
{
|
||||
private final ItemResourceLocation itemResourceLocation = new ItemResourceLocation();
|
||||
|
||||
public BuilderGive()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public BuilderGive(String player, ResourceLocation item)
|
||||
{
|
||||
this.setPlayer(player);
|
||||
this.setItem(item);
|
||||
this.setCount(1);
|
||||
}
|
||||
|
||||
public void setPlayer(String username)
|
||||
{
|
||||
this.setNode(0, username);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setItem(String item)
|
||||
{
|
||||
this.setItem(ResourceHelper.assertRegistered(ResourceHelper.stringToResourceLocation(item), ForgeRegistries.ITEMS));
|
||||
}
|
||||
|
||||
public void setItem(ResourceLocation item)
|
||||
{
|
||||
this.itemResourceLocation.setResourceLocation(item);
|
||||
this.setNode(1, this.itemResourceLocation);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemResourceLocation getItem()
|
||||
{
|
||||
return this.getNodeAsItemResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setCount(int count)
|
||||
{
|
||||
this.setNode(2, count);
|
||||
}
|
||||
|
||||
public int getCount()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(CompoundTag nbt)
|
||||
{
|
||||
this.itemResourceLocation.setNBT(nbt);
|
||||
this.setNode(1, this.itemResourceLocation);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CompoundTag getNBT()
|
||||
{
|
||||
ItemResourceLocation item = this.getItem();
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
return item.getNBT();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("item", ArgumentType.ITEM_RESOURCE_LOCATION);
|
||||
syntax.addRequired("count", ArgumentType.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
|
||||
public class BuilderMultiCommand implements ICommandBuilder
|
||||
{
|
||||
private final ICommandBuilder[] builders;
|
||||
|
||||
public BuilderMultiCommand(ICommandBuilder... builders)
|
||||
{
|
||||
this.builders = builders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return String.join(" | ", Arrays.stream(this.builders).map(ICommandBuilder::toCommand).toArray(String[]::new));
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
|
||||
public class BuilderNoteEditor extends BuilderSetBlock
|
||||
{
|
||||
public BuilderNoteEditor()
|
||||
{
|
||||
this.setBlock(Blocks.NOTE_BLOCK.getRegistryName());
|
||||
this.setMode(EnumMode.REPLACE);
|
||||
}
|
||||
|
||||
public BuilderNoteEditor(int note)
|
||||
{
|
||||
this();
|
||||
this.setNote(note);
|
||||
}
|
||||
|
||||
public BuilderNoteEditor(int note, BlockPos pos)
|
||||
{
|
||||
this(note);
|
||||
this.setPosition(pos);
|
||||
this.setState(BlockStateProperties.NOTEBLOCK_INSTRUMENT, NoteBlockInstrument.byState(Minecraft.getInstance().level.getBlockState(pos.below())));
|
||||
}
|
||||
|
||||
public void setNote(int note)
|
||||
{
|
||||
this.setState(BlockStateProperties.NOTE, note);
|
||||
}
|
||||
|
||||
public BuilderNoteEditor build(int note)
|
||||
{
|
||||
return new BuilderNoteEditor(note, this.getBlockPos());
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderPlayer extends CommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
|
||||
public BuilderPlayer(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderPlayerReason extends CommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
|
||||
public BuilderPlayerReason(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setReason(String reason)
|
||||
{
|
||||
this.setNode(1, reason);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getReason()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addOptional("reason", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.component.impl.EffectNBT;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class BuilderPotionEffect extends CommandBuilder
|
||||
{
|
||||
private int seconds;
|
||||
private int minutes;
|
||||
private int hours;
|
||||
|
||||
public BuilderPotionEffect()
|
||||
{
|
||||
this(null, null, null);
|
||||
}
|
||||
|
||||
public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect)
|
||||
{
|
||||
this(mode, player, effect, 0, (byte) 0, false);
|
||||
}
|
||||
|
||||
public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
|
||||
{
|
||||
this.setMode(mode);
|
||||
this.setPlayer(player);
|
||||
this.setMobEffect(effect);
|
||||
this.setDuration(duration);
|
||||
this.setAmplifier(amplifier);
|
||||
this.setHideParticles(hideParticles);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
if(mode != null)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMobEffect(MobEffect effect)
|
||||
{
|
||||
this.setMobEffect(effect.getRegistryName());
|
||||
}
|
||||
|
||||
public void setMobEffect(ResourceLocation effect)
|
||||
{
|
||||
this.setNode(2, effect);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MobEffect getMobEffectAsPotion()
|
||||
{
|
||||
ResourceLocation location = this.getNodeAsResourceLocation(2);
|
||||
|
||||
if(location != null)
|
||||
{
|
||||
return ForgeRegistries.MOB_EFFECTS.getValue(location);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getMobEffect()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(2);
|
||||
}
|
||||
|
||||
public void setDuration(int duration)
|
||||
{
|
||||
this.setNode(3, Math.min(duration, 1000000));
|
||||
}
|
||||
|
||||
public int getDuration()
|
||||
{
|
||||
return this.getNodeAsInt(3);
|
||||
}
|
||||
|
||||
public void setAmplifier(byte amplifier)
|
||||
{
|
||||
this.setNode(4, (byte) (amplifier - 1));
|
||||
}
|
||||
|
||||
public int getAmplifier()
|
||||
{
|
||||
return this.getNodeAsByte(4);
|
||||
}
|
||||
|
||||
public void setHideParticles(boolean hideParticles)
|
||||
{
|
||||
this.setNode(5, hideParticles);
|
||||
}
|
||||
|
||||
public boolean getHideParticles()
|
||||
{
|
||||
return this.getNodeAsBoolean(5);
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return this.seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
this.setDuration(EffectNBT.toSeconds(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return this.minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
this.setDuration(EffectNBT.toSeconds(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
this.setDuration(EffectNBT.toSeconds(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public BuilderGeneric buildGive()
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), EnumMode.GIVE.toString(), this.getPlayer(), this.getMobEffect().toString(), String.valueOf(this.getDuration()), String.valueOf(this.getAmplifier()), String.valueOf(this.getHideParticles()));
|
||||
}
|
||||
|
||||
public BuilderGeneric buildRemove()
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer(), this.getMobEffect().toString());
|
||||
}
|
||||
|
||||
public BuilderGeneric buildClear()
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("give|clear", ArgumentType.STRING);
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("effect", ArgumentType.RESOURCE_LOCATION);
|
||||
syntax.addOptional("seconds", ArgumentType.INT, 0);
|
||||
syntax.addOptional("amplifier", ArgumentType.BYTE, (byte) -1);
|
||||
syntax.addOptional("hideParticles", ArgumentType.BOOLEAN, false);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
GIVE,
|
||||
CLEAR;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentPotionItem;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class BuilderPotionItem extends BuilderGive
|
||||
{
|
||||
private final ComponentPotionItem potion;
|
||||
|
||||
public BuilderPotionItem()
|
||||
{
|
||||
this(null, null, new ComponentPotionItem());
|
||||
}
|
||||
|
||||
public BuilderPotionItem(ResourceLocation item, String player, ComponentPotionItem potion)
|
||||
{
|
||||
super(player, item);
|
||||
this.potion = this.registerNBTComponent(potion);
|
||||
}
|
||||
|
||||
public void setAmplifier(MobEffect potion, byte amplifier)
|
||||
{
|
||||
this.potion.setAmplifier(potion, amplifier);
|
||||
}
|
||||
|
||||
public void setSeconds(MobEffect potion, int seconds)
|
||||
{
|
||||
this.potion.setSeconds(potion, seconds);
|
||||
}
|
||||
|
||||
public void setMinutes(MobEffect potion, int minutes)
|
||||
{
|
||||
this.potion.setMinutes(potion, minutes);
|
||||
}
|
||||
|
||||
public void setHours(MobEffect potion, int hours)
|
||||
{
|
||||
this.potion.setHours(potion, hours);
|
||||
}
|
||||
|
||||
public void setShowParticles(MobEffect potion, boolean showParticles)
|
||||
{
|
||||
this.potion.setShowParticles(potion, showParticles);
|
||||
}
|
||||
|
||||
public void setAmbient(MobEffect potion, boolean ambient)
|
||||
{
|
||||
this.potion.setAmbient(potion, ambient);
|
||||
}
|
||||
|
||||
public byte getAmplifier(MobEffect potion)
|
||||
{
|
||||
return this.potion.getAmplifier(potion);
|
||||
}
|
||||
|
||||
public int getSeconds(MobEffect potion)
|
||||
{
|
||||
return this.potion.getSeconds(potion);
|
||||
}
|
||||
|
||||
public int getMinutes(MobEffect potion)
|
||||
{
|
||||
return this.potion.getMinutes(potion);
|
||||
}
|
||||
|
||||
public int getHours(MobEffect potion)
|
||||
{
|
||||
return this.potion.getHours(potion);
|
||||
}
|
||||
|
||||
public boolean getShowParticles(MobEffect potion)
|
||||
{
|
||||
return this.potion.getShowParticles(potion);
|
||||
}
|
||||
|
||||
public boolean getAmbient(MobEffect potion)
|
||||
{
|
||||
return this.potion.getAmbient(potion);
|
||||
}
|
||||
|
||||
public Set<MobEffect> getMobEffects()
|
||||
{
|
||||
return this.potion.getMobEffects();
|
||||
}
|
||||
|
||||
public BuilderPotionItem build(Item item)
|
||||
{
|
||||
return new BuilderPotionItem(item.getRegistryName(), this.getPlayer(), this.potion);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
|
||||
public class BuilderRecipe extends CommandBuilder
|
||||
{
|
||||
public BuilderRecipe()
|
||||
{
|
||||
this(null, null, null);
|
||||
}
|
||||
|
||||
public BuilderRecipe(EnumMode mode, String player, ResourceLocation recipe)
|
||||
{
|
||||
this.setMode(mode);
|
||||
this.setPlayer(player);
|
||||
this.setRecipe(recipe);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode != null ? mode.toString() : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setRecipe(Recipe<?> recipe)
|
||||
{
|
||||
this.setRecipe(recipe.getId());
|
||||
}
|
||||
|
||||
public void setRecipe(ResourceLocation recipe)
|
||||
{
|
||||
this.setNode(2, recipe);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getRecipe()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(2);
|
||||
}
|
||||
|
||||
public BuilderRecipe build(EnumMode mode)
|
||||
{
|
||||
return new BuilderRecipe(mode, this.getPlayer(), this.getRecipe());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "recipe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("give|take", ArgumentType.STRING);
|
||||
syntax.addOptional("player", ArgumentType.STRING);
|
||||
syntax.addOptional("recipe", ArgumentType.RESOURCE_LOCATION);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
GIVE,
|
||||
TAKE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
|
||||
public abstract class BuilderScoreboard extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "scoreboard";
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.GreedyString;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
|
||||
public class BuilderScoreboardObjectives extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardObjectives()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "objectives");
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
String objective = this.getObjective();
|
||||
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode.toString());
|
||||
|
||||
if(objective != null)
|
||||
{
|
||||
this.setObjective(objective);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setObjective(String name)
|
||||
{
|
||||
String objective = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case ADD:
|
||||
this.setNode(4, new GreedyString(name));
|
||||
case REMOVE:
|
||||
this.setNode(2, objective);
|
||||
break;
|
||||
case SETDISPLAY:
|
||||
this.setNode(3, objective);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCriteria(String criteria)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals(EnumMode.ADD))
|
||||
{
|
||||
this.setMode(EnumMode.ADD);
|
||||
}
|
||||
|
||||
this.setNode(3, criteria);
|
||||
}
|
||||
|
||||
public void setSlot(String slot)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals(EnumMode.SETDISPLAY))
|
||||
{
|
||||
this.setMode(EnumMode.SETDISPLAY);
|
||||
}
|
||||
|
||||
this.setNode(2, slot);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSlot()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals(EnumMode.SETDISPLAY))
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getObjective()
|
||||
{
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case ADD: case REMOVE:
|
||||
return this.getNodeAsString(2);
|
||||
case SETDISPLAY:
|
||||
return this.getNodeAsString(3);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private CommandSyntax getSyntax(EnumMode mode)
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case ADD:
|
||||
syntax.addRequired("objectives", ArgumentType.STRING);
|
||||
syntax.addRequired("add", ArgumentType.STRING);
|
||||
syntax.addRequired("name", ArgumentType.STRING);
|
||||
syntax.addRequired("criteria_type", ArgumentType.STRING);
|
||||
syntax.addOptional("display_name...", ArgumentType.GREEDY_STRING);
|
||||
return syntax;
|
||||
case REMOVE:
|
||||
syntax.addRequired("objectives", ArgumentType.STRING);
|
||||
syntax.addRequired("remove", ArgumentType.STRING);
|
||||
syntax.addRequired("name", ArgumentType.STRING);
|
||||
return syntax;
|
||||
case SETDISPLAY:
|
||||
syntax.addRequired("objectives", ArgumentType.STRING);
|
||||
syntax.addRequired("setdisplay", ArgumentType.STRING);
|
||||
syntax.addRequired("slot", ArgumentType.STRING);
|
||||
syntax.addOptional("objective", ArgumentType.STRING);
|
||||
return syntax;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("objectives", ArgumentType.STRING);
|
||||
syntax.addRequired("list|add|remove|setdisplay", ArgumentType.STRING);
|
||||
syntax.addOptional("...", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
SETDISPLAY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
|
||||
public class BuilderScoreboardPlayers extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardPlayers()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "players");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
String objective = this.getObjective();
|
||||
String player = this.getPlayer();
|
||||
int points = this.getPoints();
|
||||
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode);
|
||||
this.setNode(2, player);
|
||||
this.setObjective(objective);
|
||||
|
||||
if(!mode.equals("enable"))
|
||||
{
|
||||
this.setPoints(points);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(2, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
public void setObjective(String name)
|
||||
{
|
||||
if(this.getMode() != null)
|
||||
{
|
||||
this.setNode(3, name != null ? name.replaceAll(" ", "_") : null);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getObjective()
|
||||
{
|
||||
if(this.getMode() != null)
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPoints(int points)
|
||||
{
|
||||
this.setNode(4, points);
|
||||
}
|
||||
|
||||
public int getPoints()
|
||||
{
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
if(mode != null && !EnumMode.ENABLE.equals(mode))
|
||||
{
|
||||
return this.getNodeAsInt(4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private CommandSyntax getSyntax(String mode)
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
if(mode.equals("enable"))
|
||||
{
|
||||
syntax.addRequired("players", ArgumentType.STRING);
|
||||
syntax.addRequired("enable", ArgumentType.STRING);
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("objective", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
syntax.addRequired("players", ArgumentType.STRING);
|
||||
syntax.addRequired("add|set|remove", ArgumentType.STRING, "add|set|remove");
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("objective", ArgumentType.STRING);
|
||||
syntax.addRequired("score", ArgumentType.INT, 0);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public BuilderScoreboardPlayers buildPoints(EnumMode mode)
|
||||
{
|
||||
return this.buildPoints(mode, this.getPoints());
|
||||
}
|
||||
|
||||
public BuilderScoreboardPlayers buildPoints(EnumMode mode, int points)
|
||||
{
|
||||
BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
|
||||
|
||||
builder.setMode(mode.toString());
|
||||
builder.setPlayer(this.getPlayer());
|
||||
builder.setObjective(this.getObjective());
|
||||
builder.setPoints(points);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public BuilderScoreboardPlayers buildEnable()
|
||||
{
|
||||
BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
|
||||
|
||||
builder.setMode(EnumMode.ENABLE.toString());
|
||||
builder.setPlayer(this.getPlayer());
|
||||
builder.setObjective(this.getObjective());
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("players", ArgumentType.STRING);
|
||||
syntax.addRequired("add|enable|get|list|operation|remove|reset|set", ArgumentType.STRING);
|
||||
syntax.addOptional("...", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
ENABLE,
|
||||
SET;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
||||
public class BuilderSetBlock extends BuilderBlockPos
|
||||
{
|
||||
private final BlockResourceLocation blockResourceLocation = new BlockResourceLocation();
|
||||
|
||||
public BuilderSetBlock()
|
||||
{
|
||||
super(0);
|
||||
}
|
||||
|
||||
public BuilderSetBlock(BlockPos pos, ResourceLocation block, EnumMode mode)
|
||||
{
|
||||
this();
|
||||
this.setPosition(pos);
|
||||
this.setBlock(block);
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> BuilderSetBlock(CoordinateInt x, CoordinateInt y, CoordinateInt z, ResourceLocation block, EnumMode mode)
|
||||
{
|
||||
this();
|
||||
this.setX(x);
|
||||
this.setY(y);
|
||||
this.setZ(z);
|
||||
this.setBlock(block);
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> void setState(Property<T> property, T value)
|
||||
{
|
||||
this.blockResourceLocation.setProperty(property, value);
|
||||
this.setBlock(this.blockResourceLocation);
|
||||
}
|
||||
|
||||
public void setBlock(ResourceLocation block)
|
||||
{
|
||||
this.blockResourceLocation.setResourceLocation(block);
|
||||
this.setBlock(this.blockResourceLocation);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(4, mode.toString());
|
||||
}
|
||||
|
||||
public void setBlockNBT(CompoundTag nbt)
|
||||
{
|
||||
this.blockResourceLocation.setNBT(nbt);
|
||||
this.setBlock(this.blockResourceLocation);
|
||||
}
|
||||
|
||||
protected void setBlock(BlockResourceLocation block)
|
||||
{
|
||||
this.setNode(3, this.blockResourceLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(CompoundTag nbt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "setblock";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("x", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("block", ArgumentType.BLOCK_RESOURCE_LOCATION);
|
||||
syntax.addOptional("mode", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
KEEP,
|
||||
REPLACE,
|
||||
DESTROY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import exopandora.worldhandler.util.MutableTextComponent;
|
||||
import exopandora.worldhandler.util.SignText;
|
||||
|
||||
public class BuilderSignEditor extends BuilderData
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
private final ComponentTag<SignText>[] sign = new ComponentTag[4];
|
||||
|
||||
public BuilderSignEditor()
|
||||
{
|
||||
this.setMode(EnumMode.MERGE);
|
||||
this.setTarget(EnumTarget.BLOCK);
|
||||
|
||||
for(int x = 0; x < 4; x++)
|
||||
{
|
||||
this.sign[x] = this.registerNBTComponent(new ComponentTag<SignText>("Text" + (x + 1), new SignText(), SignText::serialize));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSpecial()
|
||||
{
|
||||
for(int x = 0; x < this.sign.length; x++)
|
||||
{
|
||||
if(this.getColoredString(x).isSpecial())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MutableTextComponent getColoredString(int line)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
return this.sign[line].getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCommand(int line)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
return this.sign[line].getValue().getCommand();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public void setCommand(int line, String command)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
this.sign[line].getValue().setCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkBounds(int line)
|
||||
{
|
||||
return line >= 0 && line < this.sign.length;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
|
||||
public class BuilderSpawnpoint extends CommandBuilder
|
||||
{
|
||||
public BuilderSpawnpoint()
|
||||
{
|
||||
this.setX(new CoordinateInt(EnumType.GLOBAL));
|
||||
this.setY(new CoordinateInt(EnumType.GLOBAL));
|
||||
this.setZ(new CoordinateInt(EnumType.GLOBAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "spawnpoint";
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public void setX(CoordinateInt x)
|
||||
{
|
||||
this.setNode(1, x);
|
||||
}
|
||||
|
||||
public void setY(CoordinateInt y)
|
||||
{
|
||||
this.setNode(2, y);
|
||||
}
|
||||
|
||||
public void setZ(CoordinateInt z)
|
||||
{
|
||||
this.setNode(3, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("x", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("y", ArgumentType.COORDINATE_INT);
|
||||
syntax.addRequired("z", ArgumentType.COORDINATE_INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateDouble;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class BuilderSummon extends BuilderEntity
|
||||
{
|
||||
public BuilderSummon()
|
||||
{
|
||||
this.setX(new CoordinateDouble(0.0, EnumType.LOCAL));
|
||||
this.setY(new CoordinateDouble(0.0, EnumType.LOCAL));
|
||||
this.setZ(new CoordinateDouble(2.0, EnumType.LOCAL));
|
||||
}
|
||||
|
||||
public void setEntity(ResourceLocation entity)
|
||||
{
|
||||
this.setNode(0, entity);
|
||||
}
|
||||
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(0);
|
||||
}
|
||||
|
||||
public void setX(CoordinateDouble x)
|
||||
{
|
||||
this.setNode(1, x);
|
||||
}
|
||||
|
||||
public CoordinateDouble getX()
|
||||
{
|
||||
return this.getNodeAsCoordinateDouble(1);
|
||||
}
|
||||
|
||||
public void setY(CoordinateDouble y)
|
||||
{
|
||||
this.setNode(2, y);
|
||||
}
|
||||
|
||||
public CoordinateDouble getY()
|
||||
{
|
||||
return this.getNodeAsCoordinateDouble(2);
|
||||
}
|
||||
|
||||
public void setZ(CoordinateDouble z)
|
||||
{
|
||||
this.setNode(3, z);
|
||||
}
|
||||
|
||||
public CoordinateDouble getZ()
|
||||
{
|
||||
return this.getNodeAsCoordinateDouble(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(CompoundTag nbt)
|
||||
{
|
||||
this.setNode(4, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "summon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("entity_name", ArgumentType.RESOURCE_LOCATION);
|
||||
syntax.addOptional("x", ArgumentType.COORDINATE_DOUBLE);
|
||||
syntax.addOptional("y", ArgumentType.COORDINATE_DOUBLE);
|
||||
syntax.addOptional("z", ArgumentType.COORDINATE_DOUBLE);
|
||||
syntax.addOptional("nbt", ArgumentType.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderTag extends CommandBuilder
|
||||
{
|
||||
public BuilderTag()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderTag(String player, EnumMode mode, String name)
|
||||
{
|
||||
this.setPlayer(player);
|
||||
this.setMode(mode);
|
||||
this.setName(name);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
if(mode != null)
|
||||
{
|
||||
this.setNode(1, mode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.setNode(2, name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName()
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "tag";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("player", ArgumentType.STRING);
|
||||
syntax.addRequired("add|list|remove", ArgumentType.STRING);
|
||||
syntax.addRequired("name", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public BuilderTag build(EnumMode mode)
|
||||
{
|
||||
return new BuilderTag(this.getPlayer(), mode, this.getName());
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
LIST,
|
||||
REMOVE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.GreedyString;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
|
||||
public class BuilderTeams extends CommandBuilder
|
||||
{
|
||||
public void setTeam(String name)
|
||||
{
|
||||
String team = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(EnumMode.ADD.equals(this.getMode()))
|
||||
{
|
||||
this.setNode(2, new GreedyString(name));
|
||||
}
|
||||
|
||||
this.setNode(1, team);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTeam()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
String team = this.getTeam();
|
||||
String player = this.getPlayer();
|
||||
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(0, mode.toString());
|
||||
|
||||
if(team != null)
|
||||
{
|
||||
this.setTeam(team);
|
||||
}
|
||||
|
||||
if(player != null && (EnumMode.JOIN.equals(mode) || EnumMode.LEAVE.equals(mode) || EnumMode.JOIN_OR_LEAVE.equals(mode)))
|
||||
{
|
||||
this.setPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
if(EnumMode.JOIN.equals(mode) || EnumMode.LEAVE.equals(mode) || EnumMode.JOIN_OR_LEAVE.equals(mode))
|
||||
{
|
||||
this.setNode(2, player);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
if(EnumMode.JOIN.equals(mode) || EnumMode.LEAVE.equals(mode) || EnumMode.JOIN_OR_LEAVE.equals(mode))
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setRule(String rule)
|
||||
{
|
||||
if(!EnumMode.MODIFY.equals(this.getMode()))
|
||||
{
|
||||
this.setMode(EnumMode.MODIFY);
|
||||
}
|
||||
|
||||
this.setNode(2, rule);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRule()
|
||||
{
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
if(mode == null || EnumMode.MODIFY.equals(mode))
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
if(!EnumMode.MODIFY.equals(this.getMode()))
|
||||
{
|
||||
this.setMode(EnumMode.MODIFY);
|
||||
}
|
||||
|
||||
this.setNode(3, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getValue()
|
||||
{
|
||||
EnumMode mode = this.getMode();
|
||||
|
||||
if(mode == null || EnumMode.MODIFY.equals(mode))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private CommandSyntax getSyntax(EnumMode mode)
|
||||
{
|
||||
if(EnumMode.ADD.equals(mode))
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("add", ArgumentType.STRING);
|
||||
syntax.addRequired("name", ArgumentType.STRING);
|
||||
syntax.addOptional("display_name...", ArgumentType.GREEDY_STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(EnumMode.REMOVE.equals(mode) || EnumMode.EMPTY.equals(mode) || EnumMode.REMOVE_OR_EMPTY.equals(mode))
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("remove|empty", ArgumentType.STRING, "remove|empty");
|
||||
syntax.addRequired("name", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(EnumMode.JOIN.equals(mode) || EnumMode.LEAVE.equals(mode) || EnumMode.JOIN_OR_LEAVE.equals(mode))
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("join|leave", ArgumentType.STRING, "join|leave");
|
||||
syntax.addRequired("player|team", ArgumentType.STRING);
|
||||
syntax.addOptional("player", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(EnumMode.MODIFY.equals(mode))
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("modify", ArgumentType.STRING);
|
||||
syntax.addRequired("team", ArgumentType.STRING);
|
||||
syntax.addRequired("friendlyfire|color|seeFriendlyInvisibles|nametagVisibility|deathMessageVisibility|collisionRule", ArgumentType.STRING);
|
||||
syntax.addRequired("value", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BuilderTeams build(EnumMode mode)
|
||||
{
|
||||
BuilderTeams builder = new BuilderTeams();
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case JOIN_OR_LEAVE:
|
||||
case JOIN:
|
||||
builder.setNode(0, mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
builder.setNode(2, this.getPlayer());
|
||||
break;
|
||||
case LEAVE:
|
||||
builder.setNode(0, mode.toString());
|
||||
builder.setNode(1, this.getPlayer());
|
||||
break;
|
||||
case REMOVE_OR_EMPTY:
|
||||
case REMOVE:
|
||||
case EMPTY:
|
||||
builder.setNode(0, mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
break;
|
||||
case ADD:
|
||||
builder.setMode(mode);
|
||||
builder.setTeam(this.getTeam());
|
||||
break;
|
||||
case MODIFY:
|
||||
builder.setMode(mode);
|
||||
builder.setTeam(this.getTeam());
|
||||
builder.setRule(this.getRule());
|
||||
builder.setValue(this.getValue());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("list|add|remove|empty|join|leave|modify", ArgumentType.STRING);
|
||||
syntax.addOptional("...", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "team";
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
JOIN,
|
||||
LEAVE,
|
||||
REMOVE,
|
||||
EMPTY,
|
||||
ADD,
|
||||
MODIFY,
|
||||
JOIN_OR_LEAVE,
|
||||
REMOVE_OR_EMPTY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(EnumMode.JOIN_OR_LEAVE.equals(this))
|
||||
{
|
||||
return "join|leave";
|
||||
}
|
||||
else if(EnumMode.REMOVE_OR_EMPTY.equals(this))
|
||||
{
|
||||
return "remove|empty";
|
||||
}
|
||||
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderTime extends CommandBuilder
|
||||
{
|
||||
public BuilderTime()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderTime(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderTime(EnumMode mode, int value)
|
||||
{
|
||||
this(mode);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "time";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("set|add|query", ArgumentType.STRING);
|
||||
syntax.addOptional("value", ArgumentType.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
SET,
|
||||
QUERY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
|
||||
public class BuilderTrigger extends CommandBuilder
|
||||
{
|
||||
public BuilderTrigger()
|
||||
{
|
||||
this.setValue(0);
|
||||
}
|
||||
|
||||
public BuilderTrigger(String objective, EnumMode mode, int value)
|
||||
{
|
||||
this.setObjective(objective);
|
||||
this.setMode(mode);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setObjective(String name)
|
||||
{
|
||||
this.setNode(0, name != null ? name.replaceAll(" ", "_") : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getObjective()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
if(mode != null)
|
||||
{
|
||||
this.setNode(1, mode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.setNode(2, value);
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "trigger";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("objective", ArgumentType.STRING);
|
||||
syntax.addRequired("add|set", ArgumentType.STRING);
|
||||
syntax.addRequired("value", ArgumentType.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public BuilderTrigger build(EnumMode mode)
|
||||
{
|
||||
return new BuilderTrigger(this.getObjective(), mode, this.getValue());
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
SET;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.CommandSyntax.Argument;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.CoordinateDouble;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.builder.types.GreedyString;
|
||||
import exopandora.worldhandler.builder.types.ItemResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class BuilderUsercontent extends CommandBuilder
|
||||
{
|
||||
private final String name;
|
||||
private final CommandSyntax syntax;
|
||||
|
||||
public BuilderUsercontent(String name, CommandSyntax syntax)
|
||||
{
|
||||
this.name = name;
|
||||
this.syntax = syntax;
|
||||
this.updateSyntax(this.syntax);
|
||||
}
|
||||
|
||||
public void set(int index, String object)
|
||||
{
|
||||
if(index < this.syntax.getArguments().size() && index >= 0)
|
||||
{
|
||||
Argument argument = this.syntax.getArguments().get(index);
|
||||
ArgumentType type = argument.getType();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case STRING:
|
||||
this.setNode(index, type.<String>parseOfDefault(object, (String) argument.getDefault()));
|
||||
break;
|
||||
case BLOCK_RESOURCE_LOCATION:
|
||||
this.setNode(index, type.<BlockResourceLocation>parseOfDefault(object, type.parse((String) argument.getDefault())));
|
||||
break;
|
||||
case BOOLEAN:
|
||||
this.setNode(index, type.<Boolean>parseOfDefault(object, (Boolean) argument.getDefault()));
|
||||
break;
|
||||
case BYTE:
|
||||
this.setNode(index, type.<Byte>parseOfDefault(object, ((Double) argument.getDefault()).byteValue()));
|
||||
break;
|
||||
case COORDINATE_DOUBLE:
|
||||
this.setNode(index, type.<CoordinateDouble>parseOfDefault(object, type.parse((String) argument.getDefault())));
|
||||
break;
|
||||
case COORDINATE_INT:
|
||||
this.setNode(index, type.<CoordinateInt>parseOfDefault(object, type.parse((String) argument.getDefault())));
|
||||
break;
|
||||
case DOUBLE:
|
||||
this.setNode(index, type.<Double>parseOfDefault(object, (Double) argument.getDefault()));
|
||||
break;
|
||||
case FLOAT:
|
||||
this.setNode(index, type.<Float>parseOfDefault(object, ((Double) argument.getDefault()).floatValue()));
|
||||
break;
|
||||
case GREEDY_STRING:
|
||||
this.setNode(index, type.<GreedyString>parseOfDefault(object, type.parse((String) argument.getDefault())));
|
||||
break;
|
||||
case INT:
|
||||
this.setNode(index, type.<Integer>parseOfDefault(object, ((Double) argument.getDefault()).intValue()));
|
||||
break;
|
||||
case ITEM_RESOURCE_LOCATION:
|
||||
this.setNode(index, type.<ItemResourceLocation>parseOfDefault(object, type.parse((String) argument.getDefault())));
|
||||
break;
|
||||
case LONG:
|
||||
this.setNode(index, type.<Long>parseOfDefault(object, ((Double) argument.getDefault()).longValue()));
|
||||
break;
|
||||
case NBT:
|
||||
this.setNode(index, type.<CompoundTag>parseOfDefault(object, type.parse((String) argument.getDefault())));
|
||||
break;
|
||||
case RESOURCE_LOCATION:
|
||||
this.setNode(index, type.<ResourceLocation>parseOfDefault(object, type.parse((String) argument.getDefault())));
|
||||
break;
|
||||
case SHORT:
|
||||
this.setNode(index, type.<Short>parseOfDefault(object, ((Double) argument.getDefault()).shortValue()));
|
||||
break;
|
||||
case TARGET_SELECTOR:
|
||||
this.setNode(index, type.<TargetSelector>parseOfDefault(object, type.<TargetSelector>parse((String) argument.getDefault())));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String get(int index)
|
||||
{
|
||||
if(index < this.syntax.getArguments().size() && index >= 0)
|
||||
{
|
||||
Argument argument = this.syntax.getArguments().get(index);
|
||||
|
||||
switch(argument.getType())
|
||||
{
|
||||
case BLOCK_RESOURCE_LOCATION:
|
||||
return this.getNodeAsBlockResourceLocation(index).toString();
|
||||
case BOOLEAN:
|
||||
return String.valueOf(this.getNodeAsBoolean(index));
|
||||
case BYTE:
|
||||
return String.valueOf(this.getNodeAsByte(index));
|
||||
case COORDINATE_DOUBLE:
|
||||
return this.getNodeAsCoordinateDouble(index).toString();
|
||||
case COORDINATE_INT:
|
||||
return this.getNodeAsCoordinateInt(index).toString();
|
||||
case DOUBLE:
|
||||
return String.valueOf(this.getNodeAsDouble(index));
|
||||
case FLOAT:
|
||||
return String.valueOf(this.getNodeAsFloat(index));
|
||||
case GREEDY_STRING:
|
||||
return this.getNodeAsGreedyString(index);
|
||||
case INT:
|
||||
return String.valueOf(this.getNodeAsInt(index));
|
||||
case ITEM_RESOURCE_LOCATION:
|
||||
return this.getNodeAsItemResourceLocation(index).toString();
|
||||
case LONG:
|
||||
return String.valueOf(this.getNodeAsLong(index));
|
||||
case NBT:
|
||||
return this.getNodeAsNBT(index).toString();
|
||||
case RESOURCE_LOCATION:
|
||||
return this.getNodeAsResourceLocation(index).toString();
|
||||
case SHORT:
|
||||
return String.valueOf(this.getNodeAsShort(index));
|
||||
case STRING:
|
||||
return this.getNodeAsString(index);
|
||||
case TARGET_SELECTOR:
|
||||
return this.getNodeAsTargetSelector(index).toString();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPlayerName(String username)
|
||||
{
|
||||
for(int x = 0; x < this.syntax.getArguments().size(); x++)
|
||||
{
|
||||
if(ArgumentType.PLAYER.equals(this.syntax.getArguments().get(x).getType()))
|
||||
{
|
||||
this.setPlayerName(x, username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
return this.syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderWH extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "wh";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("pos1|pos2|fill|replace", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderWeather extends CommandBuilder
|
||||
{
|
||||
public BuilderWeather()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderWeather(EnumWeather weather)
|
||||
{
|
||||
this.setWeather(weather);
|
||||
}
|
||||
|
||||
public BuilderWeather(EnumWeather weather, int value)
|
||||
{
|
||||
this(weather);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setWeather(EnumWeather weather)
|
||||
{
|
||||
this.setNode(0, weather.toString());
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "weather";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("clear|rain|thunde", ArgumentType.STRING);
|
||||
syntax.addOptional("duration", ArgumentType.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumWeather
|
||||
{
|
||||
CLEAR,
|
||||
RAIN,
|
||||
THUNDER;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderWhitelist extends CommandBuilder
|
||||
{
|
||||
public BuilderWhitelist()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BuilderWhitelist(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderWhitelist(EnumMode mode, String player)
|
||||
{
|
||||
this(mode);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "whitelist";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BuilderWhitelist build(EnumMode mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case ADD:
|
||||
case REMOVE:
|
||||
return new BuilderWhitelist(mode, this.getPlayer());
|
||||
case RELOAD:
|
||||
case ON:
|
||||
case OFF:
|
||||
return new BuilderWhitelist(mode);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("add|remove|reload|on|off", ArgumentType.STRING);
|
||||
syntax.addOptional("player", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
RELOAD,
|
||||
ON,
|
||||
OFF;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.CommandSyntax;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
|
||||
public class BuilderWorldHandler extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "worldhandler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandSyntax getSyntax()
|
||||
{
|
||||
CommandSyntax syntax = new CommandSyntax();
|
||||
|
||||
syntax.addRequired("help|display|version", ArgumentType.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public enum ArgumentType
|
||||
{
|
||||
SHORT(Short::valueOf),
|
||||
BYTE(Byte::valueOf),
|
||||
INT(Integer::valueOf),
|
||||
FLOAT(Float::valueOf),
|
||||
DOUBLE(Double::valueOf),
|
||||
LONG(Long::valueOf),
|
||||
BOOLEAN(Boolean::valueOf),
|
||||
STRING(String::valueOf),
|
||||
GREEDY_STRING(GreedyString::valueOf),
|
||||
RESOURCE_LOCATION(ArgumentType::parseResourceLocation),
|
||||
ITEM_RESOURCE_LOCATION(ItemResourceLocation::valueOf),
|
||||
BLOCK_RESOURCE_LOCATION(BlockResourceLocation::valueOf),
|
||||
NBT(ArgumentType::parseCompoundNBT),
|
||||
COORDINATE_INT(CoordinateInt::valueOf),
|
||||
COORDINATE_DOUBLE(CoordinateDouble::valueOf),
|
||||
TARGET_SELECTOR(TargetSelector::valueOf),
|
||||
PLAYER(String::valueOf);
|
||||
|
||||
private final Function<String, Object> parser;
|
||||
|
||||
private ArgumentType(Function<String, Object> parser)
|
||||
{
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T parse(String object)
|
||||
{
|
||||
return (T) this.parser.apply(object);
|
||||
}
|
||||
|
||||
public <T> T parseOfDefault(String object, T def)
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.<T>parse(object);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation parseResourceLocation(String value)
|
||||
{
|
||||
return value != null && !value.isEmpty() ? new ResourceLocation(value) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CompoundTag parseCompoundNBT(String value)
|
||||
{
|
||||
if(value != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return TagParser.parseTag(value);
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class BlockResourceLocation extends ItemResourceLocation
|
||||
{
|
||||
private BlockState state;
|
||||
|
||||
public BlockResourceLocation()
|
||||
{
|
||||
this(null);
|
||||
}
|
||||
|
||||
public BlockResourceLocation(ResourceLocation resource)
|
||||
{
|
||||
this(resource, null, null);
|
||||
}
|
||||
|
||||
public BlockResourceLocation(ResourceLocation resource, BlockState state, CompoundTag nbt)
|
||||
{
|
||||
super(resource, nbt);
|
||||
this.state = this.findState(state, resource);
|
||||
}
|
||||
|
||||
private BlockState findState(BlockState state, ResourceLocation resource)
|
||||
{
|
||||
boolean matchOld = this.state != null && this.state.getBlock().getRegistryName().equals(resource);
|
||||
boolean matchNew = state != null && state.getBlock().getRegistryName().equals(resource);
|
||||
|
||||
if(matchNew)
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
if(matchOld)
|
||||
{
|
||||
return this.state;
|
||||
}
|
||||
|
||||
if(resource != null && ForgeRegistries.BLOCKS.containsKey(resource))
|
||||
{
|
||||
return ForgeRegistries.BLOCKS.getValue(resource).defaultBlockState();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceLocation(ResourceLocation resource)
|
||||
{
|
||||
super.setResourceLocation(resource);
|
||||
this.state = this.findState(null, resource);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockState getState()
|
||||
{
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> void setProperty(Property<T> property, T value)
|
||||
{
|
||||
if(this.state != null && this.state.hasProperty(property))
|
||||
{
|
||||
this.state = this.state.setValue(property, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static BlockResourceLocation valueOf(String input)
|
||||
{
|
||||
if(input != null)
|
||||
{
|
||||
BlockStateParser parser = new BlockStateParser(new StringReader(input), false);
|
||||
|
||||
try
|
||||
{
|
||||
parser.parse(true);
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockState state = parser.getState();
|
||||
|
||||
if(state != null)
|
||||
{
|
||||
return new BlockResourceLocation(state.getBlock().getRegistryName(), state, parser.getNbt());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.resource != null && this.state != null)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(this.state.toString());
|
||||
String block = this.state.getBlock().toString();
|
||||
builder.replace(0, block.length(), this.resource.toString());
|
||||
|
||||
if(this.nbt != null)
|
||||
{
|
||||
builder.append(this.nbt.toString());
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class Coordinate<T extends Number> implements ICoordinate<T>
|
||||
{
|
||||
protected T value;
|
||||
protected EnumType type;
|
||||
|
||||
public Coordinate(T value)
|
||||
{
|
||||
this(value, EnumType.ABSOLUTE);
|
||||
}
|
||||
|
||||
public Coordinate(T value, EnumType type)
|
||||
{
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setValue(T value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public T getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setType(EnumType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public EnumType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.type.format(this.value, this.zero());
|
||||
}
|
||||
|
||||
public static <S extends Number, U extends Coordinate<S>> U parse(U coordiante, String input, Function<String, S> parser)
|
||||
{
|
||||
for(EnumType type : EnumType.values())
|
||||
{
|
||||
if(!type.prefix.isEmpty() && input.startsWith(type.prefix))
|
||||
{
|
||||
String numbers = input.substring(type.prefix.length());
|
||||
|
||||
coordiante.setType(type);
|
||||
coordiante.setValue(numbers.isEmpty() ? coordiante.zero() : parser.apply(numbers));
|
||||
|
||||
return coordiante;
|
||||
}
|
||||
}
|
||||
|
||||
coordiante.setType(EnumType.ABSOLUTE);
|
||||
coordiante.setValue(parser.apply(input));
|
||||
|
||||
return coordiante;
|
||||
}
|
||||
|
||||
public static enum EnumType
|
||||
{
|
||||
/**
|
||||
* Prefix: <code>None</code>
|
||||
*/
|
||||
ABSOLUTE(""),
|
||||
/**
|
||||
* Prefix: <code>"~"</code>
|
||||
*/
|
||||
GLOBAL("~"),
|
||||
/**
|
||||
* Prefix: <code>"^"</code>
|
||||
*/
|
||||
LOCAL("^");
|
||||
|
||||
private final String prefix;
|
||||
|
||||
private EnumType(String prefix)
|
||||
{
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public <T extends Number> String format(T value, T zero)
|
||||
{
|
||||
if(value == null || value.equals(zero))
|
||||
{
|
||||
if(this.prefix.isEmpty())
|
||||
{
|
||||
return zero.toString();
|
||||
}
|
||||
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
return this.prefix + value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
public class CoordinateDouble extends Coordinate<Double>
|
||||
{
|
||||
public CoordinateDouble()
|
||||
{
|
||||
super(0.0);
|
||||
}
|
||||
|
||||
public CoordinateDouble(Double value)
|
||||
{
|
||||
super(value);
|
||||
}
|
||||
|
||||
public CoordinateDouble(EnumType type)
|
||||
{
|
||||
super(0.0, type);
|
||||
}
|
||||
|
||||
public CoordinateDouble(Double value, EnumType type)
|
||||
{
|
||||
super(value, type);
|
||||
}
|
||||
|
||||
public static CoordinateDouble valueOf(String value)
|
||||
{
|
||||
return Coordinate.parse(new CoordinateDouble(), value, Double::parseDouble);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zero()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
public class CoordinateInt extends Coordinate<Integer>
|
||||
{
|
||||
public CoordinateInt()
|
||||
{
|
||||
super(0);
|
||||
}
|
||||
|
||||
public CoordinateInt(Integer value)
|
||||
{
|
||||
super(value);
|
||||
}
|
||||
|
||||
public CoordinateInt(EnumType type)
|
||||
{
|
||||
super(0, type);
|
||||
}
|
||||
|
||||
public CoordinateInt(Integer value, EnumType type)
|
||||
{
|
||||
super(value, type);
|
||||
}
|
||||
|
||||
public static CoordinateInt valueOf(String value)
|
||||
{
|
||||
return Coordinate.parse(new CoordinateInt(), value, Integer::parseInt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer zero()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GreedyString
|
||||
{
|
||||
private String string;
|
||||
|
||||
public GreedyString(String string)
|
||||
{
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String getString()
|
||||
{
|
||||
return this.string;
|
||||
}
|
||||
|
||||
public void setString(String string)
|
||||
{
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if(this.string == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.string.isEmpty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GreedyString valueOf(String string)
|
||||
{
|
||||
if(string != null && string.matches("\"(.*)\""))
|
||||
{
|
||||
return new GreedyString(string.substring(1, string.length() - 1));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "\"" + this.string + "\"";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
public interface ICoordinate<T extends Number>
|
||||
{
|
||||
T zero();
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ItemResourceLocation
|
||||
{
|
||||
protected ResourceLocation resource;
|
||||
protected CompoundTag nbt;
|
||||
|
||||
public ItemResourceLocation()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public ItemResourceLocation(ResourceLocation resource)
|
||||
{
|
||||
this(resource, null);
|
||||
}
|
||||
|
||||
public ItemResourceLocation(ResourceLocation resource, CompoundTag nbt)
|
||||
{
|
||||
this.resource = resource;
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceLocation()
|
||||
{
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public void setResourceLocation(ResourceLocation resource)
|
||||
{
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public CompoundTag getNBT()
|
||||
{
|
||||
return this.nbt;
|
||||
}
|
||||
|
||||
public void setNBT(CompoundTag nbt)
|
||||
{
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemResourceLocation valueOf(String input)
|
||||
{
|
||||
int start = input.indexOf("{");
|
||||
ResourceLocation resource = new ResourceLocation(input.substring(0, start));
|
||||
CompoundTag nbt = null;
|
||||
|
||||
if(start > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
nbt = TagParser.parseTag(input.substring(start, input.lastIndexOf("}") + 1));
|
||||
}
|
||||
catch(CommandSyntaxException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemResourceLocation(resource, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.resource != null)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(this.resource.toString());
|
||||
|
||||
if(this.nbt != null)
|
||||
{
|
||||
builder.append(this.nbt.toString());
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TargetSelector
|
||||
{
|
||||
private final Map<String, Object> values = new HashMap<String, Object>();
|
||||
private static final String REGEX = "@e\\[(.*)\\]";
|
||||
|
||||
public void set(String id, Object value)
|
||||
{
|
||||
this.values.put(id.toLowerCase(), value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(String id)
|
||||
{
|
||||
return (T) this.values.get(id);
|
||||
}
|
||||
|
||||
public Object remove(String id)
|
||||
{
|
||||
return this.values.remove(id.toLowerCase());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static TargetSelector valueOf(String input)
|
||||
{
|
||||
if(input.matches(REGEX));
|
||||
{
|
||||
TargetSelector result = new TargetSelector();
|
||||
|
||||
for(String keys : input.replaceFirst(REGEX, "$1").split(","))
|
||||
{
|
||||
String[] pair = keys.split("=");
|
||||
|
||||
if(pair.length > 1)
|
||||
{
|
||||
result.set(pair[0], pair[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TargetSelector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "@e[" + String.join(",", this.values.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue().toString()).collect(Collectors.toList())) + "]";
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,28 @@
|
||||
package exopandora.worldhandler.command;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.context.ParsedCommandNode;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone;
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill.EnumBlockFilter;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.argument.Coordinate;
|
||||
import exopandora.worldhandler.builder.argument.Coordinate.Type;
|
||||
import exopandora.worldhandler.builder.impl.CloneCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.FillCommandBuilder;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.blocks.BlockInput;
|
||||
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateArgument;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.DistExecutor.SafeRunnable;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class CommandWH
|
||||
@@ -47,34 +41,28 @@ public class CommandWH
|
||||
.then(Commands.literal("replace")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.then(Commands.argument("block", BlockStateArgument.block())
|
||||
.then(Commands.argument("replace", BlockStateArgument.block())
|
||||
.executes(context -> replace(context.getSource(), BlockStateArgument.getBlock(context, "block"), BlockStateArgument.getBlock(context, "replace"))))))
|
||||
.then(Commands.argument("filter", BlockPredicateArgument.blockPredicate())
|
||||
.executes(context -> replace(context.getSource(), BlockStateArgument.getBlock(context, "block"), getCommandNode("filter", context.getNodes()).getRange().get(context.getInput()))))))
|
||||
.then(Commands.literal("clone")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.executes(context -> clone(context.getSource(), "masked"))
|
||||
.executes(context -> clone(context.getSource(), "masked", null))
|
||||
.then(Commands.literal("filtered")
|
||||
.then(Commands.argument("filter", StringBlockPredicateArgument.blockPredicate())
|
||||
.executes(context -> clone(context.getSource(), "filter", StringBlockPredicateArgument.getBlockPredicate(context, "filter")))))
|
||||
.then(Commands.argument("filter", BlockPredicateArgument.blockPredicate())
|
||||
.executes(context -> clone(context.getSource(), "filter", getCommandNode("filter", context.getNodes()).getRange().get(context.getInput())))))
|
||||
.then(Commands.literal("masked")
|
||||
.executes(context -> clone(context.getSource(), "masked")))
|
||||
.executes(context -> clone(context.getSource(), "masked", null)))
|
||||
.then(Commands.literal("replace")
|
||||
.executes(context -> clone(context.getSource(), "replace")))));
|
||||
.executes(context -> clone(context.getSource(), "replace", null)))));
|
||||
}
|
||||
|
||||
private static int pos1(CommandSourceStack source) throws CommandSyntaxException
|
||||
{
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable()
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
private static final long serialVersionUID = 818420798194963795L;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.getPos1();
|
||||
BlockHelper.pos1().set(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.pos1();
|
||||
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
|
||||
CommandHelper.sendFeedback(source, "Set first position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
|
||||
}
|
||||
});
|
||||
|
||||
return 1;
|
||||
@@ -82,18 +70,12 @@ public class CommandWH
|
||||
|
||||
private static int pos2(CommandSourceStack source) throws CommandSyntaxException
|
||||
{
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable()
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
private static final long serialVersionUID = 5436684018502529063L;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.getPos2();
|
||||
BlockHelper.pos2().set(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.pos2();
|
||||
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
|
||||
CommandHelper.sendFeedback(source, "Set second position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
|
||||
}
|
||||
});
|
||||
|
||||
return 1;
|
||||
@@ -101,39 +83,28 @@ public class CommandWH
|
||||
|
||||
private static int fill(CommandSourceStack source, BlockInput block)
|
||||
{
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable()
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
private static final long serialVersionUID = 7622739284160142817L;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setBlock1(new BlockResourceLocation(block.getState().getBlock().getRegistryName(), block.getState(), block.tag));
|
||||
CommandHelper.sendCommand(source.getTextName(), builder);
|
||||
}
|
||||
FillCommandBuilder builder = new FillCommandBuilder();
|
||||
builder.from().set(BlockHelper.pos1());
|
||||
builder.to().set(BlockHelper.pos2());
|
||||
builder.block().set(block.getState(), block.tag);
|
||||
CommandHelper.sendCommand(source.getTextName(), builder, FillCommandBuilder.Label.FILL);
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int replace(CommandSourceStack source, BlockInput block, BlockInput replace)
|
||||
private static int replace(CommandSourceStack source, BlockInput block, String filter)
|
||||
{
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable()
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
private static final long serialVersionUID = -5007303344454187200L;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setBlockHandling(EnumBlockFilter.REPLACE);
|
||||
builder.setBlock1(new BlockResourceLocation(replace.getState().getBlock().getRegistryName(), replace.getState(), replace.tag));
|
||||
builder.setBlock2(new BlockResourceLocation(block.getState().getBlock().getRegistryName(), block.getState(), block.tag));
|
||||
CommandHelper.sendCommand(source.getTextName(), builder);
|
||||
}
|
||||
FillCommandBuilder builder = new FillCommandBuilder();
|
||||
builder.from().set(BlockHelper.pos1());
|
||||
builder.to().set(BlockHelper.pos2());
|
||||
builder.block().set(block.getState(), block.tag);
|
||||
builder.filter().deserialize(filter);
|
||||
CommandHelper.sendCommand(source.getTextName(), builder, FillCommandBuilder.Label.REPLACE);
|
||||
});
|
||||
|
||||
return 1;
|
||||
@@ -141,74 +112,44 @@ public class CommandWH
|
||||
|
||||
private static int clone(CommandSourceStack source, String mask, String filter)
|
||||
{
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable()
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
private static final long serialVersionUID = -2849956095821394079L;
|
||||
CloneCommandBuilder builder = new CloneCommandBuilder();
|
||||
builder.begin().set(BlockHelper.pos1());
|
||||
builder.end().set(BlockHelper.pos2());
|
||||
builder.destination().setX(new Coordinate.Ints(Type.RELATIVE));
|
||||
builder.destination().setY(new Coordinate.Ints(Type.RELATIVE));
|
||||
builder.destination().setZ(new Coordinate.Ints(Type.RELATIVE));
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
switch(mask)
|
||||
{
|
||||
BuilderClone builder = new BuilderClone();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setMask(EnumHelper.valueOf(mask, EnumMask.class));
|
||||
builder.setFilter(filter);
|
||||
CommandHelper.sendCommand(source.getTextName(), builder);
|
||||
case "filtered":
|
||||
builder.filter().deserialize(filter);
|
||||
CommandHelper.sendCommand(source.getTextName(), builder, CloneCommandBuilder.Label.FILTERED);
|
||||
break;
|
||||
case "masked":
|
||||
CommandHelper.sendCommand(source.getTextName(), builder, CloneCommandBuilder.Label.MASKED);
|
||||
break;
|
||||
case "replace":
|
||||
CommandHelper.sendCommand(source.getTextName(), builder, CloneCommandBuilder.Label.REPLACE);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int clone(CommandSourceStack source, String mask)
|
||||
@Nullable
|
||||
private static <T> ParsedCommandNode<T> getCommandNode(String name, List<ParsedCommandNode<T>> nodes)
|
||||
{
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable()
|
||||
for(ParsedCommandNode<T> node : nodes)
|
||||
{
|
||||
private static final long serialVersionUID = -7349335271543407747L;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
if(name.equals(node.getNode().getName()))
|
||||
{
|
||||
BuilderClone builder = new BuilderClone();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setMask(EnumHelper.valueOf(mask, EnumMask.class));
|
||||
CommandHelper.sendCommand(source.getTextName(), builder);
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static class StringBlockPredicateArgument implements ArgumentType<String>
|
||||
{
|
||||
public static StringBlockPredicateArgument blockPredicate()
|
||||
{
|
||||
return new StringBlockPredicateArgument();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(StringReader reader) throws CommandSyntaxException
|
||||
{
|
||||
BlockStateParser blockstateparser = new BlockStateParser(reader, true).parse(true);
|
||||
|
||||
if(blockstateparser.getState() != null)
|
||||
{
|
||||
return new BlockResourceLocation(blockstateparser.getState().getBlock().getRegistryName(), blockstateparser.getState(), blockstateparser.getNbt()).toString();
|
||||
}
|
||||
|
||||
return "#" + blockstateparser.getTag();
|
||||
}
|
||||
|
||||
public static String getBlockPredicate(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException
|
||||
{
|
||||
return context.getArgument(name, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder)
|
||||
{
|
||||
return BlockPredicateArgument.blockPredicate().listSuggestions(context, builder);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.DistExecutor.SafeRunnable;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
|
||||
@@ -40,17 +39,7 @@ public class CommandWorldHandler
|
||||
|
||||
private static int display(CommandSourceStack source) throws CommandSyntaxException
|
||||
{
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable()
|
||||
{
|
||||
private static final long serialVersionUID = 210782927512442500L;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Minecraft.getInstance().execute(ActionHelper::displayGui);
|
||||
}
|
||||
});
|
||||
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().execute(ActionHelper::displayGui));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package exopandora.worldhandler.config;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderSetBlock.EnumMode;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.util.BlockPlacingMode;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||
@@ -23,7 +23,7 @@ public class ConfigCategorySettings
|
||||
private final IntValue noon;
|
||||
private final IntValue sunset;
|
||||
private final IntValue midnight;
|
||||
private final ConfigValue<EnumMode> blockPlacingMode;
|
||||
private final ConfigValue<BlockPlacingMode> blockPlacingMode;
|
||||
|
||||
public ConfigCategorySettings(ForgeConfigSpec.Builder builder)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ public class ConfigCategorySettings
|
||||
this.blockPlacingMode = builder
|
||||
.translation("gui.worldhandler.config.settings.block_placing_mode")
|
||||
.comment("Block placing mode (keep, replace, destroy)")
|
||||
.defineEnum("block_placing_mode", EnumMode.KEEP, EnumMode.values());
|
||||
.defineEnum("block_placing_mode", BlockPlacingMode.KEEP, BlockPlacingMode.values());
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@@ -242,12 +242,12 @@ public class ConfigCategorySettings
|
||||
Config.set(this.midnight, ticks);
|
||||
}
|
||||
|
||||
public EnumMode getBlockPlacingMode()
|
||||
public BlockPlacingMode getBlockPlacingMode()
|
||||
{
|
||||
return this.blockPlacingMode.get();
|
||||
}
|
||||
|
||||
public void setBlockPlacingMode(EnumMode mode)
|
||||
public void setBlockPlacingMode(BlockPlacingMode mode)
|
||||
{
|
||||
Config.set(this.blockPlacingMode, mode);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.RenderUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
|
||||
@@ -18,31 +19,31 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class ClientEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void renderWorldLastEvent(RenderWorldLastEvent event)
|
||||
public static void renderLevelLastEvent(RenderLevelLastEvent event)
|
||||
{
|
||||
if(Config.getSettings().highlightBlocks() && Minecraft.getInstance().level != null && Minecraft.getInstance().getEntityRenderDispatcher().camera != null)
|
||||
{
|
||||
Vec3 projected = Minecraft.getInstance().getEntityRenderDispatcher().camera.getPosition();
|
||||
|
||||
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX());
|
||||
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY());
|
||||
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ());
|
||||
double minX = Math.min(BlockHelper.pos1().getX(), BlockHelper.pos2().getX()) - RenderUtils.EPS;
|
||||
double minY = Math.min(BlockHelper.pos1().getY(), BlockHelper.pos2().getY()) - RenderUtils.EPS;
|
||||
double minZ = Math.min(BlockHelper.pos1().getZ(), BlockHelper.pos2().getZ()) - RenderUtils.EPS;
|
||||
|
||||
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + 1;
|
||||
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + 1;
|
||||
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + 1;
|
||||
double maxX = Math.max(BlockHelper.pos1().getX(), BlockHelper.pos2().getX()) + 1 + RenderUtils.EPS;
|
||||
double maxY = Math.max(BlockHelper.pos1().getY(), BlockHelper.pos2().getY()) + 1 + RenderUtils.EPS;
|
||||
double maxZ = Math.max(BlockHelper.pos1().getZ(), BlockHelper.pos2().getZ()) + 1 + RenderUtils.EPS;
|
||||
|
||||
AABB aabb = new AABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
|
||||
if(aabb.getCenter().distanceTo(projected) < 96)
|
||||
{
|
||||
PoseStack matrix = event.getMatrixStack();
|
||||
PoseStack matrix = event.getPoseStack();
|
||||
matrix.pushPose();
|
||||
matrix.translate(-projected.x(), -projected.y(), -projected.z());
|
||||
|
||||
@@ -54,29 +55,6 @@ public class ClientEventHandler
|
||||
buffer.endBatch(RenderType.lines());
|
||||
buffer.endBatch();
|
||||
|
||||
// try
|
||||
// {
|
||||
// Field transparencyChain = WorldRenderer.class.getDeclaredField("transparencyChain");
|
||||
// transparencyChain.setAccessible(true);
|
||||
// ShaderGroup shader = (ShaderGroup) transparencyChain.get(event.getContext());
|
||||
//
|
||||
// if(shader != null)
|
||||
// {
|
||||
// Field ITEM_ENTITY_TARGET = RenderState.class.getDeclaredField("ITEM_ENTITY_TARGET");
|
||||
// ITEM_ENTITY_TARGET.setAccessible(true);
|
||||
// RenderState.TargetState target = (RenderState.TargetState) ITEM_ENTITY_TARGET.get(null);
|
||||
// target.setupRenderState();
|
||||
// event.getContext().getItemEntityTarget().framebufferClear(Minecraft.IS_RUNNING_ON_MAC);
|
||||
// event.getContext().getItemEntityTarget().copyDepthFrom(Minecraft.getInstance().getFramebuffer());
|
||||
// Minecraft.getInstance().getFramebuffer().bindFramebuffer(false);
|
||||
// target.clearRenderState();
|
||||
// }
|
||||
// }
|
||||
// catch(NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
matrix.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.ClientRegistry;
|
||||
import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fmlclient.registry.ClientRegistry;
|
||||
|
||||
public class KeyHandler
|
||||
{
|
||||
@@ -29,11 +29,11 @@ public class KeyHandler
|
||||
}
|
||||
else if(Config.getSettings().shortcutKeys() && KEY_WORLD_HANDLER_POS1.isDown())
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
BlockHelper.pos1().set(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
else if(Config.getSettings().shortcutKeys() && KEY_WORLD_HANDLER_POS2.isDown())
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
BlockHelper.pos2().set(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package exopandora.worldhandler.gui.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.gui.menu.IMenu;
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import exopandora.worldhandler.gui.widget.menu.IMenu;
|
||||
import exopandora.worldhandler.gui.widget.menu.Menu;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package exopandora.worldhandler.gui.container;
|
||||
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import exopandora.worldhandler.gui.widget.menu.Menu;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
|
||||
@@ -11,7 +11,6 @@ import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.menu.IMenu;
|
||||
import exopandora.worldhandler.gui.widget.IContainerWidget;
|
||||
import exopandora.worldhandler.gui.widget.IContainerWidget.EnumLayer;
|
||||
import exopandora.worldhandler.gui.widget.WidgetCommandSyntax;
|
||||
@@ -20,6 +19,7 @@ import exopandora.worldhandler.gui.widget.WidgetShortcuts;
|
||||
import exopandora.worldhandler.gui.widget.WidgetTabRenderer;
|
||||
import exopandora.worldhandler.gui.widget.WidgetWatch;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.menu.IMenu;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.RenderUtils;
|
||||
import exopandora.worldhandler.util.ResourceHelper;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package exopandora.worldhandler.gui.content;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -24,7 +29,7 @@ public interface IContent extends IWidget
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default ICommandBuilder getCommandBuilder()
|
||||
default CommandPreview getCommandPreview()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -33,4 +38,44 @@ public interface IContent extends IWidget
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static class CommandPreview
|
||||
{
|
||||
private final List<Entry> builders = new ArrayList<Entry>();
|
||||
|
||||
public CommandPreview()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public CommandPreview(ICommandBuilder builder, Object label)
|
||||
{
|
||||
this.add(builder, label);
|
||||
}
|
||||
|
||||
public CommandPreview add(ICommandBuilder builder, Object label)
|
||||
{
|
||||
this.builders.add(new Entry(builder, label));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.builders.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.builders.stream().map(entry -> entry.builder().toCommand(entry.label(), true)).collect(Collectors.joining(" | "));
|
||||
}
|
||||
|
||||
private record Entry(ICommandBuilder builder, Object label)
|
||||
{
|
||||
public Entry
|
||||
{
|
||||
Objects.requireNonNull(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,21 +4,19 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.AdvancementCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.AdvancementCommandBuilder.Label;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicMapped;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicMapped;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.AdvancementHelper;
|
||||
@@ -31,13 +29,16 @@ import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentAdvancements extends Content
|
||||
{
|
||||
private final BuilderAdvancement builderAdvancement = new BuilderAdvancement(EnumMode.values()[0]);
|
||||
private final List<EnumMode> modes = Arrays.stream(EnumMode.values()).filter(mode -> !mode.equals(EnumMode.EVERYTHING)).collect(Collectors.toList());
|
||||
private final AdvancementCommandBuilder builderAdvancement = new AdvancementCommandBuilder();
|
||||
private Mode mode = Mode.ONLY;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.builderAdvancement;
|
||||
CommandPreview preview = new CommandPreview()
|
||||
.add(this.builderAdvancement, this.mode.getGrant())
|
||||
.add(this.builderAdvancement, this.mode.getRevoke());
|
||||
return preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +65,7 @@ public class ContentAdvancements extends Content
|
||||
@Override
|
||||
public void onClick(Advancement item)
|
||||
{
|
||||
ContentAdvancements.this.builderAdvancement.setAdvancement(item.getId());
|
||||
ContentAdvancements.this.builderAdvancement.advancement().set(item.getId());
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@@ -90,24 +91,24 @@ public class ContentAdvancements extends Content
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonList<EnumMode>(x + 118, y, this.modes, 114, 20, container, new ILogicMapped<EnumMode>()
|
||||
container.add(new GuiButtonList<Mode>(x + 118, y, Arrays.asList(Mode.values()), 114, 20, container, new ILogicMapped<Mode>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(EnumMode item)
|
||||
public MutableComponent translate(Mode mode)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.advancements." + item.toString());
|
||||
return new TranslatableComponent("gui.worldhandler.advancements." + mode.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(EnumMode item)
|
||||
public MutableComponent toTooltip(Mode mode)
|
||||
{
|
||||
return new TextComponent(item.toString());
|
||||
return new TextComponent(mode.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumMode item)
|
||||
public void onClick(Mode mode)
|
||||
{
|
||||
ContentAdvancements.this.builderAdvancement.setMode(item);
|
||||
ContentAdvancements.this.mode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,15 +120,15 @@ public class ContentAdvancements extends Content
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.advancements.grant"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderAdvancement.build(EnumActionType.GRANT));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderAdvancement, this.mode.getGrant());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.advancements.revoke"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderAdvancement.build(EnumActionType.REVOKE));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderAdvancement, this.mode.getRevoke());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.reset").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderAdvancement.build(EnumActionType.REVOKE, EnumMode.EVERYTHING)));
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderAdvancement, AdvancementCommandBuilder.Label.REVOKE_EVERYTHING));
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -158,6 +159,39 @@ public class ContentAdvancements extends Content
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderAdvancement.setPlayer(username);
|
||||
this.builderAdvancement.targets().setTarget(username);
|
||||
}
|
||||
|
||||
private static enum Mode
|
||||
{
|
||||
ONLY(AdvancementCommandBuilder.Label.GRANT_ONLY, AdvancementCommandBuilder.Label.REVOKE_ONLY),
|
||||
UNTIL(AdvancementCommandBuilder.Label.GRANT_UNTIL, AdvancementCommandBuilder.Label.REVOKE_UNTIL),
|
||||
FROM(AdvancementCommandBuilder.Label.GRANT_FROM, AdvancementCommandBuilder.Label.REVOKE_FROM),
|
||||
THROUGH(AdvancementCommandBuilder.Label.GRANT_THROUGH, AdvancementCommandBuilder.Label.REVOKE_THROUGH);
|
||||
|
||||
private final AdvancementCommandBuilder.Label grant;
|
||||
private final AdvancementCommandBuilder.Label revoke;
|
||||
|
||||
private Mode(Label grant, Label revoke)
|
||||
{
|
||||
this.grant = grant;
|
||||
this.revoke = revoke;
|
||||
}
|
||||
|
||||
public AdvancementCommandBuilder.Label getGrant()
|
||||
{
|
||||
return this.grant;
|
||||
}
|
||||
|
||||
public AdvancementCommandBuilder.Label getRevoke()
|
||||
{
|
||||
return this.revoke;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import java.util.stream.Collectors;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderButcher;
|
||||
import exopandora.worldhandler.builder.argument.TargetArgument.SelectorTypes;
|
||||
import exopandora.worldhandler.builder.impl.KillCommandBuilder;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
@@ -33,12 +33,13 @@ public class ContentButcher extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip radiusField;
|
||||
private String radius;
|
||||
private final BuilderButcher builderButcher = new BuilderButcher();
|
||||
private final KillCommandBuilder builderKill = new KillCommandBuilder();
|
||||
private final CommandPreview preview = new CommandPreview(this.builderKill, KillCommandBuilder.Label.KILL_TARGETS);
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.builderButcher;
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,11 +74,11 @@ public class ContentButcher extends Content
|
||||
|
||||
if(!this.radius.isEmpty())
|
||||
{
|
||||
this.builderButcher.setDistance(Integer.valueOf(this.radius));
|
||||
this.builderKill.targets().setDistance(Double.valueOf(this.radius));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.builderButcher.setDistance(0);
|
||||
this.builderKill.targets().setDistance(0D);
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
@@ -102,18 +103,19 @@ public class ContentButcher extends Content
|
||||
|
||||
container.add(slaughter = new GuiButtonBase(x + 58, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.slaughter"), () ->
|
||||
{
|
||||
ContentButcher.slaughter(container.getPlayer(), Config.getButcher().getEntities().stream().map(ForgeRegistries.ENTITIES::getValue).filter(Predicates.notNull()).collect(Collectors.toList()), Integer.parseInt(this.radius));
|
||||
Collection<EntityType<?>> entities = Config.getButcher().getEntities().stream().map(ForgeRegistries.ENTITIES::getValue).filter(Predicates.notNull()).collect(Collectors.toList());
|
||||
ContentButcher.slaughter(container.getPlayer(), entities, Integer.parseInt(this.radius));
|
||||
}));
|
||||
slaughter.active = enabled && !Config.getButcher().getEntities().isEmpty();
|
||||
|
||||
container.add(slaughter = new GuiButtonBase(x + 58, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.butcher.presets"), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.BUTCHER_PRESETS.withBuilder(this.builderButcher).withRadius(Integer.parseInt(this.radius)));
|
||||
ActionHelper.open(Contents.BUTCHER_PRESETS.withBuilder(this.builderKill, KillCommandBuilder.Label.KILL_TARGETS).withRadius(Double.parseDouble(this.radius)));
|
||||
}));
|
||||
slaughter.active = enabled;
|
||||
}
|
||||
|
||||
public static void slaughter(String username, Collection<EntityType<?>> entities, int radius)
|
||||
public static void slaughter(String username, Collection<EntityType<?>> entities, double radius)
|
||||
{
|
||||
Player player = Minecraft.getInstance().player;
|
||||
Level level = Minecraft.getInstance().level;
|
||||
@@ -129,7 +131,11 @@ public class ContentButcher extends Content
|
||||
|
||||
if(!targets.isEmpty())
|
||||
{
|
||||
CommandHelper.sendCommand(username, new BuilderButcher(entity.getRegistryName(), radius));
|
||||
KillCommandBuilder kill = new KillCommandBuilder();
|
||||
kill.targets().setSelectorType(SelectorTypes.ALL_ENTITIES);
|
||||
kill.targets().setType(entity.getRegistryName());
|
||||
kill.targets().setDistanceMax(radius);
|
||||
CommandHelper.sendCommand(username, kill, KillCommandBuilder.Label.KILL_TARGETS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,25 +13,25 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ContentButcherPresets extends ContentChild
|
||||
{
|
||||
private ICommandBuilder builder;
|
||||
private int radius;
|
||||
private CommandPreview preview;
|
||||
private double radius;
|
||||
|
||||
public ContentButcherPresets withBuilder(ICommandBuilder builder)
|
||||
public ContentButcherPresets withBuilder(ICommandBuilder builder, Object label)
|
||||
{
|
||||
this.builder = builder;
|
||||
this.preview = new CommandPreview(builder, label);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContentButcherPresets withRadius(int radius)
|
||||
public ContentButcherPresets withRadius(double radius)
|
||||
{
|
||||
this.radius = radius;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.builder;
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,10 +5,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
@@ -10,17 +10,13 @@ import javax.annotation.Nullable;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.component.impl.EntityNBT;
|
||||
import exopandora.worldhandler.builder.impl.BuilderButcher;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSetBlock;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSetBlock.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSummon;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateDouble;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.builder.argument.Coordinate;
|
||||
import exopandora.worldhandler.builder.argument.TargetArgument.SelectorTypes;
|
||||
import exopandora.worldhandler.builder.argument.tag.EntityTag;
|
||||
import exopandora.worldhandler.builder.impl.FillCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.KillCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.SetBlockCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.SummonCommandBuilder;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
@@ -48,43 +44,63 @@ public class ContentCommandStack extends ContentChild
|
||||
private int scroll;
|
||||
private GuiButtonBase buttonCopy;
|
||||
|
||||
private final BuilderSummon builderCommandStack = new BuilderSummon();
|
||||
private final SummonCommandBuilder builderCommandStack = new SummonCommandBuilder();
|
||||
private final CommandPreview preview = new CommandPreview(this.builderCommandStack, SummonCommandBuilder.Label.SUMMON_POS_NBT);
|
||||
private final EntityTag activatorRail = new EntityTag();
|
||||
|
||||
public ContentCommandStack()
|
||||
{
|
||||
this.builderCommandStack.setEntity(EntityType.FALLING_BLOCK.getRegistryName());
|
||||
this.builderCommandStack.setX(new CoordinateDouble(0.0D, EnumType.GLOBAL));
|
||||
this.builderCommandStack.setY(new CoordinateDouble(0.5D, EnumType.GLOBAL));
|
||||
this.builderCommandStack.setZ(new CoordinateDouble(0.0D, EnumType.GLOBAL));
|
||||
this.builderCommandStack.setMotion(0.0D, 0.315D, 0.0D);
|
||||
this.builderCommandStack.setTime(1);
|
||||
this.builderCommandStack.setBlockState(Blocks.ACTIVATOR_RAIL.defaultBlockState());
|
||||
this.builderCommandStack.entity().set(EntityType.FALLING_BLOCK);
|
||||
this.builderCommandStack.pos().setX(new Coordinate.Doubles(Coordinate.Type.RELATIVE));
|
||||
this.builderCommandStack.pos().setY(new Coordinate.Doubles(0.5, Coordinate.Type.RELATIVE));
|
||||
this.builderCommandStack.pos().setZ(new Coordinate.Doubles(Coordinate.Type.RELATIVE));
|
||||
|
||||
EntityNBT redstoneBlock = new EntityNBT(EntityType.FALLING_BLOCK.getRegistryName());
|
||||
this.activatorRail.setMotion(0.0D, 0.315D, 0.0D);
|
||||
this.activatorRail.setTime(1);
|
||||
this.activatorRail.setBlockState(Blocks.ACTIVATOR_RAIL.defaultBlockState());
|
||||
this.builderCommandStack.nbt().addTagProvider(this.activatorRail);
|
||||
|
||||
EntityTag redstoneBlock = new EntityTag(EntityType.FALLING_BLOCK.getRegistryName());
|
||||
redstoneBlock.setTime(1);
|
||||
redstoneBlock.setBlockState(Blocks.REDSTONE_BLOCK.defaultBlockState());
|
||||
this.builderCommandStack.addPassenger(redstoneBlock);
|
||||
this.activatorRail.addPassenger(redstoneBlock);
|
||||
|
||||
this.addCommand(0);
|
||||
|
||||
EntityNBT blockRemover = new EntityNBT(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
BuilderSetBlock builder = new BuilderSetBlock(new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(-2, EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), Blocks.REPEATING_COMMAND_BLOCK.getRegistryName(), EnumMode.DESTROY);
|
||||
EntityTag blockRemover = new EntityTag(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
SetBlockCommandBuilder builder = new SetBlockCommandBuilder();
|
||||
builder.pos().setX(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
builder.pos().setY(new Coordinate.Ints(-2, Coordinate.Type.RELATIVE));
|
||||
builder.pos().setZ(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
builder.block().set(Blocks.REPEATING_COMMAND_BLOCK);
|
||||
CompoundTag commandBlock = new CompoundTag();
|
||||
commandBlock.putByte("auto", (byte) 1);
|
||||
commandBlock.putString("Command", new BuilderFill(new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(2, EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new BlockResourceLocation(Blocks.AIR.getRegistryName())).toActualCommand());
|
||||
builder.setBlockNBT(commandBlock);
|
||||
blockRemover.setCommand(builder.toActualCommand());
|
||||
this.builderCommandStack.addPassenger(blockRemover);
|
||||
FillCommandBuilder fill = new FillCommandBuilder();
|
||||
fill.from().setX(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
fill.from().setY(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
fill.from().setZ(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
fill.to().setX(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
fill.to().setY(new Coordinate.Ints(2, Coordinate.Type.RELATIVE));
|
||||
fill.to().setZ(new Coordinate.Ints(Coordinate.Type.RELATIVE));
|
||||
fill.block().set(Blocks.AIR);
|
||||
commandBlock.putString("Command", fill.toCommand(FillCommandBuilder.Label.FILL, false));
|
||||
builder.block().setTag(commandBlock);
|
||||
blockRemover.setCommand(builder.toCommand(SetBlockCommandBuilder.Label.DESTROY, false));
|
||||
this.activatorRail.addPassenger(blockRemover);
|
||||
|
||||
EntityNBT entityRemover = new EntityNBT(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
entityRemover.setCommand(new BuilderButcher(EntityType.COMMAND_BLOCK_MINECART.getRegistryName(), 1).toActualCommand());
|
||||
this.builderCommandStack.addPassenger(entityRemover);
|
||||
EntityTag entityRemover = new EntityTag(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
KillCommandBuilder kill = new KillCommandBuilder();
|
||||
kill.targets().setSelectorType(SelectorTypes.ALL_ENTITIES);
|
||||
kill.targets().setType(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
kill.targets().setDistanceMax(1.0D);
|
||||
entityRemover.setCommand(kill.toCommand(KillCommandBuilder.Label.KILL_TARGETS, false));
|
||||
this.activatorRail.addPassenger(entityRemover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.builderCommandStack;
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,7 +182,7 @@ public class ContentCommandStack extends ContentChild
|
||||
|
||||
container.add(this.buttonCopy = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.command_stack.copy_command"), () ->
|
||||
{
|
||||
Minecraft.getInstance().keyboardHandler.setClipboard(this.builderCommandStack.toActualCommand());
|
||||
Minecraft.getInstance().keyboardHandler.setClipboard(this.builderCommandStack.toCommand(SummonCommandBuilder.Label.SUMMON_POS_NBT, false));
|
||||
}));
|
||||
container.add(buttonScrollUp = new GuiButtonIcon(x + 118, y + 72, 56, 20, EnumIcon.ARROW_UP, new TranslatableComponent("gui.worldhandler.actions.move_up"), () ->
|
||||
{
|
||||
@@ -239,7 +255,7 @@ public class ContentCommandStack extends ContentChild
|
||||
|
||||
private void setCommand(int index, String command)
|
||||
{
|
||||
EntityNBT entity = this.builderCommandStack.getPassenger(index + HEAD_LENGTH);
|
||||
EntityTag entity = this.activatorRail.getPassenger(index + HEAD_LENGTH);
|
||||
|
||||
if(entity != null)
|
||||
{
|
||||
@@ -249,18 +265,18 @@ public class ContentCommandStack extends ContentChild
|
||||
|
||||
private void addCommand(int index)
|
||||
{
|
||||
this.builderCommandStack.addPassenger(index + HEAD_LENGTH, new EntityNBT(EntityType.COMMAND_BLOCK_MINECART.getRegistryName()));
|
||||
this.activatorRail.addPassenger(index + HEAD_LENGTH, new EntityTag(EntityType.COMMAND_BLOCK_MINECART.getRegistryName()));
|
||||
}
|
||||
|
||||
private void removeCommand(int index)
|
||||
{
|
||||
this.builderCommandStack.removePassenger(index + HEAD_LENGTH);
|
||||
this.activatorRail.removePassenger(index + HEAD_LENGTH);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getCommand(int index)
|
||||
{
|
||||
EntityNBT entity = this.builderCommandStack.getPassenger(index + HEAD_LENGTH);
|
||||
EntityTag entity = this.activatorRail.getPassenger(index + HEAD_LENGTH);
|
||||
|
||||
if(entity != null)
|
||||
{
|
||||
@@ -272,12 +288,12 @@ public class ContentCommandStack extends ContentChild
|
||||
|
||||
private int getCommandCount()
|
||||
{
|
||||
return this.builderCommandStack.getPassengerCount() - HEAD_LENGTH - TAIL_LENGTH;
|
||||
return this.activatorRail.getPassengerCount() - HEAD_LENGTH - TAIL_LENGTH;
|
||||
}
|
||||
|
||||
private void swapCommands(int i, int j)
|
||||
{
|
||||
Collections.swap(this.builderCommandStack.getPassengers(), i + HEAD_LENGTH, j + HEAD_LENGTH);
|
||||
Collections.swap(this.activatorRail.getPassengers(), i + HEAD_LENGTH, j + HEAD_LENGTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderGive;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSetBlock;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.builder.argument.Coordinate;
|
||||
import exopandora.worldhandler.builder.impl.GiveCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.SetBlockCommandBuilder;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
@@ -18,7 +17,9 @@ import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -29,21 +30,9 @@ public class ContentContainers extends Content
|
||||
{
|
||||
container.add(new GuiButtonBase(x, y + 96, 232, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonBase(x + 24, y, 208, 20, Blocks.CRAFTING_TABLE.getName(), () ->
|
||||
{
|
||||
BlockHelper.setBlockNearPlayer(container.getPlayer(), Blocks.CRAFTING_TABLE);
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 24, y + 24, 208, 20, Blocks.ENDER_CHEST.getName(), () ->
|
||||
{
|
||||
BlockHelper.setBlockNearPlayer(container.getPlayer(), Blocks.ENDER_CHEST);
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 24, y + 48, 208, 20, Blocks.ANVIL.getName(), () ->
|
||||
{
|
||||
BlockHelper.setBlockNearPlayer(container.getPlayer(), Blocks.ANVIL);
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 24, y, 208, 20, Blocks.CRAFTING_TABLE.getName(), () -> this.placeBlock(container.getPlayer(), Blocks.CRAFTING_TABLE)));
|
||||
container.add(new GuiButtonBase(x + 24, y + 24, 208, 20, Blocks.ENDER_CHEST.getName(), () -> this.placeBlock(container.getPlayer(), Blocks.ENDER_CHEST)));
|
||||
container.add(new GuiButtonBase(x + 24, y + 48, 208, 20, Blocks.ANVIL.getName(), () -> this.placeBlock(container.getPlayer(), Blocks.ANVIL)));
|
||||
container.add(new GuiButtonBase(x + 24, y + 72, 208, 20, Blocks.ENCHANTING_TABLE.getName(), () ->
|
||||
{
|
||||
double angle = Minecraft.getInstance().player.getDirection().get2DDataValue() * Math.PI / 2;
|
||||
@@ -68,10 +57,28 @@ public class ContentContainers extends Content
|
||||
{
|
||||
block = Blocks.ENCHANTING_TABLE;
|
||||
}
|
||||
|
||||
if(block != null)
|
||||
else
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), new BuilderSetBlock(new CoordinateInt(cx, EnumType.GLOBAL), new CoordinateInt(yOffset, EnumType.GLOBAL), new CoordinateInt(cz, EnumType.GLOBAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()));
|
||||
continue;
|
||||
}
|
||||
|
||||
SetBlockCommandBuilder builder = new SetBlockCommandBuilder();
|
||||
builder.pos().setX(new Coordinate.Ints(cx, Coordinate.Type.RELATIVE));
|
||||
builder.pos().setY(new Coordinate.Ints(yOffset, Coordinate.Type.RELATIVE));
|
||||
builder.pos().setZ(new Coordinate.Ints(cz, Coordinate.Type.RELATIVE));
|
||||
builder.block().set(block);
|
||||
|
||||
switch(Config.getSettings().getBlockPlacingMode())
|
||||
{
|
||||
case KEEP:
|
||||
CommandHelper.sendCommand(container.getPlayer(), builder, SetBlockCommandBuilder.Label.KEEP);
|
||||
break;
|
||||
case REPLACE:
|
||||
CommandHelper.sendCommand(container.getPlayer(), builder, SetBlockCommandBuilder.Label.REPLACE);
|
||||
break;
|
||||
case DESTROY:
|
||||
CommandHelper.sendCommand(container.getPlayer(), builder, SetBlockCommandBuilder.Label.DESTROY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,22 +87,24 @@ public class ContentContainers extends Content
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonItem(x, y, 20, 20, new ItemStack(Blocks.CRAFTING_TABLE), () ->
|
||||
container.add(new GuiButtonItem(x, y, 20, 20, new ItemStack(Blocks.CRAFTING_TABLE), () -> this.giveItem(container.getPlayer(), Items.CRAFTING_TABLE)));
|
||||
container.add(new GuiButtonItem(x, y + 24, 20, 20, new ItemStack(Blocks.ENDER_CHEST), () -> this.giveItem(container.getPlayer(), Items.ENDER_CHEST)));
|
||||
container.add(new GuiButtonItem(x, y + 48, 20, 20, new ItemStack(Blocks.ANVIL), () -> this.giveItem(container.getPlayer(), Items.ANVIL)));
|
||||
container.add(new GuiButtonItem(x, y + 72, 20, 20, new ItemStack(Blocks.ENCHANTING_TABLE), () -> this.giveItem(container.getPlayer(), Items.ENCHANTING_TABLE)));
|
||||
}
|
||||
|
||||
private void giveItem(String player, Item item)
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), new BuilderGive(container.getPlayer(), Blocks.CRAFTING_TABLE.getRegistryName()));
|
||||
}));
|
||||
container.add(new GuiButtonItem(x, y + 24, 20, 20, new ItemStack(Blocks.ENDER_CHEST), () ->
|
||||
GiveCommandBuilder builder = new GiveCommandBuilder();
|
||||
builder.targets().setTarget(player);
|
||||
builder.item().set(item);
|
||||
CommandHelper.sendCommand(player, builder, GiveCommandBuilder.Label.GIVE);
|
||||
}
|
||||
|
||||
private void placeBlock(String player, Block block)
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), new BuilderGive(container.getPlayer(), Blocks.ENDER_CHEST.getRegistryName()));
|
||||
}));
|
||||
container.add(new GuiButtonItem(x, y + 48, 20, 20, new ItemStack(Blocks.ANVIL), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), new BuilderGive(container.getPlayer(), Blocks.ANVIL.getRegistryName()));
|
||||
}));
|
||||
container.add(new GuiButtonItem(x, y + 72, 20, 20, new ItemStack(Blocks.ENCHANTING_TABLE), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), new BuilderGive(container.getPlayer(), Blocks.ENCHANTING_TABLE.getRegistryName()));
|
||||
}));
|
||||
BlockHelper.setBlockNearPlayer(player, block);
|
||||
ActionHelper.backToGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.ICommandBuilderSyntax;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
@@ -16,24 +15,26 @@ public class ContentContinue extends ContentChild
|
||||
{
|
||||
private ICommandBuilder builder;
|
||||
private GuiTextFieldTooltip commandField;
|
||||
private Object label;
|
||||
private boolean special;
|
||||
|
||||
public ContentContinue withBuilder(ICommandBuilder builder)
|
||||
public ContentContinue withBuilder(ICommandBuilder builder, Object label)
|
||||
{
|
||||
return this.withBuilder(builder, false);
|
||||
return this.withBuilder(builder, label, false);
|
||||
}
|
||||
|
||||
public ContentContinue withBuilder(ICommandBuilder builder, boolean special)
|
||||
public ContentContinue withBuilder(ICommandBuilder builder, Object label, boolean special)
|
||||
{
|
||||
this.builder = builder;
|
||||
this.label = label;
|
||||
this.special = special;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.builder;
|
||||
return new CommandPreview(this.builder, this.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,16 +42,7 @@ public class ContentContinue extends ContentChild
|
||||
{
|
||||
this.commandField = new GuiTextFieldTooltip(x + 116 / 2, y + 12, 116, 20);
|
||||
this.commandField.setFocus(false);
|
||||
|
||||
if(this.builder instanceof ICommandBuilderSyntax)
|
||||
{
|
||||
this.commandField.setValue(((ICommandBuilderSyntax) this.builder).toActualCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.commandField.setValue(this.builder.toCommand());
|
||||
}
|
||||
|
||||
this.commandField.setValue(this.builder.toCommand(this.label, false));
|
||||
this.commandField.moveCursorToStart();
|
||||
this.commandField.setFilter(text -> text.equals(this.commandField.getValue()));
|
||||
}
|
||||
@@ -64,7 +56,7 @@ public class ContentContinue extends ContentChild
|
||||
container.add(this.commandField);
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 36, 116, 20, new TranslatableComponent("gui.worldhandler.generic.yes").withStyle(ChatFormatting.RED), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builder, this.special);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builder, this.label, this.special);
|
||||
ActionHelper.open(this.getParentContent());
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 60, 116, 20, new TranslatableComponent("gui.worldhandler.generic.no"), () -> ActionHelper.back(this)));
|
||||
|
||||
@@ -5,27 +5,28 @@ import java.util.ArrayList;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttribute;
|
||||
import exopandora.worldhandler.builder.impl.BuilderCustomItem;
|
||||
import exopandora.worldhandler.builder.argument.tag.AbstractAttributeTag;
|
||||
import exopandora.worldhandler.builder.argument.tag.AttributeModifiersTag;
|
||||
import exopandora.worldhandler.builder.argument.tag.DisplayTag;
|
||||
import exopandora.worldhandler.builder.argument.tag.EnchantmentsTag;
|
||||
import exopandora.worldhandler.builder.impl.GiveCommandBuilder;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuColorField;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderAttribute;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuColorField;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.ResourceHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
@@ -40,39 +41,49 @@ public class ContentCustomItem extends Content
|
||||
private GuiTextFieldTooltip itemLore1Field;
|
||||
private GuiTextFieldTooltip itemLore2Field;
|
||||
|
||||
private final BuilderCustomItem builderCutomItem = new BuilderCustomItem();
|
||||
private final GiveCommandBuilder builderCutomItem = new GiveCommandBuilder();
|
||||
private final AttributeModifiersTag attributes = new AttributeModifiersTag();
|
||||
private final DisplayTag display = new DisplayTag();
|
||||
private final EnchantmentsTag enchantments = new EnchantmentsTag();
|
||||
private final CommandPreview preview = new CommandPreview(this.builderCutomItem, GiveCommandBuilder.Label.GIVE);
|
||||
|
||||
private int startPage;
|
||||
|
||||
private Page page = Page.START;
|
||||
private String item;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public ContentCustomItem()
|
||||
{
|
||||
return this.builderCutomItem;
|
||||
this.builderCutomItem.item().addTagProvider(this.attributes);
|
||||
this.builderCutomItem.item().addTagProvider(this.display);
|
||||
this.builderCutomItem.item().addTagProvider(this.enchantments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Container container)
|
||||
{
|
||||
for(Attribute attribute : this.builderCutomItem.getAttributes())
|
||||
for(Attribute attribute : this.attributes.getAttributes())
|
||||
{
|
||||
double ammount = this.builderCutomItem.getAttributeAmmount(attribute);
|
||||
double value = this.attributes.get(attribute);
|
||||
|
||||
if(ammount > Config.getSliders().getMaxItemAttributes())
|
||||
if(value > Config.getSliders().getMaxItemAttributes())
|
||||
{
|
||||
this.builderCutomItem.setAttribute(attribute, Config.getSliders().getMaxItemAttributes());
|
||||
this.attributes.set(attribute, Config.getSliders().getMaxItemAttributes());
|
||||
}
|
||||
}
|
||||
|
||||
for(Enchantment enchantment : this.builderCutomItem.getEnchantments())
|
||||
for(Enchantment enchantment : this.enchantments.getEnchantments())
|
||||
{
|
||||
short level = this.builderCutomItem.getEnchantmentLevel(enchantment);
|
||||
short level = this.enchantments.get(enchantment);
|
||||
|
||||
if(level > Config.getSliders().getMaxItemEnchantment())
|
||||
{
|
||||
this.builderCutomItem.setEnchantment(enchantment, (short) Config.getSliders().getMaxItemEnchantment());
|
||||
this.enchantments.set(enchantment, (short) Config.getSliders().getMaxItemEnchantment());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,25 +97,25 @@ public class ContentCustomItem extends Content
|
||||
this.itemField.setResponder(text ->
|
||||
{
|
||||
this.item = text;
|
||||
this.builderCutomItem.setItem(this.item);
|
||||
this.builderCutomItem.item().deserialize(this.item);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.start.lore_1"));
|
||||
this.itemLore1Field.setFilter(Predicates.<String>notNull());
|
||||
this.itemLore1Field.setText(this.builderCutomItem.getLore1());
|
||||
this.itemLore1Field.setText(this.display.getLore1());
|
||||
this.itemLore1Field.setResponder(text ->
|
||||
{
|
||||
this.builderCutomItem.setLore1(new TextComponent(text));
|
||||
this.display.setLore1(new TextComponent(text));
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.start.lore_2"));
|
||||
this.itemLore2Field.setFilter(Predicates.<String>notNull());
|
||||
this.itemLore2Field.setText(this.builderCutomItem.getLore2());
|
||||
this.itemLore2Field.setText(this.display.getLore2());
|
||||
this.itemLore2Field.setResponder(text ->
|
||||
{
|
||||
this.builderCutomItem.setLore2(new TextComponent(text));
|
||||
this.display.setLore2(new TextComponent(text));
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
@@ -112,7 +123,7 @@ public class ContentCustomItem extends Content
|
||||
{
|
||||
if(this.startPage == 1)
|
||||
{
|
||||
container.add(new MenuColorField(x, y, "gui.worldhandler.items.custom_item.start.custom_name", this.builderCutomItem.getName()));
|
||||
container.add(new MenuColorField(x, y, "gui.worldhandler.items.custom_item.start.custom_name", this.display.getName()));
|
||||
}
|
||||
}
|
||||
else if(Page.ENCHANT.equals(this.page))
|
||||
@@ -142,7 +153,7 @@ public class ContentCustomItem extends Content
|
||||
{
|
||||
return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(item.getRegistryName().toString(), text, value ->
|
||||
{
|
||||
ContentCustomItem.this.builderCutomItem.setEnchantment(item, value.shortValue());
|
||||
ContentCustomItem.this.enchantments.set(item, value.shortValue());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -162,32 +173,32 @@ public class ContentCustomItem extends Content
|
||||
}
|
||||
else if(Page.ATTRIBUTES.equals(this.page))
|
||||
{
|
||||
MenuPageList<Attribute> attributes = new MenuPageList<Attribute>(x + 118, y, ComponentAttribute.ATTRIBUTES, 114, 20, 3, container, new ILogicPageList<Attribute>()
|
||||
MenuPageList<Attribute> attributes = new MenuPageList<Attribute>(x + 118, y, AbstractAttributeTag.ATTRIBUTES, 114, 20, 3, container, new ILogicPageList<Attribute>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(Attribute item)
|
||||
public MutableComponent translate(Attribute attribute)
|
||||
{
|
||||
return new TranslatableComponent(item.getDescriptionId());
|
||||
return new TranslatableComponent(attribute.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Attribute item)
|
||||
public MutableComponent toTooltip(Attribute attribute)
|
||||
{
|
||||
return new TextComponent(item.getRegistryName().toString());
|
||||
return new TextComponent(attribute.getRegistryName().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Attribute item)
|
||||
public void onClick(Attribute attribute)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Attribute item, ActionHandler actionHandler)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Attribute attribute, ActionHandler actionHandler)
|
||||
{
|
||||
return new GuiSlider(x, y, width, height, -Config.getSliders().getMaxItemAttributes(), Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderAttribute(item, text, value ->
|
||||
return new GuiSlider(x, y, width, height, -Config.getSliders().getMaxItemAttributes(), Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderAttribute(attribute, text, value ->
|
||||
{
|
||||
ContentCustomItem.this.builderCutomItem.setAttribute(item, value);
|
||||
ContentCustomItem.this.attributes.set(attribute, value);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -273,21 +284,21 @@ public class ContentCustomItem extends Content
|
||||
button3.active = false;
|
||||
}
|
||||
|
||||
if(!this.builderCutomItem.needsCommandBlock() && !this.builderCutomItem.getName().isSpecial())
|
||||
if(!this.builderCutomItem.needsCommandBlock(GiveCommandBuilder.Label.GIVE, false) && !this.display.getName().isSpecial())
|
||||
{
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.custom_item"), () -> this.send(container.getPlayer())));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.items.custom_item.custom_item"), () -> this.giveItem(container.getPlayer())));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.place_command_block"), () -> this.send(container.getPlayer())));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.place_command_block"), () -> this.giveItem(container.getPlayer())));
|
||||
}
|
||||
|
||||
button4.active = ResourceHelper.isRegistered(ResourceHelper.stringToResourceLocation(this.item), ForgeRegistries.ITEMS);
|
||||
button4.active = this.builderCutomItem.item().hasValue();
|
||||
}
|
||||
|
||||
private void send(String player)
|
||||
private void giveItem(String player)
|
||||
{
|
||||
CommandHelper.sendCommand(player, this.builderCutomItem, this.builderCutomItem.getName().isSpecial());
|
||||
CommandHelper.sendCommand(player, this.builderCutomItem, GiveCommandBuilder.Label.GIVE, this.display.getName().isSpecial());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -339,7 +350,7 @@ public class ContentCustomItem extends Content
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderCutomItem.setPlayer(username);
|
||||
this.builderCutomItem.targets().setTarget(username);
|
||||
}
|
||||
|
||||
public static enum Page
|
||||
|
||||
@@ -5,71 +5,64 @@ import java.util.Arrays;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone;
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWH;
|
||||
import exopandora.worldhandler.command.CommandWH.StringBlockPredicateArgument;
|
||||
import exopandora.worldhandler.builder.impl.CloneCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.FillCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.WHCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.CloneCommandBuilder.Label;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicMapped;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicMapped;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.ResourceHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ContentEditBlocks extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip x1Field;
|
||||
private GuiTextFieldTooltip y1Field;
|
||||
private GuiTextFieldTooltip z1Field;
|
||||
|
||||
private GuiTextFieldTooltip x2Field;
|
||||
private GuiTextFieldTooltip y2Field;
|
||||
private GuiTextFieldTooltip z2Field;
|
||||
|
||||
private GuiTextFieldTooltip block1Field;
|
||||
private GuiTextFieldTooltip block2Field;
|
||||
|
||||
private GuiTextFieldTooltip filterField;
|
||||
|
||||
private final BuilderFill builderFill = BlockHelper.addPositionObservers(new BuilderFill(), builder -> builder::setPosition1, builder -> builder::setPosition2);
|
||||
private final BuilderClone builderClone = BlockHelper.addPositionObservers(new BuilderClone(), builder -> builder::setPosition1, builder -> builder::setPosition2);
|
||||
private final BuilderWH builderWH = new BuilderWH();
|
||||
private final FillCommandBuilder builderFill = new FillCommandBuilder();
|
||||
private final CloneCommandBuilder builderClone = new CloneCommandBuilder();
|
||||
private final WHCommandBuilder builderWH = new WHCommandBuilder();
|
||||
|
||||
private String block1;
|
||||
private String block2;
|
||||
private String filter;
|
||||
|
||||
private Page page = Page.COORDINATES;
|
||||
private Mask mask = Mask.FILTERED;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
if(Page.COORDINATES.equals(this.page))
|
||||
{
|
||||
return this.builderWH;
|
||||
return new CommandPreview(this.builderWH, null);
|
||||
}
|
||||
else if(Page.FILL.equals(this.page) || Page.REPLACE.equals(this.page))
|
||||
{
|
||||
return this.builderFill;
|
||||
return new CommandPreview(this.builderFill, FillCommandBuilder.Label.FILL);
|
||||
}
|
||||
else if(Page.CLONE.equals(this.page))
|
||||
{
|
||||
return this.builderClone;
|
||||
return new CommandPreview(this.builderClone, this.mask.getLabel());
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -78,53 +71,37 @@ public class ContentEditBlocks extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.updatePositions();
|
||||
|
||||
this.x1Field = new GuiTextFieldTooltip(x + 118, y, 55, 20);
|
||||
this.x1Field.setFilter(this.getCoordinatePredicate("X1"));
|
||||
this.x1Field.setValue("X1: " + BlockHelper.getPos1().getX());
|
||||
this.x1Field.setResponder(text ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), this.parseCoordinate(text)));
|
||||
});
|
||||
this.x1Field.setFilter(this.coordinatePredicate("X1"));
|
||||
this.x1Field.setValue("X1: " + BlockHelper.pos1().getX());
|
||||
this.x1Field.setResponder(text -> BlockHelper.pos1().setX(this.parseCoordinate(text)));
|
||||
|
||||
this.y1Field = new GuiTextFieldTooltip(x + 118, y + 24, 55, 20);
|
||||
this.y1Field.setFilter(this.getCoordinatePredicate("Y1"));
|
||||
this.y1Field.setValue("Y1: " + BlockHelper.getPos1().getY());
|
||||
this.y1Field.setResponder(text ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), this.parseCoordinate(text)));
|
||||
});
|
||||
this.y1Field.setFilter(this.coordinatePredicate("Y1"));
|
||||
this.y1Field.setValue("Y1: " + BlockHelper.pos1().getY());
|
||||
this.y1Field.setResponder(text -> BlockHelper.pos1().setY(this.parseCoordinate(text)));
|
||||
|
||||
this.z1Field = new GuiTextFieldTooltip(x + 118, y + 48, 55, 20);
|
||||
this.z1Field.setFilter(this.getCoordinatePredicate("Z1"));
|
||||
this.z1Field.setValue("Z1: " + BlockHelper.getPos1().getZ());
|
||||
this.z1Field.setResponder(text ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), this.parseCoordinate(text)));
|
||||
});
|
||||
this.z1Field.setFilter(this.coordinatePredicate("Z1"));
|
||||
this.z1Field.setValue("Z1: " + BlockHelper.pos1().getZ());
|
||||
this.z1Field.setResponder(text -> BlockHelper.pos1().setZ(this.parseCoordinate(text)));
|
||||
|
||||
this.x2Field = new GuiTextFieldTooltip(x + 118 + 59, y, 55, 20);
|
||||
this.x2Field.setFilter(this.getCoordinatePredicate("X2"));
|
||||
this.x2Field.setValue("X2: " + BlockHelper.getPos2().getX());
|
||||
this.x2Field.setResponder(text ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), this.parseCoordinate(text)));
|
||||
});
|
||||
this.x2Field.setFilter(this.coordinatePredicate("X2"));
|
||||
this.x2Field.setValue("X2: " + BlockHelper.pos2().getX());
|
||||
this.x2Field.setResponder(text -> BlockHelper.pos2().setX(this.parseCoordinate(text)));
|
||||
|
||||
this.y2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 24, 55, 20);
|
||||
this.y2Field.setFilter(this.getCoordinatePredicate("Y2"));
|
||||
this.y2Field.setValue("Y2: " + BlockHelper.getPos2().getY());
|
||||
this.y2Field.setResponder(text ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), this.parseCoordinate(text)));
|
||||
});
|
||||
this.y2Field.setFilter(this.coordinatePredicate("Y2"));
|
||||
this.y2Field.setValue("Y2: " + BlockHelper.pos2().getY());
|
||||
this.y2Field.setResponder(text -> BlockHelper.pos2().setY(this.parseCoordinate(text)));
|
||||
|
||||
this.z2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 48, 55, 20);
|
||||
this.z2Field.setFilter(this.getCoordinatePredicate("Z2"));
|
||||
this.z2Field.setValue("Z2: " + BlockHelper.getPos2().getZ());
|
||||
this.z2Field.setResponder(text ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), this.parseCoordinate(text)));
|
||||
});
|
||||
this.z2Field.setFilter(this.coordinatePredicate("Z2"));
|
||||
this.z2Field.setValue("Z2: " + BlockHelper.pos2().getZ());
|
||||
this.z2Field.setResponder(text -> BlockHelper.pos2().setZ(this.parseCoordinate(text)));
|
||||
|
||||
this.block1Field = new GuiTextFieldTooltip(x + 118, y, 114, 20, Page.FILL.equals(this.page) ? new TranslatableComponent("gui.worldhandler.edit_blocks.fill.block_id_to_fill") : new TranslatableComponent("gui.worldhandler.edit_blocks.replace.block_id_replace"));
|
||||
this.block1Field.setFilter(Predicates.notNull());
|
||||
@@ -132,7 +109,7 @@ public class ContentEditBlocks extends Content
|
||||
this.block1Field.setResponder(text ->
|
||||
{
|
||||
this.block1 = text;
|
||||
this.builderFill.setBlock1(this.block1);
|
||||
this.builderFill.block().deserialize(this.block1);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
@@ -142,7 +119,7 @@ public class ContentEditBlocks extends Content
|
||||
this.block2Field.setResponder(text ->
|
||||
{
|
||||
this.block2 = text;
|
||||
this.builderFill.setBlock2(this.block2);
|
||||
this.builderFill.filter().deserialize(this.block2); //TODO block2 = filter ???
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
@@ -152,7 +129,7 @@ public class ContentEditBlocks extends Content
|
||||
this.filterField.setResponder(text ->
|
||||
{
|
||||
this.filter = text;
|
||||
this.builderClone.setFilter(this.filter);
|
||||
this.builderClone.filter().deserialize(this.filter);
|
||||
container.initButtons();
|
||||
});
|
||||
}
|
||||
@@ -225,9 +202,9 @@ public class ContentEditBlocks extends Content
|
||||
container.add(this.block1Field);
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.fill"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderFill.build());
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderFill, FillCommandBuilder.Label.FILL);
|
||||
}));
|
||||
button1.active = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS);
|
||||
button1.active = this.builderFill.block().hasValue();
|
||||
}
|
||||
else if(Page.REPLACE.equals(this.page))
|
||||
{
|
||||
@@ -243,9 +220,9 @@ public class ContentEditBlocks extends Content
|
||||
container.add(this.block2Field);
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.replace"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderFill.buildReplace());
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderFill, FillCommandBuilder.Label.REPLACE);
|
||||
}));
|
||||
button1.active = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS) && ResourceHelper.isRegistered(this.builderFill.getBlock2(), ForgeRegistries.BLOCKS);
|
||||
button1.active = this.builderFill.block().hasValue() && this.builderFill.filter().hasValue();
|
||||
}
|
||||
else if(Page.CLONE.equals(this.page))
|
||||
{
|
||||
@@ -257,36 +234,34 @@ public class ContentEditBlocks extends Content
|
||||
width2 = 56;
|
||||
xOffset2 = 58;
|
||||
|
||||
if(EnumMask.FILTERED.equals(this.builderClone.getMask()))
|
||||
if(Mask.FILTERED.equals(this.mask))
|
||||
{
|
||||
this.builderClone.setFilter(this.filter);
|
||||
container.add(this.filterField);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.builderClone.setFilter(null);
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, TextComponent.EMPTY, null));
|
||||
button1.active = false;
|
||||
}
|
||||
|
||||
container.add(new GuiButtonList<EnumMask>(x + 118, y, Arrays.asList(EnumMask.values()), 114, 20, container, new ILogicMapped<EnumMask>()
|
||||
container.add(new GuiButtonList<Mask>(x + 118, y, Arrays.asList(Mask.values()), 114, 20, container, new ILogicMapped<Mask>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(EnumMask item)
|
||||
public MutableComponent translate(Mask mask)
|
||||
{
|
||||
return new TranslatableComponent("gui.worldhandler.edit_blocks.clone.mode." + item.toString());
|
||||
return new TranslatableComponent("gui.worldhandler.edit_blocks.clone.mode." + mask.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(EnumMask item)
|
||||
public MutableComponent toTooltip(Mask mask)
|
||||
{
|
||||
return new TextComponent(item.toString());
|
||||
return new TextComponent(mask.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumMask item)
|
||||
public void onClick(Mask mask)
|
||||
{
|
||||
ContentEditBlocks.this.builderClone.setMask(item);
|
||||
ContentEditBlocks.this.mask = mask;
|
||||
container.init();
|
||||
}
|
||||
|
||||
@@ -299,34 +274,38 @@ public class ContentEditBlocks extends Content
|
||||
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.clone"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderClone);
|
||||
System.out.println(this.builderClone.toCommand(this.mask.getLabel(), false));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderClone, this.mask.getLabel());
|
||||
}));
|
||||
|
||||
try
|
||||
if(Mask.FILTERED.equals(this.mask))
|
||||
{
|
||||
if(EnumMask.FILTERED.equals(this.builderClone.getMask()))
|
||||
{
|
||||
StringBlockPredicateArgument.blockPredicate().parse(new StringReader(this.builderClone.getFilter()));
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
button2.active = false;
|
||||
button2.active = this.builderClone.filter().hasValue();
|
||||
}
|
||||
}
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + yOffset1, width1, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.pos.set_pos_1"), () ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
BlockHelper.pos1().set(BlockHelper.getFocusedBlockPos());
|
||||
this.updatePositions();
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118 + xOffset2, y + yOffset2, width2, 20, new TranslatableComponent("gui.worldhandler.edit_blocks.pos.set_pos_2"), () ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
BlockHelper.pos2().set(BlockHelper.getFocusedBlockPos());
|
||||
this.updatePositions();
|
||||
container.init();
|
||||
}));
|
||||
}
|
||||
|
||||
private void updatePositions()
|
||||
{
|
||||
this.builderFill.from().set(BlockHelper.pos1());
|
||||
this.builderFill.to().set(BlockHelper.pos2());
|
||||
this.builderClone.begin().set(BlockHelper.pos1());
|
||||
this.builderClone.end().set(BlockHelper.pos2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
@@ -351,7 +330,9 @@ public class ContentEditBlocks extends Content
|
||||
}
|
||||
else if(Page.CLONE.equals(this.page))
|
||||
{
|
||||
if(EnumMask.FILTERED.equals(this.builderClone.getMask()))
|
||||
this.builderClone.destination().set(Minecraft.getInstance().player.blockPosition());
|
||||
|
||||
if(Mask.FILTERED.equals(this.mask))
|
||||
{
|
||||
this.filterField.tick();
|
||||
}
|
||||
@@ -382,14 +363,14 @@ public class ContentEditBlocks extends Content
|
||||
}
|
||||
else if(Page.CLONE.equals(this.page))
|
||||
{
|
||||
if(EnumMask.FILTERED.equals(this.builderClone.getMask()))
|
||||
if(Mask.FILTERED.equals(this.mask))
|
||||
{
|
||||
this.filterField.renderButton(matrix, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Predicate<String> getCoordinatePredicate(String coordinate)
|
||||
private Predicate<String> coordinatePredicate(String coordinate)
|
||||
{
|
||||
return string -> string.matches(coordinate + ": [-]?[0-9]*");
|
||||
}
|
||||
@@ -433,11 +414,36 @@ public class ContentEditBlocks extends Content
|
||||
return Contents.EDIT_BLOCKS;
|
||||
}
|
||||
|
||||
public static enum Page
|
||||
private static enum Page
|
||||
{
|
||||
COORDINATES,
|
||||
FILL,
|
||||
REPLACE,
|
||||
CLONE;
|
||||
}
|
||||
|
||||
private static enum Mask
|
||||
{
|
||||
FILTERED(CloneCommandBuilder.Label.FILTERED),
|
||||
MASKED(CloneCommandBuilder.Label.MASKED),
|
||||
REPLACE(CloneCommandBuilder.Label.REPLACE);
|
||||
|
||||
private final CloneCommandBuilder.Label label;
|
||||
|
||||
private Mask(Label label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public CloneCommandBuilder.Label getLabel()
|
||||
{
|
||||
return this.label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,18 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderEnchantment;
|
||||
import exopandora.worldhandler.builder.impl.EnchantCommandBuilder;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
@@ -26,12 +25,13 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ContentEnchantment extends Content
|
||||
{
|
||||
private final BuilderEnchantment builderEnchantment = new BuilderEnchantment();
|
||||
private final EnchantCommandBuilder builderEnchantment = new EnchantCommandBuilder();
|
||||
private final CommandPreview preview = new CommandPreview(this.builderEnchantment, EnchantCommandBuilder.Label.ENCHANT_LEVEL);
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.builderEnchantment;
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,22 +40,22 @@ public class ContentEnchantment extends Content
|
||||
MenuPageList<Enchantment> enchantments = new MenuPageList<Enchantment>(x, y, new ArrayList<Enchantment>(ForgeRegistries.ENCHANTMENTS.getValues()), 114, 20, 3, container, new ILogicPageList<Enchantment>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(Enchantment item)
|
||||
public MutableComponent translate(Enchantment enchantment)
|
||||
{
|
||||
return new TranslatableComponent(item.getDescriptionId());
|
||||
return new TranslatableComponent(enchantment.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Enchantment item)
|
||||
public MutableComponent toTooltip(Enchantment enchantment)
|
||||
{
|
||||
return new TextComponent(item.getRegistryName().toString());
|
||||
return new TextComponent(enchantment.getRegistryName().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Enchantment item)
|
||||
public void onClick(Enchantment enchantment)
|
||||
{
|
||||
ContentEnchantment.this.builderEnchantment.setEnchantment(item);
|
||||
ContentEnchantment.this.builderEnchantment.setLevel(1);
|
||||
ContentEnchantment.this.builderEnchantment.enchantment().set(enchantment);
|
||||
ContentEnchantment.this.builderEnchantment.level().set(1);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@@ -81,14 +81,14 @@ public class ContentEnchantment extends Content
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, new TranslatableComponent("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 1, ForgeRegistries.ENCHANTMENTS.getValue(this.builderEnchantment.getEnchantment()).getMaxLevel(), 1, container, new LogicSliderSimple("enchantment", new TranslatableComponent("gui.worldhandler.items.enchantment.level"), value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 1, this.builderEnchantment.enchantment().getEnchantment().getMaxLevel(), 1, container, new LogicSliderSimple("enchantment", new TranslatableComponent("gui.worldhandler.items.enchantment.level"), value ->
|
||||
{
|
||||
this.builderEnchantment.setLevel(value.intValue());
|
||||
this.builderEnchantment.level().set(value.intValue());
|
||||
})));
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.items.enchantment.enchant"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderEnchantment);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderEnchantment, EnchantCommandBuilder.Label.ENCHANT_LEVEL);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -119,6 +119,6 @@ public class ContentEnchantment extends Content
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderEnchantment.setPlayer(username);
|
||||
this.builderEnchantment.target().setTarget(username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderExperience;
|
||||
import exopandora.worldhandler.builder.impl.ExperienceCommandBuilder;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
@@ -19,23 +18,29 @@ import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ContentExperience extends Content
|
||||
{
|
||||
private final BuilderExperience builderExperience = new BuilderExperience();
|
||||
private final ExperienceCommandBuilder builderExperience = new ExperienceCommandBuilder();
|
||||
private final CommandPreview preview = new CommandPreview(this.builderExperience, null);
|
||||
|
||||
private GuiButtonBase buttonAdd;
|
||||
private GuiButtonBase buttonRemove;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public ContentExperience()
|
||||
{
|
||||
return this.builderExperience;
|
||||
this.builderExperience.amount().set(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Container container)
|
||||
{
|
||||
if(this.builderExperience.getLevel() > Config.getSliders().getMaxExperience())
|
||||
if(this.builderExperience.amount().get() > Config.getSliders().getMaxExperience())
|
||||
{
|
||||
this.builderExperience.setLevel((int) Config.getSliders().getMaxExperience());
|
||||
this.builderExperience.amount().set((int) Config.getSliders().getMaxExperience());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,25 +52,30 @@ public class ContentExperience extends Content
|
||||
|
||||
container.add(new GuiSlider(x + 116 / 2, y, 114, 20, 0, Config.getSliders().getMaxExperience(), 0, container, new LogicSliderSimple("experience", new TranslatableComponent("gui.worldhandler.title.player.experience"), value ->
|
||||
{
|
||||
this.builderExperience.setLevel(value);
|
||||
this.builderExperience.amount().set(value);
|
||||
})));
|
||||
|
||||
container.add(this.buttonAdd = new GuiButtonBase(x + 116 / 2, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderExperience.buildAdd());
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderExperience, ExperienceCommandBuilder.Label.ADD_LEVELS);
|
||||
container.init();
|
||||
}));
|
||||
container.add(this.buttonRemove = new GuiButtonBase(x + 116 / 2, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.actions.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderExperience.buildRemove());
|
||||
ExperienceCommandBuilder builder = new ExperienceCommandBuilder();
|
||||
builder.targets().setTarget(this.builderExperience.targets().getTarget());
|
||||
builder.amount().set(-this.builderExperience.amount().get());
|
||||
CommandHelper.sendCommand(container.getPlayer(), builder, ExperienceCommandBuilder.Label.ADD_LEVELS);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 116 / 2, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.actions.reset"), new TranslatableComponent("gui.worldhandler.actions.set_to_0"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderExperience.buildReset());
|
||||
container.init();
|
||||
ExperienceCommandBuilder builder = new ExperienceCommandBuilder();
|
||||
builder.amount().set(0);
|
||||
builder.targets().setTarget(this.builderExperience.targets().getTarget());
|
||||
CommandHelper.sendCommand(container.getPlayer(), builder, ExperienceCommandBuilder.Label.SET_POINTS);
|
||||
}));
|
||||
|
||||
boolean enabled = this.builderExperience.getLevel() > 0;
|
||||
boolean enabled = this.builderExperience.amount().get() > 0;
|
||||
|
||||
this.buttonAdd.active = enabled;
|
||||
this.buttonRemove.active = enabled;
|
||||
@@ -74,7 +84,7 @@ public class ContentExperience extends Content
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
boolean enabled = this.builderExperience.getLevel() > 0;
|
||||
boolean enabled = this.builderExperience.amount().get() > 0;
|
||||
|
||||
this.buttonAdd.active = enabled;
|
||||
this.buttonRemove.active = enabled;
|
||||
@@ -107,6 +117,6 @@ public class ContentExperience extends Content
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderExperience.setPlayer(username);
|
||||
this.builderExperience.targets().setTarget(username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,17 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamerule;
|
||||
import exopandora.worldhandler.builder.impl.GameRuleCommandBuilder;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
@@ -37,12 +36,13 @@ public class ContentGamerules extends Content
|
||||
private boolean booleanValue;
|
||||
private String value;
|
||||
|
||||
private final BuilderGamerule builderGamerule = new BuilderGamerule();
|
||||
private final GameRuleCommandBuilder builderGamerule = new GameRuleCommandBuilder();
|
||||
private final CommandPreview preview = new CommandPreview(this.builderGamerule, GameRuleCommandBuilder.Label.GAMERULE_VALUE);
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
return this.builderGamerule;
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +55,7 @@ public class ContentGamerules extends Content
|
||||
this.valueField.setResponder(text ->
|
||||
{
|
||||
this.value = text;
|
||||
this.builderGamerule.setValue(this.value);
|
||||
this.builderGamerule.value().set(text);
|
||||
});
|
||||
|
||||
Map<String, ArgumentType<?>> map = new HashMap<String, ArgumentType<?>>();
|
||||
@@ -72,30 +72,30 @@ public class ContentGamerules extends Content
|
||||
MenuPageList<String> rules = new MenuPageList<String>(x, y, new ArrayList<String>(map.keySet()), 114, 20, 3, container, new ILogicPageList<String>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(String item)
|
||||
public MutableComponent translate(String rule)
|
||||
{
|
||||
return new TranslatableComponent("gamerule." + item);
|
||||
return new TranslatableComponent("gamerule." + rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(String item)
|
||||
public MutableComponent toTooltip(String rule)
|
||||
{
|
||||
return new TextComponent(item);
|
||||
return new TextComponent(rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(String item)
|
||||
public void onClick(String rule)
|
||||
{
|
||||
ContentGamerules.this.builderGamerule.setRule(item);
|
||||
ContentGamerules.this.booleanValue = map.get(item) instanceof BoolArgumentType;
|
||||
ContentGamerules.this.builderGamerule.rule().set(rule);
|
||||
ContentGamerules.this.booleanValue = map.get(rule) instanceof BoolArgumentType;
|
||||
|
||||
if(ContentGamerules.this.booleanValue)
|
||||
{
|
||||
ContentGamerules.this.builderGamerule.setValue(null);
|
||||
ContentGamerules.this.builderGamerule.value().set(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentGamerules.this.builderGamerule.setValue(ContentGamerules.this.value);
|
||||
ContentGamerules.this.builderGamerule.value().set(ContentGamerules.this.value);
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
@@ -127,11 +127,11 @@ public class ContentGamerules extends Content
|
||||
{
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderGamerule.build(String.valueOf(true)));
|
||||
this.setGameRule(container.getPlayer(), String.valueOf(true));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.generic.disable"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderGamerule.build(String.valueOf(false)));
|
||||
this.setGameRule(container.getPlayer(), String.valueOf(false));
|
||||
}));
|
||||
}
|
||||
else
|
||||
@@ -139,11 +139,19 @@ public class ContentGamerules extends Content
|
||||
container.add(this.valueField);
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.actions.perform"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderGamerule);
|
||||
this.setGameRule(container.getPlayer(), this.value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void setGameRule(String player, String value)
|
||||
{
|
||||
GameRuleCommandBuilder builder = new GameRuleCommandBuilder();
|
||||
builder.rule().set(this.builderGamerule.rule().get());
|
||||
builder.value().set(value);
|
||||
CommandHelper.sendCommand(player, builder, GameRuleCommandBuilder.Label.GAMERULE_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
|
||||
@@ -3,13 +3,16 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGeneric;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPlayer;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPlayerReason;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWhitelist;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWhitelist.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BanCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.DeOpCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.KickCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.OpCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.PardonCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.SaveAllCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.SaveOffCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.SaveOnCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.StopCommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.WhitelistCommandBuilder;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -35,43 +38,53 @@ public class ContentMultiplayer extends Content
|
||||
|
||||
private Page page = Page.KICK_AND_BAN;
|
||||
|
||||
private final BuilderPlayerReason builderKick = new BuilderPlayerReason("kick");
|
||||
private final BuilderPlayerReason builderBan = new BuilderPlayerReason("ban");
|
||||
private final BuilderPlayer builderPardon = new BuilderPlayer("pardon");
|
||||
private final BuilderPlayer builderOp = new BuilderPlayer("op");
|
||||
private final BuilderPlayer builderDeop = new BuilderPlayer("deop");
|
||||
private final BuilderGeneric builderSaveAll = new BuilderGeneric("save-all");
|
||||
private final BuilderGeneric builderSaveOn = new BuilderGeneric("save-on");
|
||||
private final BuilderGeneric builderSaveOff = new BuilderGeneric("save-off");
|
||||
private final BuilderGeneric builderStop = new BuilderGeneric("stop");
|
||||
private final BuilderWhitelist builderWhitelist = new BuilderWhitelist();
|
||||
private final KickCommandBuilder builderKick = new KickCommandBuilder();
|
||||
private final BanCommandBuilder builderBan = new BanCommandBuilder();
|
||||
private final PardonCommandBuilder builderPardon = new PardonCommandBuilder();
|
||||
private final OpCommandBuilder builderOp = new OpCommandBuilder();
|
||||
private final DeOpCommandBuilder builderDeop = new DeOpCommandBuilder();
|
||||
private final SaveAllCommandBuilder builderSaveAll = new SaveAllCommandBuilder();
|
||||
private final SaveOnCommandBuilder builderSaveOn = new SaveOnCommandBuilder();
|
||||
private final SaveOffCommandBuilder builderSaveOff = new SaveOffCommandBuilder();
|
||||
private final StopCommandBuilder builderStop = new StopCommandBuilder();
|
||||
private final WhitelistCommandBuilder builderWhitelist = new WhitelistCommandBuilder();
|
||||
|
||||
private final BuilderMultiCommand builderKickBan = new BuilderMultiCommand(this.builderKick, this.builderBan);
|
||||
private final BuilderMultiCommand builderPermissions = new BuilderMultiCommand(this.builderOp, this.builderDeop);
|
||||
private final BuilderMultiCommand builderRuntime = new BuilderMultiCommand(this.builderSaveAll, this.builderSaveOn, this.builderSaveOff, this.builderStop);
|
||||
private final CommandPreview previewKickBan = new CommandPreview()
|
||||
.add(this.builderKick, KickCommandBuilder.Label.KICK)
|
||||
.add(this.builderBan, BanCommandBuilder.Label.BAN);
|
||||
private final CommandPreview previewPardon = new CommandPreview(this.builderPardon, PardonCommandBuilder.Label.PARDON);
|
||||
private final CommandPreview previewPermissions = new CommandPreview()
|
||||
.add(this.builderOp, OpCommandBuilder.Label.OP)
|
||||
.add(this.builderDeop, DeOpCommandBuilder.Label.DEOP);
|
||||
private final CommandPreview previewRuntime = new CommandPreview()
|
||||
.add(this.builderSaveAll, SaveAllCommandBuilder.Label.SAVE_ALL)
|
||||
.add(this.builderSaveOn, SaveOnCommandBuilder.Label.SAVE_ON)
|
||||
.add(this.builderSaveOff, SaveOffCommandBuilder.Label.SAVE_OFF)
|
||||
.add(this.builderStop, StopCommandBuilder.Label.STOP);
|
||||
private final CommandPreview previewWhitelist = new CommandPreview(this.builderWhitelist, null);
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
public CommandPreview getCommandPreview()
|
||||
{
|
||||
if(Page.KICK_AND_BAN.equals(this.page))
|
||||
{
|
||||
return this.builderKickBan;
|
||||
return this.previewKickBan;
|
||||
}
|
||||
else if(Page.PARDON.equals(this.page))
|
||||
{
|
||||
return this.builderPardon;
|
||||
return this.previewPardon;
|
||||
}
|
||||
else if(Page.PERMISSIONS.equals(this.page))
|
||||
{
|
||||
return this.builderPermissions;
|
||||
return this.previewPermissions;
|
||||
}
|
||||
else if(Page.RUNTIME.equals(this.page))
|
||||
{
|
||||
return this.builderRuntime;
|
||||
return this.previewRuntime;
|
||||
}
|
||||
else if(Page.WHITELIST.equals(this.page))
|
||||
{
|
||||
return this.builderWhitelist;
|
||||
return this.previewWhitelist;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -83,7 +96,7 @@ public class ContentMultiplayer extends Content
|
||||
this.playerField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.username"));
|
||||
this.playerField.setFilter(Predicates.notNull());
|
||||
this.playerField.setFocus(false);
|
||||
this.playerField.setValue(this.builderKick.getPlayer());
|
||||
this.playerField.setValue(this.builderKick.targets().getTarget());
|
||||
this.playerField.setMaxLength(16);
|
||||
this.playerField.setResponder(text ->
|
||||
{
|
||||
@@ -94,7 +107,7 @@ public class ContentMultiplayer extends Content
|
||||
this.reasonField = new GuiTextFieldTooltip(x + 118, y + 24 + this.page.getShift(), 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.kick_ban.reason"));
|
||||
this.reasonField.setFilter(Predicates.notNull());
|
||||
this.reasonField.setFocus(false);
|
||||
this.reasonField.setValue(this.builderKick.getReason());
|
||||
this.reasonField.setValue(this.builderKick.reason().get());
|
||||
this.reasonField.setResponder(text ->
|
||||
{
|
||||
this.setReason(this.reasonField.getValue());
|
||||
@@ -145,13 +158,13 @@ public class ContentMultiplayer extends Content
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(this.reasonField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.kick"), new TextComponent(this.builderKick.toActualCommand()), () ->
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.kick"), new TextComponent(this.builderKick.toCommand(KickCommandBuilder.Label.KICK_REASON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderKick);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderKick, KickCommandBuilder.Label.KICK_REASON);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.ban"), new TextComponent(this.builderBan.toActualCommand()), () ->
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.ban"), new TextComponent(this.builderBan.toCommand(BanCommandBuilder.Label.BAN_REASON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderBan);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderBan, BanCommandBuilder.Label.BAN_REASON);
|
||||
}));
|
||||
|
||||
if(this.playerField.getValue().isEmpty())
|
||||
@@ -165,9 +178,9 @@ public class ContentMultiplayer extends Content
|
||||
else if(Page.PARDON.equals(this.page))
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.pardon"), new TextComponent(this.builderPardon.toActualCommand()), () ->
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.pardon"), new TextComponent(this.builderPardon.toCommand(PardonCommandBuilder.Label.PARDON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderPardon);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderPardon, PardonCommandBuilder.Label.PARDON);
|
||||
}));
|
||||
|
||||
if(this.playerField.getValue().isEmpty())
|
||||
@@ -180,13 +193,13 @@ public class ContentMultiplayer extends Content
|
||||
else if(Page.PERMISSIONS.equals(this.page))
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 24 + 12, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.permissions.give"), new TextComponent(this.builderOp.toActualCommand()), () ->
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 24 + 12, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.permissions.give"), new TextComponent(this.builderOp.toCommand(OpCommandBuilder.Label.OP, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderOp);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderOp, OpCommandBuilder.Label.OP);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 48 + 12, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.permissions.take"), new TextComponent(this.builderDeop.toActualCommand()), () ->
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 48 + 12, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.permissions.take"), new TextComponent(this.builderDeop.toCommand(DeOpCommandBuilder.Label.DEOP, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderDeop);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderDeop, DeOpCommandBuilder.Label.DEOP);
|
||||
}));
|
||||
|
||||
if(this.playerField.getValue().isEmpty())
|
||||
@@ -199,21 +212,21 @@ public class ContentMultiplayer extends Content
|
||||
}
|
||||
else if(Page.RUNTIME.equals(this.page))
|
||||
{
|
||||
container.add(new GuiButtonTooltip(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.save_world"), new TextComponent(this.builderSaveAll.toActualCommand()), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.save_world"), new TextComponent(this.builderSaveAll.toCommand(SaveAllCommandBuilder.Label.SAVE_ALL, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSaveAll);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSaveAll, SaveAllCommandBuilder.Label.SAVE_ALL);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.autosave", new TranslatableComponent("gui.worldhandler.generic.on")), new TextComponent(this.builderSaveOn.toActualCommand()), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 24, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.autosave", new TranslatableComponent("gui.worldhandler.generic.on")), new TextComponent(this.builderSaveOn.toCommand(SaveOnCommandBuilder.Label.SAVE_ON, false)), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSaveOn);
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderSaveOn, SaveOnCommandBuilder.Label.SAVE_ON);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.autosave", new TranslatableComponent("gui.worldhandler.generic.off")).withStyle(ChatFormatting.RED), new TextComponent(this.builderSaveOff.toActualCommand()), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.autosave", new TranslatableComponent("gui.worldhandler.generic.off")).withStyle(ChatFormatting.RED), new TextComponent(this.builderSaveOff.toCommand(SaveOffCommandBuilder.Label.SAVE_OFF, false)), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderSaveOff));
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderSaveOff, SaveOffCommandBuilder.Label.SAVE_OFF));
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.stop_server").withStyle(ChatFormatting.RED), new TextComponent(this.builderStop.toActualCommand()), () ->
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.runtime.stop_server").withStyle(ChatFormatting.RED), new TextComponent(this.builderStop.toCommand(StopCommandBuilder.Label.STOP, false)), () ->
|
||||
{
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderStop));
|
||||
ActionHelper.open(Contents.CONTINUE.withBuilder(this.builderStop, StopCommandBuilder.Label.STOP));
|
||||
}));
|
||||
|
||||
button4.active = false;
|
||||
@@ -223,25 +236,25 @@ public class ContentMultiplayer extends Content
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonBase(x + 118, y + 24, 44, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist.build(EnumMode.ADD));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.ADD);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonBase(x + 118 + 47, y + 24, 44, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist.build(EnumMode.REMOVE));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.REMOVE);
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.whitelist", new TranslatableComponent("gui.worldhandler.generic.on")), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist.build(EnumMode.ON));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.ON);
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.whitelist", new TranslatableComponent("gui.worldhandler.generic.off")), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist.build(EnumMode.OFF));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.OFF);
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonIcon(x + 232 - 20, y + 24, 20, 20, EnumIcon.RELOAD, new TranslatableComponent("gui.worldhandler.multiplayer.whitelist.reload"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist.build(EnumMode.RELOAD));
|
||||
CommandHelper.sendCommand(container.getPlayer(), this.builderWhitelist, WhitelistCommandBuilder.Label.RELOAD);
|
||||
}));
|
||||
|
||||
if(this.playerField.getValue().isEmpty())
|
||||
@@ -284,20 +297,18 @@ public class ContentMultiplayer extends Content
|
||||
|
||||
private void setPlayer(String player)
|
||||
{
|
||||
this.builderBan.setPlayer(player);
|
||||
this.builderKick.setPlayer(player);
|
||||
|
||||
this.builderPardon.setPlayer(player);
|
||||
this.builderOp.setPlayer(player);
|
||||
this.builderDeop.setPlayer(player);
|
||||
|
||||
this.builderWhitelist.setPlayer(player);
|
||||
this.builderBan.targets().setTarget(player);
|
||||
this.builderKick.targets().setTarget(player);
|
||||
this.builderPardon.targets().setTarget(player);
|
||||
this.builderOp.targets().setTarget(player);
|
||||
this.builderDeop.targets().setTarget(player);
|
||||
this.builderWhitelist.targets().setTarget(player);
|
||||
}
|
||||
|
||||
private void setReason(String reason)
|
||||
{
|
||||
this.builderBan.setReason(reason);
|
||||
this.builderKick.setReason(reason);
|
||||
this.builderBan.reason().set(reason);
|
||||
this.builderKick.reason().set(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user