Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Add API to use 1.7 chat features. Adds BUKKIT-5245 #8

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
dff7352
First draft
Ribesg Jul 17, 2014
0c577dc
More draft
Ribesg Jul 21, 2014
5375e34
Append a Message to another one
Ribesg Jul 21, 2014
a844dc3
Prevent modifying parts
Ribesg Jul 25, 2014
6c4cd36
Make Part mutable, add some methods
Ribesg Jul 25, 2014
d45527f
Implement new API
Ribesg Jul 25, 2014
734978a
Move hover data outside of Part, move inner classes outside of Message
Ribesg Jul 25, 2014
6ae81e6
Add test material & little modifications
Ribesg Jul 25, 2014
5ec90a0
Add equals() and hashCode() everywhere
Ribesg Jul 25, 2014
8af1389
Clean tabs and stuff
Ribesg Jul 26, 2014
9fe76be
Make Click & Hover immutable
Ribesg Jul 30, 2014
7df8f44
Ensure stored String[] and ItemStack are not modified
Ribesg Jul 30, 2014
f457284
Handle null value in String[]
Ribesg Jul 30, 2014
b4abdef
Add .toString() to Message and Part
Ribesg Jul 30, 2014
db58a06
Don't print "null" for Achievement or Item parts
Ribesg Jul 30, 2014
074bde3
Add 2 millions methods
Ribesg Aug 7, 2014
8d74fcb
Document the Click class
Ribesg Aug 7, 2014
090dc73
Document the Hover class
Ribesg Aug 7, 2014
73e4a63
Add basic Javadoc for Message and Part
Ribesg Aug 22, 2014
9f814e4
Add JavaDucks for Message static constructors
Ribesg Aug 25, 2014
33e6fae
Add JavaDucks for Message append(...) methods
Ribesg Aug 25, 2014
d98d04e
Add JavaDucks for Message insert(...) methods
Ribesg Aug 25, 2014
ae2c82e
Added some javadocs
ST-DDT Aug 29, 2014
c929fc3
Use Messages in Events too.
ST-DDT Aug 30, 2014
270c9f3
Added Deprecation annotation to all string message related methods
ST-DDT Aug 30, 2014
a26aae7
Merge pull request #8 from ST-DDT/BUKKIT-5245-v2_javadocs
Ribesg Aug 30, 2014
0a356c0
Merge pull request #7 from ST-DDT/BUKKIT-5245-v2_events
Ribesg Aug 30, 2014
91f1321
Update PlayerDeathEvent
ST-DDT Aug 31, 2014
ec799c8
Update AsyncPlayerChatEvent
ST-DDT Aug 31, 2014
e1bb1e7
Added AsyncPlayerChatEvent#getFormatedMessage
ST-DDT Aug 31, 2014
6c3dbf2
Update PlayerLoginEvent
ST-DDT Aug 31, 2014
d8b1861
Update AsyncPlayerPreLoginEvent
ST-DDT Aug 31, 2014
9a1d7b1
Use setters to centralize logic and ternary for one line statements.
ST-DDT Sep 1, 2014
34799da
Improve jd formating
ST-DDT Sep 1, 2014
7b13b43
Formating
ST-DDT Sep 1, 2014
7f1e301
Replace '!=' with 'does not match' in jd, add additional javadocs
ST-DDT Sep 2, 2014
caed86c
Lowercase Null.
ST-DDT Sep 2, 2014
f62d47b
Add support for '%s' in format
ST-DDT Sep 2, 2014
5f89c99
Fixed indentation in AsyncPlayerChatEvent
ST-DDT Sep 2, 2014
210c99f
Added clone method
ST-DDT Sep 2, 2014
869402e
Improve cloning
ST-DDT Sep 2, 2014
51bdb2e
Ternary
ST-DDT Sep 2, 2014
33044d5
Added missing deprecation javadocs + added ServerListPingEvent
ST-DDT Sep 3, 2014
48bc47a
Added support for Player.kick(Message) and updated PlayerKickEvent ac…
ST-DDT Sep 3, 2014
a0111e0
Added Player.chat(Message)
ST-DDT Sep 3, 2014
83d7145
Messages cannot be a command
ST-DDT Sep 3, 2014
119cde4
Merge pull request #10 from ST-DDT/BUKKIT-5245-v2_clone
bendem Sep 3, 2014
5f1c443
Fixed typos and minor improvements
ST-DDT Sep 3, 2014
00b7652
Fixed some more typos
ST-DDT Sep 3, 2014
7e1908f
Made Click implement ConfigurationSerializable, add toString
ST-DDT Sep 4, 2014
a9927d1
Made Hover implement ConfigurationSerializable, add toString, fix equals
ST-DDT Sep 4, 2014
10c879d
Made Message implement ConfigurationSerializable
ST-DDT Sep 4, 2014
4d595ac
Made Part implement ConfigurationSerializable
ST-DDT Sep 4, 2014
05fe519
Merge pull request #11 from ST-DDT/BUKKIT-5245-v2_config
Ribesg Sep 5, 2014
6f279f3
Merge pull request #9 from ST-DDT/BUKKIT-5245-v2_events
Ribesg Sep 5, 2014
057b8eb
Remove useless brackets
ST-DDT Sep 5, 2014
b11d0a3
Clone the parts before adding it to the formated message
ST-DDT Sep 5, 2014
ec5be3d
Merge pull request #12 from ST-DDT/BUKKIT-5245-v2_clone
Ribesg Sep 5, 2014
f9c611d
Merge pull request #13 from ST-DDT/BUKKIT-5245-v2_bugfix
Ribesg Sep 5, 2014
ade1877
Merge constructors
ST-DDT Sep 6, 2014
8c1e88f
Added some missing validation
ST-DDT Sep 6, 2014
d20d306
Merge pull request #14 from ST-DDT/BUKKIT-5245-v2_events
Ribesg Sep 6, 2014
830aad1
Merge pull request #15 from ST-DDT/BUKKIT-5245-v2_validation
Ribesg Sep 6, 2014
1d1875d
Add tests for clone methods, fixed whitespace issues.
ST-DDT Sep 6, 2014
5fb2d36
Merge pull request #16 from ST-DDT/BUKKIT-5245-v2_test
Ribesg Sep 6, 2014
c80cfd7
Minor improvements
ST-DDT Sep 16, 2014
9aea521
Merge pull request #17 from ST-DDT/BUKKIT-5245-v2_improvements
Ribesg Sep 17, 2014
ce341e8
Added MC 1.8 features
ST-DDT Sep 19, 2014
a42dc5b
Fixed javadocs errors
ST-DDT Sep 20, 2014
04b84b6
Merge pull request #18 from ST-DDT/v1.8_features
Ribesg Oct 1, 2014
79252ca
Bugfix Message
ST-DDT Nov 6, 2014
ec23ace
Merge pull request #19 from ST-DDT/BUKKIT-5245-v2
bendem Nov 6, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use Messages in Events too.
ST-DDT committed Aug 30, 2014
commit c929fc3de2b01743e4d0310be190b18adbc88689
71 changes: 64 additions & 7 deletions src/main/java/org/bukkit/event/player/PlayerJoinEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.event.player;

