-
Notifications
You must be signed in to change notification settings - Fork 0
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
5 changed files
with
105 additions
and
2 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
28 changes: 28 additions & 0 deletions
28
api/src/main/java/com/artformgames/core/command/handlers/CommandUsageHandler.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,28 @@ | ||
package com.artformgames.core.command.handlers; | ||
|
||
import com.artformgames.core.conf.GeneralMessages; | ||
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; | ||
|
||
public class CommandUsageHandler implements InvalidUsageHandler<CommandSender> { | ||
|
||
|
||
@Override | ||
public void handle(Invocation<CommandSender> invocation, InvalidUsage<CommandSender> result, ResultHandlerChain<CommandSender> chain) { | ||
CommandSender sender = invocation.sender(); | ||
Schematic schematic = result.getSchematic(); | ||
|
||
if (schematic.isOnlyFirst()) { | ||
GeneralMessages.UNKNOWN_COMMAND.send(sender, schematic.first()); | ||
return; | ||
} | ||
|
||
GeneralMessages.UNKNOWN_COMMANDS.send(sender); | ||
schematic.all().forEach(scheme -> sender.sendMessage("§8 # §7" + scheme)); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
api/src/main/java/com/artformgames/core/command/handlers/PermMissedHandler.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,33 @@ | ||
package com.artformgames.core.command.handlers; | ||
|
||
import com.artformgames.core.conf.GeneralMessages; | ||
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; | ||
|
||
public class PermMissedHandler implements MissingPermissionsHandler<CommandSender> { | ||
|
||
@Override | ||
public void handle(Invocation<CommandSender> invocation, | ||
MissingPermissions missingPermissions, ResultHandlerChain<CommandSender> resultHandlerChain) { | ||
CommandSender sender = invocation.sender(); | ||
|
||
GeneralMessages.NO_PERMISSIONS.send(sender); | ||
|
||
if (sender.hasPermission("group.admin")) { | ||
int i = 1; | ||
for (String permission : missingPermissions.getPermissions()) { | ||
if (!sender.hasPermission(permission)) { | ||
GeneralMessages.MISSING_PERMISSION.send(sender); | ||
sender.sendMessage("§8 # §7" + i + ". " + permission); | ||
i++; | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
} |
28 changes: 28 additions & 0 deletions
28
api/src/main/java/com/artformgames/core/conf/GeneralMessages.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,28 @@ | ||
package com.artformgames.core.conf; | ||
|
||
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList; | ||
import net.md_5.bungee.api.chat.BaseComponent; | ||
|
||
public class GeneralMessages extends MessagesRoot { | ||
|
||
public static final ConfiguredMessageList<BaseComponent[]> UNKNOWN_COMMAND = list() | ||
.defaults( | ||
"&c&lUnknown command! &fPlease check your inputs.", | ||
"&8# &fMaybe you want to use &e%(command) &f?" | ||
).params("command").build(); | ||
|
||
public static final ConfiguredMessageList<BaseComponent[]> UNKNOWN_COMMANDS = list() | ||
.defaults( | ||
"&c&lUnknown command! &fPossible commands:" | ||
).build(); | ||
|
||
|
||
public static final ConfiguredMessageList<BaseComponent[]> NO_PERMISSIONS = list() | ||
.defaults("&c&lSorry! &fYou don't have permission to do this.") | ||
.build(); | ||
|
||
public static final ConfiguredMessageList<BaseComponent[]> MISSING_PERMISSION = list() | ||
.defaults("&7Missing permissions: ") | ||
.build(); | ||
|
||
} |
8 changes: 6 additions & 2 deletions
8
plugin/src/main/java/com/artformgames/core/conf/PluginMessages.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,10 @@ | ||
package com.artformgames.core.conf; | ||
|
||
import cc.carm.lib.configuration.core.ConfigurationRoot; | ||
import cc.carm.lib.configuration.core.annotation.ConfigPath; | ||
|
||
public class PluginMessages extends MessagesRoot { | ||
|
||
@ConfigPath(root = true) | ||
public static final Class<?> GENERAL = GeneralMessages.class; | ||
|
||
public class PluginMessages extends ConfigurationRoot { | ||
} |