Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "cloud.cloudie"
version = "0.3.5"
version = "0.3.6"

repositories {
mavenCentral()
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/cloud/cloudie/cloudsystem/CloudSystem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cloud.cloudie.cloudsystem;

import cloud.cloudie.cloudsystem.commands.FlyCommand;
import cloud.cloudie.cloudsystem.commands.GiveCommand;
import cloud.cloudie.cloudsystem.commands.PissCommand;
import cloud.cloudie.cloudsystem.commands.ReskinCommand;
import cloud.cloudie.cloudsystem.commands.RulesGUICommand;
Expand All @@ -14,9 +15,11 @@
import cloud.cloudie.cloudsystem.util.UpdateChecker;
import co.aikar.commands.PaperCommandManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.Material;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -40,10 +43,10 @@ public void onEnable() {
getLogger().info("|---[ CloudieSMP ]---------------------------------------|");
getLogger().info("| |");

commandCompletions();
registerClasses();
registerCommands();
registerEvents();
commandCompletions();

getLogger().info("| |");
getLogger().info("|-----------------------------[ ENABLED SUCCESSFULLY ]---|");
Expand All @@ -57,6 +60,7 @@ void registerCommands(){
manager.registerCommand(new ReskinCommand());
manager.registerCommand(new PissCommand());
manager.registerCommand(new RulesGUICommand());
manager.registerCommand(new GiveCommand());

//if renameCommands are enabled
if(getConfig().getBoolean("ShortenCommands")){
Expand Down Expand Up @@ -85,6 +89,10 @@ void commandCompletions(){
List<String> skins = getConfig().getStringList("skins");
return ImmutableList.copyOf(skins);
});

manager.getCommandCompletions().registerCompletion("Items", context -> Arrays.stream(Material.values())
.map(Material::name)
.toList());
}

@Override
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/cloud/cloudie/cloudsystem/commands/GiveCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package cloud.cloudie.cloudsystem.commands;

import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Optional;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

@CommandAlias("i")
@CommandPermission("system.admin.give")
public class GiveCommand extends BaseCommand {

@Default
@CommandCompletion("@Items @range:1-64 @Players")
public void onGiveCommand(CommandSender sender, String targetItem, @Optional Integer amount, @Optional String targetName) {
// Ensure sender is a player
if (!(sender instanceof Player player)) {
sender.sendMessage(Component.text("Only players can give items.")
.color(TextColor.fromHexString("#FF5555")));
return;
}

// Set amount (default to 1 if not provided)
int itemAmount = (amount != null) ? Math.max(1, Math.min(amount, 64)) : 1; // Ensure it's between 1-64

// Determine the target player
Player target = (targetName != null) ? Bukkit.getPlayerExact(targetName) : player;
if (target == null) {
sender.sendMessage(Component.text("Player not found.")
.color(TextColor.fromHexString("#FF5555")));
return;
}

// Check if item exists
Material material = Material.matchMaterial(targetItem);
if (material == null) {
sender.sendMessage(Component.text("Invalid item name: " + targetItem)
.color(TextColor.fromHexString("#FF5555")));
return;
}

// Give the item
ItemStack item = new ItemStack(material, itemAmount);
target.getInventory().addItem(item);

sender.sendMessage(Component.text("Gave " + itemAmount + "x " + material.name() + " to " + target.getName() + ".")
.color(TextColor.fromHexString("#55FF55"))); }
}
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
messages:
welcome: "Welcome to Cloudie SMP S9, {player}!"
welcome: "Welcome to CloudSystem, {player}!"
skins:
- cat_ears
- dog_ears
Expand Down