mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Working party system, still need to fix party chat to not be jibberish though.
This commit is contained in:
parent
2a1ff28af2
commit
42cb17db5b
@ -448,6 +448,20 @@ public class vMinecraftChat {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean partyChat(Player player, String message){
|
||||
if(vMinecraftUsers.getProfile(player).inParty()){
|
||||
String partychat = Colors.Green + "(" + getName(player) + Colors.Green + ") ";
|
||||
for (Player p: etc.getServer().getPlayerList()){
|
||||
if (p != null){
|
||||
if (vMinecraftUsers.getProfile(p).inParty() && (vMinecraftUsers.getProfile(p).getParty().equals(vMinecraftUsers.getProfile(player).getParty()))){
|
||||
sendMessage(player, p, partychat + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
//Function: quote
|
||||
|
@ -54,6 +54,11 @@ public class vMinecraftCommands{
|
||||
cl.register("/promote", "promote", "Promote a player one rank");
|
||||
cl.register("/demote", "demote", "Demote a player one rank");
|
||||
|
||||
//Party
|
||||
cl.register("/party", "party");
|
||||
cl.register("/pquit", "partyquit");
|
||||
cl.register("/p", "partychat");
|
||||
|
||||
//Movement
|
||||
cl.register("/freeze", "freeze");
|
||||
cl.register("/tp", "teleport");
|
||||
@ -179,6 +184,39 @@ public class vMinecraftCommands{
|
||||
.globalmessages());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
public static int partychat(Player player, String[] args){
|
||||
if(vMinecraftUsers.getProfile(player).inParty()){
|
||||
String message = args.toString();
|
||||
vMinecraftChat.partyChat(player, message);
|
||||
return EXIT_SUCCESS;
|
||||
} else{
|
||||
return EXIT_FAIL;
|
||||
}
|
||||
}
|
||||
public static int party(Player player, String[] args){
|
||||
if(vMinecraftUsers.getProfile(player).inParty()){
|
||||
player.sendMessage(Colors.Red + "You are already in a party, use /pquit to leave it");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if(args[0] != null) {
|
||||
vMinecraftUsers.getProfile(player).setParty(args[0]);
|
||||
player.sendMessage(Colors.DarkPurple + "Party set to " + args[0]);
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
player.sendMessage(Colors.Red + "Correct usage is /party [partyname]");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
public static int partyquit(Player player, String[] args){
|
||||
if(vMinecraftUsers.getProfile(player).inParty()){
|
||||
vMinecraftUsers.getProfile(player).removeParty();
|
||||
player.sendMessage(Colors.LightGreen + "Party successfully removed");
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
player.sendMessage(Colors.Red + "You are not in a party");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
public static int tpback(Player player, String[] args){
|
||||
if(player.canUseCommand("/tpback")){
|
||||
String tpxyz = vMinecraftUsers.getProfile(player).getTpxyz();
|
||||
|
@ -165,6 +165,16 @@ public class vMinecraftListener extends PluginListener {
|
||||
if(vMinecraftSettings.getInstance().isEzModo(dplayer.getName())){
|
||||
return true;
|
||||
}
|
||||
if(attacker.isPlayer()){
|
||||
Player aplayer = attacker.getPlayer();
|
||||
if(vMinecraftUsers.getProfile(dplayer).inParty()){
|
||||
if(vMinecraftParty.inSameParty(aplayer, dplayer)){
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
12
vMinecraftParty.java
Normal file
12
vMinecraftParty.java
Normal file
@ -0,0 +1,12 @@
|
||||
import java.util.ArrayList;
|
||||
public class vMinecraftParty {
|
||||
|
||||
//Check if two players are in the same party
|
||||
public static boolean inSameParty(Player playera, Player playerb){
|
||||
if(vMinecraftUsers.getProfile(playera).getParty().equals(vMinecraftUsers.getProfile(playerb).getParty())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -54,6 +54,7 @@ public class vMinecraftSettings {
|
||||
//An array of blocks that won't catch on fire
|
||||
static public ArrayList<Integer> fireblockan;
|
||||
|
||||
|
||||
private PropertiesFile properties;
|
||||
String file = "vminecraft.properties";
|
||||
public String rules[] = new String[0];
|
||||
|
@ -153,6 +153,7 @@ class PlayerList
|
||||
nickName,
|
||||
tag,
|
||||
suffix,
|
||||
party,
|
||||
tpxyz;
|
||||
|
||||
private boolean dead;
|
||||
@ -183,6 +184,8 @@ class PlayerList
|
||||
nickName = new String();
|
||||
suffix = new String();
|
||||
tpxyz = new String();
|
||||
party = new String();
|
||||
party = null;
|
||||
defaultColor = 'f';
|
||||
ignoreList = new ArrayList<String>();
|
||||
aliasList = new commandList();
|
||||
@ -505,6 +508,27 @@ class PlayerList
|
||||
nickName = newNick;
|
||||
save();
|
||||
}
|
||||
//Store the player's party
|
||||
public void setParty(String newParty)
|
||||
{
|
||||
party = newParty;
|
||||
save();
|
||||
}
|
||||
//Retrieve the player's party
|
||||
public String getParty() {return party;}
|
||||
//Remove party
|
||||
public void removeParty() {
|
||||
party = null;
|
||||
save();
|
||||
}
|
||||
//Retrieve whether or not the player is in a party
|
||||
public boolean inParty() {
|
||||
if(party != null){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
//Function: getNick
|
||||
|
Loading…
Reference in New Issue
Block a user