mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Tweaked, requested changes added
This commit is contained in:
parent
0fc0a0be29
commit
e021fb9ce3
@ -1,21 +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.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 {
|
||||
|
||||
@ -40,37 +35,32 @@ class BackpackCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack <Player> <Number>"));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack <Player> <ID>"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = (Player) sender;
|
||||
String ownerName = args[1];
|
||||
int id = Integer.parseInt(args[2]);
|
||||
OfflinePlayer owner = Bukkit.getPlayer(ownerName);
|
||||
|
||||
if (owner == null) {
|
||||
owner = Bukkit.getOfflinePlayer(ownerName);
|
||||
final Player p = (Player) sender;
|
||||
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(ownerName);
|
||||
if (!owner.hasPlayedBefore()) {
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "guide.backpack.player-never-joined");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerProfile.get(owner, profile -> {
|
||||
if (!profile.getBackpack(id).isPresent()) {
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "guide.backpack.backpack-does-not-exist");
|
||||
return;
|
||||
}
|
||||
PlayerBackpack bp = profile.getBackpack(id).get();
|
||||
//No point switching for size, would still miss soulbound
|
||||
ItemStack item = SlimefunItems.BACKPACK_MEDIUM;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List lore = meta.getLore();
|
||||
lore.set(2, ChatColor.GRAY + "ID: " + profile.getUUID().toString() + "#" + id);
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
Slimefun.runSync(() -> p.getInventory().addItem(item));
|
||||
Slimefun.runSync(() -> {
|
||||
p.getInventory().addItem(SlimefunItems.RESTORED_BACKPACK);
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "guide.backpack.restored-backpack-given");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
public final class Commands {
|
||||
|
||||
private Commands() {}
|
||||
private Commands() {
|
||||
}
|
||||
|
||||
public static void addCommands(SlimefunCommand cmd, Collection<SubCommand> commands) {
|
||||
SlimefunPlugin plugin = cmd.getPlugin();
|
||||
|
@ -0,0 +1,14 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HiddenBackpack extends SlimefunBackpack {
|
||||
|
||||
public HiddenBackpack(Category category, SlimefunItemStack item) {
|
||||
super(1, category, item, RecipeType.NULL, new ItemStack[9]);
|
||||
this.hidden = true;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.setup;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.HiddenBackpack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
@ -1202,6 +1203,8 @@ public final class SlimefunItemSetup {
|
||||
new ItemStack[] {SlimefunItems.GOLD_24K, null, SlimefunItems.GOLD_24K, new ItemStack(Material.LEATHER), SlimefunItems.GILDED_BACKPACK, new ItemStack(Material.LEATHER), SlimefunItems.GOLD_24K, null, SlimefunItems.GOLD_24K})
|
||||
.register(plugin);
|
||||
|
||||
new HiddenBackpack(categories.usefulItems, (SlimefunItemStack) SlimefunItems.RESTORED_BACKPACK).register(plugin);
|
||||
|
||||
new SlimefunItem(categories.technicalComponents, (SlimefunItemStack) SlimefunItems.MAGNET, RecipeType.SMELTERY,
|
||||
new ItemStack[] {SlimefunItems.NICKEL_INGOT, SlimefunItems.ALUMINUM_DUST, SlimefunItems.IRON_DUST, SlimefunItems.COBALT_INGOT, null, null, null, null, null})
|
||||
.register(plugin);
|
||||
|
@ -72,6 +72,8 @@ 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 ItemStack RESTORED_BACKPACK = new SlimefunItemStack("RESTORED_BACKPACK", "40cb1e67b512ab2d4bf3d7ace0eaaf61c32cd4681ddc3987ceb326706a33fa", "&eRestored Backpack", "", "&7Retrieve your lost items", "", "&7&eRight Click&7 to open");
|
||||
|
||||
|
||||
/* Jetpacks */
|
||||
public static final SlimefunItemStack DURALUMIN_JETPACK = new SlimefunItemStack("DURALUMIN_JETPACK", Material.LEATHER_CHESTPLATE, Color.SILVER, "&9Electric Jetpack &7- &eI", "", "&8\u21E8 &7Material: &bDuralumin", "&c&o&8\u21E8 &e\u26A1 &70 / 20 J", "&8\u21E8 &7Thrust: &c0.35", "", "&7Hold &eShift&7 to use");
|
||||
|
@ -45,8 +45,10 @@ guide:
|
||||
no-multiblocks: '&4You cannot cheat in Multiblocks, you have to build them!'
|
||||
|
||||
backpack:
|
||||
invalid-id: '&4The id must be a non-negative integer!'
|
||||
player-never-joined: '&4No player with that name has ever joined the server!'
|
||||
backpack-does-not-exist: '&4That backpack does not exist!'
|
||||
restored-backpack-given: 'Backpack restored successfully! Added to your inventory!'
|
||||
|
||||
pages:
|
||||
previous: 'Previous page'
|
||||
|
Loading…
Reference in New Issue
Block a user