mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-07 16:01:27 +01:00
Version command
This commit is contained in:
parent
48de4cb285
commit
ec00736fc3
@ -126,7 +126,7 @@ public class PlayerManager {
|
||||
// Checking duplicated UUID's which usually is a cause of previous bugs
|
||||
if (playerUUIDMap.containsKey(info.getUuid()) && playerUUIDMap.get(info.getUuid()).getID() != info.getID()) {
|
||||
int id = playerUUIDMap.get(info.getUuid()).getID();
|
||||
CMIMessages.consoleMessage("&7Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in dabase. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info.getID());
|
||||
CMIMessages.consoleMessage("&7Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info.getID());
|
||||
|
||||
if (id < info.getID()) {
|
||||
return;
|
||||
@ -136,7 +136,7 @@ public class PlayerManager {
|
||||
// Checking duplicated names which usually is a cause of previous bugs
|
||||
if (playerNameMap.containsKey(info.getName().toLowerCase()) && playerNameMap.get(info.getName().toLowerCase()).getID() != info.getID()) {
|
||||
int id = playerNameMap.get(info.getName().toLowerCase()).getID();
|
||||
CMIMessages.consoleMessage("&7Name Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in dabase. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info
|
||||
CMIMessages.consoleMessage("&7Name Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info
|
||||
.getID());
|
||||
if (id < info.getID()) {
|
||||
return;
|
||||
|
110
src/main/java/com/gamingmesh/jobs/commands/list/version.java
Normal file
110
src/main/java/com/gamingmesh/jobs/commands/list/version.java
Normal file
@ -0,0 +1,110 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
import net.Zrips.CMILib.Util.CMIVersionChecker;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
public class version implements Cmd {
|
||||
|
||||
@Override
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
final String version = plugin.getDescription().getVersion();
|
||||
final String official = Jobs.getVersionCheckManager().getNewVersion();
|
||||
String ofCMIlibVersion = CMIVersionChecker.getOfficialVersion(87610, "CMILib");
|
||||
|
||||
final String server = Bukkit.getBukkitVersion();
|
||||
String[] split = Bukkit.getVersion().split("-");
|
||||
final String serverType = split.length > 1 ? split[1] : split[0];
|
||||
String build = null;
|
||||
|
||||
try {
|
||||
if (serverType.equalsIgnoreCase("Paper"))
|
||||
build = Bukkit.getVersion().split("-")[2].split(" ")[0];
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
final String buildVersion = build == null ? "" : "(" + build + ")";
|
||||
|
||||
String injector = "";
|
||||
if (plugin.getServer().getPluginManager().getPlugin("CMIEInjector") != null)
|
||||
injector = "(CMIEInjector)";
|
||||
|
||||
Plugin v = plugin.getServer().getPluginManager().getPlugin("Vault");
|
||||
String preVault = "Unknown0";
|
||||
String vProvider = null;
|
||||
if (v != null) {
|
||||
preVault = v.getDescription().getVersion();
|
||||
preVault = (preVault + (v.getDescription().getDescription().contains("CMIEconomy") ? "(+)" : injector)).replace("${env.TRAVIS_BUILD_NUMBER}", "");
|
||||
|
||||
RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp != null) {
|
||||
vProvider = rsp.getProvider().getName();
|
||||
}
|
||||
}
|
||||
|
||||
final String vault = preVault;
|
||||
final String vaultProvider = vProvider;
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Plugin CMILib = Bukkit.getPluginManager().getPlugin("CMILib");
|
||||
String CMILibversion = null;
|
||||
if (CMILib != null) {
|
||||
CMILibversion = CMILib.getDescription().getVersion();
|
||||
}
|
||||
|
||||
CMIMessages.sendMessage(sender, LC.info_Spliter);
|
||||
|
||||
RawMessage rm = new RawMessage();
|
||||
rm.addText(Jobs.getLanguage().getMessage("command.version.output.jobsVersion", "[version]", version)
|
||||
+ Jobs.getLanguage().getMessage("command.version.output.dbType", "[db]", Jobs.getDBManager().getDbType().toString()));
|
||||
|
||||
if (!version.equalsIgnoreCase(official))
|
||||
rm.addText(Jobs.getLanguage().getMessage("command.version.output.jobsVersionNew", "[newVersion]", official)).addUrl("https://www.spigotmc.org/resources/4216/updates").addHover(
|
||||
"&r&2New version available");
|
||||
rm.show(sender);
|
||||
|
||||
if (CMILibversion != null) {
|
||||
rm = new RawMessage();
|
||||
rm.addText(Jobs.getLanguage().getMessage("command.version.output.CMILib", "[version]", CMILibversion));
|
||||
|
||||
if (ofCMIlibVersion != null && Version.convertVersion(CMILibversion) < Version.convertVersion(ofCMIlibVersion)) {
|
||||
rm.addText(Jobs.getLanguage().getMessage("command.version.output.cmilVersionNew", "[newVersion]", ofCMIlibVersion));
|
||||
rm.addUrl("https://www.spigotmc.org/resources/" + 87610 + "/updates").addHover("&r&2New version available");
|
||||
}
|
||||
rm.show(sender);
|
||||
}
|
||||
|
||||
CMIMessages.sendMessage(sender, Jobs.getLanguage().getMessage("command.version.output.newServer", "[version]", serverType + buildVersion + " " + server));
|
||||
|
||||
CMIMessages.sendMessage(sender, (vaultProvider != null ? Jobs.getLanguage().getMessage("command.version.output.Economy", "[provider]", vaultProvider) : "") +
|
||||
(vault != null ? Jobs.getLanguage().getMessage("command.version.output.newVault", "[version]", vault) : ""));
|
||||
|
||||
LC.info_Spliter.sendMessage(sender);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -632,6 +632,18 @@ public class LanguageManager {
|
||||
c.get("command.toggle.output.on", "&aToggled: &aON");
|
||||
c.get("command.toggle.output.off", "&aToggled: &4OFF");
|
||||
|
||||
c.get("command.version.help.info", "Plugin version information");
|
||||
c.get("command.version.help.args", "");
|
||||
c.get("command.version.output.jobsVersion", "&eJobs: &6[version]");
|
||||
c.get("command.version.output.jobsVersionNew", "&e-> [newVersion]");
|
||||
c.get("command.version.output.dbType", " &7[db]");
|
||||
c.get("command.version.output.newServer", "&eServer: &6[version]");
|
||||
c.get("command.version.output.Economy", "&eEconomy: &6[provider] ");
|
||||
c.get("command.version.output.newVault", "&eVault: &6[version] ");
|
||||
c.get("command.version.output.CMILib", "&eCMILib: &6[version] ");
|
||||
c.get("command.version.output.cmilVersionNew", "&e-> [newVersion]");
|
||||
|
||||
|
||||
c.get("message.skillup.broadcast", "%playername% has been promoted to a %titlename% %jobname%.");
|
||||
c.get("message.skillup.nobroadcast", "Congratulations, you have been promoted to a %titlename% %jobname%.");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user