mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-27 04:55:25 +01:00
Remove health strategies.
This commit is contained in:
parent
41e910ad69
commit
93798a3e51
@ -1,7 +1,7 @@
|
||||
name: MobArena
|
||||
author: garbagemule
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.95.5.37
|
||||
version: 0.95.5.38
|
||||
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
|
||||
commands:
|
||||
ma:
|
||||
|
@ -15,7 +15,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -1029,7 +1028,7 @@ public class ArenaImpl implements Arena
|
||||
}
|
||||
|
||||
private void setHealth(Player p, double health) {
|
||||
plugin.getHealthStrategy().setHealth(p, health);
|
||||
p.setHealth(health);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,9 +23,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import com.garbagemule.MobArena.commands.CommandHandler;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
import com.garbagemule.MobArena.health.HealthStrategy;
|
||||
import com.garbagemule.MobArena.health.HealthStrategyHeroes;
|
||||
import com.garbagemule.MobArena.health.HealthStrategyStandard;
|
||||
import com.garbagemule.MobArena.listeners.MAGlobalListener;
|
||||
import com.garbagemule.MobArena.listeners.MagicSpellsListener;
|
||||
import com.garbagemule.MobArena.metrics.Metrics;
|
||||
@ -46,10 +43,6 @@ public class MobArena extends JavaPlugin
|
||||
// Inventories from disconnects
|
||||
private Set<String> inventoriesToRestore;
|
||||
|
||||
// Heroes
|
||||
private boolean hasHeroes;
|
||||
private HealthStrategy healthStrategy;
|
||||
|
||||
// Vault
|
||||
private Economy economy;
|
||||
|
||||
@ -69,9 +62,7 @@ public class MobArena extends JavaPlugin
|
||||
|
||||
// Set up soft dependencies
|
||||
setupVault();
|
||||
setupHeroes();
|
||||
setupMagicSpells();
|
||||
setupStrategies();
|
||||
|
||||
// Set up the ArenaMaster
|
||||
arenaMaster = new ArenaMasterImpl(this);
|
||||
@ -180,14 +171,6 @@ public class MobArena extends JavaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void setupHeroes() {
|
||||
Plugin heroesPlugin = this.getServer().getPluginManager().getPlugin("Heroes");
|
||||
if (heroesPlugin == null) return;
|
||||
|
||||
Messenger.info("Heroes found; using different health strategy.");
|
||||
hasHeroes = true;
|
||||
}
|
||||
|
||||
private void setupMagicSpells() {
|
||||
Plugin spells = this.getServer().getPluginManager().getPlugin("MagicSpells");
|
||||
if (spells == null) return;
|
||||
@ -196,10 +179,6 @@ public class MobArena extends JavaPlugin
|
||||
this.getServer().getPluginManager().registerEvents(new MagicSpellsListener(this), this);
|
||||
}
|
||||
|
||||
private void setupStrategies() {
|
||||
healthStrategy = (hasHeroes ? new HealthStrategyHeroes() : new HealthStrategyStandard());
|
||||
}
|
||||
|
||||
private void loadAbilities() {
|
||||
File dir = new File(this.getDataFolder(), "abilities");
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
@ -217,10 +196,6 @@ public class MobArena extends JavaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public HealthStrategy getHealthStrategy() {
|
||||
return healthStrategy;
|
||||
}
|
||||
|
||||
public ArenaMaster getArenaMaster() {
|
||||
return arenaMaster;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package com.garbagemule.MobArena.health;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface HealthStrategy
|
||||
{
|
||||
/**
|
||||
* Set the health of a player.
|
||||
* @param p a player
|
||||
* @param health amount of health
|
||||
*/
|
||||
public void setHealth(Player p, double health);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.garbagemule.MobArena.health;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
|
||||
public class HealthStrategyHeroes implements HealthStrategy
|
||||
{
|
||||
@Override
|
||||
public void setHealth(Player p, double health) {
|
||||
double current = p.getHealth();
|
||||
double regain = health == p.getMaxHealth() ? p.getMaxHealth() : health - current;
|
||||
|
||||
try {
|
||||
EntityRegainHealthEvent event = new EntityRegainHealthEvent(p, regain, RegainReason.CUSTOM);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
catch (Exception e) {} // Because Bukkit is retarded.
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.garbagemule.MobArena.health;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class HealthStrategyStandard implements HealthStrategy
|
||||
{
|
||||
@Override
|
||||
public void setHealth(Player p, double health) {
|
||||
p.setHealth(health);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user