Hook with SocialSpy(Essentials) - Fix OP removed

This commit is contained in:
Xephi 2013-05-14 01:28:45 +02:00
parent bad44f3af7
commit 447d6633b2
8 changed files with 86 additions and 43 deletions

BIN
lib/Essentials.jar Normal file

Binary file not shown.

View File

@ -28,7 +28,7 @@
</plugin>
</plugins>
</build>
<version>2.7.16</version>
<version>2.7.16b1</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
@ -118,6 +118,13 @@
<version>2.5-b654</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Multiverse-Core-2.5.jar</systemPath>
</dependency>
<dependency>
<groupId>com.earth2me.essentials</groupId>
<artifactId>Essentials</artifactId>
<version>Pre2.9.4.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Essentials.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>

View File

@ -23,6 +23,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Random;
import com.earth2me.essentials.Essentials;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -94,6 +96,7 @@ public class AuthMe extends JavaPlugin {
public int CombatTag = 0;
public double ChestShop = 0;
public boolean BungeeCord = false;
public Essentials ess;
public Notifications notifications;
public API api;
public HashMap<String, Integer> captcha = new HashMap<String, Integer>();
@ -143,6 +146,9 @@ public class AuthMe extends JavaPlugin {
//Check ChestShop
checkChestShop();
//Check Essentials
checkEssentials();
/*
* Back style on start if avaible
@ -346,6 +352,21 @@ public class AuthMe extends JavaPlugin {
}
}
}
private void checkEssentials() {
if (this.getServer().getPluginManager().getPlugin("Essentials") != null && this.getServer().getPluginManager().getPlugin("Essentials").isEnabled()) {
try {
ess = (Essentials) this.getServer().getPluginManager().getPlugin("Essentials");
ConsoleLogger.info("Hook with Essentials plugin");
} catch (NullPointerException npe) {
ess = null;
} catch (ClassCastException cce) {
ess = null;
} catch (NoClassDefFoundError ncdfe) {
ess = null;
}
}
}
private void checkNotifications() {
if (!Settings.notifications) {

View File

@ -73,7 +73,7 @@ public class ConsoleLogger {
w.newLine();
w.close();
} catch (IOException e) {
ConsoleLogger.showError(e.getMessage());
e.printStackTrace();
}
}

View File

@ -159,7 +159,6 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0];
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
//System.out.println("debug chat: chat isnt allowed");
event.setCancelled(true);
return;
}
@ -221,7 +220,6 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0];
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
//System.out.println("debug chat: chat isnt allowed");
event.setCancelled(true);
return;
}
@ -283,7 +281,6 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0];
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
//System.out.println("debug chat: chat isnt allowed");
event.setCancelled(true);
return;
}
@ -345,7 +342,6 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0];
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
//System.out.println("debug chat: chat isnt allowed");
event.setCancelled(true);
return;
}
@ -407,7 +403,6 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0];
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
//System.out.println("debug chat: chat isnt allowed");
event.setCancelled(true);
return;
}
@ -469,7 +464,6 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0];
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
//System.out.println("debug chat: chat isnt allowed");
event.setCancelled(true);
return;
}
@ -562,23 +556,17 @@ public class AuthMePlayerListener implements Listener {
return;
}
//Run that asynchronous
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
if(!Settings.isSessionsEnabled) {
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
} else if(PlayerCache.getInstance().isAuthenticated(name)) {
if(!Settings.sessionExpireOnIpChange)
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
LimboCache.getInstance().deleteLimboPlayer(name);
}
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
}
}
}
});
if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
if(!Settings.isSessionsEnabled) {
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
} else if(PlayerCache.getInstance().isAuthenticated(name)) {
if(!Settings.sessionExpireOnIpChange)
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
LimboCache.getInstance().deleteLimboPlayer(name);
}
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
}
}
//Check if forceSingleSession is set to true, so kick player that has joined with same nick of online player
if(player.isOnline() && Settings.isForceSingleSessionEnabled ) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
@ -614,16 +602,6 @@ public class AuthMePlayerListener implements Listener {
return;
}
}
if (Settings.bungee) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("IP");
} catch (IOException e) {
}
player.sendPluginMessage(this.plugin, "BungeeCord", b.toByteArray());
}
if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL) return;
if (player.isBanned()) return;
if (!plugin.authmePermissible(player, "authme.vip")) {
@ -647,6 +625,27 @@ public class AuthMePlayerListener implements Listener {
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLowestJoin(PlayerJoinEvent event) {
if (event.getPlayer() == null) return;
Player player = event.getPlayer();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
if (Settings.bungee) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("IP");
} catch (IOException e) {
}
player.sendPluginMessage(this.plugin, "BungeeCord", b.toByteArray());
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(PlayerJoinEvent event) {
if (event.getPlayer() == null) {
@ -668,6 +667,9 @@ public class AuthMePlayerListener implements Listener {
return;
}
if (plugin.ess != null && Settings.disableSocialSpy)
plugin.ess.getUser(player.getName()).setSocialSpyEnabled(false);
String ip = player.getAddress().getAddress().getHostAddress();
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
@ -776,7 +778,7 @@ public class AuthMePlayerListener implements Listener {
});
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer() == null) {
return;
@ -784,6 +786,9 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
Location loc = player.getLocation();
if (loc.getY() % 1 != 0)
loc.add(0, 0.5, 0);
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
@ -791,7 +796,7 @@ public class AuthMePlayerListener implements Listener {
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),player.getLocation().getBlock().getX(),player.getLocation().getBlock().getY(),player.getLocation().getBlock().getZ());
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),loc.getBlockX(),loc.getBlockY(),loc.getBlockZ());
try {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
@ -831,7 +836,7 @@ public class AuthMePlayerListener implements Listener {
player.saveData();
}
@EventHandler(priority=EventPriority.MONITOR)
@EventHandler(priority=EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
if (event.getPlayer() == null) {
return;
@ -841,6 +846,9 @@ public class AuthMePlayerListener implements Listener {
}
Player player = event.getPlayer();
Location loc = player.getLocation();
if (loc.getY() % 1 != 0)
loc.add(0, 0.5, 0);
if ((plugin.getCitizensCommunicator().isNPC(player, plugin)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
return;
@ -855,7 +863,7 @@ public class AuthMePlayerListener implements Listener {
String name = player.getName().toLowerCase();
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) &&
(Settings.isSaveQuitLocationEnabled.booleanValue()) && data.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), (int)player.getLocation().getX(), (int)player.getLocation().getY(), (int)player.getLocation().getZ());
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {

View File

@ -59,7 +59,8 @@ public final class Settings extends YamlConfiguration {
isForceSurvivalModeEnabled, isResetInventoryIfCreative, isCachingEnabled, isKickOnWrongPasswordEnabled,
getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart,
isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange;
useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
disableSocialSpy;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
@ -204,6 +205,7 @@ public void loadConfigOptions() {
doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
useLogging = configFile.getBoolean("Security.console.logConsole", false);
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
saveDefaults();
}
@ -323,6 +325,7 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
useLogging = configFile.getBoolean("Security.console.logConsole", false);
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
}
@ -391,6 +394,8 @@ public void mergeConfig() {
set("settings.sessions.sessionExpireOnIpChange", false);
if(!contains("Security.console.logConsole"))
set("Security.console.logConsole", false);
if(!contains("Hooks.disableSocialSpy"))
set("Hooks.disableSocialSpy", true);
plugin.getLogger().info("Merge new Config Options if needed..");
plugin.saveConfig();

View File

@ -66,6 +66,8 @@ public class Spawn extends CustomConfiguration {
return location;
} catch (NullPointerException npe) {
return null;
} catch (NumberFormatException nfe) {
return null;
}
}

View File

@ -1,10 +1,10 @@
name: AuthMe
author: darkwarriros,Xephi
author: darkwarriors,Xephi
website: http://www.multiplayer-italia.com/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
main: uk.org.whoami.authme.AuthMe
version: 2.7.16
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag]
version: 2.7.16b1
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials]
commands:
register:
description: Register an account