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;
|
package me.blackvein.quests;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
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.ConversationAbandonedEvent;
|
||||||
import org.bukkit.conversations.ConversationAbandonedListener;
|
import org.bukkit.conversations.ConversationAbandonedListener;
|
||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
||||||
@ -134,9 +138,15 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
|
|||||||
|
|
||||||
public void sendInvite(Quester target){
|
public void sendInvite(Quester target){
|
||||||
|
|
||||||
|
//Temporary.
|
||||||
|
if (factory == null) {
|
||||||
|
this.initFactory();
|
||||||
|
}
|
||||||
|
|
||||||
Player player = target.getPlayer();
|
Player player = target.getPlayer();
|
||||||
|
Conversation conversation = factory.buildConversation((Conversable)player);
|
||||||
|
conversation.getContext().setSessionData("inviter", getLeader().getPlayer().getName());
|
||||||
|
conversation.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkSize(){
|
public void checkSize(){
|
||||||
@ -160,9 +170,10 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void conversationAbandoned(ConversationAbandonedEvent cae) {
|
public void conversationAbandoned(ConversationAbandonedEvent event) {
|
||||||
//TODO: support this.
|
//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 {
|
private static class PartyPrefix implements ConversationPrefix {
|
||||||
@ -190,24 +201,33 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
|
|||||||
@Override
|
@Override
|
||||||
public Prompt acceptInput(ConversationContext context, String s) {
|
public Prompt acceptInput(ConversationContext context, String s) {
|
||||||
|
|
||||||
Player player = (Player) context.getForWhom();
|
Player invited = (Player) context.getForWhom();
|
||||||
|
|
||||||
if (s.equalsIgnoreCase("Yes")) {
|
if (s.equalsIgnoreCase("Yes")) {
|
||||||
|
|
||||||
String inviterName = (String) context.getSessionData("inviter");
|
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;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
|
||||||
} else if (s.equalsIgnoreCase("No")) {
|
} else if (s.equalsIgnoreCase("No")) {
|
||||||
|
|
||||||
|
String inviterName = (String) context.getSessionData("inviter");
|
||||||
|
|
||||||
player.sendMessage(partyPrefix + YELLOW + "Declined invite.");
|
invited.sendMessage(partyPrefix + YELLOW + "Declined invite.");
|
||||||
|
Bukkit.getPlayerExact(inviterName).sendMessage(partyPrefix + GREEN + invited.getName() + YELLOW + " has declined your invitation.");
|
||||||
|
|
||||||
return Prompt.END_OF_CONVERSATION;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
player.sendMessage(RED + "Invalid choice. Type \'Yes\' or \'No\'");
|
invited.sendMessage(RED + "Invalid choice. Type \'Yes\' or \'No\'");
|
||||||
return new InvitePrompt();
|
return new InvitePrompt();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.conversations.Conversable;
|
import org.bukkit.conversations.Conversable;
|
||||||
|
import org.bukkit.conversations.Conversation;
|
||||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||||
import org.bukkit.conversations.ConversationAbandonedListener;
|
import org.bukkit.conversations.ConversationAbandonedListener;
|
||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
||||||
@ -1045,7 +1046,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
LinkedList<Quester> members = party.getMembers();
|
LinkedList<Quester> members = party.getMembers();
|
||||||
|
|
||||||
player.sendMessage(PURPLE + "- " + PINK + "Party" + PURPLE + " -");
|
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);
|
player.sendMessage(PINK + "" + BOLD + "Leader: " + RESET + "" + PINK + leader.name);
|
||||||
if(members.isEmpty())
|
if(members.isEmpty())
|
||||||
player.sendMessage(PURPLE + "" + BOLD + "Members: " + RESET + "" + PURPLE + "(None)");
|
player.sendMessage(PURPLE + "" + BOLD + "Members: " + RESET + "" + PURPLE + "(None)");
|
||||||
@ -1094,10 +1095,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(found != null){
|
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){
|
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{
|
}else{
|
||||||
player.sendMessage(Party.partyPrefix + RED + "" + BOLD + found.getName() + RESET + "" + RED + " is already in a party!");
|
player.sendMessage(Party.partyPrefix + RED + "" + BOLD + found.getName() + RESET + "" + RED + " is already in a party!");
|
||||||
|
Loading…
Reference in New Issue
Block a user