Permalink
Browse files

Add PlayerChatEvent

  • Loading branch information...
nickrobson committed Jul 26, 2017
1 parent c8fcda9 commit 88223a941191eb604eaec022e7080d4b3f7c84af
@@ -160,6 +160,14 @@ default void sendMessage(String message) {
*/
void kick(ChatComponent reason);
/**
* Sends a message in chat as this player.
* Commands are not handled.
*
* @param msg The message.
*/
void chat(String msg);
/**
* Obtains the game mode which the player is currently
* using.
@@ -0,0 +1,44 @@
/*
* Trident - A Multithreaded Server Alternative
* Copyright 2017 The TridentSDK Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.tridentsdk.event.player;
import java.util.concurrent.atomic.AtomicBoolean;
import net.tridentsdk.entity.living.Player;
import net.tridentsdk.event.Cancellable;
/**
* @author Nick Robson
*/
public abstract class CancellablePlayerEvent extends PlayerEvent implements Cancellable {
private final AtomicBoolean cancelled = new AtomicBoolean(false);
public CancellablePlayerEvent(Player player) {
super(player);
}
@Override
public boolean isCancelled() {
return this.cancelled.get();
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled.set(cancelled);
}
}
@@ -0,0 +1,46 @@
/*
* Trident - A Multithreaded Server Alternative
* Copyright 2017 The TridentSDK Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.tridentsdk.event.player;
import java.util.Collection;
import java.util.Objects;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import net.tridentsdk.entity.living.Player;
import net.tridentsdk.ui.chat.ChatComponent;
/**
* @author Nick Robson
*/
@Getter
@Setter
public class PlayerChatEvent extends CancellablePlayerEvent {
@NonNull
private ChatComponent chatComponent;
@NonNull
private Collection<Player> recipients;
public PlayerChatEvent(Player player, ChatComponent chatComponent, Collection<Player> recipients) {
super(player);
this.chatComponent = Objects.requireNonNull(chatComponent, "chat component cannot be null");
this.recipients = Objects.requireNonNull(recipients, "recipients cannot be null");
}
}
@@ -18,6 +18,7 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import net.tridentsdk.entity.living.Player;
import net.tridentsdk.event.Event;
import net.tridentsdk.event.Supertype;
@@ -36,5 +37,6 @@
@AllArgsConstructor
public class PlayerEvent implements Event {
@Getter
@NonNull
private final Player player;
}
}
@@ -137,6 +137,11 @@ public void kick(ChatComponent reason) {
}
@Override
public void chat(String msg) {
}
@Override
public GameMode getGameMode() {
return null;

0 comments on commit 88223a9

Please sign in to comment.