forked from Upstream/CitizensCMD
Better config modification checker.
This commit is contained in:
parent
ae41395e5f
commit
b6a166739b
52
pom.xml
52
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.mattstudios.plugins</groupId>
|
<groupId>me.mattstudios.plugins</groupId>
|
||||||
<artifactId>citizens-cmd</artifactId>
|
<artifactId>citizens-cmd</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>CitizensCMD</name>
|
<name>CitizensCMD</name>
|
||||||
@ -14,6 +14,12 @@
|
|||||||
<description>citizens-cmd</description>
|
<description>citizens-cmd</description>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<spigot.version>1.14.4-R0.1-SNAPSHOT</spigot.version>
|
||||||
|
<citizens.version>2.0.25-SNAPSHOT</citizens.version>
|
||||||
|
<papi.version>2.10.2</papi.version>
|
||||||
|
<vault.version>da407c0059</vault.version>
|
||||||
|
<jsonmsg.version>1.0.0</jsonmsg.version>
|
||||||
|
<utils.version>636229e</utils.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -59,10 +65,6 @@
|
|||||||
<id>spigotmc-repo</id>
|
<id>spigotmc-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>sonatype</id>
|
|
||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>rayzr-repo</id>
|
<id>rayzr-repo</id>
|
||||||
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
||||||
@ -82,46 +84,50 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Provided -->
|
||||||
|
<!-- Spigot API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.14.3-R0.1-SNAPSHOT</version>
|
<version>${spigot.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Citizens API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.citizensnpcs</groupId>
|
<groupId>net.citizensnpcs</groupId>
|
||||||
<artifactId>citizensapi</artifactId>
|
<artifactId>citizensapi</artifactId>
|
||||||
<version>2.0.25-SNAPSHOT</version>
|
<version>${citizens.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- PAPI API -->
|
||||||
<groupId>me.rayzr522</groupId>
|
|
||||||
<artifactId>jsonmessage</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
<version>2.10.2</version>
|
<version>${papi.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Vault API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.MilkBowl</groupId>
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
<version>da407c0059</version>
|
<version>${vault.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Compile -->
|
||||||
|
<!-- Json message repo -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>me.rayzr522</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>jsonmessage</artifactId>
|
||||||
<version>13.0</version>
|
<version>${jsonmsg.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- My utils -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ipsk</groupId>
|
||||||
|
<artifactId>MattUtils</artifactId>
|
||||||
|
<version>${utils.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.8</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -18,10 +18,16 @@
|
|||||||
|
|
||||||
package me.mattstudios.citizenscmd;
|
package me.mattstudios.citizenscmd;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.mattstudios.citizenscmd.api.CitizensCMDAPI;
|
import me.mattstudios.citizenscmd.api.CitizensCMDAPI;
|
||||||
import me.mattstudios.citizenscmd.commands.*;
|
import me.mattstudios.citizenscmd.commands.CMDAdd;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDCooldown;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDEdit;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDHelp;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDList;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDPermission;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDPrice;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDReload;
|
||||||
|
import me.mattstudios.citizenscmd.commands.CMDRemove;
|
||||||
import me.mattstudios.citizenscmd.commands.base.CommandHandler;
|
import me.mattstudios.citizenscmd.commands.base.CommandHandler;
|
||||||
import me.mattstudios.citizenscmd.files.CooldownHandler;
|
import me.mattstudios.citizenscmd.files.CooldownHandler;
|
||||||
import me.mattstudios.citizenscmd.files.DataHandler;
|
import me.mattstudios.citizenscmd.files.DataHandler;
|
||||||
@ -47,8 +53,10 @@ import java.util.HashMap;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Getter
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
@Setter
|
import static me.mattstudios.utils.MessageUtils.info;
|
||||||
|
import static me.mattstudios.utils.YamlUtils.copyDefaults;
|
||||||
|
|
||||||
public final class CitizensCMD extends JavaPlugin {
|
public final class CitizensCMD extends JavaPlugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,9 +69,7 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
private CooldownHandler cooldownHandler = null;
|
private CooldownHandler cooldownHandler = null;
|
||||||
private PermissionsManager permissionsManager = null;
|
private PermissionsManager permissionsManager = null;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static CitizensCMDAPI api;
|
private static CitizensCMDAPI api;
|
||||||
@Getter
|
|
||||||
private static Economy economy = null;
|
private static Economy economy = null;
|
||||||
|
|
||||||
private boolean papi = false;
|
private boolean papi = false;
|
||||||
@ -79,8 +85,8 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
Util.checkOldConfig(this);
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
copyDefaults(getClassLoader().getResourceAsStream("config.yml"), new File(getDataFolder().getPath(), "config.yml"));
|
||||||
|
|
||||||
if (!hasCitizens() && getConfig().getBoolean("citizens-check")) {
|
if (!hasCitizens() && getConfig().getBoolean("citizens-check")) {
|
||||||
Util.disablePlugin(this);
|
Util.disablePlugin(this);
|
||||||
@ -92,7 +98,7 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
|
|
||||||
new Metrics(this);
|
new Metrics(this);
|
||||||
|
|
||||||
Util.info(Util.color(Util.TAG + "&3Citizens&cCMD &8&o" + getDescription().getVersion() + " &8By &3Mateus Moreira &c@LichtHund"));
|
info(color(Util.TAG + "&3Citizens&cCMD &8&o" + getDescription().getVersion() + " &8By &3Mateus Moreira &c@LichtHund"));
|
||||||
|
|
||||||
permissionsManager = new PermissionsManager(this);
|
permissionsManager = new PermissionsManager(this);
|
||||||
|
|
||||||
@ -111,22 +117,22 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
if (hasPAPI()) {
|
if (hasPAPI()) {
|
||||||
switch (lang.getLanguage()) {
|
switch (lang.getLanguage()) {
|
||||||
case "en":
|
case "en":
|
||||||
Util.info(Util.color(Util.TAG + "&7Using &aPlaceholderAPI&7!"));
|
info(color(Util.TAG + "&7Using &aPlaceholderAPI&7!"));
|
||||||
break;
|
break;
|
||||||
case "pt":
|
case "pt":
|
||||||
Util.info(Util.color(Util.TAG + "&7Usando &aPlaceholderAPI&7!"));
|
info(color(Util.TAG + "&7Usando &aPlaceholderAPI&7!"));
|
||||||
break;
|
break;
|
||||||
case "ro":
|
case "ro":
|
||||||
Util.info(Util.color(Util.TAG + "&7Folositi &aPlaceholderAPI&7!"));
|
info(color(Util.TAG + "&7Folositi &aPlaceholderAPI&7!"));
|
||||||
break;
|
break;
|
||||||
case "bg":
|
case "bg":
|
||||||
Util.info(Util.color(Util.TAG + "&7Използвайки &aPlaceholderAPI&7!"));
|
info(color(Util.TAG + "&7Използвайки &aPlaceholderAPI&7!"));
|
||||||
break;
|
break;
|
||||||
case "no":
|
case "no":
|
||||||
Util.info(Util.color(Util.TAG + "&7Bruk &aPlaceholderAPI&7!"));
|
info(color(Util.TAG + "&7Bruk &aPlaceholderAPI&7!"));
|
||||||
break;
|
break;
|
||||||
case "ch":
|
case "ch":
|
||||||
Util.info(Util.color(Util.TAG + "&7运用 &aPlaceholderAPI&7!"));
|
info(color(Util.TAG + "&7运用 &aPlaceholderAPI&7!"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
papi = true;
|
papi = true;
|
||||||
@ -135,22 +141,22 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
if (setupEconomy()) {
|
if (setupEconomy()) {
|
||||||
switch (lang.getLanguage()) {
|
switch (lang.getLanguage()) {
|
||||||
case "en":
|
case "en":
|
||||||
Util.info(Util.color(Util.TAG + "&7Using &aVault&7!"));
|
info(color(Util.TAG + "&7Using &aVault&7!"));
|
||||||
break;
|
break;
|
||||||
case "pt":
|
case "pt":
|
||||||
Util.info(Util.color(Util.TAG + "&7Usando &aVault&7!"));
|
info(color(Util.TAG + "&7Usando &aVault&7!"));
|
||||||
break;
|
break;
|
||||||
case "ro":
|
case "ro":
|
||||||
Util.info(Util.color(Util.TAG + "&7Folositi &aVault&7!"));
|
info(color(Util.TAG + "&7Folositi &aVault&7!"));
|
||||||
break;
|
break;
|
||||||
case "bg":
|
case "bg":
|
||||||
Util.info(Util.color(Util.TAG + "&7Използвайки &aVault&7!"));
|
info(color(Util.TAG + "&7Използвайки &aVault&7!"));
|
||||||
break;
|
break;
|
||||||
case "no":
|
case "no":
|
||||||
Util.info(Util.color(Util.TAG + "&7Bruk &aVault&7!"));
|
info(color(Util.TAG + "&7Bruk &aVault&7!"));
|
||||||
break;
|
break;
|
||||||
case "ch":
|
case "ch":
|
||||||
Util.info(Util.color(Util.TAG + "&7运用 &aVault&7!"));
|
info(color(Util.TAG + "&7运用 &aVault&7!"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,29 +186,29 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
newVersion = updater.getLatestVersion();
|
newVersion = updater.getLatestVersion();
|
||||||
switch (lang.getLanguage()) {
|
switch (lang.getLanguage()) {
|
||||||
case "en":
|
case "en":
|
||||||
Util.info(Util.color(Util.TAG + "&cA new version of CitizensCMD is now available:"));
|
info(color(Util.TAG + "&cA new version of CitizensCMD is now available:"));
|
||||||
break;
|
break;
|
||||||
case "pt":
|
case "pt":
|
||||||
Util.info(Util.color(Util.TAG + "&cA nova versão de CitizensCMD está disponivel:"));
|
info(color(Util.TAG + "&cA nova versão de CitizensCMD está disponivel:"));
|
||||||
break;
|
break;
|
||||||
case "ro":
|
case "ro":
|
||||||
Util.info(Util.color(Util.TAG + "&cO noua versiune a CitizensCMD este acum valabila:"));
|
info(color(Util.TAG + "&cO noua versiune a CitizensCMD este acum valabila:"));
|
||||||
break;
|
break;
|
||||||
case "bg":
|
case "bg":
|
||||||
Util.info(Util.color(Util.TAG + "&cНалична е нова версия на CitizensCMD:"));
|
info(color(Util.TAG + "&cНалична е нова версия на CitizensCMD:"));
|
||||||
break;
|
break;
|
||||||
case "no":
|
case "no":
|
||||||
Util.info(Util.color(Util.TAG + "&cEn ny versjon av CitizensCMD er nå tilgjengelig:"));
|
info(color(Util.TAG + "&cEn ny versjon av CitizensCMD er nå tilgjengelig:"));
|
||||||
break;
|
break;
|
||||||
case "ch":
|
case "ch":
|
||||||
Util.info(Util.color(Util.TAG + "&cCitizensCMD的新版本现已推出:"));
|
info(color(Util.TAG + "&cCitizensCMD的新版本现已推出:"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Util.info(Util.color(Util.TAG + "&b&o" + updater.getResourceURL()));
|
info(color(Util.TAG + "&b&o" + updater.getResourceURL()));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// If it can't check for an update, tell the user and throw an error.
|
// If it can't check for an update, tell the user and throw an error.
|
||||||
Util.info("Could not check for updates! Stacktrace:");
|
info("Could not check for updates! Stacktrace:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +269,7 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
pm.registerEvents(new NPCListener(this), this);
|
pm.registerEvents(new NPCListener(this), this);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Util.info(Util.color("&cCould not register clone event, please update your Citizens."));
|
info(color("&cCould not register clone event, please update your Citizens."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,4 +356,142 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
public boolean papiEnabled() {
|
public boolean papiEnabled() {
|
||||||
return papi;
|
return papi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the language that is selected on the config
|
||||||
|
*
|
||||||
|
* @return returns the language
|
||||||
|
*/
|
||||||
|
public LangHandler getLang() {
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if or not should alert player of new update on join
|
||||||
|
*
|
||||||
|
* @return Returns update status
|
||||||
|
*/
|
||||||
|
public boolean getUpdateStatus() {
|
||||||
|
return updateStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets new update status from scheduler
|
||||||
|
*
|
||||||
|
* @param newUpdateStatus New boolean with the update status;
|
||||||
|
*/
|
||||||
|
public void setUpdateStatus(boolean newUpdateStatus) {
|
||||||
|
this.updateStatus = newUpdateStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets String with new version
|
||||||
|
*
|
||||||
|
* @return the new version
|
||||||
|
*/
|
||||||
|
public String getNewVersion() {
|
||||||
|
return newVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new version string
|
||||||
|
*
|
||||||
|
* @param newVersion the new version to be set
|
||||||
|
*/
|
||||||
|
public void setNewVersion(String newVersion) {
|
||||||
|
this.newVersion = newVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the NPC data to be used in other classes without needing to open the file
|
||||||
|
*
|
||||||
|
* @return returns the DataHandler class
|
||||||
|
*/
|
||||||
|
public DataHandler getDataHandler() {
|
||||||
|
return dataHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cooldown handler to check for cooldown informations
|
||||||
|
*
|
||||||
|
* @return Returns the cooldown handler
|
||||||
|
*/
|
||||||
|
public CooldownHandler getCooldownHandler() {
|
||||||
|
return cooldownHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the permission manager to set and unset permission
|
||||||
|
*
|
||||||
|
* @return the permission manager class
|
||||||
|
*/
|
||||||
|
public PermissionsManager getPermissionsManager() {
|
||||||
|
return permissionsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the economy to be used
|
||||||
|
*
|
||||||
|
* @return Returns the economy
|
||||||
|
*/
|
||||||
|
public static Economy getEconomy() {
|
||||||
|
return economy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the hashmap with the players waiting to confirm the NPC payment
|
||||||
|
*
|
||||||
|
* @return returns the list of players
|
||||||
|
*/
|
||||||
|
public HashMap<String, Boolean> getWaitingList() {
|
||||||
|
return waitingList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if player needs to shift or not to confirm payment
|
||||||
|
*
|
||||||
|
* @return Returns the boolean of whether or not players should shift
|
||||||
|
*/
|
||||||
|
public boolean shouldShift() {
|
||||||
|
return shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new shifting rule
|
||||||
|
*
|
||||||
|
* @param shift The new shifting rule
|
||||||
|
*/
|
||||||
|
public void setShift(boolean shift) {
|
||||||
|
this.shift = shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the display format to be used
|
||||||
|
*
|
||||||
|
* @return Returns either SHORT, MEDIUM OR FULL
|
||||||
|
*/
|
||||||
|
public DisplayFormat getDisplayFormat() {
|
||||||
|
return displayFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new display format when reloading
|
||||||
|
*
|
||||||
|
* @param displayFormat The new display format
|
||||||
|
*/
|
||||||
|
public void setDisplayFormat(DisplayFormat displayFormat) {
|
||||||
|
this.displayFormat = displayFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CitizensCMDAPI getApi() {
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShift() {
|
||||||
|
return shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUpdateStatus() {
|
||||||
|
return updateStatus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.notDouble;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.NumbersUtils.isDouble;
|
||||||
|
|
||||||
|
|
||||||
public class CMDAdd extends CommandBase {
|
public class CMDAdd extends CommandBase {
|
||||||
@ -81,7 +81,7 @@ public class CMDAdd extends CommandBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notDouble(commandsArray[i + 1])) {
|
if (!isDouble(commandsArray[i + 1])) {
|
||||||
hasDelayError = true;
|
hasDelayError = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ import me.mattstudios.citizenscmd.paths.Path;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.notInteger;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.NumbersUtils.isInteger;
|
||||||
|
|
||||||
public class CMDCooldown extends CommandBase {
|
public class CMDCooldown extends CommandBase {
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class CMDCooldown extends CommandBase {
|
|||||||
|
|
||||||
if (npcNotSelected(plugin, player)) return;
|
if (npcNotSelected(plugin, player)) return;
|
||||||
|
|
||||||
if (notInteger(args[0])) {
|
if (!isInteger(args[0])) {
|
||||||
player.sendMessage(color(HEADER));
|
player.sendMessage(color(HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_COOLDOWN));
|
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_COOLDOWN));
|
||||||
return;
|
return;
|
||||||
|
@ -27,10 +27,10 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.notInteger;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.NumbersUtils.isInteger;
|
||||||
|
|
||||||
|
|
||||||
public class CMDEdit extends CommandBase {
|
public class CMDEdit extends CommandBase {
|
||||||
@ -47,7 +47,7 @@ public class CMDEdit extends CommandBase {
|
|||||||
|
|
||||||
if (npcNotSelected(plugin, player)) return;
|
if (npcNotSelected(plugin, player)) return;
|
||||||
|
|
||||||
if (notInteger(args[2])) {
|
if (!isInteger(args[2])) {
|
||||||
player.sendMessage(color(HEADER));
|
player.sendMessage(color(HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_ID_NUMBER));
|
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_ID_NUMBER));
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,7 @@ import me.rayzr522.jsonmessage.JSONMessage;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thank you GlareMasters for creating this class as an example!
|
* Thank you GlareMasters for creating this class as an example!
|
||||||
|
@ -29,9 +29,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
|
||||||
public class CMDList extends CommandBase {
|
public class CMDList extends CommandBase {
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ import me.mattstudios.citizenscmd.paths.Path;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
|
||||||
public class CMDPermission extends CommandBase {
|
public class CMDPermission extends CommandBase {
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ import me.mattstudios.citizenscmd.paths.Path;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.notDouble;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.NumbersUtils.isDouble;
|
||||||
|
|
||||||
|
|
||||||
public class CMDPrice extends CommandBase {
|
public class CMDPrice extends CommandBase {
|
||||||
@ -44,7 +44,7 @@ public class CMDPrice extends CommandBase {
|
|||||||
|
|
||||||
if (npcNotSelected(plugin, player)) return;
|
if (npcNotSelected(plugin, player)) return;
|
||||||
|
|
||||||
if (notDouble(args[0])) {
|
if (!isDouble(args[0])) {
|
||||||
player.sendMessage(color(HEADER));
|
player.sendMessage(color(HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_PRICE));
|
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_PRICE));
|
||||||
return;
|
return;
|
||||||
|
@ -28,7 +28,7 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
|
||||||
public class CMDReload extends CommandBase {
|
public class CMDReload extends CommandBase {
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ import me.mattstudios.citizenscmd.utility.EnumTypes;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
import static me.mattstudios.citizenscmd.utility.Util.getSelectedNpcId;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.notInteger;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelected;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.NumbersUtils.isInteger;
|
||||||
|
|
||||||
|
|
||||||
public class CMDRemove extends CommandBase {
|
public class CMDRemove extends CommandBase {
|
||||||
@ -45,7 +45,7 @@ public class CMDRemove extends CommandBase {
|
|||||||
|
|
||||||
if (npcNotSelected(plugin, player)) return;
|
if (npcNotSelected(plugin, player)) return;
|
||||||
|
|
||||||
if (notInteger(args[1])) {
|
if (!isInteger(args[1])) {
|
||||||
player.sendMessage(color(HEADER));
|
player.sendMessage(color(HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_ID_NUMBER));
|
player.sendMessage(plugin.getLang().getMessage(Path.INVALID_ID_NUMBER));
|
||||||
return;
|
return;
|
||||||
|
@ -26,7 +26,6 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -35,9 +34,9 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
import static me.mattstudios.citizenscmd.utility.Util.HEADER;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.color;
|
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.getTabCompleteArgs;
|
import static me.mattstudios.citizenscmd.utility.Util.getTabCompleteArgs;
|
||||||
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelectedNM;
|
import static me.mattstudios.citizenscmd.utility.Util.npcNotSelectedNM;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thank you GlareMasters for creating this class!
|
* Thank you GlareMasters for creating this class!
|
||||||
@ -67,7 +66,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter, IHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, Command cmd, @NotNull String commandLabel, @NotNull String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
if (!cmd.getName().equalsIgnoreCase("npcmd")) {
|
if (!cmd.getName().equalsIgnoreCase("npcmd")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -134,7 +133,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter, IHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, Command cmd, @NotNull String commandLabel, @NotNull String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
if (cmd.getName().equalsIgnoreCase("npcmd")) {
|
if (cmd.getName().equalsIgnoreCase("npcmd")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> commandNames = new ArrayList<>();
|
List<String> commandNames = new ArrayList<>();
|
||||||
|
@ -29,6 +29,9 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.info;
|
||||||
|
|
||||||
public class CooldownHandler {
|
public class CooldownHandler {
|
||||||
|
|
||||||
private CitizensCMD plugin;
|
private CitizensCMD plugin;
|
||||||
@ -70,7 +73,7 @@ public class CooldownHandler {
|
|||||||
try {
|
try {
|
||||||
cooldownsFile.createNewFile();
|
cooldownsFile.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Util.info(Util.color("&cError creating cooldowns file.."));
|
info(color("&cError creating cooldowns file.."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.info;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class DataHandler {
|
public class DataHandler {
|
||||||
|
|
||||||
@ -75,7 +78,7 @@ public class DataHandler {
|
|||||||
try {
|
try {
|
||||||
savesFile.createNewFile();
|
savesFile.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Util.info(Util.color("&cError creating saves file.."));
|
info(color("&cError creating saves file.."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,12 +168,12 @@ public class DataHandler {
|
|||||||
dataConfigurator.set("npc-data.npc-" + npc + ".price", 0);
|
dataConfigurator.set("npc-data.npc-" + npc + ".price", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.NPC_ADDED));
|
player.sendMessage(plugin.getLang().getMessage(Path.NPC_ADDED));
|
||||||
|
|
||||||
dataConfigurator.save(savesFile);
|
dataConfigurator.save(savesFile);
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.NPC_ADD_FAIL));
|
player.sendMessage(plugin.getLang().getMessage(Path.NPC_ADD_FAIL));
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@ -241,12 +244,12 @@ public class DataHandler {
|
|||||||
|
|
||||||
data.replace("npc-data.npc-" + npc + ".cooldown", cooldown);
|
data.replace("npc-data.npc-" + npc + ".cooldown", cooldown);
|
||||||
|
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.NPC_COOLDOWN_SET));
|
player.sendMessage(plugin.getLang().getMessage(Path.NPC_COOLDOWN_SET));
|
||||||
|
|
||||||
dataConfigurator.save(savesFile);
|
dataConfigurator.save(savesFile);
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.NPC_COOLDOWN_SET_ERROR));
|
player.sendMessage(plugin.getLang().getMessage(Path.NPC_COOLDOWN_SET_ERROR));
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@ -269,7 +272,7 @@ public class DataHandler {
|
|||||||
|
|
||||||
data.replace("npc-data.npc-" + npc + ".price", price);
|
data.replace("npc-data.npc-" + npc + ".price", price);
|
||||||
|
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.NPC_PRICE_SET));
|
player.sendMessage(plugin.getLang().getMessage(Path.NPC_PRICE_SET));
|
||||||
|
|
||||||
dataConfigurator.save(savesFile);
|
dataConfigurator.save(savesFile);
|
||||||
@ -296,7 +299,7 @@ public class DataHandler {
|
|||||||
|
|
||||||
data.replace("npc-data.npc-" + npc + ".permission", permission);
|
data.replace("npc-data.npc-" + npc + ".permission", permission);
|
||||||
|
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.PERMISSION_SET));
|
player.sendMessage(plugin.getLang().getMessage(Path.PERMISSION_SET));
|
||||||
|
|
||||||
dataConfigurator.save(savesFile);
|
dataConfigurator.save(savesFile);
|
||||||
@ -323,7 +326,7 @@ public class DataHandler {
|
|||||||
|
|
||||||
data.remove("npc-data.npc-" + npc + ".permission");
|
data.remove("npc-data.npc-" + npc + ".permission");
|
||||||
|
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.PERMISSION_REMOVED));
|
player.sendMessage(plugin.getLang().getMessage(Path.PERMISSION_REMOVED));
|
||||||
|
|
||||||
dataConfigurator.save(savesFile);
|
dataConfigurator.save(savesFile);
|
||||||
@ -437,7 +440,7 @@ public class DataHandler {
|
|||||||
data.replace(key, commands);
|
data.replace(key, commands);
|
||||||
dataConfigurator.set(key, commands);
|
dataConfigurator.set(key, commands);
|
||||||
|
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.REMOVED_COMMAND));
|
player.sendMessage(plugin.getLang().getMessage(Path.REMOVED_COMMAND));
|
||||||
|
|
||||||
dataConfigurator.save(savesFile);
|
dataConfigurator.save(savesFile);
|
||||||
@ -486,7 +489,7 @@ public class DataHandler {
|
|||||||
data.replace(key, commandsData);
|
data.replace(key, commandsData);
|
||||||
dataConfigurator.set(key, commandsData);
|
dataConfigurator.set(key, commandsData);
|
||||||
|
|
||||||
player.sendMessage(Util.color(Util.HEADER));
|
player.sendMessage(color(Util.HEADER));
|
||||||
player.sendMessage(plugin.getLang().getMessage(Path.EDITED_COMMAND).replace("{type}", typeText));
|
player.sendMessage(plugin.getLang().getMessage(Path.EDITED_COMMAND).replace("{type}", typeText));
|
||||||
|
|
||||||
dataConfigurator.save(savesFile);
|
dataConfigurator.save(savesFile);
|
||||||
|
@ -30,6 +30,9 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.info;
|
||||||
|
|
||||||
public class LangHandler {
|
public class LangHandler {
|
||||||
|
|
||||||
private CitizensCMD plugin;
|
private CitizensCMD plugin;
|
||||||
@ -48,25 +51,25 @@ public class LangHandler {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case "en":
|
case "en":
|
||||||
Util.info(Util.color(Util.TAG + "&7Using &aEnglish &7messages!"));
|
info(color(Util.TAG + "&7Using &aEnglish &7messages!"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "pt":
|
case "pt":
|
||||||
Util.info(Util.color(Util.TAG + "&7Usando mensagens em Portugues!"));
|
info(color(Util.TAG + "&7Usando mensagens em Portugues!"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ro":
|
case "ro":
|
||||||
Util.info(Util.color(Util.TAG + "&7Folositi mesajele in Limba &aRomana&7!"));
|
info(color(Util.TAG + "&7Folositi mesajele in Limba &aRomana&7!"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "bg":
|
case "bg":
|
||||||
Util.info(Util.color(Util.TAG + "&7Използване на &aбългарски &7език!"));
|
info(color(Util.TAG + "&7Използване на &aбългарски &7език!"));
|
||||||
break;
|
break;
|
||||||
case "no":
|
case "no":
|
||||||
Util.info(Util.color(Util.TAG + "&aNorsk &7Oversettelse!"));
|
info(color(Util.TAG + "&aNorsk &7Oversettelse!"));
|
||||||
break;
|
break;
|
||||||
case "ch":
|
case "ch":
|
||||||
Util.info(Util.color(Util.TAG + "&7使用&a中文&7消息!"));
|
info(color(Util.TAG + "&7使用&a中文&7消息!"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +302,7 @@ public class LangHandler {
|
|||||||
* @return Returns String with colored message from file
|
* @return Returns String with colored message from file
|
||||||
*/
|
*/
|
||||||
public String getMessage(String path) {
|
public String getMessage(String path) {
|
||||||
return Util.color(messages.get(path));
|
return color(messages.get(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
package me.mattstudios.citizenscmd.listeners;
|
package me.mattstudios.citizenscmd.listeners;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import me.mattstudios.citizenscmd.CitizensCMD;
|
import me.mattstudios.citizenscmd.CitizensCMD;
|
||||||
import net.citizensnpcs.api.event.NPCCloneEvent;
|
import net.citizensnpcs.api.event.NPCCloneEvent;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class NPCListener implements Listener {
|
public class NPCListener implements Listener {
|
||||||
|
|
||||||
private CitizensCMD plugin;
|
private CitizensCMD plugin;
|
||||||
|
|
||||||
|
public NPCListener(CitizensCMD plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void on(NPCCloneEvent event) {
|
public void on(NPCCloneEvent event) {
|
||||||
if (!plugin.getDataHandler().hasNPCData(event.getNPC().getId())) return;
|
if (!plugin.getDataHandler().hasNPCData(event.getNPC().getId())) return;
|
||||||
|
@ -27,6 +27,8 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
|
||||||
public class UpdateEvent implements Listener {
|
public class UpdateEvent implements Listener {
|
||||||
|
|
||||||
private CitizensCMD plugin;
|
private CitizensCMD plugin;
|
||||||
@ -38,9 +40,9 @@ public class UpdateEvent implements Listener {
|
|||||||
@EventHandler (priority = EventPriority.NORMAL)
|
@EventHandler (priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
if (plugin.isUpdateStatus() && event.getPlayer().hasPermission("citizenscmd.update")) {
|
if (plugin.isUpdateStatus() && event.getPlayer().hasPermission("citizenscmd.update")) {
|
||||||
JSONMessage.create(Util.color(Util.HEADER)).send(event.getPlayer());
|
JSONMessage.create(color(Util.HEADER)).send(event.getPlayer());
|
||||||
JSONMessage.create(Util.color(plugin.getLang().getUncoloredMessage(Path.NEW_VERSION) + plugin.getNewVersion())).send(event.getPlayer());
|
JSONMessage.create(color(plugin.getLang().getUncoloredMessage(Path.NEW_VERSION) + plugin.getNewVersion())).send(event.getPlayer());
|
||||||
JSONMessage.create(Util.color(plugin.getLang().getUncoloredMessage(Path.DOWNLOAD_AT) + " spigotmc.org/resources/citizens-CMD.30224/")).openURL("https://spigotmc.org/resources/citizens-CMD.30224/").send(event.getPlayer());
|
JSONMessage.create(color(plugin.getLang().getUncoloredMessage(Path.DOWNLOAD_AT) + " spigotmc.org/resources/citizens-CMD.30224/")).openURL("https://spigotmc.org/resources/citizens-CMD.30224/").send(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import me.mattstudios.citizenscmd.paths.Path;
|
|||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@ -42,6 +41,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static me.mattstudios.utils.MessageUtils.color;
|
||||||
|
import static me.mattstudios.utils.MessageUtils.info;
|
||||||
import static org.bukkit.Bukkit.getScheduler;
|
import static org.bukkit.Bukkit.getScheduler;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
@ -52,32 +53,6 @@ public class Util {
|
|||||||
public static final String HEADER = "&c&m-&6&m-&e&m-&a&m-&b&m-&3&l CitizensCMD &b&m-&a&m-&e&m-&6&m-&c&m-";
|
public static final String HEADER = "&c&m-&6&m-&e&m-&a&m-&b&m-&3&l CitizensCMD &b&m-&a&m-&e&m-&6&m-&c&m-";
|
||||||
public static final String TAG = "&f[&3Citizens&cCMD&f]&r ";
|
public static final String TAG = "&f[&3Citizens&cCMD&f]&r ";
|
||||||
|
|
||||||
/**
|
|
||||||
* @param str String to check if it is a number or not
|
|
||||||
* @return Returns true if it is a number false if it is a string or contains any non numeric character
|
|
||||||
*/
|
|
||||||
public static boolean notInteger(String str) {
|
|
||||||
try {
|
|
||||||
Integer.parseInt(str);
|
|
||||||
} catch (NumberFormatException | NullPointerException e) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param str String to check if it is a double number or not
|
|
||||||
* @return Returns true if it is a number false if it is a string or contains any non numeric character
|
|
||||||
*/
|
|
||||||
public static boolean notDouble(String str) {
|
|
||||||
try {
|
|
||||||
Double.parseDouble(str);
|
|
||||||
} catch (NumberFormatException | NullPointerException e) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if player has or not selected an NPC
|
* Checks if player has or not selected an NPC
|
||||||
*
|
*
|
||||||
@ -121,25 +96,6 @@ public class Util {
|
|||||||
return plugin.getConfig().getBoolean("check-updates");
|
return plugin.getConfig().getBoolean("check-updates");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility to use color codes easily
|
|
||||||
*
|
|
||||||
* @param msg The message String
|
|
||||||
* @return returns the string with color
|
|
||||||
*/
|
|
||||||
public static String color(String msg) {
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simplified way for sending console messages
|
|
||||||
*
|
|
||||||
* @param msg the message to be sent to the console
|
|
||||||
*/
|
|
||||||
public static void info(String msg) {
|
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets default cooldown set on the config
|
* Gets default cooldown set on the config
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user