Advertisement
Guest User

FancyTextComponent.java

a guest
Feb 15th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.60 KB | None | 0 0
  1. import YOUR.PACKAGE.HERE.FancyClickEvent;
  2. import YOUR.PACKAGE.HERE.FancyHoverEvent;
  3. import org.bukkit.ChatColor;
  4.  
  5. public class FancyTextComponent {
  6.  
  7.     private String text;
  8.  
  9.     private String color;
  10.  
  11.     private String[] attributes;
  12.  
  13.     private FancyClickEvent clickEvent;
  14.     private FancyHoverEvent hoverEvent;
  15.  
  16.     public final static String bold = "bold";
  17.     public final static String italic = "italic";
  18.     public final static String underlined = "underlined";
  19.     public final static String strikethrough = "strikethrough";
  20.     public final static String obfuscated = "obfuscated";
  21.  
  22.     private FancyTextComponent(String text, String color, FancyClickEvent clickEvent, FancyHoverEvent hoverEvent, String... attributes) {
  23.         this.text = text;
  24.         this.color = color;
  25.         this.clickEvent = clickEvent;
  26.         this.hoverEvent = hoverEvent;
  27.         this.attributes = attributes;
  28.     }
  29.  
  30.     public static FancyTextComponent fancyTextComponent(String text, String... attributes) {
  31.         return new FancyTextComponent(text, "white", null, null, attributes);
  32.     }
  33.  
  34.     public static FancyTextComponent fancyTextComponent(String text, String color, String... attributes) {
  35.         return new FancyTextComponent(text, color, null, null, attributes);
  36.     }
  37.  
  38.     public static FancyTextComponent fancyTextComponent(String text, ChatColor color, String... attributes) {
  39.         return new FancyTextComponent(text, color.name().toLowerCase(), null, null, attributes);
  40.     }
  41.  
  42.     public static FancyTextComponent fancyTextComponent(String text, String color, FancyClickEvent clickEvent, String... attributes) {
  43.         return new FancyTextComponent(text, color, clickEvent, null, attributes);
  44.     }
  45.  
  46.     public static FancyTextComponent fancyTextComponent(String text, ChatColor color, FancyClickEvent clickEvent, String... attributes) {
  47.         return new FancyTextComponent(text, color.name().toLowerCase(), clickEvent, null, attributes);
  48.     }
  49.  
  50.     public static FancyTextComponent fancyTextComponent(String text, String color, FancyHoverEvent hoverEvent, String... attributes) {
  51.         return new FancyTextComponent(text, color, null, hoverEvent, attributes);
  52.     }
  53.  
  54.     public static FancyTextComponent fancyTextComponent(String text, ChatColor color, FancyHoverEvent hoverEvent, String... attributes) {
  55.         return new FancyTextComponent(text, color.name().toLowerCase(), null, hoverEvent, attributes);
  56.     }
  57.  
  58.     public static FancyTextComponent fancyTextComponent(String text, String color, FancyClickEvent clickEvent, FancyHoverEvent hoverEvent, String... attributes) {
  59.         return new FancyTextComponent(text, color, clickEvent, hoverEvent, attributes);
  60.     }
  61.  
  62.     public static FancyTextComponent fancyTextComponent(String text, ChatColor color, FancyClickEvent clickEvent, FancyHoverEvent hoverEvent, String... attributes) {
  63.         return new FancyTextComponent(text, color.name().toLowerCase(), clickEvent, hoverEvent, attributes);
  64.     }
  65.  
  66.  
  67.     public void clearEvents() {
  68.         this.clickEvent = null;
  69.         this.hoverEvent = null;
  70.     }
  71.  
  72.     public String getText() {
  73.         return text;
  74.     }
  75.  
  76.     public String getColor() {
  77.         return color;
  78.     }
  79.  
  80.     public String[] getAttributes() {
  81.         return attributes;
  82.     }
  83.  
  84.     public FancyClickEvent getClickEvent() {
  85.         return clickEvent;
  86.     }
  87.  
  88.     public FancyHoverEvent getHoverEvent() {
  89.         return hoverEvent;
  90.     }
  91.  
  92.     public boolean hasClickEvent() {
  93.         return clickEvent != null;
  94.     }
  95.  
  96.     public boolean hasHoverEvent() {
  97.         return hoverEvent != null;
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement