-
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.
- Loading branch information
Showing
8 changed files
with
137 additions
and
13 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
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
57 changes: 57 additions & 0 deletions
57
src/main/java/dev/twme/debugstickpro/commands/subcommands/console/ConsoleGiveCommand.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 dev.twme.debugstickpro.commands.subcommands.console; | ||
|
||
import dev.twme.debugstickpro.localization.I18n; | ||
import dev.twme.debugstickpro.localization.Lang; | ||
import dev.twme.debugstickpro.playerdata.PlayerDataManager; | ||
import dev.twme.debugstickpro.utils.DebugStickItem; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class ConsoleGiveCommand { | ||
public static boolean onGiveCommand(CommandSender sender, String[] args) { | ||
MiniMessage mm = MiniMessage.miniMessage(); | ||
|
||
if (!sender.hasPermission("debugstickpro.give")) { | ||
Component parsed = mm.deserialize(I18n.string(Lang.CommandsMessages.NoPermission)); | ||
sender.sendMessage(parsed); | ||
return true; | ||
} | ||
|
||
// Directly give the player a debug stick | ||
if (args.length == 1) { | ||
if (!(sender instanceof Player)) { | ||
Component parsed = mm.deserialize(I18n.string(Lang.CommandsMessages.YouAreNotPlayer)); | ||
sender.sendMessage(parsed); | ||
return true; | ||
} | ||
return true; | ||
} | ||
|
||
if (args.length != 2) { | ||
return false; | ||
} | ||
|
||
Player onlinePlayer = Bukkit.getPlayerExact(args[1]); | ||
|
||
// Check if player not exist | ||
if (onlinePlayer == null) { | ||
Component parsed = mm.deserialize(I18n.string(Lang.CommandsMessages.Give.NoPlayer)); | ||
sender.sendMessage(parsed); | ||
return true; | ||
} | ||
|
||
// Give another player a debug stick | ||
onlinePlayer.getInventory().addItem(DebugStickItem.getDebugStickItem()); | ||
Component parsed = mm.deserialize(I18n.string(Lang.CommandsMessages.Give.Success).replace("%player%", onlinePlayer.getName())); | ||
sender.sendMessage(parsed); | ||
|
||
if (DebugStickItem.checkPlayer(onlinePlayer)) { | ||
PlayerDataManager.addPlayerToDisplayList(onlinePlayer.getUniqueId()); | ||
} | ||
|
||
return true; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/dev/twme/debugstickpro/commands/subcommands/console/ConsoleHelpCommand.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,26 @@ | ||
package dev.twme.debugstickpro.commands.subcommands.console; | ||
|
||
import dev.twme.debugstickpro.localization.I18n; | ||
import dev.twme.debugstickpro.localization.Lang; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class ConsoleHelpCommand { | ||
public static boolean onHelpCommand(CommandSender sender, String[] args) { | ||
MiniMessage mm = MiniMessage.miniMessage(); | ||
|
||
if (args.length > 1) { | ||
return false; | ||
} | ||
if (!sender.hasPermission("debugstickpro.help")) { | ||
Component parsed = mm.deserialize(I18n.string(Lang.CommandsMessages.NoPermission)); | ||
sender.sendMessage(parsed); | ||
return true; | ||
} | ||
for (String message : I18n.list(Lang.CommandsMessages.Help.HelpMessage)) { | ||
sender.sendMessage(mm.deserialize(message)); | ||
} | ||
return true; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/dev/twme/debugstickpro/commands/subcommands/console/ConsoleReloadCommand.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,27 @@ | ||
package dev.twme.debugstickpro.commands.subcommands.console; | ||
|
||
import dev.twme.debugstickpro.DebugStickPro; | ||
import dev.twme.debugstickpro.localization.I18n; | ||
import dev.twme.debugstickpro.localization.Lang; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class ConsoleReloadCommand { | ||
public static boolean onReloadCommand(CommandSender sender, String[] args) { | ||
MiniMessage mm = MiniMessage.miniMessage(); | ||
|
||
if (args.length > 1) { | ||
return false; | ||
} | ||
if (!sender.hasPermission("debugstickpro.reload")) { | ||
Component parsed = mm.deserialize(I18n.string(Lang.CommandsMessages.NoPermission)); | ||
sender.sendMessage(parsed); | ||
return true; | ||
} | ||
DebugStickPro.getInstance().onReload(); | ||
Component parsed = mm.deserialize(I18n.string(Lang.CommandsMessages.Reload.Success)); | ||
sender.sendMessage(parsed); | ||
return true; | ||
} | ||
} |
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