Skip to content

Commit

Permalink
* Removed Config.java and replaced with FileManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Hempfest committed Mar 24, 2021
1 parent 244cd40 commit 9e43f21
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 50 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/github/sanctum/labyrinth/data/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ synchronized public void saveConfig() {
}
}

/**
* Save the configuration to its backing file then immediately reload changes.
*
* @throws IllegalStateException if an error is encountered while saving
*/
synchronized public void refreshConfig() {
saveConfig();
reload();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.github.sanctum.labyrinth.formatting.component;

import com.github.sanctum.labyrinth.formatting.string.ColoredString;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;

public class NewComponent {

private static String color(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}

public TextComponent textHoverable(String normalText, String hoverText, String hoverTextMessage) {
TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
text.addExtra(hover);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage)))));
return text;
}

public TextComponent textHoverable(String normalText, String hoverText, String normalText2, String hoverTextMessage) {
TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent();
text.addExtra(hover);
text.addExtra(text2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage)))));
return text;
}

public TextComponent textHoverable(String normalText, String hoverText, String normalText2, String hoverText2, String hoverTextMessage, String hoverText2Message) {
TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover2 = new ColoredString(hoverText2, ColoredString.ColorType.MC_COMPONENT).toComponent();
text.addExtra(hover);
text.addExtra(text2);
text.addExtra(hover2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage)))));
hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverText2Message)))));
return text;
}
// *
//
// SEND TEXT THE PLAYER CAN BE SUGGESTED TO EXECUTE COMMANDS WITH
//

public TextComponent textSuggestable(String normalText, String hoverText, String hoverTextMessage, String commandName) {
TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
text.addExtra(hover);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage)))));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + commandName));
return text;
}
// *
//
// SEND TEXT THE PLAYER CAN RUN COMMANDS WITH
//

public TextComponent textRunnable(String normalText, String hoverText, String hoverTextMessage, String commandName) {
TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
text.addExtra(hover);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString()))));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
return text;
}

public TextComponent textRunnable(String normalText, String hoverText, String normalText2, String hoverTextMessage, String commandName) {
TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent();
text.addExtra(hover);
text.addExtra(text2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString()))));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
return text;
}

public TextComponent textRunnable(String normalText, String hoverText, String normalText2, String hoverText2, String hoverTextMessage, String hoverText2Message, String commandName, String commandName2) {
TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover2 = new ColoredString(hoverText2, ColoredString.ColorType.MC_COMPONENT).toComponent();
text.addExtra(hover);
text.addExtra(text2);
text.addExtra(hover2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString()))));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverText2Message, ColoredString.ColorType.HEX).toString()))));
hover2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName2));
return text;
}

public TextComponent textRunnable(String hoverText, String hoverText2, String hoverTextBody3, String hoverTextMessage, String hoverText2Message, String hoverMessage3, String commandName, String commandName2, String commandName3) {
TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover2 = new ColoredString(hoverText2, ColoredString.ColorType.MC_COMPONENT).toComponent();
TextComponent hover3 = new ColoredString(hoverTextBody3, ColoredString.ColorType.MC_COMPONENT).toComponent();
hover.addExtra(hover2);
hover.addExtra(hover3);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString()))));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverText2Message, ColoredString.ColorType.HEX).toString()))));
hover2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName2));
hover3.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverMessage3, ColoredString.ColorType.HEX).toString()))));
hover3.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName3));
return hover;
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.github.sanctum.labyrinth.formatting.component;


import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;

public class OldComponent {

private String color(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}

public TextComponent textHoverable(String normalText, String hoverText, String hoverTextMessage) {
TextComponent text = new TextComponent(color(normalText));
TextComponent hover = new TextComponent(color(hoverText));
text.addExtra(hover);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
return text;
}

public TextComponent textHoverable(String normalText, String hoverText, String normalText2, String hoverTextMessage) {
TextComponent text = new TextComponent(color(normalText));
TextComponent hover = new TextComponent(color(hoverText));
TextComponent text2 = new TextComponent(color(normalText2));
text.addExtra(hover);
text.addExtra(text2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
return text;
}

public TextComponent textHoverable(String normalText, String hoverText, String normalText2, String hoverText2, String hoverTextMessage, String hoverText2Message) {
TextComponent text = new TextComponent(color(normalText));
TextComponent hover = new TextComponent(color(hoverText));
TextComponent text2 = new TextComponent(color(normalText2));
TextComponent hover2 = new TextComponent(color(hoverText2));
text.addExtra(hover);
text.addExtra(text2);
text.addExtra(hover2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverText2Message)).create()));
return text;
}

public TextComponent textSuggestable(String normalText, String hoverText, String hoverTextMessage, String commandName) {
TextComponent text = new TextComponent(color(normalText));
TextComponent hover = new TextComponent(color(hoverText));
text.addExtra(hover);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + commandName));
return text;
}

public TextComponent textRunnable(String normalText, String hoverText, String hoverTextMessage, String commandName) {
TextComponent text = new TextComponent(color(normalText));
TextComponent hover = new TextComponent(color(hoverText));
text.addExtra(hover);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
return text;
}

public TextComponent textRunnable(String normalText, String hoverText, String normalText2, String hoverTextMessage, String commandName) {
TextComponent text = new TextComponent(color(normalText));
TextComponent hover = new TextComponent(color(hoverText));
TextComponent text2 = new TextComponent(color(normalText2));
text.addExtra(hover);
text.addExtra(text2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
return text;
}

public TextComponent textRunnable(String normalText, String hoverText, String normalText2, String hoverText2, String hoverTextMessage, String hoverText2Message, String commandName, String commandName2) {
TextComponent text = new TextComponent(color(normalText));
TextComponent hover = new TextComponent(color(hoverText));
TextComponent text2 = new TextComponent(color(normalText2));
TextComponent hover2 = new TextComponent(color(hoverText2));
text.addExtra(hover);
text.addExtra(text2);
text.addExtra(hover2);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverText2Message)).create()));
hover2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName2));
return text;
}

public TextComponent textRunnable(String hoverText, String hoverText2, String hoverTextBody3, String hoverTextMessage, String hoverText2Message, String hoverMessage3, String commandName, String commandName2, String commandName3) {
TextComponent hover = new TextComponent(color(hoverText));
TextComponent hover2 = new TextComponent(color(hoverText2));
TextComponent hover3 = new TextComponent(color(hoverTextBody3));
hover.addExtra(hover2);
hover.addExtra(hover3);
hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverTextMessage)).create()));
hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName));
hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverText2Message)).create()));
hover2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName2));
hover3.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color(hoverMessage3)).create()));
hover3.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName3));
return hover;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;

/**
* @deprecated Replaced by {@link NewComponent}
*/
public class Text {

private static String color(String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;

/**
* @deprecated Replaced by {@link OldComponent}
*/
public class Text_R2 {

private static String color(String text) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/sanctum/labyrinth/gui/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.List;

/**
* @deprecated Fully replaced by functional menu builder.
* @deprecated Fully replaced by {@link com.github.sanctum.labyrinth.gui.menuman.Menu}
*/
@Deprecated
public abstract class Menu implements InventoryHolder {
Expand Down

0 comments on commit 9e43f21

Please sign in to comment.