Skip to content

Commit

Permalink
[BREAKING] Create a common interface for per-player debug messages.
Browse files Browse the repository at this point in the history
Breaking, because it alters Check, CheckListener and BaseAdapter. Not
really meant/possible to be used by external plugins, though.
  • Loading branch information
asofold committed Mar 10, 2016
1 parent 8d43b0a commit 7dcbe3d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
Expand Up @@ -12,6 +12,7 @@
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.net.NetConfigCache;
import fr.neatmonster.nocheatplus.checks.net.NetDataFactory;
import fr.neatmonster.nocheatplus.components.IDebugPlayer;
import fr.neatmonster.nocheatplus.stats.Counters;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;

Expand All @@ -20,7 +21,7 @@
* @author asofold
*
*/
public abstract class BaseAdapter extends PacketAdapter {
public abstract class BaseAdapter extends PacketAdapter implements IDebugPlayer {

protected final Counters counters = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Counters.class);
protected final NetConfigCache configFactory = (NetConfigCache) CheckType.NET.getConfigFactory();
Expand Down Expand Up @@ -53,11 +54,7 @@ public BaseAdapter(Plugin plugin, PacketType... types) {
super(plugin, types);
}

/**
* Convenience method for logging the standard format.
* @param player
* @param message
*/
@Override
public void debug(final Player player, final String message) {
CheckUtils.debug(player, checkType, message);
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.components.IDebugPlayer;
import fr.neatmonster.nocheatplus.components.MCAccessHolder;
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
import fr.neatmonster.nocheatplus.players.DataManager;
Expand Down Expand Up @@ -56,7 +57,7 @@
* actual check.</li>
*
*/
public abstract class Check implements MCAccessHolder {
public abstract class Check implements MCAccessHolder, IDebugPlayer {

// TODO: Do these get cleaned up ?
/** The execution histories of each check. */
Expand Down Expand Up @@ -227,14 +228,7 @@ public MCAccess getMCAccess() {
return mcAccess;
}

/**
* Output a message for a player with the standard format (see
* CheckUtils.debug(Player, CheckType, String).
*
* @param player
* Can be null.
* @param message
*/
@Override
public void debug(final Player player, final String message) {
CheckUtils.debug(player, type, message);
}
Expand Down
Expand Up @@ -9,6 +9,7 @@

import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.components.IDebugPlayer;
import fr.neatmonster.nocheatplus.components.IHoldSubComponents;
import fr.neatmonster.nocheatplus.components.MCAccessHolder;
import fr.neatmonster.nocheatplus.components.NCPListener;
Expand All @@ -20,7 +21,7 @@
* @author mc_dev
*
*/
public class CheckListener extends NCPListener implements MCAccessHolder, IHoldSubComponents{
public class CheckListener extends NCPListener implements MCAccessHolder, IHoldSubComponents, IDebugPlayer {

/** Check group / type which this listener is for. */
protected final CheckType checkType;
Expand Down Expand Up @@ -69,14 +70,7 @@ public Collection<Object> getSubComponents() {
return res;
}

/**
* Output a message for a player with the standard format (see
* CheckUtils.debug(Player, CheckType, String).
*
* @param player
* Can be null.
* @param message
*/
@Override
public void debug(final Player player, final String message) {
CheckUtils.debug(player, checkType, message);
}
Expand Down
@@ -0,0 +1,23 @@
package fr.neatmonster.nocheatplus.components;

import org.bukkit.entity.Player;

/**
* Convenient player-specific debug messages with standard format.
*
* @author asofold
*
*/
public interface IDebugPlayer {

/**
* Output a message for a player with the standard format (see
* CheckUtils.debug(Player, CheckType, String).
*
* @param player
* May be null.
* @param message
*/
public void debug(Player player, String message);

}

0 comments on commit 7dcbe3d

Please sign in to comment.