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

Commit

Permalink
Add WildCard support, update .gitignore
Browse files Browse the repository at this point in the history
Add WildCard support, update .gitignore with IntelliJ specific entries,
remove unused .toString() methods, simplify boolean returns and if
statements.
  • Loading branch information
fpigerre committed Feb 17, 2014
1 parent ce3d47a commit b76c7fe
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 139 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
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

0 comments on commit b76c7fe

Please sign in to comment.