Merge pull request #12 from DroppingAnvil/1.6.x

Added new mission type + added an existing type that was missing from config + added ALL for all missions that use Material or EntityType
This commit is contained in:
Driftay 2019-09-15 04:55:59 -04:00 committed by GitHub
commit 7e9c6cead8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 5 deletions

View File

View File

@ -562,4 +562,4 @@ public class FactionsBlockListener implements Listener {
}
}
}
}
}

View File

@ -6,6 +6,8 @@ import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -13,6 +15,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityBreedEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.player.PlayerFishEvent;
import java.util.List;
@ -38,7 +41,7 @@ public class MissionHandler implements Listener {
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("kill")).collect(Collectors.toList());
for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType"))) {
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType")) && !section.getConfigurationSection("Mission").getString("EntityType").equalsIgnoreCase("ALL")) {
continue;
}
mission2.incrementProgress();
@ -55,7 +58,7 @@ public class MissionHandler implements Listener {
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("mine")).collect(Collectors.toList());
for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material"))) {
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material")) && !section.getConfigurationSection("Mission").getString("Material").equalsIgnoreCase("ALL")) {
continue;
}
mission2.incrementProgress();
@ -72,7 +75,7 @@ public class MissionHandler implements Listener {
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("place")).collect(Collectors.toList());
for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material"))) {
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material")) && !section.getConfigurationSection("Mission").getString("Material").equalsIgnoreCase("ALL")) {
continue;
}
mission2.incrementProgress();
@ -97,6 +100,26 @@ public class MissionHandler implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTame(EntityTameEvent event) {
if (!(event.getOwner() instanceof Player)) {
return;
}
FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player)event.getOwner());
if (fPlayer == null) {
return;
}
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("tame")).collect(Collectors.toList());
for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType")) && !section.getConfigurationSection("Mission").getString("EntityType").equalsIgnoreCase("ALL")) {
continue;
}
mission2.incrementProgress();
checkIfDone(fPlayer, mission2, section);
}
}
private void checkIfDone(FPlayer fPlayer, Mission mission, ConfigurationSection section) {
if (mission.getProgress() < section.getConfigurationSection("Mission").getLong("Amount")) {
return;

View File

View File

@ -741,7 +741,7 @@ Missions-GUI-Title: '&bFaction Missions'
MaximumMissionsAllowedAtOnce: 1
Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}'
#Mission Types: KILL, MINE, FISH
#Mission Types: KILL, MINE, PLACE, FISH, TAME
Missions:
sugarcane:
Slot: 11
@ -778,6 +778,18 @@ Missions:
Amount: 100
Reward:
Commands: ["f points add %faction% 100"]
animaltaming:
Slot: 21
Material: "BONE"
Name: "&f100 &cTamed Animals"
Lore:
- "&b&lTame an animal &n100&r &d&ltimes"
Mission:
Type: "TAME"
EntityType: "ALL"
Amount: 100
Reward:
Commands: ["f points add %faction% 100"]
############################################################
# +------------------------------------------------------+ #

View File

@ -22,6 +22,7 @@ permissions:
factions.modifypower: true
factions.ahome: true
factions.setmaxvaults: true
factions.convertconfig: true
factions.*:
description: This is just an alias for factions.kit.admin
children: