Keep wrapping Via, ViaAPI, and Bossbar API in api-legacy module

This commit is contained in:
KennyTV 2021-04-26 20:21:47 +02:00
parent a25a5634de
commit dbf6a110f2
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
10 changed files with 434 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,3 @@
dependencies {
compileOnly(projects.viaversionApi)
}

View File

@ -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<T> implements ViaAPI<T> {
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<Integer> getSupportedVersions() {
return com.viaversion.viaversion.api.Via.getAPI().getSupportedVersions();
}
@Override
public SortedSet<Integer> getFullSupportedVersions() {
return com.viaversion.viaversion.api.Via.getAPI().getFullSupportedVersions();
}
}

View File

@ -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<T> {
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<Integer> getSupportedVersions();
SortedSet<Integer> getFullSupportedVersions();
}

View File

@ -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<T> {
private final com.viaversion.viaversion.api.boss.BossBar<T> bossBar;
public BossBar(com.viaversion.viaversion.api.boss.BossBar<T> 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<UUID> 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();
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -9,4 +9,5 @@ blossom {
dependencies {
api(projects.viaversionApi)
api(projects.viaversionApiLegacy)
}

View File

@ -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")