Add Blindness effect (configurable)

This commit is contained in:
Xephi 2014-07-25 02:06:56 +02:00
parent fd9010dc59
commit 535c96738d
9 changed files with 36 additions and 2 deletions

View File

@ -17,11 +17,12 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
@ -513,6 +514,8 @@ public class AdminCommand implements CommandExecutor {
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("reg_msg"), interval)));
if (Settings.applyBlindEffect)
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
m._(target, "unregistered");
} else {
// Player isn't online, do nothing else

View File

@ -7,6 +7,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
@ -104,6 +106,8 @@ public class LogoutCommand implements CommandExecutor {
player.getVehicle().eject();
} catch (NullPointerException npe) {
}
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
m._(player, "logout");
ConsoleLogger.info(player.getDisplayName() + " logged out");
if(plugin.notifications != null) {

View File

@ -10,6 +10,8 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
@ -108,6 +110,8 @@ public class UnregisterCommand implements CommandExecutor {
if(playerCache.doesCacheExist(name)) {
playerCache.removeCache(name);
}
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
m._(player, "unregistered");
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
if(plugin.notifications != null) {

View File

@ -34,6 +34,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
@ -711,6 +713,8 @@ public class AuthMePlayerListener implements Listener {
player.setNoDamageTicks(Settings.getRegistrationTimeout * 20);
if (Settings.useEssentialsMotd)
player.performCommand("motd");
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
// Remove the join message while the player isn't logging in
if (Settings.enableProtection || Settings.delayJoinMessage) {

View File

@ -5,6 +5,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffectType;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
@ -172,6 +173,9 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
AuthMePlayerListener.joinMessage.remove(name);
}
if (Settings.applyBlindEffect)
player.removePotionEffect(PotionEffectType.BLINDNESS);
// The Loginevent now fires (as intended) after everything is processed
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
player.saveData();

View File

@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
@ -61,6 +62,8 @@ public class ProcessSyncronousEmailRegister implements Runnable {
player.setAllowFlight(false);
player.setFlying(false);
}
if (Settings.applyBlindEffect)
player.removePotionEffect(PotionEffectType.BLINDNESS);
player.saveData();
if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName() + " registered "+plugin.getIP(player));

View File

@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
@ -104,6 +105,8 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.setAllowFlight(false);
player.setFlying(false);
}
if (Settings.applyBlindEffect)
player.removePotionEffect(PotionEffectType.BLINDNESS);
// The Loginevent now fires (as intended) after everything is processed
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
player.saveData();

View File

@ -60,7 +60,7 @@ public final class Settings extends YamlConfiguration {
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames, delayJoinMessage,
noTeleport;
noTeleport, applyBlindEffect;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
@ -248,6 +248,7 @@ public void loadConfigOptions() {
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters","[a-zA-Z0-9_?!@+&-]*");
applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
// Load the welcome message
getWelcomeMessage(plugin);
@ -410,6 +411,7 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters","[a-zA-Z0-9_?!@+&-]*");
applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
// Reload the welcome message
getWelcomeMessage(AuthMe.getInstance());
@ -528,6 +530,11 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
}
if(!contains("settings.restrictions.allowedPasswordCharacters")) {
set("settings.restrictions.allowedPasswordCharacters", "[a-zA-Z0-9_?!@+&-]*");
changes = true;
}
if(!contains("settings.applyBlindEffect")) {
set("settings.applyBlindEffect", false);
changes = true;
}
if (changes) {

View File

@ -260,6 +260,8 @@ settings:
broadcastWelcomeMessage: false
# Do we need to delay the X has joined the game after /login ?
delayJoinMessage: false
# Do we need to add potion effect Blinding before login/register ?
applyBlindEffect: false
ExternalBoardOptions:
# MySQL column for the salt , needed for some forum/cms support
mySQLColumnSalt: ''