mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-09-19 19:41:11 +02:00
Added group size requirement
This commit is contained in:
parent
0791008ea4
commit
0a9149eb69
2
pom.xml
2
pom.xml
@ -78,7 +78,7 @@
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>commons</artifactId>
|
||||
<version>0.7</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
|
@ -84,7 +84,7 @@ public enum DMessages implements Messages {
|
||||
ERROR_NOT_SAVED("Error_NotSaved", "&4The map &6&v1&4 has not been saved to the &6DungeonsXL/maps/ &4folder yet!"),
|
||||
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"),
|
||||
ERROR_READY("Error_Ready", "&4Choose your class first!"),
|
||||
ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this Dungeon!"),
|
||||
ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this dungeon!"),
|
||||
ERROR_SIGN_WRONG_FORMAT("Error_SignWrongFormat", "&4The sign is not written correctly!"),
|
||||
HELP_CMD_BREAK("Help_Cmd_Break", "/dxl break - Break a block protected by DungeonsXL"),
|
||||
HELP_CMD_CHAT("Help_Cmd_Chat", "/dxl chat - Change the chat mode"),
|
||||
|
@ -23,6 +23,7 @@ import io.github.dre2n.dungeonsxl.game.GameRules;
|
||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.requirement.FeeLevelRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.FeeMoneyRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.GroupSizeRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -189,6 +190,10 @@ public class WorldConfig extends GameRules {
|
||||
|
||||
} else if (requirement instanceof FeeLevelRequirement) {
|
||||
((FeeLevelRequirement) requirement).setFee(configFile.getInt("requirements.feeLevel"));
|
||||
|
||||
} else if (requirement instanceof GroupSizeRequirement) {
|
||||
((GroupSizeRequirement) requirement).setMinimum(configFile.getInt("requirements.groupSize.minimum"));
|
||||
((GroupSizeRequirement) requirement).setMaximum(configFile.getInt("requirements.groupSize.maximum"));
|
||||
}
|
||||
|
||||
requirements.add(requirement);
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.requirement;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class GroupSizeRequirement extends Requirement {
|
||||
|
||||
private RequirementType type = RequirementTypeDefault.GROUP_SIZE;
|
||||
|
||||
private int minimum;
|
||||
private int maximum;
|
||||
|
||||
/**
|
||||
* @return the group minimum
|
||||
*/
|
||||
public int getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minimum
|
||||
* the minimal group size to set
|
||||
*/
|
||||
public void setMinimum(int minimum) {
|
||||
this.minimum = minimum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the group size maximum
|
||||
*/
|
||||
public int getMaximum() {
|
||||
return maximum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maximum
|
||||
* the maximal group size to set
|
||||
*/
|
||||
public void setMaximum(int maximum) {
|
||||
this.maximum = maximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Player player) {
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
int size = dGroup.getPlayers().size();
|
||||
return size >= minimum && size <= maximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void demand(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequirementType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,8 @@ package io.github.dre2n.dungeonsxl.requirement;
|
||||
public enum RequirementTypeDefault implements RequirementType {
|
||||
|
||||
FEE_LEVEL("feeLevel", FeeLevelRequirement.class),
|
||||
FEE_MONEY("feeMoney", FeeMoneyRequirement.class);
|
||||
FEE_MONEY("feeMoney", FeeMoneyRequirement.class),
|
||||
GROUP_SIZE("groupSize", GroupSizeRequirement.class);
|
||||
|
||||
private String identifier;
|
||||
private Class<? extends Requirement> handler;
|
||||
|
Loading…
Reference in New Issue
Block a user