feat: add config option to disable FastRegen

This commit is contained in:
Simon Giesel 2020-05-11 22:54:22 +02:00
parent 507b858587
commit 037f0641cc
2 changed files with 15 additions and 4 deletions

View file

@ -50,8 +50,9 @@ public class Varo extends JavaPlugin {
this.banUtils = new BanUtils(this); this.banUtils = new BanUtils(this);
this.varoUtils = new VaroUtils(this); this.varoUtils = new VaroUtils(this);
// this.config.addDefault("Varo.Start", "TODO: StartDate"); this.config.addDefault("Varo.Start", "25.05.2020");
this.config.addDefault("Varo.Debug", false); this.config.addDefault("Varo.Debug", false);
this.config.addDefault("Varo.RetroHealthRegen", false);
this.config.addDefault("Varo.Bans", new ArrayList<String>()); this.config.addDefault("Varo.Bans", new ArrayList<String>());
this.config.options().copyDefaults(true); this.config.options().copyDefaults(true);
this.saveConfig(); this.saveConfig();
@ -61,7 +62,7 @@ public class Varo extends JavaPlugin {
this.getServer().getPluginManager().registerEvents(new PlayerClientOptionsChangeListener(this), this); this.getServer().getPluginManager().registerEvents(new PlayerClientOptionsChangeListener(this), this);
this.getServer().getPluginManager().registerEvents(new PlayerResourcePackStatusListener(), this); this.getServer().getPluginManager().registerEvents(new PlayerResourcePackStatusListener(), this);
this.getServer().getPluginManager().registerEvents(new ChatListener(), this); this.getServer().getPluginManager().registerEvents(new ChatListener(), this);
this.getServer().getPluginManager().registerEvents(new EntityRegainHealthListener(), this); this.getServer().getPluginManager().registerEvents(new EntityRegainHealthListener(this), this);
this.getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this); this.getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
this.getServer().getPluginManager().registerEvents(new BannedItemListener(), this); this.getServer().getPluginManager().registerEvents(new BannedItemListener(), this);
this.getServer().getPluginManager().registerEvents(new BannedActionListener(this), this); this.getServer().getPluginManager().registerEvents(new BannedActionListener(this), this);

View file

@ -5,14 +5,24 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import de.cliffbreak.varo.Varo;
public class EntityRegainHealthListener implements Listener { public class EntityRegainHealthListener implements Listener {
private final Varo plugin;
public EntityRegainHealthListener(final Varo plugin) {
this.plugin = plugin;
}
@EventHandler @EventHandler
public void onEntityRegainHealth(final EntityRegainHealthEvent e) { public void onEntityRegainHealth(final EntityRegainHealthEvent e) {
if (e.getEntity() instanceof Player) { if (e.getEntity() instanceof Player) {
if (this.plugin.getConfig().getBoolean("Varo.RetroHealthRegen")) {
if (e.isFastRegen()) { if (e.isFastRegen()) {
e.setAmount(0.13d); e.setAmount(0.13d);
} }
} }
} }
}
} }