change votes requirements to use total votes, add points requirement

This commit is contained in:
okx-code
2020-04-25 17:51:31 +01:00
parent 73e97d0b85
commit 8e755bbced
6 changed files with 72 additions and 10 deletions
@@ -70,6 +70,8 @@ import sh.okx.rankup.requirements.requirement.towny.TownyKingRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyMayorNumberResidentsRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyMayorRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyResidentRequirement;
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsDeductibleRequirement;
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsRequirement;
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginVotesRequirement;
import sh.okx.rankup.util.UpdateNotifier;
import sh.okx.rankup.util.VersionChecker;
@@ -349,7 +351,9 @@ public class RankupPlugin extends JavaPlugin {
}
if (pluginManager.isPluginEnabled("VotingPlugin")) {
requirements.addRequirements(
new VotingPluginVotesRequirement(this));
new VotingPluginVotesRequirement(this),
new VotingPluginPointsRequirement(this, "votingplugin-pointsh"),
new VotingPluginPointsDeductibleRequirement(this, "votingplugin-points"));
}
if (Bukkit.getPluginManager().isPluginEnabled("Towny")) {
requirements.addRequirements(
@@ -0,0 +1,32 @@
package sh.okx.rankup.requirements.requirement.votingplugin;
import com.Ben12345rocks.VotingPlugin.Objects.User;
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
import org.bukkit.entity.Player;
import sh.okx.rankup.RankupPlugin;
import sh.okx.rankup.requirements.DeductibleRequirement;
import sh.okx.rankup.requirements.Requirement;
public class VotingPluginPointsDeductibleRequirement extends VotingPluginPointsRequirement implements DeductibleRequirement {
public VotingPluginPointsDeductibleRequirement(RankupPlugin plugin, String name) {
super(plugin, name);
}
protected VotingPluginPointsDeductibleRequirement(Requirement clone) {
super(clone);
}
@Override
public void apply(Player player, double multiplier) {
User user = UserManager.getInstance().getVotingPluginUser(player);
if(!user.removePoints(getValueInt())) {
plugin.getLogger().warning("Unable to remove VotingPlugin points");
}
}
@Override
public Requirement clone() {
return new VotingPluginPointsDeductibleRequirement(this);
}
}
@@ -0,0 +1,28 @@
package sh.okx.rankup.requirements.requirement.votingplugin;
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
import org.bukkit.entity.Player;
import sh.okx.rankup.RankupPlugin;
import sh.okx.rankup.requirements.ProgressiveRequirement;
import sh.okx.rankup.requirements.Requirement;
public class VotingPluginPointsRequirement extends ProgressiveRequirement {
public VotingPluginPointsRequirement(RankupPlugin plugin, String name) {
super(plugin, name);
}
protected VotingPluginPointsRequirement(Requirement clone) {
super(clone);
}
@Override
public double getProgress(Player player) {
return UserManager.getInstance().getVotingPluginUser(player).getPoints();
}
@Override
public Requirement clone() {
return new VotingPluginPointsRequirement(this);
}
}
@@ -1,5 +1,6 @@
package sh.okx.rankup.requirements.requirement.votingplugin;
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
import org.bukkit.entity.Player;
import sh.okx.rankup.RankupPlugin;
@@ -17,7 +18,7 @@ public class VotingPluginVotesRequirement extends ProgressiveRequirement {
@Override
public double getProgress(Player player) {
return UserManager.getInstance().getVotingPluginUser(player).getPoints();
return UserManager.getInstance().getVotingPluginUser(player).getTotal(TopVoter.AllTime);
}
@Override