mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-14 14:45:41 +01:00
Supply external conversation hooks, part 14
This commit is contained in:
parent
4d183edaea
commit
35d326d74f
@ -1337,7 +1337,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((available.size() + rows) <= ((page * rows)) || available.size() == 0) {
|
if ((available.size() + rows) <= (page * rows) || available.size() == 0) {
|
||||||
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist"));
|
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle"));
|
player.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle"));
|
||||||
@ -1360,7 +1360,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
player.sendMessage(ChatColor.GOLD + msg);
|
player.sendMessage(ChatColor.GOLD + msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((quests.size() + rows) <= ((page * rows)) || quests.size() == 0) {
|
if ((quests.size() + rows) <= (page * rows) || quests.size() == 0) {
|
||||||
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist"));
|
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle"));
|
player.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle"));
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package me.blackvein.quests.events.command;
|
||||||
|
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quester;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the /quests list command is run by a player
|
||||||
|
*/
|
||||||
|
public class QuestsCommandPreQuestsListEvent extends QuestsCommandEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private final int page;
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public QuestsCommandPreQuestsListEvent(Quester quester, int page) {
|
||||||
|
super(quester);
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPage() {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,7 @@ import me.blackvein.quests.Requirements;
|
|||||||
import me.blackvein.quests.Stage;
|
import me.blackvein.quests.Stage;
|
||||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent;
|
import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent;
|
||||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent;
|
import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent;
|
||||||
|
import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent;
|
||||||
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
||||||
import me.blackvein.quests.exceptions.InvalidStageException;
|
import me.blackvein.quests.exceptions.InvalidStageException;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
@ -724,22 +725,38 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void questsList(final CommandSender cs, String[] args) {
|
private void questsList(final CommandSender cs, String[] args) {
|
||||||
if (((Player) cs).hasPermission("quests.list")) {
|
Player player = (Player)cs;
|
||||||
|
if (player.hasPermission("quests.list")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
plugin.listQuests((Player) cs, 1);
|
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
|
QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, 1);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
|
if (preEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.listQuests(player, 1);
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
int page;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
page = Integer.parseInt(args[1]);
|
page = Integer.parseInt(args[1]);
|
||||||
if (page < 1) {
|
if (page < 1) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionPosNum"));
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionPosNum"));
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
|
QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, page);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
|
if (preEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.listQuests(player, page);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionNum"));
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionNum"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.listQuests((Player) cs, page);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
|
Loading…
Reference in New Issue
Block a user