Skip to content

Commit

Permalink
GH-360 Add reply to target (Resolve #360)
Browse files Browse the repository at this point in the history
* Add reply to target

* Update EternalCore.java

* Description fix

* Add reply to containers, add DISABLED to notification

* invoker -> sender, announcer -> noticeService

* Fix command completion, and some messages send

---------

Co-authored-by: Martin Sulikowski <vLuckyyy.biznes@gmail.com>
  • Loading branch information
Jakubk15 and vLuckyyy authored Feb 23, 2023
1 parent e65847b commit 5b4b32e
Show file tree
Hide file tree
Showing 23 changed files with 275 additions and 56 deletions.
20 changes: 10 additions & 10 deletions core/src/main/java/com/eternalcode/core/EternalCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.eternalcode.core.database.NoneRepository;
import com.eternalcode.core.database.wrapper.HomeRepositoryOrmLite;
import com.eternalcode.core.database.wrapper.IgnoreRepositoryOrmLite;
import com.eternalcode.core.feature.essentials.playerinfo.PingCommand;
import com.eternalcode.core.feature.adminchat.AdminChatCommand;
import com.eternalcode.core.feature.afk.AfkCommand;
import com.eternalcode.core.feature.afk.AfkController;
Expand All @@ -45,6 +44,7 @@
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.SpeedCommand;
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 All @@ -65,8 +65,8 @@
import com.eternalcode.core.feature.essentials.item.SkullCommand;
import com.eternalcode.core.feature.essentials.playerinfo.OnlinePlayerCountCommand;
import com.eternalcode.core.feature.essentials.playerinfo.OnlinePlayersListCommand;
import com.eternalcode.core.feature.essentials.playerinfo.PingCommand;
import com.eternalcode.core.feature.essentials.playerinfo.WhoIsCommand;
import com.eternalcode.core.feature.essentials.SpeedCommand;
import com.eternalcode.core.feature.essentials.time.DayCommand;
import com.eternalcode.core.feature.essentials.time.NightCommand;
import com.eternalcode.core.feature.essentials.time.TimeCommand;
Expand Down Expand Up @@ -396,13 +396,13 @@ public void onEnable() {
new WarpCommand(this.noticeService, this.warpManager, this.teleportTaskService),

// Inventory Commands
new EnderchestCommand(),
new WorkbenchCommand(),
new AnvilCommand(),
new CartographyTableCommand(),
new GrindstoneCommand(),
new StonecutterCommand(),
new DisposalCommand(this.miniMessage, this.translationManager, this.userManager, server),
new EnderchestCommand(this.noticeService),
new WorkbenchCommand(this.noticeService),
new AnvilCommand(this.noticeService),
new CartographyTableCommand(this.noticeService),
new GrindstoneCommand(this.noticeService),
new StonecutterCommand(this.noticeService),
new DisposalCommand(this.miniMessage, this.translationManager, this.userManager, server, this.noticeService),

// Private Chat Commands
new PrivateChatCommands(this.privateChatService, this.noticeService),
Expand All @@ -416,7 +416,7 @@ public void onEnable() {
new GodCommand(this.noticeService),
new GameModeCommand(this.noticeService),
new SpeedCommand(this.noticeService),
new GiveCommand(this.noticeService),
new GiveCommand(this.noticeService, this.pluginConfiguration),
new EnchantCommand(this.pluginConfiguration, this.noticeService),
new RepairCommand(this.noticeService),
new HealCommand(this.noticeService),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public NoticeTypeArgument(BukkitViewerProvider viewerProvider, TranslationManage
@Override
public List<Suggestion> suggest(LiteInvocation invocation) {
return Arrays.stream(NoticeType.values())
.filter(type -> type != NoticeType.NONE)
.filter(type -> type != NoticeType.DISABLED)
.map(notificationType -> notificationType.name().toLowerCase())
.map(Suggestion::of)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public static class OtherSettings implements TeleportRequestSettings {
@Description({ " ", "# Use unsafe enchantments? Allows you to apply custom enchants to various items" })
public boolean unsafeEnchantments = true;

@Description({ " ", "# The default item give amount, when no amount is specified in the command." })
public int defaultGiveAmount = 1;

@Description({ " ", "# Time of tpa requests expire" })
public Duration tpaRequestExpire = Duration.ofSeconds(80);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ void execute(Player player) {
void execute(Viewer viewer, @Arg Player target) {
this.feed(target);

this.noticeService.create()
.notice(translation -> translation.player().feedMessage())
.player(target.getUniqueId())
.send();

this.noticeService.create()
.notice(translation -> translation.player().feedMessageBy())
.placeholder("{PLAYER}", target.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import com.eternalcode.core.notification.NoticeService;
import com.eternalcode.core.viewer.Viewer;
import dev.rollczi.litecommands.argument.Arg;
import dev.rollczi.litecommands.argument.By;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

@Route(name = "fly")
Expand Down Expand Up @@ -35,6 +33,12 @@ void execute(Player player) {
void execute(Viewer viewer, @Arg Player target) {
target.setAllowFlight(!target.getAllowFlight());

this.noticeService.create()
.notice(translation -> translation.player().flyMessage())
.placeholder("{STATE}", translation -> target.getAllowFlight() ? translation.format().enable() : translation.format().disable())
.player(target.getUniqueId())
.send();

this.noticeService.create()
.notice(translation -> translation.player().flySetMessage())
.placeholder("{PLAYER}", target.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ void execute(Player player) {
void execute(Viewer viewer, @Arg Player target) {
this.heal(target);

this.noticeService.create()
.notice(translation -> translation.player().healMessage())
.player(target.getUniqueId())
.send();


this.noticeService.create()
.notice(translation -> translation.player().healMessageBy())
.placeholder("{PLAYER}", target.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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.argument.By;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
Expand All @@ -13,14 +13,36 @@
@Permission("eternalcore.anvil")
public class AnvilCommand {

@Execute
private final NoticeService noticeService;

public AnvilCommand(NoticeService noticeService) {
this.noticeService = noticeService;
}

@Execute(required = 0)
void executeSelf(Player player) {
AdditionalContainerPaper.openAdditionalContainer(player, AdditionalContainerType.ANVIL);

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpened())
.player(player.getUniqueId())
.send();
}

@Execute
void execute(@Arg Player target) {
@Execute(required = 1)
void execute(Player sender, @Arg Player target) {
AdditionalContainerPaper.openAdditionalContainer(target, AdditionalContainerType.ANVIL);
this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpenedBy())
.placeholder("{PLAYER}", sender.getName())
.player(target.getUniqueId())
.send();

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpenedFor())
.player(sender.getUniqueId())
.placeholder("{PLAYER}", target.getName())
.send();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

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.argument.By;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
Expand All @@ -14,14 +14,37 @@
@Permission("eternalcore.cartography")
public class CartographyTableCommand {

@Execute
private final NoticeService noticeService;

public CartographyTableCommand(NoticeService noticeService) {
this.noticeService = noticeService;
}

@Execute(required = 0)
void executeSelf(Player player) {
AdditionalContainerPaper.openAdditionalContainer(player, AdditionalContainerType.CARTOGRAPHY_TABLE);

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpened())
.player(player.getUniqueId())
.send();
}

@Execute
void execute(@Arg Player target) {
@Execute(required = 1)
void execute(Player sender, @Arg Player target) {
AdditionalContainerPaper.openAdditionalContainer(target, AdditionalContainerType.CARTOGRAPHY_TABLE);

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpenedBy())
.placeholder("{PLAYER}", sender.getName())
.player(target.getUniqueId())
.send();

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpenedFor())
.player(sender.getUniqueId())
.placeholder("{PLAYER}", target.getName())
.send();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eternalcode.core.feature.essentials.container;

import com.eternalcode.core.language.Language;
import com.eternalcode.core.notification.NoticeService;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.user.UserManager;
Expand All @@ -17,16 +18,18 @@
@Permission("eternalcore.disposal")
public class DisposalCommand {

private final NoticeService noticeService;
private final MiniMessage miniMessage;
private final TranslationManager translationManager;
private final UserManager userManager;
private final Server server;

public DisposalCommand(MiniMessage miniMessage, TranslationManager translationManager, UserManager userManager, Server server) {
public DisposalCommand(MiniMessage miniMessage, TranslationManager translationManager, UserManager userManager, Server server, NoticeService noticeService) {
this.miniMessage = miniMessage;
this.translationManager = translationManager;
this.userManager = userManager;
this.server = server;
this.noticeService = noticeService;
}

@Execute
Expand All @@ -40,6 +43,11 @@ void execute(Player player) {
String serialize = Legacy.SECTION_SERIALIZER.serialize(component);

player.openInventory(this.server.createInventory(null, 54, serialize));

this.noticeService.create()
.player(player.getUniqueId())
.notice(message -> message.container().genericContainerOpened())
.send();
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.eternalcode.core.feature.essentials.container;


import com.eternalcode.core.notification.NoticeService;
import dev.rollczi.litecommands.argument.Arg;
import dev.rollczi.litecommands.argument.By;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
Expand All @@ -12,14 +12,37 @@
@Permission("eternalcore.enderchest")
public class EnderchestCommand {

@Execute
private final NoticeService noticeService;

public EnderchestCommand(NoticeService noticeService) {
this.noticeService = noticeService;
}

@Execute(required = 0)
void execute(Player player) {
player.openInventory(player.getEnderChest());

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpened())
.player(player.getUniqueId())
.send();
}

@Execute(required = 1)
void execute(Player player, @Arg Player target) {
player.openInventory(target.getEnderChest());

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpenedFor())
.placeholder("{PLAYER}", target.getName())
.player(player.getUniqueId())
.send();

this.noticeService.create()
.notice(translation -> translation.container().genericContainerOpenedBy())
.player(target.getUniqueId())
.placeholder("{PLAYER}", player.getName())
.send();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

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.argument.By;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
Expand All @@ -14,14 +14,37 @@
@Permission("eternalcore.grindstone")
public class GrindstoneCommand {

@Execute
private final NoticeService announcer;

public GrindstoneCommand(NoticeService announcer) {
this.announcer = announcer;
}

@Execute(required = 0)
void executeSelf(Player player) {
AdditionalContainerPaper.openAdditionalContainer(player, AdditionalContainerType.GRINDSTONE);

this.announcer.create()
.notice(translation -> translation.container().genericContainerOpened())
.player(player.getUniqueId())
.send();
}

@Execute
void execute(@Arg Player target) {
@Execute(required = 1)
void execute(Player sender, @Arg Player target) {
AdditionalContainerPaper.openAdditionalContainer(target, AdditionalContainerType.GRINDSTONE);

this.announcer.create()
.notice(translation -> translation.container().genericContainerOpenedFor())
.placeholder("{PLAYER}", target.getName())
.player(sender.getUniqueId())
.send();

this.announcer.create()
.notice(translation -> translation.container().genericContainerOpenedBy())
.player(target.getUniqueId())
.placeholder("{PLAYER}", sender.getName())
.send();
}

}
Expand Down
Loading

0 comments on commit 5b4b32e

Please sign in to comment.