[WIP] Initial abstraction layer work
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.hypherionmc.craterlib.core.abstraction.commands;
|
||||
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
public class AbstractCommand {
|
||||
|
||||
public static void replySuccess(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
||||
stack.getSource().sendSuccess(() -> message, false);
|
||||
}
|
||||
|
||||
public static void replyFailure(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
||||
stack.getSource().sendFailure(message);
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.hypherionmc.craterlib.core.abstraction.server;
|
||||
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class AbstractFakePlayer extends CommandSourceStack {
|
||||
|
||||
private final UUID uuid;
|
||||
|
||||
public AbstractFakePlayer(MinecraftServer server, String name, MutableComponent displayName, UUID uuid) {
|
||||
super(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, server.overworld(), 4, name, displayName, server, null);
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void onSuccess(Component component, boolean bl) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSuccess(Supplier<Component> component, boolean bl) {
|
||||
this.onSuccess(component.get(), bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFailure(Component component) {
|
||||
sendSuccess(() -> component, false);
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.hypherionmc.craterlib.core.abstraction.server;
|
||||
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class AbstractServer {
|
||||
|
||||
public static void broadcastMessage(MinecraftServer server, MutableComponent message) {
|
||||
server.getPlayerList().broadcastSystemMessage(message, false);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.hypherionmc.craterlib.core.abstraction.text;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
public class AbstractComponent {
|
||||
|
||||
public static MutableComponent literal(String component) {
|
||||
return Component.literal(component);
|
||||
}
|
||||
|
||||
public static MutableComponent translatable(String component) {
|
||||
return Component.translatable(component);
|
||||
}
|
||||
|
||||
public static Component safeCopy(Component inComponent) {
|
||||
String value = inComponent.getString();
|
||||
Style style = inComponent.getStyle();
|
||||
return Component.literal(value).withStyle(style);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user