This commit is contained in:
JaTiTV 2022-11-02 20:28:48 +01:00
parent 6295ebe84b
commit 438bdbbb1e
9 changed files with 54 additions and 64 deletions

View File

@ -6,7 +6,7 @@
<groupId>de.jatitv</groupId> <groupId>de.jatitv</groupId>
<artifactId>PaPiTest</artifactId> <artifactId>PaPiTest</artifactId>
<version>0.0.1</version> <version>1.5</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PaPiTest</name> <name>PaPiTest</name>
@ -78,7 +78,7 @@
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>12.0</version> <version>13.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -1,36 +1,32 @@
package de.jatitv.papitest; package de.jatitv.papitest;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
public class Util { public class Util {
private static double requiredT2CodeLibVersion = 12.0;
private static String prefix = "§8[§5PaPi§6Test§8]";
private static Integer spigotID = 90439;
private static Integer bstatsID = 10342;
private static String spigot = "https://www.spigotmc.org/resources/" + spigotID;
private static String discord = "http://dc.t2code.net";
public static double getRequiredT2CodeLibVersion() { public static String getInfoText() {
return requiredT2CodeLibVersion; return "";
}
public static String getRequiredT2CodeLibVersion() {
return "13.0";
} }
public static String getPrefix() { public static String getPrefix() {
return prefix; return "§8[§5PaPi§6Test§8]";
} }
public static Integer getSpigotID() { public static Integer getSpigotID() {
return spigotID; return 90439;
} }
public static Integer getBstatsID() { public static Integer getBstatsID() {
return bstatsID; return 10342;
} }
public static String getSpigot() { public static String getSpigot() {
return spigot; return "https://www.spigotmc.org/resources/" + getSpigotID();
} }
public static String getDiscord() { public static String getDiscord() {
return discord; return "http://dc.t2code.net";
} }
} }

View File

