mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-22 16:18:32 +00:00
Updated Cloud dependency to v2
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package com.dfsek.terra.addons.commands.addons;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
@@ -12,6 +9,9 @@ import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.description.Description;
|
||||
|
||||
|
||||
public class AddonsCommandAddon implements AddonInitializer {
|
||||
@Inject
|
||||
@@ -30,7 +30,7 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
|
||||
manager.command(
|
||||
manager.commandBuilder("addons", ArgumentDescription.of("List installed Terra addons"))
|
||||
manager.commandBuilder("addons", Description.of("List installed Terra addons"))
|
||||
.permission("terra.addons")
|
||||
.handler(context -> {
|
||||
StringBuilder addons = new StringBuilder("Installed addons:\n");
|
||||
@@ -41,7 +41,7 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
.append('@')
|
||||
.append(addon.getVersion().getFormatted())
|
||||
.append('\n'));
|
||||
context.getSender().sendMessage(addons.toString());
|
||||
context.sender().sendMessage(addons.toString());
|
||||
})
|
||||
)
|
||||
.command(
|
||||
@@ -61,7 +61,7 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
.append('@')
|
||||
.append(versions.getFormatted())
|
||||
.append('\n'));
|
||||
context.getSender().sendMessage(addonInfo.toString());
|
||||
context.sender().sendMessage(addonInfo.toString());
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.commands.packs;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.description.Description;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PacksCommandAddon implements AddonInitializer {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
|
||||
manager.command(
|
||||
manager.commandBuilder("packs", ArgumentDescription.of("List installed config packs"))
|
||||
manager.commandBuilder("packs", Description.of("List installed config packs"))
|
||||
.permission("terra.packs")
|
||||
.handler(context -> {
|
||||
StringBuilder packs = new StringBuilder("Installed packs:\n");
|
||||
@@ -43,12 +43,12 @@ public class PacksCommandAddon implements AddonInitializer {
|
||||
.append(pack.getID())
|
||||
.append('@')
|
||||
.append(pack.getVersion().getFormatted()));
|
||||
context.getSender().sendMessage(packs.toString());
|
||||
context.sender().sendMessage(packs.toString());
|
||||
})
|
||||
)
|
||||
.command(
|
||||
manager.commandBuilder("packs")
|
||||
.literal("info", ArgumentDescription.of("Get information about a pack"))
|
||||
.literal("info", Description.of("Get information about a pack"))
|
||||
.permission("terra.packs.info")
|
||||
.argument(RegistryArgument.of("pack", platform.getConfigRegistry()))
|
||||
.handler(context -> {
|
||||
@@ -65,21 +65,21 @@ public class PacksCommandAddon implements AddonInitializer {
|
||||
.append('@')
|
||||
.append(versions.getFormatted())
|
||||
.append('\n'));
|
||||
context.getSender().sendMessage(packInfo.toString());
|
||||
context.sender().sendMessage(packInfo.toString());
|
||||
}))
|
||||
.command(
|
||||
manager.commandBuilder("packs")
|
||||
.literal("reload", ArgumentDescription.of("Reload config packs"))
|
||||
.literal("reload", Description.of("Reload config packs"))
|
||||
.permission("terra.packs.reload")
|
||||
.handler(context -> {
|
||||
context.getSender().sendMessage("Reloading Terra...");
|
||||
context.sender().sendMessage("Reloading Terra...");
|
||||
logger.info("Reloading Terra...");
|
||||
if(platform.reload()) {
|
||||
logger.info("Terra reloaded successfully.");
|
||||
context.getSender().sendMessage("Terra reloaded successfully.");
|
||||
context.sender().sendMessage("Terra reloaded successfully.");
|
||||
} else {
|
||||
logger.error("Terra failed to reload.");
|
||||
context.getSender().sendMessage(
|
||||
context.sender().sendMessage(
|
||||
"Terra failed to reload. See logs for more information.");
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.commands.profiler;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.description.Description;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -33,24 +33,24 @@ public class ProfilerCommandAddon implements AddonInitializer {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
manager
|
||||
.command(
|
||||
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
|
||||
.literal("start", ArgumentDescription.of("Start profiling"), "st")
|
||||
manager.commandBuilder("profiler", Description.of("Access the profiler"))
|
||||
.literal("start", Description.of("Start profiling"), "st")
|
||||
.permission("terra.profiler.start")
|
||||
.handler(context -> {
|
||||
platform.getProfiler().start();
|
||||
context.getSender().sendMessage("Profiling started.");
|
||||
context.sender().sendMessage("Profiling started.");
|
||||
}))
|
||||
.command(
|
||||
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
|
||||
.literal("stop", ArgumentDescription.of("Stop profiling"), "s")
|
||||
manager.commandBuilder("profiler", Description.of("Access the profiler"))
|
||||
.literal("stop", Description.of("Stop profiling"), "s")
|
||||
.permission("terra.profiler.stop")
|
||||
.handler(context -> {
|
||||
platform.getProfiler().stop();
|
||||
context.getSender().sendMessage("Profiling stopped.");
|
||||
context.sender().sendMessage("Profiling stopped.");
|
||||
}))
|
||||
.command(
|
||||
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
|
||||
.literal("query", ArgumentDescription.of("Query profiler results"), "q")
|
||||
manager.commandBuilder("profiler", Description.of("Access the profiler"))
|
||||
.literal("query", Description.of("Query profiler results"), "q")
|
||||
.permission("terra.profiler.query")
|
||||
.handler(context -> {
|
||||
StringBuilder data = new StringBuilder("Terra Profiler data: \n");
|
||||
@@ -59,15 +59,15 @@ public class ProfilerCommandAddon implements AddonInitializer {
|
||||
.append(timings.toString())
|
||||
.append('\n'));
|
||||
logger.info(data.toString());
|
||||
context.getSender().sendMessage("Profiling data dumped to console.");
|
||||
context.sender().sendMessage("Profiling data dumped to console.");
|
||||
}))
|
||||
.command(
|
||||
manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
|
||||
.literal("reset", ArgumentDescription.of("Reset the profiler"), "r")
|
||||
manager.commandBuilder("profiler", Description.of("Access the profiler"))
|
||||
.literal("reset", Description.of("Reset the profiler"), "r")
|
||||
.permission("terra.profiler.reset")
|
||||
.handler(context -> {
|
||||
platform.getProfiler().reset();
|
||||
context.getSender().sendMessage("Profiler reset.");
|
||||
context.sender().sendMessage("Profiler reset.");
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package com.dfsek.terra.addons.commands.structure;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.EnumArgument;
|
||||
import cloud.commandframework.arguments.standard.LongArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
@@ -22,6 +16,13 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.component.DefaultValue;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.description.Description;
|
||||
import org.incendo.cloud.parser.standard.EnumParser;
|
||||
import org.incendo.cloud.parser.standard.LongParser;
|
||||
|
||||
|
||||
public class StructureCommandAddon implements AddonInitializer {
|
||||
@Inject
|
||||
@@ -31,7 +32,7 @@ public class StructureCommandAddon implements AddonInitializer {
|
||||
private BaseAddon addon;
|
||||
|
||||
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
|
||||
return sender.getSender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
|
||||
return sender.sender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,16 +44,16 @@ public class StructureCommandAddon implements AddonInitializer {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
|
||||
manager.command(
|
||||
manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures"))
|
||||
manager.commandBuilder("structures", Description.of("Manage or generate structures"))
|
||||
.literal("generate")
|
||||
.argument(RegistryArgument.builder("structure",
|
||||
.optional(RegistryArgument.builder("structure",
|
||||
StructureCommandAddon::getStructureRegistry,
|
||||
TypeKey.of(Structure.class)))
|
||||
.argument(LongArgument.optional("seed", 0))
|
||||
.argument(EnumArgument.optional(Rotation.class, "rotation", Rotation.NONE))
|
||||
.optional("seed", LongParser.longParser(), DefaultValue.constant(0L))
|
||||
.optional("rotation", EnumParser.enumParser(Rotation.class), DefaultValue.constant(Rotation.NONE))
|
||||
.handler(context -> {
|
||||
Structure structure = context.get("structure");
|
||||
Entity sender = context.getSender().getEntity().orElseThrow();
|
||||
Entity sender = context.sender().getEntity().orElseThrow();
|
||||
structure.generate(
|
||||
sender.position().toInt(),
|
||||
sender.world(),
|
||||
|
||||
Reference in New Issue
Block a user