Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[B+C] Add API to use 1.7 chat features. Adds BUKKIT-5245 #1111

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/main/java/org/bukkit/Bukkit.java
Expand Up @@ -11,6 +11,7 @@
import java.util.logging.Logger;

import org.bukkit.Warning.WarningState;
import org.bukkit.chat.Message;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
Expand Down Expand Up @@ -187,6 +188,13 @@ public static int broadcastMessage(String message) {
return server.broadcastMessage(message);
}

/**
* @see Server#broadcastMessage(org.bukkit.chat.Message message)
*/
public static int broadcastMessage(Message message) {
return server.broadcastMessage(message);
}

/**
* @see Server#getUpdateFolder()
*/
Expand Down Expand Up @@ -429,6 +437,13 @@ public static int broadcast(String message, String permission) {
return server.broadcast(message, permission);
}

/**
* @see Server#broadcast(Message message, String permission)
*/
public static int broadcast(Message message, String permission) {
return server.broadcast(message, permission);
}

/**
* @see Server#getOfflinePlayer(String name)
*/
Expand Down Expand Up @@ -609,10 +624,18 @@ public static Inventory createInventory(InventoryHolder owner, InventoryType typ
/**
* @see Server#createInventory(InventoryHolder owner, InventoryType type, String title)
*/
@Deprecated
public static Inventory createInventory(InventoryHolder owner, InventoryType type, String title) {
return server.createInventory(owner, type, title);
}

/**
* @see Server#createInventory(InventoryHolder, InventoryType, Message)
*/
public static Inventory createInventory(InventoryHolder owner, InventoryType type, Message title) {
return server.createInventory(owner, type, title);
}

/**
* @see Server#createInventory(InventoryHolder owner, int size)
*/
Expand All @@ -624,10 +647,18 @@ public static Inventory createInventory(InventoryHolder owner, int size) throws
* @see Server#createInventory(InventoryHolder owner, int size, String
* title)
*/
@Deprecated
public static Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException {
return server.createInventory(owner, size, title);
}

/**
* @see Server#createInventory(InventoryHolder, int, Message)
*/
public static Inventory createInventory(InventoryHolder owner, int size, Message title) throws IllegalArgumentException {
return server.createInventory(owner, size, title);
}

/**
* @see Server#getHelpMap()
*/
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/org/bukkit/Server.java
Expand Up @@ -13,6 +13,7 @@
import java.util.logging.Logger;

