use of net.aufdemrand.denizen.scripts.containers.core.BookScriptContainer in project Denizen-For-Bukkit by DenizenScript.
the class ScribeCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Retrieve objects from ScriptEntry
BookAction action = (BookAction) scriptEntry.getObject("action");
dItem book = (dItem) scriptEntry.getObject("item");
dScript script = (dScript) scriptEntry.getObject("script");
dLocation location = (dLocation) scriptEntry.getObject("location");
BookScriptContainer bookScript = (BookScriptContainer) script.getContainer();
book = bookScript.writeBookTo(book, ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer(), ((BukkitScriptEntryData) scriptEntry.entryData).getNPC());
// Post-write action? Can be NONE.
switch(action) {
case DROP:
dropBook(location, book.getItemStack());
break;
case GIVE:
giveBook(((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getPlayerEntity(), book.getItemStack());
// Update player's inventory
((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getPlayerEntity().updateInventory();
break;
case EQUIP:
equipBook(((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getPlayerEntity(), book.getItemStack());
// Update player's inventory
((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getPlayerEntity().updateInventory();
break;
case NONE:
break;
}
}
Aggregations