mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 15:08:18 +01:00
Fix NoClassDefFoundError on < 1.12 with Discord execute command (#4478)
This commit is contained in:
parent
df88a89c14
commit
69850d82c8
@ -1,7 +1,5 @@
|
||||
package net.ess3.provider.providers;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -60,27 +58,13 @@ public class BukkitSenderProvider implements CommandSender {
|
||||
|
||||
@Override
|
||||
public Spigot spigot() {
|
||||
return new Spigot() {
|
||||
@Override
|
||||
public void sendMessage(BaseComponent component) {
|
||||
BukkitSenderProvider.this.sendMessage(component.toLegacyText());
|
||||
try {
|
||||
Class.forName("org.bukkit.command.CommandSender$Spigot");
|
||||
return ModernCommandSenderSpigotCreator.stupidDumbHackToMakeTheJvmHappy(this);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
//noinspection ConstantConditions
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent... components) {
|
||||
sendMessage(new TextComponent(components));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(UUID sender, BaseComponent... components) {
|
||||
sendMessage(components);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(UUID sender, BaseComponent component) {
|
||||
sendMessage(component);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,40 @@
|
||||
package net.ess3.provider.providers;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ModernCommandSenderSpigotCreator {
|
||||
private ModernCommandSenderSpigotCreator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The JVM will FOR SOME REASON try to load inner classes even BEFORE THE CODE WHICH REFERENCE THEM IS CALLED.
|
||||
* This dumbass hack postpones the class lookup to until we know for sure the class exists.
|
||||
*/
|
||||
public static CommandSender.Spigot stupidDumbHackToMakeTheJvmHappy(BukkitSenderProvider provider) {
|
||||
return new CommandSender.Spigot() {
|
||||
@Override
|
||||
public void sendMessage(BaseComponent component) {
|
||||
provider.sendMessage(component.toLegacyText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent... components) {
|
||||
sendMessage(new TextComponent(components));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(UUID sender, BaseComponent... components) {
|
||||
sendMessage(components);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(UUID sender, BaseComponent component) {
|
||||
sendMessage(component);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user