@ -3,12 +3,6 @@
package de.jatitv.papitest.commands; package de.jatitv.papitest.commands;
import de.jatitv.papitest.Util; import de.jatitv.papitest.Util;
import de.jatitv.papitest.config.Config;
import de.jatitv.papitest.system.Main;
import me.clip.placeholderapi.PlaceholderAPI;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -4,10 +4,9 @@ import de.jatitv.papitest.Util;
import de.jatitv.papitest.config.Config; import de.jatitv.papitest.config.Config;
import de.jatitv.papitest.system.Main; import de.jatitv.papitest.system.Main;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,7 +17,7 @@ import java.util.stream.Collectors;
public class Commands { public class Commands {
protected static void info(CommandSender sender) { protected static void info(CommandSender sender) {
T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.autor, Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion); T2Ctemplate.sendInfo(sender,Main.getPlugin(),Util.getSpigotID(),Util.getDiscord(),Util.getInfoText());
} }
protected static void reload(CommandSender sender) { protected static void reload(CommandSender sender) {
@ -30,7 +29,7 @@ public class Commands {
} }
protected static void use(CommandSender sender, String[] args) { protected static void use(CommandSender sender, String[] args) {
if (!PluginCheck.papi()) { if (!T2CpluginCheck.papi()) {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§4\n" + Util.getPrefix() + " §4PlaceholderAPI could not be connected / found! " + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§4\n" + Util.getPrefix() + " §4PlaceholderAPI could not be connected / found! " +
"§9Please download it here: §6https://www.spigotmc.org/resources/placeholderapi.6245/§4\n" + Util.getPrefix()); "§9Please download it here: §6https://www.spigotmc.org/resources/placeholderapi.6245/§4\n" + Util.getPrefix());
if (sender instanceof Player) { if (sender instanceof Player) {
@ -62,7 +61,7 @@ public class Commands {
protected static void execute(CommandSender sender, Player target, String placeholder) { protected static void execute(CommandSender sender, Player target, String placeholder) {
sender.sendMessage(Util.getPrefix() + " §b" + placeholder + " §7-> " + "§6" + PlaceholderAPI.setPlaceholders(target, placeholder)); sender.sendMessage(Util.getPrefix() + " §b" + placeholder + " §7-> " + "§6" + PlaceholderAPI.setPlaceholders(target, placeholder));
if (!MCVersion.minecraft1_8 && Config.Titel && sender instanceof Player) { if (!T2CmcVersion.isMc1_8() && Config.Titel && sender instanceof Player) {
((Player)sender).sendTitle("§5PaPi§6Test§8: " + "§b" + placeholder, "§6" + PlaceholderAPI.setPlaceholders(target, placeholder)); ((Player)sender).sendTitle("§5PaPi§6Test§8: " + "§b" + placeholder, "§6" + PlaceholderAPI.setPlaceholders(target, placeholder));
} }
} }

View File

@ -4,8 +4,7 @@ package de.jatitv.papitest.commands;
import de.jatitv.papitest.Util; import de.jatitv.papitest.Util;
import de.jatitv.papitest.config.Config; import de.jatitv.papitest.config.Config;
import de.jatitv.papitest.system.Main; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -24,7 +23,7 @@ public class Reload {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2");
if (PluginCheck.papi()) { if (T2CpluginCheck.papi()) {
if (sender instanceof Player) { if (sender instanceof Player) {
sender.sendMessage(Util.getPrefix() + " §2PlaceholderAPI successfully connected!"); sender.sendMessage(Util.getPrefix() + " §2PlaceholderAPI successfully connected!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2PlaceholderAPI successfully connected!"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2PlaceholderAPI successfully connected!");

View File

@ -4,7 +4,7 @@ package de.jatitv.papitest.config;
import de.jatitv.papitest.Util; import de.jatitv.papitest.Util;
import de.jatitv.papitest.system.Main; import de.jatitv.papitest.system.Main;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -20,7 +20,7 @@ public class Config {
public static void configCreate() { public static void configCreate() {
File configYML = new File(Main.thisp().getDataFolder().getPath(), "Config.yml"); File configYML = new File(Main.getPlugin().getDataFolder(), "Config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML);
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §4Config.yml load..."); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §4Config.yml load...");
@ -33,7 +33,7 @@ public class Config {
yamlConfiguration.set("Plugin.UpdateCheckOnJoin", true); yamlConfiguration.set("Plugin.UpdateCheckOnJoin", true);
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §4Setting §6UpdateCheckOnJoin §4was added to §9Config.yml§4!"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §4Setting §6UpdateCheckOnJoin §4was added to §9Config.yml§4!");
} }
if (!MCVersion.minecraft1_8) { if (!T2CmcVersion.isMc1_8()) {
if (yamlConfiguration.contains("Titel.Enable")) { if (yamlConfiguration.contains("Titel.Enable")) {
Titel = yamlConfiguration.getBoolean("Titel.Enable"); Titel = yamlConfiguration.getBoolean("Titel.Enable");
} else { } else {

View File

@ -3,13 +3,11 @@
package de.jatitv.papitest.system; package de.jatitv.papitest.system;
import de.jatitv.papitest.Util; import de.jatitv.papitest.Util;
import de.jatitv.papitest.config.Config; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class JoinEvent implements Listener { public class JoinEvent implements Listener {
@ -17,7 +15,6 @@ public class JoinEvent implements Listener {
@EventHandler @EventHandler
public void onJoinEvent(PlayerJoinEvent event) { public void onJoinEvent(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
T2CupdateAPI.join(Main.getPlugin(),Util.getPrefix(),"papitest.admin",player,Util.getSpigotID(),Util.getDiscord());
UpdateAPI.join(Main.plugin, Util.getPrefix(),"papitest.admin",player,Util.getSpigot(), Util.getDiscord());
} }
} }

View File

@ -6,20 +6,17 @@ import de.jatitv.papitest.Util;
import de.jatitv.papitest.commands.CmdExecuter; import de.jatitv.papitest.commands.CmdExecuter;
import de.jatitv.papitest.commands.TabComplete; import de.jatitv.papitest.commands.TabComplete;
import de.jatitv.papitest.config.Config; import de.jatitv.papitest.config.Config;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
public final class Main extends JavaPlugin { public final class Main extends JavaPlugin {
public static Main plugin; private static Main plugin;
public static String version; public static String version;
public static List<String> autor; public static List<String> autor;
@ -27,10 +24,6 @@ public final class Main extends JavaPlugin {
return plugin; return plugin;
} }
public static Plugin thisp() {
return plugin;
}
@Override @Override
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic
@ -41,14 +34,13 @@ public final class Main extends JavaPlugin {
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §4Plugin load..."); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §4Plugin load...");
T2CupdateAPI.onUpdateCheck(plugin,Util.getPrefix(),Util.getSpigotID(),Util.getDiscord());
UpdateAPI.onUpdateCheck(Main.plugin, Util.getPrefix(), Util.getSpigot(), Util.getSpigotID(), Util.getDiscord());
Metrics.Bstats(Main.plugin, Util.getBstatsID()); Metrics.Bstats(Main.plugin, Util.getBstatsID());
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------");
Config.configCreate(); Config.configCreate();
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §8-------------------------------");
if (PluginCheck.papi()) { if (T2CpluginCheck.papi()) {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2PlaceholderAPI successfully connected!"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2PlaceholderAPI successfully connected!");
} else { } else {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§4\n" + Util.getPrefix() + " §4PlaceholderAPI could not be connected / found! " + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§4\n" + Util.getPrefix() + " §4PlaceholderAPI could not be connected / found! " +
@ -74,20 +66,33 @@ public final class Main extends JavaPlugin {
// Plugin shutdown logic // Plugin shutdown logic
} }
public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) { public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
if (Bukkit.getPluginManager().getPlugin(pl) == null) { if (Bukkit.getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: "
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin."); + "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
plugin.getPluginLoader().disablePlugin(plugin); Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true; return true;
} else { } else {
if (Double.parseDouble(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion()) < ver) { String plVer = Bukkit.getPluginManager().getPlugin(pl).getDescription().getVersion();
if (ver.contains("_")) {
if (!plVer.equals(ver)) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires the version §2"
+ ver + " §4of §6" + pl + " §4Please use this version! Please download it here or contact us in Discord: §6https://spigotmc.org/resources/"
+ pl + "." + spigotID + " Or contact us in Discord: http://dc.t2code.net");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true;
}
return false;
}
String[] split = plVer.split("_");
if (Double.parseDouble(split[0]) < Double.parseDouble(ver)) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2"
ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID
plugin.getDescription().getName() + "."); + " §4to use this version of " + plugin.getDescription().getName() + ".");
plugin.getPluginLoader().disablePlugin(plugin); Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true; return true;
} }
return false; return false;

View File

@ -1,6 +1,6 @@
name: PaPiTest name: PaPiTest
prefix: PaPiTest prefix: PaPiTest
version: 1.3 version: '${project.version}'
api-version: 1.13 api-version: 1.13
main: de.jatitv.papitest.system.Main main: de.jatitv.papitest.system.Main
softdepend: [ T2CodeLib, PlaceholderAPI ] softdepend: [ T2CodeLib, PlaceholderAPI ]