forked from Upstream/CitizensCMD
Version 2.2 final
Sound command moved, cooldowns bug fixed.
This commit is contained in:
parent
98fc5bdbe9
commit
f115d9e330
6
pom.xml
6
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</version>
|
<version>2.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>CitizensCMD</name>
|
<name>CitizensCMD</name>
|
||||||
@ -86,7 +86,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.13-R0.1-SNAPSHOT</version>
|
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -103,7 +103,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
<version>2.9.1</version>
|
<version>2.9.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -229,7 +229,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(this), new CMDAdd(this), new CMDCooldown(this), new CMDList(this), new CMDReload(this), new CMDRemove(this), new CMDEdit(this), new CMDPrice(this), new CMDSound()).forEach(commandHandler::register);
|
Stream.of(new CMDHelp(this), new CMDAdd(this), new CMDCooldown(this), new CMDList(this), new CMDReload(this), new CMDRemove(this), new CMDEdit(this), new CMDPrice(this)).forEach(commandHandler::register);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,6 @@ public class CMDAdd extends CommandBase {
|
|||||||
commandsArray[0] = commandsArray[0].replace("/", "");
|
commandsArray[0] = commandsArray[0].replace("/", "");
|
||||||
|
|
||||||
for (int i = 0; i < commandsArray.length; i++) {
|
for (int i = 0; i < commandsArray.length; i++) {
|
||||||
|
|
||||||
if (commandsArray[i].equalsIgnoreCase("-d")) {
|
if (commandsArray[i].equalsIgnoreCase("-d")) {
|
||||||
displayName = true;
|
displayName = true;
|
||||||
commandsArray[i] = "";
|
commandsArray[i] = "";
|
||||||
@ -72,14 +71,22 @@ public class CMDAdd extends CommandBase {
|
|||||||
|
|
||||||
String finalString;
|
String finalString;
|
||||||
|
|
||||||
if (displayName)
|
if (displayName) {
|
||||||
finalString = "{display} " + stringBuilder.toString().trim();
|
finalString = "{display} " + stringBuilder.toString().trim();
|
||||||
else
|
} else
|
||||||
finalString = stringBuilder.toString().trim();
|
finalString = stringBuilder.toString().trim();
|
||||||
|
|
||||||
boolean finalLeft = left;
|
if (permission.equalsIgnoreCase("sound")) {
|
||||||
|
if (commandsArray.length < 2) {
|
||||||
|
finalString += " 1 1";
|
||||||
|
} else {
|
||||||
|
if (commandsArray.length < 3) {
|
||||||
|
finalString += " 1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugin.getDataHandler().addCommand(getSelectedNpcId(player), permission, finalString, player, finalLeft);
|
plugin.getDataHandler().addCommand(getSelectedNpcId(player), permission, finalString, player, left);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,12 +44,11 @@ public class CMDHelp extends CommandBase {
|
|||||||
JSONMessage.create(color(HEADER)).send(player);
|
JSONMessage.create(color(HEADER)).send(player);
|
||||||
JSONMessage.create(color(plugin.getLang().getUncoloredMessage(Path.HELP_VERSION) + " &c&o" + plugin.getDescription().getVersion())).send(player);
|
JSONMessage.create(color(plugin.getLang().getUncoloredMessage(Path.HELP_VERSION) + " &c&o" + plugin.getDescription().getVersion())).send(player);
|
||||||
JSONMessage.create(color(plugin.getLang().getUncoloredMessage(Path.HELP_INFO))).send(player);
|
JSONMessage.create(color(plugin.getLang().getUncoloredMessage(Path.HELP_INFO))).send(player);
|
||||||
JSONMessage.create(color("&3/npcmd &cadd &b<console &b| &bmessage &b| &bnone | &bpermission &b| &b> &6<command> &d[-l]")).suggestCommand("/npcmd add ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_ADD) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oadd &b&ossentials.heal &6&oheal")).send(player);
|
JSONMessage.create(color("&3/npcmd &cadd &b<console &b| &bmessage &b| &bnone | &bpermission &b| &bserver &b| &bsound &b> &6<command> &d[-l]")).suggestCommand("/npcmd add ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_ADD) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oadd &b&ossentials.heal &6&oheal")).send(player);
|
||||||
JSONMessage.create(color("&3/npcmd &ccooldown &6<time>")).suggestCommand("/npcmd cooldown ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_COOLDOWN) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&ocooldown &6&o15")).send(player);
|
JSONMessage.create(color("&3/npcmd &ccooldown &6<time>")).suggestCommand("/npcmd cooldown ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_COOLDOWN) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&ocooldown &6&o15")).send(player);
|
||||||
JSONMessage.create(color("&3/npcmd &cprice &6<price>")).suggestCommand("/npcmd price ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_PRICE) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oprice &6&o250")).send(player);
|
JSONMessage.create(color("&3/npcmd &cprice &6<price>")).suggestCommand("/npcmd price ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_PRICE) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oprice &6&o250")).send(player);
|
||||||
JSONMessage.create(color("&3/npcmd &clist")).suggestCommand("/npcmd list").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_LIST) + "\n&8" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&olist")).send(player);
|
JSONMessage.create(color("&3/npcmd &clist")).suggestCommand("/npcmd list").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_LIST) + "\n&8" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&olist")).send(player);
|
||||||
JSONMessage.create(color("&3/npcmd &cedit &b<cmd | perm> &b<left | right> &6<id> &6<new command | new permission>")).suggestCommand("/npcmd edit ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_EDIT) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oedit &b&ocmd &b&oright &6&o1 fly")).send(player);
|
JSONMessage.create(color("&3/npcmd &cedit &b<cmd | perm> &b<left | right> &6<id> &6<new command | new permission>")).suggestCommand("/npcmd edit ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_EDIT) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oedit &b&ocmd &b&oright &6&o1 fly")).send(player);
|
||||||
JSONMessage.create(color("&3/npcmd &csound &b<sound> &d[volume] &d[pitch]")).suggestCommand("/npcmd sound ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_SOUND) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&osound &b&oENTITY_VILLAGER_YES")).send(player);
|
|
||||||
JSONMessage.create(color("&3/npcmd &cremove &b<left | right> &6<id>")).suggestCommand("/npcmd remove ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_REMOVE) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oremove &b&oright &6&o1")).send(player);
|
JSONMessage.create(color("&3/npcmd &cremove &b<left | right> &6<id>")).suggestCommand("/npcmd remove ").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_REMOVE) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oremove &b&oright &6&o1")).send(player);
|
||||||
JSONMessage.create(color("&3/npcmd &creload")).suggestCommand("/npcmd reload").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_RELOAD) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oreload")).send(player);
|
JSONMessage.create(color("&3/npcmd &creload")).suggestCommand("/npcmd reload").tooltip(color(plugin.getLang().getUncoloredMessage(Path.HELP_DESCRIPTION_RELOAD) + "\n" + plugin.getLang().getUncoloredMessage(Path.HELP_EXAMPLE) + "\n&3&o/npcmd &c&oreload")).send(player);
|
||||||
|
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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.commands.base.CommandBase;
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -159,6 +159,8 @@ public class CommandHandler implements CommandExecutor, TabCompleter, IHandler {
|
|||||||
if (args.length == 2) return getCommandNames(subCMD, args, 1, (Player) sender);
|
if (args.length == 2) return getCommandNames(subCMD, args, 1, (Player) sender);
|
||||||
if (args[1].equalsIgnoreCase("sound")) {
|
if (args[1].equalsIgnoreCase("sound")) {
|
||||||
if (args.length == 3) return getCommandNames(subCMD, args, 2, (Player) sender);
|
if (args.length == 3) return getCommandNames(subCMD, args, 2, (Player) sender);
|
||||||
|
if (args.length == 4) return getCommandNames(subCMD, args, 3, (Player) sender);
|
||||||
|
if (args.length == 5) return getCommandNames(subCMD, args, 4, (Player) sender);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -74,11 +74,6 @@ public class NPCListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getDataHandler().hasSound(npc)) {
|
|
||||||
List<String> soundProperties = plugin.getDataHandler().getNPCSound(npc);
|
|
||||||
player.playSound(player.getLocation(), Sound.valueOf(soundProperties.get(0).toUpperCase()), Float.parseFloat(soundProperties.get(1)), Float.parseFloat(soundProperties.get(2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.RIGHT)) return;
|
if (plugin.getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.RIGHT)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +154,14 @@ public class NPCListener implements Listener {
|
|||||||
player.sendMessage(color(finalMessage));
|
player.sendMessage(color(finalMessage));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "sound":
|
||||||
|
Pattern pattern = Pattern.compile("(\\w+)\\s([\\d\\.]+)\\s([\\d\\.]+)");
|
||||||
|
Matcher matcher = pattern.matcher(commands.get(i));
|
||||||
|
if (matcher.find()) {
|
||||||
|
player.playSound(player.getLocation(), Sound.valueOf(matcher.group(1)), Float.parseFloat(matcher.group(2)), Float.parseFloat(matcher.group(3)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
plugin.getPermissionsManager().setPermission(player, permissions.get(i));
|
plugin.getPermissionsManager().setPermission(player, permissions.get(i));
|
||||||
player.chat("/" + commands.get(i));
|
player.chat("/" + commands.get(i));
|
||||||
@ -192,11 +195,6 @@ public class NPCListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getDataHandler().hasSound(npc)) {
|
|
||||||
List<String> soundProperties = plugin.getDataHandler().getNPCSound(npc);
|
|
||||||
player.playSound(player.getLocation(), Sound.valueOf(soundProperties.get(0)), Float.parseFloat(soundProperties.get(1)), Float.parseFloat(soundProperties.get(2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.LEFT)) return;
|
if (plugin.getDataHandler().hasNoCommands(npc, EnumTypes.ClickType.LEFT)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +271,14 @@ public class NPCListener implements Listener {
|
|||||||
player.sendMessage(color(finalMessage));
|
player.sendMessage(color(finalMessage));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "sound":
|
||||||
|
Pattern pattern = Pattern.compile("(\\w+)\\s([\\d\\.]+)\\s([\\d\\.]+)");
|
||||||
|
Matcher matcher = pattern.matcher(commands.get(i));
|
||||||
|
if (matcher.find()) {
|
||||||
|
player.playSound(player.getLocation(), Sound.valueOf(matcher.group(1)), Float.parseFloat(matcher.group(2)), Float.parseFloat(matcher.group(3)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
plugin.getPermissionsManager().setPermission(player, permissions.get(i));
|
plugin.getPermissionsManager().setPermission(player, permissions.get(i));
|
||||||
player.chat("/" + commands.get(i));
|
player.chat("/" + commands.get(i));
|
||||||
|
@ -162,6 +162,8 @@ public class Util {
|
|||||||
case "add":
|
case "add":
|
||||||
argComplete[0] = new String[]{"console", "none", "permission", "server", "message", "sound"};
|
argComplete[0] = new String[]{"console", "none", "permission", "server", "message", "sound"};
|
||||||
argComplete[1] = getSoundsList();
|
argComplete[1] = getSoundsList();
|
||||||
|
argComplete[2] = new String[]{"1","0.5"};
|
||||||
|
argComplete[3] = new String[]{"1","0.5"};
|
||||||
break;
|
break;
|
||||||
case "remove":
|
case "remove":
|
||||||
argComplete[0] = new String[]{"left", "right"};
|
argComplete[0] = new String[]{"left", "right"};
|
||||||
@ -222,6 +224,7 @@ public class Util {
|
|||||||
|
|
||||||
if (configFile.exists()) {
|
if (configFile.exists()) {
|
||||||
configConf.load(configFile);
|
configConf.load(configFile);
|
||||||
|
|
||||||
if (configConf.contains("check-updates")) contains[0] = true;
|
if (configConf.contains("check-updates")) contains[0] = true;
|
||||||
if (configConf.contains("lang")) contains[1] = true;
|
if (configConf.contains("lang")) contains[1] = true;
|
||||||
if (configConf.contains("default-cooldown")) contains[2] = true;
|
if (configConf.contains("default-cooldown")) contains[2] = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user