Advertisement
TNT_Block

ChatUtils

Jul 7th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. package de.cryptonicdev.cryptonicclient.utils;
  2.  
  3. import de.cryptonicdev.cryptonicclient.commands.types.DefaultUssageCommand;
  4. import de.cryptonicdev.cryptonicclient.commands.types.NoDescriptionWithUssageCommand;
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.util.ChatComponentText;
  7. import net.minecraft.util.IChatComponent;
  8.  
  9. public class ChatUtils {
  10.  
  11. public void printJson(String json) {
  12. Minecraft.getMinecraft().ingameGUI.getChatGUI()
  13. .printChatMessage(IChatComponent.Serializer.jsonToComponent(json));
  14. }
  15.  
  16. public void sendMessage(String message) {
  17. Minecraft.getMinecraft().ingameGUI.getChatGUI()
  18. .printChatMessage(new ChatComponentText("§9[§1Cryptonic§9] §f" + message));
  19. }
  20.  
  21. public void reportError(Exception e) {
  22. try {
  23. this.sendMessage("§4ERROR: §f" + e.toString());
  24. } catch (Exception ex) {
  25. }
  26. }
  27.  
  28. public void throwCreative() {
  29. sendMessage("Du musst im Kreativmodus sein!");
  30. }
  31.  
  32. public void throwItemSuccessfullyCreated() {
  33. sendMessage("Du hast das Item erhalten!");
  34. }
  35.  
  36. public void throwItemNotExists() {
  37. sendMessage("Dieses Item/ Block existiert nicht!");
  38. }
  39.  
  40. public void throwException(Exception e) {
  41. sendMessage("§4ERROR: §f" + e.getMessage());
  42. }
  43.  
  44. public void throwUssage(NoDescriptionWithUssageCommand cmd) {
  45. String usg = "";
  46. for (int i = 0; i < cmd.getUssages().length; i++) {
  47. usg = usg + "<" + cmd.getUssages()[i] + ">";
  48. if (i != cmd.getUssages().length - 1) {
  49. usg += " ";
  50. }
  51. }
  52. sendMessage("Nutzung: #" + cmd.getName() + " " + usg);
  53. }
  54. public void throwUssage(DefaultUssageCommand cmd) {
  55. String usg = "";
  56. for (int i = 0; i < cmd.getUssages().length; i++) {
  57. usg = usg + "<" + cmd.getUssages()[i] + ">";
  58. if (i != cmd.getUssages().length - 1) {
  59. usg += " ";
  60. }
  61. }
  62. sendMessage("Nutzung: #" + cmd.getName() + " " + usg);
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement