coolnickname

Untitled

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