diff --git a/.gitignore b/.gitignore index d7237b8..36b43dd 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,14 @@ local.properties .classpath .settings/ .loadpath +/target +/dependency-reduced-pom.xml + +# intellij +*.iml +*.ipr +*.iws +.idea/ # External tool builders .externalToolBuilders/ @@ -27,94 +35,6 @@ local.properties # PDT-specific .buildpath -target/ - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results -[Dd]ebug/ -[Rr]elease/ -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.vspscc -.builds -*.dotCover - -## TODO: If you have NuGet Package Restore enabled, uncomment this -#packages/ - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf - -# Visual Studio profiler -*.psess -*.vsp - -# ReSharper is a .NET coding add-in -_ReSharper* - -# Installshield output folder -[Ee]xpress - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish - -# Others -[Bb]in -[Oo]bj -sql -TestResults -*.Cache -ClientBin -stylecop.* -~$* -*.dbmdl -Generated_Code #added for RIA/Silverlight projects - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML - - ############ ## Windows @@ -126,26 +46,6 @@ Thumbs.db # Folder config file Desktop.ini - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg - # Installer logs pip-log.txt diff --git a/README.md b/README.md index 9bac32e..002054f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ -CommandBouncer -============== - -[![Build Status](https://travis-ci.org/Simple-devs/CommandBouncer.png?branch=0.3)](https://travis-ci.org/Simple-devs/CommandBouncer) +CommandBouncer [![Build Status](https://travis-ci.org/Simple-devs/CommandBouncer.png?branch=0.3)](https://travis-ci.org/Simple-devs/CommandBouncer) +================== This plugin executes a given command when a player executes a certain command @@ -16,12 +14,12 @@ Development ============== For developing please use the latest branch. -To help us develop this plugin you'll need: +To help us develop this plugin, you'll need: -- GitHub +- [GitHub](http://github.com) -- NetBeans +- [NetBeans](https://netbeans.org) -- Maven +- [Maven](http://maven.apache.org) - A bukkit test server with the latest CraftBukkit `http://dl.bukkit.org/latest-dev/craftbukkit.jar` diff --git a/src/main/java/com/carlgo11/CommandBouncer/Checks.java b/src/main/java/com/carlgo11/CommandBouncer/Checks.java index cb90574..c1ebbab 100644 --- a/src/main/java/com/carlgo11/CommandBouncer/Checks.java +++ b/src/main/java/com/carlgo11/CommandBouncer/Checks.java @@ -7,29 +7,17 @@ public class Checks { public static boolean checkDisOutput(CommandBouncer plugin, String cmd) { - if (plugin.getConfig().getStringList("disabled-commands").contains(cmd)) { - return true; - } else { - return false; - } + return (plugin.getConfig().getStringList("disabled-commands").contains(cmd)); } public static boolean checkDisWorld(CommandBouncer plugin, World world) { - if (plugin.getConfig().getStringList("disabled-worlds").contains(world.getName())) { - return true; - } else { - return false; - } + return (plugin.getConfig().getStringList("disabled-worlds").contains(world.getName())); } public static boolean checkDisPlayer(CommandBouncer plugin, Player p) { - if (plugin.getConfig().getStringList("ignored-players").contains(p.getName())) { - return true; - } else { - return false; - } + return (plugin.getConfig().getStringList("ignored-players").contains(p.getName())); } } diff --git a/src/main/java/com/carlgo11/CommandBouncer/CommandBouncer.java b/src/main/java/com/carlgo11/CommandBouncer/CommandBouncer.java index 589c16a..515668d 100644 --- a/src/main/java/com/carlgo11/CommandBouncer/CommandBouncer.java +++ b/src/main/java/com/carlgo11/CommandBouncer/CommandBouncer.java @@ -98,14 +98,13 @@ public void checkcmd() { for (a = a; b != c; a++) { - if (getConfig().contains("cmd" + a)) { - } else { + if (!getConfig().contains("cmd" + a)) { b++; } } if (b == c) { - if (getConfig().getBoolean("debug") == true) { + if (getConfig().getBoolean("debug")) { System.out.println("While loop closed"); } this.getLogger().info("Loaded " + a + " cmds from the config!"); diff --git a/src/main/java/com/carlgo11/CommandBouncer/Commands/CommandBouncerCommand.java b/src/main/java/com/carlgo11/CommandBouncer/Commands/CommandBouncerCommand.java index f47e683..512d6b0 100644 --- a/src/main/java/com/carlgo11/CommandBouncer/Commands/CommandBouncerCommand.java +++ b/src/main/java/com/carlgo11/CommandBouncer/Commands/CommandBouncerCommand.java @@ -124,7 +124,7 @@ void support(CommandSender sender, String prefix) if (sender.hasPermission("commandbouncer.cmd.commandbouncer.support")) { try { String pastebin = Pastebin.makePaste(Report.Main(plugin), plugin.getDescription().getName()); - String purelink = pastebin.toString().replace("http://pastebin.com/", ""); + String purelink = pastebin.replace("http://pastebin.com/", ""); sender.sendMessage("" + prefix + ChatColor.GREEN + "Thank you for choosing our support IRC!\nIf the helpers busy please post a question on bukkit."); sender.sendMessage(ChatColor.YELLOW + "Connect with this link: " + ChatColor.BLUE + "http://cajs.co.uk/link/msg-irc?&nick=cmdbnc_" + purelink); sender.sendMessage(ChatColor.YELLOW + "Here's your log: " + ChatColor.BLUE + pastebin + "\n" + ChatColor.GREEN + "Please give the developers your log."); diff --git a/src/main/java/com/carlgo11/CommandBouncer/player/CommandListener.java b/src/main/java/com/carlgo11/CommandBouncer/player/CommandListener.java index bd67575..aa2c7a3 100644 --- a/src/main/java/com/carlgo11/CommandBouncer/player/CommandListener.java +++ b/src/main/java/com/carlgo11/CommandBouncer/player/CommandListener.java @@ -2,34 +2,48 @@ import com.carlgo11.CommandBouncer.Checks; import com.carlgo11.CommandBouncer.CommandBouncer; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; public class CommandListener implements Listener { CommandBouncer plugin; - public CommandListener(CommandBouncer plug) - { + public CommandListener(CommandBouncer plug) { super(); this.plugin = plug; } @EventHandler - public void onPlayerCommand(PlayerCommandPreprocessEvent e) - { + public void onPlayerCommand(PlayerCommandPreprocessEvent e) { plugin.senddebug("a = " + CommandBouncer.a); plugin.senddebug("b = " + CommandBouncer.b); Player player = e.getPlayer(); String cmd = e.getMessage(); - final String[] asd = e.getMessage().split(" "); for (int a = 1; a != CommandBouncer.a; a++) { plugin.senddebug("forloop started!"); - if (e.getMessage().equalsIgnoreCase("/" + plugin.getConfig().getString("cmd" + a))) { + + String wildCommand = null; + String[] splitCommand = e.getMessage().split(" "); + // Iterate through the split command + for (int x = 1; x <= splitCommand.length; x++) { + if (!splitCommand[0].equals("*")) { + if (splitCommand[x].equals("*")) { + // Iterate through the sections of the split command before the '*' character + for (int y = 0; y <= x; y++) { + // Build a new string with the sections below and including the '*' character + wildCommand = wildCommand + " " + splitCommand[y]; + } + break; + } + } + } + + if (e.getMessage().equalsIgnoreCase("/" + plugin.getConfig().getString("cmd" + a)) || (wildCommand != null && wildCommand.equalsIgnoreCase("/" + plugin.getConfig().getString("cmd" + a)))) { plugin.senddebug("matches cmd" + a); if (!Checks.checkDisPlayer(plugin, player)) { if (!Checks.checkDisWorld(plugin, player.getWorld())) { @@ -37,11 +51,11 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent e) if (Checks.checkDisOutput(plugin, "cmd" + a)) { e.setCancelled(true); - System.out.println(player.getName() + " issued server command: " + cmd.toString()); + System.out.println(player.getName() + " issued server command: " + cmd); } if (plugin.getConfig().contains("console" + a)) { for (int i = 0; i < plugin.getConfig().getStringList("console" + a).size(); i++) { - String curcmd = plugin.getConfig().getStringList("console" + a).get(i).toString(); + String curcmd = plugin.getConfig().getStringList("console" + a).get(i); String replaceinput = curcmd.replaceAll("%player%", player.getName()); String replaceinput2 = replaceinput.replaceAll("%world%", player.getWorld().getName()); plugin.senddebug("dastring:" + replaceinput); @@ -54,7 +68,7 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent e) if (plugin.getConfig().contains("player" + a)) { for (int i = 0; i < plugin.getConfig().getStringList("player" + a).size(); i++) { - String curcmd = plugin.getConfig().getStringList("player" + a).get(i).toString(); + String curcmd = plugin.getConfig().getStringList("player" + a).get(i); String replaceinput = curcmd.replaceAll("%player%", player.getName()); String replaceinput2 = replaceinput.replaceAll("%world%", player.getWorld().getName()); plugin.senddebug("dastring:" + replaceinput); @@ -76,7 +90,7 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent e) plugin.senddebug(player.getName() + " is an ignored player."); } } else { - if (plugin.getConfig().getBoolean("debug") == true) { + if (plugin.getConfig().getBoolean("debug")) { System.out.println("[" + plugin.getDescription().getName() + "] " + "No match: cmd" + a); System.out.println("[" + plugin.getDescription().getName() + "] " + player.getName() + "'s-cmd:" + e.getMessage()); System.out.println("[" + plugin.getDescription().getName() + "] " + "cmd" + a + ":" + plugin.getConfig().getString("cmd" + a)); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7ef72f4..5927eee 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,18 +20,18 @@ config-version: 1.0 # +------------------------------------------------------+ # ############################################################ -# Does this plugin not work? Set "debug" to true and pastie your server.log to an developer +# Does this plugin not work? Set "debug" to true and pastie your server.log to a developer # true/false debug: false -# Do you want the plugin to update automaticly when a new version is avible? (Recommended: 'true') +# Do you want the plugin to update automatically when a new version is available? (Recommended: 'true') auto-update: true -# If auto-update is set to false. Who should recive information when a new update is available? (Recommended: 'perm') +# If auto-update is set to false, who should receive information when a new update is available? (Recommended: 'perm') # Available options: op, perm, none warn-update: perm -# Want to backup the current config and replace it with a new one when a new version of CommandBouncer is downloaded? (Might cause you some extra work when a new version is downloaded) +# Would you like to to backup the current config and replace it with a new one when a new version of CommandBouncer is downloaded? (Might cause you some extra work when a new version is downloaded) update-config: false # When seeking assistance via /CommandBouncer support/report should the plugin upload your latest.log? (Recommended: 'true') @@ -54,9 +54,9 @@ ignored-players: - anminecrafter - zyxep -# Do you want to disable the incomming message when a command matches a commnad listed below? +# Do you want to disable the incoming message when a command matches a command listed below? # Example: player types /op & the command is set to be disabled /op won't be executed but the bounce-command will. -# If a cmd is not set below it will not be disabled. +# If a cmd is not set below, it will not be disabled. disabled-commands: - cmd1 @@ -67,8 +67,8 @@ disabled-commands: # +------------------------------------------------------+ # ############################################################ -# Enter the commands you want the plugin to listen on use the same number on the listening command as on the bouncer command! -# EXAMPLE: cmd1: hi +# Enter the commands you want the plugin to listen on. Use the same number on the listening command as on the bouncer command! +# EXAMPLE: cmd1: hi (Remember to use the same number on the console commands - console1: msg %player% Hello!) cmd1: cmdbnctest ############################################################