SHARE
TWEET

Untitled

a guest Aug 13th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package net.xyp.wurmunlimited.mods.bindscroll;
  2.  
  3. import org.gotti.wurmunlimited.modloader.interfaces.WurmServerMod;
  4. import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
  5. import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
  6. import org.gotti.wurmunlimited.modsupport.actions.ModAction;
  7. import org.gotti.wurmunlimited.modsupport.actions.ModActions;
  8.  
  9. import com.wurmonline.server.Items;
  10. import com.wurmonline.server.MiscConstants;
  11. import com.wurmonline.server.behaviours.Action;
  12. import com.wurmonline.server.behaviours.ActionEntry;
  13. import com.wurmonline.server.creatures.Creature;
  14. import com.wurmonline.server.items.Item;
  15. import com.wurmonline.server.items.ItemTypes;
  16. import com.wurmonline.server.players.Player;
  17.  
  18. import java.util.List;
  19. import java.util.Arrays;
  20.  
  21. public class ScrollOfBindingAction implements WurmServerMod, ItemTypes, MiscConstants, ModAction, BehaviourProvider, ActionPerformer {
  22.  
  23.     static short actionId;
  24.     static ActionEntry actionEntry;
  25.  
  26.     public ScrollOfBindingAction() {
  27.         actionId = (short) ModActions.getNextActionId();
  28.         actionEntry = ActionEntry.createEntry(actionId, "Bind", "Binding", new int[]{
  29.                 });
  30.         ModActions.registerAction(actionEntry);
  31.     }
  32.  
  33.     @Override
  34.     public BehaviourProvider getBehaviourProvider() {
  35.         return this;
  36.     }
  37.  
  38.     @Override
  39.     public ActionPerformer getActionPerformer() {
  40.         return this;
  41.     }
  42.  
  43.     @Override
  44.     public short getActionId() {
  45.         return actionId;
  46.     }
  47.    
  48.     @Override
  49.     public List<ActionEntry> getBehavioursFor(Creature performer, Item source, Item target) {
  50.         int itemUsed = source.getTemplateId();
  51.         boolean checkArmour = target.isArmour();
  52.         boolean checkWeapon = target.isWeapon();
  53.         boolean checkTool = target.isTool();
  54.         boolean checkShield = target.isShield();
  55.         boolean checkBow = target.isWeaponBow();
  56.         if (performer instanceof Player) {
  57.             if (itemUsed == 4021) {
  58.                 if (checkArmour ||checkWeapon || checkTool || checkShield || checkBow) {
  59.                 return (List<ActionEntry>) Arrays.asList(actionEntry);
  60.                 } else {
  61.                     return null;
  62.                 }
  63.             } else {
  64.                 return null;
  65.             }
  66.         } else {
  67.             return null;
  68.         }
  69.     }
  70.    
  71.     @Override
  72.     public boolean action(Action act, Creature performer, Item source, Item target, short action, float counter) {
  73.         try {
  74.             target.setIsIndestructible(true);
  75.             target.setIsNoDrop(true);
  76.             target.setHasNoDecay(true);
  77.             performer.getCommunicator().sendNormalServerMessage("The scroll evaporates and your item is now indestructable and can not be dropped!");
  78.             Items.destroyItem(source.getWurmId());
  79.             target.savePermissions();
  80.             return true;
  81.         } catch (Exception e) {
  82.             return false;
  83.         }
  84.     }
  85. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top