├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── proxy ├── bungeecord │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── bungee.yml │ │ │ └── java │ │ │ └── net │ │ │ └── labymod │ │ │ └── serverapi │ │ │ └── bungee │ │ │ ├── player │ │ │ ├── BungeeLabyModPlayer.java │ │ │ └── BungeeLabyModPlayerFactory.java │ │ │ ├── event │ │ │ ├── BungeeReceivePayloadEvent.java │ │ │ ├── BungeeMessageReceiveEvent.java │ │ │ └── BungeeSendPayloadEvent.java │ │ │ ├── BungeeLabyModPlugin.java │ │ │ ├── BungeeLabyDebugger.java │ │ │ └── BungeeLabyService.java │ └── build.gradle └── velocity │ ├── src │ └── main │ │ ├── resources │ │ └── velocity-plugin.json │ │ └── java │ │ └── net │ │ └── labymod │ │ └── serverapi │ │ └── velocity │ │ ├── player │ │ ├── VelocityLabyModPlayer.java │ │ └── VelocityLabyModPlayerFactory.java │ │ ├── event │ │ ├── VelocityMessageReceiveEvent.java │ │ ├── VelocityReceivePayloadEvent.java │ │ └── VelocitySendPayloadEvent.java │ │ ├── VelocityLabyDebugger.java │ │ ├── VelocityLabyModPlugin.java │ │ └── VelocityLabyService.java │ └── build.gradle ├── server ├── bukkit │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── plugin.yml │ │ │ └── java │ │ │ └── net │ │ │ └── labymod │ │ │ └── serverapi │ │ │ └── bukkit │ │ │ ├── event │ │ │ ├── BukkitLabyModEvent.java │ │ │ ├── BukkitReceivePayloadEvent.java │ │ │ ├── BukkitMessageReceiveEvent.java │ │ │ └── BukkitSendPayloadEvent.java │ │ │ ├── payload │ │ │ ├── transmitter │ │ │ │ └── exception │ │ │ │ │ └── InvalidMinecraftServerVersionException.java │ │ │ ├── BukkitPayloadCommunicator.java │ │ │ └── channel │ │ │ │ └── BukkitLegacyLabyModPayloadChannel.java │ │ │ ├── player │ │ │ ├── BukkitLabyModPlayer.java │ │ │ └── BukkitLabyModPlayerFactory.java │ │ │ ├── BukkitLabyModPlugin.java │ │ │ ├── BukkitLabyDebugger.java │ │ │ └── BukkitLabyService.java │ └── build.gradle ├── sponge │ └── build.gradle └── minestom │ └── build.gradle.kts ├── .idea └── google-java-format.xml ├── gradle.properties ├── labymod-api ├── src │ └── main │ │ └── java │ │ └── net │ │ └── labymod │ │ └── serverapi │ │ └── api │ │ ├── payload │ │ ├── PayloadChannelType.java │ │ ├── PayloadBuffer.java │ │ ├── PayloadChannelRegistrar.java │ │ └── PayloadCommunicator.java │ │ ├── serverinteraction │ │ ├── actionmenu │ │ │ ├── ActionType.java │ │ │ ├── MenuTransmitter.java │ │ │ ├── MenuEntry.java │ │ │ └── Menu.java │ │ ├── economy │ │ │ ├── EconomyBalanceType.java │ │ │ ├── EconomyDisplayTransmitter.java │ │ │ └── EconomyDisplay.java │ │ ├── TabListCache.java │ │ ├── WatermarkTransmitter.java │ │ ├── CineScopes.java │ │ ├── Watermark.java │ │ ├── CineScopesTransmitter.java │ │ ├── subtile │ │ │ ├── SubTitleTransmitter.java │ │ │ └── SubTitle.java │ │ ├── TabListCacheTransmitter.java │ │ ├── addon │ │ │ ├── AddonRecommendationTransmitter.java │ │ │ ├── RecommendedAddon.java │ │ │ └── AddonRecommendation.java │ │ ├── ServerSwitcherTransmitter.java │ │ ├── ServerSwitcher.java │ │ └── gui │ │ │ └── InputPromptTransmitter.java │ │ ├── protocol │ │ ├── Protocol.java │ │ ├── ShadowProtocol.java │ │ └── ChunkCachingProtocol.java │ │ ├── extension │ │ ├── Extension.java │ │ ├── PackageExtension.java │ │ ├── ModificationExtension.java │ │ ├── AddonExtension.java │ │ └── ExtensionCollector.java │ │ ├── LabyAPI.java │ │ ├── emote │ │ ├── Emote.java │ │ └── EmoteTransmitter.java │ │ ├── sticker │ │ ├── Sticker.java │ │ └── StickerTransmitter.java │ │ ├── labychat │ │ ├── PlayingGameModeTransmitter.java │ │ └── PlayingGameMode.java │ │ ├── permission │ │ └── Permissible.java │ │ ├── LabyDebugger.java │ │ ├── player │ │ └── LabyModPlayerService.java │ │ └── connection │ │ └── ConnectionService.java └── build.gradle ├── settings.gradle ├── labymod-common ├── build.gradle └── src │ └── main │ └── java │ └── net │ └── labymod │ └── serverapi │ └── common │ ├── emote │ ├── DefaultEmoteFactory.java │ ├── DefaultEmote.java │ └── DefaultEmoteTransmitter.java │ ├── protocol │ ├── DefaultShadowProtocolFactory.java │ ├── DefaultChunkCachingProtocolFactory.java │ ├── DefaultShadowProtocol.java │ └── DefaultChunkCachingProtocol.java │ ├── extension │ ├── DefaultPackageExtensionFactory.java │ ├── DefaultAddonExtensionFactory.java │ ├── DefaultModificationExtensionFactory.java │ ├── DefaultPackageExtensionCollector.java │ ├── DefaultPackageExtension.java │ ├── DefaultAddonExtension.java │ ├── DefaultModificationExtension.java │ ├── DefaultAddonExtensionCollector.java │ └── DefaultModificationExtensionCollector.java │ ├── sticker │ ├── DefaultStickerFactory.java │ ├── DefaultSticker.java │ └── DefaultStickerTransmitter.java │ ├── AbstractLabyDebugger.java │ ├── serverinteraction │ ├── addon │ │ ├── DefaultRecommendedAddonFactory.java │ │ ├── DefaultRecommendedAddon.java │ │ ├── DefaultAddonRecommendation.java │ │ └── DefaultAddonRecommendationTransmitter.java │ ├── actionmenu │ │ ├── DefaultMenuEntryFactory.java │ │ ├── DefaultMenuEntry.java │ │ ├── DefaultMenu.java │ │ └── DefaultMenuTransmitter.java │ ├── subtitle │ │ ├── DefaultSubTitleFactory.java │ │ ├── DefaultSubTitleTransmitter.java │ │ └── DefaultSubTitle.java │ ├── DefaultWatermark.java │ ├── DefaultWatermarkTransmitter.java │ ├── DefaultServerSwitcher.java │ ├── DefaultServerSwitcherTransmitter.java │ ├── DefaultTabListCacheTransmitter.java │ ├── DefaultTabListCache.java │ ├── DefaultCineScopes.java │ ├── DefaultCineScopesTransmitter.java │ ├── economy │ │ ├── DefaultEconomyDisplayTransmitter.java │ │ └── DefaultEconomyDisplay.java │ └── gui │ │ └── DefaultInputPromptTransmitter.java │ ├── payload │ └── DefaultPayloadBufferFactory.java │ ├── permission │ ├── DefaultPermissionFactory.java │ └── DefaultPermission.java │ ├── labychat │ ├── DefaultPlayingGameMode.java │ └── DefaultPlayingGameModeTransmitter.java │ ├── player │ ├── DefaultLabyModPlayerService.java │ ├── DefaultLabyModPlayerFactory.java │ └── DefaultLabyModPlayer.java │ └── discord │ └── DefaultRichPresenceTransmitter.java ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── gradle.yml ├── README.md ├── LICENSE.md ├── .gitignore └── gradlew.bat /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LabyMod/labymod3-server-api/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | name: LabyApi 2 | main: net.labymod.serverapi.bungee.BungeeLabyModPlugin 3 | version: ${version} 4 | author: LabyMedia GmbH -------------------------------------------------------------------------------- /server/bukkit/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: LabyApi 2 | author: LabyMedia GmbH 3 | version: ${version} 4 | main: net.labymod.serverapi.bukkit.BukkitLabyModPlugin 5 | depend: 6 | - ProtocolLib -------------------------------------------------------------------------------- /.idea/google-java-format.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/resources/velocity-plugin.json: -------------------------------------------------------------------------------- 1 | {"id":"laby_api","name":"LabyApi","version":"${version}","authors":["LabyMedia GmbH"],"dependencies":[],"main":"net.labymod.serverapi.velocity.VelocityLabyModPlugin"} -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION = 2.0.2 2 | org.gradle.jvmargs=-Xmx4G -Dfile.encoding=UTF-8 -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:+UseStringCache -XX:+OptimizeStringConcat -Dhttp.keepAlive=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/payload/PayloadChannelType.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.payload; 2 | 3 | /** An enumeration that representing all available payload channel types. */ 4 | public enum PayloadChannelType { 5 | LEGACY, 6 | MODERN 7 | } 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "LabyApi" 2 | 3 | // Server API 4 | include("labymod-api") 5 | include("labymod-common") 6 | 7 | // Proxies 8 | include("proxy:velocity") 9 | include("proxy:bungeecord") 10 | 11 | // Servers 12 | include("server:bukkit") 13 | //include("server:minestom") 14 | include("server:sponge") -------------------------------------------------------------------------------- /labymod-common/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | java { 10 | sourceCompatibility = JavaVersion.VERSION_1_8 11 | targetCompatibility = JavaVersion.VERSION_1_8 12 | } 13 | 14 | dependencies { 15 | compile(project(":labymod-api")) 16 | } -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/actionmenu/ActionType.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.actionmenu; 2 | 3 | /** An enumeration that representing all available action types for the action menu. */ 4 | public enum ActionType { 5 | NONE, 6 | CLIPBOARD, 7 | RUN_COMMAND, 8 | SUGGEST_COMMAND, 9 | OPEN_BROWSER 10 | } 11 | -------------------------------------------------------------------------------- /server/sponge/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | jcenter() 8 | 9 | maven { 10 | name = "sponge-repository" 11 | url = uri("https://repo.spongepowered.org/maven") 12 | } 13 | } 14 | 15 | dependencies { 16 | compileOnly(project(":labymod-common")) 17 | compileOnly("org.spongepowered:spongeapi:7.2.0") 18 | } -------------------------------------------------------------------------------- /labymod-api/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | java { 10 | sourceCompatibility = JavaVersion.VERSION_1_8 11 | targetCompatibility = JavaVersion.VERSION_1_8 12 | } 13 | 14 | dependencies { 15 | compile("io.netty:netty-all:4.1.54.Final") 16 | compile("com.google.code.gson:gson:2.8.6") 17 | compile("com.google.guava:guava:21.0") 18 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | | Q | A 2 | | ---------------- | ----- 3 | | Bug report? | yes/no 4 | | Feature request? | yes/no 5 | | BC Break report? | yes/no 6 | | RFC? | yes/no 7 | 8 | 13 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/emote/DefaultEmoteFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.emote; 2 | 3 | import net.labymod.serverapi.api.emote.Emote; 4 | 5 | import java.util.UUID; 6 | 7 | public class DefaultEmoteFactory implements Emote.Factory { 8 | 9 | @Override 10 | public Emote create(UUID npcUniqueId, int emoteId) { 11 | return new DefaultEmote(npcUniqueId, emoteId); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | | Q | A 2 | | ------------- | --- 3 | | Bug fix? | yes/no 4 | | New feature? | yes/no 5 | | BC breaks? | no 6 | | Deprecations? | yes/no 7 | | Fixed tickets | #... 8 | 9 | 13 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/protocol/DefaultShadowProtocolFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.protocol; 2 | 3 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 4 | 5 | public class DefaultShadowProtocolFactory implements ShadowProtocol.Factory { 6 | 7 | @Override 8 | public ShadowProtocol create(int version, boolean enabled) { 9 | return new DefaultShadowProtocol(version, enabled); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultPackageExtensionFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import net.labymod.serverapi.api.extension.PackageExtension; 4 | 5 | public class DefaultPackageExtensionFactory implements PackageExtension.Factory { 6 | 7 | @Override 8 | public PackageExtension create(String name, String version) { 9 | return new DefaultPackageExtension(name, version); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/sticker/DefaultStickerFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.sticker; 2 | 3 | import net.labymod.serverapi.api.sticker.Sticker; 4 | 5 | import java.util.UUID; 6 | 7 | public class DefaultStickerFactory implements Sticker.Factory { 8 | 9 | /** {@inheritDoc} */ 10 | @Override 11 | public Sticker create(UUID npcUniqueId, short stickerId) { 12 | return new DefaultSticker(npcUniqueId, stickerId); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultAddonExtensionFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import net.labymod.serverapi.api.extension.AddonExtension; 4 | 5 | import java.util.UUID; 6 | 7 | public class DefaultAddonExtensionFactory implements AddonExtension.Factory { 8 | 9 | @Override 10 | public AddonExtension create(String name, UUID uniqueId) { 11 | return new DefaultAddonExtension(name, uniqueId); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/protocol/DefaultChunkCachingProtocolFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.protocol; 2 | 3 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 4 | 5 | public class DefaultChunkCachingProtocolFactory implements ChunkCachingProtocol.Factory { 6 | 7 | @Override 8 | public ChunkCachingProtocol create(int version, boolean enabled) { 9 | return new DefaultChunkCachingProtocol(version, enabled); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultModificationExtensionFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import net.labymod.serverapi.api.extension.ModificationExtension; 4 | 5 | public class DefaultModificationExtensionFactory implements ModificationExtension.Factory { 6 | 7 | @Override 8 | public ModificationExtension create(String name, String identifier) { 9 | return new DefaultModificationExtension(name, identifier); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/protocol/Protocol.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.protocol; 2 | 3 | /** Represents a LabyMod protocol. */ 4 | public interface Protocol { 5 | 6 | /** 7 | * Retrieves the version of this protocol. 8 | * 9 | * @return The version of this protocol. 10 | */ 11 | int getVersion(); 12 | 13 | /** 14 | * Whether the protocol is enabled. 15 | * 16 | * @return {@code true} if the protocol is enabled, otherwise {@code false.} 17 | */ 18 | boolean isEnabled(); 19 | } 20 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/AbstractLabyDebugger.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common; 2 | 3 | import net.labymod.serverapi.api.LabyDebugger; 4 | 5 | public abstract class AbstractLabyDebugger implements LabyDebugger { 6 | 7 | private boolean debug; 8 | 9 | /** {@inheritDoc} */ 10 | @Override 11 | public boolean isDebug() { 12 | return this.debug; 13 | } 14 | 15 | /** {@inheritDoc} */ 16 | @Override 17 | public void setDebug(boolean debug) { 18 | this.debug = debug; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/addon/DefaultRecommendedAddonFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.addon; 2 | 3 | import net.labymod.serverapi.api.serverinteraction.addon.RecommendedAddon; 4 | import java.util.UUID; 5 | 6 | public class DefaultRecommendedAddonFactory implements RecommendedAddon.Factory { 7 | 8 | @Override 9 | public RecommendedAddon create(UUID publishedUniqueId, boolean required) { 10 | return new DefaultRecommendedAddon(publishedUniqueId, required); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/economy/EconomyBalanceType.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.economy; 2 | 3 | /** An enumeration that representing all available economy balance types. */ 4 | public enum EconomyBalanceType { 5 | CASH, 6 | BANK; 7 | 8 | /** 9 | * Retrieves the name of the economy balance type as lowercase name. 10 | * 11 | * @return The name of the economy balance type as lowercase name. 12 | */ 13 | public String getKey() { 14 | return this.name().toLowerCase(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/payload/DefaultPayloadBufferFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.payload; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.labymod.serverapi.api.payload.PayloadBuffer; 5 | 6 | public class DefaultPayloadBufferFactory implements PayloadBuffer.Factory { 7 | 8 | @Override 9 | public PayloadBuffer create() { 10 | return new DefaultPayloadBuffer(); 11 | } 12 | 13 | @Override 14 | public PayloadBuffer create(ByteBuf byteBuf) { 15 | return new DefaultPayloadBuffer(byteBuf); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/actionmenu/DefaultMenuEntryFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.actionmenu; 2 | 3 | import net.labymod.serverapi.api.serverinteraction.actionmenu.ActionType; 4 | import net.labymod.serverapi.api.serverinteraction.actionmenu.MenuEntry; 5 | 6 | public class DefaultMenuEntryFactory implements MenuEntry.Factory { 7 | 8 | @Override 9 | public MenuEntry create(String displayName, String value, ActionType actionType) { 10 | return new DefaultMenuEntry(displayName, value, actionType); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/event/BukkitLabyModEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.event; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | /** Represents the base event for bukkit. */ 7 | public class BukkitLabyModEvent extends Event { 8 | 9 | private static final HandlerList HANDLER_LIST = new HandlerList(); 10 | 11 | public static HandlerList getHandlerList() { 12 | return HANDLER_LIST; 13 | } 14 | 15 | /** {@inheritDoc} */ 16 | @Override 17 | public HandlerList getHandlers() { 18 | return HANDLER_LIST; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/permission/DefaultPermissionFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.permission; 2 | 3 | import net.labymod.serverapi.api.permission.Permissible; 4 | 5 | public class DefaultPermissionFactory implements Permissible.Factory { 6 | 7 | @Override 8 | public Permissible create(String internalName, String name) { 9 | return new DefaultPermission(internalName, name); 10 | } 11 | 12 | @Override 13 | public Permissible create(String internalName, String name, boolean enabled) { 14 | return new DefaultPermission(internalName, name, enabled); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/extension/Extension.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.extension; 2 | 3 | /** 4 | * Represents an addon, modification or package. 5 | * 6 | * @param The name of the extension. 7 | * @param The identifier of the extension. 8 | */ 9 | public interface Extension { 10 | 11 | /** 12 | * Retrieves the name of the extension. 13 | * 14 | * @return The extension name. 15 | */ 16 | A getName(); 17 | 18 | /** 19 | * Retrieves the identifier of the extension. 20 | * 21 | * @return The extension identifier. 22 | */ 23 | B getIdentifier(); 24 | } 25 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/extension/PackageExtension.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.extension; 2 | 3 | 4 | 5 | public interface PackageExtension extends Extension { 6 | 7 | /** A factory for creating {@link PackageExtension}'s. */ 8 | interface Factory { 9 | 10 | /** 11 | * Creates a new {@link PackageExtension} with the {@code name} and {@code version}. 12 | * 13 | * @param name The name of the package. 14 | * @param version The version of the package. 15 | * @return A created package extension. 16 | */ 17 | PackageExtension create(String name, String version); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/extension/ModificationExtension.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.extension; 2 | 3 | /** Represents a modification of the forge mod loader. */ 4 | public interface ModificationExtension extends Extension { 5 | 6 | /** A factory for creating {@link ModificationExtension}'s. */ 7 | interface Factory { 8 | 9 | /** 10 | * Creates a new {@link ModificationExtension} 11 | * 12 | * @param name The name of the modification. 13 | * @param identifier The identifier of the modification. 14 | * @return A created modification extension. 15 | */ 16 | ModificationExtension create(String name, String identifier); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LabyMod Server API 2 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/LabyMod/labymod-server-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/LabyMod/labymod-server-api/?branch=master) 3 | [![Discord](https://img.shields.io/discord/412724944112320513.svg)](https://labymod.net/dc/dev) 4 | [![CLA assistant](https://cla-assistant.io/readme/badge/LabyMod/labymod-server-api)](https://cla-assistant.io/LabyMod/labymod-server-api) 5 | 6 | Our new Server API allows you to communicate between the LabyMod client and the server by using simple JSON messages. It also allows you to enable or disable LabyMod features. 7 | If you want to find out how our API works, visit https://docs.labymod.net/pages/server/introduction/ 8 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/extension/AddonExtension.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.extension; 2 | 3 | 4 | import java.util.UUID; 5 | 6 | /** Represents an addon of the LabyMod. */ 7 | public interface AddonExtension extends Extension { 8 | 9 | /** A factory for creating {@link AddonExtension}'s. */ 10 | interface Factory { 11 | 12 | /** 13 | * Creates an new {@link AddonExtension} with the given {@code name} and {@code uniqueId}. 14 | * 15 | * @param name The name of the addon. 16 | * @param uniqueId The unique identifier of the addon. 17 | * @return A created addon extension. 18 | */ 19 | AddonExtension create(String name, UUID uniqueId); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/protocol/DefaultShadowProtocol.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.protocol; 2 | 3 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 4 | 5 | public class DefaultShadowProtocol implements ShadowProtocol { 6 | 7 | private final int version; 8 | private final boolean enabled; 9 | 10 | protected DefaultShadowProtocol(int version, boolean enabled) { 11 | this.version = version; 12 | this.enabled = enabled; 13 | } 14 | 15 | /** {@inheritDoc} */ 16 | @Override 17 | public int getVersion() { 18 | return this.version; 19 | } 20 | 21 | /** {@inheritDoc} */ 22 | @Override 23 | public boolean isEnabled() { 24 | return this.enabled; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/protocol/ShadowProtocol.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.protocol; 2 | 3 | /** Represents the shadow protocol. */ 4 | public interface ShadowProtocol extends Protocol { 5 | 6 | /** A factory for creating {@link ShadowProtocol}'s. */ 7 | interface Factory { 8 | 9 | /** 10 | * Creates a new {@link ShadowProtocol} with the {@code version} and whether it is {@code 11 | * enabled}. 12 | * 13 | * @param version The version of the shadow protocol. 14 | * @param enabled {@code true} if the shadow protocol enabled, otherwise {@code false}. 15 | * @return A created shadow protocol. 16 | */ 17 | ShadowProtocol create(int version, boolean enabled); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /proxy/bungeecord/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = "bungeecord-repository" 9 | url = uri("https://oss.sonatype.org/content/repositories/snapshots/") 10 | } 11 | } 12 | 13 | dependencies { 14 | compile(project(":labymod-common")) 15 | compileOnly("net.md-5:bungeecord-api:1.16-R0.5-SNAPSHOT") 16 | } 17 | 18 | processResources { 19 | inputs.property "version", rootProject.version 20 | 21 | from(sourceSets.main.resources.srcDirs) { 22 | include "bungee.yml" 23 | 24 | expand 'version': rootProject.version 25 | } 26 | 27 | from(sourceSets.main.resources.srcDirs) { 28 | exclude "bungee.yml" 29 | } 30 | } -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | name: Gradle build 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Set up JDK 8 17 | uses: actions/setup-java@v1 18 | with: 19 | java-version: '8' 20 | - name: Grant execute permission for gradlew 21 | run: chmod +x gradlew 22 | - name: Clean 23 | run: ./gradlew clean 24 | - name: Build with Gradle 25 | run: ./gradlew shadowJar 26 | - name: Upload jar 27 | uses: actions/upload-artifact@v2 28 | with: 29 | name: Artifacts 30 | path: build/libs/*.jar -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/protocol/DefaultChunkCachingProtocol.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.protocol; 2 | 3 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 4 | 5 | public class DefaultChunkCachingProtocol implements ChunkCachingProtocol { 6 | 7 | private final int version; 8 | private final boolean enabled; 9 | 10 | protected DefaultChunkCachingProtocol(int version, boolean enabled) { 11 | this.version = version; 12 | this.enabled = enabled; 13 | } 14 | 15 | /** {@inheritDoc} */ 16 | @Override 17 | public int getVersion() { 18 | return this.version; 19 | } 20 | 21 | /** {@inheritDoc} */ 22 | @Override 23 | public boolean isEnabled() { 24 | return this.enabled; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/extension/ExtensionCollector.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.extension; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Represents a collector that collects all {@link Extension} as {@link List} from the specified 9 | * {@link JsonObject}. 10 | * 11 | * @param The extension type to be collected. 12 | */ 13 | public interface ExtensionCollector> { 14 | 15 | /** 16 | * Collects all {@link Extension} as {@link List} from the given {@link JsonObject}. 17 | * 18 | * @param object The json object, which contains all extensions. 19 | * @return A collection with all collected extensions. 20 | */ 21 | List collect(JsonObject object); 22 | } 23 | -------------------------------------------------------------------------------- /server/minestom/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | java { 6 | sourceCompatibility = JavaVersion.VERSION_11 7 | targetCompatibility = JavaVersion.VERSION_11 8 | } 9 | 10 | 11 | repositories { 12 | mavenCentral(); 13 | jcenter(); 14 | 15 | maven { 16 | name = "sponge-repository" 17 | url = uri("https://repo.spongepowered.org/maven") 18 | } 19 | 20 | 21 | maven { 22 | name = "minecraft-repository" 23 | url = uri("https://libraries.minecraft.net") 24 | } 25 | 26 | 27 | maven { 28 | name = "jitpack" 29 | url = uri("https://jitpack.io") 30 | } 31 | } 32 | 33 | dependencies { 34 | api(project(":labymod-common")) 35 | api("com.github.Minestom", "Minestom","91a000ab31") 36 | } -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/protocol/ChunkCachingProtocol.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.protocol; 2 | 3 | /** Represents the chunk caching protocol. */ 4 | public interface ChunkCachingProtocol extends Protocol { 5 | 6 | /** A factory for creating {@link ChunkCachingProtocol}'s. */ 7 | interface Factory { 8 | 9 | /** 10 | * Creates a new {@link ChunkCachingProtocol} with the {@code version} and whether it is {@code 11 | * enabled}. 12 | * 13 | * @param version The version of the chunk caching protocol. 14 | * @param enabled {@code true} if the chunk caching protocol enabled, otherwise {@code false}. 15 | * @return A created chunk caching protocol. 16 | */ 17 | ChunkCachingProtocol create(int version, boolean enabled); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/TabListCache.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** @deprecated Use {@link TabListCache} */ 6 | @Deprecated 7 | public interface TabListCache { 8 | 9 | /** @deprecated Use {@link TabListCacheTransmitter#isEnabled()} */ 10 | @Deprecated 11 | boolean isEnabled(); 12 | 13 | /** @deprecated Use {@link TabListCacheTransmitter#setEnabled(boolean)} */ 14 | @Deprecated 15 | void setEnabled(boolean enabled); 16 | 17 | /** @deprecated Use {@link TabListCacheTransmitter#transmit(UUID)} */ 18 | @Deprecated 19 | void transmit(UUID uniqueId); 20 | 21 | /** @deprecated Use {@link TabListCacheTransmitter#transmitBroadcast()} */ 22 | @Deprecated 23 | void transmitBroadcast(); 24 | } 25 | -------------------------------------------------------------------------------- /proxy/velocity/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = "velocity-repository" 9 | url = uri("https://repo.velocitypowered.com/snapshots/") 10 | } 11 | } 12 | 13 | dependencies { 14 | annotationProcessor("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT") 15 | compileOnly(project(":labymod-common")) 16 | compileOnly("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT") 17 | } 18 | 19 | processResources { 20 | inputs.property "version", rootProject.version 21 | 22 | from(sourceSets.main.resources.srcDirs) { 23 | include "velocity-plugin.json" 24 | 25 | expand 'version': rootProject.version 26 | } 27 | 28 | from(sourceSets.main.resources.srcDirs) { 29 | exclude "velocity-plugin.json" 30 | } 31 | } -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultPackageExtensionCollector.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.extension.ExtensionCollector; 5 | import net.labymod.serverapi.api.extension.PackageExtension; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | public class DefaultPackageExtensionCollector implements ExtensionCollector { 11 | 12 | private final PackageExtension.Factory packageExtensionFactory; 13 | 14 | public DefaultPackageExtensionCollector() { 15 | this.packageExtensionFactory = new DefaultPackageExtensionFactory(); 16 | } 17 | 18 | /** {@inheritDoc} */ 19 | @Override 20 | public List collect(JsonObject object) { 21 | // TODO: 29.11.2020 Implementation 22 | return Collections.emptyList(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/payload/transmitter/exception/InvalidMinecraftServerVersionException.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.payload.transmitter.exception; 2 | 3 | public class InvalidMinecraftServerVersionException extends RuntimeException { 4 | 5 | public InvalidMinecraftServerVersionException() {} 6 | 7 | public InvalidMinecraftServerVersionException(String message) { 8 | super(message); 9 | } 10 | 11 | public InvalidMinecraftServerVersionException(String message, Throwable cause) { 12 | super(message, cause); 13 | } 14 | 15 | public InvalidMinecraftServerVersionException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | public InvalidMinecraftServerVersionException( 20 | String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 21 | super(message, cause, enableSuppression, writableStackTrace); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/LabyAPI.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api; 2 | 3 | public final class LabyAPI { 4 | 5 | private static LabyService service; 6 | 7 | /** 8 | * Initializes the {@link LabyService} associated with the currently running platform. 9 | * 10 | * @param service The laby service. 11 | */ 12 | public static void initialize(LabyService service) { 13 | LabyAPI.service = service; 14 | } 15 | 16 | /** 17 | * Retrieves the laby service associated with the currently running platform. 18 | * 19 | * @return The laby service associated with the currently running platform. 20 | */ 21 | public static LabyService getService() { 22 | return LabyAPI.service; 23 | } 24 | 25 | /** 26 | * Retrieves the debugger of the plugin. 27 | * 28 | * @return The plugin debugger. 29 | */ 30 | public static LabyDebugger getDebugger() { 31 | return LabyAPI.service.getLabyDebugger(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultPackageExtension.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import net.labymod.serverapi.api.extension.PackageExtension; 4 | 5 | /** Default implementation of the {@link PackageExtension}. */ 6 | public class DefaultPackageExtension implements PackageExtension { 7 | 8 | private final String name; 9 | private final String version; 10 | 11 | /** 12 | * Initializes a new {@link DefaultPackageExtension} with the {@code name} and {@code version}. 13 | * 14 | * @param name The name of the package. 15 | * @param version The version of the package. 16 | */ 17 | public DefaultPackageExtension(String name, String version) { 18 | this.name = name; 19 | this.version = version; 20 | } 21 | 22 | /** {@inheritDoc} */ 23 | @Override 24 | public String getName() { 25 | return this.name; 26 | } 27 | 28 | /** {@inheritDoc} */ 29 | @Override 30 | public String getIdentifier() { 31 | return this.version; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultAddonExtension.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import net.labymod.serverapi.api.extension.AddonExtension; 4 | 5 | import java.util.UUID; 6 | 7 | /** Default implementation of the {@link AddonExtension}. */ 8 | public class DefaultAddonExtension implements AddonExtension { 9 | 10 | private final String name; 11 | private final UUID uniqueId; 12 | 13 | /** 14 | * Initializes a new {@link DefaultAddonExtension} with the given {@code name} and {@code 15 | * uniqueId}. 16 | * 17 | * @param name the name of the addon. 18 | * @param uniqueId The unique identifier of the addon. 19 | */ 20 | public DefaultAddonExtension(String name, UUID uniqueId) { 21 | this.name = name; 22 | this.uniqueId = uniqueId; 23 | } 24 | 25 | /** {@inheritDoc} */ 26 | @Override 27 | public String getName() { 28 | return this.name; 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public UUID getIdentifier() { 34 | return this.uniqueId; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultModificationExtension.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import net.labymod.serverapi.api.extension.ModificationExtension; 4 | 5 | /** Default implementation of the {@link ModificationExtension}. */ 6 | public class DefaultModificationExtension implements ModificationExtension { 7 | 8 | private final String name; 9 | private final String identifier; 10 | 11 | /** 12 | * Initializes a new {@link DefaultModificationExtension} with the given {@code name} and {@code 13 | * identifier}. 14 | * 15 | * @param name The name of the modification. 16 | * @param identifier The identifier of the modification. 17 | */ 18 | public DefaultModificationExtension(String name, String identifier) { 19 | this.name = name; 20 | this.identifier = identifier; 21 | } 22 | 23 | /** {@inheritDoc} */ 24 | @Override 25 | public String getName() { 26 | return this.name; 27 | } 28 | 29 | /** {@inheritDoc} */ 30 | @Override 31 | public String getIdentifier() { 32 | return this.identifier; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/emote/DefaultEmote.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.emote; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.emote.Emote; 5 | 6 | import java.util.UUID; 7 | 8 | public class DefaultEmote implements Emote { 9 | 10 | private final UUID npcUniqueId; 11 | private final int emoteId; 12 | private final JsonObject emoteObject; 13 | 14 | public DefaultEmote(UUID npcUniqueId, int emoteId) { 15 | this.npcUniqueId = npcUniqueId; 16 | this.emoteId = emoteId; 17 | this.emoteObject = new JsonObject(); 18 | 19 | this.emoteObject.addProperty("uuid", npcUniqueId.toString()); 20 | this.emoteObject.addProperty("emote_id", emoteId); 21 | } 22 | 23 | /** {@inheritDoc} */ 24 | @Override 25 | public UUID getNPCUniqueId() { 26 | return this.npcUniqueId; 27 | } 28 | 29 | /** {@inheritDoc} */ 30 | @Override 31 | public int getEmoteId() { 32 | return this.emoteId; 33 | } 34 | 35 | /** {@inheritDoc} */ 36 | @Override 37 | public JsonObject asJsonObject() { 38 | return this.emoteObject; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/subtitle/DefaultSubTitleFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.subtitle; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.serverinteraction.subtile.SubTitle; 5 | 6 | import java.util.UUID; 7 | 8 | public class DefaultSubTitleFactory implements SubTitle.Factory { 9 | 10 | /** {@inheritDoc} */ 11 | @Override 12 | public SubTitle create(UUID uniqueId, String value) { 13 | return new DefaultSubTitle(uniqueId, value); 14 | } 15 | 16 | /** {@inheritDoc} */ 17 | @Override 18 | public SubTitle create(UUID uniqueId, JsonObject rawText) { 19 | return new DefaultSubTitle(uniqueId, rawText); 20 | } 21 | 22 | /** {@inheritDoc} */ 23 | @Override 24 | public SubTitle create(UUID uniqueId, String value, double size) { 25 | return new DefaultSubTitle(uniqueId, value, size); 26 | } 27 | 28 | /** {@inheritDoc} */ 29 | @Override 30 | public SubTitle create(UUID uniqueId, JsonObject rawText, double size) { 31 | return new DefaultSubTitle(uniqueId, rawText, size); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 LabyMedia GmbH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/sticker/DefaultSticker.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.sticker; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.sticker.Sticker; 5 | 6 | import java.util.UUID; 7 | 8 | public class DefaultSticker implements Sticker { 9 | 10 | private final UUID npcUniqueId; 11 | private final short stickerId; 12 | private final JsonObject stickerObject; 13 | 14 | protected DefaultSticker(UUID npcUniqueId, short stickerId) { 15 | this.npcUniqueId = npcUniqueId; 16 | this.stickerId = stickerId; 17 | this.stickerObject = new JsonObject(); 18 | this.stickerObject.addProperty("uuid", npcUniqueId.toString()); 19 | this.stickerObject.addProperty("sticker_id", stickerId); 20 | } 21 | 22 | /** {@inheritDoc} */ 23 | @Override 24 | public UUID getNPCUniqueId() { 25 | return this.npcUniqueId; 26 | } 27 | 28 | /** {@inheritDoc} */ 29 | @Override 30 | public short getStickerId() { 31 | return this.stickerId; 32 | } 33 | 34 | /** {@inheritDoc} */ 35 | @Override 36 | public JsonObject asJsonObject() { 37 | return this.stickerObject; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/WatermarkTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the watermark packet. 7 | * 8 | *

