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

@ -19,6 +19,7 @@ Version 1.3.06-dev
! Changed getPlayerProfile function to work for online & offline users ! Changed getPlayerProfile function to work for online & offline users
! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts) ! 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 Version 1.3.05
+ Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%) + 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, mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable,
mcremoveEnable, mcgodEnable, mcabilityEnable, mctopEnable, mcremoveEnable, mcgodEnable, mcabilityEnable, mctopEnable,
addlevelsEnable, mcrefreshEnable, aEnable, pEnable; addlevelsEnable, mcrefreshEnable, aEnable, pEnable;
public static Boolean aDisplayNames, pDisplayNames;
public static int ptpCommandCooldown; public static int ptpCommandCooldown;
public static Boolean donateMessage; public static Boolean donateMessage;
@ -460,9 +459,6 @@ public class LoadProperties extends ConfigLoader{
aEnable = config.getBoolean("Commands.a.Enabled", true); aEnable = config.getBoolean("Commands.a.Enabled", true);
pEnable = config.getBoolean("Commands.p.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); ptpCommandCooldown = config.getInt("Commands.ptp.Cooldown", 30);
animalXP = config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); animalXP = config.getDouble("Experience.Combat.Multiplier.Animals", 1.0);

View File

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

View File

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