mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Rewrote how party chat works, now you can use /p to toggle it on or off and ! prefix to enter party chat just like admin chat.
This commit is contained in:
parent
6cd41467c5
commit
e894f14989
@ -294,7 +294,7 @@ public class vChat {
|
|||||||
output = player.getName();
|
output = player.getName();
|
||||||
|
|
||||||
//Add the color if there is one
|
//Add the color if there is one
|
||||||
if(player.getColor() != null && player.getColor() != "")
|
if(player.getColor() != null && !"".equals(player.getColor()))
|
||||||
output = player.getColor().substring(0,2) + output;
|
output = player.getColor().substring(0,2) + output;
|
||||||
|
|
||||||
//Add the tag if there is one
|
//Add the tag if there is one
|
||||||
@ -448,6 +448,10 @@ public class vChat {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public static boolean partyChat(Player player, String message){
|
public static boolean partyChat(Player player, String message){
|
||||||
|
if(vConfig.getInstance().partyChat()){
|
||||||
|
//Cut off the ! prefix
|
||||||
|
if(message.startsWith("!"))
|
||||||
|
message = message.substring(1, message.length());
|
||||||
if(vUsers.getProfile(player).inParty()){
|
if(vUsers.getProfile(player).inParty()){
|
||||||
String partychat = Colors.Green + "(" + getName(player) + Colors.Green + ") ";
|
String partychat = Colors.Green + "(" + getName(player) + Colors.Green + ") ";
|
||||||
for (Player p: etc.getServer().getPlayerList()){
|
for (Player p: etc.getServer().getPlayerList()){
|
||||||
@ -459,7 +463,9 @@ public class vChat {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
|
43
vCom.java
43
vCom.java
@ -67,7 +67,7 @@ private static HashMap<String, Player> hidden = new HashMap<String, Player>();
|
|||||||
//Party
|
//Party
|
||||||
cl.register("/party", "party");
|
cl.register("/party", "party");
|
||||||
cl.register("/pquit", "partyquit");
|
cl.register("/pquit", "partyquit");
|
||||||
cl.register("/p", "partychat");
|
cl.register("/p", "partyChatToggle", "Toggles party chat on or off");
|
||||||
|
|
||||||
//Movement
|
//Movement
|
||||||
cl.register("/freeze", "freeze");
|
cl.register("/freeze", "freeze");
|
||||||
@ -269,19 +269,6 @@ private static HashMap<String, Player> hidden = new HashMap<String, Player>();
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static int partychat(Player player, String[] args){
|
|
||||||
if (args.length < 1) {
|
|
||||||
player.sendMessage(Colors.Rose + "Usage is /p [Message]");
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
if(vUsers.getProfile(player).inParty()){
|
|
||||||
String str = etc.combineSplit(0, args, " ");
|
|
||||||
vChat.partyChat(player, str);
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
} else{
|
|
||||||
return EXIT_FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static int party(Player player, String[] args){
|
public static int party(Player player, String[] args){
|
||||||
if(vUsers.getProfile(player).inParty()){
|
if(vUsers.getProfile(player).inParty()){
|
||||||
player.sendMessage(Colors.Red + "You are already in a party, use /pquit to leave it");
|
player.sendMessage(Colors.Red + "You are already in a party, use /pquit to leave it");
|
||||||
@ -1057,7 +1044,29 @@ private static HashMap<String, Player> hidden = new HashMap<String, Player>();
|
|||||||
}
|
}
|
||||||
return EXIT_FAIL;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
//Party chat toggle
|
||||||
|
public static int partyChatToggle(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//Check if party chat is even enabled befor executing anymore code
|
||||||
|
if(!vConfig.getInstance().partyChat()) return EXIT_FAIL;
|
||||||
|
//Check if the player is admin toggled, and if so remove them from that array
|
||||||
|
if(vConfig.getInstance().isAdminToggled(player.getName())){
|
||||||
|
vConfig.getInstance().removeAdminToggled(player.getName());
|
||||||
|
}
|
||||||
|
//Make sure the user has access to the command
|
||||||
|
if(!player.canUseCommand("/p")) return EXIT_FAIL;
|
||||||
|
|
||||||
|
//If the player is already toggled for admin chat, remove them
|
||||||
|
if (vConfig.getInstance().isPartyToggled(null)) {
|
||||||
|
player.sendMessage(Colors.Red + "Party Chat Toggle = off");
|
||||||
|
vConfig.getInstance().removeAdminToggled(player.getName());
|
||||||
|
//Otherwise include them
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Colors.Blue + "Party Chat Toggled on");
|
||||||
|
vConfig.getInstance().addAdminToggled(player.getName());
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: adminChatToggle (/a)
|
//Function: adminChatToggle (/a)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
@ -1068,6 +1077,10 @@ private static HashMap<String, Player> hidden = new HashMap<String, Player>();
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static int adminChatToggle(Player player, String[] args)
|
public static int adminChatToggle(Player player, String[] args)
|
||||||
{
|
{
|
||||||
|
//Check if the player is party toggled, and if so remove them from that array
|
||||||
|
if(vConfig.getInstance().isPartyToggled(player.getName())){
|
||||||
|
vConfig.getInstance().removePartyToggled(player.getName());
|
||||||
|
}
|
||||||
//Make sure the user has access to the command
|
//Make sure the user has access to the command
|
||||||
if(!player.canUseCommand("/a")) return EXIT_FAIL;
|
if(!player.canUseCommand("/a")) return EXIT_FAIL;
|
||||||
|
|
||||||
|
10
vConfig.java
10
vConfig.java
@ -18,6 +18,7 @@ public class vConfig {
|
|||||||
//The feature settings
|
//The feature settings
|
||||||
static boolean toggle = true,
|
static boolean toggle = true,
|
||||||
adminChat = false,
|
adminChat = false,
|
||||||
|
partyChat = false,
|
||||||
greentext = false,
|
greentext = false,
|
||||||
FFF = false,
|
FFF = false,
|
||||||
quakeColors = false,
|
quakeColors = false,
|
||||||
@ -52,6 +53,8 @@ public class vConfig {
|
|||||||
static ArrayList<String> frozenplayers = new ArrayList<String>();
|
static ArrayList<String> frozenplayers = new ArrayList<String>();
|
||||||
//An array of players currently toggled for admin chat
|
//An array of players currently toggled for admin chat
|
||||||
static ArrayList<String> adminChatList = new ArrayList<String>();
|
static ArrayList<String> adminChatList = new ArrayList<String>();
|
||||||
|
//An array of player currently toggled for party chat
|
||||||
|
static ArrayList<String> partyChatList = new ArrayList<String>();
|
||||||
//An array of blocks that won't catch on fire
|
//An array of blocks that won't catch on fire
|
||||||
static public ArrayList<Integer> fireblockan;
|
static public ArrayList<Integer> fireblockan;
|
||||||
|
|
||||||
@ -140,6 +143,8 @@ public class vConfig {
|
|||||||
writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n");
|
writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n");
|
||||||
writer.write("#The Random Death messages, seperate them by comma. All death messages start with the player name and a space.\r\n");
|
writer.write("#The Random Death messages, seperate them by comma. All death messages start with the player name and a space.\r\n");
|
||||||
writer.write("deathMessages=is no more,died horribly,went peacefully\r\n");
|
writer.write("deathMessages=is no more,died horribly,went peacefully\r\n");
|
||||||
|
writer.write("#Enable whether or not players can toggle party chat");
|
||||||
|
writer.write("partychat=true");
|
||||||
writer.write("hiddendistance=1024");
|
writer.write("hiddendistance=1024");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.log(Level.SEVERE, "Exception while creating " + location, e);
|
log.log(Level.SEVERE, "Exception while creating " + location, e);
|
||||||
@ -164,6 +169,7 @@ public class vConfig {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
adminChat = properties.getBoolean("adminchat",true);
|
adminChat = properties.getBoolean("adminchat",true);
|
||||||
|
partyChat = properties.getBoolean("partychat",true);
|
||||||
playerspawn = properties.getBoolean("playerspawn",true);
|
playerspawn = properties.getBoolean("playerspawn",true);
|
||||||
greentext = properties.getBoolean("QuotesAreGreen",true);
|
greentext = properties.getBoolean("QuotesAreGreen",true);
|
||||||
FFF = properties.getBoolean("FFF",true);
|
FFF = properties.getBoolean("FFF",true);
|
||||||
@ -223,6 +229,7 @@ public class vConfig {
|
|||||||
//Use: Returns if the feature is enabled
|
//Use: Returns if the feature is enabled
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public boolean adminchat() {return adminChat;}
|
public boolean adminchat() {return adminChat;}
|
||||||
|
public boolean partyChat() {return partyChat;}
|
||||||
public boolean adminChatToggle() {return cmdAdminToggle;}
|
public boolean adminChatToggle() {return cmdAdminToggle;}
|
||||||
public boolean greentext() {return greentext;}
|
public boolean greentext() {return greentext;}
|
||||||
public boolean FFF() {return FFF;}
|
public boolean FFF() {return FFF;}
|
||||||
@ -258,9 +265,12 @@ public class vConfig {
|
|||||||
public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
|
public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
|
||||||
public boolean isFrozen(String playerName) {return frozenplayers.contains(playerName);}
|
public boolean isFrozen(String playerName) {return frozenplayers.contains(playerName);}
|
||||||
public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
|
public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
|
||||||
|
public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);}
|
||||||
public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
|
public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
|
||||||
|
public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));}
|
||||||
public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));}
|
public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));}
|
||||||
public void addEzModo(String playerName) {ezModo.add(playerName);}
|
public void addEzModo(String playerName) {ezModo.add(playerName);}
|
||||||
|
public void addPartyToggled(String playerName) {partyChatList.add(playerName);}
|
||||||
public void addAdminToggled(String playerName) {adminChatList.add(playerName);}
|
public void addAdminToggled(String playerName) {adminChatList.add(playerName);}
|
||||||
public void addFrozen(String playerName) {frozenplayers.add(playerName);}
|
public void addFrozen(String playerName) {frozenplayers.add(playerName);}
|
||||||
public void removeFrozen (String playerName) {frozenplayers.remove(frozenplayers.indexOf(playerName));}
|
public void removeFrozen (String playerName) {frozenplayers.remove(frozenplayers.indexOf(playerName));}
|
||||||
|
@ -35,18 +35,19 @@ public class vListener extends PluginListener {
|
|||||||
|
|
||||||
public boolean onChat(Player player, String message){
|
public boolean onChat(Player player, String message){
|
||||||
|
|
||||||
//Quote (Greentext)
|
|
||||||
if (message.startsWith("@") ||
|
if (message.startsWith("@") ||
|
||||||
vConfig.getInstance().isAdminToggled(player.getName()))
|
vConfig.getInstance().isAdminToggled(player.getName()))
|
||||||
return vChat.adminChat(player, message);
|
return vChat.adminChat(player, message);
|
||||||
|
//PartyChat
|
||||||
|
if((message.startsWith("!")) ||
|
||||||
|
vConfig.getInstance().isPartyToggled(player.getName()))
|
||||||
|
return vChat.partyChat(player, message);
|
||||||
|
//Quote (Greentext)
|
||||||
else if (message.startsWith(">"))
|
else if (message.startsWith(">"))
|
||||||
return vChat.quote(player, message);
|
return vChat.quote(player, message);
|
||||||
|
|
||||||
//Rage (FFF)
|
//Rage (FFF)
|
||||||
else if (message.startsWith("FFF"))
|
else if (message.startsWith("FFF"))
|
||||||
return vChat.rage(player, message);
|
return vChat.rage(player, message);
|
||||||
|
|
||||||
//Send through quakeColors otherwise
|
//Send through quakeColors otherwise
|
||||||
else
|
else
|
||||||
return vChat.quakeColors(player, message);
|
return vChat.quakeColors(player, message);
|
||||||
@ -163,16 +164,22 @@ public class vListener extends PluginListener {
|
|||||||
|
|
||||||
public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
|
public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
|
||||||
//Invincibility for EzModo players
|
//Invincibility for EzModo players
|
||||||
|
//This also checks if the defender is a player
|
||||||
if(defender.isPlayer()){
|
if(defender.isPlayer()){
|
||||||
Player dplayer = defender.getPlayer();
|
Player dplayer = defender.getPlayer();
|
||||||
if(vConfig.getInstance().isEzModo(dplayer.getName())){
|
if(vConfig.getInstance().isEzModo(dplayer.getName())){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//So far we've checked if the defender is a player, next we check if the attacker is one
|
||||||
if(attacker != null && attacker.isPlayer()){
|
if(attacker != null && attacker.isPlayer()){
|
||||||
|
//If the attacker is not null and is a player we assign the attacker to a new player variable
|
||||||
Player aplayer = attacker.getPlayer();
|
Player aplayer = attacker.getPlayer();
|
||||||
|
//Then we preceed to check if they are in the same party, the code for this is stored elsewhere
|
||||||
if(vUsers.getProfile(dplayer).inParty()){
|
if(vUsers.getProfile(dplayer).inParty()){
|
||||||
|
//If they are in the same party we tell onDamage to return true stopping the damage code from executing
|
||||||
if(vmc.inSameParty(aplayer, dplayer)){
|
if(vmc.inSameParty(aplayer, dplayer)){
|
||||||
return true;
|
return true;
|
||||||
|
//if they aren't we tell it to return false, making the damage happen
|
||||||
} else{
|
} else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user