Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.emalios.saoplugin.commands;
- import org.spongepowered.api.command.CommandException;
- import org.spongepowered.api.command.CommandResult;
- import org.spongepowered.api.command.CommandSource;
- import org.spongepowered.api.command.args.CommandContext;
- import org.spongepowered.api.command.spec.CommandExecutor;
- import org.spongepowered.api.data.DataContainer;
- import org.spongepowered.api.data.DataQuery;
- import org.spongepowered.api.data.type.HandTypes;
- import org.spongepowered.api.entity.living.player.Player;
- import org.spongepowered.api.item.inventory.ItemStack;
- import static fr.emalios.saoplugin.commands.AddTag.containers;
- public class SetTag implements CommandExecutor {
- @Override
- public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
- if(src instanceof Player)
- {
- Player player = (Player) src;
- player.getItemInHand(HandTypes.MAIN_HAND).ifPresent(itemStack -> {
- if(containers == null)
- {
- System.out.println("NULL");
- }
- DataContainer c = itemStack.toContainer();
- c.set(DataQuery.of("UnsafeData","AttributeModifiers"),containers);
- ItemStack modifiedItem = ItemStack.builder().fromContainer(c).build();
- player.setItemInHand(HandTypes.MAIN_HAND, modifiedItem);
- });
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement