mirror of
https://github.com/LOOHP/Limbo.git
synced 2026-06-08 05:51:43 +00:00
Re-structure + Adventure
This commit is contained in:
@@ -2,9 +2,18 @@ package com.loohp.limbo.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.inventory.Book;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.sound.SoundStop;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.TitlePart;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
public interface CommandSender {
|
||||
public interface CommandSender extends Audience {
|
||||
|
||||
public void sendMessage(BaseComponent[] component, UUID uuid);
|
||||
|
||||
@@ -21,5 +30,31 @@ public interface CommandSender {
|
||||
public boolean hasPermission(String permission);
|
||||
|
||||
public String getName();
|
||||
|
||||
public void sendMessage(Identity source, Component message, MessageType type);
|
||||
|
||||
public void openBook(Book book);
|
||||
|
||||
public void stopSound(SoundStop stop);
|
||||
|
||||
public void playSound(Sound sound, Sound.Emitter emitter);
|
||||
|
||||
public void playSound(Sound sound, double x, double y, double z);
|
||||
|
||||
public void playSound(Sound sound);
|
||||
|
||||
public void sendActionBar(Component message);
|
||||
|
||||
public void sendPlayerListHeaderAndFooter(Component header, Component footer);
|
||||
|
||||
public <T> void sendTitlePart(TitlePart<T> part, T value);
|
||||
|
||||
public void clearTitle();
|
||||
|
||||
public void resetTitle();
|
||||
|
||||
public void showBossBar(BossBar bar);
|
||||
|
||||
public void hideBossBar(BossBar bar);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,9 @@ import com.loohp.limbo.Limbo;
|
||||
import com.loohp.limbo.player.Player;
|
||||
import com.loohp.limbo.utils.GameMode;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
|
||||
public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||
|
||||
@@ -55,7 +54,7 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||
|
||||
if (args[0].equalsIgnoreCase("kick")) {
|
||||
if (sender.hasPermission("limboserver.kick")) {
|
||||
BaseComponent reason = new TranslatableComponent("multiplayer.disconnect.kicked");
|
||||
Component reason = Component.translatable("multiplayer.disconnect.kicked");
|
||||
boolean customReason = false;
|
||||
if (args.length > 1) {
|
||||
Player player = Limbo.getInstance().getPlayer(args[1]);
|
||||
@@ -63,13 +62,13 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||
if (args.length >= 2) {
|
||||
String reasonRaw = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||
if (reasonRaw.trim().length() > 0) {
|
||||
reason = new TextComponent(reasonRaw);
|
||||
reason = LegacyComponentSerializer.legacySection().deserialize(reasonRaw);
|
||||
customReason = true;
|
||||
}
|
||||
}
|
||||
player.disconnect(reason);
|
||||
if (customReason) {
|
||||
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName() + " for the reason: " + reason.toLegacyText());
|
||||
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName() + " for the reason: " + LegacyComponentSerializer.legacySection().serialize(reason));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user