Add option to disable gender swap. Adds #26

This commit is contained in:
Lennart ten wolde 2017-02-09 22:23:38 +01:00
parent 98e65fc934
commit c30a33f0e8
3 changed files with 9 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import com.lenis0012.bukkit.marriage2.Gender;
import com.lenis0012.bukkit.marriage2.MPlayer;
import com.lenis0012.bukkit.marriage2.Marriage;
import com.lenis0012.bukkit.marriage2.config.Message;
import com.lenis0012.bukkit.marriage2.config.Settings;
public class CommandGender extends Command {
@ -16,7 +17,7 @@ public class CommandGender extends Command {
@Override
public void execute() {
Gender gender = null;
Gender gender;
try {
gender = Gender.valueOf(getArg(0).toUpperCase());
} catch(Exception e) {
@ -25,6 +26,10 @@ public class CommandGender extends Command {
}
MPlayer mPlayer = marriage.getMPlayer(player);
if(mPlayer.getGender() != Gender.UNKNOWN && !Settings.ALLOW_GENDER_CHANGE.value()) {
reply(Message.GENDER_ALREADY_CHANGED);
}
mPlayer.setGender(gender);
reply(Message.GENDER_SET, gender.toString().toLowerCase());
}

View file

@ -53,6 +53,7 @@ public enum Message {
PARTNER_PVP("&aYour partner has changed pvp rules."),
BONUS_EXP("&aYou gained %s extra EXP for leveling with your partner!"),
CONFIG_RELOAD("&aConfiguration settings were reloaded, please note that some settings may not apply until reboot."),
GENDER_ALREADY_CHANGED("&cYou have already specified your gender, you can only do this once."),
// COMMANDS
COMMAND_MARRY("Request a marriage with another player"),

View file

@ -12,6 +12,8 @@ public class Settings {
*/
public static final ConfigOption<Integer> REQUEST_EXPIRY = new ConfigOption<>("requestExpiry", 60);
public static final ConfigOption<Boolean> ENABLE_PRIEST = new ConfigOption<>("enable-priests", false);
@ConfigHeader("Allow a player's gender to be changed multiple times.")
public static final ConfigOption<Boolean> ALLOW_GENDER_CHANGE = new ConfigOption<>("enable-gender-change", true);
/**
* Cooldown