Made zombies drop $1

This commit is contained in:
alisolarflare 2016-12-08 21:34:32 -05:00
parent ba8ad22889
commit 8bad0a97f4
3 changed files with 61 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.components.alilinks.AliLinkComponent; import alisolarflare.components.alilinks.AliLinkComponent;
import alisolarflare.components.bankchest.BankChestComponent; import alisolarflare.components.bankchest.BankChestComponent;
import alisolarflare.components.cashmob.CashMobComponent;
import alisolarflare.components.creativeboundaries.CreativeBoundariesComponent; import alisolarflare.components.creativeboundaries.CreativeBoundariesComponent;
import alisolarflare.components.flaircolouring.FlairColouringComponent; import alisolarflare.components.flaircolouring.FlairColouringComponent;
import alisolarflare.components.gpowers.GPowerComponent; import alisolarflare.components.gpowers.GPowerComponent;
@ -25,6 +26,7 @@ public class AliPresents extends JavaPlugin{
new AliLinkComponent().register(this); new AliLinkComponent().register(this);
new BankChestComponent().register(this); new BankChestComponent().register(this);
new CashMobComponent().register(this);
new CreativeBoundariesComponent().register(this); new CreativeBoundariesComponent().register(this);
new FlairColouringComponent().register(this); new FlairColouringComponent().register(this);
new GPowerComponent().register(this); new GPowerComponent().register(this);

View file

@ -0,0 +1,18 @@
package alisolarflare.components.cashmob;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import com.earth2me.essentials.Essentials;
import alisolarflare.architecture.Component;
public class CashMobComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
registerListener(plugin, new MobKillListener((Essentials) Bukkit.getPluginManager().getPlugin("Essentials")));
}
}

View file

@ -0,0 +1,41 @@
package alisolarflare.components.cashmob;
import java.math.BigDecimal;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import net.ess3.api.MaxMoneyException;
public class MobKillListener implements Listener {
private Essentials essentials;
public MobKillListener(Essentials essentials) {
this.essentials = essentials;
}
@EventHandler
public void onMobKill(EntityDeathEvent event){
Player killer;
if ((killer = event.getEntity().getKiller()) == null){
return;
}
User user = essentials.getUser(killer);
switch(event.getEntity().getType()){
case ZOMBIE:
try {
user.giveMoney(BigDecimal.ONE);
} catch (MaxMoneyException e) {
return;
}
default:
return;
}
}
}