import org.bukkit.Warning.WarningState;
import org.bukkit.chat.Message;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
Expand Down Expand Up @@ -236,6 +237,17 @@ public interface Server extends PluginMessageRecipient {
*/
public int broadcastMessage(String message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a @Deprecation annotation missing here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, no. If you just want to broadcast a single String, eventually with Chatcolors, there's no problem using this.


/**
* Broadcast a rich message to all players.
* <p>
* This is the same as calling {@link #broadcast(Message, String)}
* to {@link #BROADCAST_CHANNEL_USERS}
*
* @param message the rich message
* @return the number of players
*/
public int broadcastMessage(Message message);

/**
* Gets the name of the update folder. The update folder is used to safely
* update plugins at the right moment on a plugin load.
Expand Down Expand Up @@ -594,6 +606,17 @@ public interface Server extends PluginMessageRecipient {
*/
public int broadcast(String message, String permission);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a @Deprecation annotation missing here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, no. If you just want to broadcast a single String, eventually with Chatcolors, there's no problem using this.


/**
* Broadcasts the specified rich message to every user with the given
* permission name.
*
* @param message rich message to broadcast
* @param permission the required permission {@link Permissible
* permissibles} must have to receive the broadcast
* @return number of message recipients
*/
public int broadcast(Message message, String permission);

/**
* Gets the player by the given name, regardless if they are offline or
* online.
Expand Down Expand Up @@ -743,9 +766,27 @@ public interface Server extends PluginMessageRecipient {
* @param type The type of inventory to create.
* @param title The title of the inventory, to be displayed when it is viewed.
* @return The new inventory.
* @deprecated This method now uses {@link Message} to set the title. Use
* {@link #createInventory(InventoryHolder, InventoryType, Message)}
* instead.
*/
@Deprecated
Inventory createInventory(InventoryHolder owner, InventoryType type, String title);

/**
* Creates an empty inventory with the specified type and title. If the type
* is {@link InventoryType#CHEST}, the new inventory has a size of 27;
* otherwise the new inventory has the normal size for its type.<br />
* It should be noted that some inventory types do not support titles and
* may not render with said titles on the Minecraft client.
*
* @param owner The holder of the inventory; can be null if there's no holder.
* @param type The type of inventory to create.
* @param title The title of the inventory, to be displayed when it is viewed.
* @return The new inventory.
*/
Inventory createInventory(InventoryHolder owner, InventoryType type, Message title);

/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
* specified size.
Expand All @@ -767,9 +808,25 @@ public interface Server extends PluginMessageRecipient {
* viewed
* @return a new inventory
* @throws IllegalArgumentException if the size is not a multiple of 9
* @deprecated This method now uses {@link Message} to set the title. Use
* {@link #createInventory(InventoryHolder, int, Message)} instead.
*/
@Deprecated
Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException;

/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
* specified size and title.
*
* @param owner the holder of the inventory, or null to indicate no holder
* @param size a multiple of 9 as the size of inventory to create
* @param title the title of the inventory, displayed when inventory is
* viewed
* @return a new inventory
* @throws IllegalArgumentException if the size is not a multiple of 9
*/
Inventory createInventory(InventoryHolder owner, int size, Message title) throws IllegalArgumentException;

/**
* Gets user-specified limit for number of monsters that can spawn in a
* chunk.
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/bukkit/block/Sign.java
@@ -1,5 +1,7 @@
package org.bukkit.block;

import org.bukkit.chat.Message;

/**
* Represents either a SignPost or a WallSign
*/
Expand All @@ -9,9 +11,19 @@ public interface Sign extends BlockState {
* Gets all the lines of text currently on this sign.
*
* @return Array of Strings containing each line of text
* @deprecated This method now uses {@link Message} to return the lines. Use
* {@link #getLineMessages()} instead.
*/
@Deprecated
public String[] getLines();

/**
* Gets all the lines of text currently on this sign.
*
* @return Array of Message containing each line of text
*/
public Message[] getLineMessages();

/**
* Gets the line of text at the specified index.
* <p>
Expand All @@ -20,9 +32,23 @@ public interface Sign extends BlockState {
* @param index Line number to get the text from, starting at 0
* @throws IndexOutOfBoundsException Thrown when the line does not exist
* @return Text on the given line
* @deprecated This method now uses {@link Message} to return the line. Use
* {@link #getLineMessage(int)} instead.
*/
@Deprecated
public String getLine(int index) throws IndexOutOfBoundsException;

/**
* Gets the line of text at the specified index.
* <p>
* For example, getLine(0) will return the first line of text.
*
* @param index Line number to get the text from, starting at 0
* @throws IndexOutOfBoundsException Thrown when the line does not exist
* @return Message on the given line
*/
public Message getLineMessage(int index) throws IndexOutOfBoundsException;

/**
* Sets the line of text at the specified index.
* <p>
Expand All @@ -32,6 +58,21 @@ public interface Sign extends BlockState {
* @param index Line number to set the text at, starting from 0
* @param line New text to set at the specified index
* @throws IndexOutOfBoundsException If the index is out of the range 0..3
* @deprecated This method now uses {@link Message} to set the lines. Use
* {@link #setLine(int,Message)} instead.
*/
@Deprecated
public void setLine(int index, String line) throws IndexOutOfBoundsException;

/**
* Sets the line of text at the specified index.
* <p>
* For example, setLine(0, "Line One") will set the first line of text to
* "Line One".
*
* @param index Line number to set the text at, starting from 0
* @param line New text to set at the specified index
* @throws IndexOutOfBoundsException If the index is out of the range 0..3
*/
public void setLine(int index, Message line) throws IndexOutOfBoundsException;
}