mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-30 11:57:43 +01:00
d1732552b0
- Added PreTransactionEvent which can be cancelled - Fixed not placing B/S before prices - Updated Heroes
47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
package com.Acrobot.ChestShop.Plugins;
|
|
|
|
import com.Acrobot.ChestShop.Config.Config;
|
|
import com.Acrobot.ChestShop.Config.Property;
|
|
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
|
|
import com.herocraftonline.heroes.characters.Hero;
|
|
import com.herocraftonline.heroes.characters.classes.HeroClass;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
public class Heroes implements Listener {
|
|
private com.herocraftonline.heroes.Heroes heroes;
|
|
|
|
public Heroes(com.herocraftonline.heroes.Heroes heroes) {
|
|
this.heroes = heroes;
|
|
}
|
|
|
|
@EventHandler
|
|
public void shopCreated(ShopCreatedEvent event) {
|
|
double heroExp = Config.getDouble(Property.HEROES_EXP);
|
|
|
|
if (heroExp == 0) {
|
|
return;
|
|
}
|
|
|
|
Hero hero = heroes.getCharacterManager().getHero(event.getPlayer());
|
|
|
|
if (hero.hasParty()) {
|
|
hero.getParty().gainExp(heroExp, HeroClass.ExperienceType.EXTERNAL, event.getPlayer().getLocation());
|
|
} else {
|
|
hero.gainExp(heroExp, HeroClass.ExperienceType.EXTERNAL, event.getPlayer().getLocation());
|
|
}
|
|
}
|
|
|
|
public static Heroes getHeroes(Plugin plugin) {
|
|
if (!(plugin instanceof com.herocraftonline.heroes.Heroes)) {
|
|
return null;
|
|
}
|
|
|
|
return new Heroes((com.herocraftonline.heroes.Heroes) plugin);
|
|
}
|
|
}
|