diff --git a/README.md b/README.md index 7afea9d80..1b2be3a44 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ the `build/libs` directory. License: -------- -The entirety of the [API directory](api) is licensed under the MIT License; see [licenses/MIT.md](licenses/MIT.md) for +The entirety of the [API directory](api) (including the legacy API directory) is licensed under the MIT License; see [licenses/MIT.md](licenses/MIT.md) for details. Everything else, unless explicitly stated otherwise, is licensed under the GNU General Public License, including the end diff --git a/api-legacy/build.gradle.kts b/api-legacy/build.gradle.kts new file mode 100644 index 000000000..a42a4f44d --- /dev/null +++ b/api-legacy/build.gradle.kts @@ -0,0 +1,3 @@ +dependencies { + compileOnly(projects.viaversionApi) +} \ No newline at end of file diff --git a/api-legacy/src/main/java/us/myles/ViaVersion/api/Via.java b/api-legacy/src/main/java/us/myles/ViaVersion/api/Via.java new file mode 100644 index 000000000..c29f189e6 --- /dev/null +++ b/api-legacy/src/main/java/us/myles/ViaVersion/api/Via.java @@ -0,0 +1,102 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2021 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package us.myles.ViaVersion.api; + +import io.netty.buffer.ByteBuf; +import us.myles.ViaVersion.api.boss.BossBar; +import us.myles.ViaVersion.api.boss.BossColor; +import us.myles.ViaVersion.api.boss.BossStyle; + +import java.util.SortedSet; +import java.util.UUID; + +/** + * @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.Via} + */ +@Deprecated +public class Via implements ViaAPI { + + private static final ViaAPI INSTANCE = new Via(); + + private Via() { + } + + @Deprecated + public static ViaAPI getAPI() { + return INSTANCE; + } + + @Override + public int getPlayerVersion(T player) { + return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(player); + } + + @Override + public int getPlayerVersion(UUID uuid) { + return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(uuid); + } + + @Override + public boolean isInjected(UUID playerUUID) { + return com.viaversion.viaversion.api.Via.getAPI().isInjected(playerUUID); + } + + @Override + public String getVersion() { + return com.viaversion.viaversion.api.Via.getAPI().getVersion(); + } + + @Override + public void sendRawPacket(T player, ByteBuf packet) { + com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(player, packet); + } + + @Override + public void sendRawPacket(UUID uuid, ByteBuf packet) { + com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(uuid, packet); + } + + @Override + public BossBar createBossBar(String title, BossColor color, BossStyle style) { + return new BossBar(com.viaversion.viaversion.api.Via.getAPI().createBossBar(title, + com.viaversion.viaversion.api.boss.BossColor.values()[color.ordinal()], + com.viaversion.viaversion.api.boss.BossStyle.values()[style.ordinal()])); + } + + @Override + public BossBar createBossBar(String title, float health, BossColor color, BossStyle style) { + return new BossBar(com.viaversion.viaversion.api.Via.getAPI().createBossBar(title, health, + com.viaversion.viaversion.api.boss.BossColor.values()[color.ordinal()], + com.viaversion.viaversion.api.boss.BossStyle.values()[style.ordinal()])); + } + + @Override + public SortedSet getSupportedVersions() { + return com.viaversion.viaversion.api.Via.getAPI().getSupportedVersions(); + } + + @Override + public SortedSet getFullSupportedVersions() { + return com.viaversion.viaversion.api.Via.getAPI().getFullSupportedVersions(); + } +} diff --git a/api-legacy/src/main/java/us/myles/ViaVersion/api/ViaAPI.java b/api-legacy/src/main/java/us/myles/ViaVersion/api/ViaAPI.java new file mode 100644 index 000000000..a255bf86b --- /dev/null +++ b/api-legacy/src/main/java/us/myles/ViaVersion/api/ViaAPI.java @@ -0,0 +1,63 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2021 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package us.myles.ViaVersion.api; + +import com.viaversion.viaversion.api.Via; +import io.netty.buffer.ByteBuf; +import us.myles.ViaVersion.api.boss.BossBar; +import us.myles.ViaVersion.api.boss.BossColor; +import us.myles.ViaVersion.api.boss.BossStyle; + +import java.util.SortedSet; +import java.util.UUID; + +/** + * @deprecated may be removed at some point, use {@link Via#getAPI()} + */ +@Deprecated +public interface ViaAPI { + + int getPlayerVersion(T player); + + int getPlayerVersion(UUID uuid); + + default boolean isPorted(UUID playerUUID) { + return isInjected(playerUUID); + } + + boolean isInjected(UUID playerUUID); + + String getVersion(); + + void sendRawPacket(T player, ByteBuf packet); + + void sendRawPacket(UUID uuid, ByteBuf packet); + + BossBar createBossBar(String title, BossColor color, BossStyle style); + + BossBar createBossBar(String title, float health, BossColor color, BossStyle style); + + SortedSet getSupportedVersions(); + + SortedSet getFullSupportedVersions(); +} diff --git a/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossBar.java b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossBar.java new file mode 100644 index 000000000..8c7460f39 --- /dev/null +++ b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossBar.java @@ -0,0 +1,135 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2021 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package us.myles.ViaVersion.api.boss; + +import java.util.Set; +import java.util.UUID; + +@Deprecated +public class BossBar { + + private final com.viaversion.viaversion.api.boss.BossBar bossBar; + + public BossBar(com.viaversion.viaversion.api.boss.BossBar bossBar) { + this.bossBar = bossBar; + } + + public String getTitle() { + return bossBar.getTitle(); + } + + public BossBar setTitle(String title) { + bossBar.setTitle(title); + return this; + } + + public float getHealth() { + return bossBar.getHealth(); + } + + public BossBar setHealth(float health) { + bossBar.setHealth(health); + return this; + } + + public BossColor getColor() { + return BossColor.values()[bossBar.getColor().ordinal()]; + } + + public BossBar setColor(BossColor color) { + bossBar.setColor(com.viaversion.viaversion.api.boss.BossColor.values()[color.ordinal()]); + return this; + } + + public BossStyle getStyle() { + return BossStyle.values()[bossBar.getStyle().ordinal()]; + } + + public BossBar setStyle(BossStyle style) { + bossBar.setStyle(com.viaversion.viaversion.api.boss.BossStyle.values()[style.ordinal()]); + return this; + } + + public BossBar addPlayer(T player) { + bossBar.addPlayer(player); + return this; + } + + public BossBar addPlayer(UUID player) { + bossBar.addPlayer(player); + return this; + } + + @Deprecated + public BossBar addPlayers(T... players) { + bossBar.addPlayers(players); + return this; + } + + @Deprecated + public BossBar removePlayer(T player) { + bossBar.removePlayer(player); + return this; + } + + public BossBar removePlayer(UUID uuid) { + bossBar.removePlayer(uuid); + return this; + } + + public BossBar addFlag(BossFlag flag) { + bossBar.addFlag(com.viaversion.viaversion.api.boss.BossFlag.values()[flag.ordinal()]); + return this; + } + + public BossBar removeFlag(BossFlag flag) { + bossBar.removeFlag(com.viaversion.viaversion.api.boss.BossFlag.values()[flag.ordinal()]); + return this; + } + + public boolean hasFlag(BossFlag flag) { + return bossBar.hasFlag(com.viaversion.viaversion.api.boss.BossFlag.values()[flag.ordinal()]); + } + + public Set getPlayers() { + return bossBar.getPlayers(); + } + + public BossBar show() { + bossBar.show(); + return this; + } + + public BossBar hide() { + bossBar.hide(); + return this; + } + + public boolean isVisible() { + return bossBar.isVisible(); + } + + public UUID getId() { + return bossBar.getId(); + } +} diff --git a/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossColor.java b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossColor.java new file mode 100644 index 000000000..b325ede00 --- /dev/null +++ b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossColor.java @@ -0,0 +1,45 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2021 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package us.myles.ViaVersion.api.boss; + +@Deprecated +public enum BossColor { + + PINK(0), + BLUE(1), + RED(2), + GREEN(3), + YELLOW(4), + PURPLE(5), + WHITE(6); + + private final int id; + + BossColor(int id) { + this.id = id; + } + + public int getId() { + return id; + } +} diff --git a/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossFlag.java b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossFlag.java new file mode 100644 index 000000000..14cf29a19 --- /dev/null +++ b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossFlag.java @@ -0,0 +1,40 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2021 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package us.myles.ViaVersion.api.boss; + +@Deprecated +public enum BossFlag { + + DARKEN_SKY(1), + PLAY_BOSS_MUSIC(2); + + private final int id; + + BossFlag(int id) { + this.id = id; + } + + public int getId() { + return id; + } +} diff --git a/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossStyle.java b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossStyle.java new file mode 100644 index 000000000..2e9567635 --- /dev/null +++ b/api-legacy/src/main/java/us/myles/ViaVersion/api/boss/BossStyle.java @@ -0,0 +1,43 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2021 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package us.myles.ViaVersion.api.boss; + +@Deprecated +public enum BossStyle { + + SOLID(0), + SEGMENTED_6(1), + SEGMENTED_10(2), + SEGMENTED_12(3), + SEGMENTED_20(4); + + private final int id; + + BossStyle(int id) { + this.id = id; + } + + public int getId() { + return id; + } +} diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 8d6ef9165..99e589eac 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -9,4 +9,5 @@ blossom { dependencies { api(projects.viaversionApi) + api(projects.viaversionApiLegacy) } diff --git a/settings.gradle.kts b/settings.gradle.kts index f19cd4ee3..db3f54f08 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,6 +7,7 @@ include("adventure") include("java-compat", "java-compat:java-compat-common", "java-compat:java-compat-unsafe") setupViaSubproject("api") +setupViaSubproject("api-legacy") setupViaSubproject("common") setupViaSubproject("bukkit") setupViaSubproject("bukkit-legacy")