Merge pull request #15 from DroppingAnvil/1.6.x
Added 2 new Faction Mission types!
This commit is contained in:
commit
17378f7c3a
@ -11,9 +11,11 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityTameEvent;
|
import org.bukkit.event.entity.EntityTameEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -117,6 +119,37 @@ public class MissionHandler implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerEnchant(EnchantItemEvent e) {
|
||||||
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(e.getEnchanter());
|
||||||
|
if (fPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("enchant")).collect(Collectors.toList());
|
||||||
|
for (Mission mission2 : missions) {
|
||||||
|
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||||
|
mission2.incrementProgress();
|
||||||
|
checkIfDone(fPlayer, mission2, section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerConsume(PlayerItemConsumeEvent e) {
|
||||||
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
|
if (fPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("consume")).collect(Collectors.toList());
|
||||||
|
for (Mission mission2 : missions) {
|
||||||
|
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||||
|
if (!e.getItem().toString().contains(section.getConfigurationSection("Mission").getString("Item")) && !section.getConfigurationSection("Mission").getString("Item").equalsIgnoreCase("ALL")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mission2.incrementProgress();
|
||||||
|
checkIfDone(fPlayer, mission2, section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkIfDone(FPlayer fPlayer, Mission mission, ConfigurationSection section) {
|
private void checkIfDone(FPlayer fPlayer, Mission mission, ConfigurationSection section) {
|
||||||
if (mission.getProgress() < section.getConfigurationSection("Mission").getLong("Amount")) {
|
if (mission.getProgress() < section.getConfigurationSection("Mission").getLong("Amount")) {
|
||||||
return;
|
return;
|
||||||
|
@ -741,7 +741,7 @@ Missions-GUI-Title: '&bFaction 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}'
|
||||||
|
|
||||||
#Mission Types: KILL, MINE, PLACE, FISH, TAME
|
#Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME
|
||||||
Missions:
|
Missions:
|
||||||
sugarcane:
|
sugarcane:
|
||||||
Slot: 11
|
Slot: 11
|
||||||
@ -779,7 +779,7 @@ Missions:
|
|||||||
Reward:
|
Reward:
|
||||||
Commands: ["f points add %faction% 100"]
|
Commands: ["f points add %faction% 100"]
|
||||||
animaltaming:
|
animaltaming:
|
||||||
Slot: 21
|
Slot: 20
|
||||||
Material: "BONE"
|
Material: "BONE"
|
||||||
Name: "&f100 &cTamed Animals"
|
Name: "&f100 &cTamed Animals"
|
||||||
Lore:
|
Lore:
|
||||||
@ -790,6 +790,30 @@ Missions:
|
|||||||
Amount: 100
|
Amount: 100
|
||||||
Reward:
|
Reward:
|
||||||
Commands: ["f points add %faction% 100"]
|
Commands: ["f points add %faction% 100"]
|
||||||
|
enchant:
|
||||||
|
Slot: 22
|
||||||
|
Material: "BOOK"
|
||||||
|
Name: "&f100 &dEnchants"
|
||||||
|
Lore:
|
||||||
|
- "&b&lEnchant &n100&r &d&litems"
|
||||||
|
Mission:
|
||||||
|
Type: "ENCHANT"
|
||||||
|
Amount: 100
|
||||||
|
Reward:
|
||||||
|
Commands: ["f points add %faction% 100"]
|
||||||
|
consume:
|
||||||
|
Slot: 24
|
||||||
|
Material: "COOKED_BEEF"
|
||||||
|
Name: "&f100 &dSteak"
|
||||||
|
Lore:
|
||||||
|
- "&b&lConsume &n100&r &d&lsteak"
|
||||||
|
Mission:
|
||||||
|
Type: "CONSUME"
|
||||||
|
# "ALL" can also be used for item
|
||||||
|
Item: "COOKED_BEEF"
|
||||||
|
Amount: 100
|
||||||
|
Reward:
|
||||||
|
Commands: ["f points add %faction% 100"]
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
|
Loading…
Reference in New Issue
Block a user