Merge remote-tracking branch 'origin/1.6.x' into 1.6.x

# Conflicts:
#	src/main/java/com/massivecraft/factions/cmd/CmdHome.java
This commit is contained in:
Driftay 2019-11-14 03:43:06 -05:00
commit d808bac17b
4 changed files with 101 additions and 4 deletions

View File

@ -13,7 +13,6 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.*; import java.util.*;
public class MissionGUI implements FactionGUI { public class MissionGUI implements FactionGUI {
@ -44,6 +43,9 @@ public class MissionGUI implements FactionGUI {
if (missionName == null) { if (missionName == null) {
return; return;
} }
//if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name")))) {
//return;
//}
if (fPlayer.getFaction().getMissions().containsKey(missionName)) { if (fPlayer.getFaction().getMissions().containsKey(missionName)) {
fPlayer.msg(TL.MISSION_MISSION_ACTIVE); fPlayer.msg(TL.MISSION_MISSION_ACTIVE);
return; return;
@ -63,6 +65,24 @@ public class MissionGUI implements FactionGUI {
if (missionSection == null) { if (missionSection == null) {
return; 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")); Mission mission = new Mission(missionName, missionSection.getString("Type"));
fPlayer.getFaction().getMissions().put(missionName, mission); fPlayer.getFaction().getMissions().put(missionName, mission);
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(section.getString("Name"))); fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(section.getString("Name")));
@ -110,6 +130,46 @@ public class MissionGUI implements FactionGUI {
slots.put(slot, key); slots.put(slot, key);
} }
} }
if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
ItemStack start = null;
ItemMeta meta;
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();
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Allowed.Lore")) {
loree.add(plugin.color(string));
}
meta.setLore(loree);
start.setItemMeta(meta);
if (fPlayer.getFaction().getCompletedMissions().size() >= configurationSection.getKeys(false).size() - 1 && plugin.getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
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();
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Disallowed.Lore")) {
lore.add(plugin.color(string).replace("%reason%", TL.MISSION_MISSION_ALL_COMPLETED.toString()));
}
meta.setLore(lore);
start.setItemMeta(meta);
}
if (fPlayer.getFaction().getMissions().size() >= plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce")) {
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();
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"))));
}
meta.setLore(lore);
start.setItemMeta(meta);
}
inventory.setItem(plugin.getConfig().getInt("Randomization.Start-Item.Slot"), start);
slots.put(plugin.getConfig().getInt("Randomization.Start-Item.Slot"), start.getItemMeta().getDisplayName());
}
} }
public Inventory getInventory() { public Inventory getInventory() {

View File

@ -5,9 +5,11 @@ import org.bukkit.configuration.file.FileConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Updater { public class Updater {
public static double currentVersion = 1.0; public static double currentVersion = 1.1;
public static void updateIfNeeded(FileConfiguration conf) { public static void updateIfNeeded(FileConfiguration conf) {
double version = conf.getDouble("Config-Version", 0); double version = conf.getDouble("Config-Version", 0);
//Previous version //Previous version
@ -17,6 +19,25 @@ public class Updater {
conf.set("Config-Version", 1.0); conf.set("Config-Version", 1.0);
version = 1.0; version = 1.0;
} }
if (version == 1.0) {
FactionsPlugin.getInstance().log("Updating config from version 1.0 to 1.1");
FactionsPlugin.getInstance().log("Adding randomization support for f missions...");
conf.set("Randomization.Enabled", false);
conf.set("Randomization.Start-Item.Allowed.Name", "&aStart!");
conf.set("Randomization.Start-Item.Allowed.Material", "GREEN_STAINED_GLASS_PANE");
List<String> lore = new ArrayList<>();
lore.add("&aStart a new mission!");
conf.set("Randomization.Start-Item.Allowed.Lore", lore);
conf.set("Randomization.Start-Item.Disallowed.Name", "&4Cannot start new mission");
conf.set("Randomization.Start-Item.Disallowed.Material", "GRAY_STAINED_GLASS_PANE");
lore.clear();
lore.add("&4%reason%");
conf.set("Randomization.Start-Item.Disallowed.Lore", lore);
conf.set("Randomization.Start-Item.Slot", 23);
conf.set("Config-Version", 1.1);
version = 1.1;
}
//End with save + reload //End with save + reload
try { try {
conf.save(new File("plugins/Factions/config.yml")); conf.save(new File("plugins/Factions/config.yml"));

View File

@ -1036,7 +1036,8 @@ public enum TL {
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), 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_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_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_MAX_ALLOWED("&c&l[!] &7You may not have more than &b%1$s &7missions active at once."),
MISSION_MISSION_ALL_COMPLETED("&c&l[!] &7Your faction has completed all available missions."),
MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"), MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"),
COMMAND_MISSION_DESCRIPTION("Opens missions gui"), COMMAND_MISSION_DESCRIPTION("Opens missions gui"),
// F Global \\ // F Global \\

View File

@ -1,4 +1,4 @@
Config-Version: 1.0 Config-Version: 1.1
# SaberFactions by Driftay # SaberFactions by Driftay
# Report issues: https://github.com/Driftay/Saber-Factions/issues/new # Report issues: https://github.com/Driftay/Saber-Factions/issues/new
# Live support: https://discord.gg/TFxWKeX # Live support: https://discord.gg/TFxWKeX
@ -753,6 +753,21 @@ Missions-Enabled: true
Missions-GUI-Title: '&8&lFaction Missions' Missions-GUI-Title: '&8&lFaction Missions'
MaximumMissionsAllowedAtOnce: 1 MaximumMissionsAllowedAtOnce: 1
Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}' Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}'
Randomization:
Enabled: false
Start-Item:
# Allowed means that they are under maximum allowed missions at one AND if applicable they have not completed every mission more than once
Allowed:
Name: "&aStart!"
Material: GREEN_STAINED_GLASS_PANE
Lore: "&2Start a new mission!"
Disallowed:
# Placeholder %reason% supported throughout this section
Name: "&4Cannot start new mission"
Material: GRAY_STAINED_GLASS_PANE
Lore:
- '&4%reason%'
Slot: 23
DenyMissionsMoreThenOnce: true #this setting to true, means that if they complete a mission they cannot redo the same mission 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 #Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME