Created
March 10, 2018 05:26
-
-
Save Exerosis/9ba2ccb5b7e8834267c8af61c75ebefb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.penzzly.engine.core.components.chat; | |
| import com.penzzly.engine.architecture.base.Component; | |
| import com.penzzly.engine.core.components.command.CommandComponent; | |
| import org.bukkit.entity.Player; | |
| import org.bukkit.event.player.AsyncPlayerChatEvent; | |
| import java.util.HashSet; | |
| import java.util.Set; | |
| import static com.penzzly.engine.core.base.Events.listen; | |
| public class StaffChatComponent extends Component { | |
| public StaffChatComponent(CommandComponent commands) { | |
| final Set<Player> staffChat = new HashSet<>(); | |
| addChild(listen((AsyncPlayerChatEvent event) -> { | |
| if (staffChat.contains(event.getPlayer())) | |
| event.getRecipients().retainAll(staffChat); | |
| })); | |
| addChild(commands.onPlayerCommand("sc"::equals, (player, args) -> { | |
| if (!staffChat.add(player)) | |
| staffChat.remove(player); | |
| })); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment