add HoverModule
add placeholder [nl] for next line
This commit is contained in:
JaTiTV 2022-05-31 21:31:23 +02:00
parent d7cad5524c
commit 066496dea0
5 changed files with 56 additions and 28 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>11.8</version> <version>11.9</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>T2CodeLib</name> <name>T2CodeLib</name>

View File

@ -0,0 +1,39 @@
package net.t2code.lib.Spigot.Lib.messages;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.entity.Player;
public class HoverModule {
public static void module(String text, String hover, String action, String actionValue, Player player) {
module((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null")
+ "/*/" + (actionValue != null ? actionValue : "null"), player);
}
public static void module(String msg, Player player) {
if (!msg.contains("/*/")) {
player.sendMessage(msg);
return;
}
String[] split = msg.split("/\\*/");
int i = split.length;
String text = null;
String hover = null;
String action = null;
String actionValue = null;
if (i > 0) text= split[0];
if (i > 1) hover =split[1];
if (i > 2)action = split[2];
if (i > 3)actionValue = split[3];
TextBuilder textBuilder = new TextBuilder(text);
if (hover != null && !hover.equals("null")) {
textBuilder.addHover(hover);
}
if (action != null && actionValue != null && !action.equals("null") && !actionValue.equals("null")) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(action.toUpperCase()), actionValue);
}
player.spigot().sendMessage(textBuilder.build());
}
}

View File

@ -20,7 +20,7 @@ public class send {
public static void player(Player player, String msg) { public static void player(Player player, String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
player.sendMessage(msg); HoverModule.module(msg,player);
} }
public static void title(Player player, String msg, String msg2) { public static void title(Player player, String msg, String msg2) {

View File

@ -12,14 +12,14 @@ public class Replace {
public static String replace(String prefix, String Text) { public static String replace(String prefix, String Text) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü") return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä"); .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]","\n");
} }
public static String replace(String prefix,Player player, String Text) { public static String replace(String prefix,Player player, String Text) {
return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§") return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")); .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]","\n"));
} }
@ -28,7 +28,7 @@ public class Replace {
for (String input : Text) { for (String input : Text) {
output.add(input.replace("[prefix]", prefix).replace("&", "§") output.add(input.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")); .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]","\n"));
} }
return output; return output;
} }
@ -45,7 +45,7 @@ public class Replace {
for (String input : Text) { for (String input : Text) {
output.add(PlaceholderAPI.setPlaceholders(player, input.replace("[prefix]", prefix).replace("&", "§") output.add(PlaceholderAPI.setPlaceholders(player, input.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä"))); .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]","\n")));
} }
return output; return output;
} }
@ -56,7 +56,7 @@ public class Replace {
for (String s : Text) { for (String s : Text) {
rp.add(s.replace("[prefix]", prefix).replace("&", "§") rp.add(s.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]","\n")
.replace("[price]", String.valueOf(price))); .replace("[price]", String.valueOf(price)));
} }
return rp; return rp;
@ -81,7 +81,7 @@ public class Replace {
for (String s : Text) { for (String s : Text) {
rp.add(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix).replace("&", "§") rp.add(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]","\n")
.replace("[price]", String.valueOf(price)))); .replace("[price]", String.valueOf(price))));
} }
return rp; return rp;
@ -89,7 +89,7 @@ public class Replace {
public static String replacePrice(String prefix, String Text, String price) { public static String replacePrice(String prefix, String Text, String price) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü") return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[price]", String.valueOf(price)); .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[price]", String.valueOf(price)).replace("[nl]","\n");
} }
@ -97,7 +97,7 @@ public class Replace {
return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§") return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price))); .replace("[price]", String.valueOf(price)).replace("[nl]","\n"));
} }
} }

View File

@ -4,6 +4,7 @@ package net.t2code.lib.Spigot.Lib.update;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.t2code.lib.Spigot.Lib.messages.HoverModule;
import net.t2code.lib.Spigot.Lib.messages.TextBuilder; import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.Main; import net.t2code.lib.Spigot.system.Main;
@ -85,31 +86,19 @@ public class UpdateAPI {
send.player(player, Prefix); send.player(player, Prefix);
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) { if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) {
if (publicVersion.toLowerCase().contains("dev")) { if (publicVersion.toLowerCase().contains("dev")) {
TextComponent comp = new TextBuilder(Prefix + " §6A new §4DEV§6 version was found!") HoverModule.module(Prefix + " §6A new §4DEV§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
player.spigot().sendMessage(comp);
} }
if (publicVersion.toLowerCase().contains("beta")) { if (publicVersion.toLowerCase().contains("beta")) {
TextComponent comp = new TextBuilder(Prefix + " §6A new §2BETA§6 version was found!") HoverModule.module(Prefix + " §6A new §2BETA§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
player.spigot().sendMessage(comp);
} }
if (publicVersion.toLowerCase().contains("snapshot")) { if (publicVersion.toLowerCase().contains("snapshot")) {
TextComponent comp = new TextBuilder(Prefix + " §6A new §eSNAPSHOT§6 version was found!") HoverModule.module(Prefix + " §6A new §eSNAPSHOT§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
player.spigot().sendMessage(comp);
} }
} else { } else {
TextComponent comp = new TextBuilder(Prefix + " §6A new version was found!") HoverModule.module(Prefix + " §6A new version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
player.spigot().sendMessage(comp);
} }
TextComponent comp1 = new TextBuilder(Prefix + " §c" + pluginVersion + " §7-> §a" + publicVersion) HoverModule.module(Prefix + " §c" + pluginVersion + " §7-> §a" + publicVersion, "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build(); HoverModule.module(Prefix + " §6You can find more information on Discord.", "§e" + Discord, "OPEN_URL", Discord, player);
player.spigot().sendMessage(comp1);
TextComponent comp2 = new TextBuilder(Prefix + " §6You can find more information on Discord.")
.addHover("§e" + Discord).addClickEvent(ClickEvent.Action.OPEN_URL, Discord).build();
player.spigot().sendMessage(comp2);
send.player(player, Prefix); send.player(player, Prefix);
} }