├── version.txt ├── .release-please-manifest.json ├── .DS_Store ├── .gitattributes ├── .vscode └── settings.json ├── docs └── logo.png ├── lang └── build.gradle ├── spigot └── src │ └── main │ ├── java │ └── com │ │ └── sekwah │ │ └── advancedportals │ │ └── spigot │ │ ├── metrics │ │ └── .clang-format │ │ ├── warpeffects │ │ ├── SpigotWarpEffects.java │ │ └── EnderWarpEffect.java │ │ ├── SpigotInfoLogger.java │ │ ├── utils │ │ └── ContainerHelpers.java │ │ ├── connector │ │ ├── command │ │ │ ├── SpigotCommandRegister.java │ │ │ └── SpigotCommandHandler.java │ │ └── container │ │ │ ├── SpigotCommandSenderContainer.java │ │ │ └── SpigotEntityContainer.java │ │ ├── PermissionsGeneratorSpigot.java │ │ ├── importer │ │ └── ConfigAccessor.java │ │ └── commands │ │ └── subcommands │ │ └── portal │ │ └── ImportPortalSubCommand.java │ └── templates │ └── plugin.yml ├── legacyspigot └── src │ └── main │ ├── java │ └── com │ │ └── sekwah │ │ └── advancedportals │ │ └── legacyspigot │ │ ├── metrics │ │ └── .clang-format │ │ ├── warpeffects │ │ ├── SpigotWarpEffects.java │ │ └── EnderWarpEffect.java │ │ ├── LegacySpigotInfoLogger.java │ │ ├── utils │ │ └── ContainerHelpers.java │ │ ├── connector │ │ ├── command │ │ │ ├── LegacySpigotCommandRegister.java │ │ │ └── LegacySpigotCommandHandler.java │ │ └── container │ │ │ ├── LegacySpigotCommandSenderContainer.java │ │ │ ├── LegacySpigotWorldContainer.java │ │ │ └── LegacySpigotEntityContainer.java │ │ ├── PermissionsGeneratorSpigot.java │ │ ├── importer │ │ └── ConfigAccessor.java │ │ └── commands │ │ └── subcommands │ │ └── portal │ │ └── ImportPortalSubCommand.java │ └── templates │ └── plugin.yml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── core ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── sekwah │ │ │ └── advancedportals │ │ │ └── core │ │ │ ├── data │ │ │ ├── BlockAxis.java │ │ │ └── Direction.java │ │ │ ├── network │ │ │ ├── Packet.java │ │ │ ├── ProxyCommandPacket.java │ │ │ ├── ServerDestiPacket.java │ │ │ ├── ProxyTransferPacket.java │ │ │ └── ProxyTransferDestiPacket.java │ │ │ ├── services │ │ │ ├── Creation.java │ │ │ └── PlayerDataServices.java │ │ │ ├── warphandler │ │ │ ├── TriggerType.java │ │ │ └── ActivationData.java │ │ │ ├── connector │ │ │ ├── containers │ │ │ │ ├── GameMode.java │ │ │ │ ├── HasPermission.java │ │ │ │ ├── CommandSenderContainer.java │ │ │ │ ├── EntityContainer.java │ │ │ │ ├── WorldContainer.java │ │ │ │ ├── ServerContainer.java │ │ │ │ └── PlayerContainer.java │ │ │ └── commands │ │ │ │ ├── CommandHandler.java │ │ │ │ └── CommandRegister.java │ │ │ ├── portal │ │ │ └── ActivationResult.java │ │ │ ├── repository │ │ │ ├── IPortalRepository.java │ │ │ ├── IDestinationRepository.java │ │ │ ├── IPlayerDataRepository.java │ │ │ ├── IJsonRepository.java │ │ │ ├── impl │ │ │ │ ├── PlayerDataRepositoryImpl.java │ │ │ │ ├── DestinationRepositoryImpl.java │ │ │ │ └── PortalRepositoryImpl.java │ │ │ └── ConfigRepository.java │ │ │ ├── registry │ │ │ ├── CommandErrorCode.java │ │ │ ├── CommandException.java │ │ │ ├── CommandHandler.java │ │ │ ├── RegisterBuilder.java │ │ │ ├── TagTarget.java │ │ │ ├── WarpEffectRegistry.java │ │ │ └── SubCommandRegistry.java │ │ │ ├── serializeddata │ │ │ ├── config │ │ │ │ ├── WarpEffectConfig.java │ │ │ │ ├── ConfigProvider.java │ │ │ │ ├── CommandPortalConfig.java │ │ │ │ └── Config.java │ │ │ ├── DataTag.java │ │ │ ├── ReflectiveRepresenter.java │ │ │ ├── WorldLocation.java │ │ │ ├── Vector.java │ │ │ ├── PlayerLocation.java │ │ │ └── BlockLocation.java │ │ │ ├── util │ │ │ ├── InfoLogger.java │ │ │ ├── PlayerUtils.java │ │ │ ├── GameScheduler.java │ │ │ └── Matrix.java │ │ │ ├── effect │ │ │ └── WarpEffect.java │ │ │ ├── ProxyMessages.java │ │ │ ├── commands │ │ │ ├── CommandTemplate.java │ │ │ ├── SubCommand.java │ │ │ └── subcommands │ │ │ │ ├── portal │ │ │ │ ├── VersionSubCommand.java │ │ │ │ ├── ListPortalsSubCommand.java │ │ │ │ ├── RemovePortalSubCommand.java │ │ │ │ ├── ReloadPortalSubCommand.java │ │ │ │ ├── EndGatewayBlockSubCommand.java │ │ │ │ ├── EndPortalBlockSubCommand.java │ │ │ │ ├── PortalBlockSubCommand.java │ │ │ │ ├── InfoPortalSubCommand.java │ │ │ │ ├── DisableBeaconSubCommand.java │ │ │ │ ├── SelectorSubCommand.java │ │ │ │ └── MovePortalSubCommand.java │ │ │ │ └── desti │ │ │ │ ├── ListDestiSubCommand.java │ │ │ │ ├── RemoveDestiSubCommand.java │ │ │ │ ├── RenameDestiSubCommand.java │ │ │ │ └── MoveDestiSubCommand.java │ │ │ └── tags │ │ │ ├── NameTag.java │ │ │ ├── BungeeTag.java │ │ │ ├── PermissionTag.java │ │ │ ├── MessageTag.java │ │ │ ├── PortalEventTag.java │ │ │ ├── TriggerBlockTag.java │ │ │ └── ProxyTag.java │ │ └── templates │ │ └── com │ │ └── sekwah │ │ └── advancedportals │ │ └── core │ │ └── BuildConstants.java └── build.gradle ├── bungee ├── src │ └── main │ │ ├── resources │ │ └── bungee.yml │ │ └── java │ │ └── com │ │ └── sekwah │ │ └── advancedportals │ │ └── bungee │ │ ├── connector │ │ └── container │ │ │ ├── BungeeProxyServerContainer.java │ │ │ ├── BungeeProxyPlayerContainer.java │ │ │ └── BungeeProxyContainer.java │ │ ├── BungeeInfoLogger.java │ │ ├── AdvancedPortalsBungeePlugin.java │ │ └── EventListener.java └── build.gradle ├── PULL_REQUEST_TEMPLATE.md ├── .clang-format-ignore ├── .gitignore ├── proxycore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── sekwah │ │ └── advancedportals │ │ └── proxycore │ │ └── connector │ │ └── container │ │ ├── ProxyServerContainer.java │ │ ├── ProxyPlayerContainer.java │ │ ├── ProxyContainer.java │ │ └── ProxyJoinData.java └── build.gradle ├── changelog-util.gradle ├── gradle.properties ├── settings.gradle ├── CODE_OF_CONDUCT.md ├── .clang-format ├── CONTRIBUTING.md ├── env-variables.gradle ├── velocity ├── src │ └── main │ │ └── java │ │ └── com │ │ └── sekwah │ │ └── advancedportals │ │ └── velocity │ │ ├── connector │ │ ├── container │ │ │ ├── VelocityProxyServerContainer.java │ │ │ ├── VelocityProxyPlayerContainer.java │ │ │ └── VelocityProxyContainer.java │ │ └── MinecraftToAnsi.java │ │ ├── VelocityInfoLogger.java │ │ └── AdvancedPortalsVelocityPlugin.java └── build.gradle ├── .pre-commit-config.yaml ├── .github └── workflows │ ├── snapshots.yml │ ├── pre-commit-check.yaml │ └── release-please.yml ├── release-please-config.json ├── gradlew.bat ├── README.md └── discord.gradle /version.txt: -------------------------------------------------------------------------------- 1 | 2.6.0 2 | -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | ".": "2.6.0" 3 | } 4 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sekwah41/Advanced-Portals/HEAD/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour to maintain line endings 2 | * -text 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.compile.nullAnalysis.mode": "automatic" 3 | } 4 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sekwah41/Advanced-Portals/HEAD/docs/logo.png -------------------------------------------------------------------------------- /lang/build.gradle: -------------------------------------------------------------------------------- 1 | // Check the root build.gradle under allprojects for common settings 2 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/metrics/.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true 2 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/metrics/.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sekwah41/Advanced-Portals/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/data/BlockAxis.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.data; 2 | 3 | public enum BlockAxis { X, Y, Z } 4 | -------------------------------------------------------------------------------- /bungee/src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | main: com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin 2 | name: AdvancedPortals 3 | version: ${pluginVersion} 4 | author: sekwah41 5 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fixes: 2 | - 3 | - 4 | - 5 | 6 | 7 | Tweaks: 8 | - 9 | - 10 | - 11 | 12 | Reason: (Leave this if it is obvious why from the tweak and/or fix notes) 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/network/Packet.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.network; 2 | 3 | public interface Packet { 4 | byte[] encode(); 5 | } 6 | -------------------------------------------------------------------------------- /.clang-format-ignore: -------------------------------------------------------------------------------- 1 | ./legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/metrics/Metrics.java 2 | ./spigot/src/main/java/com/sekwah/advancedportals/spigot/metrics/Metrics.java 3 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/services/Creation.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.services; 2 | 3 | public enum Creation { SUCCESS, NAME_IN_USE, TAG_REJECTED } 4 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/warphandler/TriggerType.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.warphandler; 2 | 3 | public enum TriggerType { MOVEMENT, PORTAL, MANUAL } 4 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/containers/GameMode.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.containers; 2 | 3 | public enum GameMode { SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR } 4 | -------------------------------------------------------------------------------- /core/src/main/templates/com/sekwah/advancedportals/core/BuildConstants.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core; 2 | 3 | public class BuildConstants { 4 | public static final String VERSION = "${version}"; 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .gradle 3 | .idea 4 | /build/ 5 | /target/ 6 | */build/ 7 | 8 | # Package Files # 9 | *.war 10 | *.ear 11 | 12 | *.iml 13 | *.iws 14 | *.ipr 15 | 16 | logs/ 17 | classes/ 18 | run/ 19 | .DS_Store 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/portal/ActivationResult.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.portal; 2 | 3 | public enum ActivationResult { 4 | SUCCESS, 5 | FAILED_DO_KNOCKBACK, 6 | FAILED_DO_NOTHING 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyServerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.proxycore.connector.container; 2 | 3 | public interface ProxyServerContainer { 4 | String getServerName(); 5 | } 6 | -------------------------------------------------------------------------------- /changelog-util.gradle: -------------------------------------------------------------------------------- 1 | ext.getReleaseChangelog = { 2 | def changelogFile = rootProject.file('CHANGELOG.md') 3 | def changelog = "## [${changelogFile.text.split('\n## \\[')[1]}\n\n" // ${project.github}/blob/${branch}/CHANGELOG.md 4 | return changelog 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/containers/HasPermission.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.containers; 2 | 3 | public interface HasPermission { 4 | boolean isOp(); 5 | boolean hasPermission(String permission); 6 | } 7 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # https://docs.gradle.org/current/userguide/build_environment.html 2 | # Disable with --no-build-cache 3 | org.gradle.caching=true 4 | 5 | github=https://github.com/sekwah41/Advanced-Portals 6 | curse_project_id=86001 7 | modrinth_slug=advanced-portals 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "Advanced-Portals" 2 | // Core modules 3 | include 'core' 4 | include 'proxycore' 5 | include 'lang' 6 | 7 | // Implementations 8 | include 'spigot' 9 | include 'legacyspigot' 10 | 11 | // Proxies 12 | include 'velocity' 13 | include 'bungee' 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/IPortalRepository.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository; 2 | 3 | import com.sekwah.advancedportals.core.portal.AdvancedPortal; 4 | 5 | public interface IPortalRepository extends IJsonRepository {} 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | Basically don't steal code from other projects and don't be a dick. 4 | 5 | I didn't like how overly formal the default code of conduct was from github and someone joked about it and I agree its weird as this is a little hobby project. 6 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/IDestinationRepository.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository; 2 | 3 | import com.sekwah.advancedportals.core.destination.Destination; 4 | 5 | public interface IDestinationRepository extends IJsonRepository {} 6 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/IPlayerDataRepository.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.PlayerData; 4 | 5 | public interface IPlayerDataRepository extends IJsonRepository {} 6 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/registry/CommandErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.registry; 2 | 3 | public enum CommandErrorCode { 4 | INSUFFICIENT_ARGUMENTS(""), 5 | NO_PERMISSION(""); 6 | 7 | CommandErrorCode(String message) { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyPlayerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.proxycore.connector.container; 2 | 3 | public interface ProxyPlayerContainer { 4 | String getUUID(); 5 | String getName(); 6 | void sendServerPluginMessage(byte[] data); 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/WarpEffectConfig.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata.config; 2 | 3 | public class WarpEffectConfig { 4 | public String visualEffect = "ender"; 5 | public String soundEffect = "ender"; 6 | public final boolean enabled = true; 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/ConfigProvider.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata.config; 2 | 3 | import com.google.inject.Provider; 4 | 5 | public class ConfigProvider implements Provider { 6 | @Override 7 | public Config get() { 8 | return null; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.proxycore.connector.container; 2 | 3 | public interface ProxyContainer { 4 | void invokeCommand(ProxyPlayerContainer proxyPlayer, String command); 5 | 6 | void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName); 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/DataTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata; 2 | 3 | public class DataTag { 4 | public final String NAME; 5 | public final String[] VALUES; 6 | 7 | public DataTag(String argName, String... values) { 8 | this.NAME = argName; 9 | this.VALUES = values; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/CommandPortalConfig.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata.config; 2 | 3 | public class CommandPortalConfig { 4 | public boolean op = true; 5 | public boolean console = true; 6 | public boolean permsWildcard = true; 7 | public boolean proxy = true; 8 | public boolean enabled = true; 9 | } 10 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | IndentWidth: 4 3 | TabWidth: 4 4 | UseTab: Never 5 | AllowShortFunctionsOnASingleLine: None 6 | BreakAfterJavaFieldAnnotations: true 7 | BreakBeforeBraces: Attach 8 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 9 | BreakConstructorInitializers: BeforeComma 10 | AlignAfterOpenBracket: Align 11 | PenaltyBreakBeforeFirstCallParameter: 1 12 | ColumnLimit: 80 13 | SpaceBeforeParens: ControlStatements 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/IJsonRepository.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository; 2 | 3 | import java.util.List; 4 | 5 | public interface IJsonRepository { 6 | boolean save(String name, T t); 7 | 8 | boolean containsKey(String name); 9 | 10 | boolean delete(String name); 11 | 12 | T get(String name); 13 | 14 | List getAllNames(); 15 | 16 | List getAll(); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/commands/CommandHandler.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.commands; 2 | 3 | import com.sekwah.advancedportals.core.commands.CommandTemplate; 4 | 5 | public abstract class CommandHandler { 6 | private final CommandTemplate commandExecutor; 7 | 8 | public CommandHandler(CommandTemplate commandExecutor) { 9 | this.commandExecutor = commandExecutor; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/containers/CommandSenderContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.containers; 2 | 3 | public interface CommandSenderContainer extends HasPermission { 4 | void sendMessage(String message); 5 | 6 | ServerContainer getServer(); 7 | 8 | /** 9 | * @return null if there isn't a player e.g. the console 10 | */ 11 | PlayerContainer getPlayerContainer(); 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/commands/CommandRegister.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.commands; 2 | 3 | import com.sekwah.advancedportals.core.commands.CommandTemplate; 4 | 5 | public interface CommandRegister { 6 | /** 7 | * Registers the command to the appropriate system 8 | * 9 | * @param commandName 10 | * @param commandExecutor 11 | */ 12 | void registerCommand(String commandName, CommandTemplate commandExecutor); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/data/Direction.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.data; 2 | 3 | public enum Direction { 4 | NORTH(0, 0, -1), 5 | EAST(1, 0, 0), 6 | SOUTH(0, 0, 1), 7 | WEST(-1, 0, 0), 8 | UP(0, 1, 0), 9 | DOWN(0, -1, 0); 10 | 11 | public final int x; 12 | public final int y; 13 | public final int z; 14 | 15 | Direction(int x, int y, int z) { 16 | this.x = x; 17 | this.y = y; 18 | this.z = z; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/util/InfoLogger.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.util; 2 | 3 | public abstract class InfoLogger { 4 | /** 5 | * Problematic messages 6 | * 7 | * @param s warning message 8 | */ 9 | public abstract void warning(String s); 10 | 11 | /** 12 | * General information logging 13 | * 14 | * @param s info message 15 | */ 16 | public abstract void info(String s); 17 | 18 | public abstract void error(Exception e); 19 | } 20 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.warpeffects; 2 | 3 | import com.sekwah.advancedportals.core.registry.WarpEffectRegistry; 4 | import com.sekwah.advancedportals.shadowed.inject.Inject; 5 | 6 | public class SpigotWarpEffects { 7 | @Inject 8 | private WarpEffectRegistry warpEffectRegistry; 9 | 10 | public void registerEffects() { 11 | warpEffectRegistry.registerEffect("ender", new EnderWarpEffect()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveRepresenter.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata; 2 | 3 | import org.yaml.snakeyaml.DumperOptions; 4 | import org.yaml.snakeyaml.introspector.BeanAccess; 5 | import org.yaml.snakeyaml.representer.Representer; 6 | 7 | public class ReflectiveRepresenter extends Representer { 8 | public ReflectiveRepresenter(DumperOptions options) { 9 | super(options); 10 | this.getPropertyUtils().setBeanAccess(BeanAccess.FIELD); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/warpeffects/SpigotWarpEffects.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.warpeffects; 2 | 3 | import com.sekwah.advancedportals.core.registry.WarpEffectRegistry; 4 | import com.sekwah.advancedportals.shadowed.inject.Inject; 5 | 6 | public class SpigotWarpEffects { 7 | @Inject 8 | private WarpEffectRegistry warpEffectRegistry; 9 | 10 | public void registerEffects() { 11 | warpEffectRegistry.registerEffect("ender", new EnderWarpEffect()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Advanced Portals 2 | 3 | Just generally sick to the coding style and layout style you see in the current project, it will just speed up pull requests. Useful requests will still be accepted if the style is wrong though will take longer as they will need to be changed by me or another key programmer to the project (if there are more at the time of requesting) 4 | 5 | Just make sure to fill out the pull request template properly. If one of the fields doesnt apply just remove it or put None as the only bullet point. 6 | 7 | More info coming soon 8 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/effect/WarpEffect.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.effect; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 4 | 5 | public interface WarpEffect { 6 | enum Action { 7 | ENTER, 8 | EXIT 9 | } 10 | 11 | interface Sound extends WarpEffect { 12 | void onWarpSound(PlayerContainer player, Action action); 13 | } 14 | 15 | interface Visual extends WarpEffect { 16 | void onWarpVisual(PlayerContainer player, Action action); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /env-variables.gradle: -------------------------------------------------------------------------------- 1 | 2 | def branch = System.getenv("GITHUB_REF") 3 | if(branch != null) { 4 | branch = branch.replace('refs/heads/', '') 5 | } 6 | def isRelease = System.getenv("IS_RELEASE") == "true" 7 | 8 | def snapshotName = (branch == null || branch.startsWith("release-please")) ? "SNAPSHOT" : branch 9 | def githubSha = System.getenv("GITHUB_SHA") 10 | def shaRef = githubSha != null ? "-${githubSha.substring(0, 8)}" : "" 11 | 12 | ext.branch = branch 13 | ext.snapshotName = snapshotName 14 | ext.githubSha = githubSha 15 | ext.shaRef = shaRef 16 | ext.isRelease = isRelease 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/registry/CommandException.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.registry; 2 | 3 | public class CommandException { 4 | private final CommandErrorCode errorCode; 5 | private final String message; 6 | 7 | public CommandException(CommandErrorCode errorCode, String message) { 8 | this.errorCode = errorCode; 9 | this.message = message; 10 | } 11 | 12 | public CommandErrorCode getErrorCode() { 13 | return errorCode; 14 | } 15 | 16 | public String getMessage() { 17 | return message; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spigot/src/main/templates/plugin.yml: -------------------------------------------------------------------------------- 1 | main: com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin 2 | name: AdvancedPortals 3 | version: ${pluginVersion} 4 | author: sekwah41 5 | description: An advanced portals plugin for bukkit. 6 | api-version: 1.13 7 | softdepend: [PlaceholderAPI, Vault] 8 | commands: 9 | portal: 10 | description: The main command for the advanced portals 11 | aliases: [portals, aportals, advancedportals] 12 | usage: / 13 | destination: 14 | description: Can be used to access portal destinations. 15 | aliases: [desti] 16 | usage: / 17 | permissions: ${permissions} 18 | -------------------------------------------------------------------------------- /legacyspigot/src/main/templates/plugin.yml: -------------------------------------------------------------------------------- 1 | main: com.sekwah.advancedportals.legacyspigot.AdvancedPortalsPlugin 2 | name: AdvancedPortals 3 | version: ${pluginVersion} 4 | author: sekwah41 5 | description: An advanced portals plugin for bukkit. 6 | api-version: 1.8.8 7 | softdepend: [PlaceholderAPI] 8 | commands: 9 | portal: 10 | description: The main command for the advanced portals 11 | aliases: [portals, aportals, advancedportals] 12 | usage: / 13 | destination: 14 | description: Can be used to access portal destinations. 15 | aliases: [desti] 16 | usage: / 17 | permissions: ${permissions} 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/util/PlayerUtils.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.util; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 4 | import com.sekwah.advancedportals.core.serializeddata.Vector; 5 | 6 | public class PlayerUtils { 7 | public static void throwPlayerBack(PlayerContainer player, 8 | double strength) { 9 | Vector playerLoc = player.getLoc().getDirection(); 10 | player.setVelocity( 11 | playerLoc.setY(0).normalize().multiply(-1).setY(0.5).multiply( 12 | strength)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyServerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.bungee.connector.container; 2 | 3 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer; 4 | import net.md_5.bungee.api.connection.Server; 5 | 6 | public class BungeeProxyServerContainer implements ProxyServerContainer { 7 | private final Server server; 8 | 9 | public BungeeProxyServerContainer(Server server) { 10 | this.server = server; 11 | } 12 | 13 | @Override 14 | public String getServerName() { 15 | return this.server.getInfo().getName(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyJoinData.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.proxycore.connector.container; 2 | 3 | public class ProxyJoinData { 4 | public final String destination; 5 | public final String serverName; 6 | public final long joinTime; 7 | 8 | public ProxyJoinData(String destination, String serverName) { 9 | this.destination = destination; 10 | this.serverName = serverName; 11 | this.joinTime = System.currentTimeMillis(); 12 | } 13 | 14 | public boolean isExpired() { 15 | return System.currentTimeMillis() - this.joinTime 16 | > 1000 * 15; // 15 seconds 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/WorldLocation.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata; 2 | 3 | public class WorldLocation extends Vector { 4 | public final String worldName; 5 | 6 | public WorldLocation(String worldName, double posX, double posY, 7 | double posZ) { 8 | super(posX, posY, posZ); 9 | this.worldName = worldName; 10 | } 11 | 12 | public BlockLocation toBlockPos() { 13 | return new BlockLocation(this.worldName, (int) Math.floor(this.x), 14 | (int) Math.floor(this.y), 15 | (int) Math.floor(this.z)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyServerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.velocity.connector.container; 2 | 3 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer; 4 | import com.velocitypowered.api.proxy.server.RegisteredServer; 5 | 6 | public class VelocityProxyServerContainer implements ProxyServerContainer { 7 | private final RegisteredServer server; 8 | 9 | public VelocityProxyServerContainer(RegisteredServer server) { 10 | this.server = server; 11 | } 12 | 13 | @Override 14 | public String getServerName() { 15 | return this.server.getServerInfo().getName(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/containers/EntityContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.containers; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 4 | import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; 5 | import com.sekwah.advancedportals.core.serializeddata.Vector; 6 | 7 | public interface EntityContainer { 8 | PlayerLocation getLoc(); 9 | 10 | double getHeight(); 11 | 12 | BlockLocation getBlockLoc(); 13 | 14 | boolean teleport(PlayerLocation location); 15 | 16 | WorldContainer getWorld(); 17 | 18 | String getName(); 19 | 20 | String getWorldName(); 21 | 22 | void setVelocity(Vector vector); 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/ProxyMessages.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core; 2 | 3 | /** 4 | * messages going to the proxy will start with proxy: messages going to the 5 | * server will start with server: 6 | */ 7 | public class ProxyMessages { 8 | /** 9 | * Could split by channel messages we will handle it ourselves 10 | */ 11 | public static final String CHANNEL_NAME = "advancedportals:message"; 12 | 13 | public static final String PROXY_TRANSFER_DESTI = "proxy:transfer_desti"; 14 | public static final String PROXY_TRANSFER = "proxy:transfer"; 15 | public static final String PROXY_COMMAND = "proxy:command"; 16 | 17 | public static final String SERVER_DESTI = "server:destination"; 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/registry/CommandHandler.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.registry; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 5 | 6 | public interface CommandHandler { 7 | void onExecute(String commandName, String parentCommand, 8 | CommandSenderContainer sender, ImmutableList args); 9 | 10 | default void onCommandFailure(String[] command, 11 | CommandSenderContainer sender, 12 | CommandException exception, 13 | ImmutableList args) { 14 | sender.sendMessage(exception.getMessage()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/SpigotInfoLogger.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot; 2 | 3 | import com.sekwah.advancedportals.core.util.InfoLogger; 4 | import java.util.logging.Level; 5 | 6 | public class SpigotInfoLogger extends InfoLogger { 7 | private final AdvancedPortalsPlugin plugin; 8 | 9 | public SpigotInfoLogger(AdvancedPortalsPlugin plugin) { 10 | this.plugin = plugin; 11 | } 12 | 13 | @Override 14 | public void warning(String s) { 15 | plugin.getLogger().warning(s); 16 | } 17 | 18 | @Override 19 | public void info(String s) { 20 | plugin.getLogger().info(s); 21 | } 22 | 23 | @Override 24 | public void error(Exception e) { 25 | plugin.getLogger().log(Level.SEVERE, e.getMessage(), e); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/containers/WorldContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.containers; 2 | 3 | import com.sekwah.advancedportals.core.data.BlockAxis; 4 | import com.sekwah.advancedportals.core.portal.AdvancedPortal; 5 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 6 | 7 | public interface WorldContainer { 8 | void setBlock(BlockLocation location, String material); 9 | 10 | String getBlock(BlockLocation location); 11 | 12 | boolean isWaterlogged(BlockLocation location); 13 | 14 | void disableBeacon(BlockLocation location); 15 | 16 | BlockAxis getBlockAxis(BlockLocation location); 17 | 18 | void setBlockAxis(BlockLocation location, BlockAxis axis); 19 | 20 | void disableBeacon(AdvancedPortal portal); 21 | } 22 | -------------------------------------------------------------------------------- /proxycore/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | apply plugin: 'idea' 3 | apply plugin: 'eclipse' 4 | 5 | configurations { 6 | // configuration that holds jars to copy into lib 7 | includeLibs 8 | } 9 | 10 | repositories { 11 | maven { url "https://repo.maven.apache.org/maven2" } 12 | maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } 13 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 14 | } 15 | 16 | dependencies { 17 | implementation project(":core") 18 | runtimeOnly project(path: ':core', configuration: 'shadow') 19 | } 20 | 21 | tasks.named('compileJava') { 22 | dependsOn(':core:shadowJar') 23 | } 24 | 25 | 26 | jar { 27 | from configurations.includeLibs.collect { 28 | it.isDirectory() ? it : zipTree(it) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /bungee/src/main/java/com/sekwah/advancedportals/bungee/BungeeInfoLogger.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.bungee; 2 | 3 | import com.sekwah.advancedportals.core.util.InfoLogger; 4 | import java.util.logging.Level; 5 | 6 | public class BungeeInfoLogger extends InfoLogger { 7 | private final AdvancedPortalsBungeePlugin plugin; 8 | 9 | public BungeeInfoLogger(AdvancedPortalsBungeePlugin plugin) { 10 | this.plugin = plugin; 11 | } 12 | 13 | @Override 14 | public void warning(String s) { 15 | plugin.getLogger().warning(s); 16 | } 17 | 18 | @Override 19 | public void info(String s) { 20 | plugin.getLogger().info(s); 21 | } 22 | 23 | @Override 24 | public void error(Exception e) { 25 | plugin.getLogger().log(Level.SEVERE, e.getMessage(), e); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/LegacySpigotInfoLogger.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot; 2 | 3 | import com.sekwah.advancedportals.core.util.InfoLogger; 4 | import java.util.logging.Level; 5 | 6 | public class LegacySpigotInfoLogger extends InfoLogger { 7 | private final AdvancedPortalsPlugin plugin; 8 | 9 | public LegacySpigotInfoLogger(AdvancedPortalsPlugin plugin) { 10 | this.plugin = plugin; 11 | } 12 | 13 | @Override 14 | public void warning(String s) { 15 | plugin.getLogger().warning(s); 16 | } 17 | 18 | @Override 19 | public void info(String s) { 20 | plugin.getLogger().info(s); 21 | } 22 | 23 | @Override 24 | public void error(Exception e) { 25 | plugin.getLogger().log(Level.SEVERE, e.getMessage(), e); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /velocity/build.gradle: -------------------------------------------------------------------------------- 1 | // Check the root build.gradle under allprojects for common settings 2 | 3 | configurations { 4 | // configuration that holds jars to copy into lib 5 | includeLibs 6 | } 7 | 8 | repositories { 9 | maven { url "https://repo.maven.apache.org/maven2" } 10 | maven { 11 | name 'papermc' 12 | url 'https://repo.papermc.io/repository/maven-public/' 13 | } 14 | } 15 | 16 | // includeLibs just says to include the library in the final jar 17 | dependencies { 18 | implementation project(":proxycore") 19 | implementation project(":core") 20 | 21 | implementation("com.velocitypowered:velocity-api:3.1.0") 22 | annotationProcessor("com.velocitypowered:velocity-api:3.1.0") 23 | } 24 | 25 | jar { 26 | from configurations.includeLibs.collect { 27 | it.isDirectory() ? it : zipTree(it) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/utils/ContainerHelpers.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.utils; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 4 | import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; 5 | import org.bukkit.Location; 6 | 7 | public class ContainerHelpers { 8 | public static PlayerLocation toPlayerLocation(Location loc) { 9 | return new PlayerLocation(loc.getWorld().getName(), loc.getX(), 10 | loc.getY(), loc.getZ(), loc.getYaw(), 11 | loc.getPitch()); 12 | } 13 | 14 | public static BlockLocation toBlockLocation(Location loc) { 15 | return new BlockLocation(loc.getWorld().getName(), loc.getBlockX(), 16 | loc.getBlockY(), loc.getBlockZ()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | repos: 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v4.6.0 5 | hooks: 6 | - id: trailing-whitespace 7 | - id: end-of-file-fixer 8 | - id: fix-byte-order-marker 9 | - id: mixed-line-ending 10 | - id: check-merge-conflict 11 | - id: check-case-conflict 12 | 13 | - repo: https://github.com/Lucas-C/pre-commit-hooks 14 | rev: v1.5.5 15 | hooks: 16 | - id: remove-crlf 17 | - id: remove-tabs 18 | 19 | - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks 20 | rev: v2.13.0 21 | hooks: 22 | - id: pretty-format-yaml 23 | args: [--autofix] 24 | - id: pretty-format-toml 25 | args: [--autofix] 26 | 27 | - repo: https://github.com/pocc/pre-commit-hooks 28 | rev: v1.3.5 29 | hooks: 30 | - id: clang-format 31 | args: [-i, --style=file] 32 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/utils/ContainerHelpers.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.utils; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 4 | import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; 5 | import org.bukkit.Location; 6 | 7 | public class ContainerHelpers { 8 | public static PlayerLocation toPlayerLocation(Location loc) { 9 | return new PlayerLocation(loc.getWorld().getName(), loc.getX(), 10 | loc.getY(), loc.getZ(), loc.getYaw(), 11 | loc.getPitch()); 12 | } 13 | 14 | public static BlockLocation toBlockLocation(Location loc) { 15 | return new BlockLocation(loc.getWorld().getName(), loc.getBlockX(), 16 | loc.getBlockY(), loc.getBlockZ()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/containers/ServerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.containers; 2 | 3 | import com.sekwah.advancedportals.core.tags.CommandTag; 4 | import java.util.List; 5 | import java.util.UUID; 6 | 7 | public interface ServerContainer { 8 | WorldContainer getWorld(String name); 9 | 10 | PlayerContainer getPlayer(String name); 11 | 12 | PlayerContainer getPlayer(UUID name); 13 | 14 | List getAllTriggerBlocks(); 15 | 16 | List getCommonTriggerBlocks(); 17 | 18 | PlayerContainer[] getPlayers(); 19 | 20 | void registerOutgoingChannel(String channel); 21 | 22 | void registerIncomingChannel(String channel); 23 | 24 | void dispatchCommand(UUID uuid, String command, 25 | CommandTag.CommandLevel commandLevel); 26 | 27 | String matchMaterialName(String materialName); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/registry/RegisterBuilder.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.registry; 2 | 3 | import java.lang.reflect.ParameterizedType; 4 | 5 | public class RegisterBuilder { 6 | public static RegisterBuilder newBuilder() { 7 | return new RegisterBuilder(); 8 | } 9 | 10 | private RegisterBuilder() { 11 | } 12 | 13 | private boolean allowPermissionInheritance; 14 | private String scanDirectory; 15 | private final Class genericType = 16 | (Class) ((ParameterizedType) getClass().getGenericSuperclass()) 17 | .getActualTypeArguments()[0]; 18 | 19 | public RegisterBuilder inheritPermissions(boolean allowInheritance) { 20 | allowPermissionInheritance = allowInheritance; 21 | return this; 22 | } 23 | 24 | public RegisterBuilder scanDirectory(String directoryName) { 25 | this.scanDirectory = directoryName; 26 | return this; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/network/ProxyCommandPacket.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.network; 2 | 3 | import com.google.common.io.ByteArrayDataInput; 4 | import com.google.common.io.ByteArrayDataOutput; 5 | import com.google.common.io.ByteStreams; 6 | import com.sekwah.advancedportals.core.ProxyMessages; 7 | 8 | public class ProxyCommandPacket implements Packet { 9 | private final String command; 10 | 11 | public ProxyCommandPacket(String command) { 12 | this.command = command; 13 | } 14 | 15 | public byte[] encode() { 16 | ByteArrayDataOutput buffer = ByteStreams.newDataOutput(); 17 | buffer.writeUTF(ProxyMessages.PROXY_COMMAND); 18 | buffer.writeUTF(this.command); 19 | return buffer.toByteArray(); 20 | } 21 | 22 | public static ProxyCommandPacket decode(ByteArrayDataInput buffer) { 23 | return new ProxyCommandPacket(buffer.readUTF()); 24 | } 25 | 26 | public String getCommand() { 27 | return command; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/CommandTemplate.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 4 | import java.util.List; 5 | 6 | /** 7 | * Already know spigot's auto complete possibilities 8 | * 9 | *

