public void onUse(Player player) { ItemBehavior ib = ScriptManager.instance().getItemBehavior(behavior); if (ib != null) { try { ib.onUse(player, this); } catch (Exception e) { log.log(Level.SEVERE, "Exception in onUse: " + e.getMessage(), e); } } }
public void setBehavior(String behavior) { this.behavior = behavior; ItemBehavior ib = ScriptManager.instance().getItemBehavior(behavior); if (ib != null) { try { ib.onBehaviorChange(this); } catch (Exception e) { log.log(Level.SEVERE, "Script error in onBehaviorSet: " + e.getMessage(), e); } } }
@Override public void onLoad() { ItemBehavior ib = ScriptManager.instance().getItemBehavior(behavior); if (ib != null) { try { ib.onLoad(this); } catch (Exception e) { log.log(Level.SEVERE, "Script error in onLoad: " + e.getMessage(), e); } } }
public Item(long serial, int graphic, String behavior) { super(serial); this.graphic = graphic; // might be overridden by onCreate this.behavior = behavior; ItemBehavior ib = ScriptManager.instance().getItemBehavior(behavior); if (ib == null) { throw new UnsupportedOperationException("invalid behavior"); } else { try { ib.onCreate(this); } catch (Exception e) { log.log(Level.SEVERE, "Script error in onCreate: " + e.getMessage(), e); delete(); } } setBasicAttributes(); }