-
-
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.
Merge branch 'master' into add-okaeri-serializer
- Loading branch information
Showing
64 changed files
with
1,832 additions
and
372 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,3 +1,4 @@ | ||
.gradle | ||
build | ||
.idea | ||
.idea | ||
run |
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,17 @@ | ||
|
||
object Versions { | ||
|
||
const val ADVENTURE_PLATFORM_BUKKIT = "4.3.3-SNAPSHOT" | ||
const val ADVENTURE_API = "4.18.0-SNAPSHOT" | ||
const val CDN = "1.14.5" | ||
|
||
const val MOCKITO_CORE = "5.12.0" | ||
const val JUNIT_JUPITER = "5.10.2" | ||
const val ASSERTJ_CORE = "3.26.0" | ||
const val AWAITILITY = "4.2.1" | ||
|
||
const val SPIGOT_API = "1.19.4-R0.1-SNAPSHOT" | ||
|
||
const val JETBRAINS_ANNOTATIONS = "24.1.0" | ||
|
||
} |
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,5 +1,5 @@ | ||
plugins { | ||
id("java-library") | ||
`java-library` | ||
} | ||
|
||
java { | ||
|
14 changes: 7 additions & 7 deletions
14
buildSrc/src/main/kotlin/multification-java-unit-test.gradle.kts
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,5 +1,5 @@ | ||
plugins { | ||
id("java-library") | ||
`java-library` | ||
} | ||
|
||
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
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
plugins { | ||
id("java") | ||
id("com.github.johnrengelman.shadow") version "8.1.1" | ||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0" | ||
id("xyz.jpenilla.run-paper") version "2.3.0" | ||
} | ||
|
||
version = "1.0.0-SNAPSHOT" | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://repo.panda-lang.org/releases/") | ||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") | ||
maven("https://repo.stellardrift.ca/repository/snapshots/") | ||
} | ||
|
||
dependencies { | ||
compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") | ||
|
||
implementation("net.kyori:adventure-platform-bukkit:${Versions.ADVENTURE_PLATFORM_BUKKIT}") | ||
implementation("net.kyori:adventure-text-minimessage:${Versions.ADVENTURE_API}") | ||
implementation("dev.rollczi:litecommands-bukkit:3.4.1") | ||
// implementation("com.eternalcode:multification-bukkit:1.0.3") // <-- uncomment in your project | ||
// implementation("com.eternalcode:multification-cdn:1.0.3") // <-- uncomment in your project | ||
|
||
implementation(project(":multification-bukkit")) // don't use this line in your build.gradle | ||
implementation(project(":multification-cdn")) // don't use this line in your build.gradle | ||
} | ||
|
||
val pluginName = "ExamplePlugin" | ||
val packageName = "com.eternalcode.example.bukkit" | ||
|
||
bukkit { | ||
main = "$packageName.$pluginName" | ||
apiVersion = "1.13" | ||
author = "Rollczi" | ||
name = pluginName | ||
version = "${project.version}" | ||
} | ||
|
||
tasks.shadowJar { | ||
archiveFileName.set("$pluginName v${project.version}.jar") | ||
|
||
listOf( | ||
"com.eternalcode.multification", | ||
"net.dzikoysk.cdn", | ||
"panda.std", | ||
"panda.utilities", | ||
"net.kyori", | ||
).forEach { relocate(it, "$packageName.libs.$it") } | ||
} | ||
|
||
sourceSets.test { | ||
java.setSrcDirs(emptyList<String>()) | ||
resources.setSrcDirs(emptyList<String>()) | ||
} | ||
|
||
tasks.runServer { | ||
minecraftVersion("1.20.4") | ||
} |
57 changes: 57 additions & 0 deletions
57
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/ExamplePlugin.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,57 @@ | ||
package com.eternalcode.example.bukkit; | ||
|
||
import com.eternalcode.example.bukkit.command.GiveCommand; | ||
import com.eternalcode.example.bukkit.command.TeleportCommand; | ||
import com.eternalcode.example.bukkit.config.ConfigurationManager; | ||
import com.eternalcode.example.bukkit.config.MessagesConfig; | ||
import com.eternalcode.example.bukkit.multification.YourMultification; | ||
import com.eternalcode.example.bukkit.command.FlyCommand; | ||
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory; | ||
import dev.rollczi.litecommands.LiteCommands; | ||
import net.kyori.adventure.platform.AudienceProvider; | ||
import net.kyori.adventure.platform.bukkit.BukkitAudiences; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class ExamplePlugin extends JavaPlugin { | ||
|
||
private LiteCommands<CommandSender> liteCommands; | ||
private AudienceProvider audienceProvider; | ||
|
||
@Override | ||
public void onEnable() { | ||
// Kyori Adventure platform | ||
audienceProvider = BukkitAudiences.create(this); | ||
MiniMessage miniMessage = MiniMessage.miniMessage(); | ||
|
||
// Config & Multification | ||
MessagesConfig messagesConfig = new MessagesConfig(); | ||
YourMultification multification = new YourMultification(messagesConfig, audienceProvider, miniMessage); | ||
|
||
ConfigurationManager configurationManager = new ConfigurationManager(this.getDataFolder(), multification.getNoticeRegistry()); | ||
configurationManager.load(messagesConfig, "messages.yml"); | ||
|
||
this.liteCommands = LiteBukkitFactory.builder() | ||
.commands( | ||
new TeleportCommand(multification), | ||
new FlyCommand(multification), | ||
new GiveCommand(multification) | ||
) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// unregister all commands from bukkit | ||
if (this.liteCommands != null) { | ||
this.liteCommands.unregister(); | ||
} | ||
|
||
// close audience provider | ||
if (this.audienceProvider != null) { | ||
this.audienceProvider.close(); | ||
} | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/FlyCommand.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,57 @@ | ||
package com.eternalcode.example.bukkit.command; | ||
|
||
import com.eternalcode.example.bukkit.multification.YourMultification; | ||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.annotations.permission.Permission; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
@Command(name = "fly", aliases = {"f"}) | ||
@Permission("example.fly") | ||
public class FlyCommand { | ||
|
||
private final YourMultification multification; | ||
|
||
public FlyCommand(YourMultification multification) { | ||
this.multification = multification; | ||
} | ||
|
||
@Execute | ||
void execute(@Context Player sender) { | ||
sender.setAllowFlight(!sender.getAllowFlight()); | ||
multification.create() | ||
.player(sender.getUniqueId()) | ||
.notice(messages -> messages.selfFlyCommandMessage) | ||
.placeholder("{state}", sender.getAllowFlight() ? "enabled" : "disabled") | ||
.send(); | ||
} | ||
|
||
@Execute | ||
void executeOther(@Context CommandSender sender, @Arg Player target) { | ||
target.setAllowFlight(!target.getAllowFlight()); | ||
|
||
multification.create() | ||
.player(target.getUniqueId()) | ||
.notice(messages -> messages.selfFlyCommandMessage) | ||
.placeholder("{state}", target.getAllowFlight() ? "enabled" : "disabled") | ||
.send(); | ||
|
||
multification.create() | ||
.viewer(sender) | ||
.notice(messages -> messages.otherFlyCommandMessage) | ||
.placeholder("{state}", target.getAllowFlight() ? "enabled" : "disabled") | ||
.placeholder("{player}", target.getName()) | ||
.send(); | ||
|
||
multification.create() | ||
.player(target.getUniqueId()) | ||
.notice(messages -> messages.otherFlyCommandMessageTarget) | ||
.placeholder("{state}", target.getAllowFlight() ? "enabled" : "disabled") | ||
.placeholder("{player}", sender.getName()) | ||
.send(); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/GiveCommand.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,55 @@ | ||
package com.eternalcode.example.bukkit.command; | ||
|
||
import com.eternalcode.example.bukkit.multification.YourMultification; | ||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.annotations.optional.OptionalArg; | ||
import org.bukkit.Material; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
@Command(name = "give") | ||
public class GiveCommand { | ||
|
||
private final YourMultification multification; | ||
|
||
public GiveCommand(YourMultification multification) { | ||
this.multification = multification; | ||
} | ||
|
||
@Execute | ||
public void execute( | ||
@Context CommandSender commandSender, | ||
@Arg("nick") Player target, | ||
@Arg("item") Material item, | ||
@OptionalArg("amount") Integer amount | ||
) { | ||
if (amount == null) { | ||
amount = 1; | ||
} | ||
|
||
multification.create() | ||
.player(target.getUniqueId()) | ||
.notice(messages -> messages.receiverGiveCommandMessage) | ||
.placeholder("{player}", commandSender.getName()) | ||
.placeholder("{amount}", amount.toString()) | ||
.placeholder("{item}", item.name()) | ||
.send(); | ||
|
||
|
||
multification | ||
.create() | ||
.viewer(commandSender) | ||
.notice(messages -> messages.senderGiveCommandMessage) | ||
.placeholder("{player}", target.getName()) | ||
.placeholder("{amount}", amount.toString()) | ||
.placeholder("{item}", item.name()) | ||
.send(); | ||
|
||
target.getInventory().addItem(new ItemStack(item, amount)); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/TeleportCommand.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,32 @@ | ||
package com.eternalcode.example.bukkit.command; | ||
|
||
import com.eternalcode.example.bukkit.multification.YourMultification; | ||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.annotations.permission.Permission; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import org.bukkit.entity.Player; | ||
|
||
@Command(name = "teleport", aliases = "tp") | ||
@Permission("dev.rollczi.teleport") | ||
public class TeleportCommand { | ||
|
||
private final YourMultification multification; | ||
|
||
public TeleportCommand(YourMultification multification) { | ||
this.multification = multification; | ||
} | ||
|
||
@Execute | ||
public void teleportSelf(@Context Player sender, @Arg Player to) { | ||
multification.create() | ||
.player(sender.getUniqueId()) | ||
.notice(messages -> messages.selfTeleportCommandMessage) | ||
.placeholder("{player}", to.getName()) | ||
.send(); | ||
|
||
sender.teleport(to.getLocation()); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...ples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/ConfigurationManager.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,36 @@ | ||
package com.eternalcode.example.bukkit.config; | ||
|
||
import com.eternalcode.multification.cdn.MultificationNoticeCdnComposer; | ||
import com.eternalcode.multification.notice.Notice; | ||
import com.eternalcode.multification.notice.resolver.NoticeResolverRegistry; | ||
import java.io.File; | ||
import net.dzikoysk.cdn.Cdn; | ||
import net.dzikoysk.cdn.CdnFactory; | ||
import net.dzikoysk.cdn.reflect.Visibility; | ||
import net.dzikoysk.cdn.source.Source; | ||
public class ConfigurationManager { | ||
|
||
private final Cdn cdn; | ||
private final File dataFolder; | ||
|
||
public ConfigurationManager(File dataFolder, NoticeResolverRegistry resolverRegistry) { | ||
this.dataFolder = dataFolder; | ||
this.cdn = CdnFactory | ||
.createYamlLike() | ||
.getSettings() | ||
.withComposer(Notice.class, new MultificationNoticeCdnComposer(resolverRegistry)) | ||
.withMemberResolver(Visibility.PACKAGE_PRIVATE) | ||
.build(); | ||
} | ||
|
||
public <T> T load(T config, String fileName) { | ||
this.cdn.load(Source.of(this.dataFolder, fileName), config) | ||
.orThrow(RuntimeException::new); | ||
|
||
this.cdn.render(config, Source.of(this.dataFolder, fileName)) | ||
.orThrow(RuntimeException::new); | ||
|
||
return config; | ||
} | ||
|
||
} |
Oops, something went wrong.