Created
December 18, 2019 18:43
-
-
Save eirikh1996/765a30d994e4d13bf63e6dc905787575 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { | |
if (!(src instanceof Player)) { | |
src.sendMessage(Text.of(COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Must be player"))); | |
return CommandResult.empty(); | |
} | |
String arg = args.<String>getOne(Text.of()).get(); | |
final Player player = (Player) src; | |
@NotNull final WorldEditHandler weHandler = StructureBoxes.getInstance().getWorldEditHandler(); | |
@Nullable Clipboard clipboard = weHandler.loadClipboardFromSchematic(StructureBoxes.getInstance().getWorldEditPlugin().getWorld(player.getLocation().getExtent()), arg); | |
if (clipboard == null) { | |
player.sendMessage(Text.of(COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - No schematic"))); | |
return CommandResult.empty(); | |
} | |
if (Settings.MaxStructureSize > -1 && weHandler.getStructureSize(clipboard) > Settings.MaxStructureSize) { | |
player.sendMessage(Text.of(COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Structure too large"))); | |
return CommandResult.empty(); | |
} | |
Inventory emptySlots = player.getInventory().query(QueryOperationTypes.ITEM_TYPE.of(ItemTypes.AIR)); | |
if (emptySlots.size() <= 0) { | |
player.sendMessage(Text.of(COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Insufficient inventory space"))); | |
return CommandResult.empty(); | |
} | |
return CommandResult.success(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment