mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-05 07:04:44 +02:00
PlayerListener cleanup
This commit is contained in:
src/main/java/com/gmail/nossr50
@ -76,7 +76,7 @@ public class BlockChecks {
|
||||
* @param block Block to check
|
||||
* @return true if the block should allow ability activation, false otherwise
|
||||
*/
|
||||
public static boolean abilityBlockCheck(Block block) {
|
||||
public static boolean canActivateAbilities(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||
@ -151,7 +151,7 @@ public class BlockChecks {
|
||||
* @param block The block to check
|
||||
* @return true if the block can be made mossy, false otherwise
|
||||
*/
|
||||
public static boolean makeMossy(Block block) {
|
||||
public static boolean canMakeMossy(Block block) {
|
||||
switch (block.getType()) {
|
||||
case COBBLESTONE:
|
||||
case DIRT:
|
||||
@ -314,4 +314,16 @@ public class BlockChecks {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canActivateHerbalism(Block block) {
|
||||
switch (block.getType()) {
|
||||
case DIRT:
|
||||
case GRASS:
|
||||
case SOIL:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
73
src/main/java/com/gmail/nossr50/util/ChatManager.java
Normal file
73
src/main/java/com/gmail/nossr50/util/ChatManager.java
Normal file
@ -0,0 +1,73 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class ChatManager {
|
||||
private mcMMO plugin;
|
||||
private Player player;
|
||||
private String playerName;
|
||||
private AsyncPlayerChatEvent event;
|
||||
|
||||
public ChatManager (mcMMO plugin, Player player, AsyncPlayerChatEvent event) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.playerName = player.getName();
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public void handleAdminChat() {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String adminMessage = chatEvent.getMessage();
|
||||
|
||||
plugin.getLogger().info("[A]<" + playerName + "> " + adminMessage);
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {playerName}) + adminMessage);
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void handlePartyChat() {
|
||||
Party party = Users.getProfile(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String partyMessage = chatEvent.getMessage();
|
||||
|
||||
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + partyMessage);
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + partyMessage);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user