Added a basic reward model and repetitive unlocks to calculate time till next unlock on repeating rewards

This commit is contained in:
BuildTools
2020-04-06 01:47:24 -05:00
parent 28a9013868
commit fa39d13dc3
4 changed files with 68 additions and 0 deletions
Binary file not shown.
@@ -0,0 +1,10 @@
// GASM.java (General Activation Sequence Manager)
// - In charge of making sure things do their thing when they are supposed to
//
// (c) Owen Rummage 2020
package dev.astridlabs.playtimerewardsplus.Controllers;
public class GASM {
}
@@ -7,7 +7,9 @@ package dev.astridlabs.playtimerewardsplus.DataTypes;
import org.bukkit.Location; import org.bukkit.Location;
import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public class PlayerData { public class PlayerData {
@@ -19,6 +21,8 @@ public class PlayerData {
private Location CurrentLocation; private Location CurrentLocation;
private Location LastLocation; private Location LastLocation;
private List<String> RepetitiveUnlocks = new ArrayList<String>();
public PlayerData(UUID uuid, String DisplayName){ public PlayerData(UUID uuid, String DisplayName){
this.uuid = uuid; this.uuid = uuid;
this.DisplayName = DisplayName; this.DisplayName = DisplayName;
@@ -56,4 +60,32 @@ public class PlayerData {
public void setLastLocation(Location lastLocation) { public void setLastLocation(Location lastLocation) {
this.LastLocation = lastLocation; this.LastLocation = lastLocation;
} }
public String getRepetitiveUnlocks(String timeRequired){
String returnableString = "none";
for(String reward : RepetitiveUnlocks){
if(reward.split(":")[0].equals(timeRequired)){
returnableString = reward;
}
}
return returnableString;
}
public void setRepetitiveUnlocks(String timeRequired, Integer times){
for(int i = 0; i<RepetitiveUnlocks.size(); i++){
String reward = RepetitiveUnlocks.get(i);
if(reward.split(":")[0].equals(timeRequired)){
StringBuilder sb = new StringBuilder();
sb.append(timeRequired);
sb.append(":");
sb.append(times);
RepetitiveUnlocks.set(i, sb.toString());
}
}
}
} }
@@ -0,0 +1,26 @@
// Reward.java
// - Datatype saved by the RewardManager.java
//
// (c) Owen Rummage 2020
package dev.astridlabs.playtimerewardsplus.DataTypes;
import java.util.ArrayList;
import java.util.List;
public class Reward {
public Integer TimeRequred;
public boolean DoesRepeat;
public String UnlockMessage;
public List<String> Commands = new ArrayList<String>();
public Reward(Integer timeRequred, boolean doesRepeat, String unlockMessage, List commands){
this.TimeRequred = timeRequred;
this.DoesRepeat = doesRepeat;
this.UnlockMessage = unlockMessage;
this.Commands = commands;
}
}