mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Admin and Party chat events
This commit is contained in:
parent
7c01fced68
commit
54e945bf14
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class ACommand implements CommandExecutor {
|
||||
@ -26,6 +27,13 @@ public class ACommand implements CommandExecutor {
|
||||
aMessage = aMessage + " " + args[i];
|
||||
}
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return true;
|
||||
|
||||
aMessage = chatEvent.getMessage();
|
||||
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
|
||||
|
||||
Bukkit.getLogger().info("[A]<*Console*> " + aMessage);
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class PCommand implements CommandExecutor {
|
||||
@ -27,6 +28,13 @@ public class PCommand implements CommandExecutor {
|
||||
pMessage = pMessage + " " + args[i];
|
||||
}
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], pMessage);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return true;
|
||||
|
||||
pMessage = chatEvent.getMessage();
|
||||
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") ";
|
||||
|
||||
Bukkit.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage);
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to the admin chat channel
|
||||
*/
|
||||
public class McMMOAdminChatEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private String sender, message;
|
||||
|
||||
public McMMOAdminChatEvent(String sender, String message) {
|
||||
this.sender = sender;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the player who sent the chat, or "Console"
|
||||
*/
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String message that will be sent
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message String message to be sent in chat
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to a party channel
|
||||
*/
|
||||
public class McMMOPartyChatEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private String sender, party, message;
|
||||
|
||||
public McMMOPartyChatEvent(String sender, String party, String message) {
|
||||
this.sender = sender;
|
||||
this.party = party;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the player who sent the chat, or "Console"
|
||||
*/
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the party the message will be sent to
|
||||
*/
|
||||
public String getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String message that will be sent
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message String message to be sent in chat
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
@ -39,6 +39,8 @@ import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
@ -300,9 +302,7 @@ public class mcPlayerListener implements Listener {
|
||||
ChatColor color = null;
|
||||
|
||||
if (partyChat || adminChat) {
|
||||
|
||||
if (partyChat) {
|
||||
|
||||
if (!PP.inParty()) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
return;
|
||||
@ -310,6 +310,13 @@ public class mcPlayerListener implements Listener {
|
||||
|
||||
color = ChatColor.GREEN;
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return;
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Party.getInstance().inSameParty(player, x)) {
|
||||
intendedRecipients.add(x);
|
||||
@ -321,6 +328,14 @@ public class mcPlayerListener implements Listener {
|
||||
|
||||
if (adminChat) {
|
||||
color = ChatColor.AQUA;
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return;
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (x.isOp() || mcPermissions.getInstance().adminChat(x)) {
|
||||
intendedRecipients.add(x);
|
||||
|
Loading…
Reference in New Issue
Block a user