mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-03 15:08:10 +01:00
+Able to invite players to party.
This commit is contained in:
parent
5842d10a08
commit
58b71e0084
@ -1,6 +1,10 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ConversationAbandonedListener;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
@ -134,9 +138,15 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
public void sendInvite(Quester target){
|
||||
|
||||
//Temporary.
|
||||
if (factory == null) {
|
||||
this.initFactory();
|
||||
}
|
||||
|
||||
Player player = target.getPlayer();
|
||||
|
||||
|
||||
Conversation conversation = factory.buildConversation((Conversable)player);
|
||||
conversation.getContext().setSessionData("inviter", getLeader().getPlayer().getName());
|
||||
conversation.begin();
|
||||
}
|
||||
|
||||
public void checkSize(){
|
||||
@ -160,9 +170,10 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void conversationAbandoned(ConversationAbandonedEvent cae) {
|
||||
public void conversationAbandoned(ConversationAbandonedEvent event) {
|
||||
//TODO: support this.
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
//Player player = (Player) event.getContext().getForWhom();
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
private static class PartyPrefix implements ConversationPrefix {
|
||||
@ -190,24 +201,33 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String s) {
|
||||
|
||||
Player player = (Player) context.getForWhom();
|
||||
Player invited = (Player) context.getForWhom();
|
||||
|
||||
if (s.equalsIgnoreCase("Yes")) {
|
||||
|
||||
String inviterName = (String) context.getSessionData("inviter");
|
||||
|
||||
//Quester quester =
|
||||
Quester quester = quests.getQuester(invited.getName());
|
||||
members.add(quester);
|
||||
|
||||
//send message to inviter and invited
|
||||
quester.getPlayer().sendMessage(partyPrefix + YELLOW + "Accepted invite.");
|
||||
Bukkit.getPlayerExact(inviterName).sendMessage(partyPrefix + GREEN + invited.getName() + YELLOW + " has accepted your invitation.");
|
||||
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
|
||||
} else if (s.equalsIgnoreCase("No")) {
|
||||
|
||||
player.sendMessage(partyPrefix + YELLOW + "Declined invite.");
|
||||
String inviterName = (String) context.getSessionData("inviter");
|
||||
|
||||
invited.sendMessage(partyPrefix + YELLOW + "Declined invite.");
|
||||
Bukkit.getPlayerExact(inviterName).sendMessage(partyPrefix + GREEN + invited.getName() + YELLOW + " has declined your invitation.");
|
||||
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(RED + "Invalid choice. Type \'Yes\' or \'No\'");
|
||||
invited.sendMessage(RED + "Invalid choice. Type \'Yes\' or \'No\'");
|
||||
return new InvitePrompt();
|
||||
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ConversationAbandonedListener;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
@ -1045,7 +1046,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
LinkedList<Quester> members = party.getMembers();
|
||||
|
||||
player.sendMessage(PURPLE + "- " + PINK + "Party" + PURPLE + " -");
|
||||
player.sendMessage(YELLOW + "" + BOLD + "Current Quest: " + RESET + "" + YELLOW + current != null ? (current.getName()) : "(None)");
|
||||
player.sendMessage(YELLOW + "" + BOLD + "Current Quest: " + RESET + "" + YELLOW + ((current != null) ? current.getName() : "(None)"));
|
||||
player.sendMessage(PINK + "" + BOLD + "Leader: " + RESET + "" + PINK + leader.name);
|
||||
if(members.isEmpty())
|
||||
player.sendMessage(PURPLE + "" + BOLD + "Members: " + RESET + "" + PURPLE + "(None)");
|
||||
@ -1094,10 +1095,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
|
||||
if(found != null){
|
||||
|
||||
if (found.getName().equals(player.getName())) {
|
||||
player.sendMessage(Party.partyPrefix + RED + "you can't invite yourself!");
|
||||
return true;
|
||||
}
|
||||
if(getQuester(found.getName()).getParty() == null){
|
||||
|
||||
//TODO: do stuff?
|
||||
//TODO: Invite player to party!
|
||||
party.sendMessage(Party.partyPrefix + PINK + "" + BOLD + player.getName() + RESET + "" + PINK + " invited: " + BOLD + found.getName() + RESET + "" + PINK + " to the party!" );
|
||||
party.sendInvite(getQuester(found.getName()));
|
||||
|
||||
}else{
|
||||
player.sendMessage(Party.partyPrefix + RED + "" + BOLD + found.getName() + RESET + "" + RED + " is already in a party!");
|
||||
|
Loading…
Reference in New Issue
Block a user