Fixed party & admin chat handling

This commit is contained in:
GJ 2012-04-10 01:52:06 -04:00
parent 7a119facdf
commit 11a4fdfcd5
4 changed files with 26 additions and 37 deletions

View File

@ -18,7 +18,8 @@ Version 1.3.06-dev
! Changed PlayerProfile constructor to always take a boolean
! Changed getPlayerProfile function to work for online & offline users
! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts)
! Changed /addlevel command to work for offline users
! Changed /addlevel command to work for offline users
! Changed party & admin chat handling to be nicer to developers
Version 1.3.05
+ Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%)

View File

@ -25,7 +25,6 @@ public class LoadProperties extends ConfigLoader{
mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable,
mcremoveEnable, mcgodEnable, mcabilityEnable, mctopEnable,
addlevelsEnable, mcrefreshEnable, aEnable, pEnable;
public static Boolean aDisplayNames, pDisplayNames;
public static int ptpCommandCooldown;
public static Boolean donateMessage;
@ -460,9 +459,6 @@ public class LoadProperties extends ConfigLoader{
aEnable = config.getBoolean("Commands.a.Enabled", true);
pEnable = config.getBoolean("Commands.p.Enabled", true);
aDisplayNames = config.getBoolean("Commands.a.Display_Names", true);
pDisplayNames = config.getBoolean("Commands.p.Display_Names", true);
ptpCommandCooldown = config.getInt("Commands.ptp.Cooldown", 30);
animalXP = config.getDouble("Experience.Combat.Multiplier.Animals", 1.0);

View File

@ -1,5 +1,8 @@
package com.gmail.nossr50.listeners;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -291,51 +294,42 @@ public class mcPlayerListener implements Listener {
PlayerProfile PP = Users.getProfile(player);
boolean partyChat = PP.getPartyChatMode();
boolean adminChat = PP.getAdminChatMode();
Set<Player> recipients = event.getRecipients();
Set<Player> intendedRecipients = new HashSet<Player>();
String header = "";
if (partyChat || adminChat) {
event.setCancelled(true);
String name = "";
boolean displayNames = false;
ChatColor color = ChatColor.WHITE;
String logHeader = "";
/* Set the pChat & aChat specific stuff */
if (partyChat) {
if (!PP.inParty()) {
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
return;
}
displayNames = LoadProperties.pDisplayNames;
color = ChatColor.GREEN;
logHeader = "[P](" + PP.getParty() + ")<";
}
else if (adminChat) {
displayNames = LoadProperties.aDisplayNames;
color = ChatColor.AQUA;
logHeader = "[A]<";
header = ChatColor.GREEN + "[P] (" + PP.getParty() + ") ";
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (Party.getInstance().inSameParty(player, x)) {
intendedRecipients.add(x);
}
}
}
/* Format & display */
if (displayNames) {
name = player.getDisplayName();
}
else {
name = player.getName();
}
if (adminChat) {
header = ChatColor.AQUA + "[A] ";
String format = color + "(" + ChatColor.WHITE + name + color + ") " + event.getMessage();
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (partyChat && Party.getInstance().inSameParty(player, x))
x.sendMessage(format);
else if (adminChat && (x.isOp() || mcPermissions.getInstance().adminChat(x))) {
x.sendMessage(format);
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (x.isOp() || mcPermissions.getInstance().adminChat(x)) {
intendedRecipients.add(x);
}
}
}
Bukkit.getLogger().info(logHeader + name + ">" + event.getMessage());
recipients.retainAll(intendedRecipients);
event.setFormat(header + "<%1$s> " + ChatColor.WHITE + "%2$s");
}
}

View File

@ -315,10 +315,8 @@ Commands:
Cooldown: 30
p:
Enabled: true
Display_Names: true
a:
Enabled: true
Display_Names: true
#
# Settings for Spout features