Randomized missions implemented!

Signed-off-by: DroppingAnvil <dr0pping.4nvi1@gmail.com>
This commit is contained in:
DroppingAnvil 2019-11-18 17:05:46 -06:00
parent 1927f49221
commit 649392363f
3 changed files with 33 additions and 33 deletions

View File

@ -30,7 +30,30 @@ public class MissionGUI implements FactionGUI {
@Override
public void onClick(int slot, ClickType action) {
String missionName = slots.get(slot);
if (missionName == null) {
return;
}
ConfigurationSection configurationSection = plugin.getConfig().getConfigurationSection("Missions");
if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Allowed.Name")))) {
Mission pickedMission = null;
Set<String> keys = plugin.getConfig().getConfigurationSection("Missions").getKeys(false);
while (pickedMission == null) {
Random r = new Random();
int pick = r.nextInt(keys.size() - 1);
if (!keys.toArray()[pick].toString().equals("FillItem")) {
missionName = keys.toArray()[pick].toString();
if (!fPlayer.getFaction().getMissions().keySet().contains(missionName)) {
pickedMission = new Mission(missionName, plugin.getConfig().getString("Missions." + missionName + ".Mission.Type"));
fPlayer.getFaction().getMissions().put(missionName, pickedMission);
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(plugin.getConfig().getString("Missions." + missionName + ".Name")));
build();
fPlayer.getPlayer().openInventory(inventory);
return;
}
}
}
} else if (plugin.getConfig().getBoolean("Randomization.Enabled")) {return;}
if (configurationSection == null) {
return;
}
@ -39,13 +62,9 @@ public class MissionGUI implements FactionGUI {
fPlayer.msg(TL.MISSION_MISSION_MAX_ALLOWED, max);
return;
}
String missionName = slots.get(slot);
if (missionName == null) {
if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name")))) {
return;
}
//if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name")))) {
//return;
//}
if (fPlayer.getFaction().getMissions().containsKey(missionName)) {
fPlayer.msg(TL.MISSION_MISSION_ACTIVE);
return;
@ -65,24 +84,7 @@ public class MissionGUI implements FactionGUI {
if (missionSection == null) {
return;
}
//Coming soon (:
//if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Allowed.Name")))) {
//Mission pickedMission = null;
//Set<String> keys = plugin.getConfig().getConfigurationSection("Missions").getKeys(false);
//while (pickedMission == null) {
//Random r = new Random();
//int pick = r.nextInt(keys.size() - 1);
//if (!keys.toArray()[pick].toString().equals("FillItem")) {
//missionName = keys.toArray()[pick].toString();
//pickedMission = new Mission(missionName, plugin.getConfig().getString("Missions." + missionName + ".Mission.Type"));
//fPlayer.getFaction().getMissions().put(missionName, pickedMission);
//fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(plugin.getConfig().getString("Missions." + missionName + ".Name")));
//build();
//fPlayer.getPlayer().openInventory(inventory);
//return;
//}
//}
//}
Mission mission = new Mission(missionName, missionSection.getString("Type"));
fPlayer.getFaction().getMissions().put(missionName, mission);
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(section.getString("Name")));
@ -136,8 +138,7 @@ public class MissionGUI implements FactionGUI {
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).parseItem();
meta = start.getItemMeta();
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Name")));
List<String> loree = meta.getLore();
loree.clear();
List<String> loree = new ArrayList<>();
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Allowed.Lore")) {
loree.add(plugin.color(string));
}
@ -147,8 +148,7 @@ public class MissionGUI implements FactionGUI {
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
meta = start.getItemMeta();
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
List<String> lore = meta.getLore();
lore.clear();
List<String> lore = new ArrayList<>();
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Disallowed.Lore")) {
lore.add(plugin.color(string).replace("%reason%", TL.MISSION_MISSION_ALL_COMPLETED.toString()));
}
@ -159,8 +159,7 @@ public class MissionGUI implements FactionGUI {
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
meta = start.getItemMeta();
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
List<String> lore = meta.getLore();
lore.clear();
List<String> lore = new ArrayList<>();
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Disallowed.Lore")) {
lore.add(plugin.color(string).replace("%reason%", FactionsPlugin.getInstance().txt.parse(TL.MISSION_MISSION_MAX_ALLOWED.toString(), plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce"))));
}

View File

@ -33,7 +33,7 @@ public class Updater {
lore.clear();
lore.add("&4%reason%");
conf.set("Randomization.Start-Item.Disallowed.Lore", lore);
conf.set("Randomization.Start-Item.Slot", 23);
conf.set("Randomization.Start-Item.Slot", 28);
conf.set("Config-Version", 1.1);
version = 1.1;

View File

@ -748,7 +748,7 @@ f-points:
# | Faction Missions | #
# +------------------------------------------------------+ #
############################################################
MissionGUISize: 3
MissionGUISize: 4
Missions-Enabled: true
Missions-GUI-Title: '&8&lFaction Missions'
MaximumMissionsAllowedAtOnce: 1
@ -767,14 +767,15 @@ Randomization:
Material: GRAY_STAINED_GLASS_PANE
Lore:
- '&4%reason%'
Slot: 23
# in default configuration you will need to change the GUI size to 4 and for best results change the fillitem rows to 4 as well.
Slot: 31
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:
FillItem:
Material: BLACK_STAINED_GLASS_PANE
Rows: 3
Rows: 4
sugarcane:
Slot: 11
Material: "SUGAR_CANE"