Compare commits

...

4 Commits

Author SHA1 Message Date
1c962a54d6 code changes 2021-12-31 05:30:39 +01:00
1ce07cce81 add removeColorCode 2021-12-31 05:26:57 +01:00
3c6bb074d8 commands change
- add permission for '/t2c debug createReportLog'
- add '/t2c info'
2021-12-31 05:26:45 +01:00
07293cded4 Recode /<plugin> info 2021-12-31 05:23:57 +01:00
8 changed files with 57 additions and 23 deletions

View File

@ -1,7 +1,7 @@
<component name="ArtifactManager">
<artifact type="jar" name="T2CodeLib_9.0_Snapshot_1">
<artifact type="jar" name="T2CodeLib_9.0_Snapshot_2">
<output-path>$PROJECT_DIR$/../../Plugins/T2CodeLib/.jar</output-path>
<root id="archive" name="T2CodeLib_9.0_Snapshot_1.jar">
<root id="archive" name="T2CodeLib_9.0_Snapshot_2.jar">
<element id="module-output" name="T2CodeLib" />
</root>
</artifact>

View File

@ -2,6 +2,7 @@ package net.t2code.lib.Spigot.Lib.messages;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Spigot.system.Main;
import org.bukkit.Bukkit;
@ -78,19 +79,30 @@ public class T2CodeTemplate {
public static void sendInfo(CommandSender sender, String prefix, String spigot, String discord, List autor, String pluginVersion, String publicVersion) {
send.sender(sender, prefix + "§4======= " + prefix + " §4=======");
send.sender(sender, prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
if (sender instanceof Player) {
if (publicVersion.equalsIgnoreCase(pluginVersion)) {
send.sender(sender, prefix + " §2Version: §6" + pluginVersion);
} else {
if (sender instanceof Player) {
Player player = (Player) sender;
UpdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, player);
TextComponent comp2 = new TextBuilder(prefix + " §2Version: §6" + pluginVersion)
.addHover("§8Click to copy").addClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, Replace.removeColorCode(prefix) +" - "+ pluginVersion).build();
sender.spigot().sendMessage(comp2);
if (!publicVersion.equalsIgnoreCase(pluginVersion)) {
UpdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, (Player) sender);
}
TextComponent comp3 = new TextBuilder(prefix + " §2Spigot: §6" + spigot)
.addHover("§8Open Spigot").addClickEvent(ClickEvent.Action.OPEN_URL, spigot).build();
sender.spigot().sendMessage(comp3);
TextComponent comp4 = new TextBuilder(prefix + " §2Discord: §6" + discord)
.addHover("§8Open Discord").addClickEvent(ClickEvent.Action.OPEN_URL, discord).build();
sender.spigot().sendMessage(comp4);
} else {
if (publicVersion.equalsIgnoreCase(pluginVersion)) {
send.sender(sender, prefix + " §2Version: §6" + pluginVersion);
} else {
UpdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion);
}
send.sender(sender, prefix + " §2Spigot: §6" + spigot);
send.sender(sender, prefix + " §2Discord: §6" + discord);
}
send.sender(sender, prefix + " §2Spigot: §6" + spigot);
send.sender(sender, prefix + " §2Discord: §6" + discord);
send.sender(sender, prefix + "§4======= " + prefix + " §4=======");
}
}

View File

@ -63,6 +63,19 @@ public class Replace {
return rp;
}
public static String removeColorCode(String value){
String text = value.replace("&", "§");
while(text.contains("§")){
int stelle = text.indexOf("§");
if(text.length() >= stelle+2) {
text = text.substring(0, stelle) + text.substring(stelle + 2);
}else{
text = text.substring(0, stelle) + text.substring(stelle + 1);
}
}
return (text);
}
public static List<String> replacePrice(String prefix,Player player, List<String> Text, String price) {
List<String> rp = new ArrayList();

View File

@ -4,6 +4,7 @@ import net.md_5.bungee.protocol.packet.Commands;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -22,29 +23,36 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class CmdExecuter implements CommandExecutor, TabCompleter {
private static Plugin plugin = Main.plugin;
private static String prefix = Main.prefix;
private static List autor = Main.autor;
private static String version = Main.version;
private static String spigot = Main.spigot;
private static String discord = Main.discord;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("t2code.admin")){
send.sender(sender,"§4No Permission §8t2code.admin");
return false;
}
if (args.length == 0) {
T2CodeTemplate.sendInfo(sender, prefix, spigot, discord, autor, version, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion);
T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.autor, Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion);
} else {
switch (args[0].toLowerCase()) {
case "info":
case "plugin":
case "pl":
case "version":
case "ver":
T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.autor, Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion);
return false;
}
if ("debug".equals(args[0].toLowerCase())) {
if (args.length != 2) {
send.sender(sender,"§4Use: §7/t2code debug createReportLog");
send.sender(sender, "§4Use: §7/t2code debug createReportLog");
return false;
}
if ("createreportlog".equals(args[1].toLowerCase())) {
CreateReportLog.create(sender);
CreateReportLog.create(sender);
} else send.sender(sender,"§4Use: §7/t2code debug createReportLog");
} else send.sender(sender,"§4Use: §7/t2code debug createReportLog");
} else send.sender(sender, "§4Use: §7/t2code debug createReportLog");
} else send.sender(sender, "§4Use: §7/t2code debug createReportLog");
}
return false;
}
@ -53,6 +61,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
//TabCompleter
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("debug", "t2code.admin");
put("info", "t2code.admin");
}};
@Override