Overview: 9 | * 10 | *

This feature will show a LabyMod banner in the bottom right corner. It was made for LabyMod 11 | * tournaments. A special feature of this watermark is that the server can force an emote to the 12 | * player without changing the unique identifier. 13 | */ 14 | public interface WatermarkTransmitter { 15 | 16 | /** 17 | * Transmits the watermark packet to the client. 18 | * 19 | * @param uniqueId The unique identifier of the receiver. 20 | * @param showWatermark {@code true} if the watermark should be displayed, otherwise {@code 21 | * false}. 22 | */ 23 | void transmit(UUID uniqueId, boolean showWatermark); 24 | 25 | /** 26 | * Transmits the watermark packet to all online laby users. 27 | * 28 | * @param showWatermark {@code true} if the watermark should be displayed, otherwise {@code 29 | * false}. 30 | */ 31 | void broadcastTransmit(boolean showWatermark); 32 | } 33 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/emote/Emote.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.emote; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | import java.util.UUID; 6 | 7 | /** Represents an emote. */ 8 | public interface Emote { 9 | 10 | /** 11 | * Retrieves the unique identifier of a NPC where the emote is to be played. 12 | * 13 | * @return The unique identifier of a NPC. 14 | */ 15 | UUID getNPCUniqueId(); 16 | 17 | /** 18 | * Retrieves the identifier of an emote to be played. 19 | * 20 | * @return The identifier of an emote. 21 | */ 22 | int getEmoteId(); 23 | 24 | /** 25 | * Retrieves the emote as a {@link JsonObject}. 26 | * 27 | * @return The emote as a json object. 28 | */ 29 | JsonObject asJsonObject(); 30 | 31 | /** A factory for creating {@link Emote}. */ 32 | interface Factory { 33 | 34 | /** 35 | * Creates a new {@link Emote} with the {@code npcUniqueId} and the {@code emoteId}. 36 | * 37 | * @param npcUniqueId The unique identifier of a NPC. 38 | * @param emoteId The identifier of an emote. 39 | * @return A created emote. 40 | */ 41 | Emote create(UUID npcUniqueId, int emoteId); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/sticker/Sticker.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.sticker; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | import java.util.UUID; 6 | 7 | /** Represents a sticker. */ 8 | public interface Sticker { 9 | 10 | /** 11 | * Retrieves the unique identifier of a NPC where the sticker is to be played. 12 | * 13 | * @return The unique identifier of a NPC. 14 | */ 15 | UUID getNPCUniqueId(); 16 | 17 | /** 18 | * Retrieves the identifier of a sticker to be played. 19 | * 20 | * @return The identifier of a sticker. 21 | */ 22 | short getStickerId(); 23 | 24 | /** 25 | * Retrieves the sticker as a {@link JsonObject}. 26 | * 27 | * @return The sticker as a json object. 28 | */ 29 | JsonObject asJsonObject(); 30 | 31 | /** A factory for creating {@link Sticker}'s. */ 32 | interface Factory { 33 | 34 | /** 35 | * Creates a new {@link Sticker} with the {@code npcUniqueId} and the {@code stickerId}. 36 | * 37 | * @param npcUniqueId The unique identifier of a NPC. 38 | * @param stickerId The identifier of a sticker. 39 | * @return A created sticker. 40 | */ 41 | Sticker create(UUID npcUniqueId, short stickerId); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/player/BukkitLabyModPlayer.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.player; 2 | 3 | import net.labymod.serverapi.api.extension.AddonExtension; 4 | import net.labymod.serverapi.api.extension.ModificationExtension; 5 | import net.labymod.serverapi.api.extension.PackageExtension; 6 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 7 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 8 | import net.labymod.serverapi.common.player.DefaultLabyModPlayer; 9 | import org.bukkit.entity.Player; 10 | 11 | import java.util.List; 12 | 13 | public class BukkitLabyModPlayer extends DefaultLabyModPlayer { 14 | 15 | public BukkitLabyModPlayer( 16 | Player player, 17 | String version, 18 | ChunkCachingProtocol chunkCachingProtocol, 19 | ShadowProtocol shadowProtocol, 20 | List addons, 21 | List modifications, 22 | List packages) { 23 | super( 24 | player, 25 | player.getName(), 26 | player.getUniqueId(), 27 | version, 28 | chunkCachingProtocol, 29 | shadowProtocol, 30 | addons, 31 | modifications, 32 | packages); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/player/VelocityLabyModPlayer.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity.player; 2 | 3 | import com.velocitypowered.api.proxy.Player; 4 | import net.labymod.serverapi.api.extension.AddonExtension; 5 | import net.labymod.serverapi.api.extension.ModificationExtension; 6 | import net.labymod.serverapi.api.extension.PackageExtension; 7 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 8 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 9 | import net.labymod.serverapi.common.player.DefaultLabyModPlayer; 10 | 11 | import java.util.List; 12 | 13 | public class VelocityLabyModPlayer extends DefaultLabyModPlayer { 14 | 15 | public VelocityLabyModPlayer( 16 | Player player, 17 | String version, 18 | ChunkCachingProtocol chunkCachingProtocol, 19 | ShadowProtocol shadowProtocol, 20 | List addons, 21 | List modifications, 22 | List packages) { 23 | super( 24 | player, 25 | player.getUsername(), 26 | player.getUniqueId(), 27 | version, 28 | chunkCachingProtocol, 29 | shadowProtocol, 30 | addons, 31 | modifications, 32 | packages); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /server/bukkit/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = "bungeecord-repository" 9 | url = uri("https://oss.sonatype.org/content/repositories/snapshots/") 10 | } 11 | maven { 12 | name = "spigot-repository" 13 | url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") 14 | } 15 | 16 | maven { 17 | name = "dmulloy2" 18 | url = uri("https://repo.dmulloy2.net/nexus/repository/public/") 19 | } 20 | 21 | maven { 22 | name = "via-version" 23 | url = uri("https://repo.viaversion.com/") 24 | } 25 | 26 | 27 | } 28 | 29 | dependencies { 30 | compileOnly(project(":labymod-common")) 31 | compileOnly("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT") 32 | compileOnly("com.comphenix.protocol:ProtocolLib:4.5.0") 33 | compileOnly("org.lz4:lz4-java:1.4.1") 34 | } 35 | 36 | processResources { 37 | inputs.property "version", rootProject.version 38 | 39 | from(sourceSets.main.resources.srcDirs) { 40 | include "plugin.yml" 41 | 42 | expand 'version': rootProject.version 43 | } 44 | 45 | from(sourceSets.main.resources.srcDirs) { 46 | exclude "plugin.yml" 47 | } 48 | } -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/player/BungeeLabyModPlayer.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee.player; 2 | 3 | import net.labymod.serverapi.api.extension.AddonExtension; 4 | import net.labymod.serverapi.api.extension.ModificationExtension; 5 | import net.labymod.serverapi.api.extension.PackageExtension; 6 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 7 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 8 | import net.labymod.serverapi.common.player.DefaultLabyModPlayer; 9 | import net.md_5.bungee.api.connection.ProxiedPlayer; 10 | 11 | import java.util.List; 12 | 13 | public class BungeeLabyModPlayer extends DefaultLabyModPlayer { 14 | 15 | public BungeeLabyModPlayer( 16 | ProxiedPlayer player, 17 | String version, 18 | ChunkCachingProtocol chunkCachingProtocol, 19 | ShadowProtocol shadowProtocol, 20 | List addons, 21 | List modifications, 22 | List packages) { 23 | super( 24 | player, 25 | player.getName(), 26 | player.getUniqueId(), 27 | version, 28 | chunkCachingProtocol, 29 | shadowProtocol, 30 | addons, 31 | modifications, 32 | packages); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/event/BukkitReceivePayloadEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.event; 2 | 3 | import java.util.UUID; 4 | 5 | /** Is fired when a custom payload message is received from the client. */ 6 | public class BukkitReceivePayloadEvent extends BukkitLabyModEvent { 7 | 8 | private final UUID uniqueId; 9 | private final String identifier; 10 | private final byte[] payload; 11 | 12 | public BukkitReceivePayloadEvent(UUID uniqueId, String identifier, byte[] payload) { 13 | this.uniqueId = uniqueId; 14 | this.identifier = identifier; 15 | this.payload = payload; 16 | } 17 | 18 | /** 19 | * Retrieves the unique identifier of the client player. 20 | * 21 | * @return The unique identifier of the client player. 22 | */ 23 | public UUID getUniqueId() { 24 | return uniqueId; 25 | } 26 | 27 | /** 28 | * Retrieves the channel identifier to which the payload was sent. 29 | * 30 | * @return The channel identifier to which the payload was sent. 31 | */ 32 | public String getIdentifier() { 33 | return identifier; 34 | } 35 | 36 | /** 37 | * Retrieves the sent payload. 38 | * 39 | * @return The sent payload. 40 | */ 41 | public byte[] getPayload() { 42 | return payload; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/CineScopes.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the cine scope packet. 7 | * 8 | *

Overview: 9 | * 10 | *

It is possible to use Cine Scopes (Black bars) for game mode cinematics. 11 | * 12 | * @deprecated Use {@link CineScopesTransmitter}. 13 | */ 14 | @Deprecated 15 | public interface CineScopes { 16 | 17 | /** 18 | * Sends the cine scope packet to the client. 19 | * 20 | * @param uniqueId The unique identifier of the receiver. 21 | * @param showCineScopes {@code true} if the black bar should be fade in, for fade out{@code 22 | * false}. 23 | * @param coveragePercent The height of the black bars in percent. The minimum of the black bars 24 | * is 1% and the maximum is 50%. 25 | * @param duration The duration 26 | * @deprecated Use {@link CineScopesTransmitter#transmit(UUID, boolean, int, long)} 27 | */ 28 | @Deprecated 29 | void sendCineScope(UUID uniqueId, boolean showCineScopes, int coveragePercent, long duration); 30 | 31 | /** {@link CineScopesTransmitter#broadcastTransmit(boolean, int, long)} */ 32 | @Deprecated 33 | void broadcastSendCineScope(boolean showCineScopes, int coveragePercent, long duration); 34 | } 35 | -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/event/BungeeReceivePayloadEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee.event; 2 | 3 | import net.md_5.bungee.api.plugin.Event; 4 | 5 | import java.util.UUID; 6 | 7 | /** Fired when a custom payload message is received from the client. */ 8 | public class BungeeReceivePayloadEvent extends Event { 9 | 10 | private final UUID uniqueId; 11 | private final String identifier; 12 | private final byte[] payload; 13 | 14 | public BungeeReceivePayloadEvent(UUID uniqueId, String identifier, byte[] payload) { 15 | this.uniqueId = uniqueId; 16 | this.identifier = identifier; 17 | this.payload = payload; 18 | } 19 | 20 | /** 21 | * Retrieves the unique identiifer of the client player. 22 | * 23 | * @return The unique identifier of the client player. 24 | */ 25 | public UUID getUniqueId() { 26 | return uniqueId; 27 | } 28 | 29 | /** 30 | * Retrieves the channel identifier to which the payload was sent. 31 | * 32 | * @return The channel identifier to which the payload was sent. 33 | */ 34 | public String getIdentifier() { 35 | return identifier; 36 | } 37 | 38 | /** 39 | * Retrieves the sent payload. 40 | * 41 | * @return The sent payload. 42 | */ 43 | public byte[] getPayload() { 44 | return payload; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/event/VelocityMessageReceiveEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity.event; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.velocitypowered.api.proxy.Player; 5 | 6 | /** Is fired when a payload message is received. */ 7 | public class VelocityMessageReceiveEvent { 8 | 9 | private final Player player; 10 | private final String messageKey; 11 | private final JsonElement messageContent; 12 | 13 | public VelocityMessageReceiveEvent(Player player, String messageKey, JsonElement messageContent) { 14 | this.player = player; 15 | this.messageKey = messageKey; 16 | this.messageContent = messageContent; 17 | } 18 | 19 | /** 20 | * Retrieves the player that received the payload message. 21 | * 22 | * @return The player that received the payload message. 23 | */ 24 | public Player getPlayer() { 25 | return player; 26 | } 27 | 28 | /** 29 | * Retrieves the key assigned to the message content. 30 | * 31 | * @return The key assigned to the message content. 32 | */ 33 | public String getMessageKey() { 34 | return messageKey; 35 | } 36 | 37 | /** 38 | * Retrieves the message content as a JSON tree. 39 | * 40 | * @return The message content as a JSON tree. 41 | */ 42 | public JsonElement getMessageContent() { 43 | return messageContent; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/event/BukkitMessageReceiveEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.event; 2 | 3 | import com.google.gson.JsonElement; 4 | import org.bukkit.entity.Player; 5 | 6 | /** Is fired when a custom payload message is received from the client. */ 7 | public class BukkitMessageReceiveEvent extends BukkitLabyModEvent { 8 | 9 | private final Player player; 10 | private final String messageKey; 11 | private final JsonElement messageContent; 12 | 13 | public BukkitMessageReceiveEvent(Player player, String messageKey, JsonElement messageContent) { 14 | this.player = player; 15 | this.messageKey = messageKey; 16 | this.messageContent = messageContent; 17 | } 18 | 19 | /** 20 | * Retrieves the player that received the payload message. 21 | * 22 | * @return The player that received the payload message. 23 | */ 24 | public Player getPlayer() { 25 | return player; 26 | } 27 | 28 | /** 29 | * Retrieves the key assigned to the message content. 30 | * 31 | * @return The key assigned to the message content. 32 | */ 33 | public String getMessageKey() { 34 | return messageKey; 35 | } 36 | 37 | /** 38 | * Retrieves the message content as a JSON tree. 39 | * 40 | * @return The message content as a JSON tree. 41 | */ 42 | public JsonElement getMessageContent() { 43 | return messageContent; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/BukkitLabyModPlugin.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit; 2 | 3 | import net.labymod.serverapi.api.LabyAPI; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadChannelRegistrar; 6 | import net.labymod.serverapi.bukkit.payload.channel.BukkitLegacyLabyModPayloadChannel; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.plugin.java.JavaPlugin; 9 | 10 | public class BukkitLabyModPlugin extends JavaPlugin { 11 | 12 | private LabyService service; 13 | 14 | @Override 15 | public void onEnable() { 16 | this.service = new BukkitLabyService(this, getDescription().getVersion()); 17 | LabyAPI.initialize(this.service); 18 | 19 | PayloadChannelRegistrar payloadChannelRegistrar = 20 | this.service.getPayloadChannelRegistrar(); 21 | payloadChannelRegistrar.registerModernChannelIdentifier("labymod3", "main"); 22 | 23 | this.getServer() 24 | .getPluginManager() 25 | .registerEvents((Listener) this.service.getConnectionService(), this); 26 | this.getServer() 27 | .getPluginManager() 28 | .registerEvents(new BukkitLegacyLabyModPayloadChannel(this, this.service), this); 29 | } 30 | 31 | @Override 32 | public void onDisable() {} 33 | 34 | @Deprecated 35 | public String getPluginVersion() { 36 | return this.service.getVersion(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/Watermark.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the watermark packet. 7 | * 8 | *

Overview: 9 | * 10 | *

This feature will show a LabyMod banner in the bottom right corner. It was made for LabyMod 11 | * tournaments. A special feature of this watermark is that the server can force an emote to the 12 | * player without changing the unique identifier. 13 | * 14 | * @deprecated Use {@link WatermarkTransmitter}. 15 | */ 16 | @Deprecated 17 | public interface Watermark { 18 | 19 | /** 20 | * Sends the watermark packet to the client. 21 | * 22 | * @param uniqueId The unique identifier of the receiver. 23 | * @param showWatermark {@code true} if the watermark should be displayed, otherwise {@code 24 | * false}. 25 | * @deprecated Use {@link WatermarkTransmitter#transmit(UUID, boolean)} 26 | */ 27 | @Deprecated 28 | void displayWatermark(UUID uniqueId, boolean showWatermark); 29 | 30 | /** 31 | * Sends the watermark packet to all online laby users. 32 | * 33 | * @param showWatermark {@code true} if the watermark should be displayed, otherwise {@code 34 | * false}. 35 | * @deprecated Use {@link WatermarkTransmitter#broadcastTransmit(boolean)} 36 | */ 37 | @Deprecated 38 | void broadcastDisplayWatermark(boolean showWatermark); 39 | } 40 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/CineScopesTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the cine scope packet. 7 | * 8 | *

Overview: 9 | * 10 | *

It is possible to use Cine Scopes (Black bars) for game mode cinematics. 11 | */ 12 | public interface CineScopesTransmitter { 13 | 14 | /** 15 | * Transmits the cine scope packet to the client. 16 | * 17 | * @param uniqueId The unique identifier of the receiver. 18 | * @param showCineScopes {@code true} if the black bar should be fade in, for fade out{@code 19 | * false}. 20 | * @param coveragePercent The height of the black bars in percent. The minimum of the black bars 21 | * is 0% and the maximum is 50%. 22 | * @param duration The duration 23 | */ 24 | void transmit(UUID uniqueId, boolean showCineScopes, int coveragePercent, long duration); 25 | 26 | /** 27 | * Transmits the cine scope packet to all online laby users. 28 | * 29 | * @param showCineScopes {@code true} if the black bar should be fade in, for fade out {@code 30 | * false}. 31 | * @param coveragePercent The height of the black bars in percent. The minimum of the black bars 32 | * is 1% and the maximum is 50%. 33 | * @param duration The duration. 34 | */ 35 | void broadcastTransmit(boolean showCineScopes, int coveragePercent, long duration); 36 | } 37 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/actionmenu/MenuTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.actionmenu; 2 | 3 | import java.util.UUID; 4 | /** 5 | * Represents the action menu of a player. 6 | * 7 | *

Overview: 8 | * 9 | *

In version 3.3.1, we introduced a middle click for players. It features custom actions 10 | * are executed for the player that has been clicked on. A server can add custom buttons to that 11 | * list of actions. 12 | */ 13 | public interface MenuTransmitter { 14 | 15 | /** 16 | * Adds a menu entry to a list, which should then be displayed in the menu. 17 | * 18 | * @param entry The menu entry which should be displayed. 19 | * @return This object for a fluent chaining. 20 | */ 21 | MenuTransmitter addEntry(MenuEntry entry); 22 | 23 | /** 24 | * Adds to a list an array of menu entries, which should then be displayed in the menu. 25 | * 26 | * @param entries An array menu entries which should be displayed. 27 | * @return This object for a fluent chaining. 28 | */ 29 | MenuTransmitter addEntries(MenuEntry... entries); 30 | 31 | /** 32 | * Transmits an action menu to the client. 33 | * 34 | * @param uniqueId The unique identifier of the receiver. 35 | */ 36 | void transmit(UUID uniqueId); 37 | 38 | /** 39 | * Transmits an action menu to all online laby users. 40 | */ 41 | void broadcastTransmit(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/addon/DefaultRecommendedAddon.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.addon; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.serverinteraction.addon.RecommendedAddon; 6 | 7 | public class DefaultRecommendedAddon implements RecommendedAddon { 8 | 9 | private final UUID publishedUniqueId; 10 | private final JsonObject recommendAddonObject; 11 | private boolean required; 12 | 13 | public DefaultRecommendedAddon(UUID publishedUniqueId, boolean required) { 14 | this.publishedUniqueId = publishedUniqueId; 15 | this.recommendAddonObject = new JsonObject(); 16 | this.required = required; 17 | this.recommendAddonObject.addProperty("uuid", publishedUniqueId.toString()); 18 | } 19 | 20 | /** {@inheritDoc} */ 21 | @Override 22 | public UUID getPublishedUniqueId() { 23 | return this.publishedUniqueId; 24 | } 25 | 26 | /** {@inheritDoc} */ 27 | @Override 28 | public boolean isRequired() { 29 | return this.required; 30 | } 31 | 32 | /** {@inheritDoc} */ 33 | @Override 34 | public void setRequired(boolean required) { 35 | this.required = required; 36 | this.recommendAddonObject.addProperty("required", required); 37 | } 38 | 39 | /** {@inheritDoc} */ 40 | @Override 41 | public JsonObject asJsonObject() { 42 | return this.recommendAddonObject; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/subtile/SubTitleTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.subtile; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents a subtitle transmitter that sends a payload message in channel account_subtitle 7 | * to the LabyMod client. 8 | * 9 | *

Overview: 10 | * 11 | *

The LabyMod client can display a subtitle tag (similar through using the scoreboard) under a 12 | * players name. 13 | */ 14 | public interface SubTitleTransmitter { 15 | 16 | /** 17 | * Adds a subtitle to a list which will be displayed when sending. 18 | * 19 | * @param subTitle The subtitle which should be displayed above the player. 20 | * @return This object for a fluent chaining. 21 | */ 22 | SubTitleTransmitter addSubtitle(SubTitle subTitle); 23 | 24 | /** 25 | * Adds to a list an array of subtitles which will be displayed when sending. 26 | * 27 | * @param subTitles An array subtitles which should be displayed above the player's. 28 | * @return This object for a fluent chaining. 29 | */ 30 | SubTitleTransmitter addSubtitles(SubTitle... subTitles); 31 | 32 | /** 33 | * Transmits a list of all subtitles to the client. 34 | * 35 | * @param uniqueId The unique identifier of the receiver. 36 | */ 37 | void transmit(UUID uniqueId); 38 | 39 | /** Transmits a list of all subtitles to all online laby users. */ 40 | void broadcastTransmit(); 41 | } 42 | -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/event/BungeeMessageReceiveEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee.event; 2 | 3 | import com.google.gson.JsonElement; 4 | import net.md_5.bungee.api.connection.ProxiedPlayer; 5 | import net.md_5.bungee.api.plugin.Event; 6 | 7 | /** Is fired when a payload message is received. */ 8 | public class BungeeMessageReceiveEvent extends Event { 9 | 10 | private final ProxiedPlayer player; 11 | private final String messageKey; 12 | private final JsonElement messageContent; 13 | 14 | public BungeeMessageReceiveEvent( 15 | ProxiedPlayer player, String messageKey, JsonElement messageContent) { 16 | this.player = player; 17 | this.messageKey = messageKey; 18 | this.messageContent = messageContent; 19 | } 20 | 21 | /** 22 | * Retrieves the player that received the payload message. 23 | * 24 | * @return The player that received the payload message. 25 | */ 26 | public ProxiedPlayer getPlayer() { 27 | return player; 28 | } 29 | 30 | /** 31 | * Retrieves the key assigned to the message content. 32 | * 33 | * @return THe key assigned to the message content. 34 | */ 35 | public String getMessageKey() { 36 | return messageKey; 37 | } 38 | 39 | /** 40 | * Retrieves the message content as a JSON tree. 41 | * 42 | * @return The message content as a JSON tree. 43 | */ 44 | public JsonElement getMessageContent() { 45 | return messageContent; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/TabListCacheTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the tab list cache packet. 7 | * 8 | *

Overview: 9 | * 10 | *

LabyMod has a cache for the player tab-list. If you want to spawn a NPC, you have to add it to 11 | * the tab-list to make it visible and remove it again to keep the tab-list clean. With LabyMod you 12 | * can add the NPC to the tab-list and remove it in the same tick again. The client will remember 13 | * the information and use it when you spawn the actual Player entity. 14 | */ 15 | public interface TabListCacheTransmitter { 16 | 17 | /** 18 | * Whether the tab list cache should be enabled or not. 19 | * 20 | * @return {@code true} if the tab list cache is enabled, otherwise {@code false}. 21 | */ 22 | boolean isEnabled(); 23 | 24 | /** 25 | * Changes whether the tab list cache should be enabled or not. 26 | * 27 | * @param enabled {@code true} if the tab list cache should be enabled, otherwise {@code false}. 28 | */ 29 | void setEnabled(boolean enabled); 30 | 31 | /** 32 | * Transmits the tab list cache packet to the laby client. 33 | * 34 | * @param uniqueId The unique identifier of the laby client user. 35 | */ 36 | void transmit(UUID uniqueId); 37 | 38 | /** Transmits the tab list cache packet to all online laby users. */ 39 | void transmitBroadcast(); 40 | } 41 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/actionmenu/DefaultMenuEntry.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.actionmenu; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.serverinteraction.actionmenu.ActionType; 5 | import net.labymod.serverapi.api.serverinteraction.actionmenu.MenuEntry; 6 | 7 | public class DefaultMenuEntry implements MenuEntry { 8 | 9 | private final String displayName; 10 | private final String value; 11 | private final ActionType actionType; 12 | private final JsonObject entryObject; 13 | 14 | public DefaultMenuEntry(String displayName, String value, ActionType actionType) { 15 | this.displayName = displayName; 16 | this.value = value; 17 | this.actionType = actionType; 18 | this.entryObject = new JsonObject(); 19 | 20 | this.entryObject.addProperty("displayName", displayName); 21 | this.entryObject.addProperty("value", value); 22 | this.entryObject.addProperty("type", actionType.name()); 23 | } 24 | 25 | /** {@inheritDoc} */ 26 | @Override 27 | public String getDisplayName() { 28 | return this.displayName; 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public String getValue() { 34 | return this.value; 35 | } 36 | 37 | /** {@inheritDoc} */ 38 | @Override 39 | public ActionType getActionType() { 40 | return this.actionType; 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public JsonObject asJsonObject() { 46 | return this.entryObject; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/addon/AddonRecommendationTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.addon; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the addon recommendation packet. 7 | * 8 | *

Overview: 9 | * 10 | *

With this packet the server can recommend published addons to the user and the user can 11 | * install them very simple in a GUI. Multiple add-ons can be suggested at the same time or can also 12 | * be flagged as being required. You have to react to the response of the client if an addon is 13 | * required. 14 | */ 15 | public interface AddonRecommendationTransmitter { 16 | 17 | /** 18 | * Adds a recommending addon to a list which will be sent to the client. 19 | * 20 | * @param recommendedAddon The recommended addon to be added. 21 | * @return This object for a fluent chaining. 22 | */ 23 | AddonRecommendationTransmitter addRecommendAddon(RecommendedAddon recommendedAddon); 24 | 25 | /** 26 | * Adds to a list an array of recommending addons which will be sent to the client. 27 | * 28 | * @param recommendedAddons An array of recommended addons to be added. 29 | * @return This object for a fluent chaining. 30 | */ 31 | AddonRecommendationTransmitter addRecommendAddons(RecommendedAddon... recommendedAddons); 32 | 33 | /** 34 | * Transmits the addon recommendation packet to the client. 35 | * 36 | * @param uniqueId The unique identifier of the receiver. 37 | */ 38 | void transmit(UUID uniqueId); 39 | } 40 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultWatermark.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.Watermark; 9 | 10 | import java.util.UUID; 11 | 12 | public class DefaultWatermark implements Watermark { 13 | 14 | private static final String WATERMARK_CHANNEL = "watermark"; 15 | private final LabyModPlayerService playerService; 16 | private final PayloadCommunicator payloadCommunicator; 17 | 18 | public DefaultWatermark(LabyService service) { 19 | this.payloadCommunicator = service.getPayloadCommunicator(); 20 | this.playerService = service.getLabyPlayerService(); 21 | } 22 | 23 | /** {@inheritDoc} */ 24 | @Override 25 | public void displayWatermark(UUID uniqueId, boolean showWatermark) { 26 | JsonObject watermarkObject = new JsonObject(); 27 | watermarkObject.addProperty("visible", showWatermark); 28 | 29 | this.payloadCommunicator.sendLabyModMessage(uniqueId, WATERMARK_CHANNEL, watermarkObject); 30 | } 31 | 32 | /** {@inheritDoc} */ 33 | @Override 34 | public void broadcastDisplayWatermark(boolean showWatermark) { 35 | for (LabyModPlayer player : this.playerService.getPlayers()) { 36 | this.displayWatermark(player.getUniqueId(), showWatermark); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/economy/EconomyDisplayTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.economy; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the economy display packet. 7 | * 8 | *

Overview: 9 | * 10 | *

It is also possible to display the balance of your economy system. If the user enters a shop 11 | * or is in a trading situation, you can display the amount of the balance in the top right corner. 12 | * You can also use this feature in games if you have to collect coins. 13 | */ 14 | public interface EconomyDisplayTransmitter { 15 | 16 | /** 17 | * Transmits the balance display to the LabyMod client. 18 | * 19 | * @param uniqueId The unique identifier of the receiver. 20 | * @param economyBalanceType The type of the economy balance. 21 | * @param showBalanceDisplay {@code true} shows the balance display, otherwise {@code false}. 22 | * @param balance The balance of the receiver. 23 | */ 24 | void transmit( 25 | UUID uniqueId, 26 | EconomyBalanceType economyBalanceType, 27 | boolean showBalanceDisplay, 28 | int balance); 29 | 30 | /** 31 | * Transmits the balance display to all online laby users. 32 | * 33 | * @param economyBalanceType The type of the economy balance. 34 | * @param showBalanceDisplay {@code true} shows the balance display, otherwise {@code false}. 35 | * @param balance The balance of the receiver. 36 | */ 37 | void broadcastTransmit( 38 | EconomyBalanceType economyBalanceType, boolean showBalanceDisplay, int balance); 39 | } 40 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/actionmenu/MenuEntry.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.actionmenu; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | /** Represents a menu entry. */ 6 | public interface MenuEntry { 7 | 8 | /** 9 | * Retrieves the display name of the menu entry. 10 | * 11 | * @return The display name of the entry. 12 | */ 13 | String getDisplayName(); 14 | 15 | /** 16 | * Retrieves the value of the menu entry. 17 | * 18 | *

Note: 19 | * 20 | *

`{name}` will be replaced with the players name. 21 | * 22 | * @return The value of the menu entry. 23 | */ 24 | String getValue(); 25 | 26 | /** 27 | * Retrieves the action type of the menu entry. 28 | * 29 | * @return The action type of the entry. 30 | */ 31 | ActionType getActionType(); 32 | 33 | /** 34 | * Retrieves the menu entry as a {@link JsonObject}. 35 | * 36 | * @return The menu entry as a json object. 37 | */ 38 | JsonObject asJsonObject(); 39 | 40 | /** A factory for creating {@link MenuEntry}'s. */ 41 | interface Factory { 42 | 43 | /** 44 | * Creates a new {@link MenuEntry} with the given {@code displayName}, {@code value} and the 45 | * {@code actionType}. 46 | * 47 | * @param displayName The display name of the menu entry. 48 | * @param value The value for the menu entry. 49 | * @param actionType The action type for the menu entry. 50 | * @return A created menu entry. 51 | */ 52 | MenuEntry create(String displayName, String value, ActionType actionType); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultWatermarkTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.LabyService; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.player.LabyModPlayerService; 9 | import net.labymod.serverapi.api.serverinteraction.WatermarkTransmitter; 10 | 11 | public class DefaultWatermarkTransmitter implements WatermarkTransmitter { 12 | 13 | private static final String WATERMARK_CHANNEL = "watermark"; 14 | private final LabyModPlayerService playerService; 15 | private final PayloadCommunicator payloadCommunicator; 16 | 17 | public DefaultWatermarkTransmitter(LabyService service) { 18 | this.payloadCommunicator = service.getPayloadCommunicator(); 19 | this.playerService = service.getLabyPlayerService(); 20 | } 21 | 22 | /** {@inheritDoc} */ 23 | @Override 24 | public void transmit(UUID uniqueId, boolean showWatermark) { 25 | JsonObject watermarkObject = new JsonObject(); 26 | watermarkObject.addProperty("visible", showWatermark); 27 | 28 | this.payloadCommunicator.sendLabyModMessage(uniqueId, WATERMARK_CHANNEL, watermarkObject); 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public void broadcastTransmit(boolean showWatermark) { 34 | for (LabyModPlayer player : this.playerService.getPlayers()) { 35 | this.transmit(player.getUniqueId(), showWatermark); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/BungeeLabyModPlugin.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee; 2 | 3 | import net.labymod.serverapi.api.LabyAPI; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadChannelRegistrar; 6 | import net.labymod.serverapi.bungee.payload.channel.BungeeLegacyLabyModPayloadChannel; 7 | import net.md_5.bungee.api.plugin.Listener; 8 | import net.md_5.bungee.api.plugin.Plugin; 9 | import net.md_5.bungee.api.plugin.PluginManager; 10 | 11 | public class BungeeLabyModPlugin extends Plugin { 12 | 13 | private LabyService service; 14 | 15 | @Override 16 | public void onEnable() { 17 | this.service = new BungeeLabyService(this, this.getDescription().getVersion()); 18 | LabyAPI.initialize(this.service); 19 | 20 | PayloadChannelRegistrar payloadChannelRegistrar = 21 | this.service.getPayloadChannelRegistrar(); 22 | payloadChannelRegistrar.registerModernChannelIdentifier("labymod3", "main"); 23 | 24 | PluginManager pluginManager = this.getProxy().getPluginManager(); 25 | 26 | pluginManager.registerListener(this, (Listener) this.service.getConnectionService()); 27 | pluginManager.registerListener(this, (Listener) this.service.getPayloadCommunicator()); 28 | pluginManager.registerListener(this, new BungeeLegacyLabyModPayloadChannel(this.service, this)); 29 | } 30 | 31 | @Override 32 | public void onDisable() {} 33 | 34 | public LabyService getService() { 35 | return service; 36 | } 37 | 38 | @Deprecated 39 | public String getPluginVersion() { 40 | return this.service.getVersion(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/event/VelocityReceivePayloadEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity.event; 2 | 3 | import java.util.UUID; 4 | 5 | /** Fired when a custom payload message is received from the client. */ 6 | public class VelocityReceivePayloadEvent { 7 | 8 | private final UUID uniqueId; 9 | private final String identifier; 10 | private final byte[] payload; 11 | 12 | /** 13 | * Initializes a new {@link VelocityReceivePayloadEvent} with the given {@code uniqueId}, 14 | * {@code identifier} and {@code payload}. 15 | * 16 | * @param uniqueId The unique identifier of the client player. 17 | * @param identifier The channel identifier to which the payload was sent. 18 | * @param payload The sent payload. 19 | */ 20 | public VelocityReceivePayloadEvent(UUID uniqueId, String identifier, byte[] payload) { 21 | this.uniqueId = uniqueId; 22 | this.identifier = identifier; 23 | this.payload = payload; 24 | } 25 | 26 | /** 27 | * Retrieves the unique identifier of the client player.. 28 | * 29 | * @return The unique identifier of the client player. 30 | */ 31 | public UUID getUniqueId() { 32 | return uniqueId; 33 | } 34 | 35 | /** 36 | * Retrieves the channel identifier to which the payload was sent. 37 | * 38 | * @return The channel identifier to which the payload was sent. 39 | */ 40 | public String getIdentifier() { 41 | return identifier; 42 | } 43 | 44 | /** 45 | * Retrieves the sent payload. 46 | * 47 | * @return The sent payload. 48 | */ 49 | public byte[] getPayload() { 50 | return payload; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/VelocityLabyDebugger.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity; 2 | 3 | import net.labymod.serverapi.common.AbstractLabyDebugger; 4 | import org.slf4j.Logger; 5 | 6 | public class VelocityLabyDebugger extends AbstractLabyDebugger { 7 | 8 | private static final String DEBUGGER_FORMAT = "[LabyApi] {}"; 9 | private final Logger logger; 10 | 11 | public VelocityLabyDebugger(Logger logger) { 12 | this.logger = logger; 13 | } 14 | 15 | /** {@inheritDoc} */ 16 | @Override 17 | public void info(String message) { 18 | if (this.isDebug()) { 19 | this.logger.info(DEBUGGER_FORMAT, message); 20 | } 21 | } 22 | 23 | /** {@inheritDoc} */ 24 | @Override 25 | public void info(String message, Throwable throwable) { 26 | if (this.isDebug()) { 27 | this.logger.info(DEBUGGER_FORMAT, message, throwable); 28 | } 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public void warn(String message) { 34 | if (this.isDebug()) { 35 | this.logger.warn(DEBUGGER_FORMAT, message); 36 | } 37 | } 38 | 39 | /** {@inheritDoc} */ 40 | @Override 41 | public void warn(String message, Throwable throwable) { 42 | if (this.isDebug()) { 43 | this.logger.warn(DEBUGGER_FORMAT, message, throwable); 44 | } 45 | } 46 | 47 | /** {@inheritDoc} */ 48 | @Override 49 | public void error(String message) { 50 | if (this.isDebug()) { 51 | this.logger.error(DEBUGGER_FORMAT, message); 52 | } 53 | } 54 | 55 | /** {@inheritDoc} */ 56 | @Override 57 | public void error(String message, Throwable throwable) { 58 | if (this.isDebug()) { 59 | this.logger.error(DEBUGGER_FORMAT, message, throwable); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/labychat/PlayingGameModeTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.labychat; 2 | 3 | import java.util.UUID; 4 | 5 | /** The LabyMod chat can display the name of the current game mode on the server. */ 6 | public interface PlayingGameModeTransmitter { 7 | 8 | /** 9 | * Transmits the current game mode to a player with the specified unique identifier. 10 | * 11 | * @param uniqueId The unique identifier of a player. 12 | * @param visible {@code true} if the current game mode should be displayed in LabyChat, otherwise 13 | * {@code false}. 14 | * @param gameModeName The name of the game mode. 15 | */ 16 | void transmit(UUID uniqueId, boolean visible, String gameModeName); 17 | 18 | /** 19 | * Transmits the current game mode to a player with the specified unique identifier. 20 | * 21 | * @param uniqueId The unique identifier of a player. 22 | * @param gameModeName The name of the game mode. 23 | */ 24 | default void transmit(UUID uniqueId, String gameModeName) { 25 | this.transmit(uniqueId, true, gameModeName); 26 | } 27 | 28 | /** 29 | * Transmits the current game mode to all online laby users. 30 | * 31 | * @param visible {@code true} if the current game mode should be displayed in LabyChat, otherwise 32 | * {@code false}. 33 | * @param gameModeName The name of the game mode. 34 | */ 35 | void broadcastTransmit(boolean visible, String gameModeName); 36 | 37 | /** 38 | * Transmits the current game mode to all online laby users. 39 | * 40 | * @param gameModeName The name of the game mode. 41 | */ 42 | default void broadcastTransmit(String gameModeName) { 43 | this.broadcastTransmit(true, gameModeName); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/addon/RecommendedAddon.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.addon; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | import java.util.UUID; 6 | 7 | /** Represents a recommended addon. */ 8 | public interface RecommendedAddon { 9 | 10 | /** 11 | * Retrieves the published unique identifier of the recommended addon. 12 | * 13 | * @return The published unique identifier of the recommended addon. 14 | */ 15 | UUID getPublishedUniqueId(); 16 | 17 | /** 18 | * Whether the recommended addon is required. 19 | * 20 | * @return {@code true} if the recommended addon is required, otherwise {@code false}. 21 | */ 22 | boolean isRequired(); 23 | 24 | /** 25 | * Changes whether the recommended addon is required. 26 | * 27 | * @param required {@code true} if the recommend addon is required, otherwise {@code false}. 28 | */ 29 | void setRequired(boolean required); 30 | 31 | /** 32 | * Retrieves the recommended addon as a {@link JsonObject}. 33 | * 34 | * @return The recommend addon as a json object. 35 | */ 36 | JsonObject asJsonObject(); 37 | 38 | /** A factory for creating {@link RecommendedAddon}'s. */ 39 | interface Factory { 40 | 41 | /** 42 | * Creates a new {@link RecommendedAddon} with the {@code publishedUniqueId} and {@code 43 | * required} if it is needed. 44 | * 45 | * @param publishedUniqueId The published unique identifier of the recommended addon. 46 | * @param required {@code true} if the recommended addon should be required, otherwise {@code 47 | * false}. 48 | * @return A created recommended addon. 49 | */ 50 | RecommendedAddon create(UUID publishedUniqueId, boolean required); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/payload/PayloadBuffer.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.payload; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | 5 | /** Represents a payload buffer to write something to the payload channels. */ 6 | public interface PayloadBuffer { 7 | 8 | /** 9 | * Reads a string from the byte buffer. 10 | * 11 | * @return The read string. 12 | */ 13 | String readString(); 14 | 15 | /** 16 | * Writes a string to the byte buffer. 17 | * 18 | * @param content The that ssould be written to the byte buffer. 19 | * @return This object object for chaining. 20 | */ 21 | PayloadBuffer writeString(String content); 22 | 23 | /** 24 | * Reads a varint from the byte buffer. 25 | * 26 | * @return The read varint. 27 | */ 28 | int readVarIntFromBuffer(); 29 | 30 | /** 31 | * Writes a varint into the byte buffer. 32 | * 33 | * @param input The input that should be written to the buffer. 34 | * @return This object for chaining. 35 | */ 36 | PayloadBuffer writeVarIntIntoBuffer(int input); 37 | 38 | /** 39 | * Retrieves all readable bytes from the byte buffer. 40 | * 41 | * @return All readable bytes from the byte buffer. 42 | */ 43 | byte[] getBytes(); 44 | 45 | /** A factory for creating {@link PayloadBuffer}. */ 46 | interface Factory { 47 | 48 | /** 49 | * Creates a new {@link PayloadBuffer}. 50 | * 51 | * @return A created payload buffer. 52 | */ 53 | PayloadBuffer create(); 54 | 55 | /** 56 | * Creates a new {@link PayloadBuffer} wit the given {@code byteBuf}. 57 | * 58 | * @param byteBuf The byte buf for the payload buffer. 59 | * @return A created payload buffer. 60 | */ 61 | PayloadBuffer create(ByteBuf byteBuf); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/labychat/DefaultPlayingGameMode.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.labychat; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.labychat.PlayingGameMode; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.player.LabyModPlayerService; 9 | 10 | import java.util.UUID; 11 | 12 | @Deprecated 13 | public class DefaultPlayingGameMode implements PlayingGameMode { 14 | 15 | private static final String SERVER_GAMEMODE_CHANNEL = "server_gamemode"; 16 | private final LabyModPlayerService playerService; 17 | private final PayloadCommunicator payloadCommunicator; 18 | 19 | public DefaultPlayingGameMode(LabyService service) { 20 | this.payloadCommunicator = service.getPayloadCommunicator(); 21 | this.playerService = service.getLabyPlayerService(); 22 | } 23 | 24 | /** {@inheritDoc} */ 25 | @Override 26 | public void sendCurrentPlayingGameMode(UUID uniqueId, boolean showGameMode, String gameModeName) { 27 | JsonObject currentPlayingGameModeObject = new JsonObject(); 28 | currentPlayingGameModeObject.addProperty("show_gamemode", showGameMode); 29 | currentPlayingGameModeObject.addProperty("gamemode_name", gameModeName); 30 | 31 | this.payloadCommunicator.sendLabyModMessage( 32 | uniqueId, SERVER_GAMEMODE_CHANNEL, currentPlayingGameModeObject); 33 | } 34 | 35 | @Override 36 | public void broadcastCurrentlyPlayingGameMode(boolean visible, String gameModeName) { 37 | for (LabyModPlayer player : this.playerService.getPlayers()) { 38 | this.sendCurrentPlayingGameMode(player.getUniqueId(), gameModeName); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultServerSwitcher.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.ServerSwitcher; 9 | 10 | import java.util.UUID; 11 | 12 | public class DefaultServerSwitcher implements ServerSwitcher { 13 | 14 | private static final String SERVER_SWITCH_CHANNEL = "server_switch"; 15 | 16 | private final PayloadCommunicator payloadCommunicator; 17 | private final LabyModPlayerService playerService; 18 | 19 | public DefaultServerSwitcher(LabyService service) { 20 | this.payloadCommunicator = service.getPayloadCommunicator(); 21 | this.playerService = service.getLabyPlayerService(); 22 | } 23 | 24 | /** {@inheritDoc} */ 25 | @Override 26 | public void sendPlayerToServer(UUID uniqueId, String title, String address, boolean preview) { 27 | JsonObject serverSwitchObject = new JsonObject(); 28 | 29 | serverSwitchObject.addProperty("title", title); 30 | serverSwitchObject.addProperty("address", address); 31 | serverSwitchObject.addProperty("preview", preview); 32 | 33 | this.payloadCommunicator.sendLabyModMessage( 34 | uniqueId, SERVER_SWITCH_CHANNEL, serverSwitchObject); 35 | } 36 | 37 | @Override 38 | public void broadcastSendPlayerToServer(String title, String address, boolean preview) { 39 | for (LabyModPlayer player : this.playerService.getPlayers()) { 40 | this.sendPlayerToServer(player.getUniqueId(), title, address, preview); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/actionmenu/Menu.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.actionmenu; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the action menu of a player. 7 | * 8 | *

Overview: 9 | * 10 | *

In version 3.3.1, we introduced a middle click for players. It features custom actions 11 | * are executed for the player that has been clicked on. A server can add custom buttons to that 12 | * list of actions. 13 | * 14 | * @deprecated {@link MenuTransmitter} 15 | */ 16 | @Deprecated 17 | public interface Menu { 18 | 19 | /** 20 | * Adds a menu entry to a list, which should then be displayed in the menu. 21 | * 22 | * @param entry The menu entry which should be displayed. 23 | * @return This object for a fluent chaining. 24 | * @deprecated {@link MenuTransmitter#addEntry(MenuEntry)} 25 | */ 26 | @Deprecated 27 | Menu addEntry(MenuEntry entry); 28 | 29 | /** 30 | * Adds to a list an array of menu entries, which should then be displayed in the menu. 31 | * 32 | * @param entries An array menu entries which should be displayed. 33 | * @return This object for a fluent chaining. 34 | * @deprecated {@link MenuTransmitter#addEntries(MenuEntry...)} 35 | */ 36 | @Deprecated 37 | Menu addEntries(MenuEntry... entries); 38 | 39 | /** 40 | * Transmits an action menu to the client. 41 | * 42 | * @param uniqueId The unique identifier of the receiver. 43 | * @deprecated {@link MenuTransmitter#transmit(UUID)} 44 | */ 45 | @Deprecated 46 | void transmit(UUID uniqueId); 47 | 48 | /** 49 | * Transmits an action menu to all online laby users. 50 | * 51 | * @deprecated {@link MenuTransmitter#broadcastTransmit()} 52 | */ 53 | @Deprecated 54 | void broadcastTransmit(); 55 | } 56 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/ServerSwitcherTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the server switch packet. 7 | * 8 | *

Overview: 9 | * 10 | *

With out server switch packet you can send LabyMod users between different servers. The server 11 | * can request a user to directly connect to a different IP address (or domain name). This can be 12 | * used to create multi-server-networks. As this does not need any extra proxy software and 13 | * hardware, it is generally cheaper for a network to connect players directly to the server instead 14 | * of using an intermediate software like BungeeCord. 15 | */ 16 | public interface ServerSwitcherTransmitter { 17 | 18 | /** 19 | * Transmits a player to another network or server. 20 | * 21 | * @param uniqueId The unique identifier of a player which should be sent to another 22 | * network/server. 23 | * @param title The title of the warning. 24 | * @param address The address of the network / server where the player should be sent to. 25 | * @param preview {@code true} if information about the network / server should be displayed, 26 | * otherwise {@code false}. 27 | */ 28 | void transmit(UUID uniqueId, String title, String address, boolean preview); 29 | 30 | /** 31 | * Transmits all online laby user to another network or server. 32 | * 33 | * @param title The title of the warning. 34 | * @param address The address of the network / server where the players should be sent to. 35 | * @param preview {@code true} if information about the network / server should be displayed, 36 | * otherwise {@code false}. 37 | */ 38 | void broadcastTransmit(String title, String address, boolean preview); 39 | } 40 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/sticker/StickerTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.sticker; 2 | 3 | import net.labymod.serverapi.api.emote.EmoteTransmitter; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * Represents a sticker transmitter that sends a payload message in channel sticker_api to 9 | * the LabyMod client. 10 | * 11 | *

Overview: 12 | * 13 | *

LabyMod users can play client side a sticker for all other players on the minecraft server. 14 | * Minecraft servers can also force-play stickers for specifc player's using the plugin messages. 15 | * 16 | *

Warning: 17 | * 18 | *

This works only for NPC's and not for real players. 19 | * 20 | *

21 | * 22 | *

The behavior is the same as in the emote api ({@link EmoteTransmitter}). 23 | * 24 | *

Note: The permission is default enabled. 16 | * 17 | * @param internalName The internal name of the permission. 18 | * @param name The name of the permission. 19 | */ 20 | protected DefaultPermission(String internalName, String name) { 21 | this(internalName, name, true); 22 | } 23 | 24 | /** 25 | * Initializes a new default permission with the given parameters. 26 | * 27 | * @param internalName The internal name of the permission. 28 | * @param name The name of the permission. 29 | * @param enabled {@code true} if the permission should be enabled, otherwise {@code false}. 30 | */ 31 | protected DefaultPermission(String internalName, String name, boolean enabled) { 32 | this.internalName = internalName; 33 | this.name = name; 34 | this.enabled = enabled; 35 | } 36 | 37 | /** {@inheritDoc} */ 38 | @Override 39 | public String getInternalName() { 40 | return this.internalName; 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public String getName() { 46 | return this.name; 47 | } 48 | 49 | /** {@inheritDoc} */ 50 | @Override 51 | public boolean isEnabled() { 52 | return this.enabled; 53 | } 54 | 55 | /** {@inheritDoc} */ 56 | @Override 57 | public void setEnabled(boolean enabled) { 58 | this.enabled = enabled; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultTabListCacheTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.LabyService; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.player.LabyModPlayerService; 9 | import net.labymod.serverapi.api.serverinteraction.TabListCacheTransmitter; 10 | 11 | public class DefaultTabListCacheTransmitter implements TabListCacheTransmitter { 12 | 13 | private static final String TABLIST_CACHE_CHANNEL = "tablist_cache"; 14 | 15 | private final LabyModPlayerService playerService; 16 | private final PayloadCommunicator communicator; 17 | private boolean enabled; 18 | 19 | public DefaultTabListCacheTransmitter(LabyService service) { 20 | this.communicator = service.getPayloadCommunicator(); 21 | this.playerService = service.getLabyPlayerService(); 22 | this.enabled = true; 23 | } 24 | 25 | /** {@inheritDoc} */ 26 | @Override 27 | public boolean isEnabled() { 28 | return this.enabled; 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public void setEnabled(boolean enabled) { 34 | this.enabled = enabled; 35 | } 36 | 37 | /** {@inheritDoc} */ 38 | @Override 39 | public void transmit(UUID uniqueId) { 40 | JsonObject object = new JsonObject(); 41 | object.addProperty("enabled", this.enabled); 42 | this.communicator.sendLabyModMessage(uniqueId, TABLIST_CACHE_CHANNEL, object); 43 | } 44 | 45 | /** {@inheritDoc} */ 46 | @Override 47 | public void transmitBroadcast() { 48 | for (LabyModPlayer player : this.playerService.getPlayers()) { 49 | this.transmit(player.getUniqueId()); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultTabListCache.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.TabListCache; 9 | 10 | import java.util.UUID; 11 | 12 | /** Default implementation of {@link TabListCache}. */ 13 | public class DefaultTabListCache implements TabListCache { 14 | 15 | private static final String TABLIST_CACHE_CHANNEL = "tablist_cache"; 16 | 17 | private final LabyModPlayerService playerService; 18 | private final PayloadCommunicator communicator; 19 | private boolean enabled; 20 | 21 | public DefaultTabListCache(LabyService service) { 22 | this.communicator = service.getPayloadCommunicator(); 23 | this.playerService = service.getLabyPlayerService(); 24 | this.enabled = true; 25 | } 26 | 27 | /** {@inheritDoc} */ 28 | @Override 29 | public boolean isEnabled() { 30 | return this.enabled; 31 | } 32 | 33 | /** {@inheritDoc} */ 34 | @Override 35 | public void setEnabled(boolean enabled) { 36 | this.enabled = enabled; 37 | } 38 | 39 | /** {@inheritDoc} */ 40 | @Override 41 | public void transmit(UUID uniqueId) { 42 | JsonObject object = new JsonObject(); 43 | object.addProperty("enabled", this.enabled); 44 | this.communicator.sendLabyModMessage(uniqueId, TABLIST_CACHE_CHANNEL, object); 45 | } 46 | 47 | /** {@inheritDoc} */ 48 | @Override 49 | public void transmitBroadcast() { 50 | for (LabyModPlayer player : this.playerService.getPlayers()) { 51 | this.transmit(player.getUniqueId()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/labychat/DefaultPlayingGameModeTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.labychat; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.LabyService; 6 | import net.labymod.serverapi.api.labychat.PlayingGameModeTransmitter; 7 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 8 | import net.labymod.serverapi.api.player.LabyModPlayer; 9 | import net.labymod.serverapi.api.player.LabyModPlayerService; 10 | 11 | /** Default implementation of the {@link PlayingGameModeTransmitter}. */ 12 | public class DefaultPlayingGameModeTransmitter implements PlayingGameModeTransmitter { 13 | 14 | private static final String SERVER_GAMEMODE_CHANNEL = "server_gamemode"; 15 | private final LabyModPlayerService playerService; 16 | private final PayloadCommunicator payloadCommunicator; 17 | 18 | public DefaultPlayingGameModeTransmitter(LabyService service) { 19 | this.payloadCommunicator = service.getPayloadCommunicator(); 20 | this.playerService = service.getLabyPlayerService(); 21 | } 22 | 23 | /** {@inheritDoc} */ 24 | @Override 25 | public void transmit(UUID uniqueId, boolean visible, String gameModeName) { 26 | JsonObject currentPlayingGameModeObject = new JsonObject(); 27 | currentPlayingGameModeObject.addProperty("show_gamemode", visible); 28 | currentPlayingGameModeObject.addProperty("gamemode_name", gameModeName); 29 | 30 | this.payloadCommunicator.sendLabyModMessage( 31 | uniqueId, SERVER_GAMEMODE_CHANNEL, currentPlayingGameModeObject); 32 | } 33 | 34 | /** {@inheritDoc} */ 35 | @Override 36 | public void broadcastTransmit(boolean visible, String gameModeName) { 37 | for (LabyModPlayer player : this.playerService.getPlayers()) { 38 | this.transmit(player.getUniqueId(), visible, gameModeName); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/economy/EconomyDisplay.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.economy; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the economy display packet. 7 | * 8 | *

Overview: 9 | * 10 | *

It is also possible to display the balance of your economy system. If the user enters a shop 11 | * or is in a trading situation, you can display the amount of the balance in the top right corner. 12 | * You can also use this feature in games if you have to collect coins. 13 | * 14 | * @deprecated Use {@link EconomyDisplayTransmitter} 15 | */ 16 | @Deprecated 17 | public interface EconomyDisplay { 18 | 19 | /** 20 | * Sends the balance display to the LabyMod client. 21 | * 22 | * @param uniqueId The unique identifier of the receiver. 23 | * @param economyBalanceType The type of the economy balance. 24 | * @param showBalanceDisplay {@code true} shows the balance display, otherwise {@code false}. 25 | * @param balance The balance of the receiver. 26 | * @deprecated Use {@link EconomyDisplayTransmitter#transmit(UUID, EconomyBalanceType, boolean, int)} 27 | */ 28 | @Deprecated 29 | void sendBalanceDisplay( 30 | UUID uniqueId, 31 | EconomyBalanceType economyBalanceType, 32 | boolean showBalanceDisplay, 33 | int balance); 34 | 35 | /** 36 | * Sends the balance display to all online laby users. 37 | * 38 | * @param economyBalanceType The type of the economy balance. 39 | * @param showBalanceDisplay {@code true} shows the balance display, otherwise {@code false}. 40 | * @param balance The balance of the receiver. 41 | * @deprecated Use {@link EconomyDisplayTransmitter#broadcastTransmit(EconomyBalanceType, boolean, int)} 42 | */ 43 | @Deprecated 44 | void broadcastSendBalanceDisplay( 45 | EconomyBalanceType economyBalanceType, boolean showBalanceDisplay, int balance); 46 | } 47 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/addon/AddonRecommendation.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.addon; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the addon recommendation packet. 7 | * 8 | *

Overview: 9 | * 10 | *

With this packet the server can recommend published addons to the user and the user can 11 | * install them very simple in a GUI. Multiple add-ons can be suggested at the same time or can also 12 | * be flagged as being required. You have to react to the response of the client if an addon is 13 | * required. 14 | * @deprecated Use {@link AddonRecommendationTransmitter} 15 | */ 16 | @Deprecated 17 | public interface AddonRecommendation { 18 | 19 | /** 20 | * Adds a recommending addon to a list which will be sent to the client. 21 | * 22 | * @param recommendedAddon The recommended addon to be added. 23 | * @return This object for a fluent chaining. 24 | * @deprecated Use {@link AddonRecommendationTransmitter#addRecommendAddon(RecommendedAddon)} 25 | */ 26 | @Deprecated 27 | AddonRecommendation addRecommendAddon(RecommendedAddon recommendedAddon); 28 | 29 | /** 30 | * Adds to a list an array of recommending addons which will be sent to the client. 31 | * 32 | * @param recommendedAddons An array of recommended addons to be added. 33 | * @return This object for a fluent chaining. 34 | * @deprecated Use {@link AddonRecommendationTransmitter#addRecommendAddons(RecommendedAddon...)} 35 | */ 36 | @Deprecated 37 | AddonRecommendation addRecommendAddons(RecommendedAddon... recommendedAddons); 38 | 39 | /** 40 | * Sends the addon recommendation packet to the client. 41 | * 42 | * @param uniqueId The unique identifier of the receiver. 43 | * @deprecated Use {@link AddonRecommendationTransmitter#transmit(UUID)} 44 | */ 45 | @Deprecated 46 | void sendRecommendAddons(UUID uniqueId); 47 | } 48 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/actionmenu/DefaultMenu.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.actionmenu; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.actionmenu.Menu; 9 | import net.labymod.serverapi.api.serverinteraction.actionmenu.MenuEntry; 10 | 11 | import java.util.UUID; 12 | 13 | public class DefaultMenu implements Menu { 14 | 15 | private static final String USER_MENU_ACTIONS_CHANNEL = "user_menu_actions"; 16 | 17 | private final LabyModPlayerService playerService; 18 | private final PayloadCommunicator payloadCommunicator; 19 | private final JsonArray entries; 20 | 21 | public DefaultMenu(LabyService service) { 22 | this.payloadCommunicator = service.getPayloadCommunicator(); 23 | this.playerService = service.getLabyPlayerService(); 24 | this.entries = new JsonArray(); 25 | } 26 | 27 | /** {@inheritDoc} */ 28 | @Override 29 | public Menu addEntry(MenuEntry entry) { 30 | this.entries.add(entry.asJsonObject()); 31 | return this; 32 | } 33 | 34 | /** {@inheritDoc} */ 35 | @Override 36 | public Menu addEntries(MenuEntry... entries) { 37 | for (MenuEntry entry : entries) { 38 | this.entries.add(entry.asJsonObject()); 39 | } 40 | return this; 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public void transmit(UUID uniqueId) { 46 | this.payloadCommunicator.sendLabyModMessage(uniqueId, USER_MENU_ACTIONS_CHANNEL, this.entries); 47 | } 48 | 49 | @Override 50 | public void broadcastTransmit() { 51 | for (LabyModPlayer player : this.playerService.getPlayers()) { 52 | this.transmit(player.getUniqueId()); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultCineScopes.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.CineScopes; 9 | 10 | import java.util.UUID; 11 | 12 | public class DefaultCineScopes implements CineScopes { 13 | 14 | private static final String CINESCOPES_CHANNEL = "cinescopes"; 15 | 16 | private final LabyModPlayerService playerService; 17 | private final PayloadCommunicator payloadCommunicator; 18 | 19 | public DefaultCineScopes(LabyService service) { 20 | this.payloadCommunicator = service.getPayloadCommunicator(); 21 | this.playerService = service.getLabyPlayerService(); 22 | } 23 | 24 | /** {@inheritDoc} */ 25 | @Override 26 | public void sendCineScope( 27 | UUID uniqueId, boolean showCineScopes, int coveragePercent, long duration) { 28 | JsonObject cineScopeObject = new JsonObject(); 29 | 30 | if (coveragePercent < 1) { 31 | coveragePercent = 1; 32 | } else if (coveragePercent > 50) { 33 | coveragePercent = 50; 34 | } 35 | 36 | cineScopeObject.addProperty("visible", showCineScopes); 37 | cineScopeObject.addProperty("coverage", coveragePercent); 38 | cineScopeObject.addProperty("duration", duration); 39 | 40 | this.payloadCommunicator.sendLabyModMessage(uniqueId, CINESCOPES_CHANNEL, cineScopeObject); 41 | } 42 | 43 | @Override 44 | public void broadcastSendCineScope(boolean showCineScopes, int coveragePercent, long duration) { 45 | for (LabyModPlayer player : this.playerService.getPlayers()) { 46 | this.sendCineScope(player.getUniqueId(), showCineScopes, coveragePercent, duration); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/player/DefaultLabyModPlayerService.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.player; 2 | 3 | import net.labymod.serverapi.api.player.LabyModPlayer; 4 | import net.labymod.serverapi.api.player.LabyModPlayerService; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Optional; 9 | import java.util.UUID; 10 | import java.util.function.Predicate; 11 | 12 | public class DefaultLabyModPlayerService implements LabyModPlayerService { 13 | 14 | private final List> labyModPlayers; 15 | 16 | public DefaultLabyModPlayerService() { 17 | this.labyModPlayers = new ArrayList<>(); 18 | } 19 | 20 | /** {@inheritDoc} */ 21 | @Override 22 | public void registerPlayer(LabyModPlayer player) { 23 | if (!this.getPlayer(player.getUniqueId()).isPresent()) { 24 | this.labyModPlayers.add(player); 25 | } 26 | } 27 | 28 | /** {@inheritDoc} */ 29 | @Override 30 | public void unregisterPlayer(LabyModPlayer player) { 31 | this.labyModPlayers.remove(player); 32 | } 33 | 34 | /** {@inheritDoc} */ 35 | @Override 36 | public boolean unregisterPlayerIf(Predicate> predicate) { 37 | return this.labyModPlayers.removeIf(predicate); 38 | } 39 | 40 | /** {@inheritDoc} */ 41 | @Override 42 | public List> getPlayers() { 43 | return this.labyModPlayers; 44 | } 45 | 46 | /** {@inheritDoc} */ 47 | @Override 48 | public Optional> getPlayer(String username) { 49 | return this.labyModPlayers.stream() 50 | .filter(labyModPlayer -> labyModPlayer.getUsername().equalsIgnoreCase(username)) 51 | .findFirst(); 52 | } 53 | 54 | /** {@inheritDoc} */ 55 | @Override 56 | public Optional> getPlayer(UUID uniqueId) { 57 | return this.labyModPlayers.stream() 58 | .filter(labyModPlayer -> labyModPlayer.getUniqueId().equals(uniqueId)) 59 | .findFirst(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/event/BungeeSendPayloadEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee.event; 2 | 3 | import net.md_5.bungee.api.connection.ProxiedPlayer; 4 | import net.md_5.bungee.api.plugin.Cancellable; 5 | import net.md_5.bungee.api.plugin.Event; 6 | 7 | /** Is fired when a custom payload is sent. */ 8 | public class BungeeSendPayloadEvent extends Event implements Cancellable { 9 | 10 | private final ProxiedPlayer player; 11 | private final String channelIdentifier; 12 | private final byte[] payload; 13 | private boolean cancelled; 14 | 15 | public BungeeSendPayloadEvent(ProxiedPlayer player, String channelIdentifier, byte[] payload) { 16 | this(player, channelIdentifier, payload, false); 17 | } 18 | 19 | public BungeeSendPayloadEvent( 20 | ProxiedPlayer player, String channelIdentifier, byte[] payload, boolean cancelled) { 21 | this.player = player; 22 | this.channelIdentifier = channelIdentifier; 23 | this.payload = payload; 24 | this.cancelled = cancelled; 25 | } 26 | 27 | /** 28 | * Retrieves the player to which the payload is sent. 29 | * 30 | * @return The player to which the payload is sent. 31 | */ 32 | public ProxiedPlayer getPlayer() { 33 | return player; 34 | } 35 | 36 | /** 37 | * Retrieves the channel identifier to which the payload is sent. 38 | * 39 | * @return The channel identifier to which the payload is sent. 40 | */ 41 | public String getChannelIdentifier() { 42 | return channelIdentifier; 43 | } 44 | 45 | /** 46 | * Retrieves the sent payload message. 47 | * 48 | * @return The sent payload message. 49 | */ 50 | public byte[] getPayload() { 51 | return payload; 52 | } 53 | 54 | /** {@inheritDoc} */ 55 | @Override 56 | public boolean isCancelled() { 57 | return this.cancelled; 58 | } 59 | 60 | /** {@inheritDoc} */ 61 | @Override 62 | public void setCancelled(boolean cancel) { 63 | this.cancelled = cancel; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/labychat/PlayingGameMode.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.labychat; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * The LabyMod chat can display the name of the current game mode on the server. 7 | * 8 | * @deprecated Use {@link PlayingGameModeTransmitter} 9 | */ 10 | @Deprecated 11 | public interface PlayingGameMode { 12 | 13 | /** 14 | * Sends the current game mode to a player with the specified unique identifier. 15 | * 16 | * @param uniqueId The unique identifier of a player. 17 | * @param visible {@code true} if the current game mode should be displayed in LabyChat, otherwise 18 | * {@code false}. 19 | * @param gameModeName The name of the game mode. 20 | * @deprecated Use {@link PlayingGameModeTransmitter#transmit(UUID, boolean, String)} 21 | */ 22 | @Deprecated 23 | void sendCurrentPlayingGameMode(UUID uniqueId, boolean visible, String gameModeName); 24 | 25 | /** 26 | * Sends the current game mode to a player with the specified unique identifier. 27 | * 28 | *

Note: The functions shows the current game mode in LabyChat. 29 | * 30 | * @param uniqueId The unique identifier of a player. 31 | * @param gameModeName The name of the game mode. 32 | * @deprecated Use {@link PlayingGameModeTransmitter#transmit(UUID, String)} 33 | */ 34 | @Deprecated 35 | default void sendCurrentPlayingGameMode(UUID uniqueId, String gameModeName) { 36 | this.sendCurrentPlayingGameMode(uniqueId, true, gameModeName); 37 | } 38 | 39 | /** @deprecated Use {@link PlayingGameModeTransmitter#broadcastTransmit(boolean, String)} */ 40 | @Deprecated 41 | void broadcastCurrentlyPlayingGameMode(boolean visible, String gameModeName); 42 | 43 | /** @deprecated Use {@link PlayingGameModeTransmitter#broadcastTransmit(String)} */ 44 | @Deprecated 45 | default void broadcastCurrentlyPlayingGameMode(String gameModeName) { 46 | this.broadcastCurrentlyPlayingGameMode(true, gameModeName); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/permission/Permissible.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.permission; 2 | 3 | /** Represents a Labymod permission. */ 4 | public interface Permissible { 5 | 6 | /** 7 | * Retrieves the internal name of this permission. 8 | * 9 | *

Note: The internal name is sent to the client. 10 | * 11 | * @return The permission's internal name. 12 | */ 13 | String getInternalName(); 14 | 15 | /** 16 | * Retrieves the name of this permission. 17 | * 18 | * @return The permission's name. 19 | */ 20 | String getName(); 21 | 22 | /** 23 | * Whether the permission is enabled. 24 | * 25 | * @return {@code true} if the permission is enabled, otherwise {@code false}. 26 | */ 27 | boolean isEnabled(); 28 | 29 | /** 30 | * Changes whether the permission is enabled. 31 | * 32 | * @param enabled {@code true} if the permission should be enabled, otherwise {@code false}. 33 | */ 34 | void setEnabled(boolean enabled); 35 | 36 | /** A factory for creating {@link Permissible}'s. */ 37 | interface Factory { 38 | 39 | /** 40 | * Creates a new {@link Permissible} with the given name. 41 | * 42 | *

Note: The created permission is default enabled. 43 | * 44 | * @param internalName The internal name of the permission. 45 | * @param name The name of the permission to be created. 46 | * @return A created permission. 47 | */ 48 | Permissible create(String internalName, String name); 49 | 50 | /** 51 | * Creates a new {@link Permissible} with the given name and the enable state. 52 | * 53 | * @param internalName The internal name of the permission. 54 | * @param name The name of the permission to be created. 55 | * @param enabled {@code true} if the permission should be enabled, otherwise {@code false}. 56 | * @return A created permission. 57 | */ 58 | Permissible create(String internalName, String name, boolean enabled); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/LabyDebugger.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api; 2 | 3 | /** Represents the debugger for the plugin. */ 4 | public interface LabyDebugger { 5 | 6 | /** 7 | * Whether the plugin is in debug mode. 8 | * 9 | * @return {@code true} if the plugin is in debug mode, otherwise {@code false}. 10 | */ 11 | boolean isDebug(); 12 | 13 | /** 14 | * Changes whether the plugin is in debug mode. 15 | * 16 | * @param debug {@code true} if the plugin should be in debug mode, otherwise {@code false}. 17 | */ 18 | void setDebug(boolean debug); 19 | 20 | /** 21 | * Logs a message at the INFO level. 22 | * 23 | * @param message The message string to be logged. 24 | */ 25 | void info(String message); 26 | 27 | /** 28 | * Logs an exception (throwable) at the INFO level with an accompanying message. 29 | * 30 | * @param message The message accompanying the exception. 31 | * @param throwable The exception (throwable) to be log. 32 | */ 33 | void info(String message, Throwable throwable); 34 | 35 | /** 36 | * Logs a message at the WARN level. 37 | * 38 | * @param message The message string to be logged. 39 | */ 40 | void warn(String message); 41 | 42 | /** 43 | * Logs an exception (throwable) at the WARN level with an accompanying message. 44 | * 45 | * @param message The message accompanying the exception. 46 | * @param throwable The exception (throwable) to be log. 47 | */ 48 | void warn(String message, Throwable throwable); 49 | 50 | /** 51 | * Logs a message at the ERROR level. 52 | * 53 | * @param message The message string to be logged. 54 | */ 55 | void error(String message); 56 | 57 | /** 58 | * Logs an exception (throwable) at the ERROR level with an accompanying message. 59 | * 60 | * @param message The message accompanying the exception. 61 | * @param throwable The exception (throwable) to be log. 62 | */ 63 | void error(String message, Throwable throwable); 64 | } 65 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultCineScopesTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.LabyService; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.player.LabyModPlayerService; 9 | import net.labymod.serverapi.api.serverinteraction.CineScopesTransmitter; 10 | 11 | public class DefaultCineScopesTransmitter implements CineScopesTransmitter { 12 | 13 | private static final String CINESCOPES_CHANNEL = "cinescopes"; 14 | 15 | private final LabyModPlayerService playerService; 16 | private final PayloadCommunicator payloadCommunicator; 17 | 18 | public DefaultCineScopesTransmitter(LabyService service) { 19 | this.payloadCommunicator = service.getPayloadCommunicator(); 20 | this.playerService = service.getLabyPlayerService(); 21 | } 22 | 23 | /** {@inheritDoc} */ 24 | @Override 25 | public void transmit(UUID uniqueId, boolean showCineScopes, int coveragePercent, long duration) { 26 | JsonObject cineScopeObject = new JsonObject(); 27 | 28 | if (coveragePercent < 0) { 29 | coveragePercent = 0; 30 | } else if (coveragePercent > 50) { 31 | coveragePercent = 50; 32 | } 33 | 34 | cineScopeObject.addProperty("visible", showCineScopes); 35 | cineScopeObject.addProperty("coverage", coveragePercent); 36 | cineScopeObject.addProperty("duration", duration); 37 | 38 | this.payloadCommunicator.sendLabyModMessage(uniqueId, CINESCOPES_CHANNEL, cineScopeObject); 39 | } 40 | 41 | /** {@inheritDoc} */ 42 | @Override 43 | public void broadcastTransmit(boolean showCineScopes, int coveragePercent, long duration) { 44 | for (LabyModPlayer player : this.playerService.getPlayers()) { 45 | this.transmit(player.getUniqueId(), showCineScopes, coveragePercent, duration); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/emote/EmoteTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.emote; 2 | 3 | import net.labymod.serverapi.api.serverinteraction.Watermark; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * Represents an emote transmitter that sends a payload message in channel emote_api to the 9 | * LabyMod client. 10 | * 11 | *

Overview: 12 | * 13 | *

LabyMod users can play client side an emote for all other players on the Minecraft server. 14 | * Minecraft servers can also force-play emotes for specific player's using the payload messages. 15 | * 16 | *

Warning: This works only for NPC's and not for real players. 17 | * 18 | *

Servers can make NPC's do emotes. To prevent abuse, this does not work for real players. To 19 | * enforce this, emotes can only be forced for players that have the second half of their {@link 20 | * UUID} entirely being 0 (64 least significant bits are 0, or the second long value equals 0) You 21 | * therefore need to spawn them with a unique identifier like this. 22 | * 23 | *

This rule does not apply if the {@link Watermark} feature is activated. 24 | */ 25 | public interface EmoteTransmitter { 26 | 27 | /** 28 | * Adds an emote to a list to be played when sending. 29 | * 30 | * @param emote The emote which should be played. 31 | * @return This object for a fluent chaining. 32 | */ 33 | EmoteTransmitter addEmote(Emote emote); 34 | 35 | /** 36 | * Adds to a list an array of emotes to be played when sending. 37 | * 38 | * @param emotes An array emotes which should be played. 39 | * @return This object for a fluent chaining. 40 | */ 41 | EmoteTransmitter addEmotes(Emote... emotes); 42 | 43 | /** 44 | * Transmits a list of all forced emotes to the client. 45 | * 46 | * @param receiverUniqueId The unique identifier of the receiver. 47 | */ 48 | void transmit(UUID receiverUniqueId); 49 | 50 | /** Transmits a list of all forced emotes to all online laby users. */ 51 | void broadcastTransmit(); 52 | } 53 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/addon/DefaultAddonRecommendation.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.addon; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.serverinteraction.addon.AddonRecommendation; 7 | import net.labymod.serverapi.api.serverinteraction.addon.RecommendedAddon; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | import java.util.UUID; 13 | 14 | public class DefaultAddonRecommendation implements AddonRecommendation { 15 | 16 | private static final String ADDON_RECOMMENDATION_CHANNEL = "addon_recommendation"; 17 | private final PayloadCommunicator payloadCommunicator; 18 | private final List recommendedAddons; 19 | 20 | public DefaultAddonRecommendation(LabyService service) { 21 | this.payloadCommunicator = service.getPayloadCommunicator(); 22 | this.recommendedAddons = new ArrayList<>(); 23 | } 24 | 25 | /** {@inheritDoc} */ 26 | @Override 27 | public AddonRecommendation addRecommendAddon(RecommendedAddon recommendedAddon) { 28 | this.recommendedAddons.add(recommendedAddon); 29 | return this; 30 | } 31 | 32 | /** {@inheritDoc} */ 33 | @Override 34 | public AddonRecommendation addRecommendAddons(RecommendedAddon... recommendedAddons) { 35 | this.recommendedAddons.addAll(Arrays.asList(recommendedAddons)); 36 | return this; 37 | } 38 | 39 | /** {@inheritDoc} */ 40 | @Override 41 | public void sendRecommendAddons(UUID uniqueId) { 42 | JsonArray recommendAddons = new JsonArray(); 43 | 44 | for (RecommendedAddon addonRecommendation : this.recommendedAddons) { 45 | recommendAddons.add(addonRecommendation.asJsonObject()); 46 | } 47 | 48 | this.recommendedAddons.clear(); 49 | 50 | this.payloadCommunicator.sendLabyModMessage( 51 | uniqueId, ADDON_RECOMMENDATION_CHANNEL, recommendAddons); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/actionmenu/DefaultMenuTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.actionmenu; 2 | 3 | import com.google.gson.JsonArray; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.LabyService; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.player.LabyModPlayerService; 9 | import net.labymod.serverapi.api.serverinteraction.actionmenu.MenuEntry; 10 | import net.labymod.serverapi.api.serverinteraction.actionmenu.MenuTransmitter; 11 | 12 | public class DefaultMenuTransmitter implements MenuTransmitter { 13 | 14 | private static final String USER_MENU_ACTIONS_CHANNEL = "user_menu_actions"; 15 | 16 | private final LabyModPlayerService playerService; 17 | private final PayloadCommunicator payloadCommunicator; 18 | private final JsonArray entries; 19 | 20 | public DefaultMenuTransmitter(LabyService service) { 21 | this.payloadCommunicator = service.getPayloadCommunicator(); 22 | this.playerService = service.getLabyPlayerService(); 23 | this.entries = new JsonArray(); 24 | } 25 | 26 | /** {@inheritDoc} */ 27 | @Override 28 | public MenuTransmitter addEntry(MenuEntry entry) { 29 | this.entries.add(entry.asJsonObject()); 30 | return this; 31 | } 32 | 33 | /** {@inheritDoc} */ 34 | @Override 35 | public MenuTransmitter addEntries(MenuEntry... entries) { 36 | for (MenuEntry entry : entries) { 37 | this.entries.add(entry.asJsonObject()); 38 | } 39 | return this; 40 | } 41 | 42 | /** {@inheritDoc} */ 43 | @Override 44 | public void transmit(UUID uniqueId) { 45 | this.payloadCommunicator.sendLabyModMessage(uniqueId, USER_MENU_ACTIONS_CHANNEL, this.entries); 46 | } 47 | 48 | /** {@inheritDoc} */ 49 | @Override 50 | public void broadcastTransmit() { 51 | for (LabyModPlayer player : this.playerService.getPlayers()) { 52 | this.transmit(player.getUniqueId()); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/player/BukkitLabyModPlayerFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.player; 2 | 3 | 4 | import net.labymod.serverapi.api.extension.AddonExtension; 5 | import net.labymod.serverapi.api.extension.ModificationExtension; 6 | import net.labymod.serverapi.api.extension.PackageExtension; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 9 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 10 | import net.labymod.serverapi.common.player.DefaultLabyModPlayerFactory; 11 | import org.bukkit.entity.Player; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.UUID; 16 | 17 | 18 | public class BukkitLabyModPlayerFactory extends DefaultLabyModPlayerFactory { 19 | 20 | /** {@inheritDoc} */ 21 | @Override 22 | public LabyModPlayer create( 23 | Player player, 24 | String username, 25 | UUID uniqueId, 26 | String version, 27 | ChunkCachingProtocol chunkCachingProtocol, 28 | ShadowProtocol shadowProtocol, 29 | List addons, 30 | List modifications) { 31 | return this.create( 32 | player, 33 | player.getName(), 34 | player.getUniqueId(), 35 | version, 36 | chunkCachingProtocol, 37 | shadowProtocol, 38 | addons, 39 | modifications, 40 | new ArrayList<>()); 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public LabyModPlayer create( 46 | Player player, 47 | String username, 48 | UUID uniqueId, 49 | String version, 50 | ChunkCachingProtocol chunkCachingProtocol, 51 | ShadowProtocol shadowProtocol, 52 | List addons, 53 | List modifications, 54 | List packages) { 55 | return new BukkitLabyModPlayer( 56 | player, version, chunkCachingProtocol, shadowProtocol, addons, modifications, packages); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/player/LabyModPlayerService.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.player; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | import java.util.UUID; 6 | import java.util.function.Predicate; 7 | 8 | /** 9 | * Represents a player service for the LabyMod. 10 | * 11 | * @param The player type of the specified platform. 12 | */ 13 | public interface LabyModPlayerService { 14 | 15 | int[] NON_LEGACY_SUPPORT_VERSION = new int[] {3, 8, 0}; 16 | 17 | /** 18 | * Registers a LabyMod player. 19 | * 20 | * @param player The player to be registered. 21 | */ 22 | void registerPlayer(LabyModPlayer player); 23 | 24 | /** 25 | * Unregisters a LabyMod player. 26 | * 27 | * @param player The player to be unregistered. 28 | */ 29 | void unregisterPlayer(LabyModPlayer player); 30 | 31 | /** 32 | * Unregisters a LabyMod player that satisfy the given {@code predicate.} 33 | * 34 | * @param predicate A predicate which returns {@code true} for player to be removed. 35 | * @return {@code true} if any players were removed, otherwise {@code false}. 36 | */ 37 | boolean unregisterPlayerIf(Predicate> predicate); 38 | 39 | /** 40 | * Retrieves a collection with all connected LabyMod players. 41 | * 42 | * @return A collection with all connected LabyMod players. 43 | */ 44 | List> getPlayers(); 45 | 46 | /** 47 | * Retrieves the player currently connected with LabyMod by their Minecraft username. 48 | * 49 | * @param username The username of a LabyMod player. 50 | * @return An optional with the player that can be empty. 51 | */ 52 | Optional> getPlayer(String username); 53 | 54 | /** 55 | * Retrieves the player currently connected with LabyMod by their Minecraft unique identifier. 56 | * 57 | * @param uniqueId The unique identifier of a LabyMod player. 58 | * @return An optional with the player that can be empty. 59 | */ 60 | Optional> getPlayer(UUID uniqueId); 61 | } 62 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/player/DefaultLabyModPlayerFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.player; 2 | 3 | import net.labymod.serverapi.api.extension.AddonExtension; 4 | import net.labymod.serverapi.api.extension.ModificationExtension; 5 | import net.labymod.serverapi.api.extension.PackageExtension; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayer.Factory; 8 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 9 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.UUID; 14 | 15 | public class DefaultLabyModPlayerFactory implements Factory { 16 | 17 | /** {@inheritDoc} */ 18 | @Override 19 | public LabyModPlayer create( 20 | T player, 21 | String username, 22 | UUID uniqueId, 23 | String version, 24 | ChunkCachingProtocol chunkCachingProtocol, 25 | ShadowProtocol shadowProtocol, 26 | List addons, 27 | List modifications) { 28 | return this.create( 29 | player, 30 | username, 31 | uniqueId, 32 | version, 33 | chunkCachingProtocol, 34 | shadowProtocol, 35 | addons, 36 | modifications, 37 | new ArrayList<>()); 38 | } 39 | 40 | /** {@inheritDoc} */ 41 | @Override 42 | public LabyModPlayer create( 43 | T player, 44 | String username, 45 | UUID uniqueId, 46 | String version, 47 | ChunkCachingProtocol chunkCachingProtocol, 48 | ShadowProtocol shadowProtocol, 49 | List addons, 50 | List modifications, 51 | List packages) { 52 | return new DefaultLabyModPlayer<>( 53 | player, 54 | username, 55 | uniqueId, 56 | version, 57 | chunkCachingProtocol, 58 | shadowProtocol, 59 | addons, 60 | modifications, 61 | packages); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/BukkitLabyDebugger.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit; 2 | 3 | import net.labymod.serverapi.common.AbstractLabyDebugger; 4 | 5 | public class BukkitLabyDebugger extends AbstractLabyDebugger { 6 | 7 | private static final String DEBUG_MESSAGE_FORMAT = "[LabyApi] %s"; 8 | private final BukkitLabyModPlugin plugin; 9 | 10 | public BukkitLabyDebugger(BukkitLabyModPlugin plugin) { 11 | this.plugin = plugin; 12 | } 13 | 14 | /** {@inheritDoc} */ 15 | @Override 16 | public void info(String message) { 17 | if (this.isDebug()) { 18 | this.plugin.getLogger().info(String.format(DEBUG_MESSAGE_FORMAT, message)); 19 | } 20 | } 21 | 22 | /** {@inheritDoc} */ 23 | @Override 24 | public void info(String message, Throwable throwable) { 25 | if (this.isDebug()) { 26 | this.plugin 27 | .getLogger() 28 | .info(String.format(DEBUG_MESSAGE_FORMAT + " (%s)", message, throwable.getMessage())); 29 | } 30 | } 31 | 32 | /** {@inheritDoc} */ 33 | @Override 34 | public void warn(String message) { 35 | if (this.isDebug()) { 36 | this.plugin.getLogger().warning(String.format(DEBUG_MESSAGE_FORMAT, message)); 37 | } 38 | } 39 | 40 | /** {@inheritDoc} */ 41 | @Override 42 | public void warn(String message, Throwable throwable) { 43 | if (this.isDebug()) { 44 | this.plugin 45 | .getLogger() 46 | .warning(String.format(DEBUG_MESSAGE_FORMAT + " (%s)", message, throwable.getMessage())); 47 | } 48 | } 49 | 50 | /** {@inheritDoc} */ 51 | @Override 52 | public void error(String message) { 53 | if (this.isDebug()) { 54 | this.plugin.getLogger().severe(String.format(DEBUG_MESSAGE_FORMAT, message)); 55 | } 56 | } 57 | 58 | /** {@inheritDoc} */ 59 | @Override 60 | public void error(String message, Throwable throwable) { 61 | if (this.isDebug()) { 62 | this.plugin 63 | .getLogger() 64 | .severe(String.format(DEBUG_MESSAGE_FORMAT + " (%s)", message, throwable.getMessage())); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/BungeeLabyDebugger.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee; 2 | 3 | import net.labymod.serverapi.common.AbstractLabyDebugger; 4 | 5 | public class BungeeLabyDebugger extends AbstractLabyDebugger { 6 | 7 | private static final String DEBUG_MESSAGE_FORMAT = "[LabyApi] %s"; 8 | private final BungeeLabyModPlugin plugin; 9 | 10 | public BungeeLabyDebugger(BungeeLabyModPlugin plugin) { 11 | this.plugin = plugin; 12 | } 13 | 14 | /** {@inheritDoc} */ 15 | @Override 16 | public void info(String message) { 17 | if (this.isDebug()) { 18 | this.plugin.getLogger().info(String.format(DEBUG_MESSAGE_FORMAT, message)); 19 | } 20 | } 21 | 22 | /** {@inheritDoc} */ 23 | @Override 24 | public void info(String message, Throwable throwable) { 25 | if (this.isDebug()) { 26 | this.plugin 27 | .getLogger() 28 | .info(String.format(DEBUG_MESSAGE_FORMAT + " (%s)", message, throwable.getMessage())); 29 | } 30 | } 31 | 32 | /** {@inheritDoc} */ 33 | @Override 34 | public void warn(String message) { 35 | if (this.isDebug()) { 36 | this.plugin.getLogger().warning(String.format(DEBUG_MESSAGE_FORMAT, message)); 37 | } 38 | } 39 | 40 | /** {@inheritDoc} */ 41 | @Override 42 | public void warn(String message, Throwable throwable) { 43 | if (this.isDebug()) { 44 | this.plugin 45 | .getLogger() 46 | .warning(String.format(DEBUG_MESSAGE_FORMAT + " (%s)", message, throwable.getMessage())); 47 | } 48 | } 49 | 50 | /** {@inheritDoc} */ 51 | @Override 52 | public void error(String message) { 53 | if (this.isDebug()) { 54 | this.plugin.getLogger().severe(String.format(DEBUG_MESSAGE_FORMAT, message)); 55 | } 56 | } 57 | 58 | /** {@inheritDoc} */ 59 | @Override 60 | public void error(String message, Throwable throwable) { 61 | if (this.isDebug()) { 62 | this.plugin 63 | .getLogger() 64 | .severe(String.format(DEBUG_MESSAGE_FORMAT + " (%s)", message, throwable.getMessage())); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/player/VelocityLabyModPlayerFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity.player; 2 | 3 | 4 | import com.velocitypowered.api.proxy.Player; 5 | import net.labymod.serverapi.api.extension.AddonExtension; 6 | import net.labymod.serverapi.api.extension.ModificationExtension; 7 | import net.labymod.serverapi.api.extension.PackageExtension; 8 | import net.labymod.serverapi.api.player.LabyModPlayer; 9 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 10 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 11 | import net.labymod.serverapi.common.player.DefaultLabyModPlayerFactory; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.UUID; 16 | 17 | 18 | public class VelocityLabyModPlayerFactory extends DefaultLabyModPlayerFactory { 19 | 20 | /** {@inheritDoc} */ 21 | @Override 22 | public LabyModPlayer create( 23 | Player player, 24 | String username, 25 | UUID uniqueId, 26 | String version, 27 | ChunkCachingProtocol chunkCachingProtocol, 28 | ShadowProtocol shadowProtocol, 29 | List addons, 30 | List modifications) { 31 | return this.create( 32 | player, 33 | player.getUsername(), 34 | player.getUniqueId(), 35 | version, 36 | chunkCachingProtocol, 37 | shadowProtocol, 38 | addons, 39 | modifications, 40 | new ArrayList<>()); 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public LabyModPlayer create( 46 | Player player, 47 | String username, 48 | UUID uniqueId, 49 | String version, 50 | ChunkCachingProtocol chunkCachingProtocol, 51 | ShadowProtocol shadowProtocol, 52 | List addons, 53 | List modifications, 54 | List packages) { 55 | return new VelocityLabyModPlayer( 56 | player, version, chunkCachingProtocol, shadowProtocol, addons, modifications, packages); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultAddonExtensionCollector.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonObject; 5 | import net.labymod.serverapi.api.extension.AddonExtension; 6 | import net.labymod.serverapi.api.extension.ExtensionCollector; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Collections; 10 | import java.util.List; 11 | import java.util.UUID; 12 | 13 | 14 | public class DefaultAddonExtensionCollector implements ExtensionCollector { 15 | 16 | private final AddonExtension.Factory addonExtensionFactory; 17 | 18 | 19 | public DefaultAddonExtensionCollector() { 20 | this.addonExtensionFactory = new DefaultAddonExtensionFactory(); 21 | } 22 | 23 | /** {@inheritDoc} */ 24 | @Override 25 | public List collect(JsonObject object) { 26 | if (!object.has("addons") || !object.get("addons").isJsonArray()) { 27 | return Collections.emptyList(); 28 | } 29 | 30 | List addonExtensions = new ArrayList<>(); 31 | 32 | for (JsonElement element : object.get("addons").getAsJsonArray()) { 33 | if (!element.isJsonObject()) { 34 | continue; 35 | } 36 | 37 | JsonObject addonObject = element.getAsJsonObject(); 38 | 39 | if (this.shouldString(addonObject, "uuid") || this.shouldString(addonObject, "name")) { 40 | continue; 41 | } 42 | 43 | UUID uniqueId; 44 | 45 | try { 46 | uniqueId = UUID.fromString(addonObject.get("uuid").getAsString()); 47 | } catch (IllegalArgumentException ignored) { 48 | continue; 49 | } 50 | 51 | addonExtensions.add( 52 | this.addonExtensionFactory.create(addonObject.get("name").getAsString(), uniqueId)); 53 | } 54 | 55 | return addonExtensions; 56 | } 57 | 58 | private boolean shouldString(JsonObject object, String name) { 59 | return !object.has(name) 60 | || !object.get(name).isJsonPrimitive() 61 | || !object.get(name).getAsJsonPrimitive().isString(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/subtitle/DefaultSubTitleTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.subtitle; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.subtile.SubTitle; 9 | import net.labymod.serverapi.api.serverinteraction.subtile.SubTitleTransmitter; 10 | 11 | import java.util.UUID; 12 | 13 | public class DefaultSubTitleTransmitter implements SubTitleTransmitter { 14 | 15 | private static final String ACCOUNT_SUBTITLE_CHANNEL = "account_subtitle"; 16 | 17 | private final LabyModPlayerService playerService; 18 | private final PayloadCommunicator payloadCommunicator; 19 | private final JsonArray subTitles; 20 | 21 | public DefaultSubTitleTransmitter(LabyService service) { 22 | this.payloadCommunicator = service.getPayloadCommunicator(); 23 | this.playerService = service.getLabyPlayerService(); 24 | this.subTitles = new JsonArray(); 25 | } 26 | 27 | /** {@inheritDoc} */ 28 | @Override 29 | public SubTitleTransmitter addSubtitle(SubTitle subTitle) { 30 | this.subTitles.add(subTitle.asJsonObject()); 31 | return this; 32 | } 33 | 34 | /** {@inheritDoc} */ 35 | @Override 36 | public SubTitleTransmitter addSubtitles(SubTitle... subTitles) { 37 | for (SubTitle subTitle : subTitles) { 38 | this.subTitles.add(subTitle.asJsonObject()); 39 | } 40 | return this; 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public void transmit(UUID uniqueId) { 46 | this.payloadCommunicator.sendLabyModMessage(uniqueId, ACCOUNT_SUBTITLE_CHANNEL, this.subTitles); 47 | } 48 | 49 | /** {@inheritDoc} */ 50 | @Override 51 | public void broadcastTransmit() { 52 | for (LabyModPlayer player : this.playerService.getPlayers()) { 53 | this.transmit(player.getUniqueId()); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/addon/DefaultAddonRecommendationTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.addon; 2 | 3 | import com.google.gson.JsonArray; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.List; 7 | import java.util.UUID; 8 | import net.labymod.serverapi.api.LabyService; 9 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 10 | import net.labymod.serverapi.api.serverinteraction.addon.AddonRecommendationTransmitter; 11 | import net.labymod.serverapi.api.serverinteraction.addon.RecommendedAddon; 12 | 13 | public class DefaultAddonRecommendationTransmitter implements AddonRecommendationTransmitter { 14 | 15 | private static final String ADDON_RECOMMENDATION_CHANNEL = "addon_recommendation"; 16 | private final PayloadCommunicator payloadCommunicator; 17 | private final List recommendedAddons; 18 | 19 | public DefaultAddonRecommendationTransmitter(LabyService service) { 20 | this.payloadCommunicator = service.getPayloadCommunicator(); 21 | this.recommendedAddons = new ArrayList<>(); 22 | } 23 | 24 | /** {@inheritDoc} */ 25 | @Override 26 | public AddonRecommendationTransmitter addRecommendAddon(RecommendedAddon recommendedAddon) { 27 | this.recommendedAddons.add(recommendedAddon); 28 | return this; 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public AddonRecommendationTransmitter addRecommendAddons(RecommendedAddon... recommendedAddons) { 34 | this.recommendedAddons.addAll(Arrays.asList(recommendedAddons)); 35 | return this; 36 | } 37 | 38 | /** {@inheritDoc} */ 39 | @Override 40 | public void transmit(UUID uniqueId) { 41 | 42 | JsonArray recommendAddons = new JsonArray(); 43 | 44 | for (RecommendedAddon addonRecommendation : this.recommendedAddons) { 45 | recommendAddons.add(addonRecommendation.asJsonObject()); 46 | } 47 | 48 | this.recommendedAddons.clear(); 49 | 50 | this.payloadCommunicator.sendLabyModMessage( 51 | uniqueId, ADDON_RECOMMENDATION_CHANNEL, recommendAddons); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/player/BungeeLabyModPlayerFactory.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee.player; 2 | 3 | 4 | import net.labymod.serverapi.api.extension.AddonExtension; 5 | import net.labymod.serverapi.api.extension.ModificationExtension; 6 | import net.labymod.serverapi.api.extension.PackageExtension; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 9 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 10 | import net.labymod.serverapi.common.player.DefaultLabyModPlayerFactory; 11 | import net.md_5.bungee.api.connection.ProxiedPlayer; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.UUID; 16 | 17 | 18 | public class BungeeLabyModPlayerFactory extends DefaultLabyModPlayerFactory { 19 | 20 | /** {@inheritDoc} */ 21 | @Override 22 | public LabyModPlayer create( 23 | ProxiedPlayer player, 24 | String username, 25 | UUID uniqueId, 26 | String version, 27 | ChunkCachingProtocol chunkCachingProtocol, 28 | ShadowProtocol shadowProtocol, 29 | List addons, 30 | List modifications) { 31 | return this.create( 32 | player, 33 | player.getName(), 34 | player.getUniqueId(), 35 | version, 36 | chunkCachingProtocol, 37 | shadowProtocol, 38 | addons, 39 | modifications, 40 | new ArrayList<>()); 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public LabyModPlayer create( 46 | ProxiedPlayer player, 47 | String username, 48 | UUID uniqueId, 49 | String version, 50 | ChunkCachingProtocol chunkCachingProtocol, 51 | ShadowProtocol shadowProtocol, 52 | List addons, 53 | List modifications, 54 | List packages) { 55 | return new BungeeLabyModPlayer( 56 | player, version, chunkCachingProtocol, shadowProtocol, addons, modifications, packages); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/ServerSwitcher.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents the server switch packet. 7 | * 8 | *

Overview: 9 | * 10 | *

With out server switch packet you can send LabyMod users between different servers. The server 11 | * can request a user to directly connect to a different IP address (or domain name). This can be 12 | * used to create multi-server-networks. As this does not need any extra proxy software and 13 | * hardware, it is generally cheaper for a network to connect players directly to the server instead 14 | * of using an intermediate software like BungeeCord. 15 | * 16 | * @deprecated Use {@link ServerSwitcherTransmitter} 17 | */ 18 | @Deprecated 19 | public interface ServerSwitcher { 20 | 21 | /** 22 | * Sends a player to another network or server. 23 | * 24 | * @param uniqueId The unique identifier of a player which should be sent to another 25 | * network/server. 26 | * @param title The title of the warning. 27 | * @param address The address of the network / server where the player should be sent to. 28 | * @param preview {@code true} if information about the network / server should be displayed, 29 | * otherwise {@code false}. 30 | * @deprecated Use {@link ServerSwitcherTransmitter#transmit(UUID, String, String, boolean)} 31 | */ 32 | @Deprecated 33 | void sendPlayerToServer(UUID uniqueId, String title, String address, boolean preview); 34 | 35 | /** 36 | * Sends all online laby user to another network or server. 37 | * 38 | * @param title The title of the warning. 39 | * @param address The address of the network / server where the players should be sent to. 40 | * @param preview {@code true} if information about the network / server should be displayed, 41 | * otherwise {@code false}. 42 | * @deprecated Use {@link ServerSwitcherTransmitter#broadcastTransmit(String, String, boolean)} 43 | */ 44 | @Deprecated 45 | void broadcastSendPlayerToServer(String title, String address, boolean preview); 46 | } 47 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/economy/DefaultEconomyDisplayTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.economy; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.LabyService; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.player.LabyModPlayerService; 9 | import net.labymod.serverapi.api.serverinteraction.economy.EconomyBalanceType; 10 | import net.labymod.serverapi.api.serverinteraction.economy.EconomyDisplayTransmitter; 11 | 12 | public class DefaultEconomyDisplayTransmitter implements EconomyDisplayTransmitter { 13 | 14 | private static final String ECONOMY_CHANNEL = "economy"; 15 | 16 | private final PayloadCommunicator payloadCommunicator; 17 | private final LabyModPlayerService playerService; 18 | 19 | public DefaultEconomyDisplayTransmitter(LabyService service) { 20 | this.payloadCommunicator = service.getPayloadCommunicator(); 21 | this.playerService = service.getLabyPlayerService(); 22 | } 23 | 24 | /** {@inheritDoc} */ 25 | @Override 26 | public void transmit( 27 | UUID uniqueId, 28 | EconomyBalanceType economyBalanceType, 29 | boolean showBalanceDisplay, 30 | int balance) { 31 | JsonObject economyObject = new JsonObject(); 32 | JsonObject cashObject = new JsonObject(); 33 | 34 | cashObject.addProperty("visible", showBalanceDisplay); 35 | cashObject.addProperty("balance", balance); 36 | 37 | economyObject.add(economyBalanceType.getKey(), cashObject); 38 | 39 | this.payloadCommunicator.sendLabyModMessage(uniqueId, ECONOMY_CHANNEL, economyObject); 40 | } 41 | 42 | /** {@inheritDoc} */ 43 | @Override 44 | public void broadcastTransmit( 45 | EconomyBalanceType economyBalanceType, boolean showBalanceDisplay, int balance) { 46 | for (LabyModPlayer player : this.playerService.getPlayers()) { 47 | this.transmit(player.getUniqueId(), economyBalanceType, showBalanceDisplay, balance); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/economy/DefaultEconomyDisplay.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.economy; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.economy.EconomyBalanceType; 9 | import net.labymod.serverapi.api.serverinteraction.economy.EconomyDisplay; 10 | 11 | import java.util.UUID; 12 | 13 | public class DefaultEconomyDisplay implements EconomyDisplay { 14 | 15 | private static final String ECONOMY_CHANNEL = "economy"; 16 | 17 | private final PayloadCommunicator payloadCommunicator; 18 | private final LabyModPlayerService playerService; 19 | 20 | public DefaultEconomyDisplay(LabyService service) { 21 | this.payloadCommunicator = service.getPayloadCommunicator(); 22 | this.playerService = service.getLabyPlayerService(); 23 | } 24 | 25 | /** {@inheritDoc} */ 26 | @Override 27 | public void sendBalanceDisplay( 28 | UUID uniqueId, 29 | EconomyBalanceType economyBalanceType, 30 | boolean showBalanceDisplay, 31 | int balance) { 32 | 33 | JsonObject economyObject = new JsonObject(); 34 | JsonObject cashObject = new JsonObject(); 35 | 36 | cashObject.addProperty("visible", showBalanceDisplay); 37 | cashObject.addProperty("balance", balance); 38 | 39 | economyObject.add(economyBalanceType.getKey(), cashObject); 40 | 41 | this.payloadCommunicator.sendLabyModMessage(uniqueId, ECONOMY_CHANNEL, economyObject); 42 | } 43 | 44 | /** {@inheritDoc} */ 45 | @Override 46 | public void broadcastSendBalanceDisplay( 47 | EconomyBalanceType economyBalanceType, boolean showBalanceDisplay, int balance) { 48 | for (LabyModPlayer player : this.playerService.getPlayers()) { 49 | this.sendBalanceDisplay( 50 | player.getUniqueId(), economyBalanceType, showBalanceDisplay, balance); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/event/VelocitySendPayloadEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity.event; 2 | 3 | import com.velocitypowered.api.event.ResultedEvent; 4 | import com.velocitypowered.api.event.connection.PluginMessageEvent.ForwardResult; 5 | import com.velocitypowered.api.proxy.Player; 6 | import com.velocitypowered.api.proxy.messages.ChannelIdentifier; 7 | 8 | /** Is fired when a custom payload is sent. */ 9 | public class VelocitySendPayloadEvent implements ResultedEvent { 10 | 11 | private final Player player; 12 | private final ChannelIdentifier channelIdentifier; 13 | private final byte[] payload; 14 | private ForwardResult result; 15 | 16 | public VelocitySendPayloadEvent( 17 | Player player, ChannelIdentifier channelIdentifier, byte[] payload) { 18 | this(player, channelIdentifier, payload, ForwardResult.forward()); 19 | } 20 | 21 | public VelocitySendPayloadEvent( 22 | Player player, ChannelIdentifier channelIdentifier, byte[] payload, ForwardResult result) { 23 | this.player = player; 24 | this.channelIdentifier = channelIdentifier; 25 | this.payload = payload; 26 | this.result = result; 27 | } 28 | 29 | /** 30 | * Retrieves the player to which the payload is sent. 31 | * 32 | * @return The player to which the payload is sent. 33 | */ 34 | public Player getPlayer() { 35 | return player; 36 | } 37 | 38 | /** 39 | * Retrieves the channel identifier to which the payload is sent. 40 | * 41 | * @return The channel identifier to which the payload is sent. 42 | */ 43 | public ChannelIdentifier getChannelIdentifier() { 44 | return channelIdentifier; 45 | } 46 | 47 | /** 48 | * Retrieves the sent payload message. 49 | * 50 | * @return The sent payload message. 51 | */ 52 | public byte[] getPayload() { 53 | return payload; 54 | } 55 | 56 | /** {@inheritDoc} */ 57 | @Override 58 | public ForwardResult getResult() { 59 | return this.result; 60 | } 61 | 62 | /** {@inheritDoc} */ 63 | @Override 64 | public void setResult(ForwardResult result) { 65 | this.result = result; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/emote/DefaultEmoteTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.emote; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.emote.Emote; 6 | import net.labymod.serverapi.api.emote.EmoteTransmitter; 7 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 8 | import net.labymod.serverapi.api.player.LabyModPlayer; 9 | import net.labymod.serverapi.api.player.LabyModPlayerService; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | /** Default implementation of the {@link EmoteTransmitter}. */ 17 | public class DefaultEmoteTransmitter implements EmoteTransmitter { 18 | 19 | private static final String EMOTE_API_CHANNEL = "emote_api"; 20 | 21 | private final LabyModPlayerService playerService; 22 | private final PayloadCommunicator payloadCommunicator; 23 | private final List emotes; 24 | 25 | public DefaultEmoteTransmitter(LabyService service) { 26 | this.playerService = service.getLabyPlayerService(); 27 | this.payloadCommunicator = service.getPayloadCommunicator(); 28 | this.emotes = new ArrayList<>(); 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public EmoteTransmitter addEmote(Emote emote) { 34 | this.emotes.add(emote); 35 | return this; 36 | } 37 | 38 | /** {@inheritDoc} */ 39 | @Override 40 | public EmoteTransmitter addEmotes(Emote... emotes) { 41 | this.emotes.addAll(Arrays.asList(emotes)); 42 | return this; 43 | } 44 | 45 | /** {@inheritDoc} */ 46 | @Override 47 | public void transmit(UUID receiverUniqueId) { 48 | JsonArray emotes = new JsonArray(); 49 | 50 | for (Emote emote : this.emotes) { 51 | emotes.add(emote.asJsonObject()); 52 | } 53 | this.emotes.clear(); 54 | this.payloadCommunicator.sendLabyModMessage(receiverUniqueId, EMOTE_API_CHANNEL, emotes); 55 | } 56 | 57 | @Override 58 | public void broadcastTransmit() { 59 | for (LabyModPlayer player : this.playerService.getPlayers()) { 60 | this.transmit(player.getUniqueId()); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/extension/DefaultModificationExtensionCollector.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.extension; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonObject; 5 | import net.labymod.serverapi.api.extension.ExtensionCollector; 6 | import net.labymod.serverapi.api.extension.ModificationExtension; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | /** 13 | * Default implementation of the {@link ExtensionCollector} to collect {@link 14 | * ModificationExtension}'s. 15 | */ 16 | public class DefaultModificationExtensionCollector 17 | implements ExtensionCollector { 18 | 19 | private final ModificationExtension.Factory modificationExtensionFactory; 20 | 21 | public DefaultModificationExtensionCollector() { 22 | this.modificationExtensionFactory = new DefaultModificationExtensionFactory(); 23 | } 24 | 25 | /** {@inheritDoc} */ 26 | @Override 27 | public List collect(JsonObject object) { 28 | if (!object.has("mods") || !object.get("mods").isJsonArray()) { 29 | return Collections.emptyList(); 30 | } 31 | 32 | List modificationExtensions = new ArrayList<>(); 33 | 34 | for (JsonElement element : object.get("mods").getAsJsonArray()) { 35 | if (!element.isJsonObject()) { 36 | continue; 37 | } 38 | 39 | JsonObject modificationObject = element.getAsJsonObject(); 40 | 41 | if (this.shouldString(modificationObject, "hash") 42 | || this.shouldString(modificationObject, "name")) { 43 | continue; 44 | } 45 | 46 | modificationExtensions.add( 47 | this.modificationExtensionFactory.create( 48 | modificationObject.get("name").getAsString(), 49 | modificationObject.get("hash").getAsString())); 50 | } 51 | 52 | return modificationExtensions; 53 | } 54 | 55 | private boolean shouldString(JsonObject object, String name) { 56 | return !object.has(name) 57 | || !object.get(name).isJsonPrimitive() 58 | || !object.get(name).getAsJsonPrimitive().isString(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/sticker/DefaultStickerTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.sticker; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.sticker.Sticker; 9 | import net.labymod.serverapi.api.sticker.StickerTransmitter; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | public class DefaultStickerTransmitter implements StickerTransmitter { 17 | 18 | private static final String STICKER_API_CHANNEL = "sticker_api"; 19 | 20 | private final PayloadCommunicator payloadCommunicator; 21 | private final LabyModPlayerService labyPlayerService; 22 | private final List stickers; 23 | 24 | public DefaultStickerTransmitter(LabyService service) { 25 | this.payloadCommunicator = service.getPayloadCommunicator(); 26 | this.labyPlayerService = service.getLabyPlayerService(); 27 | this.stickers = new ArrayList<>(); 28 | } 29 | 30 | /** {@inheritDoc} */ 31 | @Override 32 | public StickerTransmitter addSticker(Sticker sticker) { 33 | this.stickers.add(sticker); 34 | return this; 35 | } 36 | 37 | /** {@inheritDoc} */ 38 | @Override 39 | public StickerTransmitter addStickers(Sticker... stickers) { 40 | this.stickers.addAll(Arrays.asList(stickers)); 41 | return this; 42 | } 43 | 44 | /** {@inheritDoc} */ 45 | @Override 46 | public void transmit(UUID receiverUniqueId) { 47 | JsonArray stickers = new JsonArray(); 48 | 49 | for (Sticker sticker : this.stickers) { 50 | stickers.add(sticker.asJsonObject()); 51 | } 52 | this.stickers.clear(); 53 | 54 | this.payloadCommunicator.sendLabyModMessage(receiverUniqueId, STICKER_API_CHANNEL, stickers); 55 | } 56 | 57 | /** {@inheritDoc} */ 58 | @Override 59 | public void broadcastTransmit() { 60 | for (LabyModPlayer player : this.labyPlayerService.getPlayers()) { 61 | this.transmit(player.getUniqueId()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/payload/PayloadChannelRegistrar.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.payload; 2 | 3 | import com.google.common.collect.Multimap; 4 | 5 | /** Represents a registrar to register and unregister payload channel's. */ 6 | public interface PayloadChannelRegistrar { 7 | 8 | /** 9 | * Registers a new modern and legacy payload channel. 10 | * 11 | *

Note: The modern payload channel namespace is `legacy`. 12 | * 13 | * @param channelIdentifier The channel identifier for the modern and legacy payload channel. 14 | */ 15 | void registerModernLegacyChannelIdentifier(String channelIdentifier); 16 | 17 | /** 18 | * Registers a new legacy payload channel with the {@code channelIdentifier}. 19 | * 20 | * @param channelIdentifier The channel identifier for the legacy payload channel. 21 | */ 22 | void registerLegacyChannelIdentifier(String channelIdentifier); 23 | 24 | /** 25 | * Registers a new modern payload channel with the given {@code namespace} and {@code path}. 26 | * 27 | * @param namespace The namespace of the channel identifier. 28 | * @param path The path of the channel identifier. 29 | */ 30 | void registerModernChannelIdentifier(String namespace, String path); 31 | 32 | /** 33 | * Unregisters a modern and legacy payload channel. 34 | * 35 | * @param channelIdentifier The channel identifier of the payload channels to be unregistered. 36 | */ 37 | void unregisterModernLegacyChannelIdentifier(String channelIdentifier); 38 | 39 | /** 40 | * Unregisters a legacy payload channel. 41 | * 42 | * @param channelIdentifier The channel identifier to be unregistered. 43 | */ 44 | void unregisterLegacyChannelIdentifier(String channelIdentifier); 45 | 46 | /** 47 | * Unregisters a modern payload channel. 48 | * 49 | * @param namespace The namespace of the modern payload channel to be unregistered. 50 | * @param path The path of the modern payload channel to be unregistered. 51 | */ 52 | void unregisterModernChannelIdentifier(String namespace, String path); 53 | 54 | /** 55 | * Retrieves a multimap with all registered channel identifiers. 56 | * 57 | * @return A multimap with all registered channel identifiers. 58 | */ 59 | Multimap getChannelIdentifiers(); 60 | } 61 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/event/BukkitSendPayloadEvent.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.event; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Cancellable; 5 | import org.bukkit.event.HandlerList; 6 | 7 | /** Is fired when a custom payload is sent. */ 8 | public class BukkitSendPayloadEvent extends BukkitLabyModEvent implements Cancellable { 9 | 10 | private static final HandlerList HANDLER_LIST = new HandlerList(); 11 | 12 | private final Player player; 13 | private String channelIdentifier; 14 | private byte[] payload; 15 | private boolean cancelled; 16 | 17 | public BukkitSendPayloadEvent(Player player, String channelIdentifier, byte[] payload) { 18 | this(player, channelIdentifier, payload, false); 19 | } 20 | 21 | public BukkitSendPayloadEvent( 22 | Player player, String channelIdentifier, byte[] payload, boolean cancelled) { 23 | this.player = player; 24 | this.channelIdentifier = channelIdentifier; 25 | this.payload = payload; 26 | this.cancelled = cancelled; 27 | } 28 | 29 | /** 30 | * Retrieves the player to which the payload is sent. 31 | * 32 | * @return The player to which the payload is sent. 33 | */ 34 | public Player getPlayer() { 35 | return player; 36 | } 37 | 38 | /** 39 | * Retrieves the channel identifier to which the payload is sent. 40 | * 41 | * @return The channel identifier to which the payload is sent. 42 | */ 43 | public String getChannelIdentifier() { 44 | return channelIdentifier; 45 | } 46 | 47 | /** 48 | * Changes the channel identifier. 49 | * 50 | * @param channelIdentifier The new channel identifier. 51 | */ 52 | public void setChannelIdentifier(String channelIdentifier) { 53 | this.channelIdentifier = channelIdentifier; 54 | } 55 | 56 | /** 57 | * Retrieves the sent payload message. 58 | * 59 | * @return The sent payload message. 60 | */ 61 | public byte[] getPayload() { 62 | return payload; 63 | } 64 | 65 | /** 66 | * Changes the sent payload message. 67 | * 68 | * @param payload The new payload message. 69 | */ 70 | public void setPayload(byte[] payload) { 71 | this.payload = payload; 72 | } 73 | 74 | /** {@inheritDoc} */ 75 | @Override 76 | public boolean isCancelled() { 77 | return this.cancelled; 78 | } 79 | 80 | /** {@inheritDoc} */ 81 | @Override 82 | public void setCancelled(boolean cancel) { 83 | this.cancelled = cancel; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/subtile/SubTitle.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.subtile; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | import java.util.UUID; 6 | 7 | /** Represents a sub title. */ 8 | public interface SubTitle { 9 | 10 | /** 11 | * Retrieves the unique identifier of the player for which the subtitle should be displayed. 12 | * 13 | * @return The unique identifier of the player for which the subtitle should be displayed. 14 | */ 15 | UUID getUniqueId(); 16 | 17 | /** 18 | * Retrieves the value of the subtitle. 19 | * 20 | * @return The value of the subtitle. 21 | */ 22 | String getValue(); 23 | 24 | /** 25 | * Retrieves the size of the subtitle. 26 | * 27 | * @return The size of the subtitle. 28 | */ 29 | double getSize(); 30 | 31 | JsonObject getRawTextAsJson(); 32 | 33 | /** 34 | * Retrieves the subtitle as a {@link JsonObject}. 35 | * 36 | * @return The subtitle as a json object. 37 | */ 38 | JsonObject asJsonObject(); 39 | 40 | /** A factory for creating {@link SubTitle}'s. */ 41 | interface Factory { 42 | 43 | /** 44 | * Creates a new {@link SubTitle} with the given {@code uniqueId} and {@code value}. 45 | * 46 | *

Note: 47 | * 48 | *

This creates a subtitle which is {@code 0.8D} in size. 49 | * 50 | * @param uniqueId The unique identifier of the player for which the subtitle should be 51 | * displayed. 52 | * @param value The value of the subtitle. 53 | * @return A created subtitle. 54 | */ 55 | SubTitle create(UUID uniqueId, String value); 56 | 57 | SubTitle create(UUID uniqueId, JsonObject rawText); 58 | 59 | /** 60 | * Creates a new {@link SubTitle} with the given {@code uniqueId}, {@code value} and the {@code 61 | * size}. 62 | * 63 | *

Note: 64 | * 65 | *

The smallest subtitle size is {@code 0.8D} and the largest is {@code 1.6D} which is the 66 | * size of the normal Minecraft tag. 67 | * 68 | * @param uniqueId The unique identifier of the player for which the subtitle should be 69 | * displayed. 70 | * @param value The value of the subtitle. 71 | * @param size The size of the subtitle. 72 | * @return A created subtitle. 73 | */ 74 | SubTitle create(UUID uniqueId, String value, double size); 75 | 76 | SubTitle create(UUID uniqueId, JsonObject rawText, double size); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/subtitle/DefaultSubTitle.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.subtitle; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.serverinteraction.subtile.SubTitle; 5 | 6 | import java.util.UUID; 7 | 8 | public class DefaultSubTitle implements SubTitle { 9 | 10 | private final UUID uniqueId; 11 | private String value; 12 | private JsonObject rawText; 13 | private final double size; 14 | 15 | private final JsonObject subTitleObject; 16 | 17 | protected DefaultSubTitle(UUID uniqueId, String value) { 18 | this(uniqueId, value, 0.8D); 19 | } 20 | 21 | protected DefaultSubTitle(UUID uniqueId, JsonObject rawText) { 22 | this(uniqueId, rawText, 0.8D); 23 | } 24 | 25 | protected DefaultSubTitle(UUID uniqueId, String value, double size) { 26 | size = this.checkSize(size); 27 | 28 | this.uniqueId = uniqueId; 29 | this.value = value; 30 | this.size = size; 31 | this.subTitleObject = new JsonObject(); 32 | 33 | this.subTitleObject.addProperty("uuid", uniqueId.toString()); 34 | 35 | this.subTitleObject.addProperty("size", size); 36 | 37 | if (this.value != null) { 38 | this.subTitleObject.addProperty("value", value); 39 | } 40 | } 41 | 42 | protected DefaultSubTitle(UUID uniqueId, JsonObject rawText, double size) { 43 | size = this.checkSize(size); 44 | 45 | this.uniqueId = uniqueId; 46 | this.rawText = rawText; 47 | this.size = size; 48 | 49 | this.subTitleObject = new JsonObject(); 50 | 51 | this.subTitleObject.addProperty("uuid", uniqueId.toString()); 52 | this.subTitleObject.addProperty("size", size); 53 | 54 | if (this.rawText != null) { 55 | this.subTitleObject.addProperty("raw_json_text", this.rawText.toString()); 56 | } 57 | } 58 | 59 | private double checkSize(double size) { 60 | return size < 0.8D ? 0.8D : Math.min(size, 1.6D); 61 | } 62 | 63 | /** {@inheritDoc} */ 64 | @Override 65 | public UUID getUniqueId() { 66 | return this.uniqueId; 67 | } 68 | 69 | /** {@inheritDoc} */ 70 | @Override 71 | public String getValue() { 72 | return this.value; 73 | } 74 | 75 | /** {@inheritDoc} */ 76 | @Override 77 | public double getSize() { 78 | return this.size; 79 | } 80 | 81 | /** {@inheritDoc} */ 82 | @Override 83 | public JsonObject getRawTextAsJson() { 84 | return this.rawText; 85 | } 86 | 87 | /** {@inheritDoc} */ 88 | @Override 89 | public JsonObject asJsonObject() { 90 | return this.subTitleObject; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/payload/PayloadCommunicator.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.payload; 2 | 3 | import com.google.gson.JsonElement; 4 | import java.util.UUID; 5 | 6 | public interface PayloadCommunicator { 7 | 8 | /** 9 | * Sends a custom payload into the given channel {@code identifier}. 10 | * 11 | * @param uniqueId The unique identifier of a player that is to receive the payload. 12 | * @param identifier The channel identifier where the payload should be sent to . 13 | * @param payload The payload as a byte array. 14 | */ 15 | void send(UUID uniqueId, String identifier, byte[] payload); 16 | 17 | /** 18 | * Sends a custom payload into the chunk caching protocol channel. 19 | * 20 | * @param uniqueId TThe unique identifier of a player that is to receive the payload. 21 | * @param payload The payload as a byte array. 22 | */ 23 | void sendChunkCachingProtocolMessage(UUID uniqueId, byte[] payload); 24 | 25 | /** 26 | * Sends a custom payload into the shadow protocol channel. 27 | * 28 | * @param uniqueId The unique identifier of a player that is to receive the payload. 29 | * @param payload The payload as a byte array. 30 | */ 31 | void sendShadowProtocolMessage(UUID uniqueId, byte[] payload); 32 | 33 | /** 34 | * Sends a custom payload into the lava update protocol channel. 35 | * 36 | * @param uniqueId The unique identifier of a player that is to receive the payload. 37 | * @param payload The payload as a byte array. 38 | */ 39 | void sendLavaUpdateProtocolMessage(UUID uniqueId, byte[] payload); 40 | 41 | /** 42 | * Sends a custom payload as a json tree into the lmc channel. 43 | * 44 | * @param uniqueId The unique identifier of a player that is to receive the payload. 45 | * @param messageKey The key of the message. 46 | * @param messageContent The content for the message as a json tree. 47 | */ 48 | void sendLabyModMessage(UUID uniqueId, String messageKey, JsonElement messageContent); 49 | 50 | /** 51 | * Sends a custom payload message to the `labymod3:main` channel with the `server_api` key. 52 | * 53 | * @param uniqueId The unique identifier of a player that is to receive the payload. 54 | */ 55 | void sendServerApiMessage(UUID uniqueId); 56 | 57 | /** 58 | * Receives a custom payload from the given channel {@code identifier}. 59 | * 60 | * @param uniqueId The unique identifier of a player that sent the payload. 61 | * @param identifier The channel identifier to which the payload was sent. 62 | * @param payload The payload as a byte array. 63 | */ 64 | void receive(UUID uniqueId, String identifier, byte[] payload); 65 | } 66 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/discord/DefaultRichPresenceTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.discord; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.discord.RichPresenceTransmitter; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | 8 | import java.util.UUID; 9 | 10 | /** Default implementation of {@link RichPresenceTransmitter}. */ 11 | public class DefaultRichPresenceTransmitter implements RichPresenceTransmitter { 12 | 13 | private static final String DISCORD_RPC_CHANNEL = "discord_rpc"; 14 | private final PayloadCommunicator payloadCommunicator; 15 | 16 | public DefaultRichPresenceTransmitter(LabyService service) { 17 | this.payloadCommunicator = service.getPayloadCommunicator(); 18 | } 19 | 20 | /** {@inheritDoc} */ 21 | @Override 22 | public void updateRichPresenceTimer(UUID receiverUniqueId, String gameMode, long startTime) { 23 | this.updateRichPresence(receiverUniqueId, gameMode, startTime, 0L); 24 | } 25 | 26 | /** {@inheritDoc} */ 27 | @Override 28 | public void updateRichPresenceCountdown(UUID receiverUniqueId, String gameMode, long endTime) { 29 | this.updateRichPresence(receiverUniqueId, gameMode, 0L, System.currentTimeMillis()); 30 | } 31 | 32 | /** {@inheritDoc} */ 33 | @Override 34 | public void updateRichPresence( 35 | UUID receiverUniqueId, boolean hasGame, String gameMode, long startTime, long endTime) { 36 | 37 | JsonObject richPresenceObject = new JsonObject(); 38 | 39 | richPresenceObject.addProperty("hasGame", hasGame); 40 | 41 | if (hasGame) { 42 | richPresenceObject.addProperty("game_mode", gameMode); 43 | richPresenceObject.addProperty("game_startTime", startTime); 44 | richPresenceObject.addProperty("game_endTime", endTime); 45 | } 46 | 47 | this.payloadCommunicator.sendLabyModMessage( 48 | receiverUniqueId, DISCORD_RPC_CHANNEL, richPresenceObject); 49 | } 50 | 51 | /** {@inheritDoc} */ 52 | @Override 53 | public void updateParty( 54 | UUID receiverUniqueId, 55 | boolean hasParty, 56 | UUID partyLeaderUniqueId, 57 | int partySize, 58 | int maximalPartyMembers, 59 | String domain) { 60 | 61 | JsonObject partyObject = new JsonObject(); 62 | 63 | partyObject.addProperty("hasParty", hasParty); 64 | 65 | if (hasParty) { 66 | partyObject.addProperty("partyId", partyLeaderUniqueId.toString() + ":" + domain); 67 | partyObject.addProperty("party_size", partySize); 68 | partyObject.addProperty("party_max", maximalPartyMembers); 69 | } 70 | 71 | this.payloadCommunicator.sendLabyModMessage(receiverUniqueId, DISCORD_RPC_CHANNEL, partyObject); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/VelocityLabyModPlugin.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity; 2 | 3 | import com.google.inject.Inject; 4 | import com.velocitypowered.api.event.Subscribe; 5 | import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; 6 | import com.velocitypowered.api.event.proxy.ProxyShutdownEvent; 7 | import com.velocitypowered.api.proxy.ProxyServer; 8 | import com.velocitypowered.api.proxy.messages.ChannelIdentifier; 9 | import java.util.Optional; 10 | import net.labymod.serverapi.api.LabyAPI; 11 | import net.labymod.serverapi.api.LabyService; 12 | import net.labymod.serverapi.api.payload.PayloadChannelRegistrar; 13 | import net.labymod.serverapi.velocity.payload.channel.VelocityLegacyLabyModPayloadChannel; 14 | import org.slf4j.Logger; 15 | 16 | public class VelocityLabyModPlugin { 17 | 18 | private final ProxyServer proxyServer; 19 | private final Logger logger; 20 | private LabyService service; 21 | private PayloadChannelRegistrar payloadChannelRegistrar; 22 | private String pluginVersion; 23 | 24 | @Inject 25 | public VelocityLabyModPlugin(ProxyServer proxyServer, Logger logger) { 26 | this.proxyServer = proxyServer; 27 | this.logger = logger; 28 | } 29 | 30 | @Subscribe 31 | public void initialize(ProxyInitializeEvent event) { 32 | this.proxyServer 33 | .getPluginManager() 34 | .getPlugin("laby_api") 35 | .ifPresent( 36 | plugin -> { 37 | Optional versionOptional = plugin.getDescription().getVersion(); 38 | boolean present = versionOptional.isPresent(); 39 | if (present) { 40 | this.pluginVersion = versionOptional.get(); 41 | } 42 | }); 43 | 44 | this.service = new VelocityLabyService(this.proxyServer, this.logger, this.pluginVersion); 45 | LabyAPI.initialize(this.service); 46 | 47 | // Initializes the labymod server api 48 | this.payloadChannelRegistrar = this.service.getPayloadChannelRegistrar(); 49 | // LabyMod 3.0 Support 50 | this.payloadChannelRegistrar.registerModernChannelIdentifier("labymod3", "main"); 51 | 52 | this.proxyServer.getEventManager().register(this, this.service.getConnectionService()); 53 | this.proxyServer.getEventManager().register(this, this.service.getPayloadCommunicator()); 54 | this.proxyServer 55 | .getEventManager() 56 | .register(this, new VelocityLegacyLabyModPayloadChannel(this.proxyServer, this.service)); 57 | } 58 | 59 | @Subscribe 60 | public void shutdown(ProxyShutdownEvent event) { 61 | this.payloadChannelRegistrar.unregisterModernChannelIdentifier("labymod3", "main"); 62 | } 63 | 64 | @Deprecated 65 | public String getPluginVersion() { 66 | return this.service.getVersion(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/BukkitLabyService.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit; 2 | 3 | import net.labymod.serverapi.api.LabyDebugger; 4 | import net.labymod.serverapi.api.connection.ConnectionService; 5 | import net.labymod.serverapi.api.payload.PayloadChannelRegistrar; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.bukkit.connection.BukkitConnectionService; 9 | import net.labymod.serverapi.bukkit.payload.BukkitPayloadChannelRegistrar; 10 | import net.labymod.serverapi.bukkit.payload.BukkitPayloadCommunicator; 11 | import net.labymod.serverapi.common.AbstractLabyService; 12 | import net.labymod.serverapi.common.player.DefaultLabyModPlayerService; 13 | import org.bukkit.entity.Player; 14 | 15 | public class BukkitLabyService extends AbstractLabyService { 16 | 17 | private final LabyDebugger labyDebugger; 18 | private final ConnectionService connectionService; 19 | private final LabyModPlayerService playerService; 20 | private final PayloadCommunicator payloadCommunicator; 21 | private final PayloadChannelRegistrar payloadChannelRegistrar; 22 | 23 | private final String pluginVersion; 24 | 25 | public BukkitLabyService(BukkitLabyModPlugin plugin, String pluginVersion) { 26 | this.labyDebugger = new BukkitLabyDebugger(plugin); 27 | this.pluginVersion = pluginVersion; 28 | this.playerService = new DefaultLabyModPlayerService<>(); 29 | this.payloadCommunicator = new BukkitPayloadCommunicator(plugin, this); 30 | this.payloadChannelRegistrar = new BukkitPayloadChannelRegistrar(plugin, this); 31 | ((BukkitPayloadCommunicator) this.payloadCommunicator) 32 | .setPayloadChannelRegistrar(this.payloadChannelRegistrar); 33 | this.initialize(); 34 | this.connectionService = new BukkitConnectionService(this); 35 | } 36 | 37 | /** {@inheritDoc} */ 38 | @Override 39 | public String getVersion() { 40 | return this.pluginVersion; 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public LabyDebugger getLabyDebugger() { 46 | return this.labyDebugger; 47 | } 48 | 49 | /** {@inheritDoc} */ 50 | @SuppressWarnings("unchecked") 51 | @Override 52 | public

LabyModPlayerService

getLabyPlayerService() { 53 | return (LabyModPlayerService

) this.playerService; 54 | } 55 | 56 | /** {@inheritDoc} */ 57 | @Override 58 | public PayloadCommunicator getPayloadCommunicator() { 59 | return this.payloadCommunicator; 60 | } 61 | 62 | /** {@inheritDoc} */ 63 | @SuppressWarnings("unchecked") 64 | @Override 65 | public

PayloadChannelRegistrar

getPayloadChannelRegistrar() { 66 | return (PayloadChannelRegistrar

) this.payloadChannelRegistrar; 67 | } 68 | 69 | /** {@inheritDoc} */ 70 | @SuppressWarnings("unchecked") 71 | @Override 72 | public

ConnectionService

getConnectionService() { 73 | return (ConnectionService

) this.connectionService; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /proxy/bungeecord/src/main/java/net/labymod/serverapi/bungee/BungeeLabyService.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bungee; 2 | 3 | import net.labymod.serverapi.api.LabyDebugger; 4 | import net.labymod.serverapi.api.connection.ConnectionService; 5 | import net.labymod.serverapi.api.payload.PayloadChannelRegistrar; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.bungee.connection.BungeeConnectionService; 9 | import net.labymod.serverapi.bungee.payload.BungeePayloadChannelRegistrar; 10 | import net.labymod.serverapi.bungee.payload.BungeePayloadCommunicator; 11 | import net.labymod.serverapi.common.AbstractLabyService; 12 | import net.labymod.serverapi.common.player.DefaultLabyModPlayerService; 13 | import net.md_5.bungee.api.connection.ProxiedPlayer; 14 | 15 | public class BungeeLabyService extends AbstractLabyService { 16 | 17 | private final LabyDebugger labyDebugger; 18 | private final ConnectionService connectionService; 19 | private final LabyModPlayerService playerService; 20 | private final PayloadCommunicator payloadCommunicator; 21 | private final PayloadChannelRegistrar payloadChannelRegistrar; 22 | 23 | private final String pluginVersion; 24 | 25 | public BungeeLabyService(BungeeLabyModPlugin plugin, String pluginVersion) { 26 | this.labyDebugger = new BungeeLabyDebugger(plugin); 27 | this.pluginVersion = pluginVersion; 28 | this.playerService = new DefaultLabyModPlayerService<>(); 29 | this.payloadCommunicator = new BungeePayloadCommunicator(this, plugin); 30 | this.payloadChannelRegistrar = new BungeePayloadChannelRegistrar(plugin); 31 | 32 | ((BungeePayloadCommunicator) this.payloadCommunicator) 33 | .setPayloadChannelRegistrar(this.payloadChannelRegistrar); 34 | this.initialize(); 35 | this.connectionService = new BungeeConnectionService(this); 36 | } 37 | 38 | /** {@inheritDoc} */ 39 | @Override 40 | public LabyDebugger getLabyDebugger() { 41 | return this.labyDebugger; 42 | } 43 | 44 | /** {@inheritDoc} */ 45 | @Override 46 | public String getVersion() { 47 | return this.pluginVersion; 48 | } 49 | 50 | /** {@inheritDoc} */ 51 | @SuppressWarnings("unchecked") 52 | @Override 53 | public

LabyModPlayerService

getLabyPlayerService() { 54 | return (LabyModPlayerService

) this.playerService; 55 | } 56 | 57 | /** {@inheritDoc} */ 58 | @Override 59 | public PayloadCommunicator getPayloadCommunicator() { 60 | return this.payloadCommunicator; 61 | } 62 | 63 | /** {@inheritDoc} */ 64 | @SuppressWarnings("unchecked") 65 | @Override 66 | public

PayloadChannelRegistrar

getPayloadChannelRegistrar() { 67 | return (PayloadChannelRegistrar

) this.payloadChannelRegistrar; 68 | } 69 | 70 | /** {@inheritDoc} */ 71 | @SuppressWarnings("unchecked") 72 | @Override 73 | public

ConnectionService

getConnectionService() { 74 | return (ConnectionService

) this.connectionService; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/gui/DefaultInputPromptTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction.gui; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.player.LabyModPlayerService; 8 | import net.labymod.serverapi.api.serverinteraction.gui.InputPromptTransmitter; 9 | 10 | import java.util.UUID; 11 | 12 | public class DefaultInputPromptTransmitter implements InputPromptTransmitter { 13 | private static final String INPUT_PROMPT_CHANNEL = "input_prompt"; 14 | private final PayloadCommunicator communicator; 15 | private final LabyModPlayerService playerService; 16 | 17 | public DefaultInputPromptTransmitter(LabyService service) { 18 | this.communicator = service.getPayloadCommunicator(); 19 | this.playerService = service.getLabyPlayerService(); 20 | } 21 | 22 | @Override 23 | public void transmit( 24 | UUID uniqueId, 25 | int promptSessionId, 26 | JsonObject rawText, 27 | String value, 28 | String placeholder, 29 | int maximumAmount) { 30 | 31 | JsonObject object = new JsonObject(); 32 | object.addProperty("id", promptSessionId); 33 | object.addProperty("raw_json_text", rawText.toString()); 34 | object.addProperty("value", value); 35 | object.addProperty("placeholder", placeholder); 36 | object.addProperty("max_length", maximumAmount); 37 | 38 | this.communicator.sendLabyModMessage(uniqueId, INPUT_PROMPT_CHANNEL, object); 39 | } 40 | 41 | @Override 42 | public void transmit( 43 | UUID uniqueId, 44 | int promptSessionId, 45 | String message, 46 | String value, 47 | String placeholder, 48 | int maximumAmount) { 49 | 50 | JsonObject object = new JsonObject(); 51 | object.addProperty("id", promptSessionId); 52 | object.addProperty("message", message); 53 | object.addProperty("value", value); 54 | object.addProperty("placeholder", placeholder); 55 | object.addProperty("max_length", maximumAmount); 56 | 57 | this.communicator.sendLabyModMessage(uniqueId, INPUT_PROMPT_CHANNEL, object); 58 | } 59 | 60 | @Override 61 | public void broadcastTransmit( 62 | int promptSessionId, 63 | JsonObject rawText, 64 | String value, 65 | String placeholder, 66 | int maximumAmount) { 67 | for (LabyModPlayer player : this.playerService.getPlayers()) { 68 | this.transmit( 69 | player.getUniqueId(), promptSessionId, rawText, value, placeholder, maximumAmount); 70 | } 71 | } 72 | 73 | @Override 74 | public void broadcastTransmit( 75 | int promptSessionId, String message, String value, String placeholder, int maximumAmount) { 76 | for (LabyModPlayer player : this.playerService.getPlayers()) { 77 | this.transmit( 78 | player.getUniqueId(), promptSessionId, message, value, placeholder, maximumAmount); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/player/DefaultLabyModPlayer.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.player; 2 | 3 | import net.labymod.serverapi.api.extension.AddonExtension; 4 | import net.labymod.serverapi.api.extension.ModificationExtension; 5 | import net.labymod.serverapi.api.extension.PackageExtension; 6 | import net.labymod.serverapi.api.player.LabyModPlayer; 7 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 8 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 9 | 10 | import java.util.List; 11 | import java.util.UUID; 12 | 13 | public class DefaultLabyModPlayer implements LabyModPlayer { 14 | 15 | private final T player; 16 | private final String username; 17 | private final UUID uniqueId; 18 | private final String version; 19 | private final ChunkCachingProtocol chunkCachingProtocol; 20 | private final ShadowProtocol shadowProtocol; 21 | private final List addons; 22 | private final List modifications; 23 | private final List packages; 24 | 25 | public DefaultLabyModPlayer( 26 | T player, 27 | String username, 28 | UUID uniqueId, 29 | String version, 30 | ChunkCachingProtocol chunkCachingProtocol, 31 | ShadowProtocol shadowProtocol, 32 | List addons, 33 | List modifications, 34 | List packages) { 35 | this.player = player; 36 | this.username = username; 37 | this.uniqueId = uniqueId; 38 | this.version = version; 39 | this.chunkCachingProtocol = chunkCachingProtocol; 40 | this.shadowProtocol = shadowProtocol; 41 | this.addons = addons; 42 | this.modifications = modifications; 43 | this.packages = packages; 44 | } 45 | 46 | /** {@inheritDoc} */ 47 | @Override 48 | public T getPlayer() { 49 | return this.player; 50 | } 51 | 52 | /** {@inheritDoc} */ 53 | @Override 54 | public String getUsername() { 55 | return this.username; 56 | } 57 | 58 | /** {@inheritDoc} */ 59 | @Override 60 | public UUID getUniqueId() { 61 | return this.uniqueId; 62 | } 63 | 64 | /** {@inheritDoc} */ 65 | @Override 66 | public String getVersion() { 67 | return this.version; 68 | } 69 | 70 | /** {@inheritDoc} */ 71 | @Override 72 | public ChunkCachingProtocol getChunkCachingProtocol() { 73 | return this.chunkCachingProtocol; 74 | } 75 | 76 | /** {@inheritDoc} */ 77 | @Override 78 | public ShadowProtocol getShadowProtocol() { 79 | return this.shadowProtocol; 80 | } 81 | 82 | /** {@inheritDoc} */ 83 | @Override 84 | public List getAddons() { 85 | return this.addons; 86 | } 87 | 88 | /** {@inheritDoc} */ 89 | @Override 90 | public List getModifications() { 91 | return this.modifications; 92 | } 93 | 94 | /** {@inheritDoc} */ 95 | @Override 96 | public List getPackages() { 97 | return this.packages; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Java template 3 | # Compiled class file 4 | *.class 5 | 6 | # Log file 7 | *.log 8 | 9 | # BlueJ files 10 | *.ctxt 11 | 12 | # Mobile Tools for Java (J2ME) 13 | .mtj.tmp/ 14 | 15 | # Package Files # 16 | *.jar 17 | *.war 18 | *.nar 19 | *.ear 20 | *.zip 21 | *.tar.gz 22 | *.rar 23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 24 | hs_err_pid* 25 | 26 | ### JetBrains template 27 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 28 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 29 | 30 | # User-specific stuff 31 | .idea/**/workspace.xml 32 | .idea/**/tasks.xml 33 | .idea/**/usage.statistics.xml 34 | .idea/**/dictionaries 35 | .idea/**/shelf 36 | .idea/**/misc.xml 37 | .idea/codeStyles/ 38 | 39 | # Generated files 40 | .idea/**/contentModel.xml 41 | .idea/**/jarRepositories.xml 42 | .idea/**/uiDesigner.xml 43 | .idea/**/inspectionProfiles 44 | .idea/**/.name 45 | .idea/**/vcs.xml 46 | .idea/**/compiler.xml 47 | run/** 48 | 49 | # Sensitive or high-churn files 50 | .idea/**/dataSources/ 51 | .idea/**/dataSources.ids 52 | .idea/**/dataSources.local.xml 53 | .idea/**/sqlDataSources.xml 54 | .idea/**/dynamic.xml 55 | .idea/**/uiDesigner.xml 56 | .idea/**/dbnavigator.xml 57 | .idea/kotlinScripting.xml 58 | 59 | # Gradle 60 | .idea/**/gradle.xml 61 | .idea/**/libraries 62 | 63 | # Gradle and Maven with auto-import 64 | # When using Gradle or Maven with auto-import, you should exclude module files, 65 | # since they will be recreated, and may cause churn. Uncomment if using 66 | # auto-import. 67 | # .idea/artifacts 68 | # .idea/compiler.xml 69 | .idea/modules.xml 70 | .idea/*.iml 71 | # .idea/modules 72 | # *.iml 73 | # *.ipr 74 | 75 | # CMake 76 | cmake-build-*/ 77 | 78 | # Mongo Explorer plugin 79 | .idea/**/mongoSettings.xml 80 | 81 | # File-based project format 82 | *.iws 83 | 84 | # IntelliJ 85 | out/ 86 | 87 | # mpeltonen/sbt-idea plugin 88 | .idea_modules/ 89 | 90 | # JIRA plugin 91 | atlassian-ide-plugin.xml 92 | 93 | # Cursive Clojure plugin 94 | .idea/replstate.xml 95 | 96 | # Crashlytics plugin (for Android Studio and IntelliJ) 97 | com_crashlytics_export_strings.xml 98 | crashlytics.properties 99 | crashlytics-build.properties 100 | fabric.properties 101 | 102 | # Editor-based Rest Client 103 | .idea/httpRequests 104 | 105 | # Android studio 3.1+ serialized cache file 106 | .idea/caches/build_file_checksums.ser 107 | 108 | ### Gradle template 109 | .gradle 110 | /**/build/ 111 | 112 | # Ignore Gradle GUI config 113 | gradle-app.setting 114 | 115 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 116 | !gradle-wrapper.jar 117 | 118 | # Cache of project 119 | .gradletasknamecache 120 | 121 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 122 | # gradle/wrapper/gradle-wrapper.properties 123 | 124 | .idea/modules/ 125 | src/main/resources/ 126 | src/test/ 127 | **/src/main/generated/* -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/connection/ConnectionService.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.connection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.UUID; 6 | import net.labymod.serverapi.api.extension.AddonExtension; 7 | import net.labymod.serverapi.api.extension.ModificationExtension; 8 | import net.labymod.serverapi.api.extension.PackageExtension; 9 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 10 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 11 | 12 | /** 13 | * Represents the connection service for the LabyMod. 14 | * 15 | * @param The player type of the specified platform. 16 | */ 17 | public interface ConnectionService { 18 | 19 | /** 20 | * Called when a player connected to the server is playing with LabyMod. 21 | * 22 | * @param player The player who is connected to the LabyMod on the server. 23 | * @param username The username of the player. 24 | * @param uniqueId The unique identifier of the player. 25 | * @param version The version of LabyMod. 26 | * @param chunkCachingProtocol Information about the chuck caching protocol. 27 | * @param shadowProtocol Information about the shadow protocol. 28 | * @param addons A collection of all installed addons. 29 | * @param modifications A collection of all installed modifications. 30 | */ 31 | default void login( 32 | T player, 33 | String username, 34 | UUID uniqueId, 35 | String version, 36 | ChunkCachingProtocol chunkCachingProtocol, 37 | ShadowProtocol shadowProtocol, 38 | List addons, 39 | List modifications) { 40 | this.login( 41 | player, 42 | username, 43 | uniqueId, 44 | version, 45 | chunkCachingProtocol, 46 | shadowProtocol, 47 | addons, 48 | modifications, 49 | new ArrayList<>()); 50 | } 51 | 52 | /** 53 | * Called when a player connected to the server is playing with LabyMod. 54 | * 55 | * @param player The player who is connected to the LabyMod on the server. 56 | * @param username The username of the player. 57 | * @param uniqueId The unique identifier of the player. 58 | * @param version The version of LabyMod. 59 | * @param chunkCachingProtocol Information about the chuck caching protocol. 60 | * @param shadowProtocol Information about the shadow protocol. 61 | * @param addons A collection of all installed addons. 62 | * @param modifications A collection of all installed modifications. 63 | * @param packages A collection of all installed packages. 64 | */ 65 | void login( 66 | T player, 67 | String username, 68 | UUID uniqueId, 69 | String version, 70 | ChunkCachingProtocol chunkCachingProtocol, 71 | ShadowProtocol shadowProtocol, 72 | List addons, 73 | List modifications, 74 | List packages); 75 | 76 | /** 77 | * Called when a player is disconnected from the server. 78 | * 79 | * @param uniqueId The unique identifier of the disconnected player. 80 | */ 81 | void disconnect(UUID uniqueId); 82 | } 83 | -------------------------------------------------------------------------------- /labymod-api/src/main/java/net/labymod/serverapi/api/serverinteraction/gui/InputPromptTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.api.serverinteraction.gui; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | 6 | /** 7 | * Represents the input prompt packet. 8 | * 9 | *

Overview: 10 | * 11 | *

With this feature it is possible to request a text input from a player. The server can send 12 | * any text with any pre-entered input to the client. 13 | */ 14 | public interface InputPromptTransmitter { 15 | 16 | /** 17 | * Transmits the input prompt to the client with the specified {@code uniqueId}. 18 | * 19 | * @param uniqueId The unique identifier of the receiver. 20 | * @param promptSessionId The prompt session identifier. 21 | * @param rawText The message above the text field as a {@link JsonObject}. 22 | * @param value The value inside of the text field. 23 | * @param placeholder A placeholder text inside of the field if there is no value given. 24 | * @param maximumAmount The maximum amount of character of the text field value. 25 | */ 26 | void transmit( 27 | UUID uniqueId, 28 | int promptSessionId, 29 | JsonObject rawText, 30 | String value, 31 | String placeholder, 32 | int maximumAmount); 33 | 34 | /** 35 | * Transmits the input prompt to the client with the specified {@code uniqueId}. 36 | * 37 | * @param uniqueId The unique identifier of the receiver. 38 | * @param promptSessionId The prompt session identifier. 39 | * @param message The message above the text field. 40 | * @param value The value inside of the text field. 41 | * @param placeholder The placeholder text inside of the field if there is not value given. 42 | * @param maximumAmount The maximum amount of character of the text field value. 43 | */ 44 | void transmit( 45 | UUID uniqueId, 46 | int promptSessionId, 47 | String message, 48 | String value, 49 | String placeholder, 50 | int maximumAmount); 51 | 52 | /** 53 | * Transmits the input prompt to all online laby users. 54 | * 55 | * @param promptSessionId The prompt session identifier. 56 | * @param rawText The message above the text field as a {@link JsonObject}. 57 | * @param value The value inside of the text field. 58 | * @param placeholder The placeholder text inside of the field if there is not value given. 59 | * @param maximumAmount The maximum amount of character of the text field value. 60 | */ 61 | void broadcastTransmit( 62 | int promptSessionId, JsonObject rawText, String value, String placeholder, int maximumAmount); 63 | 64 | /** 65 | * Transmits the input prompt to all online laby users. 66 | * 67 | * @param promptSessionId The prompt session identifier. 68 | * @param message The message above the text field. 69 | * @param value The value inside of the text field. 70 | * @param placeholder The placeholder text inside of the field if there is not value given. 71 | * @param maximumAmount The maximum amount of character of the text field value. 72 | */ 73 | void broadcastTransmit( 74 | int promptSessionId, String message, String value, String placeholder, int maximumAmount); 75 | } 76 | -------------------------------------------------------------------------------- /proxy/velocity/src/main/java/net/labymod/serverapi/velocity/VelocityLabyService.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.velocity; 2 | 3 | import com.velocitypowered.api.proxy.Player; 4 | import com.velocitypowered.api.proxy.ProxyServer; 5 | import com.velocitypowered.api.proxy.messages.ChannelIdentifier; 6 | import net.labymod.serverapi.api.LabyDebugger; 7 | import net.labymod.serverapi.api.connection.ConnectionService; 8 | import net.labymod.serverapi.api.payload.PayloadChannelRegistrar; 9 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 10 | import net.labymod.serverapi.api.player.LabyModPlayerService; 11 | import net.labymod.serverapi.common.AbstractLabyService; 12 | import net.labymod.serverapi.common.player.DefaultLabyModPlayerService; 13 | import net.labymod.serverapi.velocity.connection.VelocityConnectionService; 14 | import net.labymod.serverapi.velocity.payload.VelocityPayloadChannelRegistrar; 15 | import net.labymod.serverapi.velocity.payload.VelocityPayloadCommunicator; 16 | import org.slf4j.Logger; 17 | 18 | public class VelocityLabyService extends AbstractLabyService { 19 | 20 | private final LabyDebugger labyDebugger; 21 | private final ConnectionService connectionService; 22 | private final LabyModPlayerService playerService; 23 | private final PayloadCommunicator payloadCommunicator; 24 | private final PayloadChannelRegistrar payloadChannelRegistrar; 25 | 26 | private final String pluginVersion; 27 | 28 | public VelocityLabyService(ProxyServer proxyServer, Logger logger, String pluginVersion) { 29 | this.labyDebugger = new VelocityLabyDebugger(logger); 30 | 31 | this.pluginVersion = pluginVersion; 32 | this.playerService = new DefaultLabyModPlayerService<>(); 33 | this.payloadCommunicator = new VelocityPayloadCommunicator(proxyServer, this); 34 | this.payloadChannelRegistrar = new VelocityPayloadChannelRegistrar(proxyServer); 35 | 36 | ((VelocityPayloadCommunicator) this.payloadCommunicator) 37 | .setPayloadChannelRegistrar(this.payloadChannelRegistrar); 38 | this.initialize(); 39 | this.connectionService = new VelocityConnectionService(this); 40 | } 41 | 42 | /** {@inheritDoc} */ 43 | @Override 44 | public LabyDebugger getLabyDebugger() { 45 | return this.labyDebugger; 46 | } 47 | 48 | /** {@inheritDoc} */ 49 | @Override 50 | public String getVersion() { 51 | return this.pluginVersion; 52 | } 53 | 54 | /** {@inheritDoc} */ 55 | @SuppressWarnings("unchecked") 56 | @Override 57 | public

LabyModPlayerService

getLabyPlayerService() { 58 | return (LabyModPlayerService

) this.playerService; 59 | } 60 | 61 | /** {@inheritDoc} */ 62 | @Override 63 | public PayloadCommunicator getPayloadCommunicator() { 64 | return this.payloadCommunicator; 65 | } 66 | 67 | /** {@inheritDoc} */ 68 | @SuppressWarnings("unchecked") 69 | @Override 70 | public

PayloadChannelRegistrar

getPayloadChannelRegistrar() { 71 | return (PayloadChannelRegistrar

) this.payloadChannelRegistrar; 72 | } 73 | 74 | /** {@inheritDoc} */ 75 | @SuppressWarnings("unchecked") 76 | @Override 77 | public

ConnectionService

getConnectionService() { 78 | return (ConnectionService

) this.connectionService; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/payload/BukkitPayloadCommunicator.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.payload; 2 | 3 | import java.util.UUID; 4 | import net.labymod.serverapi.api.LabyService; 5 | import net.labymod.serverapi.api.payload.PayloadChannelRegistrar; 6 | import net.labymod.serverapi.api.payload.PayloadChannelType; 7 | import net.labymod.serverapi.bukkit.BukkitLabyModPlugin; 8 | import net.labymod.serverapi.bukkit.event.BukkitReceivePayloadEvent; 9 | import net.labymod.serverapi.bukkit.event.BukkitSendPayloadEvent; 10 | import net.labymod.serverapi.bukkit.payload.transmitter.BukkitPayloadTransmitter; 11 | import net.labymod.serverapi.common.payload.DefaultPayloadCommunicator; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.plugin.messaging.PluginMessageListener; 14 | 15 | public class BukkitPayloadCommunicator extends DefaultPayloadCommunicator 16 | implements PluginMessageListener { 17 | 18 | private final BukkitLabyModPlugin plugin; 19 | private PayloadChannelRegistrar payloadChannelRegistrar; 20 | 21 | public BukkitPayloadCommunicator(BukkitLabyModPlugin plugin, LabyService service) { 22 | super(service); 23 | this.plugin = plugin; 24 | } 25 | 26 | public void setPayloadChannelRegistrar( 27 | final PayloadChannelRegistrar payloadChannelRegistrar) { 28 | this.payloadChannelRegistrar = payloadChannelRegistrar; 29 | } 30 | 31 | @Override 32 | public void send(UUID uniqueId, String identifier, byte[] payload) { 33 | Player player = this.plugin.getServer().getPlayer(uniqueId); 34 | 35 | if (player == null) { 36 | return; 37 | } 38 | 39 | PayloadChannelType channelType = 40 | identifier.contains(":") ? PayloadChannelType.MODERN : PayloadChannelType.LEGACY; 41 | 42 | this.payloadChannelRegistrar.getChannelIdentifiers().get(channelType).stream() 43 | .filter(channelIdentifier -> channelIdentifier.equals(identifier)) 44 | .forEach( 45 | channelIdentifier -> { 46 | BukkitSendPayloadEvent bukkitSendPayloadEvent = 47 | new BukkitSendPayloadEvent(player, channelIdentifier, payload); 48 | this.plugin.getServer().getPluginManager().callEvent(bukkitSendPayloadEvent); 49 | 50 | if (bukkitSendPayloadEvent.isCancelled()) { 51 | return; 52 | } 53 | BukkitPayloadTransmitter.transmitPayload( 54 | player, 55 | bukkitSendPayloadEvent.getChannelIdentifier(), 56 | bukkitSendPayloadEvent.getPayload()); 57 | this.debugger.info( 58 | String.format( 59 | "A payload message was sent to player \"%s\" in channel \"%s\"!", 60 | player.getName(), channelIdentifier)); 61 | }); 62 | } 63 | 64 | @Override 65 | public void receive(UUID uniqueId, String identifier, byte[] payload) { 66 | this.plugin 67 | .getServer() 68 | .getPluginManager() 69 | .callEvent(new BukkitReceivePayloadEvent(uniqueId, identifier, payload)); 70 | } 71 | 72 | @Override 73 | public void onPluginMessageReceived(String channel, Player player, byte[] message) { 74 | this.receive(player.getUniqueId(), channel, message); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /server/bukkit/src/main/java/net/labymod/serverapi/bukkit/payload/channel/BukkitLegacyLabyModPayloadChannel.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.bukkit.payload.channel; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonParser; 5 | import io.netty.buffer.Unpooled; 6 | import java.util.List; 7 | import net.labymod.serverapi.api.LabyService; 8 | import net.labymod.serverapi.api.extension.AddonExtension; 9 | import net.labymod.serverapi.api.extension.ModificationExtension; 10 | import net.labymod.serverapi.api.payload.PayloadBuffer; 11 | import net.labymod.serverapi.api.protocol.ChunkCachingProtocol; 12 | import net.labymod.serverapi.api.protocol.ShadowProtocol; 13 | import net.labymod.serverapi.bukkit.BukkitLabyModPlugin; 14 | import net.labymod.serverapi.bukkit.event.BukkitLabyModPlayerLoginEvent; 15 | import net.labymod.serverapi.bukkit.event.BukkitMessageReceiveEvent; 16 | import net.labymod.serverapi.bukkit.event.BukkitReceivePayloadEvent; 17 | import net.labymod.serverapi.common.payload.DefaultLegacyLabyModPayloadChannel; 18 | import net.labymod.serverapi.common.payload.DefaultPayloadBufferFactory; 19 | import org.bukkit.entity.Player; 20 | import org.bukkit.event.EventHandler; 21 | import org.bukkit.event.Listener; 22 | 23 | public class BukkitLegacyLabyModPayloadChannel extends DefaultLegacyLabyModPayloadChannel 24 | implements Listener { 25 | 26 | private static final JsonParser JSON_PARSER = new JsonParser(); 27 | 28 | private final BukkitLabyModPlugin plugin; 29 | private final PayloadBuffer.Factory payloadBufferFactory; 30 | 31 | public BukkitLegacyLabyModPayloadChannel(BukkitLabyModPlugin plugin, LabyService service) { 32 | super(service); 33 | this.plugin = plugin; 34 | this.payloadBufferFactory = new DefaultPayloadBufferFactory(); 35 | } 36 | 37 | @EventHandler 38 | public void receiveLabyMod3Payload(BukkitReceivePayloadEvent event) { 39 | Player player = this.plugin.getServer().getPlayer(event.getUniqueId()); 40 | 41 | if (player == null) { 42 | return; 43 | } 44 | 45 | this.readPayload( 46 | player, this.payloadBufferFactory.create(Unpooled.wrappedBuffer(event.getPayload()))); 47 | } 48 | 49 | @Override 50 | public JsonElement parseMessageContent(String messageContent) { 51 | return JSON_PARSER.parse(messageContent); 52 | } 53 | 54 | @Override 55 | public void onReceiveMessage(T player, String key, JsonElement content) { 56 | this.plugin 57 | .getServer() 58 | .getPluginManager() 59 | .callEvent(new BukkitMessageReceiveEvent((Player) player, key, content)); 60 | } 61 | 62 | @Override 63 | public void onLabyModPlayerJoin( 64 | T player, 65 | List addons, 66 | List modifications, 67 | String version, 68 | ChunkCachingProtocol chunkCachingProtocol, 69 | ShadowProtocol shadowProtocol) { 70 | Player bukkitPlayer = (Player) player; 71 | this.plugin 72 | .getServer() 73 | .getPluginManager() 74 | .callEvent( 75 | new BukkitLabyModPlayerLoginEvent( 76 | bukkitPlayer, 77 | addons, 78 | modifications, 79 | version, 80 | chunkCachingProtocol, 81 | shadowProtocol)); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | --------------------------------------------------------------------------------

A list of all available stickers. 25 | */ 26 | public interface StickerTransmitter { 27 | 28 | /** 29 | * Adds a sticker to a list to be played when sending. 30 | * 31 | * @param sticker The sticker which should be played. 32 | * @return This object for a fluent chaining. 33 | */ 34 | StickerTransmitter addSticker(Sticker sticker); 35 | 36 | /** 37 | * ADds to a list an array of stickers to be played when sending. 38 | * 39 | * @param stickers An array stickers which should be played. 40 | * @return This object for a fluent chaining. 41 | */ 42 | StickerTransmitter addStickers(Sticker... stickers); 43 | 44 | /** 45 | * Transmits a list of all forced stickers to the client. 46 | * 47 | * @param receiverUniqueId The unique identifier of the receiver. 48 | */ 49 | void transmit(UUID receiverUniqueId); 50 | 51 | /** Transmits a list of all forced stickers to all laby users. */ 52 | void broadcastTransmit(); 53 | } 54 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/serverinteraction/DefaultServerSwitcherTransmitter.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.serverinteraction; 2 | 3 | import com.google.gson.JsonObject; 4 | import java.util.UUID; 5 | import net.labymod.serverapi.api.LabyService; 6 | import net.labymod.serverapi.api.payload.PayloadCommunicator; 7 | import net.labymod.serverapi.api.player.LabyModPlayer; 8 | import net.labymod.serverapi.api.player.LabyModPlayerService; 9 | import net.labymod.serverapi.api.serverinteraction.ServerSwitcherTransmitter; 10 | 11 | public class DefaultServerSwitcherTransmitter implements ServerSwitcherTransmitter { 12 | 13 | private static final String SERVER_SWITCH_CHANNEL = "server_switch"; 14 | private final PayloadCommunicator payloadCommunicator; 15 | private final LabyModPlayerService playerService; 16 | 17 | public DefaultServerSwitcherTransmitter(LabyService service) { 18 | this.payloadCommunicator = service.getPayloadCommunicator(); 19 | this.playerService = service.getLabyPlayerService(); 20 | } 21 | 22 | /** {@inheritDoc} */ 23 | @Override 24 | public void transmit(UUID uniqueId, String title, String address, boolean preview) { 25 | JsonObject serverSwitchObject = new JsonObject(); 26 | 27 | serverSwitchObject.addProperty("title", title); 28 | serverSwitchObject.addProperty("address", address); 29 | serverSwitchObject.addProperty("preview", preview); 30 | 31 | this.payloadCommunicator.sendLabyModMessage( 32 | uniqueId, SERVER_SWITCH_CHANNEL, serverSwitchObject); 33 | } 34 | 35 | /** {@inheritDoc} */ 36 | @Override 37 | public void broadcastTransmit(String title, String address, boolean preview) { 38 | for (LabyModPlayer player : this.playerService.getPlayers()) { 39 | this.transmit(player.getUniqueId(), title, address, preview); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /labymod-common/src/main/java/net/labymod/serverapi/common/permission/DefaultPermission.java: -------------------------------------------------------------------------------- 1 | package net.labymod.serverapi.common.permission; 2 | 3 | import net.labymod.serverapi.api.permission.Permissible; 4 | 5 | /** A default implementation of the {@link Permissible}. */ 6 | public class DefaultPermission implements Permissible { 7 | 8 | private final String internalName; 9 | private final String name; 10 | private boolean enabled; 11 | 12 | /** 13 | * Initializes a new default permission with the given parameters. 14 | * 15 | *