2017-03-31 23:30:41 +02:00
|
|
|
package tc.oc.pgm.mutation.types.kit;
|
|
|
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import tc.oc.pgm.gamerules.GameRulesMatchModule;
|
|
|
|
import tc.oc.pgm.killreward.KillReward;
|
|
|
|
import tc.oc.pgm.kits.FreeItemKit;
|
|
|
|
import tc.oc.pgm.kits.ItemKit;
|
|
|
|
import tc.oc.pgm.match.Match;
|
|
|
|
import tc.oc.pgm.mutation.types.KitMutation;
|
|
|
|
import tc.oc.pgm.shield.ShieldKit;
|
|
|
|
import tc.oc.pgm.shield.ShieldParameters;
|
|
|
|
|
|
|
|
public class HardcoreMutation extends KitMutation {
|
|
|
|
|
|
|
|
final static String KEY = "naturalRegeneration";
|
|
|
|
final static ShieldKit SHIELD = new ShieldKit(new ShieldParameters());
|
|
|
|
final static ItemKit APPLE = new FreeItemKit(item(Material.GOLDEN_APPLE));
|
|
|
|
|
|
|
|
String previous; // Stores the previous game rule setting
|
|
|
|
|
|
|
|
public HardcoreMutation(Match match) {
|
|
|
|
super(match, false);
|
|
|
|
this.kits.add(SHIELD);
|
|
|
|
this.rewards.add(new KillReward(APPLE));
|
|
|
|
}
|
|
|
|
|
|
|
|
public GameRulesMatchModule rules() {
|
2017-04-03 04:09:35 +02:00
|
|
|
return match().module(GameRulesMatchModule.class).get();
|
2017-03-31 23:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void enable() {
|
|
|
|
super.enable();
|
2017-04-03 04:09:35 +02:00
|
|
|
previous = world().getGameRuleValue(KEY);
|
2017-03-31 23:30:41 +02:00
|
|
|
rules().gameRules().put(KEY, "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void disable() {
|
|
|
|
rules().gameRules().remove(KEY);
|
|
|
|
if(previous != null) {
|
2017-04-03 04:09:35 +02:00
|
|
|
world().setGameRuleValue(KEY, previous);
|
2017-03-31 23:30:41 +02:00
|
|
|
}
|
|
|
|
super.disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|