Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10 from psgs/0.3
Browse files Browse the repository at this point in the history
Add WildCard support, optimize boolean results, improve language use
  • Loading branch information
Carlgo11 committed Feb 17, 2014
2 parents ce3d47a + 32a821e commit e343caf
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 155 deletions.
116 changes: 8 additions & 108 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ local.properties
.classpath
.settings/
.loadpath
/target
/dependency-reduced-pom.xml

# intellij
*.iml
*.ipr
*.iws
.idea/

# External tool builders
.externalToolBuilders/
Expand All @@ -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
Expand All @@ -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

Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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`
18 changes: 3 additions & 15 deletions src/main/java/com/carlgo11/CommandBouncer/Checks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

}
5 changes: 2 additions & 3 deletions src/main/java/com/carlgo11/CommandBouncer/CommandBouncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,60 @@

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())) {
if (player.hasPermission("CommandBouncer.listen.cmd" + a) || player.hasPermission("CommandBouncer.listen.cmd*")) { // Checks if player has permission

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);
Expand All @@ -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);
Expand All @@ -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));
Expand Down
16 changes: 8 additions & 8 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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

############################################################
Expand Down

0 comments on commit e343caf

Please sign in to comment.