forked from Upstream/CitizensCMD
Click sound + release 2.1
This commit is contained in:
parent
8b38473896
commit
a00244db89
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.1-SNAPSHOT</version>
|
<version>2.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>CitizensCMD</name>
|
<name>CitizensCMD</name>
|
||||||
|
@ -239,7 +239,7 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
getCommand("npcmd").setExecutor(commandHandler);
|
getCommand("npcmd").setExecutor(commandHandler);
|
||||||
Stream.of(new CMDHelp(), new CMDAdd(), new CMDCooldown(), new CMDList(), new CMDReload(), new CMDRemove(), new CMDEdit(), new CMDPrice()).forEach(commandHandler::register);
|
Stream.of(new CMDHelp(), new CMDAdd(), new CMDCooldown(), new CMDList(), new CMDReload(), new CMDRemove(), new CMDEdit(), new CMDPrice(), new CMDSound()).forEach(commandHandler::register);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,7 @@ import net.citizensnpcs.api.event.NPCRemoveEvent;
|
|||||||
import net.citizensnpcs.api.event.NPCRightClickEvent;
|
import net.citizensnpcs.api.event.NPCRightClickEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -70,6 +71,11 @@ public class NPCListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CitizensCMD.getPlugin().getDataHandler().hasSound(npc)) {
|
||||||
|
List<String> soundProperties = CitizensCMD.getPlugin().getDataHandler().getNPCSound(npc);
|
||||||
|
player.playSound(player.getLocation(), Sound.valueOf(soundProperties.get(0)), Float.parseFloat(soundProperties.get(1)), Float.parseFloat(soundProperties.get(2)));
|
||||||
|
}
|
||||||
|
|
||||||
if (CitizensCMD.getPlugin().getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.RIGHT)) return;
|
if (CitizensCMD.getPlugin().getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.RIGHT)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +165,6 @@ public class NPCListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!player.hasPermission("citizenscmd.bypass") || CitizensCMD.getPlugin().getDataHandler().getNPCCooldown(npc) != 0)
|
if (!player.hasPermission("citizenscmd.bypass") || CitizensCMD.getPlugin().getDataHandler().getNPCCooldown(npc) != 0)
|
||||||
CitizensCMD.getPlugin().getCooldownHandler().addInteraction(npc, player.getUniqueId().toString(), System.nanoTime());
|
CitizensCMD.getPlugin().getCooldownHandler().addInteraction(npc, player.getUniqueId().toString(), System.nanoTime());
|
||||||
|
|
||||||
@ -185,6 +190,11 @@ public class NPCListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CitizensCMD.getPlugin().getDataHandler().hasSound(npc)) {
|
||||||
|
List<String> soundProperties = CitizensCMD.getPlugin().getDataHandler().getNPCSound(npc);
|
||||||
|
player.playSound(player.getLocation(), Sound.valueOf(soundProperties.get(0)), Float.parseFloat(soundProperties.get(1)), Float.parseFloat(soundProperties.get(2)));
|
||||||
|
}
|
||||||
|
|
||||||
if (CitizensCMD.getPlugin().getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.LEFT)) return;
|
if (CitizensCMD.getPlugin().getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.LEFT)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* CitizensCMD - Add-on for Citizens
|
||||||
|
* Copyright (C) 2018 Mateus Moreira
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* <p>
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.mattmoreira.citizenscmd.commands;
|
||||||
|
|
||||||
|
import me.mattmoreira.citizenscmd.CitizensCMD;
|
||||||
|
import me.mattmoreira.citizenscmd.commands.base.CommandBase;
|
||||||
|
import me.mattmoreira.citizenscmd.utility.Path;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import static me.mattmoreira.citizenscmd.utility.Util.*;
|
||||||
|
|
||||||
|
public class CMDSound extends CommandBase {
|
||||||
|
|
||||||
|
public CMDSound() {
|
||||||
|
super("sound", "citizenscmd.sound", false, null, 0, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(Player player, String[] args) {
|
||||||
|
|
||||||
|
if (npcNotSelected(player)) return;
|
||||||
|
|
||||||
|
int npc = getSelectedNpcId(player);
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
CitizensCMD.getPlugin().getDataHandler().removeSound(npc, player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String soundString = args[0];
|
||||||
|
Sound sound;
|
||||||
|
float volume = 1f;
|
||||||
|
float pitch = 1f;
|
||||||
|
|
||||||
|
if (args.length > 1)
|
||||||
|
if (isFloat(args[1]))
|
||||||
|
volume = Float.valueOf(args[1]);
|
||||||
|
|
||||||
|
if (args.length > 2)
|
||||||
|
if (isFloat(args[2]))
|
||||||
|
pitch = Float.valueOf(args[2]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
sound = Sound.valueOf(soundString);
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.sendMessage(color(HEADER));
|
||||||
|
player.sendMessage(CitizensCMD.getPlugin().getLang().getMessage(Path.INVALID_SOUND));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CitizensCMD.getPlugin().getDataHandler().setSound(npc, sound, volume, pitch, player);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -180,6 +180,10 @@ public class CommandHandler implements CommandExecutor, TabCompleter, IHandler {
|
|||||||
return getCommandNames(subCMD, args, 5, (Player) sender);
|
return getCommandNames(subCMD, args, 5, (Player) sender);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "sound":
|
||||||
|
if (args.length == 2) return getCommandNames(subCMD, args, 1, (Player) sender);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -203,7 +207,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter, IHandler {
|
|||||||
if (!args[arg - 1].equals("")) {
|
if (!args[arg - 1].equals("")) {
|
||||||
for (String commandName : argsComplete[arg - 1]) {
|
for (String commandName : argsComplete[arg - 1]) {
|
||||||
if (arg + 1 > args.length) break;
|
if (arg + 1 > args.length) break;
|
||||||
if (!commandName.startsWith(args[arg].toLowerCase())) continue;
|
if (!commandName.toLowerCase().startsWith(args[arg].toLowerCase())) continue;
|
||||||
commandNames.add(commandName);
|
commandNames.add(commandName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,6 +21,7 @@ package me.mattmoreira.citizenscmd.files;
|
|||||||
import me.mattmoreira.citizenscmd.CitizensCMD;
|
import me.mattmoreira.citizenscmd.CitizensCMD;
|
||||||
import me.mattmoreira.citizenscmd.utility.EnumTypes;
|
import me.mattmoreira.citizenscmd.utility.EnumTypes;
|
||||||
import me.mattmoreira.citizenscmd.utility.Path;
|
import me.mattmoreira.citizenscmd.utility.Path;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -91,6 +92,7 @@ public class DataHandler {
|
|||||||
data.put("npc-data." + parent + "." + child, dataConfigurator.getInt("npc-data." + parent + "." + child));
|
data.put("npc-data." + parent + "." + child, dataConfigurator.getInt("npc-data." + parent + "." + child));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "sound":
|
||||||
case "right-click-commands":
|
case "right-click-commands":
|
||||||
case "left-click-commands":
|
case "left-click-commands":
|
||||||
data.put("npc-data." + parent + "." + child, dataConfigurator.getStringList("npc-data." + parent + "." + child));
|
data.put("npc-data." + parent + "." + child, dataConfigurator.getStringList("npc-data." + parent + "." + child));
|
||||||
@ -161,6 +163,11 @@ public class DataHandler {
|
|||||||
dataConfigurator.set("npc-data.npc-" + npc + ".price", 0);
|
dataConfigurator.set("npc-data.npc-" + npc + ".price", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!data.containsKey("npc-data.npc-" + npc + ".sound")) {
|
||||||
|
data.put("npc-data.npc-" + npc + ".sound", new ArrayList<>());
|
||||||
|
dataConfigurator.set("npc-data.npc-" + npc + ".sound", new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
player.sendMessage(color(HEADER));
|
player.sendMessage(color(HEADER));
|
||||||
player.sendMessage(CitizensCMD.getPlugin().getLang().getMessage(Path.NPC_ADDED));
|
player.sendMessage(CitizensCMD.getPlugin().getLang().getMessage(Path.NPC_ADDED));
|
||||||
|
|
||||||
@ -227,6 +234,44 @@ public class DataHandler {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the sound of the NPC command
|
||||||
|
*
|
||||||
|
* @param npc The NPC id
|
||||||
|
* @param sound The sound to play
|
||||||
|
* @param volume the volume
|
||||||
|
* @param pitch the pitch
|
||||||
|
* @param player The player who run the command
|
||||||
|
*/
|
||||||
|
public void setSound(int npc, Sound sound, float volume, float pitch, Player player) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
createBasics();
|
||||||
|
dataConfigurator.load(savesFile);
|
||||||
|
|
||||||
|
List<String> soundProperties = new ArrayList<>();
|
||||||
|
|
||||||
|
soundProperties.add(sound.name());
|
||||||
|
soundProperties.add(String.valueOf(volume));
|
||||||
|
soundProperties.add(String.valueOf(pitch));
|
||||||
|
|
||||||
|
dataConfigurator.set("npc-data.npc-" + npc + ".sound", soundProperties);
|
||||||
|
|
||||||
|
if (data.containsKey("npc-data.npc-" + npc + ".sound"))
|
||||||
|
data.replace("npc-data.npc-" + npc + ".sound", soundProperties);
|
||||||
|
else
|
||||||
|
data.put("npc-data.npc-" + npc + ".sound", soundProperties);
|
||||||
|
|
||||||
|
player.sendMessage(color(HEADER));
|
||||||
|
player.sendMessage(CitizensCMD.getPlugin().getLang().getMessage(Path.SOUND_ADDED));
|
||||||
|
|
||||||
|
dataConfigurator.save(savesFile);
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the click commands from the saves.yml
|
* Gets the click commands from the saves.yml
|
||||||
*
|
*
|
||||||
@ -266,6 +311,12 @@ public class DataHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasSound(int npc) {
|
||||||
|
if (data.containsKey("npc-data.npc-" + npc + ".sound"))
|
||||||
|
return !(((List<String>) data.get("npc-data.npc-" + npc + ".sound")).isEmpty());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cooldown of the NPC
|
* Gets the cooldown of the NPC
|
||||||
*
|
*
|
||||||
@ -276,6 +327,10 @@ public class DataHandler {
|
|||||||
return data.containsKey("npc-data.npc-" + npc + ".cooldown") ? (int) data.get("npc-data.npc-" + npc + ".cooldown") : 0;
|
return data.containsKey("npc-data.npc-" + npc + ".cooldown") ? (int) data.get("npc-data.npc-" + npc + ".cooldown") : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getNPCSound(int npc) {
|
||||||
|
return (List<String>) data.get("npc-data.npc-" + npc + ".sound");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the price of the NPC
|
* Gets the price of the NPC
|
||||||
*
|
*
|
||||||
@ -317,6 +372,27 @@ public class DataHandler {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSound(int npc, Player player) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
createBasics();
|
||||||
|
dataConfigurator.load(savesFile);
|
||||||
|
|
||||||
|
List<String> soundProperties = new ArrayList<>();
|
||||||
|
|
||||||
|
data.replace("npc-data.npc-" + npc + ".sound", soundProperties);
|
||||||
|
dataConfigurator.set("npc-data.npc-" + npc + ".sound", soundProperties);
|
||||||
|
|
||||||
|
player.sendMessage(color(HEADER));
|
||||||
|
player.sendMessage(CitizensCMD.getPlugin().getLang().getMessage(Path.SOUND_REMOVED));
|
||||||
|
|
||||||
|
dataConfigurator.save(savesFile);
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits a command or permission from the NPC
|
* Edits a command or permission from the NPC
|
||||||
*
|
*
|
||||||
|
@ -91,6 +91,90 @@ public class LangHandler {
|
|||||||
if (!langConf.contains(Path.MESSAGE_DISPLAY))
|
if (!langConf.contains(Path.MESSAGE_DISPLAY))
|
||||||
langConf.set(Path.MESSAGE_DISPLAY, "{name}:&r");
|
langConf.set(Path.MESSAGE_DISPLAY, "{name}:&r");
|
||||||
|
|
||||||
|
if (!langConf.contains(Path.INVALID_SOUND)) {
|
||||||
|
switch (lang) {
|
||||||
|
case "en":
|
||||||
|
langConf.set(Path.INVALID_SOUND, "&cPlease enter a valid sound!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "pt":
|
||||||
|
langConf.set(Path.INVALID_SOUND, "&cSelecione um som válido!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ro":
|
||||||
|
langConf.set(Path.INVALID_SOUND, "&cIntroduceți un sunet valid!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "bg":
|
||||||
|
langConf.set(Path.INVALID_SOUND, "&cМоля, въведете валиден звук!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "no":
|
||||||
|
langConf.set(Path.INVALID_SOUND, "&cVennligst skriv inn en gyldig lyd!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ch":
|
||||||
|
langConf.set(Path.INVALID_SOUND, "&c请输入有效的声音!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!langConf.contains(Path.SOUND_ADDED)) {
|
||||||
|
switch (lang) {
|
||||||
|
case "en":
|
||||||
|
langConf.set(Path.SOUND_ADDED, "&aSound added successfully!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "pt":
|
||||||
|
langConf.set(Path.SOUND_ADDED, "&aSom adicionado com sucesso!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ro":
|
||||||
|
langConf.set(Path.SOUND_ADDED, "&aSunetul a fost adăugat cu succes!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "bg":
|
||||||
|
langConf.set(Path.SOUND_ADDED, "&aЗвукът е добавен успешно!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "no":
|
||||||
|
langConf.set(Path.SOUND_ADDED, "&aLyd lagt til!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ch":
|
||||||
|
langConf.set(Path.SOUND_ADDED, "&a声音成功添加!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!langConf.contains(Path.SOUND_REMOVED)) {
|
||||||
|
switch (lang) {
|
||||||
|
case "en":
|
||||||
|
langConf.set(Path.SOUND_REMOVED, "&aSound removed successfully!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "pt":
|
||||||
|
langConf.set(Path.SOUND_REMOVED, "&aSom removido com sucesso!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ro":
|
||||||
|
langConf.set(Path.SOUND_REMOVED, "&aSunetul a fost eliminat cu succes!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "bg":
|
||||||
|
langConf.set(Path.SOUND_REMOVED, "&aЗвукът е премахнат успешно!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "no":
|
||||||
|
langConf.set(Path.SOUND_REMOVED, "&aLyden fjernet vellykket!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ch":
|
||||||
|
langConf.set(Path.SOUND_REMOVED, "&a声音已成功删除!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (String parent : langConf.getConfigurationSection("messages").getKeys(false)) {
|
for (String parent : langConf.getConfigurationSection("messages").getKeys(false)) {
|
||||||
for (String child : langConf.getConfigurationSection("messages." + parent).getKeys(false))
|
for (String child : langConf.getConfigurationSection("messages." + parent).getKeys(false))
|
||||||
messages.put("messages." + parent + "." + child, langConf.getString("messages." + parent + "." + child));
|
messages.put("messages." + parent + "." + child, langConf.getString("messages." + parent + "." + child));
|
||||||
|
@ -38,6 +38,9 @@ public class Path {
|
|||||||
public static final String RELOAD = MAIN_PATH_COMMANDS + "reload-command";
|
public static final String RELOAD = MAIN_PATH_COMMANDS + "reload-command";
|
||||||
public static final String REMOVED_COMMAND = MAIN_PATH_COMMANDS + "removed-command";
|
public static final String REMOVED_COMMAND = MAIN_PATH_COMMANDS + "removed-command";
|
||||||
public static final String EDITED_COMMAND = MAIN_PATH_COMMANDS + "edit-command";
|
public static final String EDITED_COMMAND = MAIN_PATH_COMMANDS + "edit-command";
|
||||||
|
public static final String INVALID_SOUND = MAIN_PATH_COMMANDS + "invalid-sound";
|
||||||
|
public static final String SOUND_ADDED = MAIN_PATH_COMMANDS + "sound-added";
|
||||||
|
public static final String SOUND_REMOVED = MAIN_PATH_COMMANDS + "sound-removed";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WARNINGS
|
* WARNINGS
|
||||||
|
@ -22,6 +22,7 @@ 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.Sound;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -65,6 +66,19 @@ public class Util {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param str String to check if it is a float 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 isFloat(String str) {
|
||||||
|
try {
|
||||||
|
Float.parseFloat(str);
|
||||||
|
} catch (NumberFormatException | NullPointerException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if player has or not selected an NPC
|
* Checks if player has or not selected an NPC
|
||||||
*
|
*
|
||||||
@ -159,10 +173,26 @@ public class Util {
|
|||||||
argComplete[2] = CitizensCMD.getPlugin().getDataHandler().getCompleteCommandsNumbers(getSelectedNpcId(player), EnumTypes.ClickType.LEFT);
|
argComplete[2] = CitizensCMD.getPlugin().getDataHandler().getCompleteCommandsNumbers(getSelectedNpcId(player), EnumTypes.ClickType.LEFT);
|
||||||
argComplete[3] = CitizensCMD.getPlugin().getDataHandler().getCompleteCommandsNumbers(getSelectedNpcId(player), EnumTypes.ClickType.RIGHT);
|
argComplete[3] = CitizensCMD.getPlugin().getDataHandler().getCompleteCommandsNumbers(getSelectedNpcId(player), EnumTypes.ClickType.RIGHT);
|
||||||
argComplete[4] = new String[]{"console", "none", "permission", "server", "message"};
|
argComplete[4] = new String[]{"console", "none", "permission", "server", "message"};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "sound":
|
||||||
|
argComplete[0] = getSoundsList();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return argComplete;
|
return argComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String[] getSoundsList() {
|
||||||
|
Sound[] sounds = Sound.values();
|
||||||
|
String[] soundString = new String[sounds.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < sounds.length; i++) {
|
||||||
|
soundString[i] = sounds[i].name();
|
||||||
|
}
|
||||||
|
|
||||||
|
return soundString;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the difference in seconds between times
|
* Gets the difference in seconds between times
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,9 @@ messages:
|
|||||||
reload-command: "&aВсичко файлове бяха презаредени успешно!"
|
reload-command: "&aВсичко файлове бяха презаредени успешно!"
|
||||||
removed-command: "&aКомандата бе премахната успешно!"
|
removed-command: "&aКомандата бе премахната успешно!"
|
||||||
edit-command: "&a{type} бе променен/а успешно!"
|
edit-command: "&a{type} бе променен/а успешно!"
|
||||||
|
invalid-sound: "&cМоля, въведете валиден звук!"
|
||||||
|
sound-added: "&aЗвукът е добавен успешно!"
|
||||||
|
sound-removed: "&aЗвукът е премахнат успешно!"
|
||||||
warnings:
|
warnings:
|
||||||
no-npc-selected: "&cИзбери NPC първо!"
|
no-npc-selected: "&cИзбери NPC първо!"
|
||||||
invalid-cooldown: "&cВремето за изчакване трябва да бъде число!"
|
invalid-cooldown: "&cВремето за изчакване трябва да бъде число!"
|
||||||
|
@ -21,6 +21,9 @@ messages:
|
|||||||
reload-command: "&a所有檔案已經被重新載入!"
|
reload-command: "&a所有檔案已經被重新載入!"
|
||||||
removed-command: "&a這個指令已經被成功移除!"
|
removed-command: "&a這個指令已經被成功移除!"
|
||||||
edit-command: "&a {type} 已經被編輯!"
|
edit-command: "&a {type} 已經被編輯!"
|
||||||
|
invalid-sound: "&c请输入有效的声音!"
|
||||||
|
sound-added: "&a声音成功添加!"
|
||||||
|
sound-removed: "&a声音已成功删除!"
|
||||||
warnings:
|
warnings:
|
||||||
no-npc-selected: "&c你一定要選擇NPC來執行那個指令!"
|
no-npc-selected: "&c你一定要選擇NPC來執行那個指令!"
|
||||||
invalid-cooldown: "&c冷卻時間並不是數字!"
|
invalid-cooldown: "&c冷卻時間並不是數字!"
|
||||||
|
@ -21,6 +21,9 @@ messages:
|
|||||||
reload-command: "&aAll files have been reloaded successfully!"
|
reload-command: "&aAll files have been reloaded successfully!"
|
||||||
removed-command: "&aThe command was removed successfully!"
|
removed-command: "&aThe command was removed successfully!"
|
||||||
edit-command: "&aThe {type} was edited successfully!"
|
edit-command: "&aThe {type} was edited successfully!"
|
||||||
|
invalid-sound: "&cPlease enter a valid sound!"
|
||||||
|
sound-added: "&aSound added successfully!"
|
||||||
|
sound-removed: "&aSound removed successfully!"
|
||||||
warnings:
|
warnings:
|
||||||
no-npc-selected: "&cYou must have an NPC selected to execute that command!"
|
no-npc-selected: "&cYou must have an NPC selected to execute that command!"
|
||||||
invalid-cooldown: "&cThe cooldown must be a number!"
|
invalid-cooldown: "&cThe cooldown must be a number!"
|
||||||
|
@ -21,6 +21,9 @@ messages:
|
|||||||
reload-command: "&aAlle fillene har blitt reloadet!"
|
reload-command: "&aAlle fillene har blitt reloadet!"
|
||||||
removed-command: "&aKommandoen ble fjernet!"
|
removed-command: "&aKommandoen ble fjernet!"
|
||||||
edit-command: "&a{type} ble endret!"
|
edit-command: "&a{type} ble endret!"
|
||||||
|
invalid-sound: "&cVennligst skriv inn en gyldig lyd!"
|
||||||
|
sound-added: "&aLyd lagt til!"
|
||||||
|
sound-removed: "&aLyden fjernet vellykket!"
|
||||||
warnings:
|
warnings:
|
||||||
no-npc-selected: "&cDu må velge en NPC for å utføre denne kommandoen!"
|
no-npc-selected: "&cDu må velge en NPC for å utføre denne kommandoen!"
|
||||||
invalid-cooldown: "&cNedtellingen må være et tall!"
|
invalid-cooldown: "&cNedtellingen må være et tall!"
|
||||||
|
@ -21,6 +21,8 @@ messages:
|
|||||||
reload-command: "&aTodos os arquivos foram recarregados com sucesso!"
|
reload-command: "&aTodos os arquivos foram recarregados com sucesso!"
|
||||||
removed-command: "&aO comando foi removido com sucesso!"
|
removed-command: "&aO comando foi removido com sucesso!"
|
||||||
edit-command: "&aO {type} foi editado com sucesso!"
|
edit-command: "&aO {type} foi editado com sucesso!"
|
||||||
|
invalid-sound: "&cSelecione um som válido!"
|
||||||
|
sound-added: "&aSom adicionado com sucesso!"
|
||||||
warnings:
|
warnings:
|
||||||
no-npc-selected: "&cVocê deve ter um NPC selecionado para executar esse comando!"
|
no-npc-selected: "&cVocê deve ter um NPC selecionado para executar esse comando!"
|
||||||
invalid-cooldown: "&cO cooldown deve ser um número!"
|
invalid-cooldown: "&cO cooldown deve ser um número!"
|
||||||
|
@ -21,6 +21,9 @@ messages:
|
|||||||
reload-command: "&aToate fisierele au fost reincarcate cu succes!"
|
reload-command: "&aToate fisierele au fost reincarcate cu succes!"
|
||||||
removed-command: "&aComanda a fost eliminata cu succes!"
|
removed-command: "&aComanda a fost eliminata cu succes!"
|
||||||
edit-command: "&a{type} a fost editat cu succes!"
|
edit-command: "&a{type} a fost editat cu succes!"
|
||||||
|
invalid-sound: "&cIntroduceți un sunet valid!"
|
||||||
|
sound-added: "&aSunetul a fost adăugat cu succes!"
|
||||||
|
sound-removed: "&aSunetul a fost eliminat cu succes!"
|
||||||
warnings:
|
warnings:
|
||||||
no-npc-selected: "&cTrebuie sa ai un NPC selectat pentru a executa aceasta comanda!"
|
no-npc-selected: "&cTrebuie sa ai un NPC selectat pentru a executa aceasta comanda!"
|
||||||
invalid-cooldown: "&cCooldown-ul trebuie sa fie un numar!"
|
invalid-cooldown: "&cCooldown-ul trebuie sa fie un numar!"
|
||||||
|
Loading…
Reference in New Issue
Block a user