Missions Not Be Able to Be Done Multiple Times

This commit is contained in:
Driftay 2019-09-21 10:35:08 -04:00
parent 5b8d2ac4d5
commit 99edc5b3b5
7 changed files with 22 additions and 4 deletions

View File

@ -59,6 +59,8 @@ public interface Faction extends EconomyParticipator {
Map<String, Mission> getMissions();
List<String> getCompletedMissions();
void deinviteAlt(FPlayer alt);
void deinviteAllAlts();

View File

@ -35,7 +35,7 @@ public class CmdMoney extends FCommand {
@Override
public void perform(CommandContext context) {
if (!Conf.econEnabled) {
if (!Conf.econEnabled || !Conf.bankEnabled) {
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
return;
}

View File

@ -55,6 +55,13 @@ public class MissionGUI implements FactionGUI {
if (section == null) {
return;
}
if(FactionsPlugin.getInstance().getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
if (fPlayer.getFaction().getCompletedMissions().contains(missionName)) {
fPlayer.msg(TL.MISSION_ALREAD_COMPLETED);
return;
}
}
ConfigurationSection missionSection = section.getConfigurationSection("Mission");
if (missionSection == null) {
return;

View File

@ -159,5 +159,6 @@ public class MissionHandler implements Listener {
}
fPlayer.getFaction().getMissions().remove(mission.getName());
fPlayer.getFaction().msg(TL.MISSION_MISSION_FINISHED, plugin.color(section.getString("Name")));
fPlayer.getFaction().getCompletedMissions().add(mission.getName());
}
}

View File

@ -83,6 +83,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private int tntBankSize;
private int warpLimit;
private double reinforcedArmor;
private List<String> completedMissions;
// -------------------------------------------- //
@ -112,6 +113,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
this.checks = new ConcurrentHashMap<>();
this.playerWallCheckCount = new ConcurrentHashMap<>();
this.playerBufferCheckCount = new ConcurrentHashMap<>();
this.completedMissions = new ArrayList<>();
resetPerms(); // Reset on new Faction so it has default values.
}
@ -130,6 +132,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
money = old.money;
powerBoost = old.powerBoost;
missions = new ConcurrentHashMap<>();
this.completedMissions = new ArrayList<>();
relationWish = old.relationWish;
claimOwnership = old.claimOwnership;
fplayers = new HashSet<>();
@ -509,7 +512,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.wallCheckMinutes;
}
public void setWallCheckMinutes(final int wallCheckMinutes) {
public void setWallCheckMinutes(int wallCheckMinutes) {
this.wallCheckMinutes = wallCheckMinutes;
}
@ -517,7 +520,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.bufferCheckMinutes;
}
public void setBufferCheckMinutes(final int bufferCheckMinutes) {
public void setBufferCheckMinutes(int bufferCheckMinutes) {
this.bufferCheckMinutes = bufferCheckMinutes;
}
@ -537,7 +540,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.weeWoo;
}
public void setWeeWoo(final boolean weeWoo) {
public void setWeeWoo(boolean weeWoo) {
this.weeWoo = weeWoo;
}
@ -1266,6 +1269,9 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.missions;
}
@Override
public List<String> getCompletedMissions() {return this.completedMissions;}
public void clearAllClaimOwnership() {
claimOwnership.clear();
}

View File

@ -999,6 +999,7 @@ public enum TL {
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),
MISSION_ALREAD_COMPLETED("&c&l[!] &7You may not restart a mission you have already completed"),
MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"),
MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."),
MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"),

View File

@ -737,6 +737,7 @@ Missions-Enabled: true
Missions-GUI-Title: '&bFaction Missions'
MaximumMissionsAllowedAtOnce: 1
Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}'
DenyMissionsMoreThenOnce: true #this setting to true, means that if they complete a mission they cannot redo the same mission
#Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME
Missions: