mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
parent
21f21ed671
commit
cb8efb2d55
@ -1,23 +1,16 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class BackpackCommand extends SubCommand {
|
||||
|
||||
@ -37,7 +30,7 @@ class BackpackCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onExecute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player) || !sender.hasPermission("slimefun.command.backpack")) {
|
||||
if (!(sender instanceof Player) || !(sender.hasPermission("slimefun.command.backpack"))) {
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.no-permission", true);
|
||||
return;
|
||||
}
|
||||
@ -48,12 +41,13 @@ class BackpackCommand extends SubCommand {
|
||||
}
|
||||
|
||||
final Player p = (Player) sender;
|
||||
if (!PatternUtils.NUMERIC.matcher(args[2]).matches()) {
|
||||
final String ownerName = args[1];
|
||||
if (!PatternUtils.NUMERIC.matcher(args[2]).matches()){
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "guide.backpack.invalid-id");
|
||||
return;
|
||||
}
|
||||
final int id = Integer.parseInt(args[2]);
|
||||
final OfflinePlayer owner = Bukkit.getOfflinePlayer(args[1]);
|
||||
final OfflinePlayer owner = Bukkit.getOfflinePlayer(ownerName);
|
||||
if (!owner.hasPlayedBefore()) {
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "guide.backpack.player-never-joined");
|
||||
return;
|
||||
@ -65,13 +59,7 @@ class BackpackCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
Slimefun.runSync(() -> {
|
||||
ItemStack item = SlimefunItems.RESTORED_BACKPACK;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List lore = meta.getLore();
|
||||
lore.set(2, ChatColor.GRAY + "ID: " + profile.getUUID().toString() + "#" + id);
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
p.getInventory().addItem(item);
|
||||
p.getInventory().addItem(SlimefunItems.RESTORED_BACKPACK);
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "guide.backpack.restored-backpack-given");
|
||||
});
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -72,7 +72,7 @@ public final class SlimefunItems {
|
||||
public static final ItemStack RADIANT_BACKPACK = new SlimefunItemStack("RADIANT_BACKPACK", "40cb1e67b512ab2d4bf3d7ace0eaaf61c32cd4681ddc3987ceb326706a33fa", "&eRadiant Backpack", "", "&7Size: &e54 (Double chest)", "&7ID: <ID>", "", "&7&eRight Click&7 to open");
|
||||
public static final SlimefunItemStack BOUND_BACKPACK = new SlimefunItemStack("BOUND_BACKPACK", "2a3b34862b9afb63cf8d5779966d3fba70af82b04e83f3eaf6449aeba", "&cSoulbound Backpack", "", "&7Size: &e36", "&7ID: <ID>", "", "&7&eRight Click&7 to open");
|
||||
public static final SlimefunItemStack COOLER = new SlimefunItemStack("COOLER", "d4c1572584eb5de229de9f5a4f779d0aacbaffd33bcb33eb4536a6a2bc6a1", "&bCooler", "&rAllows you to store Juices/Smoothies", "&rand automatically consumes them when you are hungry", "&rand you have this in your Inventory", "", "&7Size: &e27", "&7ID: <ID>", "", "&7&eRight Click&7 to open");
|
||||
public static final SlimefunItemStack RESTORED_BACKPACK = new SlimefunItemStack("RESTORED_BACKPACK", "40cb1e67b512ab2d4bf3d7ace0eaaf61c32cd4681ddc3987ceb326706a33fa", "&eRestored Backpack", "", "&7Retrieve your lost items", "&7ID: <ID>", "", "&7&eRight Click&7 to open");
|
||||
public static final ItemStack RESTORED_BACKPACK = new SlimefunItemStack("RESTORED_BACKPACK", "40cb1e67b512ab2d4bf3d7ace0eaaf61c32cd4681ddc3987ceb326706a33fa", "&eRestored Backpack", "", "&7Retrieve your lost items", "", "&7&eRight Click&7 to open");
|
||||
|
||||
|
||||
/* Jetpacks */
|
||||
|
Loading…
Reference in New Issue
Block a user