Skip to content

Commit

Permalink
Merge branch 'master' into feature/poll
Browse files Browse the repository at this point in the history
  • Loading branch information
vLuckyyy authored Jun 18, 2023
2 parents ca14b51 + 86e9411 commit 8eb57ac
Show file tree
Hide file tree
Showing 33 changed files with 424 additions and 142 deletions.
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ repositories {
dependencies {
implementation("net.kyori:blossom:1.3.1")
implementation("com.github.johnrengelman:shadow:8.1.1")
implementation("xyz.jpenilla:run-task:2.0.1")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20")
implementation("xyz.jpenilla:run-task:2.1.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21")
implementation("net.minecrell:plugin-yml:0.5.3")
}

Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/eternalcode-java-test.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ dependencies {
testImplementation("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
testImplementation("net.dzikoysk:cdn:1.14.4")
testImplementation("org.codehaus.groovy:groovy-all:3.0.17")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testImplementation("org.mockito:mockito-core:5.3.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.3")
testImplementation("org.mockito:mockito-core:5.3.1")
testImplementation("net.kyori:adventure-platform-bukkit:4.3.0")
testImplementation("net.kyori:adventure-text-minimessage:4.13.1")
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/eternalcode-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group = "com.eternalcode"
version = "1.0.0"

checkstyle {
toolVersion = "10.9.3"
toolVersion = "10.11.0"

configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")

Expand Down
12 changes: 6 additions & 6 deletions eternalcore-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ eternalShadow {
onlyCompile("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")

onlyCompile("me.clip:placeholderapi:2.11.3")
onlyCompile("org.projectlombok:lombok:1.18.26")
onlyCompile("org.projectlombok:lombok:1.18.28")
onlyCompile("org.jetbrains:annotations:24.0.1")
annotationProcessors("org.projectlombok:lombok:1.18.26")
annotationProcessors("org.projectlombok:lombok:1.18.28")

// Paper and Adventure libraries
library("io.papermc:paperlib:1.0.8")
Expand All @@ -43,25 +43,25 @@ eternalShadow {
)

// command framework & skull library
library("dev.rollczi.litecommands:bukkit-adventure:2.8.7")
library("dev.rollczi.litecommands:bukkit-adventure:2.8.8")
library("dev.rollczi:liteskullapi:1.3.0")
libraryRelocate(
"dev.rollczi.litecommands",
"dev.rollczi.liteskullapi"
)

// common libraries
library("org.panda-lang:expressible:1.3.4")
library("org.panda-lang:expressible:1.3.5")
library("org.panda-lang:panda-utilities:0.5.3-alpha")
library("commons-io:commons-io:2.11.0")
library("commons-io:commons-io:2.12.0")
libraryRelocate(
"panda.std",
"panda.utilities",
"org.apache.commons.io",
)

// gui library
library("dev.triumphteam:triumph-gui:3.1.4")
library("dev.triumphteam:triumph-gui:3.1.5")
libraryRelocate("dev.triumphteam")

// metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import com.eternalcode.core.command.argument.PlayerArgument;
import com.eternalcode.core.command.argument.RequesterArgument;
import com.eternalcode.core.command.argument.SpeedArgument;
import com.eternalcode.core.command.argument.SpeedTypeArgument;
import com.eternalcode.core.command.argument.StringNicknameArgument;
import com.eternalcode.core.command.argument.UserArgument;
import com.eternalcode.core.command.argument.WarpArgument;
import com.eternalcode.core.command.argument.WorldArgument;
import com.eternalcode.core.command.argument.MobEntityArgument;
import com.eternalcode.core.command.argument.home.ArgHome;
import com.eternalcode.core.command.argument.home.HomeArgument;
import com.eternalcode.core.command.configurator.GameModeConfigurator;
import com.eternalcode.core.command.configurator.config.CommandConfiguration;
import com.eternalcode.core.command.configurator.CommandConfigurator;
import com.eternalcode.core.command.contextual.PlayerContextual;
Expand Down Expand Up @@ -47,8 +49,11 @@
import com.eternalcode.core.feature.essentials.GodCommand;
import com.eternalcode.core.feature.essentials.HealCommand;
import com.eternalcode.core.feature.essentials.KillCommand;
import com.eternalcode.core.feature.essentials.container.LoomCommand;
import com.eternalcode.core.feature.essentials.container.SmithingTableCommand;
import com.eternalcode.core.feature.essentials.mob.ButcherCommand;
import com.eternalcode.core.feature.essentials.SpeedCommand;
import com.eternalcode.core.feature.essentials.speed.SpeedCommand;
import com.eternalcode.core.feature.essentials.speed.SpeedType;
import com.eternalcode.core.feature.essentials.container.AnvilCommand;
import com.eternalcode.core.feature.essentials.container.CartographyTableCommand;
import com.eternalcode.core.feature.essentials.container.DisposalCommand;
Expand Down Expand Up @@ -305,6 +310,7 @@ public EternalCore(Plugin plugin) {
.argument(String.class, PollCommand.PollArgument.KEY, new PollCommand.PollArgument(this.pollManager))
.argument(GameMode.class, new GameModeArgument(this.viewerProvider, this.translationManager, commandConfiguration.argument))
.argument(NoticeType.class, new NoticeTypeArgument(this.viewerProvider, this.translationManager))
.argument(SpeedType.class, new SpeedTypeArgument(this.viewerProvider, this.translationManager))
.argument(Warp.class, new WarpArgument(this.warpManager, this.translationManager, this.viewerProvider))
.argument(Enchantment.class, new EnchantmentArgument(this.viewerProvider, this.translationManager))
.argument(User.class, new UserArgument(this.viewerProvider, this.translationManager, server, this.userManager))
Expand All @@ -313,7 +319,6 @@ public EternalCore(Plugin plugin) {
.argument(Duration.class, DurationArgument.KEY, new DurationArgument(this.viewerProvider, this.translationManager))
.argument(Integer.class, SpeedArgument.KEY, new SpeedArgument(this.viewerProvider, this.translationManager))
.argument(MobEntity.class, new MobEntityArgument(this.viewerProvider, this.translationManager))

// multilevel Arguments (include optional)
.argumentMultilevel(Location.class, new LocationArgument(this.translationManager, this.viewerProvider))

Expand Down Expand Up @@ -367,7 +372,7 @@ public EternalCore(Plugin plugin) {

// Spawn & Warp Command
new SetSpawnCommand(this.configurationManager, locationsConfiguration, this.noticeService),
new SpawnCommand(locationsConfiguration, this.noticeService, this.teleportTaskService, this.teleportService),
new SpawnCommand(locationsConfiguration, pluginConfiguration.teleport, this.noticeService, this.teleportTaskService, this.teleportService),
new WarpCommand(this.noticeService, this.warpManager, this.teleportTaskService, pluginConfiguration, warpInventory),

// Inventory Commands
Expand All @@ -377,6 +382,8 @@ public EternalCore(Plugin plugin) {
new CartographyTableCommand(this.noticeService),
new GrindstoneCommand(this.noticeService),
new StonecutterCommand(this.noticeService),
new LoomCommand(this.noticeService),
new SmithingTableCommand(this.noticeService),
new DisposalCommand(this.miniMessage, this.translationManager, this.userManager, server, this.noticeService),

// Private Chat Commands
Expand All @@ -389,7 +396,7 @@ public EternalCore(Plugin plugin) {
// Moderation Commands
new FlyCommand(this.noticeService),
new GodCommand(this.noticeService),
new GameModeCommand(this.noticeService),
new GameModeCommand(commandConfiguration, this.noticeService),
new SpeedCommand(this.noticeService),
new GiveCommand(this.noticeService, pluginConfiguration),
new EnchantCommand(pluginConfiguration, this.noticeService),
Expand Down Expand Up @@ -419,6 +426,7 @@ public EternalCore(Plugin plugin) {
ChatManagerCommand.create(this.chatManager, this.noticeService, pluginConfiguration.chat.linesToClear)
)
.commandGlobalEditor(new CommandConfigurator(commandConfiguration))
.commandEditor(GameModeCommand.class, new GameModeConfigurator(commandConfiguration))
.register();

/* Listeners */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.eternalcode.core.command.argument;

import com.eternalcode.core.notification.Notification;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.feature.essentials.speed.SpeedType;
import com.eternalcode.core.viewer.BukkitViewerProvider;
import dev.rollczi.litecommands.argument.ArgumentName;
import dev.rollczi.litecommands.command.LiteInvocation;
import dev.rollczi.litecommands.suggestion.Suggestion;
import panda.std.Option;
import panda.std.Result;

import java.util.Arrays;
import java.util.List;

@ArgumentName("type")
public class SpeedTypeArgument extends AbstractViewerArgument<SpeedType> {

public SpeedTypeArgument(BukkitViewerProvider viewerProvider, TranslationManager translationManager) {
super(viewerProvider, translationManager);
}

@Override
public Result<SpeedType, Notification> parse(LiteInvocation invocation, String argument, Translation translation) {
return Option.supplyThrowing(IllegalArgumentException.class, () -> SpeedType.valueOf(argument.toUpperCase()))
.toResult(() -> translation.player().speedTypeNotCorrect());
}

@Override
public List<Suggestion> suggest(LiteInvocation invocation) {
return Arrays.stream(SpeedType.values())
.map(SpeedType::name)
.map(Suggestion::of)
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.eternalcode.core.command.configurator;

import com.eternalcode.core.command.configurator.config.CommandConfiguration;
import dev.rollczi.litecommands.factory.CommandEditor;

public class GameModeConfigurator implements CommandEditor {

private final CommandConfiguration commandConfiguration;

public GameModeConfigurator(CommandConfiguration commandConfiguration) {
this.commandConfiguration = commandConfiguration;
}

@Override
public State edit(State state) {
return state.aliases(this.commandConfiguration.getGameModeShortCuts(), false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -48,6 +49,30 @@ public Collection<String> getAvailableAliases() {

}

@Description("# List of shortcuts for gamemode command")
public Map<GameMode, List<String>> gameModeShortCuts = Map.of(
GameMode.SURVIVAL, Collections.singletonList("gms"),
GameMode.CREATIVE, Collections.singletonList("gmc"),
GameMode.ADVENTURE, Collections.singletonList("gma"),
GameMode.SPECTATOR, Collections.singletonList("gmsp")
);

public List<String> getGameModeShortCuts() {
return this.gameModeShortCuts.values()
.stream()
.flatMap(Collection::stream)
.toList();
}

public GameMode getGameMode(String label) {
return this.gameModeShortCuts.entrySet()
.stream()
.filter(entry -> entry.getValue().contains(label))
.map(Map.Entry::getKey)
.findFirst()
.orElse(null);
}

@Description({
"# This file allows you to configure commands.",
"# You can change command name, aliases and permissions.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.eternalcode.core.database.DatabaseType;
import com.eternalcode.core.feature.afk.AfkSettings;
import com.eternalcode.core.feature.chat.ChatSettings;
import com.eternalcode.core.feature.spawn.SpawnSettings;
import com.eternalcode.core.teleport.Teleport;
import com.eternalcode.core.teleport.request.TeleportRequestSettings;
import net.dzikoysk.cdn.entity.Contextual;
Expand Down Expand Up @@ -79,10 +80,18 @@ public Duration teleportTime() {
public Teleport teleport = new Teleport();

@Contextual
public static class Teleport {
public static class Teleport implements SpawnSettings {

@Description("# Teleports the player to spawn after death")
public boolean teleportToSpawnOnDeath = true;

@Description("# Time of teleportation to spawn")
public Duration teleportTimeToSpawn = Duration.ofSeconds(5);

@Override
public Duration teleportationTimeToSpawn() {
return this.teleportTimeToSpawn;
}
}

@Description({ " ", "# Homes Section" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Completable<Option<Home>> getHome(User user, String name) {
.where()
.eq("owner", user.getUniqueId())
.and()
.eq("name", user.getName())
.eq("name", name)
.queryForFirst()
).map(HomeWrapper::toHome));
}
Expand All @@ -63,7 +63,7 @@ public Completable<Integer> deleteHome(User user, String name) {
builder.where()
.eq("owner", user.getUniqueId())
.and()
.eq("name", user.getName());
.eq("name", name);

return builder.delete();
}).onError(Throwable::printStackTrace).orElseGet(throwable -> 0));
Expand All @@ -80,8 +80,6 @@ public Completable<Set<Home>> getHomes(User user) {
return this.action(HomeWrapper.class, dao -> Option.supplyThrowing(Throwable.class, () -> dao.queryBuilder()
.where()
.eq("owner", user.getUniqueId())
.and()
.eq("name", user.getName())
.query()
)).thenApply(option -> option.map(homes -> homes.stream()
.map(HomeWrapper::toHome)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.eternalcode.annotations.scan.command.DescriptionDocs;
import com.eternalcode.containers.AdditionalContainerPaper;
import com.eternalcode.containers.AdditionalContainerType;
import com.eternalcode.core.notification.NoticeService;
import dev.rollczi.litecommands.argument.Arg;
import dev.rollczi.litecommands.command.execute.Execute;
Expand All @@ -23,7 +22,7 @@ public AnvilCommand(NoticeService noticeService) {
@Execute(required = 0)
@DescriptionDocs(description = "Opens an anvil for you")
void executeSelf(Player player) {
AdditionalContainerPaper.openAdditionalContainer(player, AdditionalContainerType.ANVIL);
AdditionalContainerPaper.ANVIL.open(player);

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpened())
Expand All @@ -34,7 +33,8 @@ void executeSelf(Player player) {
@Execute(required = 1)
@DescriptionDocs(description = "Opens an anvil for another player", arguments = "<player>")
void execute(Player sender, @Arg Player target) {
AdditionalContainerPaper.openAdditionalContainer(target, AdditionalContainerType.ANVIL);
AdditionalContainerPaper.ANVIL.open(target);

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpenedBy())
.placeholder("{PLAYER}", sender.getName())
Expand Down
Loading

0 comments on commit 8eb57ac

Please sign in to comment.