tweaks724/src/main/java/eu/m724/tweaks/redstone/RedstoneCommands.java
Minecon724 dde8700248
All checks were successful
/ build (push) Successful in 1m1s
redstone WIP
2024-12-29 18:40:56 +01:00

52 lines
1.7 KiB
Java

/*
* Copyright (C) 2024 Minecon724
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
* in the project root for the full license text.
*/
package eu.m724.tweaks.redstone;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class RedstoneCommands implements CommandExecutor {
private final RedstoneRepeaters redstoneRepeaters;
public RedstoneCommands(RedstoneRepeaters redstoneRepeaters) {
this.redstoneRepeaters = redstoneRepeaters;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (args.length > 0) {
if (args[0].equals("give")) {
Player player = null;
if (args.length > 1) {
player = Bukkit.getPlayerExact(args[1]);
if (player == null) {
sender.sendMessage("No player named " + args[1]);
return true;
}
} else {
if (sender instanceof Player) {
player = (Player) sender;
} else {
sender.sendMessage("Specify a player to give to, or be a player");
}
}
var itemStack = redstoneRepeaters.give();
player.getInventory().addItem(itemStack);
}
} else {
sender.sendMessage("Argument needed");
}
return true;
}
}