import org.bukkit.chat.Message;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;

@@ -8,28 +9,84 @@
*/
public class PlayerJoinEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private String joinMessage;
private Message joinMessage;

public PlayerJoinEvent(final Player playerJoined, final String joinMessage) {
/**
* Creates a new PlayerJoinEvent for the given player with the given default
* message sent to all online players after the event finished being
* processed.
*
* @param playerJoined the player that had joined the server
* @param joinMessage the join message being send to all online players
*/
public PlayerJoinEvent(final Player playerJoined, final Message joinMessage) {
super(playerJoined);
this.joinMessage = joinMessage;
}

/**
* Gets the join message to send to all online players
* Creates a new PlayerJoinEvent for the given player with the given default
* message sent to all online players after the event finished being
* processed.
*
* @param playerJoined the player that had joined the server
* @param joinMessage the join message being send to all online players
* @deprecated This event now uses {@link Message} to send the message. Use
* {@link #PlayerJoinEvent(Player, Message)} instead.
*/
@Deprecated
public PlayerJoinEvent(final Player playerJoined, final String joinMessage) {
super(playerJoined);
this.joinMessage = Message.of(joinMessage);
}

/**
* Gets the join message to send to all online players. Can be null/empty
* and may contain color codes.
*
* @return string join message
* @return string the join message to show
* @deprecated This event now uses {@link Message} to send the message. Use
* {@link #getMessage()} instead.
*/
@Deprecated
public String getJoinMessage() {
return joinMessage;
if (joinMessage == null)
return null;
else
return joinMessage.toString();
}

/**
* Sets the join message to send to all online players
* Sets the join message to send to all online players. Set to null or empty
* to prevent the message being shown.
*
* @param joinMessage join message
* @param joinMessage the join message to show. Can be null, empty and can
* contain color codes.
*/
public void setJoinMessage(String joinMessage) {
if (joinMessage == null) {
this.joinMessage = null;
} else {
this.joinMessage = Message.of(joinMessage);
}
}

/**
* Gets the join message to send to all online players. Can be null.
*
* @return the join message being shown
*/
public Message getMessage() {
return joinMessage;
}

/**
* Sets the join message to send to all online players. Set to null to
* prevent the message being shown.
*
* @param joinMessage the join message to show
*/
public void setMessage(Message joinMessage) {
this.joinMessage = joinMessage;
}

77 changes: 68 additions & 9 deletions src/main/java/org/bukkit/event/player/PlayerKickEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.event.player;

import org.bukkit.chat.Message;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -9,32 +10,75 @@
*/
public class PlayerKickEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private String leaveMessage;
private Message leaveMessage;
private String kickReason;
private Boolean cancel;

public PlayerKickEvent(final Player playerKicked, final String kickReason, final String leaveMessage) {
/**
* Creates a new PlayerKickEvent for the given player with the given default
* message sent to all online players after the event finished being
* processed.
*
* @param playerKicked the player who has been kicked from the server
* @param kickReason the reason why the player has been kicked
* @param leaveMessage the kick message being send to all online players
*/
public PlayerKickEvent(final Player playerKicked, final String kickReason, final Message leaveMessage) {
super(playerKicked);
this.kickReason = kickReason;
this.leaveMessage = leaveMessage;
this.cancel = false;
}

/**
* Gets the reason why the player is getting kicked
* Creates a new PlayerKickEvent for the given player with the given default
* message sent to all online players after the event finished being
* processed.
*
* @param playerKicked the player who has been kicked from the server
* @param kickReason the reason why the player has been kicked
* @param leaveMessage the kick message being send to all online players
* @deprecated This event now uses {@link Message} to send the message. Use
* {@link #PlayerKickEvent(Player, Message)} instead.
*/
@Deprecated
public PlayerKickEvent(final Player playerKicked, final String kickReason, final String leaveMessage) {
super(playerKicked);
this.kickReason = kickReason;
this.leaveMessage = Message.of(leaveMessage);
this.cancel = false;
}

/**
* Gets the reason why the player is getting kicked. Can be null/empty and
* may contain color codes.
*
* @return string kick reason
* @return the kick reason
*/
public String getReason() {
return kickReason;
}

/**
* Gets the leave message send to all online players
* Gets the leave message send to all online players. Can be null/empty and
* may contain color codes.
*
* @return string kick reason
* @return the leave message being shown
*/
public String getLeaveMessage() {
if (leaveMessage == null) {
return null;
} else {
return leaveMessage.toString();
}
}

/**
* Gets the leave message send to all online players. Can be null.
*
* @return the leave message being shown
*/
public Message getMessage() {
return leaveMessage;
}

@@ -49,18 +93,33 @@ public void setCancelled(boolean cancel) {
/**
* Sets the reason why the player is getting kicked
*
* @param kickReason kick reason
* @param kickReason the kick reason
*/
public void setReason(String kickReason) {
this.kickReason = kickReason;
}

/**
* Sets the leave message send to all online players
* Sets the leave message send to all online players. Set to null or empty
* to prevent the message being shown.
*
* @param leaveMessage leave message
* @param leaveMessage the leave message to show
*/
public void setLeaveMessage(String leaveMessage) {
if (leaveMessage == null) {
this.leaveMessage = null;
} else {
this.leaveMessage = Message.of(leaveMessage);
}
}

/**
* Sets the leave message send to all online players. Set to null to prevent
* the message being shown.
*
* @param leaveMessage the leave message to show
*/
public void setLeaveMessage(Message leaveMessage) {
this.leaveMessage = leaveMessage;
}

69 changes: 62 additions & 7 deletions src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.event.player;

import org.bukkit.chat.Message;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;

@@ -8,28 +9,82 @@
*/
public class PlayerQuitEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private String quitMessage;
private Message quitMessage;

public PlayerQuitEvent(final Player who, final String quitMessage) {
/**
* Creates a new PlayerKickEvent for the given player with the given default
* message sent to all online players after the event finished being
* processed.
*
* @param who the player that had left the server
* @param quitMessage the quit message being send to all online players
*/
public PlayerQuitEvent(final Player who, final Message quitMessage) {
super(who);
this.quitMessage = quitMessage;
}

/**
* Gets the quit message to send to all online players
* Creates a new PlayerKickEvent for the given player with the given default
* message sent to all online players after the event finished being
* processed.
*
* @param who the player that had left the server
* @param quitMessage the quit message being send to all online players
*/
public PlayerQuitEvent(final Player who, final String quitMessage) {
super(who);
this.quitMessage = Message.of(quitMessage);
}

/**
* Gets the quit message to send to all online players. Can be null/empty
* and may contain color codes.
*
* @return string quit message
* @return the quit message being shown.
* @deprecated This event now uses {@link Message} to send the message. Use
* {@link #getMessage()} instead.
*/
@Deprecated
public String getQuitMessage() {
return quitMessage;
if (quitMessage == null) {
return null;
} else {
return quitMessage.toString();
}
}

/**
* Sets the quit message to send to all online players
* Sets the quit message to send to all online players. Set to null or empty
* to prevent this message from being shown.
*
* @param quitMessage quit message
* @param quitMessage the quit message to show. Can be null, empty and can
* contain color codes.
*/
public void setQuitMessage(String quitMessage) {
if (quitMessage == null) {
this.quitMessage = null;
} else {
this.quitMessage = Message.of(quitMessage);
}
}

/**
* Gets the quit message to send to all online players. Can be null.
*
* @return the join message being shown
*/
public Message getMessage() {
return quitMessage;
}

/**
* Sets the join message to send to all online players. Set to null to
* prevent the message from being shown.
*
* @param quitMessage the quit message to show
*/
public void setMessage(Message quitMessage) {
this.quitMessage = quitMessage;
}