forked from EssentialsX/Essentials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NoClassDefFoundError on < 1.12 with Discord execute command (Esse…
- Loading branch information
Showing
2 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...Providers/src/main/java/net/ess3/provider/providers/ModernCommandSenderSpigotCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
}; | ||
} | ||
} |