forked from Upstream/CitizensCMD
Final commit v2.0.
This commit is contained in:
parent
7694f5b654
commit
05c44f65a3
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.mattmoreira.plugins</groupId>
|
<groupId>me.mattmoreira.plugins</groupId>
|
||||||
<artifactId>citizens-cmd</artifactId>
|
<artifactId>citizens-cmd</artifactId>
|
||||||
<version>2.0-BETA</version>
|
<version>2.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>CitizensCMD</name>
|
<name>CitizensCMD</name>
|
||||||
|
@ -48,7 +48,7 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Supported languages
|
* Supported languages
|
||||||
*/
|
*/
|
||||||
private final String[] REGISTERED_LANG_FILES = {"en", "pt", "ro", "bg"};
|
private final String[] REGISTERED_LANG_FILES = {"en", "pt", "ro", "bg", "no", "ch"};
|
||||||
|
|
||||||
private static CitizensCMD plugin;
|
private static CitizensCMD plugin;
|
||||||
|
|
||||||
@ -82,6 +82,8 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkOldConfig();
|
||||||
|
|
||||||
new Metrics(this);
|
new Metrics(this);
|
||||||
|
|
||||||
info(color(TAG + "&3Citizens&cCMD &8&o" + getDescription().getVersion() + " &8By &3Mateus Moreira &c@LichtHund"));
|
info(color(TAG + "&3Citizens&cCMD &8&o" + getDescription().getVersion() + " &8By &3Mateus Moreira &c@LichtHund"));
|
||||||
@ -115,6 +117,12 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
case "bg":
|
case "bg":
|
||||||
info(color(TAG + "&7Използвайки &aPlaceholderAPI&7!"));
|
info(color(TAG + "&7Използвайки &aPlaceholderAPI&7!"));
|
||||||
break;
|
break;
|
||||||
|
case "no":
|
||||||
|
info(color(TAG + "&7Bruk &aPlaceholderAPI&7!"));
|
||||||
|
break;
|
||||||
|
case "ch":
|
||||||
|
info(color(TAG + "&7运用 &aPlaceholderAPI&7!"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
papi = true;
|
papi = true;
|
||||||
}
|
}
|
||||||
@ -133,6 +141,12 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
case "bg":
|
case "bg":
|
||||||
info(color(TAG + "&7Използвайки &aVult&7!"));
|
info(color(TAG + "&7Използвайки &aVult&7!"));
|
||||||
break;
|
break;
|
||||||
|
case "no":
|
||||||
|
info(color(TAG + "&7Bruk &aVult&7!"));
|
||||||
|
break;
|
||||||
|
case "ch":
|
||||||
|
info(color(TAG + "&7运用 &aVult&7!"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +189,12 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
case "bg":
|
case "bg":
|
||||||
info(color(TAG + "&cНалична е нова версия на CitizensCMD:"));
|
info(color(TAG + "&cНалична е нова версия на CitizensCMD:"));
|
||||||
break;
|
break;
|
||||||
|
case "no":
|
||||||
|
info(color(TAG + "&cEn ny versjon av CitizensCMD er nå tilgjengelig:"));
|
||||||
|
break;
|
||||||
|
case "ch":
|
||||||
|
info(color(TAG + "&cCitizensCMD的新版本现已推出:"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
info(color(TAG + "&b&o" + updater.getResourceURL()));
|
info(color(TAG + "&b&o" + updater.getResourceURL()));
|
||||||
}
|
}
|
||||||
@ -302,6 +322,18 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
lang = new LangHandler("bg");
|
lang = new LangHandler("bg");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "no":
|
||||||
|
case "norw":
|
||||||
|
case "norwegian":
|
||||||
|
lang = new LangHandler("no");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ch":
|
||||||
|
case "chi":
|
||||||
|
case "chinese":
|
||||||
|
lang = new LangHandler("ch");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
lang = new LangHandler("en");
|
lang = new LangHandler("en");
|
||||||
break;
|
break;
|
||||||
|
@ -37,11 +37,11 @@ public class CMDReload extends CommandBase {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(Player player, String[] args) {
|
public void execute(Player player, String[] args) {
|
||||||
CitizensCMD.getPlugin().reloadConfig();
|
CitizensCMD.getPlugin().reloadConfig();
|
||||||
CitizensCMD.getPlugin().saveConfig();
|
CitizensCMD.getPlugin().saveDefaultConfig();
|
||||||
CitizensCMD.getPlugin().setLang(CitizensCMD.getPlugin().getConfig().getString("lang"));
|
CitizensCMD.getPlugin().setLang(CitizensCMD.getPlugin().getConfig().getString("lang"));
|
||||||
|
|
||||||
if (CitizensCMD.getPlugin().getConfig().contains("cooldonw-time-display")) {
|
if (CitizensCMD.getPlugin().getConfig().contains("cooldown-time-display")) {
|
||||||
switch (CitizensCMD.getPlugin().getConfig().getString("cooldonw-time-display").toLowerCase()) {
|
switch (CitizensCMD.getPlugin().getConfig().getString("cooldown-time-display").toLowerCase()) {
|
||||||
case "short":
|
case "short":
|
||||||
CitizensCMD.getPlugin().setDisplayFormat(DisplayFormat.SHORT);
|
CitizensCMD.getPlugin().setDisplayFormat(DisplayFormat.SHORT);
|
||||||
break;
|
break;
|
||||||
|
@ -150,11 +150,8 @@ public class CooldownHandler {
|
|||||||
if (cooldownData.containsKey("cooldown-data.npc-" + npc + "." + uuid)) {
|
if (cooldownData.containsKey("cooldown-data.npc-" + npc + "." + uuid)) {
|
||||||
if (CitizensCMD.getPlugin().getDataHandler().getNPCCooldown(npc) == -1)
|
if (CitizensCMD.getPlugin().getDataHandler().getNPCCooldown(npc) == -1)
|
||||||
return true;
|
return true;
|
||||||
else {
|
else
|
||||||
System.out.println("seconds left: " + getSecondsDifference(cooldownData.get("cooldown-data.npc-" + npc + "." + uuid)));
|
|
||||||
System.out.println("CD: " +CitizensCMD.getPlugin().getDataHandler().getNPCCooldown(npc));
|
|
||||||
return getSecondsDifference(cooldownData.get("cooldown-data.npc-" + npc + "." + uuid)) < CitizensCMD.getPlugin().getDataHandler().getNPCCooldown(npc);
|
return getSecondsDifference(cooldownData.get("cooldown-data.npc-" + npc + "." + uuid)) < CitizensCMD.getPlugin().getDataHandler().getNPCCooldown(npc);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -342,13 +342,13 @@ public class DataHandler {
|
|||||||
String tempCommand = commandsData.get(commandID - 1);
|
String tempCommand = commandsData.get(commandID - 1);
|
||||||
tempCommand = tempCommand.replaceAll(" ([^]]*)", " " + newValue);
|
tempCommand = tempCommand.replaceAll(" ([^]]*)", " " + newValue);
|
||||||
commandsData.set(commandID - 1, tempCommand);
|
commandsData.set(commandID - 1, tempCommand);
|
||||||
typeText = "command";
|
typeText = "CMD";
|
||||||
break;
|
break;
|
||||||
case PERM:
|
case PERM:
|
||||||
String tempPerm = commandsData.get(commandID - 1);
|
String tempPerm = commandsData.get(commandID - 1);
|
||||||
tempPerm = tempPerm.replaceAll("\\[([^]]*)]", "[" + newValue + "]");
|
tempPerm = tempPerm.replaceAll("\\[([^]]*)]", "[" + newValue + "]");
|
||||||
commandsData.set(commandID - 1, tempPerm);
|
commandsData.set(commandID - 1, tempPerm);
|
||||||
typeText = "permission";
|
typeText = "PERM";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,12 @@ public class LangHandler {
|
|||||||
case "bg":
|
case "bg":
|
||||||
info(color(TAG + "&7Използване на &aбългарски &7език!"));
|
info(color(TAG + "&7Използване на &aбългарски &7език!"));
|
||||||
break;
|
break;
|
||||||
|
case "no":
|
||||||
|
info(color(TAG + "&aNorsk &7Oversettelse!"));
|
||||||
|
break;
|
||||||
|
case "ch":
|
||||||
|
info(color(TAG + "&7使用&a中文&7消息!"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
messages = new HashMap<>();
|
messages = new HashMap<>();
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* <p>
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* <p>
|
||||||
|
* A special thanks to @ExtendedClip for letting me use and modify this class from PlaceholderAPI
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,9 +33,13 @@ import java.util.regex.Pattern;
|
|||||||
public class TimeUtil {
|
public class TimeUtil {
|
||||||
|
|
||||||
private static String dayFormat;
|
private static String dayFormat;
|
||||||
|
private static String dayPlural;
|
||||||
private static String hourFormat;
|
private static String hourFormat;
|
||||||
|
private static String hourPlural;
|
||||||
private static String minuteFormat;
|
private static String minuteFormat;
|
||||||
|
private static String minutePlural;
|
||||||
private static String secondFormat;
|
private static String secondFormat;
|
||||||
|
private static String secondPlural;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets formatted time from seconds
|
* Gets formatted time from seconds
|
||||||
@ -71,23 +77,61 @@ public class TimeUtil {
|
|||||||
secondFormat = shorts[0];
|
secondFormat = shorts[0];
|
||||||
break;
|
break;
|
||||||
case MEDIUM:
|
case MEDIUM:
|
||||||
dayFormat = " " + mediums[3];
|
String mediumsAfter[] = new String[4];
|
||||||
hourFormat = " " + mediums[2];
|
String mediumsPlurals[] = new String[4];
|
||||||
minuteFormat = " " + mediums[1];
|
Pattern patternMediums = Pattern.compile("([^]]*)\\(([^]]*)\\)");
|
||||||
secondFormat = " " + mediums[0];
|
for (int i = 0; i < mediums.length; i++) {
|
||||||
|
if (mediums[i].contains("(") && mediums[i].contains(")")) {
|
||||||
|
Matcher matcher = patternMediums.matcher(mediums[i]);
|
||||||
|
if (matcher.find()) {
|
||||||
|
mediumsAfter[i] = matcher.group(1);
|
||||||
|
mediumsPlurals[i] = matcher.group(2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mediumsAfter[i] = mediums[i];
|
||||||
|
mediumsPlurals[i] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dayFormat = " " + mediumsAfter[3];
|
||||||
|
dayPlural = mediumsPlurals[3];
|
||||||
|
hourFormat = " " + mediumsAfter[2];
|
||||||
|
hourPlural = mediumsPlurals[2];
|
||||||
|
minuteFormat = " " + mediumsAfter[1];
|
||||||
|
minutePlural = mediumsPlurals[1];
|
||||||
|
secondFormat = " " + mediumsAfter[0];
|
||||||
|
secondPlural = mediumsPlurals[0];
|
||||||
break;
|
break;
|
||||||
case FULL:
|
case FULL:
|
||||||
dayFormat = " " + fulls[3];
|
String fullsAfter[] = new String[4];
|
||||||
hourFormat = " " + fulls[2];
|
String fullsPlurals[] = new String[4];
|
||||||
minuteFormat = " " + fulls[1];
|
Pattern patternFulls = Pattern.compile("([^]]*)\\(([^]]*)\\)");
|
||||||
secondFormat = " " + fulls[0];
|
for (int i = 0; i < fulls.length; i++) {
|
||||||
|
if (fulls[i].contains("(") && fulls[i].contains(")")) {
|
||||||
|
Matcher matcher = patternFulls.matcher(fulls[i]);
|
||||||
|
if (matcher.find()) {
|
||||||
|
fullsAfter[i] = matcher.group(1);
|
||||||
|
fullsPlurals[i] = matcher.group(2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fullsAfter[i] = fulls[i];
|
||||||
|
fullsPlurals[i] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dayFormat = " " + fullsAfter[3];
|
||||||
|
dayPlural = fullsPlurals[3];
|
||||||
|
hourFormat = " " + fullsAfter[2];
|
||||||
|
hourPlural = fullsPlurals[2];
|
||||||
|
minuteFormat = " " + fullsAfter[1];
|
||||||
|
minutePlural = fullsPlurals[1];
|
||||||
|
secondFormat = " " + fullsAfter[0];
|
||||||
|
secondPlural = fullsPlurals[0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seconds < 60) {
|
if (seconds < 60) {
|
||||||
if (seconds == 1 && !format.equals(DisplayFormat.SHORT))
|
if (seconds == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
return seconds + secondFormat.substring(0, secondFormat.length() - 1);
|
return seconds + secondFormat;
|
||||||
return seconds + secondFormat;
|
return seconds + secondFormat + secondPlural;
|
||||||
}
|
}
|
||||||
|
|
||||||
long minutes = TimeUnit.SECONDS.toMinutes(seconds);
|
long minutes = TimeUnit.SECONDS.toMinutes(seconds);
|
||||||
@ -97,41 +141,41 @@ public class TimeUtil {
|
|||||||
if (minutes == 1 && !format.equals(DisplayFormat.SHORT)) {
|
if (minutes == 1 && !format.equals(DisplayFormat.SHORT)) {
|
||||||
if (secondsLeft > 0) {
|
if (secondsLeft > 0) {
|
||||||
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
return String.valueOf(minutes + minuteFormat.substring(0, secondFormat.length() - 1) + " " + secondsLeft + secondFormat.substring(0, secondFormat.length() - 1));
|
return String.valueOf(minutes + minuteFormat + " " + secondsLeft + secondFormat);
|
||||||
return String.valueOf(minutes + minuteFormat.substring(0, secondFormat.length() - 1) + " " + secondsLeft + secondFormat);
|
return String.valueOf(minutes + minuteFormat + " " + secondsLeft + secondFormat + secondPlural);
|
||||||
} else
|
} else
|
||||||
return String.valueOf(minutes + minuteFormat.substring(0, secondFormat.length() - 1));
|
return String.valueOf(minutes + minuteFormat);
|
||||||
} else {
|
} else {
|
||||||
if (secondsLeft > 0) {
|
if (secondsLeft > 0) {
|
||||||
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
return String.valueOf(minutes + minuteFormat + " " + secondsLeft + secondFormat.substring(0, secondFormat.length() - 1));
|
return String.valueOf(minutes + minuteFormat + minutePlural + " " + secondsLeft + secondFormat);
|
||||||
return String.valueOf(minutes + minuteFormat + " " + secondsLeft + secondFormat);
|
return String.valueOf(minutes + minuteFormat + minutePlural + " " + secondsLeft + secondFormat + secondPlural);
|
||||||
} else
|
} else
|
||||||
return String.valueOf(minutes + minuteFormat);
|
return String.valueOf(minutes + minuteFormat + minutePlural);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minutes < 1440) {
|
if (minutes < 1440) {
|
||||||
long hours = TimeUnit.MINUTES.toHours(minutes);
|
long hours = TimeUnit.MINUTES.toHours(minutes);
|
||||||
String time;
|
String time;
|
||||||
if (hours == 1 && !format.equals(DisplayFormat.SHORT))
|
if (hours == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time = hours + hourFormat.substring(0, hourFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time = hours + hourFormat;
|
time = hours + hourFormat;
|
||||||
|
else
|
||||||
|
time = hours + hourFormat + hourPlural;
|
||||||
long leftOver = minutes - TimeUnit.HOURS.toMinutes(hours);
|
long leftOver = minutes - TimeUnit.HOURS.toMinutes(hours);
|
||||||
|
|
||||||
if (leftOver >= 1) {
|
if (leftOver >= 1) {
|
||||||
if (leftOver == 1 && !format.equals(DisplayFormat.SHORT))
|
if (leftOver == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time += " " + leftOver + minuteFormat.substring(0, minuteFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time += " " + leftOver + minuteFormat;
|
time += " " + leftOver + minuteFormat;
|
||||||
|
else
|
||||||
|
time += " " + leftOver + minuteFormat + minutePlural;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secondsLeft > 0)
|
if (secondsLeft > 0)
|
||||||
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time += " " + secondsLeft + secondFormat.substring(0, secondFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time += " " + secondsLeft + secondFormat;
|
time += " " + secondsLeft + secondFormat;
|
||||||
|
else
|
||||||
|
time += " " + secondsLeft + secondFormat + secondPlural;
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
@ -139,36 +183,36 @@ public class TimeUtil {
|
|||||||
long days = TimeUnit.MINUTES.toDays(minutes);
|
long days = TimeUnit.MINUTES.toDays(minutes);
|
||||||
String time;
|
String time;
|
||||||
if (days == 1 && !format.equals(DisplayFormat.SHORT))
|
if (days == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time = days + dayFormat.substring(0, dayFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time = days + dayFormat;
|
time = days + dayFormat;
|
||||||
|
else
|
||||||
|
time = days + dayFormat + dayPlural;
|
||||||
long leftOver = minutes - TimeUnit.DAYS.toMinutes(days);
|
long leftOver = minutes - TimeUnit.DAYS.toMinutes(days);
|
||||||
|
|
||||||
if (leftOver >= 1) {
|
if (leftOver >= 1) {
|
||||||
if (leftOver < 60) {
|
if (leftOver < 60) {
|
||||||
if (leftOver == 1 && !format.equals(DisplayFormat.SHORT))
|
if (leftOver == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time += " " + leftOver + minuteFormat.substring(0, minuteFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time += " " + leftOver + minuteFormat;
|
time += " " + leftOver + minuteFormat;
|
||||||
|
else
|
||||||
|
time += " " + leftOver + minuteFormat + minutePlural;
|
||||||
} else {
|
} else {
|
||||||
long hours = TimeUnit.MINUTES.toHours(leftOver);
|
long hours = TimeUnit.MINUTES.toHours(leftOver);
|
||||||
if (hours == 1 && !format.equals(DisplayFormat.SHORT))
|
if (hours == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time += " " + hours + hourFormat.substring(0, hourFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time += " " + hours + hourFormat;
|
time += " " + hours + hourFormat;
|
||||||
|
else
|
||||||
|
time += " " + hours + hourFormat + hourPlural;
|
||||||
long minsLeft = leftOver - TimeUnit.HOURS.toMinutes(hours);
|
long minsLeft = leftOver - TimeUnit.HOURS.toMinutes(hours);
|
||||||
if (minsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
if (minsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time += " " + minsLeft + minuteFormat.substring(0, minuteFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time += " " + minsLeft + minuteFormat;
|
time += " " + minsLeft + minuteFormat;
|
||||||
|
else
|
||||||
|
time += " " + minsLeft + minuteFormat + minutePlural;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secondsLeft > 0) {
|
if (secondsLeft > 0) {
|
||||||
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
if (secondsLeft == 1 && !format.equals(DisplayFormat.SHORT))
|
||||||
time += " " + secondsLeft + secondFormat.substring(0, secondFormat.length() - 1);
|
|
||||||
else
|
|
||||||
time += " " + secondsLeft + secondFormat;
|
time += " " + secondsLeft + secondFormat;
|
||||||
|
else
|
||||||
|
time += " " + secondsLeft + secondFormat + secondPlural;
|
||||||
}
|
}
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
|
@ -22,8 +22,13 @@ import me.mattmoreira.citizenscmd.CitizensCMD;
|
|||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
@ -168,4 +173,47 @@ public class Util {
|
|||||||
return TimeUnit.SECONDS.convert((System.nanoTime() - storedTime), TimeUnit.NANOSECONDS);
|
return TimeUnit.SECONDS.convert((System.nanoTime() - storedTime), TimeUnit.NANOSECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for old config and renames it
|
||||||
|
*/
|
||||||
|
public static void checkOldConfig() {
|
||||||
|
File configFile;
|
||||||
|
File configFileNew;
|
||||||
|
FileConfiguration configConf;
|
||||||
|
|
||||||
|
boolean isNew = true;
|
||||||
|
|
||||||
|
boolean contains[] = new boolean[5];
|
||||||
|
for (int i = 0; i < contains.length; i++) {
|
||||||
|
contains[i] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
configFile = new File(CitizensCMD.getPlugin().getDataFolder(), "config.yml");
|
||||||
|
configFileNew = new File(CitizensCMD.getPlugin().getDataFolder(), "config_old.yml");
|
||||||
|
configConf = new YamlConfiguration();
|
||||||
|
|
||||||
|
if (configFile.exists()) {
|
||||||
|
configConf.load(configFile);
|
||||||
|
if (configConf.contains("check-updates")) contains[0] = true;
|
||||||
|
if (configConf.contains("lang")) contains[1] = true;
|
||||||
|
if (configConf.contains("default-cooldown")) contains[2] = true;
|
||||||
|
if (configConf.contains("shift-confirm")) contains[3] = true;
|
||||||
|
if (configConf.contains("cooldown-time-display")) contains[4] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (boolean bool : contains) {
|
||||||
|
if (!bool) {
|
||||||
|
isNew = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isNew) {
|
||||||
|
configFile.renameTo(configFileNew);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
# Citizens CMD Plugin by Mateus Moreira
|
# Citizens CMD Plugin by Mateus Moreira
|
||||||
# @LichtHund
|
# @LichtHund
|
||||||
# Version ${project.version}
|
# Version ${project.version}
|
||||||
|
# Wiki: https://github.com/ipsk/CitizensCMD/wiki
|
||||||
|
# GitHub: https://github.com/ipsk/CitizensCMD
|
||||||
|
# Spigot: https://www.spigotmc.org/resources/citizens-cmd.30224/
|
||||||
|
|
||||||
#
|
#
|
||||||
# Enables Checking for update.
|
# Enables Checking for update.
|
||||||
check-updates: true
|
check-updates: true
|
||||||
#
|
#
|
||||||
# Available languages EN, PT, BG, RO, NO
|
# Available languages EN, PT, BG, RO, NO, CH
|
||||||
lang: en
|
lang: 'en'
|
||||||
#
|
#
|
||||||
# The default npc cooldown in seconds
|
# The default npc cooldown in seconds
|
||||||
default-cooldown: 0
|
default-cooldown: 0
|
||||||
|
62
src/main/resources/lang/ch.yml
Normal file
62
src/main/resources/lang/ch.yml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Citizens CMD Plugin by Mateus Moreira
|
||||||
|
# @LichtHund
|
||||||
|
# Version ${project.version}
|
||||||
|
#
|
||||||
|
# Change as much as you need.
|
||||||
|
# Remove placeholders with caution!
|
||||||
|
# Some placeholders can be removed but might not work correctly
|
||||||
|
# Cooldown placeholder is safe to be deleted
|
||||||
|
messages:
|
||||||
|
commands:
|
||||||
|
npc-add-command-added: "&a你已經成功新增指令到這個npc!"
|
||||||
|
npc-add-command-failed: "&c新增指令到這個npc失敗!"
|
||||||
|
npc-cooldown-set: "&a你已經成功設定冷卻時間!"
|
||||||
|
npc-cooldown-error: "&c設定冷卻時間時有錯誤!"
|
||||||
|
npc-price-set: "&a你已經成功設定價格!"
|
||||||
|
list-commnads-counter-right: "&c&o{count} &7&o- 右鍵指令:"
|
||||||
|
list-commnads-counter-left: "&c&o{count} &7&o- 左鍵指令:"
|
||||||
|
list-cooldown: "&7冷卻時間: &c"
|
||||||
|
list-price: "&7價格: &c"
|
||||||
|
list-tooltip: "&7按下來編輯!"
|
||||||
|
reload-command: "&a所有檔案已經被重新載入!"
|
||||||
|
removed-command: "&a這個指令已經被成功移除!"
|
||||||
|
edit-command: "&a {type} 已經被編輯!"
|
||||||
|
warnings:
|
||||||
|
no-npc-selected: "&c你一定要選擇NPC來執行那個指令!"
|
||||||
|
invalid-cooldown: "&c冷卻時間並不是數字!"
|
||||||
|
invalid-price: "&c價格並不是數字!"
|
||||||
|
invalid-id: "&c請用一個正確的指令ID!"
|
||||||
|
invalid-click-type: "&c你一定要選擇左邊或右邊!"
|
||||||
|
no-commands: "&c這個NPC已經沒有更多指令!"
|
||||||
|
invalid-arguments: "&c你一定要選擇 CMD 或 PERM!"
|
||||||
|
invalid-permission: "&c權限不能包括空格!"
|
||||||
|
console-not-allowed: "&c這指令只能在遊戲中執行!不能在console執行!"
|
||||||
|
no-permission: "&c你沒有權限去執行這個指令!"
|
||||||
|
wrong-usage: "&c錯誤用法! &7/npcmd &c來看指令用法!"
|
||||||
|
new-version: "&7有新的版本可供用: &cv"
|
||||||
|
download-at: "&7下載:"
|
||||||
|
npc:
|
||||||
|
on-cooldown: "&7請等 &c{time} 之後再用這個指令"
|
||||||
|
one-time-click: "&7這NPC只供一次性的使用!"
|
||||||
|
pay-confirm: "&7如果要用這個NPC,你要付費 &a{price}$&7!\n&a{shift}欲確定,按右鍵&7or &c{shift}欲取消,按左鍵\n&8這行動會自動在 &c15 &8秒內取消!"
|
||||||
|
pay-canceled: "&c付費被取消!"
|
||||||
|
pay-no-money: "&c你沒有足夠的金錢!"
|
||||||
|
pay-completed: "&a已經在你的帳戶扣去{price}$!"
|
||||||
|
help:
|
||||||
|
version: "&7&o版本:"
|
||||||
|
info: "&7欲要知道更多,把鼠標停留在一個指令上!"
|
||||||
|
example: "&8例子:"
|
||||||
|
description-add: "&7添加指令到NPC."
|
||||||
|
description-cooldown: "&7設定使用NPC冷卻時間,以秒作單位."
|
||||||
|
description-price: "&7設定要使用NPC的價格."
|
||||||
|
description-list: "&7顯示這個NPC的所有指令."
|
||||||
|
description-edit: "&7編輯特定的指令或權限."
|
||||||
|
description-remove: "&7從一個NPC移除一個指令."
|
||||||
|
description-reload: "&7重新載入所有檔案."
|
||||||
|
# IMPORTANT!!
|
||||||
|
# DO NOT CHANGE THIS PATTERN, KEEP THE "[]," CHANGE ONLY THE TEXT INSIDE
|
||||||
|
time-format:
|
||||||
|
seconds: "[s], [秒], [秒]"
|
||||||
|
minutes: "[m], [分钟], [分钟]"
|
||||||
|
hours: "[h], [小时], [小时]"
|
||||||
|
days: "[d], [天], [天]"
|
@ -54,10 +54,9 @@ messages:
|
|||||||
description-remove: "&7Removes a command from the NPC."
|
description-remove: "&7Removes a command from the NPC."
|
||||||
description-reload: "&7Reloads all the files."
|
description-reload: "&7Reloads all the files."
|
||||||
# IMPORTANT!!
|
# IMPORTANT!!
|
||||||
# DO NOT CHANGE THIS PATTERN, KEEP THE "[]," CHANGE ONLY THE TEXT INSIDE
|
# DO NOT CHANGE THIS PATTERN, KEEP THE "[]," CHANGE ONLY THE TEXT INSIDE, O "()" contém os PLURALS
|
||||||
time-format:
|
time-format:
|
||||||
seconds: "[s], [secs], [seconds]"
|
seconds: "[s], [sec(s)], [second(s)]"
|
||||||
minutes: "[m], [mins], [minutes]"
|
minutes: "[m], [min(s)], [minute(s)]"
|
||||||
hours: "[h], [hours], [hours]"
|
hours: "[h], [hour(s)], [hour(s)]"
|
||||||
days: "[d], [days], [days]"
|
days: "[d], [day(s)], [day(s)]"
|
||||||
|
|
62
src/main/resources/lang/no.yml
Normal file
62
src/main/resources/lang/no.yml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Citizens CMD Plugin by Mateus Moreira
|
||||||
|
# @LichtHund
|
||||||
|
# Version ${project.version}
|
||||||
|
#
|
||||||
|
# Change as much as you need.
|
||||||
|
# Remove placeholders with caution!
|
||||||
|
# Some placeholders can be removed but might not work correctly
|
||||||
|
# Cooldown placeholder is safe to be deleted
|
||||||
|
messages:
|
||||||
|
commands:
|
||||||
|
npc-add-command-added: "&aDu har lagt til kommandoen til NPCen!"
|
||||||
|
npc-add-command-failed: "&cKunne ikke legge til kommandoen!"
|
||||||
|
npc-cooldown-set: "&aEn nedtelling ble lagt til!"
|
||||||
|
npc-cooldown-error: "&cEn error ble oppdaget når du skulle legge til en nedtelling!"
|
||||||
|
npc-price-set: "&aDu har satt en pris!"
|
||||||
|
list-commnads-counter-right: "&c&o{count} &7&o- Høyre klikk:"
|
||||||
|
list-commnads-counter-left: "&c&o{count} &7&o- Venstre klikk"
|
||||||
|
list-cooldown: "&7Nedtelling: &c"
|
||||||
|
list-price: "&7Pris: &c"
|
||||||
|
list-tooltip: "&7Klikk for å endre!"
|
||||||
|
reload-command: "&aAlle fillene har blitt reloadet!"
|
||||||
|
removed-command: "&aKommandoen ble fjernet!"
|
||||||
|
edit-command: "&a{type} ble endret!"
|
||||||
|
warnings:
|
||||||
|
no-npc-selected: "&cDu må velge en NPC for å utføre denne kommandoen!"
|
||||||
|
invalid-cooldown: "&cNedtellingen må være et tall!"
|
||||||
|
invalid-price: "&cPrisen må være et tall!"
|
||||||
|
invalid-id: "&cBruk et gyldig ID"
|
||||||
|
invalid-click-type: "&cDu må enten velge left eller right"
|
||||||
|
no-commands: "&cDet er ingen flere kommandoer i denne NPCen"
|
||||||
|
invalid-arguments: "&cDu må velge enten CMD eller PERM!"
|
||||||
|
invalid-permission: "&cPermission kan ikke inneholde et mellomrom!"
|
||||||
|
console-not-allowed: "&cDenne kommandoen kan kun utføres ingame!"
|
||||||
|
no-permission: "&cDu har ikke tilgang til å bruke denne kommandoen!"
|
||||||
|
wrong-usage: "&cFeil bruk av kommandoen! &7/npcmd &cfor hjelp!"
|
||||||
|
new-version: "&7Ny versjon er tilgjengelig: &cv"
|
||||||
|
download-at: "&7Last ned her"
|
||||||
|
npc:
|
||||||
|
on-cooldown: "&7Vent &c{time} &7før du bruker denne igjen!"
|
||||||
|
one-time-click: "&7Denne NPCen kan kun brukes engang!"
|
||||||
|
pay-confirm: "&7For å bruke denne NPCen må du betale &a{price}$&7!\n&a{shift}Høyre klikk for å bekrefte &7or &c{shift}Venstre klikk for å avbryte\n&8Denne vil bli automatisk avslått om &c15 &8sekunder!"
|
||||||
|
pay-canceled: "&cBetaling avslått!"
|
||||||
|
pay-no-money: "&cDu har ikke nok penger til dette!"
|
||||||
|
pay-completed: "&a{price}$ har blitt tatt fra din konto!"
|
||||||
|
help:
|
||||||
|
version: "&7&oVersjon:"
|
||||||
|
info: "&7Hold musen over for å få infomarsjon!"
|
||||||
|
example: "&8Eksempel:"
|
||||||
|
description-add: "&7Legg til kommandoer."
|
||||||
|
description-cooldown: "&7Legge til en nedtelling i sekunder!"
|
||||||
|
description-price: "&7Sett en pris på NPCen"
|
||||||
|
description-list: "&7Se liste over kommandoen som er på NPCen"
|
||||||
|
description-edit: "&7Endre en kommando eller permission"
|
||||||
|
description-remove: "&7Fjerne en kommando fra NPCen"
|
||||||
|
description-reload: "&7reloade alle filene"
|
||||||
|
# IMPORTANT!!
|
||||||
|
# DO NOT CHANGE THIS PATTERN, KEEP THE "[]," CHANGE ONLY THE TEXT INSIDE
|
||||||
|
time-format:
|
||||||
|
seconds: "[s], [sek], [sekund(er)]"
|
||||||
|
minutes: "[m], [min], [minutt(er)]"
|
||||||
|
hours: "[h], [time(r)], [time(r)]"
|
||||||
|
days: "[d], [dag(er)], [dag(er)]"
|
@ -1,5 +1,63 @@
|
|||||||
|
# Citizens CMD Plugin by Mateus Moreira
|
||||||
|
# @LichtHund
|
||||||
|
# Versão ${project.version}
|
||||||
|
#
|
||||||
|
# Mude o tanto que for necessário.
|
||||||
|
# Tome cuidado ao remover os placeholders!
|
||||||
|
# Alguns placeholders podem ser removidos mas podem não funcionar corretamente.
|
||||||
|
# Os placeholders do cooldown podem ser removidos com segurança.
|
||||||
messages:
|
messages:
|
||||||
commands:
|
commands:
|
||||||
command1: ""
|
npc-add-command-added: "&aVocê adicionou um comando ao NPC com sucesso!"
|
||||||
|
npc-add-command-failed: "&cFalha ao adicionar comando ao NPC!"
|
||||||
|
npc-cooldown-set: "&aVocê definiu com o cooldown sucesso!"
|
||||||
|
npc-cooldown-error: "&cOcorreu um erro ao definir o cooldown!"
|
||||||
|
npc-price-set: "&aVocê definiu o preço com sucesso!"
|
||||||
|
list-commnads-counter-right: "&c&o{count} &7&o- Comandos de clique direito:"
|
||||||
|
list-commnads-counter-left: "&c&o{count} &7&o- Comandos de clique esquerdo:"
|
||||||
|
list-cooldown: "&7Cooldown: &c"
|
||||||
|
list-price: "&7Preço: &c"
|
||||||
|
list-tooltip: "&7Clique para editar!"
|
||||||
|
reload-command: "&aTodos os arquivos foram recarregados com sucesso!"
|
||||||
|
removed-command: "&aO comando foi removido com sucesso!"
|
||||||
|
edit-command: "&aO {type} foi editado com sucesso!"
|
||||||
warnings:
|
warnings:
|
||||||
no-npc-selected: "&ctenho que traduzir depois mas aborrece!"
|
no-npc-selected: "&cVocê deve ter um NPC selecionado para executar esse comando!"
|
||||||
|
invalid-cooldown: "&cO cooldown deve ser um número!"
|
||||||
|
invalid-price: "&cO preço deve ser um número!"
|
||||||
|
invalid-id: "&cPor favor, introduza um ID de comando válido!"
|
||||||
|
invalid-click-type: "&cVocê deve selecionar esquerda ou direita!"
|
||||||
|
no-commands: "&cNão há mais comandos neste NPC!"
|
||||||
|
invalid-arguments: "&cVocê deve selecionar CMD ou PERM!"
|
||||||
|
invalid-permission: "&cPermissões não podem conter espaços!"
|
||||||
|
console-not-allowed: "&cEste comando não pode ser executado a partir do console, apenas no jogo!"
|
||||||
|
no-permission: "&cVocê não tem permissão para executar este comando!"
|
||||||
|
wrong-usage: "&cUso errado do comando! &7/npcmd &cpara ajuda!"
|
||||||
|
new-version: "&7Nova versão disponível: &cv"
|
||||||
|
download-at: "&7Faça download em"
|
||||||
|
npc:
|
||||||
|
on-cooldown: "&7Por favor, aguarde &c{time} &7antes de usar este NPC novamente!"
|
||||||
|
one-time-click: "&7Este NPC permite apenas um uso!"
|
||||||
|
pay-confirm: "&7Para usar este NPC você deve pagar &a{price}$&7!\n&a{shift}Clique com o botão direito para confirmar &7or &c{shift}Clique esquerdo para cancelar\n&8Esta operação será cancelada em &c15 &8segundos!"
|
||||||
|
pay-canceled: "&cPagamento cancelado!"
|
||||||
|
pay-no-money: "&cVocê não tem dinheiro suficiente para fazer isso!"
|
||||||
|
pay-completed: "&a{price}$ foi retirado da sua conta!"
|
||||||
|
help:
|
||||||
|
version: "&7&oVersão:"
|
||||||
|
info: "&7Passe o mouse sobre um comando para mais informações e exemplos!"
|
||||||
|
example: "&8Exemplos:"
|
||||||
|
description-add: "&7Adiciona comandos a um NPC."
|
||||||
|
description-cooldown: "&7Define o tempo de espera do clique do NPC, em segundos."
|
||||||
|
description-price: "&7Define o preço para usar o NPC."
|
||||||
|
description-list: "&7Exibe lista de comandos para o NPC atual."
|
||||||
|
description-edit: "&7Edita um comando ou permissão específica."
|
||||||
|
description-remove: "&7Remove um comando do NPC."
|
||||||
|
description-reload: "&7Recarrega todos os arquivos."
|
||||||
|
# IMPORTANT!!
|
||||||
|
# NÃO MUDE ESTE PADRÃO, MANTENHA O "[]," MUDE APENAS O TEXTO DENTRO
|
||||||
|
time-format:
|
||||||
|
seconds: "[s], [seg(s)], [secondo(s)]"
|
||||||
|
minutes: "[m], [min(s)], [minuto(s)]"
|
||||||
|
hours: "[h], [hora(s)], [hora(s)]"
|
||||||
|
days: "[d], [dia(s)], [dia(s)]"
|
||||||
|
|
||||||
|
@ -57,6 +57,6 @@ messages:
|
|||||||
# NU MODIFICATI ACEST MODEL, PASTRATI "[]," SI MODIFICATI DOAR TEXTUL DIN INTERIOR
|
# NU MODIFICATI ACEST MODEL, PASTRATI "[]," SI MODIFICATI DOAR TEXTUL DIN INTERIOR
|
||||||
time-format:
|
time-format:
|
||||||
seconds: "[s], [sec], [secunde]"
|
seconds: "[s], [sec], [secunde]"
|
||||||
minutes: "[m], [min], [minute]"
|
minutes: "[m], [min], [minut(e)]"
|
||||||
hours: "[h], [ore], [ore]"
|
hours: "[h], [ore], [ore]"
|
||||||
days: "[z], [zile], [zile]"
|
days: "[z], [zi(le)], [zi(le)]"
|
@ -1,5 +1,8 @@
|
|||||||
# Citizens CMD Plugin by Mateus Moreira aka iPSYKO
|
# Citizens CMD Plugin by Mateus Moreira aka iPSYKO
|
||||||
# @LichtHund
|
# @LichtHund
|
||||||
|
# Wiki: https://github.com/ipsk/CitizensCMD/wiki
|
||||||
|
# GitHub: https://github.com/ipsk/CitizensCMD
|
||||||
|
# Spigot: https://www.spigotmc.org/resources/citizens-cmd.30224/
|
||||||
|
|
||||||
main: me.mattmoreira.citizenscmd.CitizensCMD
|
main: me.mattmoreira.citizenscmd.CitizensCMD
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
|
Loading…
Reference in New Issue
Block a user