mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-18 05:32:11 +01:00
Fix BungeeCord player real IP - 2.7.12b1
This commit is contained in:
parent
cedafe52a8
commit
def5821e5c
BIN
lib/BungeeCord.jar
Normal file
BIN
lib/BungeeCord.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
pom.xml
8
pom.xml
@ -28,12 +28,12 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<version>2.7.11b3</version>
|
||||
<version>2.7.12b1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.4.7-R1.0</version>
|
||||
<version>1.5-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
@ -122,9 +122,9 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.4.7-SNAPSHOT</version>
|
||||
<version>1.5-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/bungeecord-api-1.4.7-20130228.060400-44.jar</systemPath>
|
||||
<systemPath>${project.basedir}/lib/BungeeCord.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
|
@ -95,6 +95,7 @@ public class AuthMe extends JavaPlugin {
|
||||
public API api;
|
||||
public HashMap<String, Integer> captcha = new HashMap<String, Integer>();
|
||||
public HashMap<String, String> cap = new HashMap<String, String>();
|
||||
public HashMap<String, String> bungeesIp = new HashMap<String, String>();
|
||||
public MultiverseCore mv = null;
|
||||
|
||||
@Override
|
||||
@ -234,6 +235,10 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
management = new Management(database, this);
|
||||
|
||||
if (Settings.bungee) {
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCord(this));
|
||||
}
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
if (pm.isPluginEnabled("Spout")) {
|
||||
pm.registerEvents(new AuthMeSpoutListener(database), this);
|
||||
|
52
src/main/java/uk/org/whoami/authme/BungeeCord.java
Normal file
52
src/main/java/uk/org/whoami/authme/BungeeCord.java
Normal file
@ -0,0 +1,52 @@
|
||||
package uk.org.whoami.authme;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
|
||||
public class BungeeCord implements PluginMessageListener {
|
||||
|
||||
public AuthMe plugin;
|
||||
|
||||
public BungeeCord(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player,
|
||||
byte[] message) {
|
||||
|
||||
if (channel.equals("BungeeCord")) {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(
|
||||
message));
|
||||
try {
|
||||
|
||||
String packetType = in.readUTF();
|
||||
|
||||
if (packetType.equals("IP")) {
|
||||
|
||||
if (player.isOnline()) {
|
||||
String ip = in.readUTF();
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(
|
||||
"Got data from bungeecord: Player "
|
||||
+ player.getName()
|
||||
+ " Logged in with IP :" + ip);
|
||||
|
||||
String name = player.getName();
|
||||
plugin.bungeesIp.put(name, ip);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,8 +5,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
import net.md_5.bungee.api.connection.ConnectedPlayer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -62,12 +60,14 @@ public class Management {
|
||||
|
||||
String name = player.getName().toLowerCase();
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee && player instanceof ProxiedPlayer) {
|
||||
ProxiedPlayer pPlayer = (ProxiedPlayer) player;
|
||||
ip = pPlayer.getAddress().getAddress().getHostAddress();
|
||||
} else if (Settings.bungee && player instanceof ConnectedPlayer) {
|
||||
ConnectedPlayer cPlayer = (ConnectedPlayer) player;
|
||||
ip = cPlayer.getAddress().getAddress().getHostAddress();
|
||||
String playerName = player.getName();
|
||||
if (Settings.bungee) {
|
||||
try {
|
||||
if (plugin.bungeesIp.containsKey(playerName))
|
||||
ip = plugin.bungeesIp.get(playerName);
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
ConsoleLogger.showError("Your BungeeCord version is outdated");
|
||||
}
|
||||
}
|
||||
World world = player.getWorld();
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
|
@ -20,8 +20,6 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
import net.md_5.bungee.api.connection.ConnectedPlayer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -78,14 +76,16 @@ public class RegisterCommand implements CommandExecutor {
|
||||
|
||||
final Player player = (Player) sender;
|
||||
final String name = player.getName().toLowerCase();
|
||||
final String playerName = player.getName();
|
||||
String ipA = player.getAddress().getAddress().getHostAddress();
|
||||
|
||||
if (Settings.bungee && player instanceof ProxiedPlayer) {
|
||||
ProxiedPlayer pPlayer = (ProxiedPlayer) player;
|
||||
ipA = pPlayer.getAddress().getAddress().getHostAddress();
|
||||
} else if (Settings.bungee && player instanceof ConnectedPlayer) {
|
||||
ConnectedPlayer cPlayer = (ConnectedPlayer) player;
|
||||
ipA = cPlayer.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
try {
|
||||
if (plugin.bungeesIp.containsKey(playerName))
|
||||
ipA = plugin.bungeesIp.get(playerName);
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
ConsoleLogger.showError("Your BungeeCord version is outdated");
|
||||
}
|
||||
}
|
||||
|
||||
final String ip = ipA;
|
||||
|
@ -111,6 +111,12 @@ public class MySQLDataSource implements DataSource {
|
||||
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
|
||||
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
+ columnPassword + " VARCHAR(255) NOT NULL;");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
|
@ -94,6 +94,12 @@ public class SqliteDataSource implements DataSource {
|
||||
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
|
||||
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
+ columnPassword + " VARCHAR(255) NOT NULL;");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
|
@ -16,12 +16,12 @@
|
||||
|
||||
package uk.org.whoami.authme.listener;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.md_5.bungee.api.connection.ConnectedPlayer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -664,22 +664,50 @@ public class AuthMePlayerListener implements Listener {
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
gm = player.getGameMode().getValue();
|
||||
final String name = player.getName().toLowerCase();
|
||||
final String playerName = player.getName();
|
||||
gameMode.put(name, gm);
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
final PlayerJoinEvent e = event;
|
||||
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
|
||||
try {
|
||||
out.writeUTF("IP");
|
||||
} catch (IOException e) {
|
||||
// Can never happen
|
||||
}
|
||||
|
||||
plugin.getServer()
|
||||
.getPlayerExact(playerName)
|
||||
.sendPluginMessage(plugin, "BungeeCord",
|
||||
b.toByteArray());
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}, 21L);
|
||||
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee && player instanceof ProxiedPlayer) {
|
||||
ProxiedPlayer pPlayer = (ProxiedPlayer) player;
|
||||
ip = pPlayer.getAddress().getAddress().getHostAddress();
|
||||
} else if (Settings.bungee && player instanceof ConnectedPlayer) {
|
||||
ConnectedPlayer cPlayer = (ConnectedPlayer) player;
|
||||
ip = cPlayer.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
try {
|
||||
if (plugin.bungeesIp.containsKey(playerName))
|
||||
ip = plugin.bungeesIp.get(playerName);
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
ConsoleLogger.showError("Your BungeeCord version is outdated");
|
||||
}
|
||||
}
|
||||
if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
|
||||
int gM = gameMode.get(name);
|
||||
@ -961,9 +989,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.isCancelled() || event.getPlayer() == null) return;
|
||||
if (event.getClickedBlock() == null) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
@ -982,10 +1009,15 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final int sign = event.getClickedBlock().getTypeId();
|
||||
if (sign == Material.SIGN_POST.getId() || sign == Material.WALL_SIGN.getId()) {
|
||||
event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
|
||||
}
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ author: darkwarriros,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.11b3
|
||||
version: 2.7.12b1
|
||||
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag]
|
||||
commands:
|
||||
register:
|
||||
|
Loading…
Reference in New Issue
Block a user