-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
171 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.gradle.kotlin.dsl.support.uppercaseFirstChar | ||
|
||
plugins { | ||
java | ||
alias(libs.plugins.shadow) | ||
} | ||
|
||
allprojects { | ||
subprojects { | ||
apply<JavaPlugin>() | ||
} | ||
apply<ShadowPlugin>() | ||
|
||
val projectName = project.name.replace("titleannouncer-", "").uppercaseFirstChar() | ||
|
||
subprojects { | ||
repositories { | ||
mavenCentral() | ||
maven("https://papermc.io/repo/repository/maven-public/") | ||
} | ||
|
||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17)) | ||
|
||
tasks.withType<JavaCompile> { | ||
options.encoding = Charsets.UTF_8.name() | ||
options.release.set(17) | ||
} | ||
} | ||
|
||
tasks { | ||
shadowJar { | ||
archiveFileName.set("TitleAnnouncer-${project.version}.jar") | ||
archiveClassifier.set("") | ||
doLast { | ||
copy { | ||
from(archiveFile) | ||
into("${rootProject.projectDir}/build") | ||
tasks { | ||
withType<JavaCompile> { | ||
options.encoding = Charsets.UTF_8.name() | ||
options.release.set(17) | ||
} | ||
if (projectName != "Common") { | ||
withType<ShadowJar> { | ||
archiveFileName.set("TitleAnnouncer-${projectName}-${project.version}.jar") | ||
archiveClassifier.set("") | ||
doLast { | ||
copy { | ||
from(archiveFile) | ||
into("${rootProject.projectDir}/build") | ||
} | ||
} | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
} | ||
} | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
} | ||
build { | ||
dependsOn(shadowJar) | ||
build { | ||
dependsOn(shadowJar) | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>() { | ||
options.encoding = "UTF-8" | ||
} |
25 changes: 23 additions & 2 deletions
25
common/src/main/java/io/github/_4drian3d/titleannouncer/common/TitleAnnouncer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
package io.github._4drian3d.titleannouncer.common; | ||
|
||
import com.google.inject.Injector; | ||
import com.google.inject.Key; | ||
import com.google.inject.TypeLiteral; | ||
import io.github._4drian3d.titleannouncer.common.commands.AnnouncerCommand; | ||
|
||
public interface TitleAnnouncer { | ||
void init(); | ||
import java.util.Set; | ||
|
||
public abstract class TitleAnnouncer { | ||
private final Injector injector; | ||
|
||
protected TitleAnnouncer( | ||
Injector injector | ||
) { | ||
this.injector = injector; | ||
} | ||
|
||
public void init() { | ||
var commands = injector.getInstance(Key.get(new TypeLiteral<Set<AnnouncerCommand>>() {})); | ||
for (final AnnouncerCommand command : commands) { | ||
command.register(); | ||
} | ||
} | ||
|
||
public abstract void stop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
common/src/main/java/io/github/_4drian3d/titleannouncer/common/adapter/CommandAdapter.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
common/src/main/java/io/github/_4drian3d/titleannouncer/common/adapter/PlatformAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.github._4drian3d.titleannouncer.common.adapter; | ||
|
||
import net.kyori.adventure.audience.Audience; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.Optional; | ||
|
||
public interface PlatformAdapter<P extends Audience> { | ||
@NotNull Audience getGlobalAudience(); | ||
|
||
@NotNull Optional<P> stringToAudience(final @NotNull String string); | ||
|
||
@NotNull Collection<String> playerSuggestions(); | ||
|
||
default Optional<? extends Audience> destinationFromString(final String string, final Audience audience) { | ||
if (string.equalsIgnoreCase("self")) { | ||
return Optional.of(audience); | ||
} | ||
if (string.equalsIgnoreCase("all")) { | ||
return Optional.of(getGlobalAudience()); | ||
} | ||
if (string.startsWith("player:")) { | ||
return stringToAudience(string.replace("player:", "")); | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
...on/src/main/java/io/github/_4drian3d/titleannouncer/common/commands/AnnouncerCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
package io.github._4drian3d.titleannouncer.common.commands; | ||
|
||
import cloud.commandframework.CommandManager; | ||
import io.github._4drian3d.titleannouncer.common.adapter.Commander; | ||
|
||
public interface AnnouncerCommand { | ||
void register(CommandManager<Commander> commandManager); | ||
void register(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
dependencies { | ||
compileOnly(libs.velocity) | ||
annotationProcessor(libs.velocity) | ||
compileOnly(projects.titleannouncerCommon) | ||
implementation(projects.titleannouncerCommon) | ||
implementation(libs.cloud.velocity) | ||
} |
10 changes: 8 additions & 2 deletions
10
...ity/src/main/java/io/github/_4drian3d/titleannouncer/velocity/TitleAnnouncerVelocity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
package io.github._4drian3d.titleannouncer.velocity; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Injector; | ||
import com.google.inject.Singleton; | ||
import io.github._4drian3d.titleannouncer.common.TitleAnnouncer; | ||
|
||
@Singleton | ||
public final class TitleAnnouncerVelocity implements TitleAnnouncer { | ||
public final class TitleAnnouncerVelocity extends TitleAnnouncer { | ||
@Inject | ||
public TitleAnnouncerVelocity(Injector injector) { | ||
super(injector); | ||
} | ||
|
||
@Override | ||
public void init() { | ||
public void stop() { | ||
|
||
} | ||
} |
Oops, something went wrong.