Sponge 10 | * href="https://docs.spongepowered.org/stable/en/plugin/commands/arguments.html#custom-command-elements">... 11 | */ 12 | public interface CommandTemplate { 13 | void onCommand(CommandSenderContainer sender, String commandExecuted, 14 | String[] args); 15 | 16 | /** 17 | * Fired when someone asks for a tab complete action. 18 | * 19 | * @param sender whoever triggered the command e.g. command block, server or 20 | * player 21 | * @param args arguments for the command 22 | * @return a lot of strings that are possible completions 23 | */ 24 | List onTabComplete(CommandSenderContainer sender, String[] args); 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/network/ServerDestiPacket.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.network; 2 | 3 | import com.google.common.io.ByteArrayDataInput; 4 | import com.google.common.io.ByteArrayDataOutput; 5 | import com.google.common.io.ByteStreams; 6 | import com.sekwah.advancedportals.core.ProxyMessages; 7 | 8 | public class ServerDestiPacket implements Packet { 9 | private final String destination; 10 | 11 | public ServerDestiPacket(String destination) { 12 | this.destination = destination; 13 | } 14 | 15 | public byte[] encode() { 16 | ByteArrayDataOutput buffer = ByteStreams.newDataOutput(); 17 | buffer.writeUTF(ProxyMessages.SERVER_DESTI); 18 | buffer.writeUTF(this.destination); 19 | return buffer.toByteArray(); 20 | } 21 | 22 | public static ServerDestiPacket decode(ByteArrayDataInput buffer) { 23 | return new ServerDestiPacket(buffer.readUTF()); 24 | } 25 | 26 | public String getDestination() { 27 | return destination; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /bungee/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsBungeePlugin.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.bungee; 2 | 3 | import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyContainer; 4 | import com.sekwah.advancedportals.core.ProxyMessages; 5 | import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore; 6 | import net.md_5.bungee.api.plugin.Plugin; 7 | 8 | public class AdvancedPortalsBungeePlugin extends Plugin { 9 | private AdvancedPortalsProxyCore proxyCore; 10 | 11 | @Override 12 | public void onEnable() { 13 | this.proxyCore = new AdvancedPortalsProxyCore( 14 | new BungeeInfoLogger(this), new BungeeProxyContainer(this)); 15 | this.proxyCore.onEnable(); 16 | 17 | getProxy().registerChannel(ProxyMessages.CHANNEL_NAME); 18 | 19 | getProxy().getPluginManager().registerListener( 20 | this, new EventListener(this, this.proxyCore)); 21 | } 22 | 23 | @Override 24 | public void onDisable() { 25 | this.proxyCore.onDisable(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferPacket.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.network; 2 | 3 | import com.google.common.io.ByteArrayDataInput; 4 | import com.google.common.io.ByteArrayDataOutput; 5 | import com.google.common.io.ByteStreams; 6 | import com.sekwah.advancedportals.core.ProxyMessages; 7 | 8 | public class ProxyTransferPacket implements Packet { 9 | private final String serverName; 10 | 11 | public ProxyTransferPacket(String serverName) { 12 | this.serverName = serverName; 13 | } 14 | 15 | public byte[] encode() { 16 | ByteArrayDataOutput buffer = ByteStreams.newDataOutput(); 17 | buffer.writeUTF(ProxyMessages.PROXY_TRANSFER); 18 | buffer.writeUTF(this.serverName); 19 | return buffer.toByteArray(); 20 | } 21 | 22 | public static ProxyTransferPacket decode(ByteArrayDataInput buffer) { 23 | return new ProxyTransferPacket(buffer.readUTF()); 24 | } 25 | 26 | public String getServerName() { 27 | return serverName; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/registry/TagTarget.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.registry; 2 | 3 | import com.sekwah.advancedportals.core.warphandler.Tag; 4 | 5 | /** 6 | * Something that a tag can be executed on. 7 | */ 8 | public interface TagTarget { 9 | /** 10 | * Get the values for the arg 11 | * 12 | * @param argName 13 | * @return 14 | */ 15 | String[] getArgValues(String argName); 16 | 17 | /** 18 | * Set the values for the arg 19 | * 20 | * @param argName 21 | * @param argValues 22 | */ 23 | void setArgValues(String argName, String[] argValues); 24 | 25 | /** 26 | * Add a new arg to the tag 27 | * 28 | * @param argName 29 | * @param argValues 30 | */ 31 | void addArg(String argName, String argValues); 32 | 33 | /** 34 | * Remove the arg entirely from the target 35 | * 36 | * @param arg 37 | */ 38 | void removeArg(String arg); 39 | 40 | String getName(); 41 | 42 | Tag.TagType targetTagType(); 43 | } 44 | -------------------------------------------------------------------------------- /bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyPlayerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.bungee.connector.container; 2 | 3 | import com.sekwah.advancedportals.core.ProxyMessages; 4 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; 5 | import net.md_5.bungee.api.connection.ProxiedPlayer; 6 | 7 | public class BungeeProxyPlayerContainer implements ProxyPlayerContainer { 8 | private final ProxiedPlayer player; 9 | 10 | public BungeeProxyPlayerContainer(ProxiedPlayer player) { 11 | this.player = player; 12 | } 13 | 14 | public ProxiedPlayer getPlayer() { 15 | return this.player; 16 | } 17 | 18 | @Override 19 | public String getUUID() { 20 | return this.player.getUniqueId().toString(); 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return this.player.getName(); 26 | } 27 | 28 | public void sendServerPluginMessage(byte[] data) { 29 | this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/command/SpigotCommandRegister.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.connector.command; 2 | 3 | import com.sekwah.advancedportals.core.commands.CommandTemplate; 4 | import com.sekwah.advancedportals.core.connector.commands.CommandRegister; 5 | import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; 6 | 7 | /** 8 | * Register the CommandTemplate files to the appropriate system 9 | */ 10 | public class SpigotCommandRegister implements CommandRegister { 11 | private final AdvancedPortalsPlugin plugin; 12 | 13 | public SpigotCommandRegister(AdvancedPortalsPlugin plugin) { 14 | this.plugin = plugin; 15 | } 16 | 17 | /** 18 | * Registers the command to the appropriate system 19 | * 20 | * @param commandName 21 | * @param commandExecutor 22 | */ 23 | public void registerCommand(String commandName, 24 | CommandTemplate commandExecutor) { 25 | this.plugin.getCommand(commandName) 26 | .setExecutor(new SpigotCommandHandler(commandExecutor)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.github/workflows/snapshots.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches-ignore: 4 | - main 5 | workflow_dispatch: 6 | name: Build 7 | jobs: 8 | snapshot: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | include: 13 | - project: spigot 14 | java-version: 8 15 | - project: legacyspigot 16 | java-version: 8 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Cache Gradle packages 20 | uses: actions/cache@v3 21 | with: 22 | path: ~/.gradle/caches 23 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} 24 | restore-keys: ${{ runner.os }}-gradle 25 | - name: Set up JDK ${{ matrix.java-version }} 26 | uses: actions/setup-java@v3 27 | with: 28 | distribution: temurin 29 | java-version: ${{ matrix.java-version }} 30 | - name: Build and upload preview (run for non-release builds) 31 | if: ${{ github.ref && !contains( github.ref, 'renovate/deps') }} 32 | env: 33 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 34 | run: | 35 | # Build 36 | ./gradlew ${{ matrix.project }}:discordupload 37 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/connector/command/LegacySpigotCommandRegister.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.connector.command; 2 | 3 | import com.sekwah.advancedportals.core.commands.CommandTemplate; 4 | import com.sekwah.advancedportals.core.connector.commands.CommandRegister; 5 | import com.sekwah.advancedportals.legacyspigot.AdvancedPortalsPlugin; 6 | 7 | /** 8 | * Register the CommandTemplate files to the appropriate system 9 | */ 10 | public class LegacySpigotCommandRegister implements CommandRegister { 11 | private final AdvancedPortalsPlugin plugin; 12 | 13 | public LegacySpigotCommandRegister(AdvancedPortalsPlugin plugin) { 14 | this.plugin = plugin; 15 | } 16 | 17 | /** 18 | * Registers the command to the appropriate system 19 | * 20 | * @param commandName 21 | * @param commandExecutor 22 | */ 23 | public void registerCommand(String commandName, 24 | CommandTemplate commandExecutor) { 25 | this.plugin.getCommand(commandName) 26 | .setExecutor(new LegacySpigotCommandHandler(commandExecutor)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /release-please-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "prerelease": true, 3 | "packages": { 4 | ".": { 5 | "release-type": "simple" 6 | } 7 | }, 8 | "changelog-sections": [ 9 | { "type": "feat", "section": "Features ✨" }, 10 | { "type": "feature", "section": "Features ✨" }, 11 | { "type": "fix", "section": "Bug Fixes \uD83D\uDC1B" }, 12 | { "type": "perf", "section": "Performance Improvements ⚡️" }, 13 | { "type": "tweak", "section": "Changes to Existing Features \uD83D\uDD27" }, 14 | { "type": "lang", "section": "Language updates \uD83C\uDF10", "hidden": true }, 15 | { "type": "revert", "section": "Reverts ⏪️" }, 16 | { "type": "docs", "section": "Documentation", "hidden": true }, 17 | { "type": "style", "section": "Styles", "hidden": true }, 18 | { "type": "chore", "section": "Miscellaneous Chores", "hidden": true }, 19 | { "type": "refactor", "section": "Code Refactoring", "hidden": true }, 20 | { "type": "test", "section": "Tests", "hidden": true }, 21 | { "type": "build", "section": "Build System", "hidden": true }, 22 | { "type": "ci", "section": "Continuous Integration", "hidden": true } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/SubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 4 | import java.util.List; 5 | 6 | public interface SubCommand { 7 | /** 8 | * @param sender 9 | * @param args arguments including the subcommand that has been specified. 10 | * @return if the command has worked (if false it will just display a 11 | * message from the command suggesting to check help) 12 | */ 13 | void onCommand(CommandSenderContainer sender, String[] args); 14 | 15 | boolean hasPermission(CommandSenderContainer sender); 16 | 17 | /** 18 | * @param sender 19 | * @param args arguments including the subcommand that has been specified. 20 | * @return tab completion for the subcommand 21 | */ 22 | List onTabComplete(CommandSenderContainer sender, String[] args); 23 | 24 | /** 25 | * @return the string to show next to the tag on the help menu. 26 | */ 27 | String getBasicHelpText(); 28 | 29 | /** 30 | * @return the string to show if help then the tag is listed. 31 | */ 32 | String getDetailedHelpText(); 33 | 34 | interface SubCommandOnInit { 35 | void registered(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferDestiPacket.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.network; 2 | 3 | import com.google.common.io.ByteArrayDataInput; 4 | import com.google.common.io.ByteArrayDataOutput; 5 | import com.google.common.io.ByteStreams; 6 | import com.sekwah.advancedportals.core.ProxyMessages; 7 | 8 | public class ProxyTransferDestiPacket implements Packet { 9 | private final String serverName; 10 | private final String destination; 11 | 12 | public ProxyTransferDestiPacket(String serverName, String destination) { 13 | this.serverName = serverName; 14 | this.destination = destination; 15 | } 16 | 17 | public byte[] encode() { 18 | ByteArrayDataOutput buffer = ByteStreams.newDataOutput(); 19 | buffer.writeUTF(ProxyMessages.PROXY_TRANSFER_DESTI); 20 | buffer.writeUTF(this.serverName); 21 | buffer.writeUTF(this.destination); 22 | return buffer.toByteArray(); 23 | } 24 | 25 | public static ProxyTransferDestiPacket decode(ByteArrayDataInput buffer) { 26 | return new ProxyTransferDestiPacket(buffer.readUTF(), buffer.readUTF()); 27 | } 28 | 29 | public String getServerName() { 30 | return serverName; 31 | } 32 | 33 | public String getDestination() { 34 | return destination; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /velocity/src/main/java/com/sekwah/advancedportals/velocity/VelocityInfoLogger.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.velocity; 2 | import com.sekwah.advancedportals.core.util.InfoLogger; 3 | import com.sekwah.advancedportals.velocity.connector.MinecraftToAnsi; 4 | import com.velocitypowered.api.proxy.ProxyServer; 5 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 6 | import org.slf4j.Logger; 7 | 8 | public class VelocityInfoLogger extends InfoLogger { 9 | private final Logger logger; 10 | private final ProxyServer proxy; 11 | private final LegacyComponentSerializer serializer = 12 | LegacyComponentSerializer.builder() 13 | .character('&') 14 | .hexCharacter('#') 15 | .hexColors() 16 | .build(); 17 | 18 | public VelocityInfoLogger(Logger logger, ProxyServer proxy) { 19 | this.logger = logger; 20 | this.proxy = proxy; 21 | } 22 | 23 | @Override 24 | public void warning(String s) { 25 | logger.warn(MinecraftToAnsi.convert(s)); 26 | } 27 | 28 | @Override 29 | public void info(String s) { 30 | logger.info(MinecraftToAnsi.convert(s)); 31 | } 32 | 33 | @Override 34 | public void error(Exception e) { 35 | logger.error(MinecraftToAnsi.convert("\u00A7c" + e.getMessage()), e); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyPlayerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.velocity.connector.container; 2 | 3 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; 4 | import com.velocitypowered.api.proxy.Player; 5 | import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; 6 | 7 | public class VelocityProxyPlayerContainer implements ProxyPlayerContainer { 8 | private final Player player; 9 | private final LegacyChannelIdentifier channel; 10 | 11 | public VelocityProxyPlayerContainer(Player player, 12 | LegacyChannelIdentifier channel) { 13 | this.player = player; 14 | this.channel = channel; 15 | } 16 | 17 | @Override 18 | public String getUUID() { 19 | return player.getUniqueId().toString(); 20 | } 21 | 22 | @Override 23 | public String getName() { 24 | return player.getUsername(); 25 | } 26 | 27 | @Override 28 | public void sendServerPluginMessage(byte[] data) { 29 | player.getCurrentServer().ifPresent( 30 | serverConnection 31 | -> serverConnection.sendPluginMessage(channel, data)); 32 | } 33 | 34 | public Player getPlayer() { 35 | return this.player; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.sekwah.advancedportals.core.BuildConstants; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.util.Lang; 7 | import java.util.List; 8 | 9 | public class VersionSubCommand implements SubCommand { 10 | @Override 11 | public void onCommand(CommandSenderContainer sender, String[] args) { 12 | sender.sendMessage(Lang.getPositivePrefix() + " Advanced Portals v" 13 | + BuildConstants.VERSION); 14 | } 15 | 16 | @Override 17 | public boolean hasPermission(CommandSenderContainer sender) { 18 | return true; 19 | } 20 | 21 | @Override 22 | public List onTabComplete(CommandSenderContainer sender, 23 | String[] args) { 24 | return null; 25 | } 26 | 27 | @Override 28 | public String getBasicHelpText() { 29 | return Lang.translate("command.version.help"); 30 | } 31 | 32 | @Override 33 | public String getDetailedHelpText() { 34 | return Lang.translate("command.version.help"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bungee/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | apply plugin: 'maven-publish' 3 | apply plugin: 'idea' 4 | apply plugin: 'eclipse' 5 | apply plugin: 'java' 6 | 7 | configurations { 8 | // configuration that holds jars to copy into lib 9 | includeLibs 10 | } 11 | 12 | repositories { 13 | mavenCentral() 14 | maven { url "https://repo.maven.apache.org/maven2" } 15 | maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } 16 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 17 | maven { url "https://libraries.minecraft.net" } 18 | } 19 | 20 | // includeLibs just says to include the library in the final jar 21 | dependencies { 22 | 23 | // For bungee api 24 | compileOnly("net.md-5:bungeecord-api:1.21-R0.3") { 25 | exclude group: "net.md-5", module: "brigadier" 26 | } 27 | 28 | implementation project(":proxycore") 29 | implementation project(":core") 30 | } 31 | 32 | jar { 33 | from configurations.includeLibs.collect { it.isDirectory() ? it : zipTree(it) } 34 | } 35 | 36 | 37 | // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task 38 | // if it is present. 39 | // If you remove this task, sources will not be generated. 40 | tasks.register('sourcesJar', Jar) { 41 | dependsOn classes 42 | getArchiveClassifier().set('sources') 43 | from sourceSets.main.allSource 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/Config.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata.config; 2 | 3 | /** 4 | * To store the data for config 5 | */ 6 | public class Config { 7 | public boolean useOnlySpecialAxe = true; 8 | 9 | public String selectorMaterial = "IRON_AXE"; 10 | 11 | public boolean portalProtection = true; 12 | 13 | public int portalProtectionRadius = 5; 14 | 15 | public String defaultTriggerBlock = "NETHER_PORTAL"; 16 | 17 | public boolean stopWaterFlow = true; 18 | 19 | public int joinCooldown = 5; 20 | 21 | public final String translationFile = "en_GB"; 22 | 23 | public final int showVisibleRange = 50; 24 | 25 | public final boolean disablePhysicsEvents = true; 26 | 27 | public boolean blockSpectatorMode = true; 28 | 29 | public final int maxPortalVisualisationSize = 1000; 30 | 31 | public final int maxSelectionVisualisationSize = 9000; 32 | 33 | public double throwbackStrength = 0.7; 34 | 35 | public boolean playFailSound = true; 36 | 37 | public boolean warpMessageOnActionBar = true; 38 | 39 | public boolean warpMessageInChat = false; 40 | 41 | public CommandPortalConfig commandPortals = new CommandPortalConfig(); 42 | 43 | public boolean enableProxySupport = false; 44 | 45 | public WarpEffectConfig warpEffect = new WarpEffectConfig(); 46 | 47 | public boolean disableGatewayBeam = true; 48 | } 49 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotCommandSenderContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.connector.container; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 4 | import com.sekwah.advancedportals.core.connector.containers.ServerContainer; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | public class SpigotCommandSenderContainer implements CommandSenderContainer { 9 | private final CommandSender sender; 10 | 11 | public SpigotCommandSenderContainer(CommandSender commandSender) { 12 | this.sender = commandSender; 13 | } 14 | 15 | public void sendMessage(String message) { 16 | sender.sendMessage(message); 17 | } 18 | 19 | @Override 20 | public ServerContainer getServer() { 21 | return new SpigotServerContainer(sender.getServer()); 22 | } 23 | 24 | public boolean isOp() { 25 | return sender.isOp(); 26 | } 27 | 28 | /** 29 | * @return null if there isnt a player e.g. the console 30 | */ 31 | public SpigotPlayerContainer getPlayerContainer() { 32 | if (sender instanceof Player) { 33 | return new SpigotPlayerContainer((Player) sender); 34 | } 35 | return null; 36 | } 37 | 38 | public boolean hasPermission(String permission) { 39 | return sender.hasPermission(permission); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PlayerDataRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository.impl; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.repository.IPlayerDataRepository; 5 | import com.sekwah.advancedportals.core.serializeddata.DataStorage; 6 | import com.sekwah.advancedportals.core.serializeddata.PlayerData; 7 | import java.util.List; 8 | 9 | public class PlayerDataRepositoryImpl implements IPlayerDataRepository { 10 | private final String fileLocation = "playerData/"; 11 | 12 | @Inject 13 | DataStorage dataStorage; 14 | 15 | @Override 16 | public boolean save(String name, PlayerData playerData) { 17 | return dataStorage.storeFile(playerData, fileLocation + name + ".yaml"); 18 | } 19 | 20 | @Override 21 | public boolean containsKey(String name) { 22 | return false; 23 | } 24 | 25 | @Override 26 | public boolean delete(String name) { 27 | return dataStorage.deleteFile(fileLocation + name + ".yaml"); 28 | } 29 | 30 | @Override 31 | public PlayerData get(String name) { 32 | return dataStorage.loadFile(PlayerData.class, 33 | fileLocation + name + ".yaml"); 34 | } 35 | 36 | @Override 37 | public List getAllNames() { 38 | return null; 39 | } 40 | 41 | @Override 42 | public List getAll() { 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/command/SpigotCommandHandler.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.connector.command; 2 | 3 | import com.sekwah.advancedportals.core.commands.CommandTemplate; 4 | import com.sekwah.advancedportals.spigot.connector.container.SpigotCommandSenderContainer; 5 | import java.util.List; 6 | import org.bukkit.command.Command; 7 | import org.bukkit.command.CommandExecutor; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.command.TabCompleter; 10 | 11 | public class SpigotCommandHandler implements CommandExecutor, TabCompleter { 12 | private final CommandTemplate commandExecutor; 13 | 14 | public SpigotCommandHandler(CommandTemplate commandExecutor) { 15 | this.commandExecutor = commandExecutor; 16 | } 17 | 18 | @Override 19 | public boolean onCommand(CommandSender commandSender, Command command, 20 | String s, String[] args) { 21 | this.commandExecutor.onCommand( 22 | new SpigotCommandSenderContainer(commandSender), command.getName(), 23 | args); 24 | return true; 25 | } 26 | 27 | @Override 28 | public List onTabComplete(CommandSender commandSender, 29 | Command command, String s, 30 | String[] args) { 31 | return this.commandExecutor.onTabComplete( 32 | new SpigotCommandSenderContainer(commandSender), args); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/connector/container/LegacySpigotCommandSenderContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.connector.container; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 4 | import com.sekwah.advancedportals.core.connector.containers.ServerContainer; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | public class LegacySpigotCommandSenderContainer 9 | implements CommandSenderContainer { 10 | private final CommandSender sender; 11 | 12 | public LegacySpigotCommandSenderContainer(CommandSender commandSender) { 13 | this.sender = commandSender; 14 | } 15 | 16 | public void sendMessage(String message) { 17 | sender.sendMessage(message); 18 | } 19 | 20 | @Override 21 | public ServerContainer getServer() { 22 | return new LegacySpigotServerContainer(sender.getServer()); 23 | } 24 | 25 | public boolean isOp() { 26 | return sender.isOp(); 27 | } 28 | 29 | /** 30 | * @return null if there isnt a player e.g. the console 31 | */ 32 | public LegacySpigotPlayerContainer getPlayerContainer() { 33 | if (sender instanceof Player) { 34 | return new LegacySpigotPlayerContainer((Player) sender); 35 | } 36 | return null; 37 | } 38 | 39 | public boolean hasPermission(String permission) { 40 | return sender.hasPermission(permission); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/connector/command/LegacySpigotCommandHandler.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.connector.command; 2 | 3 | import com.sekwah.advancedportals.core.commands.CommandTemplate; 4 | import com.sekwah.advancedportals.legacyspigot.connector.container.LegacySpigotCommandSenderContainer; 5 | import java.util.List; 6 | import org.bukkit.command.Command; 7 | import org.bukkit.command.CommandExecutor; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.command.TabCompleter; 10 | 11 | public class LegacySpigotCommandHandler 12 | implements CommandExecutor, TabCompleter { 13 | private final CommandTemplate commandExecutor; 14 | 15 | public LegacySpigotCommandHandler(CommandTemplate commandExecutor) { 16 | this.commandExecutor = commandExecutor; 17 | } 18 | 19 | @Override 20 | public boolean onCommand(CommandSender commandSender, Command command, 21 | String s, String[] args) { 22 | this.commandExecutor.onCommand( 23 | new LegacySpigotCommandSenderContainer(commandSender), 24 | command.getName(), args); 25 | return true; 26 | } 27 | 28 | @Override 29 | public List onTabComplete(CommandSender commandSender, 30 | Command command, String s, 31 | String[] args) { 32 | return this.commandExecutor.onTabComplete( 33 | new LegacySpigotCommandSenderContainer(commandSender), args); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.DataStorage; 4 | import com.sekwah.advancedportals.core.serializeddata.config.CommandPortalConfig; 5 | import com.sekwah.advancedportals.core.serializeddata.config.Config; 6 | 7 | public interface ConfigRepository { 8 | boolean getUseOnlySpecialAxe(); 9 | 10 | String getTranslation(); 11 | 12 | String getSelectorMaterial(); 13 | 14 | void loadConfig(DataStorage dataStorage); 15 | 16 | int getShowVisibleRange(); 17 | 18 | int maxPortalVisualisationSize(); 19 | int maxSelectionVisualisationSize(); 20 | 21 | String getDefaultTriggerBlock(); 22 | 23 | boolean isProtectionActive(); 24 | 25 | int getProtectionRadius(); 26 | 27 | boolean blockSpectatorMode(); 28 | 29 | boolean getStopWaterFlow(); 30 | 31 | boolean getPortalProtection(); 32 | 33 | long getPortalCooldown(); 34 | 35 | double getThrowbackStrength(); 36 | 37 | boolean playFailSound(); 38 | 39 | void storeConfig(); 40 | 41 | boolean getDisablePhysicsEvents(); 42 | 43 | CommandPortalConfig getCommandPortals(); 44 | 45 | String getWarpSound(); 46 | 47 | boolean warpMessageOnActionBar(); 48 | 49 | boolean warpMessageInChat(); 50 | 51 | String getWarpVisual(); 52 | 53 | boolean getWarpEffectEnabled(); 54 | 55 | boolean getEnableProxySupport(); 56 | 57 | boolean getDisableGatewayBeam(); 58 | 59 | void importConfig(Config config); 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ListPortalsSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.services.PortalServices; 8 | import com.sekwah.advancedportals.core.util.Lang; 9 | import java.util.List; 10 | import java.util.stream.Collectors; 11 | 12 | public class ListPortalsSubCommand implements SubCommand { 13 | @Inject 14 | PortalServices portalServices; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | sender.sendMessage( 19 | Lang.getPositivePrefix() + Lang.translate("command.portal.list") 20 | + " " 21 | + portalServices.getPortalNames().stream().sorted().collect( 22 | Collectors.joining(", "))); 23 | } 24 | 25 | @Override 26 | public boolean hasPermission(CommandSenderContainer sender) { 27 | return Permissions.LIST_PORTAL.hasPermission(sender); 28 | } 29 | 30 | @Override 31 | public List onTabComplete(CommandSenderContainer sender, 32 | String[] args) { 33 | return null; 34 | } 35 | 36 | @Override 37 | public String getBasicHelpText() { 38 | return Lang.translate("command.portal.list.help"); 39 | } 40 | 41 | @Override 42 | public String getDetailedHelpText() { 43 | return Lang.translate("command.portal.list.help"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/Vector.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata; 2 | 3 | public class Vector { 4 | protected final double x; 5 | 6 | protected final double y; 7 | 8 | protected final double z; 9 | 10 | public Vector(double X, double Y, double Z) { 11 | this.x = X; 12 | this.y = Y; 13 | this.z = Z; 14 | } 15 | 16 | public Vector add(Vector vec) { 17 | return new Vector(this.x + vec.x, this.y + vec.y, this.z + vec.z); 18 | } 19 | 20 | public Vector multiply(double value) { 21 | return new Vector(this.x * value, this.y * value, this.z * value); 22 | } 23 | 24 | public Vector setY(double y) { 25 | return new Vector(this.x, y, this.z); 26 | } 27 | 28 | public double distanceTo(Vector pos) { 29 | return Math.sqrt(this.distanceToSq(pos)); 30 | } 31 | 32 | private double distanceToSq(Vector pos) { 33 | double dx = this.x - pos.x; 34 | double dy = this.y - pos.y; 35 | double dz = this.z - pos.z; 36 | return dx * dx + dy * dy + dz * dz; 37 | } 38 | 39 | public double getX() { 40 | return this.x; 41 | } 42 | 43 | public double getY() { 44 | return this.y; 45 | } 46 | 47 | public double getZ() { 48 | return this.z; 49 | } 50 | 51 | public Vector normalize() { 52 | return this.multiply(1.0D / this.length()); 53 | } 54 | 55 | public double length() { 56 | return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); 57 | } 58 | 59 | public Vector subtract(Vector vec) { 60 | return new Vector(this.x - vec.x, this.y - vec.y, this.z - vec.z); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ListDestiSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.desti; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.services.DestinationServices; 8 | import com.sekwah.advancedportals.core.util.Lang; 9 | import java.util.List; 10 | import java.util.stream.Collectors; 11 | 12 | public class ListDestiSubCommand implements SubCommand { 13 | @Inject 14 | DestinationServices portalServices; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | sender.sendMessage( 19 | Lang.getPositivePrefix() 20 | + Lang.translate("command.destination.list") + " " 21 | + portalServices.getDestinationNames().stream().sorted().collect( 22 | Collectors.joining(", "))); 23 | } 24 | 25 | @Override 26 | public boolean hasPermission(CommandSenderContainer sender) { 27 | return Permissions.LIST_DESTI.hasPermission(sender); 28 | } 29 | 30 | @Override 31 | public List onTabComplete(CommandSenderContainer sender, 32 | String[] args) { 33 | return null; 34 | } 35 | 36 | @Override 37 | public String getBasicHelpText() { 38 | return Lang.translate("command.destination.list.help"); 39 | } 40 | 41 | @Override 42 | public String getDetailedHelpText() { 43 | return Lang.translate("command.destination.list.help"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/PlayerLocation.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata; 2 | 3 | public class PlayerLocation extends WorldLocation { 4 | private final float yaw; 5 | 6 | private final float pitch; 7 | 8 | public PlayerLocation() { 9 | super("", 0, 0, 0); 10 | this.yaw = 0; 11 | this.pitch = 0; 12 | } 13 | 14 | public PlayerLocation(String worldName, double posX, double posY, 15 | double posZ) { 16 | super(worldName, posX, posY, posZ); 17 | this.yaw = 0; 18 | this.pitch = 0; 19 | } 20 | 21 | public PlayerLocation(String worldName, double posX, double posY, 22 | double posZ, float yaw, float pitch) { 23 | super(worldName, posX, posY, posZ); 24 | this.yaw = yaw; 25 | this.pitch = pitch; 26 | } 27 | 28 | public double getPosX() { 29 | return x; 30 | } 31 | 32 | public double getPosY() { 33 | return y; 34 | } 35 | 36 | public double getPosZ() { 37 | return z; 38 | } 39 | 40 | public String getWorldName() { 41 | return worldName; 42 | } 43 | 44 | public float getYaw() { 45 | return yaw; 46 | } 47 | 48 | public float getPitch() { 49 | return pitch; 50 | } 51 | 52 | public Vector getDirection() { 53 | double rotX = this.getYaw(); 54 | double rotY = this.getPitch(); 55 | 56 | double y = -Math.sin(Math.toRadians(rotY)); 57 | double xz = Math.cos(Math.toRadians(rotY)); 58 | double x = (-xz * Math.sin(Math.toRadians(rotX))); 59 | double z = Math.cos(Math.toRadians(rotX)); 60 | 61 | return new Vector(x, y, z); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/connector/containers/PlayerContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.connector.containers; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.Vector; 4 | import java.awt.*; 5 | import java.util.UUID; 6 | 7 | /** 8 | * Just a temporary container for whenever advanced portals needs to get data 9 | * from a player 10 | */ 11 | public interface PlayerContainer extends EntityContainer, HasPermission { 12 | UUID getUUID(); 13 | 14 | void sendMessage(String message); 15 | 16 | void sendActionBar(String message); 17 | 18 | void giveItem(String material, String itemName, String... itemDescription); 19 | 20 | /** 21 | * Send packets down any channel except the minecraft: one. 22 | * @param channel 23 | * @param bytes 24 | * @return 25 | */ 26 | boolean sendPacket(String channel, byte[] bytes); 27 | 28 | void playSound(String sound, float volume, float pitch); 29 | 30 | ServerContainer getServer(); 31 | 32 | GameMode getGameMode(); 33 | 34 | default void drawLine(Vector start, Vector end, Color color, 35 | float particleDensity) { 36 | Vector direction = end.subtract(start); 37 | double length = direction.length(); 38 | if (length == 0) { 39 | return; 40 | } 41 | direction = direction.normalize(); 42 | for (double i = 0; i <= length; i += particleDensity) { 43 | Vector pos = start.add(direction.multiply(i)); 44 | this.spawnColoredDust(pos, 1, color); 45 | } 46 | } 47 | 48 | default void spawnColoredDust(Vector pos, int count, Color color) { 49 | spawnColoredDust(pos, 0, 0, 0, count, color); 50 | } 51 | 52 | void spawnColoredDust(Vector pos, double xSpread, double ySpread, 53 | double zSpread, int count, Color color); 54 | } 55 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/EnderWarpEffect.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.warpeffects; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 4 | import com.sekwah.advancedportals.core.effect.WarpEffect; 5 | import com.sekwah.advancedportals.spigot.connector.container.SpigotPlayerContainer; 6 | import org.bukkit.*; 7 | import org.bukkit.entity.Player; 8 | 9 | public class EnderWarpEffect implements WarpEffect.Visual, WarpEffect.Sound { 10 | @Override 11 | public void onWarpSound(PlayerContainer playerContainer, 12 | WarpEffect.Action action) { 13 | if (playerContainer instanceof SpigotPlayerContainer) { 14 | SpigotPlayerContainer spigotPlayerContainer = 15 | (SpigotPlayerContainer) playerContainer; 16 | org.bukkit.entity.Player player = spigotPlayerContainer.getPlayer(); 17 | 18 | player.getWorld().playSound(player.getLocation(), 19 | "entity.enderman.teleport", 1, 1); 20 | } 21 | } 22 | 23 | @Override 24 | public void onWarpVisual(PlayerContainer playerContainer, 25 | WarpEffect.Action action) { 26 | if (playerContainer instanceof SpigotPlayerContainer) { 27 | SpigotPlayerContainer spigotPlayerContainer = 28 | (SpigotPlayerContainer) playerContainer; 29 | Player player = spigotPlayerContainer.getPlayer(); 30 | World world = player.getWorld(); 31 | Location loc = player.getLocation().clone(); 32 | for (int i = 0; i < 10; i++) { 33 | world.playEffect(loc, Effect.ENDER_SIGNAL, 0); 34 | } 35 | loc.add(0D, 1D, 0D); 36 | for (int i = 0; i < 10; i++) { 37 | world.playEffect(loc, Effect.ENDER_SIGNAL, 0); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/connector/container/LegacySpigotWorldContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.connector.container; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.WorldContainer; 4 | import com.sekwah.advancedportals.core.data.BlockAxis; 5 | import com.sekwah.advancedportals.core.portal.AdvancedPortal; 6 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 7 | import org.bukkit.Material; 8 | import org.bukkit.World; 9 | 10 | public class LegacySpigotWorldContainer implements WorldContainer { 11 | private final World world; 12 | 13 | public LegacySpigotWorldContainer(World world) { 14 | this.world = world; 15 | } 16 | 17 | public void setBlock(BlockLocation location, String material) { 18 | Material mat = Material.getMaterial(material); 19 | if (mat != null) 20 | this.world 21 | .getBlockAt(location.getPosX(), location.getPosY(), 22 | location.getPosZ()) 23 | .setType(mat); 24 | } 25 | 26 | public String getBlock(BlockLocation location) { 27 | return this.world 28 | .getBlockAt(location.getPosX(), location.getPosY(), 29 | location.getPosZ()) 30 | .getType() 31 | .toString(); 32 | } 33 | 34 | @Override 35 | public void disableBeacon(BlockLocation location) { 36 | } 37 | 38 | @Override 39 | public BlockAxis getBlockAxis(BlockLocation location) { 40 | return null; 41 | } 42 | 43 | @Override 44 | public void setBlockAxis(BlockLocation location, BlockAxis axis) { 45 | } 46 | 47 | @Override 48 | public void disableBeacon(AdvancedPortal portal) { 49 | } 50 | 51 | @Override 52 | public boolean isWaterlogged(BlockLocation location) { 53 | // Waterlogged blocks were introduced in 1.13. 54 | return false; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.velocity.connector.container; 2 | 3 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer; 4 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; 5 | import com.velocitypowered.api.proxy.ProxyServer; 6 | import net.kyori.adventure.text.Component; 7 | 8 | public class VelocityProxyContainer implements ProxyContainer { 9 | private final ProxyServer proxy; 10 | 11 | public VelocityProxyContainer(ProxyServer proxy) { 12 | this.proxy = proxy; 13 | } 14 | 15 | @Override 16 | public void invokeCommand(ProxyPlayerContainer proxyPlayer, 17 | String command) { 18 | if (proxyPlayer instanceof VelocityProxyPlayerContainer) { 19 | VelocityProxyPlayerContainer playerContainer = 20 | (VelocityProxyPlayerContainer) proxyPlayer; 21 | this.proxy.getCommandManager().executeAsync( 22 | playerContainer.getPlayer(), command); 23 | } 24 | } 25 | 26 | @Override 27 | public void transferPlayer(ProxyPlayerContainer proxyPlayer, 28 | String serverName) { 29 | if (proxyPlayer instanceof VelocityProxyPlayerContainer) { 30 | VelocityProxyPlayerContainer playerContainer = 31 | (VelocityProxyPlayerContainer) proxyPlayer; 32 | this.proxy.getServer(serverName); 33 | if (this.proxy.getServer(serverName).isPresent()) { 34 | playerContainer.getPlayer() 35 | .createConnectionRequest( 36 | this.proxy.getServer(serverName).get()) 37 | .fireAndForget(); 38 | } else { 39 | playerContainer.getPlayer().sendMessage( 40 | Component.text("Could not find server: " + serverName)); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/PermissionsGeneratorSpigot.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot; 2 | 3 | import com.sekwah.advancedportals.core.permissions.PermissionBuilder; 4 | import com.sekwah.advancedportals.core.permissions.Permissions; 5 | import java.util.List; 6 | 7 | public class PermissionsGeneratorSpigot { 8 | private PermissionsGeneratorSpigot() { 9 | } 10 | 11 | public static String getPermissions() { 12 | return toPermBlock(Permissions.ROOT); 13 | } 14 | 15 | public static String toPermBlock(PermissionBuilder permission) { 16 | StringBuilder builder = new StringBuilder(); 17 | builder.append("\n"); 18 | String indent = " "; 19 | if (!permission.isDoNotExport()) { 20 | builder.append(indent).append(permission).append(":\n"); 21 | builder.append(indent).append(indent).append("default: "); 22 | builder.append( 23 | permission.getPermissionDefault().toString().toLowerCase()); 24 | builder.append("\n"); 25 | if (permission.getDescription() != null) { 26 | builder.append(indent).append(indent).append("description: "); 27 | builder.append(permission.getDescription()).append("\n"); 28 | } 29 | List children = permission.getGrantChildren(); 30 | if (!children.isEmpty()) { 31 | builder.append(indent).append(indent).append("children:\n"); 32 | for (PermissionBuilder child : children) { 33 | builder.append(indent).append(indent).append(indent); 34 | builder.append(child.toString()) 35 | .append(": true") 36 | .append("\n"); 37 | } 38 | } 39 | } 40 | for (PermissionBuilder child : permission.getChildren()) { 41 | builder.append(toPermBlock(child)); 42 | } 43 | return builder.toString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/PermissionsGeneratorSpigot.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot; 2 | 3 | import com.sekwah.advancedportals.core.permissions.PermissionBuilder; 4 | import com.sekwah.advancedportals.core.permissions.Permissions; 5 | import java.util.List; 6 | 7 | public class PermissionsGeneratorSpigot { 8 | private PermissionsGeneratorSpigot() { 9 | } 10 | 11 | public static String getPermissions() { 12 | return toPermBlock(Permissions.ROOT); 13 | } 14 | 15 | public static String toPermBlock(PermissionBuilder permission) { 16 | StringBuilder builder = new StringBuilder(); 17 | builder.append("\n"); 18 | String indent = " "; 19 | if (!permission.isDoNotExport()) { 20 | builder.append(indent).append(permission).append(":\n"); 21 | builder.append(indent).append(indent).append("default: "); 22 | builder.append( 23 | permission.getPermissionDefault().toString().toLowerCase()); 24 | builder.append("\n"); 25 | if (permission.getDescription() != null) { 26 | builder.append(indent).append(indent).append("description: "); 27 | builder.append(permission.getDescription()).append("\n"); 28 | } 29 | List children = permission.getGrantChildren(); 30 | if (!children.isEmpty()) { 31 | builder.append(indent).append(indent).append("children:\n"); 32 | for (PermissionBuilder child : children) { 33 | builder.append(indent).append(indent).append(indent); 34 | builder.append(child.toString()) 35 | .append(": true") 36 | .append("\n"); 37 | } 38 | } 39 | } 40 | for (PermissionBuilder child : permission.getChildren()) { 41 | builder.append(toPermBlock(child)); 42 | } 43 | return builder.toString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/RemovePortalSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.services.PortalServices; 8 | import com.sekwah.advancedportals.core.util.Lang; 9 | import java.util.List; 10 | 11 | public class RemovePortalSubCommand implements SubCommand { 12 | @Inject 13 | PortalServices portalServices; 14 | 15 | @Override 16 | public void onCommand(CommandSenderContainer sender, String[] args) { 17 | if (args.length > 1) { 18 | if (portalServices.removePortal(args[1], 19 | sender.getPlayerContainer())) { 20 | sender.sendMessage( 21 | Lang.getPositivePrefix() 22 | + Lang.translate("command.portal.remove.complete")); 23 | } else { 24 | sender.sendMessage( 25 | Lang.getNegativePrefix() 26 | + Lang.translate("command.portal.remove.error")); 27 | } 28 | } else { 29 | sender.sendMessage(Lang.translate("command.portal.remove.noname")); 30 | } 31 | } 32 | 33 | @Override 34 | public boolean hasPermission(CommandSenderContainer sender) { 35 | return Permissions.REMOVE_PORTAL.hasPermission(sender); 36 | } 37 | 38 | @Override 39 | public List onTabComplete(CommandSenderContainer sender, 40 | String[] args) { 41 | return portalServices.getPortalNames(); 42 | } 43 | 44 | @Override 45 | public String getBasicHelpText() { 46 | return Lang.translate("command.create.help"); 47 | } 48 | 49 | @Override 50 | public String getDetailedHelpText() { 51 | return Lang.translate("command.create.detailedhelp"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/tags/NameTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.tags; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 4 | import com.sekwah.advancedportals.core.registry.TagTarget; 5 | import com.sekwah.advancedportals.core.util.Lang; 6 | import com.sekwah.advancedportals.core.warphandler.Tag; 7 | import java.util.List; 8 | 9 | /** 10 | * The name of the destination or portal. 11 | * 12 | *

Most of the implementation of this tag is external, this is just to allow 13 | * for the tag to be used. 14 | * 15 | *

Most tags shouldn't be like this unless they are to be paired with 16 | * another tag. 17 | */ 18 | public class NameTag implements Tag.AutoComplete, Tag.Creation { 19 | public static final String TAG_NAME = "name"; 20 | 21 | private final TagType[] tagTypes = 22 | new TagType[] {TagType.PORTAL, TagType.DESTINATION}; 23 | 24 | @Override 25 | public TagType[] getTagTypes() { 26 | return tagTypes; 27 | } 28 | 29 | @Override 30 | public String getName() { 31 | return TAG_NAME; 32 | } 33 | 34 | @Override 35 | public String[] getAliases() { 36 | return null; 37 | } 38 | 39 | @Override 40 | public String description() { 41 | return Lang.translate("tag.name.description"); 42 | } 43 | 44 | @Override 45 | public List autoComplete(String argData) { 46 | return null; 47 | } 48 | 49 | @Override 50 | public boolean created(TagTarget target, PlayerContainer player, 51 | String[] argData) { 52 | if (argData.length > 0) { 53 | String name = argData[0]; 54 | if (name.contains(" ")) { 55 | player.sendMessage(Lang.getNegativePrefix() 56 | + Lang.translate("tag.name.error.nospaces")); 57 | return false; 58 | } 59 | } 60 | return true; 61 | } 62 | 63 | @Override 64 | public void destroyed(TagTarget target, PlayerContainer player, 65 | String[] argData) { 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadPortalSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 5 | import com.sekwah.advancedportals.core.commands.SubCommand; 6 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 7 | import com.sekwah.advancedportals.core.permissions.Permissions; 8 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 9 | import com.sekwah.advancedportals.core.services.DestinationServices; 10 | import com.sekwah.advancedportals.core.services.PortalServices; 11 | import com.sekwah.advancedportals.core.util.Lang; 12 | import java.util.List; 13 | 14 | public class ReloadPortalSubCommand implements SubCommand { 15 | @Inject 16 | private AdvancedPortalsCore portalsCore; 17 | 18 | @Inject 19 | PortalServices portalServices; 20 | 21 | @Inject 22 | DestinationServices destinationServices; 23 | 24 | @Inject 25 | ConfigRepository configRepository; 26 | 27 | @Override 28 | public void onCommand(CommandSenderContainer sender, String[] args) { 29 | portalsCore.loadPortalConfig(); 30 | portalServices.loadPortals(); 31 | destinationServices.loadDestinations(); 32 | Lang.loadLanguage(configRepository.getTranslation()); 33 | sender.sendMessage(Lang.getPositivePrefix() 34 | + Lang.translate("command.reload.reloaded")); 35 | } 36 | 37 | @Override 38 | public boolean hasPermission(CommandSenderContainer sender) { 39 | return Permissions.RELOAD.hasPermission(sender); 40 | } 41 | 42 | @Override 43 | public List onTabComplete(CommandSenderContainer sender, 44 | String[] args) { 45 | return null; 46 | } 47 | 48 | @Override 49 | public String getBasicHelpText() { 50 | return Lang.translate("command.reload.help"); 51 | } 52 | 53 | @Override 54 | public String getDetailedHelpText() { 55 | return Lang.translate("command.reload.detailedhelp"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 5 | import com.sekwah.advancedportals.core.commands.SubCommand; 6 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 7 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 8 | import com.sekwah.advancedportals.core.permissions.Permissions; 9 | import com.sekwah.advancedportals.core.util.Lang; 10 | import java.util.List; 11 | 12 | public class EndGatewayBlockSubCommand implements SubCommand { 13 | @Inject 14 | private AdvancedPortalsCore portalsCore; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | PlayerContainer player = sender.getPlayerContainer(); 19 | if (player == null) { 20 | sender.sendMessage(Lang.getNegativePrefix() 21 | + Lang.translate("command.playeronly")); 22 | } else { 23 | player.giveItem( 24 | "BLACK_WOOL", "\u00A78Gateway Block Placer", 25 | "\u00A7r\u00A77This wool is made of a magical substance", 26 | "\u00A7r\u00A7eRight Click\u00A77: Place portal block"); 27 | sender.sendMessage(Lang.getPositivePrefix() 28 | + Lang.translate("command.gatewayblock")); 29 | } 30 | } 31 | 32 | @Override 33 | public boolean hasPermission(CommandSenderContainer sender) { 34 | return Permissions.CREATE_PORTAL.hasPermission(sender); 35 | } 36 | 37 | @Override 38 | public List onTabComplete(CommandSenderContainer sender, 39 | String[] args) { 40 | return null; 41 | } 42 | 43 | @Override 44 | public String getBasicHelpText() { 45 | return Lang.translate("command.selector.help"); 46 | } 47 | 48 | @Override 49 | public String getDetailedHelpText() { 50 | return Lang.translate("command.selector.detailedhelp"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 5 | import com.sekwah.advancedportals.core.commands.SubCommand; 6 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 7 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 8 | import com.sekwah.advancedportals.core.permissions.Permissions; 9 | import com.sekwah.advancedportals.core.util.Lang; 10 | import java.util.List; 11 | 12 | public class EndPortalBlockSubCommand implements SubCommand { 13 | @Inject 14 | private AdvancedPortalsCore portalsCore; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | PlayerContainer player = sender.getPlayerContainer(); 19 | if (player == null) { 20 | sender.sendMessage(Lang.getNegativePrefix() 21 | + Lang.translate("command.playeronly")); 22 | } else { 23 | player.giveItem( 24 | "BLACK_WOOL", "\u00A78End Portal Block Placer", 25 | "\u00A7r\u00A77This wool is made of a magical substance", 26 | "\u00A7r\u00A7eRight Click\u00A77: Place portal block"); 27 | sender.sendMessage(Lang.getPositivePrefix() 28 | + Lang.translate("command.endportalblock")); 29 | } 30 | } 31 | 32 | @Override 33 | public boolean hasPermission(CommandSenderContainer sender) { 34 | return Permissions.CREATE_PORTAL.hasPermission(sender); 35 | } 36 | 37 | @Override 38 | public List onTabComplete(CommandSenderContainer sender, 39 | String[] args) { 40 | return null; 41 | } 42 | 43 | @Override 44 | public String getBasicHelpText() { 45 | return Lang.translate("command.selector.help"); 46 | } 47 | 48 | @Override 49 | public String getDetailedHelpText() { 50 | return Lang.translate("command.selector.detailedhelp"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.bungee.connector.container; 2 | 3 | import com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin; 4 | import com.sekwah.advancedportals.core.util.Lang; 5 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer; 6 | import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; 7 | import net.md_5.bungee.api.chat.TextComponent; 8 | import net.md_5.bungee.api.config.ServerInfo; 9 | import net.md_5.bungee.api.connection.ProxiedPlayer; 10 | 11 | public class BungeeProxyContainer implements ProxyContainer { 12 | private final AdvancedPortalsBungeePlugin plugin; 13 | 14 | public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) { 15 | this.plugin = plugin; 16 | } 17 | 18 | @Override 19 | public void invokeCommand(ProxyPlayerContainer proxyPlayer, 20 | String command) { 21 | // Should never not be true but just to be safe 22 | if (proxyPlayer instanceof BungeeProxyPlayerContainer) { 23 | BungeeProxyPlayerContainer playerContainer = 24 | (BungeeProxyPlayerContainer) proxyPlayer; 25 | plugin.getProxy().getPluginManager().dispatchCommand( 26 | playerContainer.getPlayer(), command); 27 | } 28 | } 29 | 30 | @Override 31 | public void transferPlayer(ProxyPlayerContainer proxyPlayer, 32 | String serverName) { 33 | // Should never not be true but just to be safe 34 | if (proxyPlayer instanceof BungeeProxyPlayerContainer) { 35 | BungeeProxyPlayerContainer playerContainer = 36 | (BungeeProxyPlayerContainer) proxyPlayer; 37 | ServerInfo serverInfo = plugin.getProxy().getServerInfo(serverName); 38 | ProxiedPlayer player = playerContainer.getPlayer(); 39 | if (serverInfo == null) { 40 | player.sendMessage(new TextComponent( 41 | Lang.convertColors("&cCould not find server: &e") 42 | + serverName)); 43 | return; 44 | } 45 | player.connect(serverInfo); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /bungee/src/main/java/com/sekwah/advancedportals/bungee/EventListener.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.bungee; 2 | 3 | import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyPlayerContainer; 4 | import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyServerContainer; 5 | import com.sekwah.advancedportals.core.ProxyMessages; 6 | import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore; 7 | import net.md_5.bungee.api.connection.ProxiedPlayer; 8 | import net.md_5.bungee.api.connection.Server; 9 | import net.md_5.bungee.api.event.PlayerDisconnectEvent; 10 | import net.md_5.bungee.api.event.PluginMessageEvent; 11 | import net.md_5.bungee.api.event.ServerSwitchEvent; 12 | import net.md_5.bungee.api.plugin.Listener; 13 | import net.md_5.bungee.event.EventHandler; 14 | 15 | public class EventListener implements Listener { 16 | private final AdvancedPortalsBungeePlugin plugin; 17 | private final AdvancedPortalsProxyCore proxyCore; 18 | 19 | public EventListener(AdvancedPortalsBungeePlugin plugin, 20 | AdvancedPortalsProxyCore proxyCore) { 21 | this.plugin = plugin; 22 | this.proxyCore = proxyCore; 23 | } 24 | 25 | @EventHandler 26 | public void onMessageReceived(PluginMessageEvent event) { 27 | if (!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) 28 | return; 29 | event.setCancelled(true); 30 | 31 | if (!(event.getSender() instanceof Server)) 32 | return; 33 | 34 | if (event.getReceiver() instanceof ProxiedPlayer) { 35 | ProxiedPlayer player = (ProxiedPlayer) event.getReceiver(); 36 | this.proxyCore.incomingMessage( 37 | new BungeeProxyPlayerContainer(player), event.getData()); 38 | } 39 | } 40 | 41 | @EventHandler 42 | public void onServerConnected(ServerSwitchEvent event) { 43 | this.proxyCore.onServerConnect( 44 | new BungeeProxyServerContainer(event.getPlayer().getServer()), 45 | new BungeeProxyPlayerContainer(event.getPlayer())); 46 | } 47 | 48 | @EventHandler 49 | public void onDisconnect(PlayerDisconnectEvent event) { 50 | this.proxyCore.onPlayerDisconnect( 51 | new BungeeProxyPlayerContainer(event.getPlayer())); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/importer/ConfigAccessor.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.importer; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.logging.Level; 6 | import org.bukkit.configuration.file.FileConfiguration; 7 | import org.bukkit.configuration.file.YamlConfiguration; 8 | import org.bukkit.plugin.java.JavaPlugin; 9 | 10 | public class ConfigAccessor { 11 | private final String fileName; 12 | private final JavaPlugin plugin; 13 | 14 | private File configFile; 15 | private FileConfiguration fileConfiguration; 16 | 17 | public ConfigAccessor(JavaPlugin plugin, String fileName) { 18 | this.plugin = plugin; 19 | this.fileName = fileName; 20 | } 21 | 22 | // gets all of the 23 | public void reloadConfig() { 24 | if (configFile == null) { 25 | File dataFolder = plugin.getDataFolder(); 26 | if (dataFolder == null) 27 | throw new IllegalStateException(); 28 | configFile = new File(dataFolder, fileName); 29 | } 30 | fileConfiguration = YamlConfiguration.loadConfiguration(configFile); 31 | } 32 | 33 | public FileConfiguration getConfig() { 34 | if (fileConfiguration == null) { 35 | this.reloadConfig(); 36 | } 37 | return fileConfiguration; 38 | } 39 | 40 | // Saves all the data to the selected yml file 41 | public void saveConfig() { 42 | try { 43 | getConfig().save(configFile); 44 | } catch (IOException ex) { 45 | plugin.getLogger().log( 46 | Level.SEVERE, "Could not save config to " + configFile, ex); 47 | } 48 | } 49 | 50 | // Saves 51 | 52 | /** 53 | * public void saveDefaultConfig() { if (!configFile.exists()) { 54 | * this.plugin.saveResource(fileName, false); } } 55 | */ 56 | 57 | // New save default config saving code, it checks if the needed config is in 58 | // the jar file before overriding it. 59 | public void saveDefaultConfig() { 60 | if (configFile == null) { 61 | configFile = new File(plugin.getDataFolder(), fileName); 62 | } 63 | if (!configFile.exists()) { 64 | plugin.saveResource(fileName, false); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/importer/ConfigAccessor.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.importer; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.logging.Level; 6 | import org.bukkit.configuration.file.FileConfiguration; 7 | import org.bukkit.configuration.file.YamlConfiguration; 8 | import org.bukkit.plugin.java.JavaPlugin; 9 | 10 | public class ConfigAccessor { 11 | private final String fileName; 12 | private final JavaPlugin plugin; 13 | 14 | private File configFile; 15 | private FileConfiguration fileConfiguration; 16 | 17 | public ConfigAccessor(JavaPlugin plugin, String fileName) { 18 | this.plugin = plugin; 19 | this.fileName = fileName; 20 | } 21 | 22 | // gets all of the 23 | public void reloadConfig() { 24 | if (configFile == null) { 25 | File dataFolder = plugin.getDataFolder(); 26 | if (dataFolder == null) 27 | throw new IllegalStateException(); 28 | configFile = new File(dataFolder, fileName); 29 | } 30 | fileConfiguration = YamlConfiguration.loadConfiguration(configFile); 31 | } 32 | 33 | public FileConfiguration getConfig() { 34 | if (fileConfiguration == null) { 35 | this.reloadConfig(); 36 | } 37 | return fileConfiguration; 38 | } 39 | 40 | // Saves all the data to the selected yml file 41 | public void saveConfig() { 42 | try { 43 | getConfig().save(configFile); 44 | } catch (IOException ex) { 45 | plugin.getLogger().log( 46 | Level.SEVERE, "Could not save config to " + configFile, ex); 47 | } 48 | } 49 | 50 | // Saves 51 | 52 | /** 53 | * public void saveDefaultConfig() { if (!configFile.exists()) { 54 | * this.plugin.saveResource(fileName, false); } } 55 | */ 56 | 57 | // New save default config saving code, it checks if the needed config is in 58 | // the jar file before overriding it. 59 | public void saveDefaultConfig() { 60 | if (configFile == null) { 61 | configFile = new File(plugin.getDataFolder(), fileName); 62 | } 63 | if (!configFile.exists()) { 64 | plugin.saveResource(fileName, false); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/tags/BungeeTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.tags; 2 | 3 | import com.google.common.io.ByteArrayDataOutput; 4 | import com.google.common.io.ByteStreams; 5 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 6 | import com.sekwah.advancedportals.core.registry.TagTarget; 7 | import com.sekwah.advancedportals.core.util.Lang; 8 | import com.sekwah.advancedportals.core.warphandler.ActivationData; 9 | import com.sekwah.advancedportals.core.warphandler.Tag; 10 | import java.util.Random; 11 | 12 | public class BungeeTag implements Tag.Activation { 13 | public static final String PACKET_CHANNEL = "BungeeCord"; 14 | 15 | public static final String TAG_NAME = "bungee"; 16 | 17 | private final TagType[] tagTypes = new TagType[] {TagType.PORTAL}; 18 | 19 | private final Random random = new Random(); 20 | 21 | @Override 22 | public TagType[] getTagTypes() { 23 | return tagTypes; 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return TAG_NAME; 29 | } 30 | 31 | @Override 32 | public String[] getAliases() { 33 | return null; 34 | } 35 | 36 | @Override 37 | public String description() { 38 | return Lang.translate("tag.bungee.description"); 39 | } 40 | 41 | @Override 42 | public boolean preActivated(TagTarget target, PlayerContainer player, 43 | ActivationData activeData, String[] argData) { 44 | return true; 45 | } 46 | 47 | @Override 48 | public void postActivated(TagTarget target, PlayerContainer player, 49 | ActivationData activationData, String[] argData) { 50 | } 51 | 52 | @Override 53 | public boolean activated(TagTarget target, PlayerContainer player, 54 | ActivationData activeData, String[] argData) { 55 | String selectedArg = argData[random.nextInt(argData.length)]; 56 | 57 | ByteArrayDataOutput outForSend = ByteStreams.newDataOutput(); 58 | outForSend.writeUTF("Connect"); 59 | outForSend.writeUTF(selectedArg); 60 | player.sendPacket(BungeeTag.PACKET_CHANNEL, outForSend.toByteArray()); 61 | activeData.setWarpStatus(ActivationData.WarpedStatus.WARPED); 62 | return true; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/RemoveDestiSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.desti; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.services.DestinationServices; 8 | import com.sekwah.advancedportals.core.util.Lang; 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | public class RemoveDestiSubCommand implements SubCommand { 13 | @Inject 14 | DestinationServices destinationServices; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | if (args.length > 1) { 19 | if (destinationServices.removeDestination( 20 | args[1], sender.getPlayerContainer())) { 21 | sender.sendMessage( 22 | Lang.getPositivePrefix() 23 | + Lang.translate("command.destination.remove.complete")); 24 | } else { 25 | sender.sendMessage( 26 | Lang.getNegativePrefix() 27 | + Lang.translate("command.destination.remove.error")); 28 | } 29 | } else { 30 | sender.sendMessage(Lang.translate("command.destination.noname")); 31 | } 32 | } 33 | 34 | @Override 35 | public boolean hasPermission(CommandSenderContainer sender) { 36 | return Permissions.REMOVE_DESTI.hasPermission(sender); 37 | } 38 | 39 | @Override 40 | public List onTabComplete(CommandSenderContainer sender, 41 | String[] args) { 42 | if (args.length > 2) { 43 | return Collections.emptyList(); 44 | } 45 | List destiNames = destinationServices.getDestinationNames(); 46 | Collections.sort(destiNames); 47 | return destiNames; 48 | } 49 | 50 | @Override 51 | public String getBasicHelpText() { 52 | return Lang.translate("command.create.help"); 53 | } 54 | 55 | @Override 56 | public String getDetailedHelpText() { 57 | return Lang.translate("command.create.detailedhelp"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/RenameDestiSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.desti; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.services.DestinationServices; 8 | import com.sekwah.advancedportals.core.util.Lang; 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | public class RenameDestiSubCommand implements SubCommand { 13 | @Inject 14 | DestinationServices destinationServices; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | if (args.length > 2) { 19 | String oldName = args[1]; 20 | String newName = args[2]; 21 | if (!destinationServices.renameDestination( 22 | oldName, newName, sender.getPlayerContainer())) { 23 | sender.sendMessage( 24 | Lang.getNegativePrefix() 25 | + Lang.translate("command.destination.rename.error")); 26 | } 27 | } else { 28 | sender.sendMessage( 29 | Lang.getNegativePrefix() 30 | + Lang.translate("command.destination.rename.usage")); 31 | } 32 | } 33 | 34 | @Override 35 | public boolean hasPermission(CommandSenderContainer sender) { 36 | return Permissions.RENAME_DESTI.hasPermission(sender); 37 | } 38 | 39 | @Override 40 | public List onTabComplete(CommandSenderContainer sender, 41 | String[] args) { 42 | if (args.length == 2) { 43 | List destiNames = destinationServices.getDestinationNames(); 44 | Collections.sort(destiNames); 45 | return destiNames; 46 | } 47 | return Collections.emptyList(); 48 | } 49 | 50 | @Override 51 | public String getBasicHelpText() { 52 | return Lang.translate("command.destination.rename.help"); 53 | } 54 | 55 | @Override 56 | public String getDetailedHelpText() { 57 | return Lang.translate("command.destination.rename.detailedhelp"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 5 | import com.sekwah.advancedportals.core.commands.SubCommand; 6 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 7 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 8 | import com.sekwah.advancedportals.core.permissions.Permissions; 9 | import com.sekwah.advancedportals.core.util.Lang; 10 | import java.util.List; 11 | 12 | public class PortalBlockSubCommand implements SubCommand { 13 | @Inject 14 | private AdvancedPortalsCore portalsCore; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | PlayerContainer player = sender.getPlayerContainer(); 19 | if (player == null) { 20 | sender.sendMessage(Lang.getNegativePrefix() 21 | + Lang.translate("command.playeronly")); 22 | } else { 23 | player.giveItem( 24 | "PURPLE_WOOL", "\u00A75Portal Block Placer", 25 | "\u00A7r\u00A77This wool is made of a magical substance", 26 | "\u00A7r\u00A7e" + Lang.translate("items.interact.left") 27 | + "\u00A77: Rotate portal block", 28 | "\u00A7r\u00A7e" + Lang.translate("items.interact.right") 29 | + "\u00A77: Place portal block"); 30 | sender.sendMessage(Lang.getPositivePrefix() 31 | + Lang.translate("command.portalblock")); 32 | } 33 | } 34 | 35 | @Override 36 | public boolean hasPermission(CommandSenderContainer sender) { 37 | return Permissions.CREATE_PORTAL.hasPermission(sender); 38 | } 39 | 40 | @Override 41 | public List onTabComplete(CommandSenderContainer sender, 42 | String[] args) { 43 | return null; 44 | } 45 | 46 | @Override 47 | public String getBasicHelpText() { 48 | return Lang.translate("command.selector.help"); 49 | } 50 | 51 | @Override 52 | public String getDetailedHelpText() { 53 | return Lang.translate("command.selector.detailedhelp"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit-check.yaml: -------------------------------------------------------------------------------- 1 | name: Pre-commit consistency check 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | types: [labeled, opened, reopened, synchronize] 7 | push: 8 | branches: [main] 9 | 10 | concurrency: 11 | group: ${{ github.head_ref }}-precommit 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | pre-commit-check: 16 | if: github.event.action != 'labeled' || github.event.label.name == 'pre-commit ci run' 17 | name: Run pre-commit checks 18 | runs-on: ubuntu-20.04 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v2 22 | with: 23 | fetch-depth: 0 24 | - run: gh pr edit ${{ github.event.number }} --remove-label 'pre-commit ci run' 25 | if: github.event.action == 'labeled' && github.event.label.name == 'pre-commit ci run' 26 | env: 27 | GH_TOKEN: ${{ github.token }} 28 | - uses: dorny/paths-filter@v2 29 | id: filter 30 | with: 31 | list-files: shell 32 | filters: | 33 | addedOrModified: 34 | - added|modified: '**' 35 | 36 | # run only if changed files were detected 37 | - name: Run against changes 38 | uses: pre-commit/action@v3.0.1 39 | if: steps.filter.outputs.addedOrModified == 'true' 40 | with: 41 | extra_args: --files ${{ steps.filter.outputs.addedOrModified_files }} 42 | 43 | # run if no changed files were detected (e.g. workflow_dispatch on master branch) 44 | - name: Run against all files 45 | uses: pre-commit/action@v3.0.1 46 | if: steps.filter.outputs.addedOrModified != 'true' 47 | with: 48 | extra_args: --all-files 49 | 50 | - name: Commit pre-commit changes 51 | if: github.event_name != 'pull_request' && always() 52 | run: | 53 | git config --global user.name "github-actions[bot]" 54 | git config --global user.email "github-actions[bot]@users.noreply.github.com" 55 | git add . 56 | git commit -m "chore: pre-commit changes [skip ci]" || echo "No changes to commit" 57 | env: 58 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 59 | 60 | - name: Push pre-commit changes 61 | if: github.event_name != 'pull_request' && github.event.action != 'labeled' && github.event.action != 'synchronize' && always() 62 | run: | 63 | git push ${{ github.head_ref }} 64 | env: 65 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 66 | 67 | - uses: pre-commit-ci/lite-action@v1.0.2 68 | if: always() 69 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/InfoPortalSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.portal.AdvancedPortal; 8 | import com.sekwah.advancedportals.core.services.PortalServices; 9 | import com.sekwah.advancedportals.core.util.Lang; 10 | import com.sekwah.advancedportals.core.util.TagReader; 11 | import java.util.List; 12 | 13 | public class InfoPortalSubCommand implements SubCommand { 14 | @Inject 15 | PortalServices portalServices; 16 | 17 | @Override 18 | public void onCommand(CommandSenderContainer sender, String[] args) { 19 | if (args.length > 1) { 20 | String portalName = args[1]; 21 | AdvancedPortal portal = portalServices.getPortal(portalName); 22 | if (portal == null) { 23 | sender.sendMessage( 24 | Lang.getNegativePrefix() 25 | + Lang.translateInsertVariables( 26 | "command.portal.info.notfound", portalName)); 27 | return; 28 | } 29 | sender.sendMessage(Lang.getPositivePrefix() 30 | + Lang.translateInsertVariables( 31 | "command.portal.info.complete", portalName)); 32 | TagReader.printArgs(sender, portal.getArgs()); 33 | } else { 34 | sender.sendMessage(Lang.getNegativePrefix() 35 | + Lang.translate("command.portal.info.noname")); 36 | } 37 | } 38 | 39 | @Override 40 | public boolean hasPermission(CommandSenderContainer sender) { 41 | return Permissions.PORTAL_INFO.hasPermission(sender); 42 | } 43 | 44 | @Override 45 | public List onTabComplete(CommandSenderContainer sender, 46 | String[] args) { 47 | return portalServices.getPortalNames(); 48 | } 49 | 50 | @Override 51 | public String getBasicHelpText() { 52 | return Lang.translate("command.portal.list.help"); 53 | } 54 | 55 | @Override 56 | public String getDetailedHelpText() { 57 | return Lang.translate("command.portal.list.help"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/DisableBeaconSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.portal.AdvancedPortal; 8 | import com.sekwah.advancedportals.core.services.PortalServices; 9 | import com.sekwah.advancedportals.core.util.Lang; 10 | import java.util.List; 11 | 12 | public class DisableBeaconSubCommand implements SubCommand { 13 | @Inject 14 | PortalServices portalServices; 15 | 16 | @Override 17 | public void onCommand(CommandSenderContainer sender, String[] args) { 18 | if (args.length > 1) { 19 | String portalName = args[1]; 20 | AdvancedPortal portal = portalServices.getPortal(portalName); 21 | if (portal == null) { 22 | sender.sendMessage( 23 | Lang.getNegativePrefix() 24 | + Lang.translateInsertVariables( 25 | "command.portal.disablebeacon.notfound", portalName)); 26 | return; 27 | } 28 | sender.sendMessage( 29 | Lang.getPositivePrefix() 30 | + Lang.translateInsertVariables( 31 | "command.portal.disablebeacon.complete", portalName)); 32 | sender.getPlayerContainer().getWorld().disableBeacon(portal); 33 | } else { 34 | sender.sendMessage( 35 | Lang.getNegativePrefix() 36 | + Lang.translate("command.portal.disablebeacon.noname")); 37 | } 38 | } 39 | 40 | @Override 41 | public boolean hasPermission(CommandSenderContainer sender) { 42 | return Permissions.DISABLE_BEACON.hasPermission(sender); 43 | } 44 | 45 | @Override 46 | public List onTabComplete(CommandSenderContainer sender, 47 | String[] args) { 48 | return portalServices.getPortalNames(); 49 | } 50 | 51 | @Override 52 | public String getBasicHelpText() { 53 | return Lang.translate("command.portal.disablebeacon.help"); 54 | } 55 | 56 | @Override 57 | public String getDetailedHelpText() { 58 | return Lang.translate("command.portal.disablebeacon.help"); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.services; 2 | 3 | import com.google.inject.Inject; 4 | import com.google.inject.Singleton; 5 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 6 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 7 | import com.sekwah.advancedportals.core.repository.IPlayerDataRepository; 8 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 9 | import com.sekwah.advancedportals.core.serializeddata.PlayerData; 10 | import com.sekwah.advancedportals.core.util.Lang; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import java.util.UUID; 14 | 15 | @Singleton 16 | public final class PlayerDataServices { 17 | /** 18 | * Possibly change to the cache map Aztec was talking about 19 | */ 20 | private final Map tempDataMap = new HashMap<>(); 21 | 22 | @Inject 23 | private IPlayerDataRepository tempDataRepository; 24 | 25 | @Inject 26 | private ConfigRepository configRepository; 27 | 28 | public PlayerData getPlayerData(PlayerContainer player) { 29 | return tempDataMap.computeIfAbsent(player.getUUID(), uuid -> { 30 | PlayerData tempData = 31 | tempDataRepository.get(player.getUUID().toString()); 32 | 33 | if (tempData == null) { 34 | tempData = new PlayerData(); 35 | } 36 | return tempData; 37 | }); 38 | } 39 | 40 | public void setJoinCooldown(PlayerContainer player) { 41 | PlayerData tempData = getPlayerData(player); 42 | tempData.setJoinCooldown(configRepository.getPortalCooldown() * 1000); 43 | } 44 | 45 | public void playerLeave(PlayerContainer player) { 46 | tempDataRepository.save(player.getUUID().toString(), 47 | getPlayerData(player)); 48 | tempDataMap.remove(player.getUUID()); 49 | } 50 | 51 | public void playerSelectorActivate(PlayerContainer player, 52 | BlockLocation blockLoc, 53 | boolean leftClick) { 54 | PlayerData tempData = getPlayerData(player); 55 | if (leftClick) { 56 | tempData.setPos1(blockLoc); 57 | } else { 58 | tempData.setPos2(blockLoc); 59 | } 60 | player.sendMessage(Lang.translateInsertVariables( 61 | "portal.selector.poschange", leftClick ? "1" : "2", 62 | blockLoc.getPosX(), blockLoc.getPosY(), blockLoc.getPosZ())); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/warpeffects/EnderWarpEffect.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.warpeffects; 2 | 3 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 4 | import com.sekwah.advancedportals.core.effect.WarpEffect; 5 | import com.sekwah.advancedportals.legacyspigot.AdvancedPortalsPlugin; 6 | import com.sekwah.advancedportals.legacyspigot.connector.container.LegacySpigotPlayerContainer; 7 | import org.bukkit.Effect; 8 | import org.bukkit.Location; 9 | import org.bukkit.World; 10 | import org.bukkit.entity.Player; 11 | 12 | public class EnderWarpEffect implements WarpEffect.Visual, WarpEffect.Sound { 13 | org.bukkit.Sound sound; 14 | 15 | { 16 | try { 17 | sound = org.bukkit.Sound.valueOf("ENTITY_ENDERMEN_TELEPORT"); 18 | } catch (IllegalArgumentException e) { 19 | try { 20 | sound = org.bukkit.Sound.valueOf("ENDERMAN_TELEPORT"); 21 | } catch (IllegalArgumentException e2) { 22 | AdvancedPortalsPlugin.getInstance().getLogger().warning( 23 | "Could not find the sound ENTITY_ENDERMAN_TELEPORT or ENDERMAN_TELEPORT"); 24 | } 25 | } 26 | } 27 | 28 | @Override 29 | public void onWarpSound(PlayerContainer playerContainer, Action action) { 30 | if (playerContainer instanceof LegacySpigotPlayerContainer) { 31 | LegacySpigotPlayerContainer spigotPlayerContainer = 32 | (LegacySpigotPlayerContainer) playerContainer; 33 | Player player = spigotPlayerContainer.getPlayer(); 34 | 35 | if (sound == null) { 36 | return; 37 | } 38 | player.getWorld().playSound(player.getLocation(), sound, 1, 1); 39 | } 40 | } 41 | 42 | @Override 43 | public void onWarpVisual(PlayerContainer playerContainer, Action action) { 44 | if (playerContainer instanceof LegacySpigotPlayerContainer) { 45 | LegacySpigotPlayerContainer spigotPlayerContainer = 46 | (LegacySpigotPlayerContainer) playerContainer; 47 | Player player = spigotPlayerContainer.getPlayer(); 48 | World world = player.getWorld(); 49 | Location loc = player.getLocation().clone(); 50 | for (int i = 0; i < 10; i++) { 51 | world.playEffect(loc, Effect.ENDER_SIGNAL, 0); 52 | } 53 | loc.add(0D, 1D, 0D); 54 | for (int i = 0; i < 10; i++) { 55 | world.playEffect(loc, Effect.ENDER_SIGNAL, 0); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.warphandler; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by on 30/07/2016. 9 | * 10 | * @author sekwah41 11 | */ 12 | public class ActivationData { 13 | private boolean warpAllowed = true; 14 | 15 | private WarpedStatus warpStatus = WarpedStatus.NOTACTIVATED; 16 | 17 | private PlayerLocation wantedLocation; 18 | 19 | private final TriggerType triggerType; 20 | 21 | private final Map metadata = new HashMap<>(); 22 | 23 | public WarpedStatus getWarped() { 24 | return this.warpStatus; 25 | } 26 | 27 | public ActivationData(TriggerType triggerType) { 28 | this.triggerType = triggerType; 29 | } 30 | 31 | public void setWarpStatus(WarpedStatus warped) { 32 | if (this.warpStatus == WarpedStatus.WARPED 33 | || (this.warpStatus == WarpedStatus.ACTIVATED 34 | && warped != WarpedStatus.WARPED)) { 35 | return; 36 | } 37 | this.warpStatus = warped; 38 | } 39 | 40 | public TriggerType getTriggerType() { 41 | return this.triggerType; 42 | } 43 | 44 | public String getMetadata(String key) { 45 | return this.metadata.get(key); 46 | } 47 | 48 | public void setMetadata(String key, String value) { 49 | this.metadata.put(key, value); 50 | } 51 | 52 | /** 53 | * In case you need to set the status back down a step for whatever reason. 54 | * However it is not recommended. 55 | * 56 | * @param warped 57 | */ 58 | public void setWarpStatusAbsolute(WarpedStatus warped) { 59 | this.warpStatus = warped; 60 | } 61 | 62 | public boolean getAllowed() { 63 | return this.warpAllowed; 64 | } 65 | 66 | public void setAllowed(boolean allowed) { 67 | this.warpAllowed = allowed; 68 | } 69 | 70 | public boolean hasActivated() { 71 | return this.warpStatus != WarpedStatus.NOTACTIVATED; 72 | } 73 | 74 | public enum WarpedStatus { 75 | /** 76 | * Player has moved or something major has happened. (only one of these 77 | * should activate) 78 | */ 79 | WARPED, 80 | /** 81 | * Shows that the portal has been activated even if a major function is 82 | * not performed. 83 | */ 84 | ACTIVATED, 85 | /** 86 | * Nothing has activated on the portal (may need to come up with a new 87 | * name) 88 | */ 89 | NOTACTIVATED 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /core/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | plugins { 3 | id 'com.github.johnrengelman.shadow' version '7.1.2' 4 | id 'maven-publish' 5 | id 'idea' 6 | id 'eclipse' 7 | } 8 | 9 | configurations { 10 | } 11 | 12 | repositories { 13 | maven { url "https://repo.maven.apache.org/maven2" } 14 | maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } 15 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 16 | } 17 | 18 | // includeLibs just says to include the library in the final jar 19 | dependencies { 20 | implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9' 21 | implementation group: 'com.google.inject', name: 'guice', version: '5.0.1' 22 | implementation group: 'org.yaml', name: 'snakeyaml', version: '2.2' 23 | implementation group: 'com.google.guava', name: 'guava', version: '33.2.0-jre' 24 | implementation group: 'io.netty', name: 'netty-buffer', version: '4.1.109.Final' 25 | implementation group: 'io.netty', name: 'netty-codec', version: '4.1.109.Final' 26 | } 27 | 28 | shadowJar { 29 | relocate 'com.google.code.gson', 'com.sekwah.advancedportals.shadowed.gson' 30 | relocate 'com.google.inject', 'com.sekwah.advancedportals.shadowed.inject' 31 | relocate 'com.google.errorprone', 'com.sekwah.advancedportals.shadowed.errorprone' 32 | relocate 'org.yaml.snakeyaml', 'com.sekwah.advancedportals.shadowed.snakeyaml' 33 | relocate 'com.google.common', 'com.sekwah.advancedportals.shadowed.guava' 34 | relocate 'io.netty', 'com.sekwah.advancedportals.shadowed.netty' 35 | relocate 'javax.annotation', 'com.sekwah.advancedportals.shadowed.javax.annotation' 36 | relocate 'javax.inject', 'com.sekwah.advancedportals.shadowed.javax.inject' 37 | relocate 'org.aopalliance', 'com.sekwah.advancedportals.shadowed.aopalliance' 38 | relocate 'org.checkerframework', 'com.sekwah.advancedportals.shadowed.checkerframework' 39 | 40 | exclude 'io/netty/**' 41 | 42 | minimize() 43 | 44 | archiveClassifier.set('') 45 | } 46 | 47 | tasks.named('jar') { 48 | enabled = false 49 | } 50 | 51 | tasks.named('build') { 52 | dependsOn tasks.named('shadowJar') 53 | } 54 | 55 | artifacts { 56 | runtimeOnly shadowJar 57 | } 58 | 59 | def templateSource = file('src/main/templates') 60 | def templateDest = layout.buildDirectory.dir('generated/sources/templates') 61 | 62 | def generateTemplates = tasks.register('generateTemplates', Copy) { task -> 63 | def props = [ 64 | 'version': project.version 65 | ] 66 | task.inputs.properties props 67 | 68 | task.from templateSource 69 | task.into templateDest 70 | task.expand props 71 | } 72 | 73 | sourceSets.main.java.srcDir(generateTemplates.map { it.outputs }) 74 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/MoveDestiSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.desti; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 7 | import com.sekwah.advancedportals.core.destination.Destination; 8 | import com.sekwah.advancedportals.core.permissions.Permissions; 9 | import com.sekwah.advancedportals.core.services.DestinationServices; 10 | import com.sekwah.advancedportals.core.util.Lang; 11 | 12 | import java.util.Collections; 13 | import java.util.List; 14 | 15 | public class MoveDestiSubCommand implements SubCommand { 16 | @Inject 17 | DestinationServices destinationServices; 18 | 19 | @Override 20 | public void onCommand(CommandSenderContainer sender, String[] args) { 21 | if (!hasPermission(sender)) { 22 | sender.sendMessage(Lang.translate("command.nopermission")); 23 | return; 24 | } 25 | if (!(sender instanceof PlayerContainer)) { 26 | sender.sendMessage(Lang.translate("command.playeronly")); 27 | return; 28 | } 29 | if (args.length < 2) { 30 | sender.sendMessage(getBasicHelpText()); 31 | return; 32 | } 33 | String destName = args[1]; 34 | Destination destination = destinationServices.getDestination(destName); 35 | if (destination == null) { 36 | sender.sendMessage(Lang.translate("command.destination.notfound")); 37 | return; 38 | } 39 | PlayerContainer player = (PlayerContainer) sender; 40 | destination.setLoc(player.getLoc()); 41 | destinationServices.changeDestinationLocation(destName, player.getLoc(), player); 42 | sender.sendMessage(Lang.translate("command.destination.moved")); 43 | } 44 | 45 | @Override 46 | public boolean hasPermission(CommandSenderContainer sender) { 47 | return Permissions.MOVE_DESTI.hasPermission(sender); 48 | } 49 | 50 | @Override 51 | public List onTabComplete(CommandSenderContainer sender, String[] args) { 52 | if (args.length == 2) { 53 | return destinationServices.getDestinationNames(); 54 | } 55 | return Collections.emptyList(); 56 | } 57 | 58 | @Override 59 | public String getBasicHelpText() { 60 | return Lang.translate("command.desti.move.help"); 61 | } 62 | 63 | @Override 64 | public String getDetailedHelpText() { 65 | return Lang.translate("command.desti.move.detailedhelp"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_dispatch: 3 | push: 4 | branches: 5 | - main 6 | name: release-please 7 | jobs: 8 | release-please: 9 | runs-on: ubuntu-latest 10 | environment: release 11 | outputs: 12 | release_created: ${{ steps.release.outputs.release_created }} 13 | upload_url: ${{ steps.release.outputs.upload_url }} 14 | # https://github.com/google-github-actions/release-please-action in case more config is needed 15 | steps: 16 | - uses: google-github-actions/release-please-action@v3 17 | id: release 18 | with: 19 | command: manifest 20 | token: ${{ secrets.PAT }} 21 | # See how to configure file https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md 22 | # See output info at https://github.com/google-github-actions/release-please-action#configuration for variables 23 | 24 | # Possibly optimise this by building and then passing the folder across to these stages 25 | release: 26 | strategy: 27 | fail-fast: false 28 | matrix: 29 | include: 30 | # Java 8 for legacyspigot 31 | - project: legacyspigot 32 | java-version: 8 33 | release-task: curseforge 34 | - project: legacyspigot 35 | java-version: 8 36 | release-task: modrinth 37 | # Java 16 for spigot 38 | - project: spigot 39 | java-version: 8 40 | release-task: curseforge 41 | - project: spigot 42 | java-version: 8 43 | release-task: discordupload 44 | - project: spigot 45 | java-version: 8 46 | release-task: modrinth 47 | needs: release-please 48 | runs-on: ubuntu-latest 49 | environment: release 50 | if: ${{ needs.release-please.outputs.release_created }} 51 | steps: 52 | - uses: actions/checkout@v3 53 | - name: Cache Gradle packages 54 | uses: actions/cache@v3 55 | with: 56 | path: ~/.gradle/caches 57 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} 58 | restore-keys: ${{ runner.os }}-gradle 59 | - name: Set up JDK ${{ matrix.java-version }} 60 | uses: actions/setup-java@v3 61 | with: 62 | distribution: temurin 63 | java-version: ${{ matrix.java-version }} 64 | - name: Build and publish (release) 65 | env: 66 | CURSE_API: ${{ secrets.CURSE_API }} 67 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 68 | DISCORD_RELEASE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} 69 | MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} 70 | IS_RELEASE: true 71 | run: | 72 | # Build 73 | ./gradlew build ${{ matrix.project }}:${{ matrix.release-task }} 74 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotEntityContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.connector.container; 2 | 3 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 4 | import com.sekwah.advancedportals.core.connector.containers.EntityContainer; 5 | import com.sekwah.advancedportals.core.connector.containers.WorldContainer; 6 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 7 | import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; 8 | import com.sekwah.advancedportals.core.serializeddata.Vector; 9 | import com.sekwah.advancedportals.shadowed.inject.Inject; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.Location; 12 | import org.bukkit.entity.Entity; 13 | 14 | /** 15 | * Just a temporary container for whenever advanced portals needs to get data 16 | * from a player 17 | */ 18 | public class SpigotEntityContainer implements EntityContainer { 19 | @Inject 20 | private AdvancedPortalsCore portalsCore; 21 | 22 | private final Entity entity; 23 | 24 | public SpigotEntityContainer(Entity entity) { 25 | this.entity = entity; 26 | } 27 | 28 | @Override 29 | public PlayerLocation getLoc() { 30 | Location loc = this.entity.getLocation(); 31 | return new PlayerLocation(loc.getWorld().getName(), loc.getX(), 32 | loc.getY(), loc.getZ(), loc.getYaw(), 33 | loc.getPitch()); 34 | } 35 | 36 | @Override 37 | public BlockLocation getBlockLoc() { 38 | Location loc = this.entity.getLocation(); 39 | return new BlockLocation(loc.getWorld().getName(), loc.getBlockX(), 40 | loc.getBlockY(), loc.getBlockZ()); 41 | } 42 | 43 | @Override 44 | public double getHeight() { 45 | return this.entity.getHeight(); 46 | } 47 | 48 | @Override 49 | public boolean teleport(PlayerLocation location) { 50 | return this.entity.teleport(new Location( 51 | Bukkit.getWorld(location.getWorldName()), location.getPosX(), 52 | location.getPosY(), location.getPosZ())); 53 | } 54 | 55 | @Override 56 | public WorldContainer getWorld() { 57 | return new SpigotWorldContainer(this.entity.getWorld()); 58 | } 59 | 60 | @Override 61 | public String getName() { 62 | return this.entity.getName(); 63 | } 64 | 65 | @Override 66 | public String getWorldName() { 67 | return this.entity.getWorld().getName(); 68 | } 69 | 70 | @Override 71 | public void setVelocity(Vector vector) { 72 | this.entity.setVelocity(new org.bukkit.util.Vector( 73 | vector.getX(), vector.getY(), vector.getZ())); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 5 | import com.sekwah.advancedportals.core.commands.SubCommand; 6 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 7 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 8 | import com.sekwah.advancedportals.core.permissions.Permissions; 9 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 10 | import com.sekwah.advancedportals.core.util.Lang; 11 | import java.util.List; 12 | 13 | public class SelectorSubCommand implements SubCommand { 14 | @Inject 15 | private ConfigRepository configRepo; 16 | 17 | @Inject 18 | private AdvancedPortalsCore portalsCore; 19 | 20 | @Override 21 | public void onCommand(CommandSenderContainer sender, String[] args) { 22 | PlayerContainer player = sender.getPlayerContainer(); 23 | if (player == null) { 24 | sender.sendMessage(Lang.getNegativePrefix() 25 | + Lang.translate("command.playeronly")); 26 | } else { 27 | player.giveItem( 28 | configRepo.getSelectorMaterial(), 29 | "\u00A7e" + Lang.translate("items.selector.name"), 30 | "\u00A7r\u00A77This wand with has the power to help", 31 | "\u00A7r\u00A77 create portals bistowed upon it!", "", 32 | "\u00A7r\u00A7e" + Lang.translate("items.interact.left") 33 | + "\u00A77: " 34 | + Lang.translateInsertVariables("items.selector.pos", "1"), 35 | "\u00A7r\u00A7e" + Lang.translate("items.interact.right") 36 | + "\u00A77: " 37 | + Lang.translateInsertVariables("items.selector.pos", "2")); 38 | sender.sendMessage(Lang.getPositivePrefix() 39 | + Lang.translate("command.selector")); 40 | } 41 | } 42 | 43 | @Override 44 | public boolean hasPermission(CommandSenderContainer sender) { 45 | return Permissions.SELECTOR.hasPermission(sender); 46 | } 47 | 48 | @Override 49 | public List onTabComplete(CommandSenderContainer sender, 50 | String[] args) { 51 | return null; 52 | } 53 | 54 | @Override 55 | public String getBasicHelpText() { 56 | return Lang.translate("command.selector.help"); 57 | } 58 | 59 | @Override 60 | public String getDetailedHelpText() { 61 | return Lang.translate("command.selector.detailedhelp"); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/connector/container/LegacySpigotEntityContainer.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.connector.container; 2 | 3 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 4 | import com.sekwah.advancedportals.core.connector.containers.EntityContainer; 5 | import com.sekwah.advancedportals.core.connector.containers.WorldContainer; 6 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 7 | import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; 8 | import com.sekwah.advancedportals.core.serializeddata.Vector; 9 | import com.sekwah.advancedportals.shadowed.inject.Inject; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.Location; 12 | import org.bukkit.entity.Entity; 13 | 14 | /** 15 | * Just a temporary container for whenever advanced portals needs to get data 16 | * from a player 17 | */ 18 | public class LegacySpigotEntityContainer implements EntityContainer { 19 | @Inject 20 | private AdvancedPortalsCore portalsCore; 21 | 22 | private final Entity entity; 23 | 24 | public LegacySpigotEntityContainer(Entity entity) { 25 | this.entity = entity; 26 | } 27 | 28 | @Override 29 | public PlayerLocation getLoc() { 30 | Location loc = this.entity.getLocation(); 31 | return new PlayerLocation(loc.getWorld().getName(), loc.getX(), 32 | loc.getY(), loc.getZ(), loc.getYaw(), 33 | loc.getPitch()); 34 | } 35 | 36 | @Override 37 | public BlockLocation getBlockLoc() { 38 | Location loc = this.entity.getLocation(); 39 | return new BlockLocation(loc.getWorld().getName(), loc.getBlockX(), 40 | loc.getBlockY(), loc.getBlockZ()); 41 | } 42 | 43 | @Override 44 | public double getHeight() { 45 | return 1.5; 46 | } 47 | 48 | @Override 49 | public boolean teleport(PlayerLocation location) { 50 | return this.entity.teleport(new Location( 51 | Bukkit.getWorld(location.getWorldName()), location.getPosX(), 52 | location.getPosY(), location.getPosZ())); 53 | } 54 | 55 | @Override 56 | public WorldContainer getWorld() { 57 | return new LegacySpigotWorldContainer(this.entity.getWorld()); 58 | } 59 | 60 | @Override 61 | public String getName() { 62 | return this.entity.getName(); 63 | } 64 | 65 | @Override 66 | public String getWorldName() { 67 | return this.entity.getWorld().getName(); 68 | } 69 | 70 | @Override 71 | public void setVelocity(Vector vector) { 72 | this.entity.setVelocity(new org.bukkit.util.Vector( 73 | vector.getX(), vector.getY(), vector.getZ())); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/MinecraftToAnsi.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.velocity.connector; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * I believe later versions of velocity have some component handlers for this, 8 | * and I could just send it to the server as components but ive decided to throw 9 | * this in for now just to use the plugin logger. Also, to try to clone the 10 | * bungee behavior as close as possible. 11 | */ 12 | public class MinecraftToAnsi { 13 | private static final Map minecraftToAnsiMap = 14 | new HashMap<>(); 15 | 16 | static { 17 | minecraftToAnsiMap.put('0', "\u001B[30m"); // Black 18 | minecraftToAnsiMap.put('1', "\u001B[34m"); // Dark Blue 19 | minecraftToAnsiMap.put('2', "\u001B[32m"); // Dark Green 20 | minecraftToAnsiMap.put('3', "\u001B[36m"); // Dark Aqua 21 | minecraftToAnsiMap.put('4', "\u001B[31m"); // Dark Red 22 | minecraftToAnsiMap.put('5', "\u001B[35m"); // Dark Purple 23 | minecraftToAnsiMap.put('6', "\u001B[33m"); // Gold 24 | minecraftToAnsiMap.put('7', "\u001B[37m"); // Gray 25 | minecraftToAnsiMap.put('8', "\u001B[90m"); // Dark Gray 26 | minecraftToAnsiMap.put('9', "\u001B[94m"); // Blue 27 | minecraftToAnsiMap.put('a', "\u001B[92m"); // Green 28 | minecraftToAnsiMap.put('b', "\u001B[96m"); // Aqua 29 | minecraftToAnsiMap.put('c', "\u001B[91m"); // Red 30 | minecraftToAnsiMap.put('d', "\u001B[95m"); // Light Purple 31 | minecraftToAnsiMap.put('e', "\u001B[93m"); // Yellow 32 | minecraftToAnsiMap.put('f', "\u001B[97m"); // White 33 | minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking) 34 | minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold 35 | minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough 36 | minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline 37 | minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic 38 | minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset 39 | } 40 | 41 | public static String convert(String text) { 42 | StringBuilder result = new StringBuilder(); 43 | for (int i = 0; i < text.length(); i++) { 44 | if (text.charAt(i) == '\u00A7' && i + 1 < text.length()) { 45 | char code = Character.toLowerCase(text.charAt(i + 1)); 46 | String ansiCode = minecraftToAnsiMap.getOrDefault(code, ""); 47 | result.append(ansiCode); 48 | i++; 49 | } else { 50 | result.append(text.charAt(i)); 51 | } 52 | } 53 | 54 | result.append("\u001B[0m"); 55 | return result.toString(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.registry; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 5 | import com.sekwah.advancedportals.core.effect.WarpEffect; 6 | import com.sekwah.advancedportals.core.util.InfoLogger; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author sekwah41 12 | */ 13 | public class WarpEffectRegistry { 14 | private final Map warpEffects = new HashMap<>(); 15 | 16 | @Inject 17 | private AdvancedPortalsCore portalsCore; 18 | 19 | @Inject 20 | private InfoLogger infoLogger; 21 | 22 | /** 23 | * Register a new warp effect. 24 | * 25 | * @param name 26 | * @param effect 27 | * @return if the effect was registered 28 | */ 29 | public void registerEffect(String name, WarpEffect effect) { 30 | if (name == null) { 31 | this.infoLogger.warning("Effect name cannot be null"); 32 | return; 33 | } 34 | if (this.warpEffects.containsKey(name)) { 35 | this.infoLogger.warning("Effect with the name: " + name 36 | + " already exists"); 37 | return; 38 | } 39 | this.warpEffects.put(name, effect); 40 | } 41 | 42 | public WarpEffect.Visual getVisualEffect(String name) { 43 | if (this.warpEffects.containsKey(name.toLowerCase())) { 44 | WarpEffect effect = this.warpEffects.get(name); 45 | if (effect instanceof WarpEffect.Visual) { 46 | return (WarpEffect.Visual) effect; 47 | } else { 48 | this.infoLogger.warning("Effect called " + name 49 | + " is not a visual effect"); 50 | return null; 51 | } 52 | } else { 53 | this.infoLogger.warning("No effect called " + name 54 | + " is registered"); 55 | return null; 56 | } 57 | } 58 | 59 | public WarpEffect.Sound getSoundEffect(String name) { 60 | if (this.warpEffects.containsKey(name)) { 61 | WarpEffect effect = this.warpEffects.get(name); 62 | if (effect instanceof WarpEffect.Sound) { 63 | return (WarpEffect.Sound) effect; 64 | } else { 65 | this.infoLogger.warning("Effect called " + name 66 | + " is not a sound effect"); 67 | return null; 68 | } 69 | } else { 70 | this.infoLogger.warning("No effect called " + name 71 | + " is registered"); 72 | return null; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.tags; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 5 | import com.sekwah.advancedportals.core.registry.TagTarget; 6 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 7 | import com.sekwah.advancedportals.core.services.PlayerDataServices; 8 | import com.sekwah.advancedportals.core.util.InfoLogger; 9 | import com.sekwah.advancedportals.core.util.Lang; 10 | import com.sekwah.advancedportals.core.warphandler.ActivationData; 11 | import com.sekwah.advancedportals.core.warphandler.Tag; 12 | import javax.annotation.Nullable; 13 | 14 | public class PermissionTag implements Tag.Activation { 15 | @Inject 16 | PlayerDataServices playerDataServices; 17 | 18 | @Inject 19 | ConfigRepository configRepository; 20 | 21 | @Inject 22 | private InfoLogger infoLogger; 23 | 24 | public static final String TAG_NAME = "permission"; 25 | 26 | private final String[] aliases = new String[] {"perm"}; 27 | 28 | private final TagType[] tagTypes = 29 | new TagType[] {TagType.PORTAL, TagType.DESTINATION}; 30 | 31 | @Override 32 | public TagType[] getTagTypes() { 33 | return tagTypes; 34 | } 35 | 36 | @Override 37 | public String getName() { 38 | return TAG_NAME; 39 | } 40 | 41 | @Nullable 42 | @Override 43 | public String[] getAliases() { 44 | return aliases; 45 | } 46 | 47 | @Override 48 | public String description() { 49 | return Lang.translate("tag.permission.description"); 50 | } 51 | 52 | @Override 53 | public boolean preActivated(TagTarget target, PlayerContainer player, 54 | ActivationData activeData, String[] argData) { 55 | String permission = argData[0]; 56 | if (permission.startsWith("!")) { 57 | permission = permission.substring(1); 58 | if (player.hasPermission(permission)) { 59 | player.sendMessage( 60 | Lang.getNegativePrefix() 61 | + Lang.translate("portal.error.nopermission")); 62 | return false; 63 | } 64 | return true; 65 | } else if (!player.hasPermission(argData[0])) { 66 | player.sendMessage(Lang.getNegativePrefix() 67 | + Lang.translate("portal.error.nopermission")); 68 | return false; 69 | } 70 | return true; 71 | } 72 | 73 | @Override 74 | public void postActivated(TagTarget target, PlayerContainer player, 75 | ActivationData activationData, String[] argData) { 76 | } 77 | 78 | @Override 79 | public boolean activated(TagTarget target, PlayerContainer player, 80 | ActivationData activationData, String[] argData) { 81 | return true; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/registry/SubCommandRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.registry; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.util.InfoLogger; 6 | import java.util.ArrayList; 7 | import java.util.Collections; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * Do not register to here. Register to the sprcific subcommand registry 13 | * classes. 14 | * 15 | *

Designed to let addons add new command sections to access, edit or add 16 | * new functonality. 17 | * 18 | * @author sekwah41 19 | */ 20 | public class SubCommandRegistry { 21 | protected final Map subCommandMap = new HashMap<>(); 22 | 23 | /** 24 | * List of subcommand names which should be in order alphabetically 25 | */ 26 | protected final ArrayList subCommands = new ArrayList<>(); 27 | 28 | @Inject 29 | private InfoLogger infoLogger; 30 | 31 | /** 32 | * @param arg argument needed to activate 33 | * @param subCommand 34 | * @return if the subcommand is registered or not 35 | */ 36 | public boolean registerSubCommand(String arg, SubCommand subCommand) { 37 | if (subCommand == null) { 38 | this.infoLogger.warning("The subcommand '" + arg 39 | + "' cannot be null."); 40 | return false; 41 | } 42 | 43 | if (this.subCommandMap.containsKey(arg)) { 44 | this.infoLogger.warning("The subcommand '" + arg 45 | + "' already exists."); 46 | return false; 47 | } 48 | 49 | this.subCommandMap.put(arg.toLowerCase(), subCommand); 50 | 51 | this.subCommands.add(arg.toLowerCase()); 52 | 53 | Collections.sort(this.subCommands); 54 | 55 | return true; 56 | } 57 | 58 | /** 59 | * @return a list of arguments of registered subcommands 60 | */ 61 | public ArrayList getSubCommands() { 62 | return this.subCommands; 63 | } 64 | 65 | /** 66 | * I may be wrong but for larger lists containsKey is faster with a hashmap 67 | * than arraylist. 68 | * 69 | *

Though im not sure at what size it becomes more efficient. 70 | * 71 | * @param arg 72 | * @return if the argument is registered 73 | */ 74 | public boolean isArgRegistered(String arg) { 75 | return this.subCommandMap.containsKey(arg.toLowerCase()); 76 | } 77 | 78 | /** 79 | * Gets the subcommand corresponding to the string argument 80 | * 81 | * @param arg 82 | * @return the subcommand linked to the arg 83 | */ 84 | public SubCommand getSubCommand(String arg) { 85 | if (this.subCommandMap.containsKey(arg.toLowerCase())) { 86 | return this.subCommandMap.get(arg.toLowerCase()); 87 | } 88 | return null; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.util; 2 | 3 | import com.google.inject.Singleton; 4 | import java.util.ArrayList; 5 | import java.util.Iterator; 6 | 7 | /** 8 | * For all delayed and repeating tasks. 9 | */ 10 | @Singleton 11 | public final class GameScheduler { 12 | private final ArrayList newTickEvents = 13 | new ArrayList<>(); 14 | private final ArrayList delayedTickEvents = 15 | new ArrayList<>(); 16 | 17 | public void tick() { 18 | this.delayedTickEvents.addAll(this.newTickEvents); 19 | this.newTickEvents.clear(); 20 | Iterator tickEventIterator = 21 | this.delayedTickEvents.iterator(); 22 | while (tickEventIterator.hasNext()) { 23 | DelayedGameTickEvent event = tickEventIterator.next(); 24 | event.tick(); 25 | if (event.shouldRun()) { 26 | event.run(); 27 | if (!(event instanceof DelayedGameIntervalEvent)) 28 | tickEventIterator.remove(); 29 | } 30 | } 31 | } 32 | 33 | public void delayedTickEvent(String name, Runnable consumer, 34 | int tickDelay) { 35 | this.newTickEvents.add( 36 | new DelayedGameTickEvent(name, consumer, tickDelay)); 37 | } 38 | 39 | public void intervalTickEvent(String name, Runnable consumer, int tickDelay, 40 | int interval) { 41 | this.newTickEvents.add( 42 | new DelayedGameIntervalEvent(name, consumer, tickDelay, interval)); 43 | } 44 | 45 | public void clearAllEvents() { 46 | this.newTickEvents.clear(); 47 | this.delayedTickEvents.clear(); 48 | } 49 | 50 | public static class DelayedGameTickEvent { 51 | // So we can find it later and remove it if needed 52 | public final String name; 53 | public final Runnable consumer; 54 | public int ticks; 55 | 56 | public DelayedGameTickEvent(String name, Runnable consumer, int ticks) { 57 | this.name = name; 58 | this.consumer = consumer; 59 | this.ticks = ticks; 60 | } 61 | 62 | public void tick() { 63 | this.ticks--; 64 | } 65 | 66 | public boolean shouldRun() { 67 | return this.ticks <= 0; 68 | } 69 | 70 | public void run() { 71 | this.consumer.run(); 72 | } 73 | } 74 | 75 | public static class DelayedGameIntervalEvent extends DelayedGameTickEvent { 76 | public final int interval; 77 | 78 | public DelayedGameIntervalEvent(String name, Runnable consumer, 79 | int ticks, int interval) { 80 | super(name, consumer, ticks); 81 | this.interval = interval; 82 | } 83 | 84 | public void run() { 85 | this.ticks = interval; 86 | super.run(); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository.impl; 2 | 3 | import com.google.inject.Inject; 4 | import com.google.inject.Singleton; 5 | import com.sekwah.advancedportals.core.destination.Destination; 6 | import com.sekwah.advancedportals.core.repository.IDestinationRepository; 7 | import com.sekwah.advancedportals.core.serializeddata.DataStorage; 8 | import com.sekwah.advancedportals.core.tags.NameTag; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | @Singleton 13 | public class DestinationRepositoryImpl implements IDestinationRepository { 14 | private final String fileLocation = "desti/"; 15 | 16 | @Inject 17 | DataStorage dataStorage; 18 | 19 | private boolean isValidName(String name) { 20 | return name != null && !name.contains("/") && !name.contains("\\"); 21 | } 22 | 23 | @Override 24 | public boolean save(String name, Destination destination) { 25 | if (!isValidName(name)) { 26 | throw new IllegalArgumentException("Invalid name: " + name); 27 | } 28 | return dataStorage.storeFile(destination, 29 | fileLocation + name + ".yaml"); 30 | } 31 | 32 | @Override 33 | public boolean containsKey(String name) { 34 | if (!isValidName(name)) { 35 | throw new IllegalArgumentException("Invalid name: " + name); 36 | } 37 | return dataStorage.fileExists(fileLocation + name + ".yaml"); 38 | } 39 | 40 | @Override 41 | public boolean delete(String name) { 42 | if (!isValidName(name)) { 43 | throw new IllegalArgumentException("Invalid name: " + name); 44 | } 45 | return dataStorage.deleteFile(fileLocation + name + ".yaml"); 46 | } 47 | 48 | @Override 49 | public Destination get(String name) { 50 | if (!isValidName(name)) { 51 | throw new IllegalArgumentException("Invalid name: " + name); 52 | } 53 | return dataStorage.loadFile(Destination.class, 54 | fileLocation + name + ".yaml"); 55 | } 56 | 57 | @Override 58 | public List getAllNames() { 59 | return dataStorage.listAllFiles(fileLocation, true); 60 | } 61 | 62 | @Override 63 | public List getAll() { 64 | List destinations = new ArrayList<>(); 65 | List allFiles = dataStorage.listAllFiles(fileLocation, true); 66 | for (String fileName : allFiles) { 67 | Destination destination = this.get(fileName); 68 | // Forces the name tag to be up-to-date on load 69 | String[] name = destination.getArgValues(NameTag.TAG_NAME); 70 | if (name != null && name.length > 0) { 71 | destination.setArgValues(NameTag.TAG_NAME, 72 | new String[] {fileName}); 73 | } 74 | destinations.add(destination); 75 | } 76 | return destinations; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/tags/MessageTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.tags; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 5 | import com.sekwah.advancedportals.core.registry.TagTarget; 6 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 7 | import com.sekwah.advancedportals.core.util.Lang; 8 | import com.sekwah.advancedportals.core.warphandler.ActivationData; 9 | import com.sekwah.advancedportals.core.warphandler.Tag; 10 | import java.util.Random; 11 | 12 | public class MessageTag implements Tag.Activation { 13 | @Inject 14 | ConfigRepository configRepository; 15 | 16 | public static final String TAG_NAME = "message"; 17 | 18 | private final TagType[] tagTypes = 19 | new TagType[] {TagType.PORTAL, TagType.DESTINATION}; 20 | 21 | private final Random random = new Random(); 22 | 23 | @Override 24 | public TagType[] getTagTypes() { 25 | return tagTypes; 26 | } 27 | 28 | @Override 29 | public String getName() { 30 | return TAG_NAME; 31 | } 32 | 33 | @Override 34 | public String[] getAliases() { 35 | return null; 36 | } 37 | 38 | @Override 39 | public String description() { 40 | return Lang.translate("tag.message.description"); 41 | } 42 | 43 | @Override 44 | public boolean preActivated(TagTarget target, PlayerContainer player, 45 | ActivationData activeData, String[] argData) { 46 | return true; 47 | } 48 | 49 | @Override 50 | public void postActivated(TagTarget target, PlayerContainer player, 51 | ActivationData activationData, String[] argData) { 52 | String destination = activationData.getMetadata(DestiTag.TAG_NAME); 53 | String message = activationData.getMetadata(TAG_NAME); 54 | if (destination == null) { 55 | destination = ""; 56 | } else { 57 | destination = destination.replaceAll("_", " "); 58 | } 59 | 60 | sendMessage(player, 61 | message.replaceAll("@desti", destination) 62 | .replaceAll("@player", player.getName())); 63 | } 64 | 65 | @Override 66 | public boolean activated(TagTarget target, PlayerContainer player, 67 | ActivationData activeData, String[] argData) { 68 | String selectedArg = argData[random.nextInt(argData.length)]; 69 | activeData.setMetadata(TAG_NAME, selectedArg); 70 | activeData.setWarpStatus(ActivationData.WarpedStatus.ACTIVATED); 71 | return true; 72 | } 73 | 74 | public void sendMessage(PlayerContainer player, String message) { 75 | if (this.configRepository.warpMessageOnActionBar()) { 76 | player.sendActionBar(Lang.convertColors(message)); 77 | } else if (this.configRepository.warpMessageInChat()) { 78 | player.sendMessage(Lang.getPositivePrefix() + " " 79 | + Lang.convertColors(message)); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.tags; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.connector.containers.GameMode; 5 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 6 | import com.sekwah.advancedportals.core.registry.TagTarget; 7 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 8 | import com.sekwah.advancedportals.core.services.PlayerDataServices; 9 | import com.sekwah.advancedportals.core.util.InfoLogger; 10 | import com.sekwah.advancedportals.core.util.Lang; 11 | import com.sekwah.advancedportals.core.warphandler.ActivationData; 12 | import com.sekwah.advancedportals.core.warphandler.Tag; 13 | import com.sekwah.advancedportals.core.warphandler.TriggerType; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | import java.util.Objects; 17 | import javax.annotation.Nullable; 18 | 19 | public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, 20 | Tag.DenyBehavior, Tag.OrderPriority { 21 | @Inject 22 | PlayerDataServices playerDataServices; 23 | 24 | @Inject 25 | ConfigRepository configRepository; 26 | 27 | @Inject 28 | private InfoLogger infoLogger; 29 | 30 | public static final String TAG_NAME = "portalEvent"; 31 | 32 | private final String[] aliases = new String[] {"delayed"}; 33 | 34 | private final TagType[] tagTypes = new TagType[] {TagType.PORTAL}; 35 | 36 | @Override 37 | public TagType[] getTagTypes() { 38 | return tagTypes; 39 | } 40 | 41 | @Override 42 | public String getName() { 43 | return TAG_NAME; 44 | } 45 | 46 | @Nullable 47 | @Override 48 | public String[] getAliases() { 49 | return aliases; 50 | } 51 | 52 | @Override 53 | public String description() { 54 | return Lang.translate("tag.permission.description"); 55 | } 56 | 57 | @Override 58 | public boolean preActivated(TagTarget target, PlayerContainer player, 59 | ActivationData activeData, String[] argData) { 60 | if (player.getGameMode() == GameMode.CREATIVE) { 61 | return true; 62 | } 63 | return !Objects.equals(argData[0], "true") 64 | || activeData.getTriggerType() == TriggerType.PORTAL; 65 | } 66 | 67 | @Override 68 | public void postActivated(TagTarget target, PlayerContainer player, 69 | ActivationData activationData, String[] argData) { 70 | // Do nothing 71 | } 72 | 73 | @Override 74 | public boolean activated(TagTarget target, PlayerContainer player, 75 | ActivationData activationData, String[] argData) { 76 | return true; 77 | } 78 | 79 | @Nullable 80 | @Override 81 | public List autoComplete(String argData) { 82 | return Arrays.asList("true", "false"); 83 | } 84 | 85 | @Override 86 | public Behaviour getDenyBehavior() { 87 | return Behaviour.SILENT; 88 | } 89 | 90 | @Override 91 | public Priority getPriority() { 92 | return Priority.HIGHEST; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/tags/TriggerBlockTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.tags; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 5 | import com.sekwah.advancedportals.core.connector.containers.ServerContainer; 6 | import com.sekwah.advancedportals.core.registry.TagTarget; 7 | import com.sekwah.advancedportals.core.util.InfoLogger; 8 | import com.sekwah.advancedportals.core.util.Lang; 9 | import com.sekwah.advancedportals.core.warphandler.Tag; 10 | import java.util.List; 11 | import java.util.stream.Collectors; 12 | 13 | public class TriggerBlockTag 14 | implements Tag.AutoComplete, Tag.Split, Tag.Creation { 15 | @Inject 16 | private ServerContainer serverContainer; 17 | 18 | @Inject 19 | private InfoLogger infoLogger; 20 | 21 | public static final String TAG_NAME = "triggerblock"; 22 | 23 | private final TagType[] tagTypes = new TagType[] {TagType.PORTAL}; 24 | 25 | @Override 26 | public TagType[] getTagTypes() { 27 | return tagTypes; 28 | } 29 | 30 | @Override 31 | public String getName() { 32 | return TAG_NAME; 33 | } 34 | 35 | @Override 36 | public String[] getAliases() { 37 | return null; 38 | } 39 | 40 | @Override 41 | public String description() { 42 | return Lang.translate("tag.triggerblock.description"); 43 | } 44 | 45 | @Override 46 | public List autoComplete(String argData) { 47 | List triggerBlocks = 48 | serverContainer.getCommonTriggerBlocks() 49 | .stream() 50 | .filter(block -> block.contains(argData)) 51 | .collect(Collectors.toList()); 52 | 53 | if (triggerBlocks.isEmpty()) { 54 | return serverContainer.getAllTriggerBlocks(); 55 | } 56 | 57 | return triggerBlocks; 58 | } 59 | 60 | @Override 61 | public boolean created(TagTarget target, PlayerContainer player, 62 | String[] argData) { 63 | for (int i = 0; i < argData.length; i++) { 64 | String material = serverContainer.matchMaterialName(argData[i]); 65 | if (material == null || !isValidMaterial(material)) { 66 | if(player != null) { 67 | player.sendMessage( 68 | Lang.getNegativePrefix() 69 | + Lang.translate("tag.triggerblock.error.invalidmaterial")); 70 | } else { 71 | infoLogger.warning("Invalid material " + argData[i] + " on " + target.targetTagType().toString() + ": " + target.getName()); 72 | } 73 | return false; 74 | } 75 | argData[i] = material; 76 | } 77 | return true; 78 | } 79 | 80 | @Override 81 | public void destroyed(TagTarget target, PlayerContainer player, 82 | String[] argData) { 83 | } 84 | 85 | private boolean isValidMaterial(String material) { 86 | return serverContainer.getAllTriggerBlocks().stream().anyMatch( 87 | validMaterial -> validMaterial.equalsIgnoreCase(material)); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/tags/ProxyTag.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.tags; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.ProxyMessages; 5 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 6 | import com.sekwah.advancedportals.core.network.Packet; 7 | import com.sekwah.advancedportals.core.network.ProxyTransferDestiPacket; 8 | import com.sekwah.advancedportals.core.network.ProxyTransferPacket; 9 | import com.sekwah.advancedportals.core.registry.TagTarget; 10 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 11 | import com.sekwah.advancedportals.core.util.Lang; 12 | import com.sekwah.advancedportals.core.warphandler.ActivationData; 13 | import com.sekwah.advancedportals.core.warphandler.Tag; 14 | import java.util.Random; 15 | 16 | public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split { 17 | @Inject 18 | ConfigRepository configRepository; 19 | 20 | public static final String TAG_NAME = "proxy"; 21 | 22 | private final TagType[] tagTypes = new TagType[] {TagType.PORTAL}; 23 | 24 | private final Random random = new Random(); 25 | 26 | @Override 27 | public TagType[] getTagTypes() { 28 | return tagTypes; 29 | } 30 | 31 | @Override 32 | public String getName() { 33 | return TAG_NAME; 34 | } 35 | 36 | @Override 37 | public String[] getAliases() { 38 | return null; 39 | } 40 | 41 | @Override 42 | public String description() { 43 | return Lang.translate("tag.proxy.description"); 44 | } 45 | 46 | @Override 47 | public boolean preActivated(TagTarget target, PlayerContainer player, 48 | ActivationData activeData, String[] argData) { 49 | String selectedArg = argData[random.nextInt(argData.length)]; 50 | activeData.setMetadata(TAG_NAME, selectedArg); 51 | return true; 52 | } 53 | 54 | @Override 55 | public void postActivated(TagTarget target, PlayerContainer player, 56 | ActivationData activationData, String[] argData) { 57 | } 58 | 59 | @Override 60 | public boolean activated(TagTarget target, PlayerContainer player, 61 | ActivationData activeData, String[] argData) { 62 | if (!this.configRepository.getEnableProxySupport()) { 63 | player.sendMessage(Lang.getNegativePrefix() 64 | + Lang.translate("tag.proxy.notenabled")); 65 | return false; 66 | } 67 | 68 | String selectedArg = argData[random.nextInt(argData.length)]; 69 | 70 | String desti = activeData.getMetadata(DestiTag.TAG_NAME); 71 | 72 | Packet packet; 73 | if (desti == null) { 74 | packet = new ProxyTransferPacket(selectedArg); 75 | } else { 76 | packet = new ProxyTransferDestiPacket(selectedArg, desti); 77 | } 78 | player.sendPacket(ProxyMessages.CHANNEL_NAME, packet.encode()); 79 | activeData.setWarpStatus(ActivationData.WarpedStatus.WARPED); 80 | return true; 81 | } 82 | 83 | @Override 84 | public Priority getPriority() { 85 | return Priority.HIGHEST; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/MovePortalSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.commands.subcommands.portal; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; 7 | import com.sekwah.advancedportals.core.permissions.Permissions; 8 | import com.sekwah.advancedportals.core.portal.AdvancedPortal; 9 | import com.sekwah.advancedportals.core.services.PortalServices; 10 | import com.sekwah.advancedportals.core.services.PlayerDataServices; 11 | import com.sekwah.advancedportals.core.serializeddata.BlockLocation; 12 | import com.sekwah.advancedportals.core.serializeddata.PlayerData; 13 | import com.sekwah.advancedportals.core.util.Lang; 14 | import java.util.Collections; 15 | import java.util.List; 16 | 17 | public class MovePortalSubCommand implements SubCommand { 18 | @Inject 19 | PortalServices portalServices; 20 | @Inject 21 | PlayerDataServices playerDataServices; 22 | 23 | @Override 24 | public void onCommand(CommandSenderContainer sender, String[] args) { 25 | if (args.length < 2) { 26 | sender.sendMessage(Lang.getNegativePrefix() + "Usage: /portal move "); 27 | return; 28 | } 29 | PlayerContainer player = sender.getPlayerContainer(); 30 | if (player == null) { 31 | sender.sendMessage(Lang.getNegativePrefix() + Lang.translate("command.playeronly")); 32 | return; 33 | } 34 | String portalName = args[1]; 35 | AdvancedPortal portal = portalServices.getPortal(portalName); 36 | if (portal == null) { 37 | sender.sendMessage(Lang.getNegativePrefix() + "Portal not found: " + portalName); 38 | return; 39 | } 40 | PlayerData tempData = playerDataServices.getPlayerData(player); 41 | BlockLocation pos1 = tempData.getPos1(); 42 | BlockLocation pos2 = tempData.getPos2(); 43 | if (pos1 == null || pos2 == null) { 44 | sender.sendMessage(Lang.translate("portal.error.selection.missing")); 45 | return; 46 | } 47 | 48 | if (!tempData.getPos1().getWorldName().equals( 49 | tempData.getPos2().getWorldName())) { 50 | player.sendMessage( 51 | Lang.getNegativePrefix() 52 | + Lang.translate("portal.error.selection.differentworlds")); 53 | return; 54 | } 55 | 56 | portal.updateBounds(pos1, pos2); 57 | sender.sendMessage(Lang.getPositivePrefix() + Lang.translateInsertVariables("command.portal.move.complete", portalName)); 58 | } 59 | 60 | @Override 61 | public boolean hasPermission(CommandSenderContainer sender) { 62 | return Permissions.CREATE_PORTAL.hasPermission(sender); 63 | } 64 | 65 | @Override 66 | public List onTabComplete(CommandSenderContainer sender, String[] args) { 67 | if (args.length == 2) { 68 | return portalServices.getPortalNames(); 69 | } 70 | return Collections.emptyList(); 71 | } 72 | 73 | @Override 74 | public String getBasicHelpText() { 75 | return Lang.translate("command.portal.move.help"); 76 | } 77 | 78 | @Override 79 | public String getDetailedHelpText() { 80 | return Lang.translate("command.portal.move.detailedhelp"); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/serializeddata/BlockLocation.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.serializeddata; 2 | 3 | import com.sekwah.advancedportals.core.data.Direction; 4 | 5 | public class BlockLocation { 6 | private final int posX; 7 | 8 | private final int posY; 9 | 10 | private final int posZ; 11 | 12 | private final String worldName; 13 | 14 | public BlockLocation() { 15 | this.worldName = ""; 16 | this.posX = 0; 17 | this.posY = 0; 18 | this.posZ = 0; 19 | } 20 | 21 | public BlockLocation(String worldName, int posX, int posY, int posZ) { 22 | this.worldName = worldName; 23 | this.posX = posX; 24 | this.posY = posY; 25 | this.posZ = posZ; 26 | } 27 | 28 | public BlockLocation(BlockLocation location, Direction direction) { 29 | this.worldName = location.worldName; 30 | this.posX = location.posX + direction.x; 31 | this.posY = location.posY + direction.y; 32 | this.posZ = location.posZ + direction.z; 33 | } 34 | 35 | public int getPosX() { 36 | return posX; 37 | } 38 | 39 | public int getPosY() { 40 | return posY; 41 | } 42 | 43 | public int getPosZ() { 44 | return posZ; 45 | } 46 | 47 | public String getWorldName() { 48 | return worldName; 49 | } 50 | 51 | public boolean equals(BlockLocation location) { 52 | return location.posX == this.posX && location.posY == this.posY 53 | && location.posZ == this.posZ 54 | && location.worldName.equals(this.worldName); 55 | } 56 | 57 | public double distanceTo(BlockLocation pos) { 58 | return Math.sqrt(this.distanceToSq(pos)); 59 | } 60 | 61 | public double distanceToSq(BlockLocation pos) { 62 | double dx = this.posX - pos.posX; 63 | double dy = this.posY - pos.posY; 64 | double dz = this.posZ - pos.posZ; 65 | return dx * dx + dy * dy + dz * dz; 66 | } 67 | 68 | public BlockLocation addY(double offsetY) { 69 | return this.addY((int) Math.floor(offsetY)); 70 | } 71 | 72 | public BlockLocation addY(int offsetY) { 73 | return new BlockLocation(this.worldName, this.posX, 74 | (this.posY + offsetY), this.posZ); 75 | } 76 | 77 | public int getSize(BlockLocation pos2) { 78 | int minX = Math.min(this.getPosX(), pos2.getPosX()); 79 | int minY = Math.min(this.getPosY(), pos2.getPosY()); 80 | int minZ = Math.min(this.getPosZ(), pos2.getPosZ()); 81 | 82 | int maxX = Math.max(this.getPosX(), pos2.getPosX()); 83 | int maxY = Math.max(this.getPosY(), pos2.getPosY()); 84 | int maxZ = Math.max(this.getPosZ(), pos2.getPosZ()); 85 | 86 | int widthX = maxX - minX + 1; 87 | int widthY = maxY - minY + 1; 88 | int widthZ = maxZ - minZ + 1; 89 | 90 | return widthX * widthY * widthZ; 91 | } 92 | 93 | public Vector toVector() { 94 | return new Vector(this.posX, this.posY, this.posZ); 95 | } 96 | 97 | public WorldLocation toWorldLocation() { 98 | return new WorldLocation(this.worldName, this.posX, this.posY, 99 | this.posZ); 100 | } 101 | 102 | public BlockLocation add(int x, int y, int z) { 103 | return new BlockLocation(this.worldName, this.posX + x, this.posY + y, 104 | this.posZ + z); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [//]: # (This is a link to the raw location so that the image can be displayed from pages like Modrinth) 2 | ![Advanced portals](https://raw.githubusercontent.com/sekwah41/Advanced-Portals/refs/heads/main/docs/logo.png) 3 | 4 | [![Discord](https://img.shields.io/discord/168282484037910528.svg?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/fAJ3xJg) 5 | [![](https://img.shields.io/github/contributors/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/graphs/contributors) 6 | [![](https://img.shields.io/github/issues/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/issues) 7 | [![](https://img.shields.io/github/issues-pr/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/pulls) 8 | [![](https://img.shields.io/github/forks/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/network/members) 9 | [![](https://img.shields.io/github/stars/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/stargazers) 10 | [![](https://img.shields.io/github/license/sekwah41/Advanced-Portals.svg?logo=github&style=for-the-badge)](https://github.com/sekwah41/Advanced-Portals/blob/master/LICENSE.md) 11 | 12 | Advanced Portals 13 | ============== 14 | An advanced portals plugin designed to have a wide range of features which are easy to use. It adds a bunch of commands to create and edit portals and destinations. 15 | 16 | # Usage 17 | 18 | Check out the [Tutorial](https://advancedportals.sekwah.com/docs/intro), [List of Commands](https://advancedportals.sekwah.com/docs/commands), and [List of Portal Tags](https://advancedportals.sekwah.com/docs/portal-tags). 19 | 20 | # Download 21 | 22 | - [Modrinth](https://modrinth.com/plugin/advanced-portals) 23 | - [Bukkit](https://dev.bukkit.org/projects/advanced-portals) 24 | - [Spigot](https://www.spigotmc.org/resources/advanced-portals.14356/) 25 | - [Curseforge](https://www.curseforge.com/minecraft/bukkit-plugins/advanced-portals) 26 | - [Github (Source Code)](https://github.com/sekwah41/Advanced-Portals/releases) 27 | 28 | # Contributing 29 | Please ensure that your commits are in the following style for PR's 30 | 31 | https://www.conventionalcommits.org/en/v1.0.0/ 32 | 33 | Also if you could, please run `pre-commit run --files ...` or `pre-commit run --all-files` to ensure that the code is formatted correctly. 34 | You will need to have clang-format installed for this to work. 35 | 36 | ## Types available 37 | * **build**: Changes that affect the build system or external dependencies 38 | * **ci**: Changes to our CI configuration files and scripts 39 | * **docs**: Documentation only changes 40 | * **feat**: A new feature 41 | * **fix**: A bug fix 42 | * **perf**: A code change that improves performance 43 | * **refactor**: A code change that neither fixes a bug nor adds a feature 44 | * **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) 45 | 49 | 50 | ## Scopes available 51 | The scopes available should be the specific modules being worked on. E.g. core, spigot, docs 52 | 53 | ## Documentation 54 | That is handled on the [website](https://github.com/sekwah41/Advanced-Portals/tree/website) branch. 55 | 56 | At some point I may merge this onto this branch to try to push for documentation changes with new features, though for now this works. 57 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/util/Matrix.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.util; 2 | 3 | import com.sekwah.advancedportals.core.serializeddata.Vector; 4 | 5 | public class Matrix { 6 | public double m00, m01, m02; 7 | public double m10, m11, m12; 8 | public double m20, m21, m22; 9 | 10 | public Matrix() { 11 | } 12 | 13 | public Matrix(double m00, double m01, double m02, double m10, double m11, 14 | double m12, double m20, double m21, double m22) { 15 | setMatrix(m00, m01, m02, m10, m11, m12, m20, m21, m22); 16 | } 17 | 18 | public static Matrix identity() { 19 | return new Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1); 20 | } 21 | 22 | public Matrix clone() { 23 | return new Matrix(this.m00, this.m01, this.m02, this.m10, this.m11, 24 | this.m12, this.m20, this.m21, this.m22); 25 | } 26 | 27 | public void setMatrix(double m00, double m01, double m02, double m10, 28 | double m11, double m12, double m20, double m21, 29 | double m22) { 30 | this.m00 = m00; 31 | this.m01 = m01; 32 | this.m02 = m02; 33 | this.m10 = m10; 34 | this.m11 = m11; 35 | this.m12 = m12; 36 | this.m20 = m20; 37 | this.m21 = m21; 38 | this.m22 = m22; 39 | } 40 | 41 | public Matrix rotX(double x) { 42 | x = Math.toRadians(x); 43 | double sin = Math.sin(x); 44 | double cos = Math.cos(x); 45 | 46 | this.mul(1, 0, 0, 0, cos, -sin, 0, sin, cos); 47 | return this; 48 | } 49 | 50 | public Matrix rotY(double y) { 51 | y = Math.toRadians(y); 52 | double sin = Math.sin(y); 53 | double cos = Math.cos(y); 54 | 55 | this.mul(cos, 0, sin, 0, 1, 0, -sin, 0, cos); 56 | return this; 57 | } 58 | 59 | public Matrix rotZ(double z) { 60 | z = Math.toRadians(z); 61 | double sin = Math.sin(z); 62 | double cos = Math.cos(z); 63 | 64 | this.mul(cos, -sin, 0, sin, cos, 0, 0, 0, 1); 65 | return this; 66 | } 67 | 68 | public void mul(double m00, double m01, double m02, double m10, double m11, 69 | double m12, double m20, double m21, double m22) { 70 | double t00, t01, t02, t10, t11, t12, t20, t21, t22; 71 | 72 | t00 = this.m00 * m00 + this.m01 * m10 + this.m02 * m20; 73 | t01 = this.m00 * m01 + this.m01 * m11 + this.m02 * m21; 74 | t02 = this.m00 * m02 + this.m01 * m12 + this.m02 * m22; 75 | 76 | t10 = this.m10 * m00 + this.m11 * m10 + this.m12 * m20; 77 | t11 = this.m10 * m01 + this.m11 * m11 + this.m12 * m21; 78 | t12 = this.m10 * m02 + this.m11 * m12 + this.m12 * m22; 79 | 80 | t20 = this.m20 * m00 + this.m21 * m10 + this.m22 * m20; 81 | t21 = this.m20 * m01 + this.m21 * m11 + this.m22 * m21; 82 | t22 = this.m20 * m02 + this.m21 * m12 + this.m22 * m22; 83 | 84 | this.setMatrix(t00, t01, t02, t10, t11, t12, t20, t21, t22); 85 | } 86 | 87 | public void mul(Matrix mat) { 88 | this.mul(mat.m00, mat.m01, mat.m02, mat.m10, mat.m11, mat.m12, mat.m20, 89 | mat.m21, mat.m22); 90 | } 91 | 92 | public Vector transform(Vector vec) { 93 | return transform(vec.getX(), vec.getY(), vec.getZ()); 94 | } 95 | 96 | public Vector transform(double x, double y, double z) { 97 | return new Vector(m00 * x + m01 * y + m02 * z, 98 | m10 * x + m11 * y + m12 * z, 99 | m20 * x + m21 * y + m22 * z); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /velocity/src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsVelocityPlugin.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.velocity; 2 | 3 | import com.google.inject.Inject; 4 | import com.sekwah.advancedportals.core.BuildConstants; 5 | import com.sekwah.advancedportals.core.ProxyMessages; 6 | import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore; 7 | import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyContainer; 8 | import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyPlayerContainer; 9 | import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyServerContainer; 10 | import com.velocitypowered.api.event.Subscribe; 11 | import com.velocitypowered.api.event.connection.DisconnectEvent; 12 | import com.velocitypowered.api.event.connection.PluginMessageEvent; 13 | import com.velocitypowered.api.event.player.ServerPostConnectEvent; 14 | import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; 15 | import com.velocitypowered.api.plugin.Plugin; 16 | import com.velocitypowered.api.proxy.ProxyServer; 17 | import com.velocitypowered.api.proxy.ServerConnection; 18 | import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; 19 | import org.slf4j.Logger; 20 | 21 | @Plugin(authors = {"sekwah41"}, id = "advancedportals", 22 | name = "Advanced Portals", 23 | url = "https://www.spigotmc.org/resources/advanced-portals.14356/", 24 | version = BuildConstants.VERSION) 25 | public class AdvancedPortalsVelocityPlugin { 26 | private final AdvancedPortalsProxyCore proxyCore; 27 | 28 | private final Logger logger; 29 | private final ProxyServer proxy; 30 | 31 | private LegacyChannelIdentifier AP_CHANNEL; 32 | 33 | @Inject 34 | public AdvancedPortalsVelocityPlugin(ProxyServer proxy, Logger logger) { 35 | this.proxy = proxy; 36 | this.logger = logger; 37 | this.proxyCore = new AdvancedPortalsProxyCore( 38 | new VelocityInfoLogger(this.logger, this.proxy), 39 | new VelocityProxyContainer(this.proxy)); 40 | this.proxyCore.onEnable(); 41 | } 42 | 43 | @Subscribe 44 | public void onProxyInitialize(ProxyInitializeEvent event) { 45 | AP_CHANNEL = new LegacyChannelIdentifier(ProxyMessages.CHANNEL_NAME); 46 | 47 | proxy.getChannelRegistrar().register(AP_CHANNEL); 48 | } 49 | 50 | @Subscribe 51 | public void onPluginMessage(PluginMessageEvent event) { 52 | if (event.getIdentifier().equals(AP_CHANNEL)) { 53 | if (event.getSource() instanceof ServerConnection) { 54 | ServerConnection serverConnection = 55 | (ServerConnection) event.getSource(); 56 | this.proxyCore.incomingMessage( 57 | new VelocityProxyPlayerContainer( 58 | serverConnection.getPlayer(), AP_CHANNEL), 59 | event.getData()); 60 | } 61 | // So that client packets don't make it through to the servers, 62 | // always trigger on this channel. 63 | event.setResult(PluginMessageEvent.ForwardResult.handled()); 64 | } 65 | } 66 | 67 | @Subscribe 68 | public void postJoinEvent(ServerPostConnectEvent event) { 69 | event.getPlayer().getCurrentServer().ifPresent(serverConnection -> { 70 | this.proxyCore.onServerConnect( 71 | new VelocityProxyServerContainer(serverConnection.getServer()), 72 | new VelocityProxyPlayerContainer(event.getPlayer(), 73 | AP_CHANNEL)); 74 | }); 75 | } 76 | 77 | @Subscribe 78 | public void onDisconnect(DisconnectEvent event) { 79 | this.proxyCore.onPlayerDisconnect( 80 | new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL)); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.spigot.commands.subcommands.portal; 2 | 3 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 8 | import com.sekwah.advancedportals.core.services.DestinationServices; 9 | import com.sekwah.advancedportals.core.services.PortalServices; 10 | import com.sekwah.advancedportals.core.util.Lang; 11 | import com.sekwah.advancedportals.shadowed.inject.Inject; 12 | import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; 13 | import com.sekwah.advancedportals.spigot.importer.ConfigAccessor; 14 | import com.sekwah.advancedportals.spigot.importer.LegacyImporter; 15 | import java.util.List; 16 | import java.util.Set; 17 | import org.bukkit.configuration.file.FileConfiguration; 18 | 19 | public class ImportPortalSubCommand implements SubCommand { 20 | @Inject 21 | private AdvancedPortalsCore portalsCore; 22 | 23 | @Inject 24 | DestinationServices destinationServices; 25 | 26 | @Inject 27 | PortalServices portalServices; 28 | 29 | @Inject 30 | ConfigRepository configRepo; 31 | 32 | @Override 33 | public void onCommand(CommandSenderContainer sender, String[] args) { 34 | if (args.length > 1 && "confirm".equals(args[1])) { 35 | sender.sendMessage(Lang.getPositivePrefix() 36 | + Lang.translateInsertVariables( 37 | "command.portal.import.confirm")); 38 | int destinations = 39 | LegacyImporter.importDestinations(destinationServices); 40 | int portals = LegacyImporter.importPortals(portalServices); 41 | LegacyImporter.importConfig(this.configRepo); 42 | 43 | portalsCore.loadPortalConfig(); 44 | portalServices.loadPortals(); 45 | destinationServices.loadDestinations(); 46 | 47 | sender.sendMessage( 48 | Lang.getPositivePrefix() 49 | + Lang.translateInsertVariables( 50 | "command.portal.import.complete", portals, destinations)); 51 | return; 52 | } 53 | sender.sendMessage(Lang.getPositivePrefix() 54 | + Lang.translateInsertVariables( 55 | "command.portal.import", getPortalCount(), 56 | getDestinationCount())); 57 | } 58 | 59 | public int getDestinationCount() { 60 | ConfigAccessor destiConfig = new ConfigAccessor( 61 | AdvancedPortalsPlugin.getInstance(), "destinations.yaml"); 62 | FileConfiguration config = destiConfig.getConfig(); 63 | Set destiSet = config.getKeys(false); 64 | 65 | return destiSet.size(); 66 | } 67 | 68 | public int getPortalCount() { 69 | ConfigAccessor portalConfig = new ConfigAccessor( 70 | AdvancedPortalsPlugin.getInstance(), "portals.yaml"); 71 | FileConfiguration config = portalConfig.getConfig(); 72 | Set portalSet = config.getKeys(false); 73 | 74 | return portalSet.size(); 75 | } 76 | 77 | @Override 78 | public boolean hasPermission(CommandSenderContainer sender) { 79 | return Permissions.IMPORT.hasPermission(sender); 80 | } 81 | 82 | @Override 83 | public List onTabComplete(CommandSenderContainer sender, 84 | String[] args) { 85 | return null; 86 | } 87 | 88 | @Override 89 | public String getBasicHelpText() { 90 | return Lang.translate("command.portal.import.help"); 91 | } 92 | 93 | @Override 94 | public String getDetailedHelpText() { 95 | return Lang.translate("command.portal.import.detailedhelp"); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PortalRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.core.repository.impl; 2 | 3 | import com.google.inject.Inject; 4 | import com.google.inject.Singleton; 5 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 6 | import com.sekwah.advancedportals.core.portal.AdvancedPortal; 7 | import com.sekwah.advancedportals.core.repository.IPortalRepository; 8 | import com.sekwah.advancedportals.core.serializeddata.DataStorage; 9 | import com.sekwah.advancedportals.core.tags.NameTag; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | @Singleton 14 | public class PortalRepositoryImpl implements IPortalRepository { 15 | private final String fileLocation = "portals/"; 16 | 17 | @Inject 18 | DataStorage dataStorage; 19 | 20 | /** 21 | * In memory copy of the portal files as they will be accessed every 22 | * movement tick. 23 | * 24 | *

If we need to get it by name we can just load it from the file, but 25 | * this is good for looping fast for the player move events. 26 | */ 27 | private final List portals = new ArrayList<>(); 28 | 29 | private boolean isValidName(String name) { 30 | return name != null && !name.contains("/") && !name.contains("\\"); 31 | } 32 | 33 | @Override 34 | public boolean save(String name, AdvancedPortal portal) { 35 | if (!isValidName(name)) { 36 | throw new IllegalArgumentException("Invalid name: " + name); 37 | } 38 | return dataStorage.storeFile(portal, fileLocation + name + ".yaml"); 39 | } 40 | 41 | @Override 42 | public boolean containsKey(String name) { 43 | if (!isValidName(name)) { 44 | throw new IllegalArgumentException("Invalid name: " + name); 45 | } 46 | return dataStorage.fileExists(fileLocation + name + ".yaml"); 47 | } 48 | 49 | @Override 50 | public boolean delete(String name) { 51 | if (!isValidName(name)) { 52 | throw new IllegalArgumentException("Invalid name: " + name); 53 | } 54 | return dataStorage.deleteFile(fileLocation + name + ".yaml"); 55 | } 56 | 57 | @Override 58 | public AdvancedPortal get(String name) { 59 | if (!isValidName(name)) { 60 | throw new IllegalArgumentException("Invalid name: " + name); 61 | } 62 | AdvancedPortal portal = dataStorage.loadFile( 63 | AdvancedPortal.class, fileLocation + name + ".yaml"); 64 | if (portal != null) { 65 | AdvancedPortalsCore.getInstance() 66 | .getModule() 67 | .getInjector() 68 | .injectMembers(portal); 69 | } 70 | return portal; 71 | } 72 | 73 | @Override 74 | public List getAllNames() { 75 | return dataStorage.listAllFiles(fileLocation, true, "yaml"); 76 | } 77 | 78 | @Override 79 | public List getAll() { 80 | List portals = new ArrayList<>(); 81 | List allFiles = dataStorage.listAllFiles(fileLocation, false); 82 | for (String fileName : allFiles) { 83 | AdvancedPortal portal = dataStorage.loadFile( 84 | AdvancedPortal.class, fileLocation + fileName); 85 | 86 | if (portal != null) { 87 | AdvancedPortalsCore.getInstance() 88 | .getModule() 89 | .getInjector() 90 | .injectMembers(portal); 91 | } 92 | 93 | // Forces the name tag to be up-to-date on load 94 | String[] name = portal.getArgValues(NameTag.TAG_NAME); 95 | if (name != null && name.length > 0) { 96 | portal.setArgValues( 97 | NameTag.TAG_NAME, 98 | new String[] {fileName.replace(".yaml", "")}); 99 | } 100 | portals.add(portal); 101 | } 102 | return portals; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /discord.gradle: -------------------------------------------------------------------------------- 1 | import org.apache.http.HttpEntity 2 | import org.apache.http.client.methods.CloseableHttpResponse 3 | import org.apache.http.client.methods.HttpPost 4 | import org.apache.http.entity.ContentType 5 | import org.apache.http.entity.mime.MultipartEntityBuilder 6 | import org.apache.http.impl.client.CloseableHttpClient 7 | import org.apache.http.impl.client.HttpClients 8 | 9 | buildscript { 10 | repositories { 11 | mavenCentral() 12 | } 13 | dependencies { 14 | classpath "org.apache.httpcomponents:httpmime:4.5.13" 15 | } 16 | } 17 | 18 | apply from: rootProject.file('env-variables.gradle') 19 | apply from: rootProject.file('changelog-util.gradle') 20 | 21 | task discordupload { 22 | group = 'Distribute' 23 | dependsOn(jar) 24 | 25 | doLast { 26 | 27 | String discordWebhook = isRelease ? System.getenv("DISCORD_RELEASE_WEBHOOK") : System.getenv("DISCORD_WEBHOOK") 28 | 29 | if(discordWebhook != null) { 30 | def jarFile = file(jar.archiveFile) 31 | long fileSizeInBytes = jarFile.length() 32 | double fileSizeInMB = fileSizeInBytes / (1024.0 * 1024.0) 33 | 34 | println("Selected file: ${jarFile.name}") 35 | println("File size: ${String.format("%.2f", fileSizeInMB)} MB") 36 | 37 | CloseableHttpClient httpClient = HttpClients.createDefault() 38 | HttpPost uploadFile = new HttpPost(discordWebhook) 39 | 40 | MultipartEntityBuilder builder = MultipartEntityBuilder.create() 41 | if(!isRelease) { 42 | builder.addTextBody("content", "New snapshot or testing build") 43 | } else { 44 | def maxLength = 2000 45 | 46 | def content = "# New release build\n" + 47 | "${getReleaseChangelog()}\n" 48 | 49 | def downloadLink = "\n\n[Download here](https://modrinth.com/plugin/advanced-portals)" 50 | 51 | if(isRelease && content.length() + downloadLink.length() <= maxLength) { 52 | content += downloadLink 53 | } 54 | 55 | if (content.length() + downloadLink.length() > maxLength) { 56 | def afterMessage = "[See more on GitHub]()\n\n" 57 | 58 | def truncatedContent = content.replaceAll(/(http[s]?:\/\/[^\s)]+)/, '<$1>').take(maxLength - afterMessage.length() - 1) 59 | def lastFullLine = truncatedContent.lastIndexOf("\n") 60 | content = "${truncatedContent.take(lastFullLine)}\n" 61 | content += afterMessage 62 | content += downloadLink 63 | } 64 | 65 | builder.addTextBody("content", content, ContentType.create("text/plain", "UTF-8")) 66 | } 67 | 68 | if(!isRelease) { 69 | builder.addBinaryBody("file", file(jar.archiveFile).newInputStream(), ContentType.APPLICATION_OCTET_STREAM, jar.archiveName) 70 | } 71 | 72 | HttpEntity multipart = builder.build() 73 | 74 | uploadFile.setEntity(multipart) 75 | CloseableHttpResponse response = httpClient.execute(uploadFile) 76 | response.getEntity() 77 | 78 | if(response.getStatusLine().getStatusCode() != 200) { 79 | println("Failed to post build to Discord.") 80 | println("Status Code: " + response.getStatusLine().getStatusCode()) 81 | println("Reason Phrase: " + response.getStatusLine().getReasonPhrase()) 82 | 83 | String responseContent = response.getEntity() != null ? 84 | org.apache.http.util.EntityUtils.toString(response.getEntity()) : "No content" 85 | println("Response Content: " + responseContent) 86 | 87 | throw new RuntimeException("Failed to post build to Discord") 88 | } 89 | 90 | println("Posted build") 91 | 92 | } else { 93 | println("Discord webhook unspecified") 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/commands/subcommands/portal/ImportPortalSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.sekwah.advancedportals.legacyspigot.commands.subcommands.portal; 2 | 3 | import com.sekwah.advancedportals.core.AdvancedPortalsCore; 4 | import com.sekwah.advancedportals.core.commands.SubCommand; 5 | import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; 6 | import com.sekwah.advancedportals.core.permissions.Permissions; 7 | import com.sekwah.advancedportals.core.repository.ConfigRepository; 8 | import com.sekwah.advancedportals.core.services.DestinationServices; 9 | import com.sekwah.advancedportals.core.services.PortalServices; 10 | import com.sekwah.advancedportals.core.util.Lang; 11 | import com.sekwah.advancedportals.legacyspigot.AdvancedPortalsPlugin; 12 | import com.sekwah.advancedportals.legacyspigot.importer.ConfigAccessor; 13 | import com.sekwah.advancedportals.legacyspigot.importer.LegacyImporter; 14 | import com.sekwah.advancedportals.shadowed.inject.Inject; 15 | import java.util.List; 16 | import java.util.Set; 17 | import org.bukkit.configuration.file.FileConfiguration; 18 | 19 | public class ImportPortalSubCommand implements SubCommand { 20 | @Inject 21 | private AdvancedPortalsCore portalsCore; 22 | 23 | @Inject 24 | DestinationServices destinationServices; 25 | 26 | @Inject 27 | PortalServices portalServices; 28 | 29 | @Inject 30 | ConfigRepository configRepo; 31 | 32 | @Override 33 | public void onCommand(CommandSenderContainer sender, String[] args) { 34 | if (args.length > 1 && "confirm".equals(args[1])) { 35 | sender.sendMessage(Lang.getPositivePrefix() 36 | + Lang.translateInsertVariables( 37 | "command.portal.import.confirm")); 38 | int destinations = 39 | LegacyImporter.importDestinations(destinationServices); 40 | int portals = LegacyImporter.importPortals(portalServices); 41 | LegacyImporter.importConfig(this.configRepo); 42 | 43 | portalsCore.loadPortalConfig(); 44 | portalServices.loadPortals(); 45 | destinationServices.loadDestinations(); 46 | 47 | sender.sendMessage( 48 | Lang.getPositivePrefix() 49 | + Lang.translateInsertVariables( 50 | "command.portal.import.complete", portals, destinations)); 51 | return; 52 | } 53 | sender.sendMessage(Lang.getPositivePrefix() 54 | + Lang.translateInsertVariables( 55 | "command.portal.import", getPortalCount(), 56 | getDestinationCount())); 57 | } 58 | 59 | public int getDestinationCount() { 60 | ConfigAccessor destiConfig = new ConfigAccessor( 61 | AdvancedPortalsPlugin.getInstance(), "destinations.yaml"); 62 | FileConfiguration config = destiConfig.getConfig(); 63 | Set destiSet = config.getKeys(false); 64 | 65 | return destiSet.size(); 66 | } 67 | 68 | public int getPortalCount() { 69 | ConfigAccessor portalConfig = new ConfigAccessor( 70 | AdvancedPortalsPlugin.getInstance(), "portals.yaml"); 71 | FileConfiguration config = portalConfig.getConfig(); 72 | Set portalSet = config.getKeys(false); 73 | 74 | return portalSet.size(); 75 | } 76 | 77 | @Override 78 | public boolean hasPermission(CommandSenderContainer sender) { 79 | return Permissions.IMPORT.hasPermission(sender); 80 | } 81 | 82 | @Override 83 | public List onTabComplete(CommandSenderContainer sender, 84 | String[] args) { 85 | return null; 86 | } 87 | 88 | @Override 89 | public String getBasicHelpText() { 90 | return Lang.translate("command.portal.import.help"); 91 | } 92 | 93 | @Override 94 | public String getDetailedHelpText() { 95 | return Lang.translate("command.portal.import.detailedhelp"); 96 | } 97 | } 98 | --------------------------------------------------------------------------------