mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-12 12:16:48 +01:00
Fixed bungee issues and protection
This commit is contained in:
parent
859971b6ea
commit
d2a362e5af
@ -4,4 +4,4 @@ REM Use this file for testing cases for different versions, just drag the versio
|
|||||||
java -Xmx4096M -DIReallyKnowWhatIAmDoingISwear=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar %1
|
java -Xmx4096M -DIReallyKnowWhatIAmDoingISwear=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar %1
|
||||||
REM Could add a 32 bit test part but noone uses 32 bit anymore
|
REM Could add a 32 bit test part but noone uses 32 bit anymore
|
||||||
GOTO A
|
GOTO A
|
||||||
PAUSE.
|
PAUSE
|
||||||
|
@ -2,6 +2,7 @@ package com.sekwah.advancedportals.bukkit;
|
|||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.api.events.WarpEvent;
|
import com.sekwah.advancedportals.bukkit.api.events.WarpEvent;
|
||||||
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.listeners.Listeners;
|
import com.sekwah.advancedportals.bukkit.listeners.Listeners;
|
||||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package com.sekwah.advancedportals.bukkit;
|
package com.sekwah.advancedportals.bukkit;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.compat.CraftBukkit;
|
import com.sekwah.advancedportals.bukkit.compat.CraftBukkit;
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||||
import com.sekwah.advancedportals.bukkit.destinations.DestinationCommand;
|
import com.sekwah.advancedportals.bukkit.destinations.DestinationCommand;
|
||||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||||
import com.sekwah.advancedportals.bukkit.listeners.*;
|
import com.sekwah.advancedportals.bukkit.listeners.*;
|
||||||
import com.sekwah.advancedportals.bukkit.metrics.Metrics;
|
import com.sekwah.advancedportals.bukkit.metrics.Metrics;
|
||||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||||
|
|
||||||
public CraftBukkit compat = null;
|
public CraftBukkit compat = null;
|
||||||
@ -38,6 +37,12 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
|
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
|
||||||
|
|
||||||
|
ConfigHelper configHelper = new ConfigHelper(config.getConfig());
|
||||||
|
|
||||||
|
configHelper.update();
|
||||||
|
|
||||||
|
config.saveConfig();
|
||||||
|
|
||||||
// TODO reenable and finish but probably focus on the recode first
|
// TODO reenable and finish but probably focus on the recode first
|
||||||
/*if(config.getConfig().getBoolean("DisableGatewayBeam", true)) {
|
/*if(config.getConfig().getBoolean("DisableGatewayBeam", true)) {
|
||||||
new PacketInjector(this, version);
|
new PacketInjector(this, version);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.bukkit;
|
package com.sekwah.advancedportals.bukkit;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class PluginMessages {
|
public class PluginMessages {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.bukkit;
|
package com.sekwah.advancedportals.bukkit;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.bukkit;
|
package com.sekwah.advancedportals.bukkit;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
|
|
||||||
import static com.sekwah.advancedportals.bukkit.Settings.PortalConfigOption.*;
|
import static com.sekwah.advancedportals.bukkit.Settings.PortalConfigOption.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.sekwah.advancedportals.bukkit;
|
package com.sekwah.advancedportals.bukkit.config;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.sekwah.advancedportals.bukkit.config;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
public class ConfigHelper {
|
||||||
|
|
||||||
|
public static String CONFIG_VERSION = "ConfigVersion";
|
||||||
|
|
||||||
|
private FileConfiguration config;
|
||||||
|
|
||||||
|
public ConfigHelper(FileConfiguration config) {
|
||||||
|
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
String configVersion = config.getString("ConfigVersion");
|
||||||
|
// Added in 0.5.3 so update to 0.5.3
|
||||||
|
if(configVersion == null) {
|
||||||
|
config.set(ConfigHelper.CONFIG_VERSION, "0.5.3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.bukkit.destinations;
|
package com.sekwah.advancedportals.bukkit.destinations;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.bukkit.destinations;
|
package com.sekwah.advancedportals.bukkit.destinations;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.bukkit.listeners;
|
package com.sekwah.advancedportals.bukkit.listeners;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.bukkit.listeners;
|
package com.sekwah.advancedportals.bukkit.listeners;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||||
import com.sekwah.advancedportals.bukkit.api.events.WarpEvent;
|
import com.sekwah.advancedportals.bukkit.api.events.WarpEvent;
|
||||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||||
@ -22,10 +22,8 @@ import org.bukkit.event.player.*;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Listeners implements Listener {
|
public class Listeners implements Listener {
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ import com.google.common.io.ByteArrayDataInput;
|
|||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||||
|
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Color;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
@ -28,12 +31,23 @@ public class PluginMessageReceiver implements PluginMessageListener {
|
|||||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||||
String subchannel = in.readUTF();
|
String subchannel = in.readUTF();
|
||||||
|
|
||||||
if (subchannel.equals("BungeePortal")) {
|
if (subchannel.equals(BungeeMessages.SERVER_DESTI)) {
|
||||||
String targetDestination = in.readUTF();
|
String targetDestination = in.readUTF();
|
||||||
|
UUID bungeeUUID = UUID.fromString(in.readUTF());
|
||||||
|
UUID offlineUUID = UUID.fromString(in.readUTF());
|
||||||
|
|
||||||
if (player != null) {
|
Player targetPlayer = this.plugin.getServer().getPlayer(bungeeUUID);
|
||||||
|
|
||||||
|
if(targetPlayer == null) {
|
||||||
|
targetPlayer = this.plugin.getServer().getPlayer(offlineUUID);
|
||||||
|
this.plugin.getServer().getConsoleSender().sendMessage(ChatColor.RED + BungeeMessages.WARNING_MESSAGE
|
||||||
|
+ "\n\nThis server is the offending server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetPlayer != null) {
|
||||||
|
Player finalTargetPlayer = targetPlayer;
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||||
() -> Destination.warp(player, targetDestination, false, true),
|
() -> Destination.warp(finalTargetPlayer, targetDestination, false, true),
|
||||||
20L
|
20L
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.bukkit.listeners;
|
package com.sekwah.advancedportals.bukkit.listeners;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.bukkit.listeners;
|
package com.sekwah.advancedportals.bukkit.listeners;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -42,6 +42,8 @@ public class PortalProtect implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if(!this.PortalProtect) return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!player.hasPermission("advancedportals.build")
|
if (!player.hasPermission("advancedportals.build")
|
||||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
||||||
@ -52,8 +54,10 @@ public class PortalProtect implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
if(!this.PortalProtect) return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!player.hasPermission("advancedportals.build")
|
if (PortalProtect && !player.hasPermission("advancedportals.build")
|
||||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to build here!");
|
player.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to build here!");
|
||||||
@ -62,6 +66,7 @@ public class PortalProtect implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onExplosion(EntityExplodeEvent event) {
|
public void onExplosion(EntityExplodeEvent event) {
|
||||||
|
if(!this.PortalProtect) return;
|
||||||
|
|
||||||
List<Block> blockList = event.blockList();
|
List<Block> blockList = event.blockList();
|
||||||
for (int i = 0; i < blockList.size(); i++) {
|
for (int i = 0; i < blockList.size(); i++) {
|
||||||
|
@ -3,11 +3,12 @@ package com.sekwah.advancedportals.bukkit.portals;
|
|||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.bukkit.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||||
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
||||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||||
|
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -40,7 +41,8 @@ public class Portal {
|
|||||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||||
this.showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
|
this.showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
|
||||||
|
|
||||||
this.portalProtectionRadius = config.getConfig().getInt("PortalProtectionRadius");
|
this.portalProtectionRadius = config.getConfig().getBoolean("PortalProtection") ?
|
||||||
|
config.getConfig().getInt("PortalProtectionArea") : 0;
|
||||||
|
|
||||||
this.throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
|
this.throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
|
||||||
|
|
||||||
@ -483,9 +485,11 @@ public class Portal {
|
|||||||
|
|
||||||
if (portal.getDestiation() != null) {
|
if (portal.getDestiation() != null) {
|
||||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||||
outForList.writeUTF("PortalEnter");
|
outForList.writeUTF(BungeeMessages.ENTER_PORTAL);
|
||||||
outForList.writeUTF(bungeeServer);
|
outForList.writeUTF(bungeeServer);
|
||||||
outForList.writeUTF(portal.getDestiation());
|
outForList.writeUTF(portal.getDestiation());
|
||||||
|
outForList.writeUTF(player.getUniqueId().toString());
|
||||||
|
outForList.writeUTF(player.getName());
|
||||||
|
|
||||||
player.sendPluginMessage(plugin, plugin.channelName, outForList.toByteArray());
|
player.sendPluginMessage(plugin, plugin.channelName, outForList.toByteArray());
|
||||||
}
|
}
|
||||||
@ -559,8 +563,7 @@ public class Portal {
|
|||||||
} else if (command.startsWith("%") && plugin.getSettings().enabledCommandLevel("b")) {
|
} else if (command.startsWith("%") && plugin.getSettings().enabledCommandLevel("b")) {
|
||||||
command = command.substring(1);
|
command = command.substring(1);
|
||||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||||
outForList.writeUTF("BungeeCommand");
|
outForList.writeUTF(BungeeMessages.BUNGEE_COMMAND);
|
||||||
outForList.writeUTF(player.getUniqueId().toString());
|
|
||||||
outForList.writeUTF(command);
|
outForList.writeUTF(command);
|
||||||
player.sendPluginMessage(plugin, plugin.channelName, outForList.toByteArray());
|
player.sendPluginMessage(plugin, plugin.channelName, outForList.toByteArray());
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,7 +11,7 @@ public class AdvancedPortalsPlugin extends Plugin {
|
|||||||
|
|
||||||
public String channelName = "mc:advancedportals";
|
public String channelName = "mc:advancedportals";
|
||||||
|
|
||||||
public HashMap<UUID, String[]> PlayerDestiMap = new HashMap<>();
|
public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
|
||||||
// key: UUID (string)
|
// key: UUID (string)
|
||||||
// value: [0] targetServer, [1] targetDestination
|
// value: [0] targetServer, [1] targetDestination
|
||||||
|
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.sekwah.advancedportals.bungee;
|
||||||
|
|
||||||
|
public class BungeeMessages {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I may be severely wrong but there is a serious problem with offline UUID's
|
||||||
|
*/
|
||||||
|
public static final String WARNING_MESSAGE = "\u00A7cOffline UUID detected\n" +
|
||||||
|
"You should be using IP forwarding as it also forwards UUIDs\n" +
|
||||||
|
"The issue of accounts with duplicate names does exist so ignoring this message is a bad idea\n" +
|
||||||
|
"as changing a username alters the UUID and people can also log in as anyone if they find the sub server ip\n" +
|
||||||
|
"\n" +
|
||||||
|
"Instructions to setup IP forwarding https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/\n" +
|
||||||
|
"\n" +
|
||||||
|
"Publicly complaining about this message will just show everyone you have set up your server insecurely\n" +
|
||||||
|
"\n" +
|
||||||
|
"If you have a genuine reason to be running without IP forwarding or feel I am wrong about the above statements, " +
|
||||||
|
"feel free to DM me on Spigot and I will remove this message if it is a valid reason.\n\n" +
|
||||||
|
"This message also will only shows if the bungee is in online mode.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String in
|
||||||
|
* string bungee server
|
||||||
|
* string desti name
|
||||||
|
* string uuid (of what the server thinks it is)
|
||||||
|
*
|
||||||
|
* String out (to recieving server)
|
||||||
|
* string destination
|
||||||
|
* string uuid
|
||||||
|
* string offline uuid
|
||||||
|
*
|
||||||
|
* String out
|
||||||
|
*/
|
||||||
|
public static String ENTER_PORTAL = "PortalEnter";
|
||||||
|
|
||||||
|
|
||||||
|
public static String SERVER_DESTI = "BungeePortal";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same in and out. This is read by the bungee
|
||||||
|
* String containing command
|
||||||
|
*/
|
||||||
|
public static String BUNGEE_COMMAND = "BungeeCommand";
|
||||||
|
}
|
@ -3,6 +3,7 @@ package com.sekwah.advancedportals.bungee.listener;
|
|||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
||||||
|
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
@ -16,20 +17,22 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerSwitchServer(ServerSwitchEvent event) {
|
public void onPlayerSwitchServer(ServerSwitchEvent event) {
|
||||||
UUID uuid = event.getPlayer().getUniqueId();
|
String uuid = event.getPlayer().getUniqueId().toString();
|
||||||
|
|
||||||
if (plugin.PlayerDestiMap.containsKey(uuid)) {
|
if (plugin.PlayerDestiMap.containsKey(uuid)) {
|
||||||
String[] val = plugin.PlayerDestiMap.get(uuid);
|
String[] val = plugin.PlayerDestiMap.get(uuid);
|
||||||
|
|
||||||
// key: UUID (string)
|
// key: UUID (string)
|
||||||
// value: [0] targetServer, [1] targetDestination
|
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID, [3] offlineUUID
|
||||||
|
|
||||||
if (event.getPlayer().getServer().getInfo().getName().equalsIgnoreCase(val[0])) {
|
if (event.getPlayer().getServer().getInfo().getName().equalsIgnoreCase(val[0])) {
|
||||||
|
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
|
||||||
out.writeUTF("BungeePortal");
|
out.writeUTF(BungeeMessages.SERVER_DESTI);
|
||||||
out.writeUTF(val[1]);
|
out.writeUTF(val[1]);
|
||||||
|
out.writeUTF(val[2]);
|
||||||
|
out.writeUTF(val[3]);
|
||||||
|
|
||||||
event.getPlayer().getServer().sendData(plugin.channelName, out.toByteArray());
|
event.getPlayer().getServer().sendData(plugin.channelName, out.toByteArray());
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.sekwah.advancedportals.bungee.listener;
|
package com.sekwah.advancedportals.bungee.listener;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
||||||
|
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
@ -24,32 +26,44 @@ public class PluginMessageReceiver implements Listener {
|
|||||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||||
String subChannel = in.readUTF();
|
String subChannel = in.readUTF();
|
||||||
|
|
||||||
if (subChannel.equalsIgnoreCase("PortalEnter")) {
|
if (subChannel.equalsIgnoreCase(BungeeMessages.ENTER_PORTAL)) {
|
||||||
String targetServer = in.readUTF();
|
String targetServer = in.readUTF();
|
||||||
String targetDestination = in.readUTF();
|
String targetDestination = in.readUTF();
|
||||||
UUID uuid;
|
String targetUUID = in.readUTF();
|
||||||
|
String targetName = in.readUTF();
|
||||||
|
|
||||||
|
String bungeeUUID; // If the bungee is offline mode it will be an offline uuid
|
||||||
|
|
||||||
|
String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + targetName).getBytes(Charsets.UTF_8)).toString();
|
||||||
|
|
||||||
if ( event.getReceiver() instanceof ProxiedPlayer )
|
if ( event.getReceiver() instanceof ProxiedPlayer )
|
||||||
{
|
{
|
||||||
ProxiedPlayer receiver = (ProxiedPlayer) event.getReceiver();
|
ProxiedPlayer receiver = (ProxiedPlayer) event.getReceiver();
|
||||||
uuid = receiver.getUniqueId();
|
bungeeUUID = receiver.getUniqueId().toString();
|
||||||
|
if(!targetUUID.equals(bungeeUUID)) {
|
||||||
|
Server connection = (Server) event.getSender();
|
||||||
|
plugin.getLogger().warning(BungeeMessages.WARNING_MESSAGE
|
||||||
|
+ "\n\nThe server the player was sent from is the offending server.\n" +
|
||||||
|
"Server Name: " + connection.getInfo().getName());
|
||||||
|
}
|
||||||
|
targetUUID = bungeeUUID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plugin.getLogger().warning("There has been an issue getting the player for the teleport request.");
|
plugin.getLogger().warning("There has been an issue getting the player for the teleport request.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.PlayerDestiMap.put(uuid, new String[]{targetServer, targetDestination});
|
plugin.PlayerDestiMap.put(targetUUID, new String[]{targetServer, targetDestination, targetUUID, offlineUUID});
|
||||||
|
|
||||||
|
String finalTargetUUID = targetUUID;
|
||||||
plugin.getProxy().getScheduler().schedule(plugin, () -> {
|
plugin.getProxy().getScheduler().schedule(plugin, () -> {
|
||||||
plugin.PlayerDestiMap.remove(uuid);
|
plugin.PlayerDestiMap.remove(finalTargetUUID);
|
||||||
}, 20, TimeUnit.SECONDS);
|
}, 20, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
else if (subChannel.equalsIgnoreCase("BungeeCommand")) {
|
else if (subChannel.equalsIgnoreCase(BungeeMessages.BUNGEE_COMMAND)) {
|
||||||
String targetPlayerUUID = in.readUTF();
|
|
||||||
String command = in.readUTF();
|
String command = in.readUTF();
|
||||||
ProxiedPlayer player = plugin.getProxy().getPlayer(UUID.fromString(targetPlayerUUID));
|
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
// To send command to server the player is currently on
|
// To send command to server the player is currently on in a lazy way
|
||||||
//player.chat("/" + command);
|
//player.chat("/" + command);
|
||||||
plugin.getProxy().getPluginManager().dispatchCommand(player, command);
|
plugin.getProxy().getPluginManager().dispatchCommand(player, command);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
# To set this file back to its default state just delete it and reload the server or restart it!
|
# To set this file back to its default state just delete it and reload the server or restart it!
|
||||||
|
|
||||||
|
# Will update whenever there is a config update from an older version so may not be the latest plugin version
|
||||||
|
ConfigVersion: 0.5.4
|
||||||
|
|
||||||
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
|
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
|
||||||
# It can be usefull if people with permission want to use an iron axe on a survival server
|
# It can be usefull if people with permission want to use an iron axe on a survival server
|
||||||
|
Loading…
Reference in New Issue
Block a user