I love to clean code and stuff
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package fr.xephi.authme.hooks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
public class BungeeCordMessage implements PluginMessageListener {
|
||||
|
||||
public AuthMe plugin;
|
||||
|
||||
public BungeeCordMessage(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player,
|
||||
byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||
String subChannel = in.readUTF();
|
||||
if (subChannel.equals("IP")) { // We need only the IP channel
|
||||
String ip = in.readUTF();
|
||||
// Put the IP (only the ip not the port) in the hashMap
|
||||
plugin.realIp.put(player.getName().toLowerCase(), ip);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package fr.xephi.authme.hooks;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import fr.xephi.authme.settings.CustomConfiguration;
|
||||
|
||||
public class EssSpawn extends CustomConfiguration {
|
||||
|
||||
private static EssSpawn spawn;
|
||||
|
||||
public EssSpawn() {
|
||||
super(new File("." + File.separator + "plugins" + File.separator + "Essentials" + File.separator + "spawn.yml"));
|
||||
spawn = this;
|
||||
load();
|
||||
}
|
||||
|
||||
public static EssSpawn getInstance() {
|
||||
if (spawn == null) {
|
||||
spawn = new EssSpawn();
|
||||
}
|
||||
return spawn;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
try {
|
||||
if (!this.contains("spawns.default.world"))
|
||||
return null;
|
||||
if (this.getString("spawns.default.world").isEmpty() || this.getString("spawns.default.world").equals(""))
|
||||
return null;
|
||||
Location location = new Location(Bukkit.getWorld(this.getString("spawns.default.world")), this.getDouble("spawns.default.x"), this.getDouble("spawns.default.y"), this.getDouble("spawns.default.z"), Float.parseFloat(this.getString("spawns.default.yaw")), Float.parseFloat(this.getString("spawns.default.pitch")));
|
||||
return location;
|
||||
} catch (NullPointerException | NumberFormatException npe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user