coolnickname

Untitled

Jul 14th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. var tier = 0;
  2. var msgArray = [];
  3.  
  4. var allowedItems = {"mf:pickaxeiron":2,"mf:oreiron":50,"mf:oregold":50,"mf:emeraldrough":50}
  5. var demosellmargin = 1.45
  6. var buymargin = 0.8
  7. var currentlyLooking = undefined;
  8.  
  9. say(npc, "I am a very cool duck! >:I");
  10.  
  11. function openAdvancedShop(chatter, msg){
  12. currentlyLooking = chatter.getUniqueId();
  13. tier = lib.Reputation.getReputationTier(chatter, "Elpida");
  14.  
  15.  
  16. var data = lib.shop.gui.SimpleShopData.of(
  17. lib.shop.provider.DBNPCBalance,
  18. makeSellPrice,
  19. makeBuyPrice,
  20. lib.shop.provider.defaultOnMoneyAction,
  21. npc);
  22.  
  23. lib.shop.gui.openShopGUI(chatter, data, traits.mfplayerinventorytrait);
  24. }
  25.  
  26.  
  27.  
  28. function getText(a){
  29. return a[Math.floor(Math.random()*a.length)];
  30. }
  31.  
  32. function onoff(chatter){
  33. if (chatter.getUniqueId() == currentlyLooking)
  34. currentlyLooking = undefined;
  35. }
  36.  
  37. function makeSellPrice(npc, itemstack){
  38. if (!(itemstack.getItem().getName() in allowedItems))
  39. return -1;
  40. return ( getPrice(itemstack)*makeSellMargin()).intValue();
  41. }
  42.  
  43. function makeBuyPrice(npc, itemstack){
  44. if (!(itemstack.getItem().getName() in allowedItems))
  45. return -1;
  46. var inv = npc.getTrait(Java.type("com.minecraftfrontiers.mfnpc.traits.inventory.MFPlayerInventoryTrait").class);
  47. if (inv.getAmount(itemstack.getItem().getName())+itemstack.getAmount() >= allowedItems[itemstack.getItem().getName()])
  48. return -1;
  49.  
  50. return (getPrice(itemstack)*buymargin).intValue();
  51. }
  52.  
  53. function getPrice(itemstack){
  54. var r = lib.meta.getValue(itemstack.getItem().getName());
  55. return r <= 0?-1 : r;
  56. }
  57.  
  58. function makeSellMargin(){
  59. var marg_output = demosellmargin - 0.05 * tier;
  60. return marg_output;
  61. }
  62.  
  63. function onchat(chatter, msg) {
  64. tier = lib.Reputation.getReputationTier(chatter, "Elpida");
  65. msgArray = msg.split(" ");
  66. var tempmsg = undefined;
  67. if(msgArray[0].indexOf("rawr") > -1 ){
  68. tempmsg = "Your rep level is " + tier;
  69. say(npc, tempmsg.toString());
  70. tempmsg = "Your sell margin is " + makeSellMargin();
  71. say(npc, tempmsg.toString());
  72. openAdvancedShop(chatter);
  73. }else if(msgArray[0].indexOf("points") > -1){
  74. lib.Reputation.addReputationAndNotify(chatter, "Elpida", msgArray[1]);
  75. tempmsg = "Modified " + msgArray[1] + " rep points";
  76. say(npc, tempmsg.toString());
  77. }
  78. }
Add Comment
Please, Sign In to add comment