com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode Java Examples

The following examples show how to use com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkinApplier.java    From ChangeSkin with MIT License 6 votes vote down vote up
private PacketContainer createRespawnPacket(NativeGameMode gamemode) throws ReflectiveOperationException {
    PacketContainer respawn = new PacketContainer(RESPAWN);

    Difficulty difficulty = EnumWrappers.getDifficultyConverter().getSpecific(receiver.getWorld().getDifficulty());

    //<= 1.13.1
    int dimensionId = receiver.getWorld().getEnvironment().getId();
    respawn.getIntegers().writeSafely(0, dimensionId);

    //> 1.13.1
    if (MinecraftVersion.getCurrentVersion().compareTo(MinecraftVersion.AQUATIC_UPDATE) > 0) {
        try {
            respawn.getDimensions().writeSafely(0, dimensionId);
        } catch (NoSuchMethodError noSuchMethodError) {
            throw new ReflectiveOperationException("Unable to find dimension setter. " +
                    "Your ProtocolLib version is incompatible with this plugin version in combination with " +
                    "Minecraft 1.13.1. " +
                    "Try to download an update of ProtocolLib.", noSuchMethodError);
        }
    }

    respawn.getDifficulties().writeSafely(0, difficulty);
    respawn.getGameModes().write(0, gamemode);
    respawn.getWorldTypeModifier().write(0, receiver.getWorld().getWorldType());
    return respawn;
}
 
Example #2
Source File: SimpleTabList.java    From tabbed with MIT License 5 votes vote down vote up
private PlayerInfoData getPlayerInfoData(WrappedGameProfile profile, int ping, String displayName) {
    if (displayName != null) {
        // min width
        while (displayName.length() < this.minColumnWidth)
            displayName += " ";

        // max width
        if (this.maxColumnWidth > 0)
            while (displayName.length() > this.maxColumnWidth)
                displayName = displayName.substring(0, displayName.length() - 1);
    }

    return new PlayerInfoData(profile, ping, NativeGameMode.SURVIVAL, displayName == null ? null : WrappedChatComponent.fromText(displayName));
}
 
Example #3
Source File: WrapperPlayServerRespawn.java    From PacketWrapper with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Retrieve the game mode of the current player.
 * @return The current game mode
*/
public NativeGameMode getGameMode() {
    return handle.getGameModes().read(0);
}
 
Example #4
Source File: WrapperPlayServerRespawn.java    From PacketWrapper with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Set the game mode of the current player.
 * @param mode - new value.
*/
public void setGameMode(NativeGameMode mode) {
    handle.getGameModes().write(0, mode);
}
 
Example #5
Source File: WrapperPlayServerLogin.java    From PacketWrapper with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Retrieve the game mode of the initial world.
 * @return The current gamemode.
*/
public NativeGameMode getGamemode() {
    return handle.getGameModes().read(0);
}
 
Example #6
Source File: WrapperPlayServerLogin.java    From PacketWrapper with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Set the game mode of the initial world.
 * @param value - new value.
*/
public void setGamemode(NativeGameMode value) {
    handle.getGameModes().write(0, value);
}