mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 13:15:44 +01:00
Don't use adventure-platform on Sponge (#2822)
This commit is contained in:
parent
6c34da6b32
commit
0a92597767
@ -25,7 +25,7 @@ dependencies {
|
||||
exclude(module: 'configurate-gson')
|
||||
exclude(module: 'configurate-yaml')
|
||||
}
|
||||
compileOnly 'me.lucko:adventure-platform-spongeapi:4.0.0' // re: this artifact - see note in common/build.gradle
|
||||
//compileOnly 'me.lucko:adventure-platform-spongeapi:4.0.0' // re: this artifact - see note in common/build.gradle
|
||||
}
|
||||
|
||||
blossom {
|
||||
|
@ -116,7 +116,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
protected Set<Dependency> getGlobalDependencies() {
|
||||
Set<Dependency> dependencies = super.getGlobalDependencies();
|
||||
dependencies.add(Dependency.ADVENTURE_PLATFORM);
|
||||
dependencies.add(Dependency.ADVENTURE_PLATFORM_SPONGEAPI);
|
||||
//dependencies.add(Dependency.ADVENTURE_PLATFORM_SPONGEAPI);
|
||||
dependencies.add(Dependency.CONFIGURATE_CORE);
|
||||
dependencies.add(Dependency.CONFIGURATE_HOCON);
|
||||
dependencies.add(Dependency.HOCON_CONFIG);
|
||||
|
@ -25,25 +25,25 @@
|
||||
|
||||
package me.lucko.luckperms.sponge;
|
||||
|
||||
import me.lucko.luckperms.common.locale.TranslationManager;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||
import me.lucko.luckperms.sponge.service.CompatibilityUtil;
|
||||
|
||||
import net.kyori.adventure.platform.spongeapi.SpongeAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.luckperms.api.util.Tristate;
|
||||
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeSenderFactory extends SenderFactory<LPSpongePlugin, CommandSource> {
|
||||
private final SpongeAudiences audiences;
|
||||
|
||||
public SpongeSenderFactory(LPSpongePlugin plugin) {
|
||||
super(plugin);
|
||||
this.audiences = SpongeAudiences.create(plugin.getBootstrap().getPluginContainer(), plugin.getBootstrap().getGame());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +64,7 @@ public class SpongeSenderFactory extends SenderFactory<LPSpongePlugin, CommandSo
|
||||
|
||||
@Override
|
||||
protected void sendMessage(CommandSource source, Component message) {
|
||||
this.audiences.receiver(source).sendMessage(message);
|
||||
source.sendMessage(toNativeText(TranslationManager.render(message, source.getLocale())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,9 +89,8 @@ public class SpongeSenderFactory extends SenderFactory<LPSpongePlugin, CommandSo
|
||||
getPlugin().getBootstrap().getGame().getCommandManager().process(source, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
this.audiences.close();
|
||||
public static Text toNativeText(Component component) {
|
||||
return TextSerializers.JSON.deserialize(GsonComponentSerializer.gson().serialize(component));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,9 +31,9 @@ import me.lucko.luckperms.common.locale.TranslationManager;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
||||
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||
import me.lucko.luckperms.sponge.SpongeSenderFactory;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.spongeapi.SpongeComponentSerializer;
|
||||
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.Order;
|
||||
@ -100,7 +100,7 @@ public class SpongeConnectionListener extends AbstractConnectionListener {
|
||||
e.setCancelled(true);
|
||||
e.setMessageCancelled(false);
|
||||
Component reason = TranslationManager.render(Message.LOADING_DATABASE_ERROR.build());
|
||||
e.setMessage(SpongeComponentSerializer.get().serialize(reason));
|
||||
e.setMessage(SpongeSenderFactory.toNativeText(reason));
|
||||
this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(profile.getUniqueId(), username, null);
|
||||
}
|
||||
}
|
||||
@ -154,7 +154,7 @@ public class SpongeConnectionListener extends AbstractConnectionListener {
|
||||
e.setCancelled(true);
|
||||
e.setMessageCancelled(false);
|
||||
Component reason = TranslationManager.render(Message.LOADING_STATE_ERROR.build());
|
||||
e.setMessage(SpongeComponentSerializer.get().serialize(reason));
|
||||
e.setMessage(SpongeSenderFactory.toNativeText(reason));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user