Integrate DungeonsXL using Unite

This commit is contained in:
PikaMug 2021-08-11 07:44:29 -04:00
parent 1f0404dcca
commit c333e86510
9 changed files with 206 additions and 165 deletions

View File

@ -122,14 +122,12 @@
<version>3.1.6</version>
<scope>provided</scope>
</dependency>
<!-- repo offline
<dependency>
<groupId>com.github.DRE2N</groupId>
<artifactId>DungeonsXL</artifactId>
<version>5e7b28ea55</version>
<groupId>com.github.PikaMug</groupId>
<artifactId>Unite</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>com.github.PikaMug</groupId>
<artifactId>LocaleLib</artifactId>

View File

@ -26,6 +26,7 @@ import me.blackvein.quests.reflect.denizen.DenizenAPI;
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
import me.blackvein.quests.util.Lang;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.pikamug.unite.api.objects.PartyProvider;
import net.citizensnpcs.api.CitizensPlugin;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
@ -37,15 +38,15 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import ro.nicuch.citizensbooks.CitizensBooksAPI;
import ro.nicuch.citizensbooks.CitizensBooksPlugin;
import java.util.Objects;
import java.util.UUID;
//import de.erethon.dungeonsxl.DungeonsXL;
public class Dependencies {
private final Quests plugin;
private static Economy economy = null;
private static Permission permission = null;
private static PartyProvider partyProvider = null;
private static WorldGuardAPI worldGuardApi = null;
private static mcMMO mcmmo = null;
private static Heroes heroes = null;
@ -54,7 +55,6 @@ public class Dependencies {
private static CitizensPlugin citizens = null;
private static DenizenAPI denizenApi = null;
private static CitizensBooksAPI citizensBooks = null;
//private static DungeonsXL dungeons = null;
private static PartiesAPI parties = null;
public Dependencies(final Quests plugin) {
@ -64,7 +64,7 @@ public class Dependencies {
public Economy getVaultEconomy() {
if (economy == null && isPluginAvailable("Vault")) {
if (!setupEconomy()) {
plugin.getLogger().warning("Economy not found.");
plugin.getLogger().warning("Economy provider not found.");
}
}
return economy;
@ -73,11 +73,20 @@ public class Dependencies {
public Permission getVaultPermission() {
if (permission == null && isPluginAvailable("Vault")) {
if (!setupPermissions()) {
plugin.getLogger().warning("Permissions not found.");
plugin.getLogger().warning("Permission provider not found.");
}
}
return permission;
}
public PartyProvider getPartyProvider() {
if (partyProvider == null && isPluginAvailable("Unite")) {
if (!setupParty()) {
plugin.getLogger().warning("Party provider not found.");
}
}
return partyProvider;
}
public WorldGuardAPI getWorldGuardApi() {
if (worldGuardApi == null && isPluginAvailable("WorldGuard")) {
@ -171,22 +180,15 @@ public class Dependencies {
public CitizensBooksAPI getCitizensBooksApi() {
if (citizensBooks == null && isPluginAvailable("CitizensBooks")) {
try {
citizensBooks = ((CitizensBooksPlugin) plugin.getServer().getPluginManager().getPlugin("CitizensBooks"))
.getAPI();
citizensBooks = ((CitizensBooksPlugin) Objects.requireNonNull(plugin.getServer().getPluginManager()
.getPlugin("CitizensBooks"))).getAPI();
} catch (final Exception e) {
e.printStackTrace();
}
}
return citizensBooks;
}
/*public DungeonsXL getDungeonsApi() {
if (dungeons == null && isPluginAvailable("DungeonsXL")) {
dungeons = DungeonsXL.getInstance();
}
return dungeons;
}*/
public PartiesAPI getPartiesApi() {
if (parties == null && isPluginAvailable("Parties")) {
try {
@ -202,7 +204,7 @@ public class Dependencies {
public boolean isPluginAvailable(final String pluginName) {
if (plugin.getServer().getPluginManager().getPlugin(pluginName) != null ) {
try {
if (!plugin.getServer().getPluginManager().getPlugin(pluginName).isEnabled()) {
if (!Objects.requireNonNull(plugin.getServer().getPluginManager().getPlugin(pluginName)).isEnabled()) {
plugin.getLogger().warning(pluginName
+ " was detected, but is not enabled! Fix "+ pluginName + " to allow linkage.");
} else {
@ -225,18 +227,18 @@ public class Dependencies {
getPhatLoots();
getPlaceholderApi();
getCitizensBooksApi();
//getDungeonsApi();
getPartiesApi();
getPartyProvider();
getVaultEconomy();
getVaultPermission();
}
private boolean setupEconomy() {
try {
final RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager()
.getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
final RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager()
.getRegistration(Economy.class);
if (rsp != null) {
economy = rsp.getProvider();
}
return (economy != null);
} catch (final Exception e) {
@ -245,14 +247,23 @@ public class Dependencies {
}
private boolean setupPermissions() {
final RegisteredServiceProvider<Permission> permissionProvider = plugin.getServer().getServicesManager()
.getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permission = permissionProvider.getProvider();
final RegisteredServiceProvider<Permission> rsp = plugin.getServer().getServicesManager()
.getRegistration(Permission.class);
if (rsp != null) {
permission = rsp.getProvider();
}
return (permission != null);
}
private boolean setupParty() {
final RegisteredServiceProvider<PartyProvider> rsp = plugin.getServer().getServicesManager()
.getRegistration(PartyProvider.class);
if (rsp != null) {
partyProvider = rsp.getProvider();
}
return (partyProvider != null);
}
/**
* @deprecated Do not use. Will be removed in a future version.
**/

View File

@ -16,7 +16,6 @@ import com.alessiodp.parties.api.interfaces.Party;
import com.alessiodp.parties.api.interfaces.PartyPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager;
//import de.erethon.dungeonsxl.player.DGroup;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.events.quest.QuestTakeEvent;
@ -35,6 +34,7 @@ import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import me.blackvein.quests.util.RomanNumeral;
import me.clip.placeholderapi.PlaceholderAPI;
import me.pikamug.unite.api.objects.PartyProvider;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Bukkit;
@ -76,6 +76,8 @@ import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
//import de.erethon.dungeonsxl.player.DGroup;
public class Quester implements Comparable<Quester> {
private final Quests plugin;
@ -4089,13 +4091,46 @@ public class Quester implements Comparable<Quester> {
return null;
}
final List<Quester> mq = new LinkedList<Quester>();
if (plugin.getDependencies().getPartiesApi() != null) {
if (plugin.getDependencies().getPartyProvider() != null) {
final PartyProvider partyProvider = plugin.getDependencies().getPartyProvider();
if (partyProvider != null && quest.getOptions().canUsePartiesPlugin()
|| quest.getOptions().canUseDungeonsXLPlugin()) {
if (getUUID() != null && partyProvider.getPartyId(getUUID()) != null) {
String partyId = partyProvider.getPartyId(getUUID());
final double distanceSquared = quest.getOptions().getShareDistance()
* quest.getOptions().getShareDistance();
final boolean offlinePlayers = quest.getOptions().canHandleOfflinePlayers();
if (offlinePlayers) {
for (final UUID id : partyProvider.getMembers(partyId)) {
if (!id.equals(getUUID())) {
mq.add(plugin.getQuester(id));
}
}
} else {
for (final UUID id : partyProvider.getOnlineMembers(partyId)) {
if (!id.equals(getUUID())) {
if (distanceSquared > 0) {
final Player player = Bukkit.getPlayer(id);
if (player != null && distanceSquared >= getPlayer().getLocation()
.distanceSquared(player.getLocation())) {
mq.add(plugin.getQuester(id));
}
} else {
mq.add(plugin.getQuester(id));
}
}
}
}
return mq;
}
}
} else if (plugin.getDependencies().getPartiesApi() != null) {
if (quest.getOptions().canUsePartiesPlugin()) {
final PartyPlayer partyPlayer = plugin.getDependencies().getPartiesApi().getPartyPlayer(getUUID());
if (partyPlayer != null && partyPlayer.getPartyId() != null) {
final Party party = plugin.getDependencies().getPartiesApi().getParty(partyPlayer.getPartyId());
if (party != null) {
final double distanceSquared = quest.getOptions().getShareDistance()
final double distanceSquared = quest.getOptions().getShareDistance()
* quest.getOptions().getShareDistance();
final boolean offlinePlayers = quest.getOptions().canHandleOfflinePlayers();
if (offlinePlayers) {
@ -4119,44 +4154,12 @@ public class Quester implements Comparable<Quester> {
}
}
}
return mq;
}
}
}
}
/*if (plugin.getDependencies().getDungeonsApi() != null) {
if (quest.getOptions().canUseDungeonsXLPlugin()) {
final DGroup group = (DGroup) plugin.getDependencies().getDungeonsApi().getPlayerGroup(getPlayer());
if (group != null) {
final double distanceSquared = quest.getOptions().getShareDistance()
* quest.getOptions().getShareDistance();
final boolean offlinePlayers = quest.getOptions().canHandleOfflinePlayers();
if (offlinePlayers) {
for (final UUID id : group.getMembers()) {
if (!id.equals(getUUID())) {
mq.add(plugin.getQuester(id));
}
}
} else {
for (final UUID id : group.getMembers()) {
if (!id.equals(getUUID())) {
if (distanceSquared > 0) {
final Player player = Bukkit.getPlayer(id);
if (player != null && distanceSquared >= getPlayer().getLocation()
.distanceSquared(player.getLocation())) {
mq.add(plugin.getQuester(id));
}
} else {
mq.add(plugin.getQuester(id));
}
}
}
}
return mq;
}
}
}*/
return mq;
}

View File

@ -29,10 +29,10 @@ import me.blackvein.quests.exceptions.StageFormatException;
import me.blackvein.quests.interfaces.ReloadCallback;
import me.blackvein.quests.listeners.BlockListener;
import me.blackvein.quests.listeners.CmdExecutor;
import me.blackvein.quests.listeners.DungeonsListener;
import me.blackvein.quests.listeners.ItemListener;
import me.blackvein.quests.listeners.NpcListener;
import me.blackvein.quests.listeners.PartiesListener;
import me.blackvein.quests.listeners.UniteListener;
import me.blackvein.quests.listeners.PlayerListener;
import me.blackvein.quests.statistics.Metrics;
import me.blackvein.quests.storage.Storage;
@ -102,6 +102,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
@ -137,7 +138,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
private PlayerListener playerListener;
private NpcEffectThread effectThread;
private PlayerMoveThread moveThread;
private DungeonsListener dungeonsListener;
private UniteListener uniteListener;
private PartiesListener partiesListener;
private DenizenTrigger trigger;
private LocaleManager localeManager;
@ -155,7 +156,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
itemListener = new ItemListener(this);
npcListener = new NpcListener(this);
playerListener = new PlayerListener(this);
dungeonsListener = new DungeonsListener();
uniteListener = new UniteListener();
partiesListener = new PartiesListener();
effectThread = new NpcEffectThread(this);
moveThread = new PlayerMoveThread(this);
@ -173,12 +174,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
// 3 - Setup language files
try {
setupLang();
} catch (final IOException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
} catch (final IOException | URISyntaxException e) {
e.printStackTrace();
}
// 4 - Load command executor
cmdExecutor = new CmdExecutor(this);
@ -197,15 +196,21 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
storage = storageFactory.getInstance();
// 8 - Setup commands
getCommand("quests").setExecutor(cmdExecutor);
getCommand("questadmin").setExecutor(cmdExecutor);
getCommand("quest").setExecutor(cmdExecutor);
if (getCommand("quests") != null) {
Objects.requireNonNull(getCommand("quests")).setExecutor(cmdExecutor);
}
if (getCommand("questadmin") != null) {
Objects.requireNonNull(getCommand("questadmin")).setExecutor(cmdExecutor);
}
if (getCommand("quest") != null) {
Objects.requireNonNull(getCommand("quest")).setExecutor(cmdExecutor);
}
// 9 - Build conversation factories
this.conversationFactory = new ConversationFactory(this).withModality(false)
.withPrefix(new ConversationPrefix() {
@Override
public String getPrefix(final ConversationContext context) {
public @Nonnull String getPrefix(final @Nonnull ConversationContext context) {
return ChatColor.GRAY.toString();
}
})
@ -225,10 +230,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
final long ticks = settings.getStrictPlayerMovement() * 20L;
getServer().getScheduler().scheduleSyncRepeatingTask(this, moveThread, ticks, ticks);
}
/*if (depends.getDungeonsApi() != null) {
getServer().getPluginManager().registerEvents(dungeonsListener, this);
}*/
if (depends.getPartiesApi() != null) {
if (depends.getPartyProvider() != null) {
getServer().getPluginManager().registerEvents(uniteListener, this);
} else if (depends.getPartiesApi() != null) {
getServer().getPluginManager().registerEvents(partiesListener, this);
}
@ -243,8 +247,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
final Quester quester = getQuester(p.getUniqueId());
quester.saveData();
}
Bukkit.getScheduler().cancelTasks(this);
getLogger().info("Closing storage...");
storage.close();
if (storage != null) {
storage.close();
}
}
public boolean isLoading() {
@ -527,17 +534,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return playerListener;
}
public DungeonsListener getDungeonsListener() {
return dungeonsListener;
}
public PartiesListener getPartiesListener() {
return partiesListener;
public UniteListener getUniteListener() {
return uniteListener;
}
public NpcEffectThread getNpcEffectThread() {
return effectThread;
}
public PartiesListener getPartiesListener() {
return partiesListener;
}
public DenizenTrigger getDenizenTrigger() {
return trigger;

View File

@ -16,6 +16,7 @@ import me.blackvein.quests.Objective;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
@ -67,12 +68,13 @@ public class BlockListener implements Listener {
continue;
}
if (quester.getCurrentQuests().containsKey(quest)) {
if (quester.getCurrentStage(quest) == null) {
final Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId()
+ ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")");
continue;
}
if (quester.getCurrentStage(quest).containsObjective(breakType)) {
if (currentStage.containsObjective(breakType)) {
if (quest.getOptions().canIgnoreSilkTouch()
&& player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
Lang.send(player, ChatColor.RED + Lang.get(player, "optionSilkTouchFail")
@ -90,11 +92,11 @@ public class BlockListener implements Listener {
}));
}
}
if (quester.getCurrentStage(quest).containsObjective(placeType)) {
if (currentStage.containsObjective(placeType)) {
for (final ItemStack is : quester.getQuestData(quest).blocksPlaced) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toPlace = new ItemStack(is.getType(), 64);
for (final ItemStack stack : quester.getCurrentStage(quest).getBlocksToPlace()) {
for (final ItemStack stack : currentStage.getBlocksToPlace()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toPlace = stack;
}
@ -148,7 +150,7 @@ public class BlockListener implements Listener {
}
return null;
}));
if (quester.getCurrentStage(quest).containsObjective(cutType)) {
if (currentStage.containsObjective(cutType)) {
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
quester.cutBlock(quest, blockItemStack);
}

View File

@ -1,67 +0,0 @@
/*******************************************************************************************************
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************************************/
package me.blackvein.quests.listeners;
import org.bukkit.event.Listener;
public class DungeonsListener implements Listener {
/*@EventHandler
public void onGroupCreate(final GroupCreateEvent event) {
if (Lang.get("questDungeonsCreate").length() > 0) {
final Player p = event.getCreator().getPlayer();
Lang.send(p, ChatColor.YELLOW + Lang.get("questDungeonsCreate"));
}
}
@EventHandler
public void onGroupDisbandEvent(final GroupDisbandEvent event) {
if (Lang.get("questDungeonsDisband").length() > 0) {
final Player p = event.getDisbander().getPlayer();
Lang.send(p, ChatColor.RED + Lang.get("questDungeonsDisband"));
}
}
@EventHandler
public void onPlayerJoinEvent(final GroupPlayerJoinEvent event) {
if (event.getGroup() != null && event.getPlayer() != null) {
final Player i = event.getGroup().getLeader();
final Player p = event.getPlayer().getPlayer();
if (i != null && p != null) {
if (Lang.get("questDungeonsInvite").length() > 0) {
Lang.send(i, ChatColor.GREEN + Lang.get(i, "questDungeonsInvite")
.replace("<player>", p.getName()));
}
if (Lang.get("questDungeonsJoin").length() > 0) {
Lang.send(p, ChatColor.GREEN + Lang.get(p, "questDungeonsJoin").replace("<player>", i.getName()));
}
}
}
}
@EventHandler
public void onPlayerLeaveEvent(final GroupPlayerLeaveEvent event) {
if (event.getGroup() != null && event.getPlayer() != null) {
final Player k = event.getGroup().getLeader();
final Player p = event.getPlayer().getPlayer();
if (k != null && p != null) {
if (Lang.get("questDungeonsKicked").length() > 0) {
Lang.send(k, ChatColor.RED + Lang.get(k, "questDungeonsKicked").replace("<player>", k.getName()));
}
if (Lang.get("questDungeonsLeave").length() > 0) {
Lang.send(p, ChatColor.RED + Lang.get(p, "questDungeonsLeave").replace("<player>", p.getName()));
}
}
}
}*/
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************************
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
@ -25,7 +25,7 @@ import com.alessiodp.parties.api.events.bukkit.player.BukkitPartiesPlayerPostLea
import me.blackvein.quests.util.Lang;
public class PartiesListener implements Listener {
@EventHandler
public void onPartyCreate(final BukkitPartiesPartyPostCreateEvent event) {
if (event.getCreator() != null) {
@ -37,7 +37,7 @@ public class PartiesListener implements Listener {
}
}
}
@EventHandler
public void onPlayerJoinEvent(final BukkitPartiesPlayerPostJoinEvent event) {
final Player p = Bukkit.getServer().getPlayer(event.getPartyPlayer().getPlayerUUID());
@ -46,7 +46,7 @@ public class PartiesListener implements Listener {
event.getParty().broadcastMessage(ChatColor.GREEN + Lang.get("questPartiesJoinBroadcast").replace("<player>", event.getPartyPlayer().getName()), event.getPartyPlayer());
}
}
@EventHandler
public void onPlayerLeaveEvent(final BukkitPartiesPlayerPostLeaveEvent event) {
final Player p = Bukkit.getServer().getPlayer(event.getPartyPlayer().getPlayerUUID());

View File

@ -0,0 +1,87 @@
/*******************************************************************************************************
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************************************/
package me.blackvein.quests.listeners;
import me.blackvein.quests.util.Lang;
import me.pikamug.unite.api.events.PartyCreateEvent;
import me.pikamug.unite.api.events.PartyDeleteEvent;
import me.pikamug.unite.api.events.PartyJoinEvent;
import me.pikamug.unite.api.events.PartyLeaveEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class UniteListener implements Listener {
@EventHandler
public void onPartyCreate(final PartyCreateEvent event) {
if (event.getCreator() != null) {
final Player p = Bukkit.getServer().getPlayer(event.getCreator());
if (p != null) {
if (Lang.get("questPartiesCreate").length() > 0) {
Lang.send(p, ChatColor.YELLOW + Lang.get("questPartiesCreate"));
}
}
}
}
@EventHandler
public void onPartyDelete(final PartyDeleteEvent event) {
if (event.getDisbander() != null) {
final Player p = Bukkit.getServer().getPlayer(event.getDisbander());
if (p != null) {
if (Lang.get("questDungeonsDisband").length() > 0) {
Lang.send(p, ChatColor.RED + Lang.get("questDungeonsDisband"));
}
}
}
}
@EventHandler
public void onPlayerJoinEvent(final PartyJoinEvent event) {
final Player p = Bukkit.getServer().getPlayer(event.getPlayer());
if (p != null && Lang.get("questPartiesLeave").length() > 0) {
Lang.send(p, ChatColor.GREEN + Lang.get(p, "questPartiesJoin"));
if (Lang.get("questPartiesJoinBroadcast").length() > 0) {
for (Player online : Bukkit.getOnlinePlayers()) {
if (event.getPlayer().equals(online.getUniqueId())) {
continue;
}
if (event.getPartyProvider().areInSameParty(p, online)) {
online.sendMessage(ChatColor.GREEN + Lang.get("questPartiesJoinBroadcast").replace("<player>", p.getName()));
}
}
}
}
}
@EventHandler
public void onPlayerLeaveEvent(final PartyLeaveEvent event) {
final Player p = Bukkit.getServer().getPlayer(event.getPlayer());
if (p != null && Lang.get("questPartiesLeave").length() > 0) {
Lang.send(p, ChatColor.RED + Lang.get(p, "questPartiesLeave"));
if (Lang.get("questPartiesLeaveBroadcast").length() > 0) {
for (Player online : Bukkit.getOnlinePlayers()) {
if (event.getPlayer().equals(online.getUniqueId())) {
continue;
}
if (event.getPartyProvider().areInSameParty(p, online)) {
online.sendMessage(ChatColor.RED + Lang.get("questPartiesLeaveBroadcast").replace("<player>", p.getName()));
}
}
}
}
}
}

View File

@ -6,7 +6,7 @@ description: An extensive questing system.
website: https://www.spigotmc.org/resources/quests.3711/
dev-url: https://github.com/PikaMug/Quests
author: PikaMug
softdepend: [Citizens, CitizensBooks, Denizen, DungeonsXL, GPS, Heroes, mcMMO, Parties, PhatLoots, PlaceholderAPI, Vault, WorldGuard]
softdepend: [Citizens, CitizensBooks, Denizen, DungeonsXL, GPS, Heroes, mcMMO, Parties, PhatLoots, PlaceholderAPI, Unite, Vault, WorldGuard]
permissions:
quests.*:
description: Access ALL Quests functionality