mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Abstraction is good.
This commit is contained in:
parent
c1463c3257
commit
607d2b8bd7
31
src/main/java/com/gmail/nossr50/skills/SkillManager.java
Normal file
31
src/main/java/com/gmail/nossr50/skills/SkillManager.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
|
public abstract class SkillManager {
|
||||||
|
protected Player player;
|
||||||
|
protected PlayerProfile profile;
|
||||||
|
protected int skillLevel;
|
||||||
|
|
||||||
|
public SkillManager(Player player, SkillType skill) {
|
||||||
|
this.player = player;
|
||||||
|
this.profile = Users.getProfile(player);
|
||||||
|
this.skillLevel = profile.getSkillLevel(skill);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerProfile getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSkillLevel() {
|
||||||
|
return skillLevel;
|
||||||
|
}
|
||||||
|
}
|
@ -4,23 +4,16 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class AcrobaticsManager {
|
public class AcrobaticsManager extends SkillManager {
|
||||||
private static Config config = Config.getInstance();
|
private static Config config = Config.getInstance();
|
||||||
|
|
||||||
private Player player;
|
|
||||||
private PlayerProfile profile;
|
|
||||||
private int skillLevel;
|
|
||||||
|
|
||||||
public AcrobaticsManager (Player player) {
|
public AcrobaticsManager (Player player) {
|
||||||
this.player = player;
|
super(player, SkillType.ACROBATICS);
|
||||||
this.profile = Users.getProfile(player);
|
|
||||||
this.skillLevel = profile.getSkillLevel(SkillType.ACROBATICS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,16 +81,4 @@ public class AcrobaticsManager {
|
|||||||
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
|
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PlayerProfile getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getSkillLevel() {
|
|
||||||
return skillLevel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,14 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class ArcheryManager {
|
|
||||||
private Player player;
|
|
||||||
private PlayerProfile profile;
|
|
||||||
private int skillLevel;
|
|
||||||
|
|
||||||
|
public class ArcheryManager extends SkillManager {
|
||||||
public ArcheryManager (Player player) {
|
public ArcheryManager (Player player) {
|
||||||
this.player = player;
|
super(player, SkillType.ARCHERY);
|
||||||
this.profile = Users.getProfile(player);
|
|
||||||
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,12 +81,4 @@ public class ArcheryManager {
|
|||||||
eventHandler.modifyEventDamage();
|
eventHandler.modifyEventDamage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSkillLevel() {
|
|
||||||
return skillLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,14 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class MiningManager {
|
|
||||||
private Player player;
|
|
||||||
private PlayerProfile profile;
|
|
||||||
private int skillLevel;
|
|
||||||
|
|
||||||
|
public class MiningManager extends SkillManager{
|
||||||
public MiningManager (Player player) {
|
public MiningManager (Player player) {
|
||||||
this.player = player;
|
super(player, SkillType.MINING);
|
||||||
this.profile = Users.getProfile(player);
|
|
||||||
|
|
||||||
this.skillLevel = profile.getSkillLevel(SkillType.MINING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,16 +166,4 @@ public class MiningManager {
|
|||||||
eventHandler.processDropsAndXP();
|
eventHandler.processDropsAndXP();
|
||||||
eventHandler.playSpoutSound();
|
eventHandler.playSpoutSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSkillLevel() {
|
|
||||||
return skillLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PlayerProfile getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,15 @@ package com.gmail.nossr50.skills.swords;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Combat;
|
import com.gmail.nossr50.util.Combat;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class SwordsManager {
|
|
||||||
private Player player;
|
|
||||||
private PlayerProfile profile;
|
|
||||||
private int skillLevel;
|
|
||||||
|
|
||||||
|
public class SwordsManager extends SkillManager {
|
||||||
public SwordsManager (Player player) {
|
public SwordsManager (Player player) {
|
||||||
this.player = player;
|
super(player, SkillType.SWORDS);
|
||||||
this.profile = Users.getProfile(player);
|
|
||||||
this.skillLevel = profile.getSkillLevel(SkillType.SWORDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,12 +87,4 @@ public class SwordsManager {
|
|||||||
|
|
||||||
eventHandler.applyAbilityEffects();
|
eventHandler.applyAbilityEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSkillLevel() {
|
|
||||||
return skillLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,16 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class TamingManager {
|
public class TamingManager extends SkillManager {
|
||||||
private Player player;
|
|
||||||
private PlayerProfile profile;
|
|
||||||
private int skillLevel;
|
|
||||||
private Config configInstance;
|
private Config configInstance;
|
||||||
|
|
||||||
public TamingManager (Player player) {
|
public TamingManager (Player player) {
|
||||||
this.player = player;
|
super(player, SkillType.TAMING);
|
||||||
this.profile = Users.getProfile(player);
|
|
||||||
this.skillLevel = profile.getSkillLevel(SkillType.TAMING);
|
|
||||||
this.configInstance = Config.getInstance();
|
this.configInstance = Config.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,12 +276,4 @@ public class TamingManager {
|
|||||||
eventHandler.modifyEventDamage();
|
eventHandler.modifyEventDamage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSkillLevel() {
|
|
||||||
return skillLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,21 +3,14 @@ package com.gmail.nossr50.skills.unarmed;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class UnarmedManager {
|
|
||||||
private Player player;
|
|
||||||
private PlayerProfile profile;
|
|
||||||
private int skillLevel;
|
|
||||||
|
|
||||||
|
public class UnarmedManager extends SkillManager {
|
||||||
public UnarmedManager (Player player) {
|
public UnarmedManager (Player player) {
|
||||||
this.player = player;
|
super(player, SkillType.UNARMED);
|
||||||
this.profile = Users.getProfile(player);
|
|
||||||
this.skillLevel = profile.getSkillLevel(SkillType.UNARMED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,12 +131,4 @@ public class UnarmedManager {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSkillLevel() {
|
|
||||||
return skillLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user