Skip to content

Commit

Permalink
Further API
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed Feb 3, 2024
1 parent 3e97e1d commit 59e8c03
Show file tree
Hide file tree
Showing 68 changed files with 801 additions and 330 deletions.
55 changes: 55 additions & 0 deletions api/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>OpenAudioMc-Parent</artifactId>
<groupId>com.craftmend.openaudiomc</groupId>
<version>1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>openaudiomc-api</artifactId>
<name>openaudiomc-api</name>
<version>${oa.version}</version>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<finalName>openaudiomc-api</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
11 changes: 2 additions & 9 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,11 @@
<version>24.1.0</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven</artifactId>
<version>1.18.20.0</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>compile</scope>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ public interface Client {
*/
Actor getActor();

/**
* Add a on connect handler, which fires when the client gets opened for the player
*
* @param runnable Handler
*/
void onConnect(Runnable runnable);

/**
* Add a on connect handler, which fires when the client gets closed for by player
*
* @param runnable Handler
*/
void onDisconnect(Runnable runnable);

/**
* If this client currently has the web session open
* @return if the client is connected
Expand Down
168 changes: 65 additions & 103 deletions api/src/main/java/com/craftmend/openaudiomc/api/media/Media.java
Original file line number Diff line number Diff line change
@@ -1,159 +1,121 @@
package com.craftmend.openaudiomc.api.media;

public interface Media {
import com.craftmend.openaudiomc.api.MediaApi;
import lombok.Getter;
import lombok.Setter;

/**
* The unique id of the media, used by the client to keep track of media pools.
* This is a random UUID by default, but can be set to a custom value and will be used to identify the media
* for regions, stop commands and other features.
*
* @return the unique id of the media
*/
String getMediaId();
import java.util.UUID;

@Getter
public class Media {

/**
* Source value for the media. Typically, a web compatible web link or translatable OA value
*
* @return the source of the media
*/
String getSource();
private final String source;

/**
* The volume of the media, 0-100
*
* @return the volume of the media
* The unique id of the media, used by the client to keep track of media pools.
* This is a random UUID by default, but can be set to a custom value and will be used to identify the media
* for regions, stop commands and other features.
*/
int getVolume();
@Setter
private String mediaId = UUID.randomUUID().toString();

/**
* An epoch millisecond timestamp of when the media started playing, used by the client to calculate the current position
* if keepup is configured (time spent + startAtMillis)
*
* @return the start instant of the media
*/
long getStartInstant();

@Setter
private long startInstant;

/**
* The starting point of the media, in milliseconds. 0 by default, but can be used to skip intros or start at a certain point.
*
* @return the starting point of the media
* Keep timeout is the amount of seconds that the openaudiomc plugin runtime should keep track of this media for.
* Used to retroactively play media if a client connected too late. optional, -1 by default to disable.
*/
int startAtMillis();
@Setter
private transient int keepTimeout = -1;

/**
* If the media should loop (jumping back to startAtMillis and playing again)
*
* @return if the media should loop
* If the media should attempt to pick up where its currently according to the time spent since the start instant.
*/
boolean loopMedia();
@Setter
private boolean doPickup = false;

/**
* If the media should attempt to pick up where its currently according to the time spent since the start instant.
*
* @return if the media should attempt to pick up
* If the media should loop (jumping back to startAtMillis and playing again)
*/
boolean doPickup();
@Setter
private boolean loop = false;

/**
* Fade time is the amount of milliseconds it takes to fade in or out. 0 by default, but can be used to create smooth transitions
* between multiple regions, or to create a fade in effect.
*
* @return the fade time of the media
*/
int getFadeTime();
@Setter
private int fadeTime = 0;

/**
* Keep timeout is the amount of seconds that the openaudiomc plugin runtime should keep track of this media for.
* Used to retroactively play media if a client connected too late. optional, -1 by default to disable.
*
* @return the keep timeout of the media
* The volume of the media, 0-100
*/
int getKeepTimeout();
@Setter
private int volume = 100;

/**
* If this media will mute current regions while playing. This is used to prevent overlapping media in regions.
*
* @return if the media will mute regions
*/
boolean muteRegions();
@Setter
private boolean muteRegions = false;

/**
* If this media will mute the speakers of the client. This is used to prevent overlapping media with speakers.
*
* @return if the media will mute speakers
*/
boolean muteSpeakers();

/**
* New media ID, used to identify the media for regions, stop commands and other features, can be any non-null string
*
* @param mediaId the new media id
*/
void setMediaId(String mediaId);

/**
* Epoch millisecond timestamp of when the media started playing, used by the client to calculate the current position.
*
* @param startInstant the new start instant
*/
void setStartInstant(long startInstant);

/**
* Amount of seconds to keep track of this media for, used to retroactively play media if a client connected too late.
*
* @param keepTimeout the new keep timeout in seconds
*/
void setKeepTimeout(int keepTimeout);
@Setter
private boolean muteSpeakers = false;

/**
* If the media should attempt to pick up where its currently according to the time spent since the start instant.
*
* @param doPickup if the media should attempt to pick up
*/
void setDoPickup(boolean doPickup);

/**
* If the media should loop (jumping back to startAtMillis and playing again), defaults to false
*
* @param loopMedia if the media should loop
*/
void setLoopMedia(boolean loopMedia);


/**
* The amount of milliseconds to fade in or out. 0 by default, but can be used to create smooth transitions
*
* @param fadeTime the new fade time
*/
void setFadeTime(int fadeTime);

/**
* The volume of the media, 0-100
*
* @param volume the new volume
* The starting point of the media, in milliseconds. 0 by default, but can be used to skip intros or start at a certain point.
*/
void setVolume(int volume);
@Setter
private int startAtMillis = 0;

/**
* if this media should mute current regions while playing. This is used to prevent overlapping media in regions.
*
* @param muteRegions if the media should mute regions
* The flag of the media, used to identify the type of media. This is used by the client to apply different settings
* based on the type of media. This is set to DEFAULT by default, but can be set to REGION or SPEAKER to apply different settings.
*/
void setMuteRegions(boolean muteRegions);
@Setter
private MediaFlag flag = MediaFlag.DEFAULT;

/**
* if this media should mute the speakers of the client. This is used to prevent overlapping media with speakers.
* Create a new media based on a url
* the source will first be processed by the mutation api
* so you can just use addons without needing to wor§§ry
*
* @param muteSpeakers if the media should mute speakers
* @param source the resource url
*/
void setMuteSpeakers(boolean muteSpeakers);
public Media(String source) {
this.source = MediaApi.getInstance().translateSource(source);
this.startInstant = MediaApi.getInstance().getNormalizedCurrentEpoch();
}

/**
* The starting point of the media, in miliseconds. 0 by default, but can be used to skip intros or start at a certain point.
* You can apply multiple options.
* Used by the commands to allow settings via JSON
*
* @param startAtMillis the new starting point
* @param options The options. Selected via the command
* @return instance of self
*/
void setStartAtMillis(int startAtMillis);
public Media applySettings(MediaOptions options) {
this.loop = options.isLoop();
this.keepTimeout = options.getExpirationTimeout();
if (options.getId() != null) this.mediaId = options.getId();
this.doPickup = options.isPickUp();
this.setFadeTime(options.getFadeTime());
this.volume = options.getVolume();
this.muteRegions = options.isMuteRegions();
this.muteSpeakers = options.isMuteSpeakers();
this.startAtMillis = options.getStartAtMillis();
return this;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.craftmend.openaudiomc.generic.media.enums;
package com.craftmend.openaudiomc.api.media;

/**
* The 3 types of sounds, used by the client to mark the WebAudioType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.craftmend.openaudiomc.generic.media.objects;
package com.craftmend.openaudiomc.api.media;

import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.craftmend.openaudiomc.generic.media.objects;
package com.craftmend.openaudiomc.api.media;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public interface BasicSpeaker {
* Get the radius of the speaker
* @return radius
*/
int getRadius();
@NotNull
Integer getRadius();

/**
* If this speaker is currently directly powered by redstone
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.craftmend.openaudiomc.generic.media.objects;

@Deprecated
public class Media extends com.craftmend.openaudiomc.api.media.Media {

/**
* @deprecated use Sound instead, this class only exists at this package level for legacy reasons
*/

public Media(String source) {
super(source);
}
}
Binary file not shown.
Binary file modified api/target/classes/com/craftmend/openaudiomc/api/ClientApi.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion api/target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Fri Feb 02 23:37:46 CET 2024
#Sat Feb 03 17:05:18 CET 2024
artifactId=openaudiomc-api
groupId=com.craftmend.openaudiomc
version=6.8.10
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
com/craftmend/openaudiomc/api/media/MediaFlag.class
com/craftmend/openaudiomc/api/media/MediaOptions.class
com/craftmend/openaudiomc/api/media/OptionalError.class
com/craftmend/openaudiomc/api/media/UrlMutation.class
com/craftmend/openaudiomc/generic/media/objects/Media.class
com/craftmend/openaudiomc/api/ClientApi.class
com/craftmend/openaudiomc/api/WorldApi.class
com/craftmend/openaudiomc/api/media/Media.class
com/craftmend/openaudiomc/api/basic/Actor.class
com/craftmend/openaudiomc/api/spakers/ExtraSpeakerOptions.class
com/craftmend/openaudiomc/api/spakers/BasicSpeaker.class
com/craftmend/openaudiomc/api/voice/VoicePeerOptions.class
com/craftmend/openaudiomc/api/clients/Client.class
com/craftmend/openaudiomc/api/basic/Media.class
com/craftmend/openaudiomc/api/ClientApi.class
com/craftmend/openaudiomc/api/VoiceApi.class
com/craftmend/openaudiomc/api/spakers/Loc.class
com/craftmend/openaudiomc/api/MediaApi.class
com/craftmend/openaudiomc/api/ApiHolder.class
com/craftmend/openaudiomc/api/spakers/SpeakerType.class
com/craftmend/openaudiomc/api/regions/AudioRegion.class
Loading

0 comments on commit 59e8c03

Please sign in to comment.