mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-22 10:36:17 +01:00
Add force override to enable proxy.
This commit is contained in:
parent
2da18a3417
commit
f8e5cced9e
@ -9,34 +9,32 @@ import com.sekwah.advancedportals.bukkit.listeners.*;
|
||||
import com.sekwah.advancedportals.bukkit.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
//public CraftBukkit compat = null;
|
||||
private Settings settings;
|
||||
|
||||
public boolean registeredBungeeChannels = false;
|
||||
protected boolean isProxyPluginEnabled = false;
|
||||
|
||||
public HashMap<String, String> PlayerDestiMap = new HashMap<>();
|
||||
protected boolean forceRegisterProxyChannels = false;
|
||||
|
||||
protected static final Map<String, String> PLAYER_DESTI_MAP = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
String packageName = getServer().getClass().getPackage().getName();
|
||||
String[] packageSplit = packageName.split("\\.");
|
||||
String version = packageSplit[packageSplit.length - 1];
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
/*Metrics metrics = */
|
||||
new Metrics(this);
|
||||
|
||||
|
||||
//this.compat = new CraftBukkit(this, version);
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
|
||||
|
||||
ConfigHelper configHelper = new ConfigHelper(config.getConfig());
|
||||
@ -45,10 +43,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
// TODO reenable and finish but probably focus on the recode first
|
||||
/*if(config.getConfig().getBoolean("DisableGatewayBeam", true)) {
|
||||
new PacketInjector(this, version);
|
||||
}*/
|
||||
FileConfiguration pluginConfig = config.getConfig();
|
||||
forceRegisterProxyChannels = pluginConfig.getBoolean(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, false);
|
||||
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
|
||||
portalConfig.saveDefaultConfig();
|
||||
@ -60,8 +56,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
this.settings = new Settings(this);
|
||||
|
||||
// Loads the portal and destination editors
|
||||
new Portal(this);
|
||||
new Destination(this);
|
||||
Portal.init(this);
|
||||
Destination.init(this);
|
||||
|
||||
|
||||
this.registerCommands();
|
||||
@ -106,18 +102,26 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
private void setupBungee() {
|
||||
// Enables very basic bungee support if not setup right
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
if(this.checkIfBungee()) {
|
||||
if(forceRegisterProxyChannels || this.checkIfBungee()) {
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, BungeeMessages.CHANNEL_NAME);
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, BungeeMessages.CHANNEL_NAME, new PluginMessageReceiver(this));
|
||||
registeredBungeeChannels = true;
|
||||
isProxyPluginEnabled = true;
|
||||
}
|
||||
else {
|
||||
registeredBungeeChannels = false;
|
||||
isProxyPluginEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getPlayerDestiMap() {
|
||||
return PLAYER_DESTI_MAP;
|
||||
}
|
||||
|
||||
public boolean isProxyPluginEnabled() {
|
||||
return isProxyPluginEnabled;
|
||||
}
|
||||
|
||||
private boolean checkIfBungee()
|
||||
{
|
||||
// we check if the server is Spigot/Paper (because of the spigot.yml file)
|
||||
@ -125,13 +129,17 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
} catch (ClassNotFoundException e) {
|
||||
this.getServer().getConsoleSender().sendMessage( "\u00A7ePossibly unsupported version for bungee messages detected, channels won't be enabled." );
|
||||
getLogger().info("If you believe this shouldn't be the case please contact us on discord https://discord.gg/fAJ3xJg");
|
||||
getLogger().info("If you believe this shouldn't be the case please contact us on discord https://discord.sekwah.com/");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !getServer().spigot().getConfig().getConfigurationSection("settings").getBoolean( "bungeecord" ) )
|
||||
{
|
||||
getLogger().warning( "Advanced bungee features disabled for Advanced Portals as bungee isn't enabled on the server (spigot.yml)" );
|
||||
try {
|
||||
ConfigurationSection configSelection = getServer().spigot().getConfig().getConfigurationSection("settings");
|
||||
if (configSelection == null || !configSelection.getBoolean("bungeecord") ) {
|
||||
getLogger().warning( "Advanced bungee features disabled for Advanced Portals as bungee isn't enabled on the server (spigot.yml)" );
|
||||
return false;
|
||||
}
|
||||
} catch(NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -139,6 +147,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ public class ConfigHelper {
|
||||
|
||||
public static String COMMAND_LOGS = "CommandLogs";
|
||||
|
||||
public static String FORCE_ENABLE_PROXY_SUPPORT = "ForceEnableProxySupport";
|
||||
|
||||
public static String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam";
|
||||
|
||||
private FileConfiguration config;
|
||||
@ -30,6 +32,9 @@ public class ConfigHelper {
|
||||
} else if(configVersion.equals("0.5.4")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.11");
|
||||
config.set(ConfigHelper.COMMAND_LOGS, true);
|
||||
} else if(configVersion.equals("0.5.10") || configVersion.equals("0.5.11")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.13");
|
||||
config.set(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class Destination {
|
||||
private static boolean TELEPORT_RIDING = false;
|
||||
public static int PORTAL_MESSAGE_DISPLAY = 0;
|
||||
|
||||
public Destination(AdvancedPortalsPlugin plugin) {
|
||||
public static void init(AdvancedPortalsPlugin plugin) {
|
||||
Destination.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
|
@ -105,9 +105,11 @@ public class Listeners implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.PlayerDestiMap.containsKey(uuid.toString())) {
|
||||
Destination.warp(player, plugin.PlayerDestiMap.get(uuid.toString()), false, true);
|
||||
plugin.PlayerDestiMap.remove(uuid.toString());
|
||||
Map<String, String> playerMap = plugin.getPlayerDestiMap();
|
||||
|
||||
if (playerMap.containsKey(uuid.toString())) {
|
||||
Destination.warp(player, playerMap.get(uuid.toString()), false, true);
|
||||
playerMap.remove(uuid.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
@ -40,10 +39,10 @@ public class PluginMessageReceiver implements PluginMessageListener {
|
||||
|
||||
}
|
||||
else {
|
||||
plugin.PlayerDestiMap.put(bungeeUUID, targetDestination);
|
||||
plugin.getPlayerDestiMap().put(bungeeUUID, targetDestination);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
plugin.PlayerDestiMap.remove(bungeeUUID),
|
||||
plugin.getPlayerDestiMap().remove(bungeeUUID),
|
||||
20L * 10
|
||||
);
|
||||
}
|
||||
|
@ -41,21 +41,21 @@ public class Portal {
|
||||
private static boolean commandLog;
|
||||
private static Random random = new Random();
|
||||
|
||||
public Portal(AdvancedPortalsPlugin plugin) {
|
||||
public static void init(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
|
||||
showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
|
||||
|
||||
this.portalProtectionRadius = config.getConfig().getBoolean("PortalProtection") ?
|
||||
portalProtectionRadius = config.getConfig().getBoolean("PortalProtection") ?
|
||||
config.getConfig().getInt("PortalProtectionArea") : 0;
|
||||
|
||||
this.throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
|
||||
throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
|
||||
|
||||
this.portalSound = WarpEffects.findSound(plugin, "BLOCK_PORTAL_TRAVEL", "PORTAL_TRAVEL");
|
||||
this.blockSpectatorMode = config.getConfig().getBoolean("BlockSpectatorMode", false);
|
||||
portalSound = WarpEffects.findSound(plugin, "BLOCK_PORTAL_TRAVEL", "PORTAL_TRAVEL");
|
||||
blockSpectatorMode = config.getConfig().getBoolean("BlockSpectatorMode", false);
|
||||
|
||||
this.joinCooldownDelay = config.getConfig().getInt("PortalCooldown", 5);
|
||||
joinCooldownDelay = config.getConfig().getInt("PortalCooldown", 5);
|
||||
|
||||
this.commandLog = config.getConfig().getBoolean(ConfigHelper.COMMAND_LOGS, true);
|
||||
commandLog = config.getConfig().getBoolean(ConfigHelper.COMMAND_LOGS, true);
|
||||
|
||||
Portal.plugin = plugin;
|
||||
Portal.loadPortals();
|
||||
@ -508,7 +508,7 @@ public class Portal {
|
||||
}
|
||||
|
||||
if (portal.getDestiation() != null) {
|
||||
if(plugin.registeredBungeeChannels) {
|
||||
if(plugin.isProxyPluginEnabled()) {
|
||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||
outForList.writeUTF(BungeeMessages.ENTER_PORTAL);
|
||||
outForList.writeUTF(bungeeServer);
|
||||
@ -589,7 +589,7 @@ public class Portal {
|
||||
player.removeAttachment(permissionAttachment);
|
||||
}
|
||||
} else if (command.startsWith("%") && plugin.getSettings().enabledCommandLevel("b")) {
|
||||
if(plugin.registeredBungeeChannels) {
|
||||
if(plugin.isProxyPluginEnabled()) {
|
||||
command = command.substring(1);
|
||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||
outForList.writeUTF(BungeeMessages.BUNGEE_COMMAND);
|
||||
|
@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@Plugin(id = "advancedportals", name = "Advanced Portals",
|
||||
url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
|
||||
version = "0.5.12")
|
||||
version = "0.5.13")
|
||||
public class AdvancedPortalsPlugin {
|
||||
|
||||
public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
|
||||
@ -60,7 +60,6 @@ public class AdvancedPortalsPlugin {
|
||||
|
||||
String subChannel = in.readUTF();
|
||||
|
||||
System.out.printf("SubChannel: %s%n", subChannel);
|
||||
if (subChannel.equalsIgnoreCase(BungeeMessages.ENTER_PORTAL)) {
|
||||
String targetServer = in.readUTF();
|
||||
String targetDestination = in.readUTF();
|
||||
@ -91,15 +90,11 @@ public class AdvancedPortalsPlugin {
|
||||
|
||||
String[] val = PlayerDestiMap.get(uuid);
|
||||
|
||||
System.out.println("POSTJOIN");
|
||||
System.out.println(event);
|
||||
|
||||
if (val != null) {
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID
|
||||
|
||||
event.getPlayer().getCurrentServer().ifPresent(serverConnection -> {
|
||||
System.out.println("EXIST");
|
||||
|
||||
if (serverConnection.getServerInfo().getName().equalsIgnoreCase(val[0])) {
|
||||
|
||||
@ -109,8 +104,6 @@ public class AdvancedPortalsPlugin {
|
||||
out.writeUTF(val[1]);
|
||||
out.writeUTF(val[2]);
|
||||
|
||||
System.out.println(serverConnection.sendPluginMessage(AP_CHANNEL, out.toByteArray()));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.5.12
|
||||
version: 0.5.13
|
||||
author: sekwah41
|
||||
|
@ -3,7 +3,7 @@
|
||||
# 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.10
|
||||
ConfigVersion: 0.5.13
|
||||
|
||||
# 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
|
||||
@ -88,3 +88,6 @@ CommandLevels: opcb
|
||||
|
||||
# Should the commands being triggered log in the console? (If you have an active server it may cause a bit of spam)
|
||||
CommandLogs: true
|
||||
|
||||
# If you want to use bungee or velocity and it is not automatically detected (make sure you have advanced portals on the proxy, especially with velocity)
|
||||
ForceEnableProxySupport: false
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.5.12
|
||||
version: 0.5.13
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
api-version: 1.13
|
||||
|
Loading…
Reference in New Issue
Block a user