mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-03 19:00:30 +02:00
Quick rework for client-mod-motdS. One class per client for better
overview.
This commit is contained in:
parent
04f2baed50
commit
34d851e0df
|
@ -980,7 +980,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||||
if (configOutdated) player.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Your configuration might be outdated.\n" + "Some settings could have changed, you should regenerate it!");
|
if (configOutdated) player.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Your configuration might be outdated.\n" + "Some settings could have changed, you should regenerate it!");
|
||||||
|
|
||||||
}
|
}
|
||||||
ModUtil.checkModsMessage(player);
|
ModUtil.motdOnJoin(player);
|
||||||
for (final JoinLeaveListener jlListener : joinLeaveListeners){
|
for (final JoinLeaveListener jlListener : joinLeaveListeners){
|
||||||
try{
|
try{
|
||||||
jlListener.playerJoins(player);
|
jlListener.playerJoins(player);
|
||||||
|
|
|
@ -2,9 +2,14 @@ package fr.neatmonster.nocheatplus.clients;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.clients.motd.CJBMOTD;
|
||||||
|
import fr.neatmonster.nocheatplus.clients.motd.ClientMOTD;
|
||||||
|
import fr.neatmonster.nocheatplus.clients.motd.MCAutoMapMOTD;
|
||||||
|
import fr.neatmonster.nocheatplus.clients.motd.ReiMOTD;
|
||||||
|
import fr.neatmonster.nocheatplus.clients.motd.SmartMovingMOTD;
|
||||||
|
import fr.neatmonster.nocheatplus.clients.motd.ZombeMOTD;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for dealing with client mods. This is likely to by just a refactoring stage.
|
* Utilities for dealing with client mods. This is likely to by just a refactoring stage.
|
||||||
|
@ -12,125 +17,35 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ModUtil {
|
public class ModUtil {
|
||||||
|
|
||||||
|
private static final ClientMOTD[] motdS = new ClientMOTD[]{
|
||||||
|
new ReiMOTD(),
|
||||||
|
new ZombeMOTD(),
|
||||||
|
new SmartMovingMOTD(),
|
||||||
|
new CJBMOTD(),
|
||||||
|
new MCAutoMapMOTD()
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send block codes to the player according to allowed or disallowed client-mods or client-mod features.
|
* Send block codes to the player according to allowed or disallowed client-mods or client-mod features.
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void checkModsMessage(Player player) {
|
public static void motdOnJoin(final Player player) {
|
||||||
// TODO: Somebody test this all !
|
|
||||||
|
|
||||||
String message = "";
|
// TODO: Somebody test this all !
|
||||||
|
|
||||||
// TODO: add feature to check world specific (!).
|
// TODO: add feature to check world specific (!).
|
||||||
|
|
||||||
// Check if we allow all the client mods.
|
// Check if we allow all the client mods.
|
||||||
final boolean allowAll = ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_ALLOWCLIENTMODS);
|
final boolean allowAll = ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_ALLOWCLIENTMODS);
|
||||||
|
|
||||||
// Disable Zombe's noclip.
|
|
||||||
if (allowAll || player.hasPermission(Permissions.ZOMBE_NOCLIP))
|
|
||||||
message += "§f §f §4 §0 §9 §6";
|
|
||||||
|
|
||||||
// Allow Rei's Minimap's cave mode.
|
String message = "";
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_CAVE))
|
for (int i = 0; i < motdS.length; i++){
|
||||||
message += "§0§0§1§e§f";
|
message = motdS[i].onPlayerJoin(message, player, allowAll);
|
||||||
|
|
||||||
// Allow Rei's Minimap's radar.
|
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR)){
|
|
||||||
// TODO: Does this allow all radar features?
|
|
||||||
message += "§0§0§2§3§4§5§6§7§e§f";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// Allow Rei's Minimap's player radar
|
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR_PLAYER))
|
|
||||||
message += "§0§0§2§e§f";
|
|
||||||
|
|
||||||
// Allow Rei's Minimap's animal radar
|
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR_ANIMAL))
|
|
||||||
message += "§0§0§3§e§f";
|
|
||||||
|
|
||||||
// Allow Rei's Minimap's mob radar
|
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR_MOB))
|
|
||||||
message += "§0§0§4§e§f";
|
|
||||||
|
|
||||||
// Allow Rei's Minimap's slime radar
|
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR_SLIME))
|
|
||||||
message += "§0§0§5§e§f";
|
|
||||||
|
|
||||||
// Allow Rei's Minimap's squid radar
|
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR_SQUID))
|
|
||||||
message += "§0§0§6§e§f";
|
|
||||||
|
|
||||||
// Allow Rei's Minimap's other radar
|
|
||||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR_OTHER))
|
|
||||||
message += "§0§0§7§e§f";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all the client mods are allowed, no need to go any further.
|
if (!message.isEmpty()){
|
||||||
if (allowAll) {
|
player.sendMessage(message);
|
||||||
if (!message.equals(""))
|
|
||||||
player.sendMessage(message);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Zombe's fly mod.
|
|
||||||
if (!player.hasPermission(Permissions.ZOMBE_FLY))
|
|
||||||
message += "§f §f §1 §0 §2 §4";
|
|
||||||
|
|
||||||
// Disable Zombe's cheat.
|
|
||||||
if (!player.hasPermission(Permissions.ZOMBE_CHEAT))
|
|
||||||
message += "§f §f §2 §0 §4 §8";
|
|
||||||
|
|
||||||
// Disable CJB's fly mod.
|
|
||||||
if (!player.hasPermission(Permissions.CJB_FLY))
|
|
||||||
message += "§3 §9 §2 §0 §0 §1";
|
|
||||||
|
|
||||||
// Disable CJB's xray.
|
|
||||||
if (!player.hasPermission(Permissions.CJB_XRAY))
|
|
||||||
message += "§3 §9 §2 §0 §0 §2";
|
|
||||||
|
|
||||||
// Disable CJB's radar.
|
|
||||||
if (!player.hasPermission(Permissions.CJB_RADAR))
|
|
||||||
message += "§3 §9 §2 §0 §0 §3";
|
|
||||||
|
|
||||||
// Disable Minecraft AutoMap's ores.
|
|
||||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_ORES))
|
|
||||||
message += "§0§0§1§f§e";
|
|
||||||
|
|
||||||
// Disable Minecraft AutoMap's cave mode.
|
|
||||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_CAVE))
|
|
||||||
message += "§0§0§2§f§e";
|
|
||||||
|
|
||||||
// Disable Minecraft AutoMap's radar.
|
|
||||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_RADAR))
|
|
||||||
message += "§0§0§3§4§5§6§7§8§f§e";
|
|
||||||
|
|
||||||
// Disable Smart Moving's climbing.
|
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_CLIMBING))
|
|
||||||
message += "§0§1§0§1§2§f§f";
|
|
||||||
|
|
||||||
// Disable Smart Moving's climbing.
|
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_SWIMMING))
|
|
||||||
message += "§0§1§3§4§f§f";
|
|
||||||
|
|
||||||
// Disable Smart Moving's climbing.
|
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_CRAWLING))
|
|
||||||
message += "§0§1§5§f§f";
|
|
||||||
|
|
||||||
// Disable Smart Moving's climbing.
|
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_SLIDING))
|
|
||||||
message += "§0§1§6§f§f";
|
|
||||||
|
|
||||||
// Disable Smart Moving's climbing.
|
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_JUMPING))
|
|
||||||
message += "§0§1§8§9§a§b§f§f";
|
|
||||||
|
|
||||||
// Disable Smart Moving's climbing.
|
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_FLYING))
|
|
||||||
message += "§0§1§7§f§f";
|
|
||||||
|
|
||||||
if (!message.equals(""))
|
|
||||||
player.sendMessage(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package fr.neatmonster.nocheatplus.clients.motd;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
|
|
||||||
|
public class CJBMOTD extends ClientMOTD {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlayerJoin(String message, Player player, boolean allowAll) {
|
||||||
|
|
||||||
|
if (allowAll){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cjb = "";
|
||||||
|
|
||||||
|
// TODO: Is there a compact version (just one prefix)?
|
||||||
|
|
||||||
|
// Disable CJB's fly mod.
|
||||||
|
if (!player.hasPermission(Permissions.CJB_FLY)){
|
||||||
|
cjb += "§3 §9 §2 §0 §0 §1";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable CJB's xray.
|
||||||
|
if (!player.hasPermission(Permissions.CJB_XRAY)){
|
||||||
|
cjb += "§3 §9 §2 §0 §0 §2";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable CJB's radar.
|
||||||
|
if (!player.hasPermission(Permissions.CJB_RADAR)){
|
||||||
|
cjb += "§3 §9 §2 §0 §0 §3";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cjb.isEmpty()){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return message + cjb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package fr.neatmonster.nocheatplus.clients.motd;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup for all "motd" sending for enabling/disabling client mod features.
|
||||||
|
* @author mc_dev
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ClientMOTD {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend / manipulate the message based on permissions and the allowAll setting.
|
||||||
|
* @param message
|
||||||
|
* @param player
|
||||||
|
* @param allowAll
|
||||||
|
* @return The message to send / process further.
|
||||||
|
*/
|
||||||
|
public abstract String onPlayerJoin(String message, Player player, boolean allowAll);
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package fr.neatmonster.nocheatplus.clients.motd;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
|
|
||||||
|
public class MCAutoMapMOTD extends ClientMOTD {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlayerJoin(String message, Player player, boolean allowAll) {
|
||||||
|
|
||||||
|
if (allowAll){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
String mcAutoMap = "";
|
||||||
|
|
||||||
|
// TODO: Is there a compact version (just one prefix)?
|
||||||
|
|
||||||
|
// Disable Minecraft AutoMap's ores.
|
||||||
|
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_ORES)){
|
||||||
|
mcAutoMap += "§0§0§1§f§e";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Minecraft AutoMap's cave mode.
|
||||||
|
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_CAVE)){
|
||||||
|
mcAutoMap += "§0§0§2§f§e";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Minecraft AutoMap's radar.
|
||||||
|
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_RADAR)){
|
||||||
|
mcAutoMap += "§0§0§3§4§5§6§7§8§f§e";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcAutoMap.isEmpty()){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return message + mcAutoMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package fr.neatmonster.nocheatplus.clients.motd;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rei's Minimap v3.3_04
|
||||||
|
*
|
||||||
|
* http://www.minecraftforum.net/topic/482147-151-mar21-reis-minimap-v33-04/
|
||||||
|
*
|
||||||
|
* &0&0: prefix
|
||||||
|
* &e&f: suffix
|
||||||
|
* &1: cave mapping
|
||||||
|
* &2: entities radar (player)
|
||||||
|
* &3: entities radar (animal)
|
||||||
|
* &4: entities radar (mob)
|
||||||
|
* &5: entities radar (slime)
|
||||||
|
* &6: entities radar (squid)
|
||||||
|
* &7: entities radar (other living)
|
||||||
|
*
|
||||||
|
* @author mc_dev
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ReiMOTD extends ClientMOTD {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlayerJoin(String message, Player player, boolean allowAll) {
|
||||||
|
String rei = "";
|
||||||
|
|
||||||
|
// Allow Rei's Minimap's cave mode.
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_CAVE)){
|
||||||
|
rei += "§1";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow Rei's Minimap's radar.
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_RADAR)){
|
||||||
|
// TODO: Does this allow all radar features?
|
||||||
|
rei += "§2§3§4§5§6§7";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// Allow Rei's Minimap's player radar
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_RADAR_PLAYER)){
|
||||||
|
rei += "§2";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow Rei's Minimap's animal radar
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_RADAR_ANIMAL)){
|
||||||
|
rei += "§3";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow Rei's Minimap's mob radar
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_RADAR_MOB)){
|
||||||
|
rei += "§4";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow Rei's Minimap's slime radar
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_RADAR_SLIME)){
|
||||||
|
rei += "§5";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow Rei's Minimap's squid radar
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_RADAR_SQUID)){
|
||||||
|
rei += "§6";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow Rei's Minimap's other radar
|
||||||
|
if (allowAll || player.hasPermission(Permissions.REI_RADAR_OTHER)){
|
||||||
|
rei += "§7";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rei.isEmpty()){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rei = "§0§0" + rei + "§e§f";
|
||||||
|
return message + rei;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package fr.neatmonster.nocheatplus.clients.motd;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
|
|
||||||
|
public class SmartMovingMOTD extends ClientMOTD {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlayerJoin(String message, Player player, boolean allowAll) {
|
||||||
|
|
||||||
|
if (allowAll){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
String smartMoving = "";
|
||||||
|
|
||||||
|
// TODO: Is there a compact version (just one prefix)?
|
||||||
|
|
||||||
|
// Disable Smart Moving's climbing.
|
||||||
|
if (!player.hasPermission(Permissions.SMARTMOVING_CLIMBING)){
|
||||||
|
smartMoving += "§0§1§0§1§2§f§f";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Smart Moving's climbing.
|
||||||
|
if (!player.hasPermission(Permissions.SMARTMOVING_SWIMMING)){
|
||||||
|
smartMoving += "§0§1§3§4§f§f";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Smart Moving's climbing.
|
||||||
|
if (!player.hasPermission(Permissions.SMARTMOVING_CRAWLING)){
|
||||||
|
smartMoving += "§0§1§5§f§f";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Smart Moving's climbing.
|
||||||
|
if (!player.hasPermission(Permissions.SMARTMOVING_SLIDING)){
|
||||||
|
smartMoving += "§0§1§6§f§f";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Smart Moving's climbing.
|
||||||
|
if (!player.hasPermission(Permissions.SMARTMOVING_JUMPING)){
|
||||||
|
smartMoving += "§0§1§8§9§a§b§f§f";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Smart Moving's climbing.
|
||||||
|
if (!player.hasPermission(Permissions.SMARTMOVING_FLYING)){
|
||||||
|
smartMoving += "§0§1§7§f§f";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smartMoving.isEmpty()){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return message + smartMoving;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package fr.neatmonster.nocheatplus.clients.motd;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
|
|
||||||
|
public class ZombeMOTD extends ClientMOTD {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlayerJoin(String message, Player player, boolean allowAll) {
|
||||||
|
|
||||||
|
String zombe = "";
|
||||||
|
|
||||||
|
// TODO: Is there a compact version (just one prefix)?
|
||||||
|
|
||||||
|
// Disable Zombe's noclip.
|
||||||
|
if (allowAll || player.hasPermission(Permissions.ZOMBE_NOCLIP)){
|
||||||
|
zombe += "§f §f §4 §0 §9 §6";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allowAll){
|
||||||
|
// Disable Zombe's fly mod.
|
||||||
|
if (!player.hasPermission(Permissions.ZOMBE_FLY)){
|
||||||
|
zombe += "§f §f §1 §0 §2 §4";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable Zombe's cheat.
|
||||||
|
if (!player.hasPermission(Permissions.ZOMBE_CHEAT)){
|
||||||
|
zombe += "§f §f §2 §0 §4 §8";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zombe.isEmpty()){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return message + zombe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user