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

# Conflicts:
#	src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java
#	src/main/java/com/massivecraft/factions/missions/MissionHandler.java
This commit is contained in:
Driftay 2019-09-15 05:04:22 -04:00
commit 978bcbbb3b
7 changed files with 598 additions and 583 deletions

View File

View File

@ -4,12 +4,14 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; 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.entity.EntityBreedEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
@ -18,91 +20,91 @@ import java.util.stream.Collectors;
public class MissionHandler implements Listener { public class MissionHandler implements Listener {
private FactionsPlugin plugin; private FactionsPlugin plugin;
public MissionHandler(FactionsPlugin plugin) { public MissionHandler(FactionsPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntity() == null || event.getEntity().getKiller() == null) { if (event.getEntity() == null || event.getEntity().getKiller() == null) {
return; return;
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getEntity().getKiller()); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getEntity().getKiller());
if (fPlayer == null) { if (fPlayer == null) {
return; return;
} }
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("kill")).collect(Collectors.toList()); List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("kill")).collect(Collectors.toList());
for (Mission mission2 : missions) { for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName()); 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"))) {
continue; continue;
} }
mission2.incrementProgress(); mission2.incrementProgress();
checkIfDone(fPlayer, mission2, section); checkIfDone(fPlayer, mission2, section);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fPlayer == null) { if (fPlayer == null) {
return; return;
} }
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("mine")).collect(Collectors.toList()); List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("mine")).collect(Collectors.toList());
for (Mission mission2 : missions) { for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName()); 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"))) {
continue; continue;
} }
mission2.incrementProgress(); mission2.incrementProgress();
checkIfDone(fPlayer, mission2, section); checkIfDone(fPlayer, mission2, section);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fPlayer == null) { if (fPlayer == null) {
return; return;
} }
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("place")).collect(Collectors.toList()); List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("place")).collect(Collectors.toList());
for (Mission mission2 : missions) { for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName()); 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"))) {
continue; continue;
} }
mission2.incrementProgress(); mission2.incrementProgress();
checkIfDone(fPlayer, mission2, section); checkIfDone(fPlayer, mission2, section);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) { public void onPlayerFish(PlayerFishEvent event) {
if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) { if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) {
return; return;
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fPlayer == null) { if (fPlayer == null) {
return; return;
} }
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("fish")).collect(Collectors.toList()); List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("fish")).collect(Collectors.toList());
for (Mission mission2 : missions) { for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName()); ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
mission2.incrementProgress(); mission2.incrementProgress();
checkIfDone(fPlayer, mission2, section); 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;
} }
for (String command : section.getConfigurationSection("Reward").getStringList("Commands")) { for (String command : section.getConfigurationSection("Reward").getStringList("Commands")) {
FactionsPlugin.getInstance().getServer().dispatchCommand(FactionsPlugin.getInstance().getServer().getConsoleSender(), command.replace("%faction%", fPlayer.getFaction().getTag())); FactionsPlugin.getInstance().getServer().dispatchCommand(FactionsPlugin.getInstance().getServer().getConsoleSender(), command.replace("%faction%", fPlayer.getFaction().getTag()));
} }
fPlayer.getFaction().getMissions().remove(mission.getName()); fPlayer.getFaction().getMissions().remove(mission.getName());
fPlayer.getFaction().msg(TL.MISSION_MISSION_FINISHED, plugin.color(section.getString("Name"))); fPlayer.getFaction().msg(TL.MISSION_MISSION_FINISHED, plugin.color(section.getString("Name")));
} }
} }

View File

View File

@ -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, FISH #Mission Types: KILL, MINE, PLACE, FISH, TAME
Missions: Missions:
sugarcane: sugarcane:
Slot: 11 Slot: 11
@ -778,6 +778,18 @@ Missions:
Amount: 100 Amount: 100
Reward: Reward:
Commands: ["f points add %faction% 100"] 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.modifypower: true
factions.ahome: true factions.ahome: true
factions.setmaxvaults: true factions.setmaxvaults: true
factions.convertconfig: true
factions.*: factions.*:
description: This is just an alias for factions.kit.admin description: This is just an alias for factions.kit.admin
children: children: