From dc1118e32856f8525d6a4b2113dbc2aca7b6300f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Ulf=20J=C3=B8rgensen?= Date: Fri, 10 Feb 2017 18:34:42 +0100 Subject: [PATCH] Change PowerMixin to newer setup --- src/com/massivecraft/factions/Factions.java | 14 +++--- .../massivecraft/factions/entity/MPlayer.java | 11 +++-- .../factions/mixin/PowerMixin.java | 46 ++++++++++++++--- .../factions/mixin/PowerMixinDefault.java | 49 ------------------- 4 files changed, 52 insertions(+), 68 deletions(-) delete mode 100644 src/com/massivecraft/factions/mixin/PowerMixinDefault.java diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index ec411af9..779ddd8a 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -1,9 +1,5 @@ package com.massivecraft.factions; -import com.massivecraft.factions.cmd.type.TypeFactionChunkChangeType; -import com.massivecraft.factions.cmd.type.TypeRel; -import com.massivecraft.factions.event.EventFactionsChunkChangeType; -import com.massivecraft.massivecore.command.type.RegistryType; import org.bukkit.ChatColor; import com.massivecraft.factions.adapter.BoardAdapter; @@ -25,6 +21,8 @@ import com.massivecraft.factions.chat.tag.ChatTagRoleprefix; import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce; import com.massivecraft.factions.chat.tag.ChatTagTitle; import com.massivecraft.factions.cmd.CmdFactions; +import com.massivecraft.factions.cmd.type.TypeFactionChunkChangeType; +import com.massivecraft.factions.cmd.type.TypeRel; import com.massivecraft.factions.engine.EngineCanCombatHappen; import com.massivecraft.factions.engine.EngineChat; import com.massivecraft.factions.engine.EngineChunkChange; @@ -55,13 +53,13 @@ import com.massivecraft.factions.entity.MConfColl; import com.massivecraft.factions.entity.MFlagColl; import com.massivecraft.factions.entity.MPermColl; import com.massivecraft.factions.entity.MPlayerColl; +import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.integration.V19.IntegrationV19; import com.massivecraft.factions.integration.herochat.IntegrationHerochat; import com.massivecraft.factions.integration.lwc.IntegrationLwc; import com.massivecraft.factions.integration.spigot.IntegrationSpigot; import com.massivecraft.factions.integration.worldguard.IntegrationWorldGuard; import com.massivecraft.factions.mixin.PowerMixin; -import com.massivecraft.factions.mixin.PowerMixinDefault; import com.massivecraft.factions.task.TaskEconLandReward; import com.massivecraft.factions.task.TaskFlagPermCreate; import com.massivecraft.factions.task.TaskPlayerDataRemove; @@ -71,6 +69,7 @@ import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.AspectColl; import com.massivecraft.massivecore.MassivePlugin; import com.massivecraft.massivecore.Multiverse; +import com.massivecraft.massivecore.command.type.RegistryType; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.xlib.gson.Gson; import com.massivecraft.massivecore.xlib.gson.GsonBuilder; @@ -120,9 +119,8 @@ public class Factions extends MassivePlugin public boolean isDatabaseInitialized() { return this.databaseInitialized; } // Mixins - private PowerMixin powerMixin = null; - public PowerMixin getPowerMixin() { return this.powerMixin == null ? PowerMixinDefault.get() : this.powerMixin; } - public void setPowerMixin(PowerMixin powerMixin) { this.powerMixin = powerMixin; } + @Deprecated public PowerMixin getPowerMixin() { return PowerMixin.get(); } + @Deprecated public void setPowerMixin(PowerMixin powerMixin) { PowerMixin.get().setInstance(powerMixin); } // Gson without preprocessors public final Gson gsonWithoutPreprocessors = this.getGsonBuilderWithoutPreprocessors().create(); diff --git a/src/com/massivecraft/factions/entity/MPlayer.java b/src/com/massivecraft/factions/entity/MPlayer.java index b037a873..b5b0b438 100644 --- a/src/com/massivecraft/factions/entity/MPlayer.java +++ b/src/com/massivecraft/factions/entity/MPlayer.java @@ -22,6 +22,7 @@ import com.massivecraft.factions.event.EventFactionsDisband; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsRemovePlayerMillis; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.factions.mixin.PowerMixin; import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.massivecore.mixin.MixinSenderPs; import com.massivecraft.massivecore.mixin.MixinTitle; @@ -428,27 +429,27 @@ public class MPlayer extends SenderEntity implements EconomyParticipato public double getPowerMaxUniversal() { - return Factions.get().getPowerMixin().getMaxUniversal(this); + return PowerMixin.get().getMaxUniversal(this); } public double getPowerMax() { - return Factions.get().getPowerMixin().getMax(this); + return PowerMixin.get().getMax(this); } public double getPowerMin() { - return Factions.get().getPowerMixin().getMin(this); + return PowerMixin.get().getMin(this); } public double getPowerPerHour() { - return Factions.get().getPowerMixin().getPerHour(this); + return PowerMixin.get().getPerHour(this); } public double getPowerPerDeath() { - return Factions.get().getPowerMixin().getPerDeath(this); + return PowerMixin.get().getPerDeath(this); } // MIXIN: FINER diff --git a/src/com/massivecraft/factions/mixin/PowerMixin.java b/src/com/massivecraft/factions/mixin/PowerMixin.java index 61467a78..8157e249 100644 --- a/src/com/massivecraft/factions/mixin/PowerMixin.java +++ b/src/com/massivecraft/factions/mixin/PowerMixin.java @@ -1,12 +1,46 @@ package com.massivecraft.factions.mixin; +import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.massivecore.mixin.Mixin; -public interface PowerMixin +public class PowerMixin extends Mixin { - public double getMaxUniversal(MPlayer mplayer); - public double getMax(MPlayer mplayer); - public double getMin(MPlayer mplayer); - public double getPerHour(MPlayer mplayer); - public double getPerDeath(MPlayer mplayer); + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static PowerMixin d = new PowerMixin(); + private static PowerMixin i = d; + public static PowerMixin get() { return i; } + + // -------------------------------------------- // + // METHODS + // -------------------------------------------- // + + public double getMaxUniversal(MPlayer mplayer) + { + return this.getMax(mplayer); + } + + public double getMax(MPlayer mplayer) + { + return MConf.get().powerMax + mplayer.getPowerBoost(); + } + + public double getMin(MPlayer mplayer) + { + return MConf.get().powerMin; + } + + public double getPerHour(MPlayer mplayer) + { + return MConf.get().powerPerHour; + } + + public double getPerDeath(MPlayer mplayer) + { + return MConf.get().powerPerDeath; + } + } diff --git a/src/com/massivecraft/factions/mixin/PowerMixinDefault.java b/src/com/massivecraft/factions/mixin/PowerMixinDefault.java deleted file mode 100644 index b3766991..00000000 --- a/src/com/massivecraft/factions/mixin/PowerMixinDefault.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.massivecraft.factions.mixin; - -import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.MPlayer; - -public class PowerMixinDefault implements PowerMixin -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static PowerMixinDefault i = new PowerMixinDefault(); - public static PowerMixinDefault get() { return i; } - - // -------------------------------------------- // - // OVERRIDE: PowerMixin - // -------------------------------------------- // - - @Override - public double getMaxUniversal(MPlayer mplayer) - { - return this.getMax(mplayer); - } - - @Override - public double getMax(MPlayer mplayer) - { - return MConf.get().powerMax + mplayer.getPowerBoost(); - } - - @Override - public double getMin(MPlayer mplayer) - { - return MConf.get().powerMin; - } - - @Override - public double getPerHour(MPlayer mplayer) - { - return MConf.get().powerPerHour; - } - - @Override - public double getPerDeath(MPlayer mplayer) - { - return MConf.get().powerPerDeath; - } - -}