Advertisement
TNT_Block

ChatManager

Sep 25th, 2019
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. package de.cryptonicdev.cryptonic.chat;
  2.  
  3. import de.cryptonicdev.cryptonic.commands.Command;
  4. import net.minecraft.client.Minecraft;
  5. import net.minecraft.event.ClickEvent;
  6. import net.minecraft.event.ClickEvent.Action;
  7. import net.minecraft.event.HoverEvent;
  8. import net.minecraft.util.ChatComponentText;
  9. import net.minecraft.util.ChatStyle;
  10. import net.minecraft.util.EnumChatFormatting;
  11. import net.minecraft.util.IChatComponent;
  12.  
  13. public class ChatManager {
  14. private boolean enabled = true;
  15.  
  16. public void setEnabled(boolean enabled) {
  17. this.enabled = enabled;
  18. }
  19.  
  20. public void component(final IChatComponent component) {
  21. if (enabled)
  22. Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(
  23. new ChatComponentText("§e§kii§6 Cryptonic §e§kii§7 » §r").appendSibling(component));
  24. }
  25.  
  26. public void throwCreative() {
  27. sendMessage("§cDu musst im Kreativmodus sein.");
  28. }
  29.  
  30. public void throwSyntax(Command command) {
  31. ChatComponentText component = new ChatComponentText("§cFalsche Parameter! ");
  32. ChatComponentText clickText = new ChatComponentText("§b<Klick für Hilfe>");
  33. clickText.setChatStyle(
  34. new ChatStyle().setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "#help " + command.getCommand()))
  35. .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
  36. new ChatComponentText("#help " + command.getCommand())
  37. .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)))));
  38. component.appendSibling(clickText);
  39. component(component);
  40. }
  41.  
  42. public void syntaxError(String message) {
  43. sendMessage("§4Syntax-Fehler: §f" + message);
  44. }
  45.  
  46. public void sendMessage(String message, EnumChatFormatting color, boolean bold) {
  47. component(new ChatComponentText(message).setChatStyle(new ChatStyle().setColor(color).setBold(bold)));
  48. }
  49.  
  50. public void sendMessage(String message) {
  51. component(new ChatComponentText(message));
  52. }
  53.  
  54. public void info(String message) {
  55. sendMessage("§8[§7§lINFO§8]§f " + message);
  56. }
  57.  
  58. public void debug(String message) {
  59. sendMessage("§8[§7§lDEBUG-INFO§8]§f " + message);
  60. }
  61.  
  62. public void warning(String message) {
  63. sendMessage("§c[§6§lWARNING§c]§f " + message);
  64. }
  65.  
  66. public void error(String message) {
  67. sendMessage("§c[§4§lERROR§c]§f " + message);
  68. }
  69.  
  70. public void success(String message) {
  71. sendMessage("§a[§2§lSUCCESS§a]§f " + message);
  72. }
  73.  
  74. public void failure(String message) {
  75. sendMessage("§c[§4§lFAILURE§c]§f " + message);
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement