-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
10 changed files
with
146 additions
and
116 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
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
35 changes: 0 additions & 35 deletions
35
eternalcombat-api/src/main/java/com/eternalcode/combat/command/InvalidUsage.java
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
eternalcombat-api/src/main/java/com/eternalcode/combat/command/PermissionMessage.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
eternalcombat-api/src/main/java/com/eternalcode/combat/command/ReloadCommand.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,39 @@ | ||
package com.eternalcode.combat.command; | ||
|
||
import com.eternalcode.combat.config.ConfigService; | ||
import com.eternalcode.combat.notification.NotificationAnnouncer; | ||
import com.google.common.base.Stopwatch; | ||
import dev.rollczi.litecommands.annotations.async.Async; | ||
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 java.time.Duration; | ||
import org.bukkit.command.CommandSender; | ||
import panda.utilities.text.Formatter; | ||
|
||
@Command(name = "combatlog", aliases = "combat") | ||
@Permission("eternalcombat.reload") | ||
public class ReloadCommand { | ||
|
||
private static final String RELOAD_MESSAGE = "<b><gradient:#8a1212:#fc6b03>EternalCombat:</gradient></b> Reloaded EternalCombat in <color:#fce303>{TIME}ms!</color>"; | ||
|
||
private final ConfigService configService; | ||
private final NotificationAnnouncer announcer; | ||
|
||
public ReloadCommand(ConfigService configService, NotificationAnnouncer announcer) { | ||
this.configService = configService; | ||
this.announcer = announcer; | ||
} | ||
|
||
@Async | ||
@Execute(name = "reload") | ||
void execute(@Context CommandSender sender) { | ||
Stopwatch stopwatch = Stopwatch.createStarted(); | ||
this.configService.reload(); | ||
|
||
Duration elapsed = stopwatch.elapsed(); | ||
Formatter format = new Formatter().register("{TIME}", elapsed.toMillis()); | ||
this.announcer.sendMessage(sender, format.format(RELOAD_MESSAGE)); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...bat-api/src/main/java/com/eternalcode/combat/command/handler/InvalidUsageHandlerImpl.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,38 @@ | ||
package com.eternalcode.combat.command.handler; | ||
|
||
import com.eternalcode.combat.config.implementation.PluginConfig; | ||
import com.eternalcode.combat.notification.NotificationAnnouncer; | ||
import dev.rollczi.litecommands.handler.result.ResultHandlerChain; | ||
import dev.rollczi.litecommands.invalidusage.InvalidUsage; | ||
import dev.rollczi.litecommands.invalidusage.InvalidUsageHandler; | ||
import dev.rollczi.litecommands.invocation.Invocation; | ||
import dev.rollczi.litecommands.schematic.Schematic; | ||
import org.bukkit.command.CommandSender; | ||
import panda.utilities.text.Formatter; | ||
|
||
public class InvalidUsageHandlerImpl implements InvalidUsageHandler<CommandSender> { | ||
|
||
private final PluginConfig config; | ||
private final NotificationAnnouncer announcer; | ||
|
||
public InvalidUsageHandlerImpl(PluginConfig config, NotificationAnnouncer announcer) { | ||
this.config = config; | ||
this.announcer = announcer; | ||
} | ||
|
||
@Override | ||
public void handle( | ||
Invocation<CommandSender> invocation, | ||
InvalidUsage<CommandSender> commandSenderInvalidUsage, | ||
ResultHandlerChain<CommandSender> resultHandlerChain | ||
) { | ||
Schematic schematic = commandSenderInvalidUsage.getSchematic(); | ||
|
||
for (String usage : schematic.all()) { | ||
Formatter formatter = new Formatter() | ||
.register("{USAGE}", usage); | ||
|
||
this.announcer.sendMessage(invocation.sender(), formatter.format(this.config.messages.invalidCommandUsage)); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...pi/src/main/java/com/eternalcode/combat/command/handler/MissingPermissionHandlerImpl.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,35 @@ | ||
package com.eternalcode.combat.command.handler; | ||
|
||
import com.eternalcode.combat.config.implementation.PluginConfig; | ||
import com.eternalcode.combat.notification.NotificationAnnouncer; | ||
import dev.rollczi.litecommands.handler.result.ResultHandlerChain; | ||
import dev.rollczi.litecommands.invocation.Invocation; | ||
import dev.rollczi.litecommands.permission.MissingPermissions; | ||
import dev.rollczi.litecommands.permission.MissingPermissionsHandler; | ||
import org.bukkit.command.CommandSender; | ||
import panda.utilities.text.Formatter; | ||
|
||
public class MissingPermissionHandlerImpl implements MissingPermissionsHandler<CommandSender> { | ||
|
||
private final PluginConfig config; | ||
private final NotificationAnnouncer announcer; | ||
|
||
public MissingPermissionHandlerImpl(PluginConfig config, NotificationAnnouncer announcer) { | ||
this.config = config; | ||
this.announcer = announcer; | ||
} | ||
|
||
@Override | ||
public void handle( | ||
Invocation<CommandSender> invocation, | ||
MissingPermissions missingPermissions, | ||
ResultHandlerChain<CommandSender> resultHandlerChain | ||
) { | ||
String joinedText = missingPermissions.asJoinedText(); | ||
|
||
Formatter formatter = new Formatter() | ||
.register("{PERMISSION}", joinedText); | ||
|
||
this.announcer.sendMessage(invocation.sender(), formatter.format(this.config.messages.noPermission)); | ||
} | ||
} |
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