Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from PXAV/development
Changes for release 0.0.5 - "The player interaction update"
- Loading branch information
Showing
54 changed files
with
3,979 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# v0.0.5 | ||
> Release date: 30.12.2020 | ||
**The player interaction update**: | ||
* Add `KelpServer` class, which serves as a kind of kelp wrapper for the `Bukkit` class: | ||
* Broadcast messages to `KelpPlayers` (instead of bukkit players) | ||
* Fetch all online `KelpPlayers` of the server | ||
* You can now send centered chat messages using the `KelpPlayer` as well as the `KelpServer` class. | ||
* Add player prompts accessible via the `KelpPlayer` class: | ||
* `AnvilPrompt`: Use an anvil GUI to query text input from a player (default texts possible) | ||
* `SignPrompt`: Use the sign editor to query multiple lines of text from a player (default lines are possible) | ||
* `ChatPrompt`: Simple utility to use the chat as a method to query text input (default input not possible yet). | ||
* Add methods to display a `boss bar` to a player (including process modification and boss bar removal) | ||
* Add new custom event `KelpPlayerChangeSettingsEvent` that is triggered when a player changes their settings | ||
* Fix bug that custom kelp inventory events crashed the plugin when they were actually used in an event handler | ||
* Add `KelpPlayerLoginEvent` which is called on login of a player but after it has been initialized by kelp, so that calls to the `KelpPlayerRepository` are safe. If you want to handle logins now, it is recommended to use this event instead of the normal bukkit event. | ||
* You can now send interactive messages to KelpPlayers. You can assign messages that are displayable when you hover over them and define events which are triggered when a player clicks on a message. You can combine unlimited components per message unlike the normal `TextComponent#addExtra` method which is wide spread across the spigot community. | ||
* Documentation improvements in the code as well as in the GitHub wiki | ||
* Create empty kelp sql module |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package de.pxav.kelp.core; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
import de.pxav.kelp.core.player.KelpPlayer; | ||
import de.pxav.kelp.core.player.KelpPlayerRepository; | ||
import de.pxav.kelp.core.version.KelpVersion; | ||
import org.bukkit.Bukkit; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* A class description goes here. | ||
* | ||
* @author pxav | ||
*/ | ||
@Singleton | ||
public class KelpServer { | ||
|
||
private KelpPlayerRepository kelpPlayerRepository; | ||
|
||
@Inject | ||
public KelpServer(KelpPlayerRepository kelpPlayerRepository) { | ||
this.kelpPlayerRepository = kelpPlayerRepository; | ||
} | ||
|
||
public KelpVersion getVersion() { | ||
return KelpVersion.withBukkitVersion(Bukkit.getBukkitVersion()); | ||
} | ||
|
||
public Collection<KelpPlayer> getOnlinePlayers() { | ||
Collection<KelpPlayer> output = Lists.newArrayList(); | ||
Bukkit.getOnlinePlayers().forEach(current -> output.add(kelpPlayerRepository.getKelpPlayer(current))); | ||
return output; | ||
} | ||
|
||
public int getMaxPlayers() { | ||
return Bukkit.getMaxPlayers(); | ||
} | ||
|
||
public void broadcastMessage(String message) { | ||
Bukkit.getOnlinePlayers().forEach(current -> current.sendMessage(message)); | ||
} | ||
|
||
public void broadcastCenteredMessage(String message) { | ||
this.getOnlinePlayers().forEach(current -> current.sendCenteredMessage(message)); | ||
} | ||
|
||
public void broadcastMessages(String... message) { | ||
Bukkit.getOnlinePlayers().forEach(current -> { | ||
for (String s : message) { | ||
current.sendMessage(s); | ||
} | ||
}); | ||
} | ||
|
||
public void broadcastCenteredMessages(String... message) { | ||
this.getOnlinePlayers().forEach(current -> { | ||
for (String s : message) { | ||
current.sendCenteredMessage(s); | ||
} | ||
}); | ||
} | ||
|
||
public void broadcastCenteredMessages(Collection<String> messages) { | ||
this.getOnlinePlayers().forEach(current -> { | ||
for (String s : messages) { | ||
current.sendCenteredMessage(s); | ||
} | ||
}); | ||
} | ||
|
||
public void broadcastMessages(Collection<String> messages) { | ||
Bukkit.getOnlinePlayers().forEach(current -> { | ||
for (String s : messages) { | ||
current.sendMessage(s); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
71 changes: 71 additions & 0 deletions
71
core/src/main/java/de/pxav/kelp/core/event/kelpevent/KelpPlayerLoginEvent.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package de.pxav.kelp.core.event.kelpevent; | ||
|
||
import de.pxav.kelp.core.player.KelpPlayer; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.player.PlayerEvent; | ||
import org.bukkit.event.player.PlayerLoginEvent; | ||
|
||
/** | ||
* This event is triggered on any player login. It is recommended to use this | ||
* event instead of the normal {@link PlayerLoginEvent} as this event is used | ||
* to handle the handshake between the client and server. | ||
* | ||
* If a kelp application would try to convert the {@link Player} instance into a | ||
* {@link KelpPlayer} instance, there would be a {@link NullPointerException} as | ||
* the player has not been registered yet. So the login event handler that creates | ||
* the {@link KelpPlayer} instances calls this event after it has finished so that | ||
* it is safe to use the kelp player object. | ||
* | ||
* All methods (except {@link #getKelpPlayer()}) are the same as those from the normal | ||
* bukkit event, so you can look for more detailed information there. | ||
* | ||
* @author pxav | ||
*/ | ||
public class KelpPlayerLoginEvent extends PlayerEvent { | ||
|
||
// list of all event handlers listening for this event | ||
private static final HandlerList handlers = new HandlerList(); | ||
|
||
private String hostname; | ||
private PlayerLoginEvent.Result result; | ||
private String message; | ||
private KelpPlayer kelpPlayer; | ||
|
||
public KelpPlayerLoginEvent(Player who, KelpPlayer kelpPlayer, String hostname, PlayerLoginEvent.Result result, String message) { | ||
super(who); | ||
this.hostname = hostname; | ||
this.result = result; | ||
this.message = message; | ||
this.kelpPlayer = kelpPlayer; | ||
} | ||
|
||
/** | ||
* @return The {@link KelpPlayer} instance of the player who logged in. | ||
*/ | ||
public KelpPlayer getKelpPlayer() { | ||
return kelpPlayer; | ||
} | ||
|
||
public String getHostname() { | ||
return hostname; | ||
} | ||
|
||
public PlayerLoginEvent.Result getResult() { | ||
return result; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
} |
Oops, something went wrong.