MyPet - Wiki
WebsiteDownloadSpigotDiscord
3.0
3.0
  • MyPet - Wiki
  • MyPet 3.0
  • Setup
    • Update to 3.0
    • Permissions
    • Commands
    • Configurations
      • config.yml
      • pet-config.yml
      • pet-shops.yml
      • hooks-config.yml
      • exp-config.yml
      • worldgroups.yml
      • Custom-Item-Data in Config
  • Systems
    • Translation
    • Leash Flags / Requirements
    • Skilltrees
      • Skilltree Requirements
      • SkilltreeCreator - Tool
    • Experience
      • Experience-Script
    • Pet Storage
    • Hunger-System
    • World Groups
    • Auto Updater
  • Skill Overview
    • Backpack
    • Beacon
    • Behavior
    • Control
    • Damage
    • Fire
    • Heal
    • Knockback
    • Life
    • Lightning
    • Pickup
    • Poison
    • Slow
    • Ranged
    • Ride
    • Shield
    • Sprint
    • Stomp
    • Thorns
    • Wither
  • Tutorials
    • How to get a pet
    • File to MySQL
    • File to MongoDB
  • Plugin-Hooks
    • Hook Types
    • Citizens NPC
    • WG Region Flags
    • PlaceholderAPI
    • BossShopPro
  • Default Settings
    • Pet-Config
  • Misc
    • MyPet-Premium
    • Is MyPet EULA compliant?
    • FAQ
    • Changelog
Powered by GitBook
On this page
  • Installation
  • Script
  • Differentiating between pet types and world groups
  • Debugging
  • Example

Was this helpful?

  1. Systems
  2. Experience

Experience-Script

PreviousExperienceNextPet Storage

Last updated 1 year ago

Was this helpful?

With the Experience-Script exp.js it's possible to customize when a pet will level up. As you can see at the file ending, the used language is JavaScript.

Installation

  1. Download , rename the jar to rhino.jar and put the file into the MyPet folder.

  2. Set LevelSystem.CalculationMode to JavaScript int the config.yml.

  3. Edit the exp.js to your likings.

Script

To make a fully functional exp-script that can be used by MyPet you have to implement the following method:

exp.js
function getExpByLevel(level, petType, worldGroup) {
  var exp = 0;
  return exp;
}

Differentiating between pet types and world groups

Examples:

exp.js
function getExpByLevel(level, petType, worldGroup) {
  var exp = 10;
  if(petType == "Cow") {
    exp = 15;
  }
  return exp;
}
exp.js
function getExpByLevel(level, petType, worldGroup) {
  var exp = 10;
  if(worldGroup == "LuckyWorlds") {
    exp = 20;
  }
  return exp;
}

Debugging

To provide an easy method to debug your scripts the plugin adds a print method to the usable JavaScript functions.

print("message");

Example

exp.js
//  Level 2-17 cost 17 XP points each
//  Level 18-31 cost 3 more XP points than the previous
//  Level 32-∞ cost 7 more XP points than the previous

function getExpByLevel(level, petType, worldGroup) {
    var exp = 0, i;
    if (level > 31) {
        exp = 887;
        level -= 31;
        for (i = 1; i < level; i++) {
            exp += 62 + (i * 7);
        }
        return exp;
    }
    if (level > 17) {
        exp = 272;
        level -= 17;
        for (i = 1; i <= level; i++) {
            exp += 17 + (i * 3);
        }
        return exp;
    }
    return (level - 1) * 17;
}
Rhino