mirror of
https://github.com/NEZNAMY/TAB.git
synced 2026-11-12 20:22:01 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54cb3e4d54 | ||
|
|
b0fc2caef9 | ||
|
|
1221509d24 | ||
|
|
17f5f60504 | ||
|
|
a8b0b488c6 | ||
|
|
6d922d5b70 | ||
|
|
1ab62a33e3 | ||
|
|
f9540a1e78 | ||
|
|
a720bf2c8b | ||
|
|
c143eab6fb | ||
|
|
1afb20af8b | ||
|
|
c6f27c839d | ||
|
|
742f1708c5 | ||
|
|
ac9601a48b | ||
|
|
4cd109a5fc | ||
|
|
078554a8b0 | ||
|
|
464e2f4f64 | ||
|
|
b84f55aa18 | ||
|
|
be2f780bfa | ||
|
|
262d8493a6 | ||
|
|
24e12e871b | ||
|
|
a2ee75339c | ||
|
|
9c28c4d63c | ||
|
|
7d57da1424 | ||
|
|
b77b20ba4d | ||
|
|
57ae58f093 | ||
|
|
b29c878688 | ||
|
|
5a5a6c76c1 | ||
|
|
f6a53f537c | ||
|
|
d86ed37208 | ||
|
|
92b945f28d | ||
|
|
cb164f0055 | ||
|
|
acfe37c1b5 | ||
|
|
44ded26df4 | ||
|
|
6dbd92a010 | ||
|
|
f729ca0ad2 | ||
|
|
065490c077 | ||
|
|
da6425dd93 | ||
|
|
250dcbc676 | ||
|
|
de4ca4a88f | ||
|
|
723a0c890e | ||
|
|
7085e7df20 | ||
|
|
09496d60f3 | ||
|
|
bf6bc26a5c | ||
|
|
a7217eae15 | ||
|
|
2a532ef9b7 | ||
|
|
c304ded924 | ||
|
|
4d8c47a505 | ||
|
|
d3e0ccbf34 | ||
|
|
3c82b46148 | ||
|
|
07d7f2cc17 | ||
|
|
54d4f09ab1 | ||
|
|
e8c698b5e8 | ||
|
|
b096906ffd | ||
|
|
5a9cec12fa | ||
|
|
a2ed71751f | ||
|
|
5a3a2df920 | ||
|
|
9d07e669ea | ||
|
|
aa18f1cc35 | ||
|
|
668d78ea64 | ||
|
|
6f62581d6e | ||
|
|
06686ada5c | ||
|
|
4380482606 | ||
|
|
d5112b3d32 | ||
|
|
ef67506640 | ||
|
|
c2ea4d2793 |
No files matched your search
@@ -11,15 +11,16 @@ jobs:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 11
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
@@ -38,7 +39,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||
run: ./gradlew clean build
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v2.3.1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Jar
|
||||
path: jar/build/libs/TAB-**.jar
|
||||
@@ -16,16 +16,15 @@ Once the plugin compiles, grab the jar from `/jar/build/libs/` folder.
|
||||
|
||||
# Links
|
||||
The precompiled JAR can be downloaded for free from:
|
||||
* Releases: https://github.com/NEZNAMY/TAB/releases
|
||||
* GitHub releases: https://github.com/NEZNAMY/TAB/releases
|
||||
* MC-Market: https://www.mc-market.org/resources/20631/
|
||||
|
||||
Supporting my work:
|
||||
* MC-Market: https://www.mc-market.org/resources/14009/
|
||||
* Polymart: https://polymart.org/resource/484
|
||||
* Donation link: https://paypal.me/neznamy1
|
||||
|
||||
Other links:
|
||||
* Discord: https://discord.gg/EaSvdk6
|
||||
* Discord support for buyers: https://discord.gg/EaSvdk6
|
||||
* Wiki: https://github.com/NEZNAMY/TAB/wiki
|
||||
|
||||
# Issues
|
||||
|
||||
@@ -4,25 +4,30 @@ public interface ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns true if offset is static, false if not
|
||||
* @return true if static, false if dynamic
|
||||
*
|
||||
* @return true if static, false if dynamic
|
||||
*/
|
||||
boolean hasStaticOffset();
|
||||
|
||||
/**
|
||||
* Changes offset of the armor stand
|
||||
* @param offset - new offset
|
||||
*
|
||||
* @param offset
|
||||
* new offset
|
||||
*/
|
||||
void setOffset(double offset);
|
||||
|
||||
/**
|
||||
* Returns offset of the armor stand
|
||||
* @return offset from base
|
||||
*
|
||||
* @return offset from base
|
||||
*/
|
||||
double getOffset();
|
||||
|
||||
/**
|
||||
* Returns property for armor stand's name
|
||||
* @return property for armor stand's name
|
||||
*
|
||||
* @return property for armor stand's name
|
||||
*/
|
||||
Property getProperty();
|
||||
|
||||
@@ -33,14 +38,17 @@ public interface ArmorStand {
|
||||
|
||||
/**
|
||||
* Teleports armor stand to owner's current location for specified player
|
||||
* @param viewer - player to send packet to
|
||||
*
|
||||
* @param viewer
|
||||
* player to send packet to
|
||||
*/
|
||||
void teleport(TabPlayer viewer);
|
||||
|
||||
/**
|
||||
* Changes sneaking flag and sends packets to everyone in range
|
||||
* @param sneaking
|
||||
* new sneaking status
|
||||
*
|
||||
* @param sneaking
|
||||
* new sneaking status
|
||||
*/
|
||||
void sneak(boolean sneaking);
|
||||
|
||||
@@ -51,7 +59,9 @@ public interface ArmorStand {
|
||||
|
||||
/**
|
||||
* DeSpawns armor stand for specified player
|
||||
* @param viewer - player to send packet to
|
||||
*
|
||||
* @param viewer
|
||||
* player to send packet to
|
||||
*/
|
||||
void destroy(TabPlayer viewer);
|
||||
|
||||
@@ -62,19 +72,24 @@ public interface ArmorStand {
|
||||
|
||||
/**
|
||||
* Updates visibility if needed
|
||||
* @param force - if refresh should be forced
|
||||
*
|
||||
* @param force
|
||||
* if refresh should be forced
|
||||
*/
|
||||
void updateVisibility(boolean force);
|
||||
|
||||
/**
|
||||
* Returns entity ID of this armor stand
|
||||
* @return entity ID of this armor stand
|
||||
*
|
||||
* @return entity ID of this armor stand
|
||||
*/
|
||||
int getEntityId();
|
||||
|
||||
/**
|
||||
* Spawns armor stand for specified player
|
||||
* @param viewer - player to spawn for
|
||||
*
|
||||
* @param viewer
|
||||
* player to spawn for
|
||||
*/
|
||||
void spawn(TabPlayer viewer);
|
||||
|
||||
|
||||
@@ -5,31 +5,37 @@ public interface FeatureManager {
|
||||
/**
|
||||
* Registers a feature, which will start receiving events
|
||||
*
|
||||
* @param name - name of feature
|
||||
* @param feature - the handler
|
||||
* @param name
|
||||
* name of feature
|
||||
* @param feature
|
||||
* the handler
|
||||
*/
|
||||
void registerFeature(String name, TabFeature feature);
|
||||
|
||||
/**
|
||||
* Unregisters feature making it no longer receive events. This does not run unload method nor cancel
|
||||
* tasks created by the feature
|
||||
* @param name - feature name defined in registerFeature
|
||||
*
|
||||
* @param name
|
||||
* feature name defined in registerFeature
|
||||
*/
|
||||
void unregisterFeature(String name);
|
||||
|
||||
/**
|
||||
* Returns whether a feature with said name is registered or not
|
||||
*
|
||||
* @param name - name of feature defined in registerFeature method
|
||||
* @return true if feature exists, false if not
|
||||
* @param name
|
||||
* name of feature defined in registerFeature method
|
||||
* @return true if feature exists, false if not
|
||||
*/
|
||||
boolean isFeatureEnabled(String name);
|
||||
|
||||
/**
|
||||
* Returns feature handler by its name
|
||||
*
|
||||
* @param name - name of feature defined in registerFeature method
|
||||
* @return the feature or null if feature does not exist
|
||||
* @param name
|
||||
* name of feature defined in registerFeature method
|
||||
* @return the feature or null if feature does not exist
|
||||
*/
|
||||
TabFeature getFeature(String name);
|
||||
}
|
||||
@@ -4,51 +4,61 @@ public interface Property {
|
||||
|
||||
/**
|
||||
* Returns original raw value ignoring API calls
|
||||
* @return original raw value
|
||||
*
|
||||
* @return original raw value
|
||||
*/
|
||||
String getOriginalRawValue();
|
||||
|
||||
/**
|
||||
* Temporarily overrides current raw value with an API call
|
||||
* @param temporaryValue - temporary value to be assigned
|
||||
*
|
||||
* @param temporaryValue
|
||||
* temporary value to be assigned
|
||||
*/
|
||||
void setTemporaryValue(String temporaryValue);
|
||||
|
||||
/**
|
||||
* Returns current temporary value
|
||||
* @return temporary value or null if not set
|
||||
*
|
||||
* @return temporary value or null if not set
|
||||
*/
|
||||
String getTemporaryValue();
|
||||
|
||||
/**
|
||||
* Returns temporary value (via API) if present, raw value otherwise
|
||||
* @return current raw value
|
||||
*
|
||||
* @return current raw value
|
||||
*/
|
||||
String getCurrentRawValue();
|
||||
|
||||
/**
|
||||
* Returns last known value
|
||||
* @return last known value
|
||||
*
|
||||
* @return last known value
|
||||
*/
|
||||
String get();
|
||||
|
||||
/**
|
||||
* Replaces all placeholders in current raw value, colorizes it, removes remove-strings and returns whether value changed or not
|
||||
* @return if updating changed value or not
|
||||
*
|
||||
* @return if updating changed value or not
|
||||
*/
|
||||
boolean update();
|
||||
|
||||
/**
|
||||
* Replaces all placeholders in current raw value, colorizes it, removes remove-strings and returns it.
|
||||
* Equal to calling update() and then get().
|
||||
* @return updated value
|
||||
*
|
||||
* @return updated value
|
||||
*/
|
||||
String updateAndGet();
|
||||
|
||||
/**
|
||||
* Returns value for defined viewer by applying relational placeholders to last known value
|
||||
* @param viewer - the viewer
|
||||
* @return format for the viewer
|
||||
*
|
||||
* @param viewer
|
||||
* the viewer
|
||||
* @return format for the viewer
|
||||
*/
|
||||
String getFormat(TabPlayer viewer);
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package me.neznamy.tab.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface PropertyConfiguration {
|
||||
|
||||
@@ -12,19 +11,34 @@ public interface PropertyConfiguration {
|
||||
|
||||
void remove(String name);
|
||||
|
||||
Map<String, String> getGlobalSettings(String name);
|
||||
Map<String, Object> getGlobalSettings(String name);
|
||||
|
||||
Map<String, Map<String, String>> getPerWorldSettings(String name);
|
||||
Map<String, Map<String, Object>> getPerWorldSettings(String name);
|
||||
|
||||
Map<String, Map<String, String>> getPerServerSettings(String name);
|
||||
Map<String, Map<String, Object>> getPerServerSettings(String name);
|
||||
|
||||
Set<String> getAllEntries();
|
||||
|
||||
default Map<String, Map<String, String>> convertMap(Map<String, Map<String, Map<String, String>>> map, String key) {
|
||||
Map<String, Map<String, String>> converted = new HashMap<>();
|
||||
for (Map.Entry<String, Map<String, Map<String, String>>> entry : map.entrySet()) {
|
||||
default Map<String, Map<String, Object>> convertMap(Map<String, Map<String, Map<String, Object>>> map, String key) {
|
||||
Map<String, Map<String, Object>> converted = new HashMap<>();
|
||||
for (Map.Entry<String, Map<String, Map<String, Object>>> entry : map.entrySet()) {
|
||||
converted.put(entry.getKey(), entry.getValue().get(key));
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default String toString(Object obj) {
|
||||
if (obj instanceof List) {
|
||||
return ((List<Object>)obj).stream().map(Object::toString).collect(Collectors.joining("\n"));
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
default Object fromString(String string) {
|
||||
if (string != null && string.contains("\n")) {
|
||||
return Arrays.asList(string.split("\n"));
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,9 @@ public enum ProtocolVersion {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given network id
|
||||
* @param networkId - network id of this version
|
||||
*
|
||||
* @param networkId
|
||||
* network id of this version
|
||||
*/
|
||||
ProtocolVersion(int networkId){
|
||||
this.networkId = networkId;
|
||||
@@ -86,7 +88,9 @@ public enum ProtocolVersion {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given friendly name
|
||||
* @param friendlyName - friendly name to display
|
||||
*
|
||||
* @param friendlyName
|
||||
* friendly name to display
|
||||
*/
|
||||
ProtocolVersion(String friendlyName){
|
||||
this.networkId = 999;
|
||||
@@ -96,7 +100,8 @@ public enum ProtocolVersion {
|
||||
|
||||
/**
|
||||
* Returns the version's network id
|
||||
* @return version's network id
|
||||
*
|
||||
* @return version's network id
|
||||
*/
|
||||
public int getNetworkId() {
|
||||
return networkId;
|
||||
@@ -104,7 +109,8 @@ public enum ProtocolVersion {
|
||||
|
||||
/**
|
||||
* Returns user-friendly name of the version (such as 1.16.2 instead of V1_16_2)
|
||||
* @return user-friendly name of the version
|
||||
*
|
||||
* @return user-friendly name of the version
|
||||
*/
|
||||
public String getFriendlyName() {
|
||||
return friendlyName;
|
||||
@@ -112,7 +118,8 @@ public enum ProtocolVersion {
|
||||
|
||||
/**
|
||||
* Returns minor version of this release, such as 8 for 1.8.x or 13 for 1.13.x
|
||||
* @return version's minor version
|
||||
*
|
||||
* @return version's minor version
|
||||
*/
|
||||
public int getMinorVersion() {
|
||||
return minorVersion;
|
||||
@@ -122,8 +129,9 @@ public enum ProtocolVersion {
|
||||
* Overrides minor version of the version instance. This is used internally to
|
||||
* set minor version of UNKNOWN_SERVER_VERSION value to value from package to fix compatibility
|
||||
* with server forks that set bukkit version field value to "Unknown".
|
||||
* @param minorVersion
|
||||
* minor version to change value to
|
||||
*
|
||||
* @param minorVersion
|
||||
* minor version to change value to
|
||||
*/
|
||||
public void setMinorVersion(int minorVersion) {
|
||||
this.minorVersion = minorVersion;
|
||||
@@ -131,8 +139,10 @@ public enum ProtocolVersion {
|
||||
|
||||
/**
|
||||
* Returns enum constant of entered version or UNKNOWN_SERVER_VERSION if unknown version
|
||||
* @param friendlyName - friendly name of the version
|
||||
* @return version or UNKNOWN_SERVER_VERSION if version is unknown
|
||||
*
|
||||
* @param friendlyName
|
||||
* friendly name of the version
|
||||
* @return version or UNKNOWN_SERVER_VERSION if version is unknown
|
||||
*/
|
||||
public static ProtocolVersion fromFriendlyName(String friendlyName) {
|
||||
if (friendlyName.startsWith("1.8")) return V1_8;
|
||||
@@ -145,8 +155,10 @@ public enum ProtocolVersion {
|
||||
|
||||
/**
|
||||
* Returns version from given network id
|
||||
* @param networkId - network id of protocol version
|
||||
* @return version from given network id
|
||||
*
|
||||
* @param networkId
|
||||
* network id of protocol version
|
||||
* @return version from given network id
|
||||
*/
|
||||
public static ProtocolVersion fromNetworkId(int networkId) {
|
||||
for (ProtocolVersion v : VALUES) {
|
||||
|
||||
@@ -18,6 +18,8 @@ public abstract class TabAPI {
|
||||
private static TabAPI instance;
|
||||
|
||||
public static TabAPI getInstance() {
|
||||
if (instance == null) throw new IllegalStateException("API instance is null. This likely means you shaded TAB's API into your project" +
|
||||
" instead of only using it, which is not allowed.");
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -27,39 +29,47 @@ public abstract class TabAPI {
|
||||
|
||||
/**
|
||||
* Returns player object from given UUID
|
||||
* @return player object from given UUID
|
||||
* @param id - Player UUID
|
||||
*
|
||||
* @param id
|
||||
* Player UUID
|
||||
* @return player object from given UUID
|
||||
*/
|
||||
public abstract TabPlayer getPlayer(UUID id);
|
||||
|
||||
/**
|
||||
* Returns player object from given name
|
||||
* @return player object from given name
|
||||
* @param name - Player name
|
||||
*
|
||||
* @param name
|
||||
* Player name
|
||||
* @return player object from given name
|
||||
*/
|
||||
public abstract TabPlayer getPlayer(String name);
|
||||
|
||||
/**
|
||||
* Returns collection of all online players. Will return empty list if plugin is disabled (due to a broken configuration file for example).
|
||||
* @return collection of online players
|
||||
*
|
||||
* @return collection of online players
|
||||
*/
|
||||
public abstract TabPlayer[] getOnlinePlayers();
|
||||
|
||||
/**
|
||||
* Return BossBar manager instance if the feature is enabled. Returns null otherwise.
|
||||
* @return BossBar manager
|
||||
*
|
||||
* @return BossBar manager
|
||||
*/
|
||||
public abstract BossBarManager getBossBarManager();
|
||||
|
||||
/**
|
||||
* Returns scoreboard manager instance if the feature is enabled. Returns null otherwise.
|
||||
* @return scoreboard manager
|
||||
*
|
||||
* @return scoreboard manager
|
||||
*/
|
||||
public abstract ScoreboardManager getScoreboardManager();
|
||||
|
||||
/**
|
||||
* Returns team manager instance if the feature is enabled, false otherwise
|
||||
* @return team manager
|
||||
*
|
||||
* @return team manager
|
||||
*/
|
||||
public abstract TeamManager getTeamManager();
|
||||
|
||||
@@ -67,13 +77,15 @@ public abstract class TabAPI {
|
||||
|
||||
/**
|
||||
* Returns PlaceholderManager instance
|
||||
* @return PlaceholderManager instance
|
||||
*
|
||||
* @return PlaceholderManager instance
|
||||
*/
|
||||
public abstract PlaceholderManager getPlaceholderManager();
|
||||
|
||||
/**
|
||||
* Returns feature manager instance
|
||||
* @return feature manager instance
|
||||
*
|
||||
* @return feature manager instance
|
||||
*/
|
||||
public abstract FeatureManager getFeatureManager();
|
||||
|
||||
@@ -82,20 +94,24 @@ public abstract class TabAPI {
|
||||
/**
|
||||
* Gets the event bus for registering listeners for TAB events.
|
||||
*
|
||||
* @return the event bus
|
||||
* @return the event bus
|
||||
*/
|
||||
public abstract EventBus getEventBus();
|
||||
|
||||
/**
|
||||
* Returns server version. On proxy installation returns PROXY.
|
||||
* @return server version
|
||||
*
|
||||
* @return server version
|
||||
*/
|
||||
public abstract ProtocolVersion getServerVersion();
|
||||
|
||||
/**
|
||||
* Prints message into console
|
||||
* @param message - message to print
|
||||
* @param translateColors - true if colors should be translated, false if not
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param translateColors
|
||||
* true if colors should be translated, false if not
|
||||
*/
|
||||
public abstract void sendConsoleMessage(String message, boolean translateColors);
|
||||
|
||||
|
||||
@@ -86,9 +86,12 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes command from player
|
||||
* @param sender - command sender
|
||||
* @param message - command line
|
||||
* @return true if event should be cancelled, false if not
|
||||
*
|
||||
* @param sender
|
||||
* command sender
|
||||
* @param message
|
||||
* command line
|
||||
* @return true if event should be cancelled, false if not
|
||||
*/
|
||||
public boolean onCommand(TabPlayer sender, String message) {
|
||||
return false;
|
||||
@@ -96,7 +99,9 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes join event
|
||||
* @param connectedPlayer - player who connected
|
||||
*
|
||||
* @param connectedPlayer
|
||||
* player who connected
|
||||
*/
|
||||
public void onJoin(TabPlayer connectedPlayer) {
|
||||
//empty by default
|
||||
@@ -104,16 +109,23 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes quit event
|
||||
* @param disconnectedPlayer - player who disconnected
|
||||
*
|
||||
* @param disconnectedPlayer
|
||||
* player who disconnected
|
||||
*/
|
||||
public void onQuit(TabPlayer disconnectedPlayer) {
|
||||
//empty by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes world switch
|
||||
* @param changed - player who switched world
|
||||
* @param from - world player changed from
|
||||
* @param to - world player changed to
|
||||
*
|
||||
* @param changed
|
||||
* player who switched world
|
||||
* @param from
|
||||
* world player changed from
|
||||
* @param to
|
||||
* world player changed to
|
||||
*/
|
||||
public void onWorldChange(TabPlayer changed, String from, String to) {
|
||||
//empty by default
|
||||
@@ -121,9 +133,13 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes server switch
|
||||
* @param changed - player who switched server
|
||||
* @param from - server player changed from
|
||||
* @param to - server player changed to
|
||||
*
|
||||
* @param changed
|
||||
* player who switched server
|
||||
* @param from
|
||||
* server player changed from
|
||||
* @param to
|
||||
* server player changed to
|
||||
*/
|
||||
public void onServerChange(TabPlayer changed, String from, String to) {
|
||||
//empty by default
|
||||
@@ -131,8 +147,11 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes the packet send and returns true if packet should be cancelled
|
||||
* @param receiver - player receiving packet
|
||||
* @param packet - received packet
|
||||
*
|
||||
* @param receiver
|
||||
* player receiving packet
|
||||
* @param packet
|
||||
* received packet
|
||||
*/
|
||||
public void onDisplayObjective(TabPlayer receiver, PacketPlayOutScoreboardDisplayObjective packet) {
|
||||
//empty by default
|
||||
@@ -140,7 +159,9 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes login packet, only available on BungeeCord
|
||||
* @param packetReceiver - player receiving client reset packet
|
||||
*
|
||||
* @param packetReceiver
|
||||
* player receiving client reset packet
|
||||
*/
|
||||
public void onLoginPacket(TabPlayer packetReceiver) {
|
||||
//empty by default
|
||||
@@ -148,8 +169,11 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes the packet send
|
||||
* @param receiver - player receiving packet
|
||||
* @param packet - received packet
|
||||
*
|
||||
* @param receiver
|
||||
* player receiving packet
|
||||
* @param packet
|
||||
* received packet
|
||||
*/
|
||||
public void onObjective(TabPlayer receiver, PacketPlayOutScoreboardObjective packet) {
|
||||
//empty by default
|
||||
@@ -157,8 +181,11 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes the packet send and possibly modifies it
|
||||
* @param receiver - player receiving packet
|
||||
* @param info - received packet
|
||||
*
|
||||
* @param receiver
|
||||
* player receiving packet
|
||||
* @param info
|
||||
* received packet
|
||||
*/
|
||||
public void onPlayerInfo(TabPlayer receiver, PacketPlayOutPlayerInfo info) {
|
||||
//empty by default
|
||||
@@ -166,11 +193,14 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes raw packet sent by client
|
||||
* @param sender - packet sender
|
||||
* @param packet - packet received
|
||||
* @return true if false should be cancelled, false if not
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @param sender
|
||||
* packet sender
|
||||
* @param packet
|
||||
* packet received
|
||||
* @return true if false should be cancelled, false if not
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public boolean onPacketReceive(TabPlayer sender, Object packet) throws ReflectiveOperationException {
|
||||
return false;
|
||||
@@ -178,10 +208,13 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Processes raw packet sent to client
|
||||
* @param receiver - packet receiver
|
||||
* @param packet - the packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @param receiver
|
||||
* packet receiver
|
||||
* @param packet
|
||||
* the packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public void onPacketSend(TabPlayer receiver, Object packet) throws ReflectiveOperationException {
|
||||
//empty by default
|
||||
@@ -189,8 +222,11 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Performs refresh of specified player
|
||||
* @param refreshed - player to refresh
|
||||
* @param force - if refresh should be forced despite refresh seemingly not needed
|
||||
*
|
||||
* @param refreshed
|
||||
* player to refresh
|
||||
* @param force
|
||||
* if refresh should be forced despite refresh seemingly not needed
|
||||
*/
|
||||
public void refresh(TabPlayer refreshed, boolean force) {
|
||||
//empty by default
|
||||
@@ -202,7 +238,9 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Registers this feature as one using specified placeholders
|
||||
* @param placeholders - placeholders to add as used in this feature
|
||||
*
|
||||
* @param placeholders
|
||||
* placeholders to add as used in this feature
|
||||
*/
|
||||
public void addUsedPlaceholders(Collection<String> placeholders) {
|
||||
if (placeholders.isEmpty()) return;
|
||||
@@ -211,9 +249,12 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Returns true if world or server is disabled, false if not
|
||||
* @param world - world to check
|
||||
* @param server - server to check
|
||||
* @return true if feature should be disabled, false if not
|
||||
*
|
||||
* @param server
|
||||
* server to check
|
||||
* @param world
|
||||
* world to check
|
||||
* @return true if feature should be disabled, false if not
|
||||
*/
|
||||
public boolean isDisabled(String server, String world) {
|
||||
boolean contains = contains(disabledWorlds, world);
|
||||
@@ -238,7 +279,8 @@ public abstract class TabFeature {
|
||||
|
||||
/**
|
||||
* Returns name of the feature displayed in /tab cpu.
|
||||
* @return name of the feature displayed in /tab cpu
|
||||
*
|
||||
* @return name of the feature displayed in /tab cpu
|
||||
*/
|
||||
public String getFeatureName() {
|
||||
return featureName;
|
||||
|
||||
@@ -19,215 +19,268 @@ public interface TabPlayer {
|
||||
|
||||
/**
|
||||
* Returns player's name
|
||||
* @return Player's name
|
||||
*
|
||||
* @return Player's name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns player's UUID
|
||||
* @return Player's UUID
|
||||
*
|
||||
* @return Player's UUID
|
||||
*/
|
||||
UUID getUniqueId();
|
||||
|
||||
/**
|
||||
* Returns player's uuid used in TabList. This may only be different from real uuid if
|
||||
* TAB is installed on velocity with some specific velocity setup
|
||||
* @return player's uuid in TabList
|
||||
*
|
||||
* @return player's uuid in TabList
|
||||
*/
|
||||
UUID getTablistUUID();
|
||||
|
||||
/**
|
||||
* Returns player's protocol version
|
||||
* @return player's protocol version
|
||||
*
|
||||
* @return player's protocol version
|
||||
*/
|
||||
ProtocolVersion getVersion();
|
||||
|
||||
/**
|
||||
* Returns platform-specific entity
|
||||
* @return an instance of bukkit/bungee player depending on platform
|
||||
*
|
||||
* @return an instance of bukkit/bungee player depending on platform
|
||||
*/
|
||||
Object getPlayer();
|
||||
|
||||
/**
|
||||
* Returns player's current world name (on BungeeCord this requires bridge installed)
|
||||
* @return name of world where player is currently in, "N/A" on BungeeCord if bridge is not installed
|
||||
*
|
||||
* @return name of world where player is currently in, "N/A" on BungeeCord if bridge is not installed
|
||||
*/
|
||||
String getWorld();
|
||||
|
||||
/**
|
||||
* Returns player's current server name on BungeeCord (on bukkit this returns "N/A")
|
||||
* @return name of server where player is currently in, "N/A" on bukkit
|
||||
*
|
||||
* @return name of server where player is currently in, "N/A" on bukkit
|
||||
*/
|
||||
String getServer();
|
||||
|
||||
/**
|
||||
* Performs platform-specific API call to check for permission and returns the result
|
||||
* @param permission - the permission to check for
|
||||
* @return - true if player has permission, false if not
|
||||
*
|
||||
* @param permission
|
||||
* the permission to check for
|
||||
* @return true if player has permission, false if not
|
||||
*/
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
/**
|
||||
* Sends the player a custom universal packet
|
||||
* @param packet - packet to send
|
||||
*
|
||||
* @param packet
|
||||
* packet to send
|
||||
*/
|
||||
void sendCustomPacket(TabPacket packet);
|
||||
|
||||
/**
|
||||
* Sends the player a custom universal packet and adds that packet into counter that
|
||||
* is displayed in /tab cpu
|
||||
* @param packet - packet to send
|
||||
* @param feature - feature to increment sent packet counter of
|
||||
*
|
||||
* @param packet
|
||||
* packet to send
|
||||
* @param feature
|
||||
* feature to increment sent packet counter of
|
||||
*/
|
||||
void sendCustomPacket(TabPacket packet, TabFeature feature);
|
||||
|
||||
/**
|
||||
* Sends the player a custom universal packet and adds that packet into counter that
|
||||
* is displayed in /tab cpu
|
||||
* @param packet - packet to send
|
||||
* @param feature - feature to increment sent packet counter of
|
||||
*
|
||||
* @param packet
|
||||
* packet to send
|
||||
* @param feature
|
||||
* feature to increment sent packet counter of
|
||||
*/
|
||||
void sendCustomPacket(TabPacket packet, String feature);
|
||||
|
||||
/**
|
||||
* Sends the player a platform-specific packet
|
||||
* @param packet - an instance of packet depending on platform
|
||||
*
|
||||
* @param packet
|
||||
* an instance of packet depending on platform
|
||||
*/
|
||||
void sendPacket(Object packet);
|
||||
|
||||
/**
|
||||
* Sends the player a platform-specific packet and adds that packet into counter that
|
||||
* is displayed in /tab cpu
|
||||
* @param packet - an instance of packet depending on platform
|
||||
* @param feature - feature to increment sent packet counter of
|
||||
*
|
||||
* @param packet
|
||||
* an instance of packet depending on platform
|
||||
* @param feature
|
||||
* feature to increment sent packet counter of
|
||||
*/
|
||||
void sendPacket(Object packet, TabFeature feature);
|
||||
|
||||
/**
|
||||
* Sends the player a platform-specific packet and adds that packet into counter that
|
||||
* is displayed in /tab cpu
|
||||
* @param packet - an instance of packet depending on platform
|
||||
* @param feature - feature to increment sent packet counter of
|
||||
*
|
||||
* @param packet
|
||||
* an instance of packet depending on platform
|
||||
* @param feature
|
||||
* feature to increment sent packet counter of
|
||||
*/
|
||||
void sendPacket(Object packet, String feature);
|
||||
|
||||
/**
|
||||
* Returns player's property by name
|
||||
* @param name - name of property
|
||||
* @return the property or null if not found
|
||||
*
|
||||
* @param name
|
||||
* name of property
|
||||
* @return the property or null if not found
|
||||
*/
|
||||
Property getProperty(String name);
|
||||
|
||||
/**
|
||||
* Sends a message to the player
|
||||
* @param message - message to be sent
|
||||
* @param translateColors - whether colors should be translated or not
|
||||
*
|
||||
* @param message
|
||||
* message to be sent
|
||||
* @param translateColors
|
||||
* whether colors should be translated or not
|
||||
*/
|
||||
void sendMessage(String message, boolean translateColors);
|
||||
|
||||
/**
|
||||
* Sends specified component as a chat message
|
||||
* @param message - message to send
|
||||
*
|
||||
* @param message
|
||||
* message to send
|
||||
*/
|
||||
void sendMessage(IChatBaseComponent message);
|
||||
|
||||
/**
|
||||
* Returns player's primary permission group
|
||||
* @return player's group depending on configuration
|
||||
*
|
||||
* @return player's group depending on configuration
|
||||
*/
|
||||
String getGroup();
|
||||
|
||||
/**
|
||||
* Returns player's channel or null if server is 1.7 or older
|
||||
* @return player's channel
|
||||
*
|
||||
* @return player's channel
|
||||
*/
|
||||
Channel getChannel();
|
||||
|
||||
/**
|
||||
* Returns player's ping calculated by server
|
||||
* @return player's ping
|
||||
*
|
||||
* @return player's ping
|
||||
*/
|
||||
int getPing();
|
||||
|
||||
/**
|
||||
* Returns player's skin data
|
||||
* @return player's skin
|
||||
*
|
||||
* @return player's skin
|
||||
*/
|
||||
Skin getSkin();
|
||||
|
||||
/**
|
||||
* Returns true once the player is successfully loaded (onJoin method ran through all methods)
|
||||
* @return true if player is fully loaded, false otherwise
|
||||
*
|
||||
* @return true if player is fully loaded, false otherwise
|
||||
*/
|
||||
boolean isLoaded();
|
||||
|
||||
/**
|
||||
* Sets property with specified name to new value. If property did not exist before, it is
|
||||
* created and true is returned. If it existed, it is overridden and true is returned. False is returned otherwise.
|
||||
* @param feature - feature using this property to get placeholders registered
|
||||
* @param identifier - property name
|
||||
* @param rawValue - new raw value
|
||||
* @return true if value changed / did not exist, false if value did not change
|
||||
*
|
||||
* @param feature
|
||||
* feature using this property to get placeholders registered
|
||||
* @param identifier
|
||||
* property name
|
||||
* @param rawValue
|
||||
* new raw value
|
||||
* @return true if value changed / did not exist, false if value did not change
|
||||
*/
|
||||
boolean setProperty(TabFeature feature, String identifier, String rawValue);
|
||||
|
||||
/**
|
||||
* Loads property from config using standard property loading algorithm
|
||||
* @param property - property name to load
|
||||
* @return true if value did not exist or changed, false otherwise
|
||||
*
|
||||
* @param property
|
||||
* property name to load
|
||||
* @return true if value did not exist or changed, false otherwise
|
||||
*/
|
||||
boolean loadPropertyFromConfig(TabFeature feature, String property);
|
||||
|
||||
/**
|
||||
* Loads property from config using standard property loading algorithm. If the property is
|
||||
* not set in config, sets it to ifNotSet value
|
||||
* @param property - property name to load
|
||||
* @param ifNotSet - value to use if property is not defined in config
|
||||
* @return true if value did not exist or changed, false otherwise
|
||||
*
|
||||
* @param property
|
||||
* property name to load
|
||||
* @param ifNotSet
|
||||
* value to use if property is not defined in config
|
||||
* @return true if value did not exist or changed, false otherwise
|
||||
*/
|
||||
boolean loadPropertyFromConfig(TabFeature feature, String property, String ifNotSet);
|
||||
|
||||
/**
|
||||
* Returns name of player's scoreboard team or null if NameTag feature is disabled
|
||||
* @return name of player's team
|
||||
*
|
||||
* @return name of player's team
|
||||
*/
|
||||
String getTeamName();
|
||||
|
||||
/**
|
||||
* Returns user-friendly explanation of team name
|
||||
* @return explanation behind team name
|
||||
*
|
||||
* @return explanation behind team name
|
||||
*/
|
||||
String getTeamNameNote();
|
||||
|
||||
/**
|
||||
* Returns true if player is disguised using LibsDisguises
|
||||
* @return true if player is disguised, false if not
|
||||
*
|
||||
* @return true if player is disguised, false if not
|
||||
*/
|
||||
boolean isDisguised();
|
||||
|
||||
/**
|
||||
* Returns true if player has invisibility potion, false if not. For bukkit, API is used, for BungeeCord
|
||||
* bukkit bridge is used
|
||||
* @return true if player has invisibility potion, false if not
|
||||
*
|
||||
* @return true if player has invisibility potion, false if not
|
||||
*/
|
||||
boolean hasInvisibilityPotion();
|
||||
|
||||
/**
|
||||
* Currently only PV hook on BungeeCord for global PlayerList function. Looking to expand this
|
||||
* in the future
|
||||
* @return true if vanished with PV on BungeeCord
|
||||
*
|
||||
* @return true if vanished with PV on BungeeCord
|
||||
*/
|
||||
boolean isVanished();
|
||||
|
||||
/**
|
||||
* Returns true if player is online according to server
|
||||
* @return true if online, false if not
|
||||
*
|
||||
* @return true if online, false if not
|
||||
*/
|
||||
boolean isOnline();
|
||||
|
||||
/**
|
||||
* Returns GameMode of the player (0 for survival, 1 creative, 2 adventure, 3 spectator)
|
||||
* @return GameMode of the player
|
||||
*
|
||||
* @return GameMode of the player
|
||||
*/
|
||||
int getGamemode();
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ public enum BarStyle {
|
||||
/**
|
||||
* Initializes enum constant with given bukkit name
|
||||
*
|
||||
* @param bukkitName
|
||||
* Name of color to be returned in {@code getBukkitName()}
|
||||
* @param bukkitName
|
||||
* Name of color to be returned in {@code getBukkitName()}
|
||||
*/
|
||||
BarStyle(String bukkitName){
|
||||
this.bukkitName = bukkitName;
|
||||
@@ -28,7 +28,7 @@ public enum BarStyle {
|
||||
|
||||
/**
|
||||
* Returns name of this style in Bukkit API
|
||||
* @return name of this style in Bukkit API
|
||||
* @return name of this style in Bukkit API
|
||||
*/
|
||||
public String getBukkitName() {
|
||||
return bukkitName;
|
||||
|
||||
@@ -23,14 +23,16 @@ public interface BossBar {
|
||||
* Returns name of this BossBar. If it was defined in config, returns
|
||||
* the name specified in config. If it was made using the API, returns
|
||||
* randomly generated ID given to this BossBar when creating.
|
||||
* @return name of BossBar
|
||||
*
|
||||
* @return name of BossBar
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns randomly generated uuid of this BossBar used internally to match
|
||||
* the BossBar in client with packets or with Bukkit API BossBar instances.
|
||||
* @return uuid of this BossBar
|
||||
*
|
||||
* @return uuid of this BossBar
|
||||
*/
|
||||
UUID getUniqueId();
|
||||
|
||||
@@ -43,8 +45,8 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If specified title is equal to the current one, nothing happens.
|
||||
*
|
||||
* @param title
|
||||
* New title to display in this BossBar
|
||||
* @param title
|
||||
* New title to display in this BossBar
|
||||
*/
|
||||
void setTitle(String title);
|
||||
|
||||
@@ -59,8 +61,8 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If specified progress is equal to the current one, nothing happens.
|
||||
*
|
||||
* @param progress
|
||||
* New progress to use in this BossBar
|
||||
* @param progress
|
||||
* New progress to use in this BossBar
|
||||
*/
|
||||
void setProgress(String progress);
|
||||
|
||||
@@ -68,8 +70,9 @@ public interface BossBar {
|
||||
* Changes BossBar progress to specified value ranging from 0 to 100.
|
||||
* <p>
|
||||
* If specified progress is equal to the current one, nothing happens.
|
||||
* @param progress
|
||||
* New progress to use in this BossBar
|
||||
*
|
||||
* @param progress
|
||||
* New progress to use in this BossBar
|
||||
*/
|
||||
void setProgress(float progress);
|
||||
|
||||
@@ -84,8 +87,8 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If specified color is equal to the current one, nothing happens.
|
||||
*
|
||||
* @param color
|
||||
* New color to use in this BossBar
|
||||
* @param color
|
||||
* New color to use in this BossBar
|
||||
*/
|
||||
void setColor(String color);
|
||||
|
||||
@@ -94,8 +97,8 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If specified color is equal to the current one, nothing happens.
|
||||
*
|
||||
* @param color
|
||||
* New color to use in this BossBar
|
||||
* @param color
|
||||
* New color to use in this BossBar
|
||||
*/
|
||||
void setColor(BarColor color);
|
||||
|
||||
@@ -110,8 +113,8 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If specified style is equal to the current one, nothing happens.
|
||||
*
|
||||
* @param style
|
||||
* New style to use in this BossBar
|
||||
* @param style
|
||||
* New style to use in this BossBar
|
||||
*/
|
||||
void setStyle(String style);
|
||||
|
||||
@@ -120,36 +123,40 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If specified style is equal to the current one, nothing happens.
|
||||
*
|
||||
* @param style
|
||||
* New style to use in this BossBar
|
||||
* @param style
|
||||
* New style to use in this BossBar
|
||||
*/
|
||||
void setStyle(BarStyle style);
|
||||
|
||||
/**
|
||||
* Returns current title of the BossBar in raw format. If it contains placeholders,
|
||||
* their raw identifiers are used in the result.
|
||||
* @return title of the BossBar
|
||||
*
|
||||
* @return title of the BossBar
|
||||
*/
|
||||
String getTitle();
|
||||
|
||||
/**
|
||||
* Returns progress of the BossBar as a string, which is either entered string
|
||||
* containing placeholders or entered number converted to string
|
||||
* @return entered progress as a string
|
||||
*
|
||||
* @return entered progress as a string
|
||||
*/
|
||||
String getProgress();
|
||||
|
||||
/**
|
||||
* Returns color of the BossBar as a string, which is either entered string
|
||||
* containing placeholders or entered enum value converted to string
|
||||
* @return entered color as a string
|
||||
*
|
||||
* @return entered color as a string
|
||||
*/
|
||||
String getColor();
|
||||
|
||||
/**
|
||||
* Returns style of the BossBar as a string, which is either entered string
|
||||
* containing placeholders or entered enum value converted to string
|
||||
* @return entered style as a string
|
||||
*
|
||||
* @return entered style as a string
|
||||
*/
|
||||
String getStyle();
|
||||
|
||||
@@ -158,8 +165,8 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If the player already sees this BossBar, nothing happens.
|
||||
*
|
||||
* @param player
|
||||
* Player to register this BossBar to
|
||||
* @param player
|
||||
* Player to register this BossBar to
|
||||
*/
|
||||
void addPlayer(TabPlayer player);
|
||||
|
||||
@@ -168,8 +175,8 @@ public interface BossBar {
|
||||
* <p>
|
||||
* If the player does not see this BossBar, nothing happens.
|
||||
*
|
||||
* @param player
|
||||
* Player to unregister this BossBar from
|
||||
* @param player
|
||||
* Player to unregister this BossBar from
|
||||
*/
|
||||
void removePlayer(TabPlayer player);
|
||||
|
||||
@@ -179,15 +186,17 @@ public interface BossBar {
|
||||
* The returned list can only be used to read. Writing
|
||||
* will not work properly. For adding/removing players see {@link #addPlayer(TabPlayer)}
|
||||
* and {@link #removePlayer(TabPlayer)}.
|
||||
* @return List of players seeing this BossBar
|
||||
*
|
||||
* @return List of players seeing this BossBar
|
||||
*/
|
||||
List<TabPlayer> getPlayers();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if specified player can see this BossBar, {@code false} if not
|
||||
* @param player
|
||||
* Player to check for
|
||||
* @return {@code true} if contains, {@code false} if not
|
||||
*
|
||||
* @param player
|
||||
* Player to check for
|
||||
* @return {@code true} if contains, {@code false} if not
|
||||
*/
|
||||
boolean containsPlayer(TabPlayer player);
|
||||
}
|
||||
@@ -20,18 +20,15 @@ public interface BossBarManager {
|
||||
* Creates BossBar with specified parameters and registers it to BossBar manager,
|
||||
* allowing to retrieve it later.
|
||||
*
|
||||
* @param title
|
||||
* Title to display, supports placeholders
|
||||
*
|
||||
* @param progress
|
||||
* Progress to use. Must be between 0 and 100
|
||||
*
|
||||
* @param color
|
||||
* Color to use
|
||||
*
|
||||
* @param style
|
||||
* Style to use
|
||||
* @return The newly created BossBar
|
||||
* @param title
|
||||
* Title to display, supports placeholders
|
||||
* @param progress
|
||||
* Progress to use. Must be between 0 and 100
|
||||
* @param color
|
||||
* Color to use
|
||||
* @param style
|
||||
* Style to use
|
||||
* @return The newly created BossBar
|
||||
*/
|
||||
BossBar createBossBar(String title, float progress, BarColor color, BarStyle style);
|
||||
|
||||
@@ -39,21 +36,18 @@ public interface BossBarManager {
|
||||
* Creates BossBar with specified parameters and registers it to BossBar manager,
|
||||
* allowing to retrieve it later.
|
||||
*
|
||||
* @param title
|
||||
* Title to display, supports placeholders
|
||||
*
|
||||
* @param progress
|
||||
* Progress to use. Must be a string version of a number, or
|
||||
* a placeholder that returns a number
|
||||
*
|
||||
* @param color
|
||||
* Color to use. Must be a string version of one of enum constants, or
|
||||
* a placeholder that returns one of them
|
||||
*
|
||||
* @param style
|
||||
* Style to use. Must be a string version of one of enum constants, or
|
||||
* a placeholder that returns one of them
|
||||
* @return The newly created BossBar
|
||||
* @param title
|
||||
* Title to display, supports placeholders
|
||||
* @param progress
|
||||
* Progress to use. Must be a string version of a number, or
|
||||
* a placeholder that returns a number
|
||||
* @param color
|
||||
* Color to use. Must be a string version of one of enum constants, or
|
||||
* a placeholder that returns one of them
|
||||
* @param style
|
||||
* Style to use. Must be a string version of one of enum constants, or
|
||||
* a placeholder that returns one of them
|
||||
* @return The newly created BossBar
|
||||
*/
|
||||
BossBar createBossBar(String title, String progress, String color, String style);
|
||||
|
||||
@@ -63,9 +57,9 @@ public interface BossBarManager {
|
||||
* retrieved using {@link me.neznamy.tab.api.bossbar.BossBar#getName()}.
|
||||
* Returns null if no such BossBar exists.
|
||||
*
|
||||
* @param name
|
||||
* Name of registered BossBar
|
||||
* @return BossBar with specified name
|
||||
* @param name
|
||||
* Name of registered BossBar
|
||||
* @return BossBar with specified name
|
||||
*/
|
||||
BossBar getBossBar(String name);
|
||||
|
||||
@@ -74,9 +68,9 @@ public interface BossBarManager {
|
||||
* BossBar is created and used in packets / to match which the one from Bukkit API.
|
||||
* Returns null if no such BossBar exists.
|
||||
*
|
||||
* @param id
|
||||
* UUID to return BossBar by
|
||||
* @return BossBar with specified uuid
|
||||
* @param id
|
||||
* UUID to return BossBar by
|
||||
* @return BossBar with specified uuid
|
||||
*/
|
||||
BossBar getBossBar(UUID id);
|
||||
|
||||
@@ -86,31 +80,31 @@ public interface BossBarManager {
|
||||
* <p>
|
||||
* Map key is BossBar's name available in {@link me.neznamy.tab.api.bossbar.BossBar#getName()},
|
||||
* map value is the BossBar interface.
|
||||
* @return all registered BossBars
|
||||
*
|
||||
* @return all registered BossBars
|
||||
*/
|
||||
Map<String, BossBar> getRegisteredBossBars();
|
||||
|
||||
/**
|
||||
* Toggles BossBar for this player and sends toggle message if {@code sendToggleMessage} is true.
|
||||
*
|
||||
* @param player
|
||||
* Player to toggle BossBar for
|
||||
*
|
||||
* @param sendToggleMessage
|
||||
* {@code true} if toggle message should be sent, {@code false} if not
|
||||
* @see #hasBossBarVisible(TabPlayer)
|
||||
* @see #setBossBarVisible(TabPlayer, boolean, boolean)
|
||||
* @param player
|
||||
* Player to toggle BossBar for
|
||||
* @param sendToggleMessage
|
||||
* {@code true} if toggle message should be sent, {@code false} if not
|
||||
* @see #hasBossBarVisible(TabPlayer)
|
||||
* @see #setBossBarVisible(TabPlayer, boolean, boolean)
|
||||
*/
|
||||
void toggleBossBar(TabPlayer player, boolean sendToggleMessage);
|
||||
|
||||
/**
|
||||
* Returns true if player can see BossBars, false if toggled via command or API.
|
||||
*
|
||||
* @param player
|
||||
* Player to check toggle status of
|
||||
* @return {@code true} if visible, {@code false} if disabled (toggled)
|
||||
* @see #toggleBossBar(TabPlayer, boolean)
|
||||
* @see #setBossBarVisible(TabPlayer, boolean, boolean)
|
||||
* @param player
|
||||
* Player to check toggle status of
|
||||
* @return {@code true} if visible, {@code false} if disabled (toggled)
|
||||
* @see #toggleBossBar(TabPlayer, boolean)
|
||||
* @see #setBossBarVisible(TabPlayer, boolean, boolean)
|
||||
*/
|
||||
boolean hasBossBarVisible(TabPlayer player);
|
||||
|
||||
@@ -118,12 +112,12 @@ public interface BossBarManager {
|
||||
* Sets BossBar visibility of player to set value. If value did not change, nothing happens.
|
||||
* If visibility changed, toggle message is sent if {@code sendToggleMessage} is {@code true}.
|
||||
*
|
||||
* @param player
|
||||
* Player to set BossBar visibility of
|
||||
* @param visible
|
||||
* {@code true} if BossBar should be visible, {@code false} if not
|
||||
* @param sendToggleMessage
|
||||
* {@code true} if toggle message should be sent if value changed, {@code false} if not
|
||||
* @param player
|
||||
* Player to set BossBar visibility of
|
||||
* @param visible
|
||||
* {@code true} if BossBar should be visible, {@code false} if not
|
||||
* @param sendToggleMessage
|
||||
* {@code true} if toggle message should be sent if value changed, {@code false} if not
|
||||
* @see #toggleBossBar(TabPlayer, boolean)
|
||||
* @see #hasBossBarVisible(TabPlayer)
|
||||
*/
|
||||
@@ -131,37 +125,40 @@ public interface BossBarManager {
|
||||
|
||||
/**
|
||||
* Temporarily displays registered BossBar to player for specified amount of time in milliseconds.
|
||||
* @param player
|
||||
* Player to show BossBar to
|
||||
* @param bossBar
|
||||
* Name of registered BossBar to show
|
||||
* @param duration
|
||||
* In milliseconds for how long should BossBar be displayed
|
||||
* @throws IllegalArgumentException
|
||||
* if no BossBar with specified name exists
|
||||
* @see #announceBossBar(String, int)
|
||||
* @see #getAnnouncedBossBars()
|
||||
*
|
||||
* @param player
|
||||
* Player to show BossBar to
|
||||
* @param bossBar
|
||||
* Name of registered BossBar to show
|
||||
* @param duration
|
||||
* In milliseconds for how long should BossBar be displayed
|
||||
* @throws IllegalArgumentException
|
||||
* if no BossBar with specified name exists
|
||||
* @see #announceBossBar(String, int)
|
||||
* @see #getAnnouncedBossBars()
|
||||
*/
|
||||
void sendBossBarTemporarily(TabPlayer player, String bossBar, int duration);
|
||||
|
||||
/**
|
||||
* Temporarily displays registered BossBar to all players for specified amount of time in milliseconds.
|
||||
* @param bossBar
|
||||
* Name of registered BossBar to show
|
||||
* @param duration
|
||||
* In milliseconds for how long should BossBar be displayed
|
||||
* @throws IllegalArgumentException
|
||||
* if no BossBar with specified name exists
|
||||
* @see #sendBossBarTemporarily(TabPlayer, String, int)
|
||||
* @see #getAnnouncedBossBars()
|
||||
*
|
||||
* @param bossBar
|
||||
* Name of registered BossBar to show
|
||||
* @param duration
|
||||
* In milliseconds for how long should BossBar be displayed
|
||||
* @throws IllegalArgumentException
|
||||
* if no BossBar with specified name exists
|
||||
* @see #sendBossBarTemporarily(TabPlayer, String, int)
|
||||
* @see #getAnnouncedBossBars()
|
||||
*/
|
||||
void announceBossBar(String bossBar, int duration);
|
||||
|
||||
/**
|
||||
* Returns list of BossBars which are currently being announced.
|
||||
* @return list of currently active BossBar announcements
|
||||
* @see #sendBossBarTemporarily(TabPlayer, String, int)
|
||||
* @see #announceBossBar(String, int)
|
||||
*
|
||||
* @return list of currently active BossBar announcements
|
||||
* @see #sendBossBarTemporarily(TabPlayer, String, int)
|
||||
* @see #announceBossBar(String, int)
|
||||
*/
|
||||
List<BossBar> getAnnouncedBossBars();
|
||||
}
|
||||
@@ -15,12 +15,13 @@ public class ChatClickable {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given action and value.
|
||||
* @param action
|
||||
* click event action
|
||||
* @param value
|
||||
* click event value
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code action} is null or {@code value} is null
|
||||
*
|
||||
* @param action
|
||||
* click event action
|
||||
* @param value
|
||||
* click event value
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code action} is null or {@code value} is null
|
||||
*/
|
||||
public ChatClickable(EnumClickAction action, String value) {
|
||||
Preconditions.checkNotNull(action, "hover action");
|
||||
@@ -31,7 +32,8 @@ public class ChatClickable {
|
||||
|
||||
/**
|
||||
* Returns click action defined in constructor
|
||||
* @return click action
|
||||
*
|
||||
* @return click action
|
||||
*/
|
||||
public EnumClickAction getAction() {
|
||||
return action;
|
||||
@@ -39,7 +41,8 @@ public class ChatClickable {
|
||||
|
||||
/**
|
||||
* Returns click action defined in constructor
|
||||
* @return click action
|
||||
*
|
||||
* @return click action
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
|
||||
@@ -15,12 +15,13 @@ public class ChatHoverable {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given action and value.
|
||||
* @param action
|
||||
* hover event action
|
||||
* @param value
|
||||
* hover event value
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code action} is null or {@code value} is null
|
||||
*
|
||||
* @param action
|
||||
* hover event action
|
||||
* @param value
|
||||
* hover event value
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code action} is null or {@code value} is null
|
||||
*/
|
||||
public ChatHoverable(EnumHoverAction action, IChatBaseComponent value) {
|
||||
Preconditions.checkNotNull(action, "hover action");
|
||||
@@ -31,7 +32,8 @@ public class ChatHoverable {
|
||||
|
||||
/**
|
||||
* Returns hover action defined in constructor
|
||||
* @return hover action
|
||||
*
|
||||
* @return hover action
|
||||
*/
|
||||
public EnumHoverAction getAction() {
|
||||
return action;
|
||||
@@ -39,7 +41,8 @@ public class ChatHoverable {
|
||||
|
||||
/**
|
||||
* Returns hover value defined in constructor
|
||||
* @return hover value
|
||||
*
|
||||
* @return hover value
|
||||
*/
|
||||
public IChatBaseComponent getValue() {
|
||||
return value;
|
||||
|
||||
@@ -94,7 +94,8 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Returns true if bold is defined and set to true, false otherwise
|
||||
* @return true if bold is defined and set to true, false otherwise
|
||||
*
|
||||
* @return true if bold is defined and set to true, false otherwise
|
||||
*/
|
||||
public boolean isBold(){
|
||||
return Boolean.TRUE.equals(bold);
|
||||
@@ -102,7 +103,8 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Returns true if italic is defined and set to true, false otherwise
|
||||
* @return true if italic is defined and set to true, false otherwise
|
||||
*
|
||||
* @return true if italic is defined and set to true, false otherwise
|
||||
*/
|
||||
public boolean isItalic(){
|
||||
return Boolean.TRUE.equals(italic);
|
||||
@@ -110,7 +112,8 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Returns true if underlined is defined and set to true, false otherwise
|
||||
* @return true if underlined is defined and set to true, false otherwise
|
||||
*
|
||||
* @return true if underlined is defined and set to true, false otherwise
|
||||
*/
|
||||
public boolean isUnderlined(){
|
||||
return Boolean.TRUE.equals(underlined);
|
||||
@@ -118,7 +121,8 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Returns true if strikethrough is defined and set to true, false otherwise
|
||||
* @return true if strikethrough is defined and set to true, false otherwise
|
||||
*
|
||||
* @return true if strikethrough is defined and set to true, false otherwise
|
||||
*/
|
||||
public boolean isStrikethrough(){
|
||||
return Boolean.TRUE.equals(strikethrough);
|
||||
@@ -126,7 +130,8 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Returns true if obfuscation is defined and set to true, false otherwise
|
||||
* @return true if obfuscation is defined and set to true, false otherwise
|
||||
*
|
||||
* @return true if obfuscation is defined and set to true, false otherwise
|
||||
*/
|
||||
public boolean isObfuscated(){
|
||||
return Boolean.TRUE.equals(obfuscated);
|
||||
@@ -150,7 +155,9 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets click action to OPEN_URL and url to given value
|
||||
* @param url - url to open
|
||||
*
|
||||
* @param url
|
||||
* url to open
|
||||
*/
|
||||
public void onClickOpenUrl(String url) {
|
||||
Preconditions.checkNotNull(url, "url");
|
||||
@@ -159,7 +166,9 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets click action to RUN_COMMAND and command to given value
|
||||
* @param command - command to perform, might be without / to send a chat message
|
||||
*
|
||||
* @param command
|
||||
* command to perform, might be without / to send a chat message
|
||||
*/
|
||||
public void onClickRunCommand(String command) {
|
||||
Preconditions.checkNotNull(command, "command");
|
||||
@@ -168,7 +177,9 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets click action to SUGGEST_COMMAND and command to given value
|
||||
* @param command - command to suggest
|
||||
*
|
||||
* @param command
|
||||
* command to suggest
|
||||
*/
|
||||
public void onClickSuggestCommand(String command) {
|
||||
Preconditions.checkNotNull(command, "command");
|
||||
@@ -177,7 +188,9 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets click action to CHANGE_PAGE and page id to given value
|
||||
* @param newPage - id of new page
|
||||
*
|
||||
* @param newPage
|
||||
* id of new page
|
||||
*/
|
||||
public void onClickChangePage(int newPage) {
|
||||
if (TabAPI.getInstance().getServerVersion().getMinorVersion() < 8) throw new UnsupportedOperationException("change_page click action is not supported on <1.8");
|
||||
@@ -186,7 +199,9 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets click action to COPY_TO_CLIPBOARD and text to provided value
|
||||
* @param text - text to copy to clipboard on click
|
||||
*
|
||||
* @param text
|
||||
* text to copy to clipboard on click
|
||||
*/
|
||||
public void onClickCopyToClipBoard(String text) {
|
||||
Preconditions.checkNotNull(text, "text");
|
||||
@@ -201,7 +216,9 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets hover action to SHOW_TEXT and text to given value
|
||||
* @param text - text to show
|
||||
*
|
||||
* @param text
|
||||
* text to show
|
||||
*/
|
||||
public void onHoverShowText(IChatBaseComponent text) {
|
||||
Preconditions.checkNotNull(text, "text");
|
||||
@@ -210,7 +227,9 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets hover action to SHOW_ITEM and item to given value
|
||||
* @param serializedItem - item to show
|
||||
*
|
||||
* @param serializedItem
|
||||
* item to show
|
||||
*/
|
||||
public void onHoverShowItem(String serializedItem) {
|
||||
Preconditions.checkNotNull(serializedItem, "item");
|
||||
@@ -219,9 +238,13 @@ public class ChatModifier {
|
||||
|
||||
/**
|
||||
* Sets hover action to SHOW_ENTITY and entity data to given values
|
||||
* @param type - entity type
|
||||
* @param id - entity uuid
|
||||
* @param name - entity custom name
|
||||
*
|
||||
* @param type
|
||||
* entity type
|
||||
* @param id
|
||||
* entity uuid
|
||||
* @param name
|
||||
* entity custom name
|
||||
*/
|
||||
public void onHoverShowEntity(String type, UUID id, String name) {
|
||||
Preconditions.checkNotNull(type, "type");
|
||||
|
||||
@@ -156,11 +156,11 @@ public class DeserializedChatComponent extends IChatBaseComponent {
|
||||
/**
|
||||
* Returns boolean value of requested key from map
|
||||
*
|
||||
* @param jsonObject
|
||||
* map to get value from
|
||||
* @param key
|
||||
* name of key
|
||||
* @return value from json object or null if not present
|
||||
* @param jsonObject
|
||||
* map to get value from
|
||||
* @param key
|
||||
* name of key
|
||||
* @return value from json object or null if not present
|
||||
*/
|
||||
private static Boolean getBoolean(JSONObject jsonObject, String key) {
|
||||
Preconditions.checkNotNull(jsonObject, "json object");
|
||||
|
||||
@@ -59,10 +59,11 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Constructs new color instance with given character and hex code
|
||||
* @param character
|
||||
* character which the color goes by
|
||||
* @param hexCode
|
||||
* 6-digit hex code of the color
|
||||
*
|
||||
* @param character
|
||||
* character which the color goes by
|
||||
* @param hexCode
|
||||
* 6-digit hex code of the color
|
||||
*/
|
||||
EnumChatFormat(char character, String hexCode) {
|
||||
this.character = character;
|
||||
@@ -76,8 +77,9 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Constructs new magic code instance with given character
|
||||
* @param character
|
||||
* character representing the magic code
|
||||
*
|
||||
* @param character
|
||||
* character representing the magic code
|
||||
*/
|
||||
EnumChatFormat(char character) {
|
||||
this.character = character;
|
||||
@@ -90,7 +92,8 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns red value of this color code
|
||||
* @return red value
|
||||
*
|
||||
* @return red value
|
||||
*/
|
||||
public short getRed() {
|
||||
return red;
|
||||
@@ -98,7 +101,8 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns green value of this color code
|
||||
* @return green value
|
||||
*
|
||||
* @return green value
|
||||
*/
|
||||
public short getGreen() {
|
||||
return green;
|
||||
@@ -106,7 +110,8 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns blue value of this color code
|
||||
* @return blue value
|
||||
*
|
||||
* @return blue value
|
||||
*/
|
||||
public short getBlue() {
|
||||
return blue;
|
||||
@@ -114,9 +119,10 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns enum value based on provided character or null if character is not valid
|
||||
* @param c
|
||||
* color code character (0-9, a-f, k-o, r)
|
||||
* @return instance from the character or null if character is not valid
|
||||
*
|
||||
* @param c
|
||||
* color code character (0-9, a-f, k-o, r)
|
||||
* @return instance from the character or null if character is not valid
|
||||
*/
|
||||
public static EnumChatFormat getByChar(char c) {
|
||||
for (EnumChatFormat format : VALUES) {
|
||||
@@ -128,9 +134,10 @@ public enum EnumChatFormat {
|
||||
/**
|
||||
* Returns enum value of last colors used in given string.
|
||||
* If it's null, empty or does not contain color codes, WHITE is returned.
|
||||
* @param string
|
||||
* string to check last colors of
|
||||
* @return last used color code in given string or WHITE if nothing is found
|
||||
*
|
||||
* @param string
|
||||
* string to check last colors of
|
||||
* @return last used color code in given string or WHITE if nothing is found
|
||||
*/
|
||||
public static EnumChatFormat lastColorsOf(String string) {
|
||||
if (string == null || string.length() == 0) return EnumChatFormat.WHITE;
|
||||
@@ -147,7 +154,8 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns color char followed by color's character
|
||||
* @return color char followed by color's character
|
||||
*
|
||||
* @return color char followed by color's character
|
||||
*/
|
||||
public String getFormat() {
|
||||
return chatFormat;
|
||||
@@ -155,7 +163,8 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns character representing this color
|
||||
* @return character representing this color
|
||||
*
|
||||
* @return character representing this color
|
||||
*/
|
||||
public char getCharacter() {
|
||||
return character;
|
||||
@@ -163,7 +172,8 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns hex code of this format, null if this is a magic code
|
||||
* @return hex code of this format
|
||||
*
|
||||
* @return hex code of this format
|
||||
*/
|
||||
public String getHexCode() {
|
||||
return hexCode;
|
||||
@@ -171,13 +181,14 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Returns enum value with exact red, green and blue values or null if no match was found
|
||||
* @param red
|
||||
* exact red value
|
||||
* @param green
|
||||
* exact green value
|
||||
* @param blue
|
||||
* exact blue value
|
||||
* @return enum value or null if no such combination exists
|
||||
*
|
||||
* @param red
|
||||
* exact red value
|
||||
* @param green
|
||||
* exact green value
|
||||
* @param blue
|
||||
* exact blue value
|
||||
* @return enum value or null if no such combination exists
|
||||
*/
|
||||
public static EnumChatFormat fromRGBExact(int red, int green, int blue){
|
||||
for (EnumChatFormat format : VALUES) {
|
||||
@@ -189,9 +200,10 @@ public enum EnumChatFormat {
|
||||
/**
|
||||
* Color translation method taken from bukkit, which converts '&' symbol into
|
||||
* the actual color character if followed by a valid color character.
|
||||
* @param textToTranslate
|
||||
* text to replace color symbol in
|
||||
* @return colorized string from provided text
|
||||
*
|
||||
* @param textToTranslate
|
||||
* text to replace color symbol in
|
||||
* @return colorized string from provided text
|
||||
*/
|
||||
public static String color(String textToTranslate){
|
||||
if (textToTranslate == null) return null;
|
||||
@@ -208,9 +220,10 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Turns back the color symbol into '&' symbol in provided text.
|
||||
* @param text
|
||||
* text to revert colors in
|
||||
* @return reverted text
|
||||
*
|
||||
* @param text
|
||||
* text to revert colors in
|
||||
* @return reverted text
|
||||
*/
|
||||
public static String decolor(String text) {
|
||||
if (text == null) return null;
|
||||
@@ -220,9 +233,10 @@ public enum EnumChatFormat {
|
||||
|
||||
/**
|
||||
* Code taken from bukkit, which returns last color codes used in provided text.
|
||||
* @param input
|
||||
* text to get last colors from
|
||||
* @return last colors used in provided text or empty string if nothing was found
|
||||
*
|
||||
* @param input
|
||||
* text to get last colors from
|
||||
* @return last colors used in provided text or empty string if nothing was found
|
||||
*/
|
||||
public static String getLastColors(String input) {
|
||||
if (input == null) return "";
|
||||
|
||||
@@ -39,8 +39,9 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Constructs a new component which is a clone of provided component
|
||||
* @param component
|
||||
* component to clone
|
||||
*
|
||||
* @param component
|
||||
* component to clone
|
||||
*/
|
||||
public IChatBaseComponent(IChatBaseComponent component) {
|
||||
Preconditions.checkNotNull(component, "component");
|
||||
@@ -53,8 +54,9 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given text
|
||||
* @param text
|
||||
* text to display
|
||||
*
|
||||
* @param text
|
||||
* text to display
|
||||
*/
|
||||
public IChatBaseComponent(String text) {
|
||||
this.text = text;
|
||||
@@ -62,7 +64,8 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Returns list of extra components. If no extra components are defined, returns empty list.
|
||||
* @return list of extra components
|
||||
*
|
||||
* @return list of extra components
|
||||
*/
|
||||
public List<IChatBaseComponent> getExtra(){
|
||||
if (extra == null) return Collections.emptyList();
|
||||
@@ -71,11 +74,12 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Sets full list of extra components to given list. Does not allow empty list.
|
||||
* @param components
|
||||
* components to use as extra
|
||||
* @return self
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code components} is an empty list
|
||||
*
|
||||
* @param components
|
||||
* components to use as extra
|
||||
* @return self
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code components} is an empty list
|
||||
*/
|
||||
public IChatBaseComponent setExtra(List<IChatBaseComponent> components){
|
||||
if (components.isEmpty()) throw new IllegalArgumentException("Unexpected empty array of components"); //exception taken from minecraft
|
||||
@@ -85,8 +89,9 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Appends provided component as extra component
|
||||
* @param child
|
||||
* component to append
|
||||
*
|
||||
* @param child
|
||||
* component to append
|
||||
*/
|
||||
public void addExtra(IChatBaseComponent child) {
|
||||
Preconditions.checkNotNull(child, "extra");
|
||||
@@ -96,7 +101,8 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Returns text of this component
|
||||
* @return text of this component
|
||||
*
|
||||
* @return text of this component
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
@@ -104,7 +110,8 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Returns chat modifier of this component
|
||||
* @return chat modifier of this component
|
||||
*
|
||||
* @return chat modifier of this component
|
||||
*/
|
||||
public ChatModifier getModifier() {
|
||||
return modifier;
|
||||
@@ -112,10 +119,11 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Sets modifier to provided value
|
||||
* @param modifier
|
||||
* modifier to set value to
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code modifier} is null
|
||||
*
|
||||
* @param modifier
|
||||
* modifier to set value to
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code modifier} is null
|
||||
*/
|
||||
public void setModifier(ChatModifier modifier) {
|
||||
Preconditions.checkNotNull(modifier, "modifier");
|
||||
@@ -124,8 +132,9 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Changes text of this component
|
||||
* @param text
|
||||
* text to show
|
||||
*
|
||||
* @param text
|
||||
* text to show
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
@@ -133,9 +142,10 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Deserializes string and returns created component. If provided string is null, returns null.
|
||||
* @param json
|
||||
* serialized string
|
||||
* @return Deserialized component or null if input is null
|
||||
*
|
||||
* @param json
|
||||
* serialized string
|
||||
* @return Deserialized component or null if input is null
|
||||
*/
|
||||
public static IChatBaseComponent deserialize(String json) {
|
||||
if (json == null) return null;
|
||||
@@ -146,8 +156,9 @@ public class IChatBaseComponent {
|
||||
* Converts the component to a string representing the serialized component.
|
||||
* This method is only used internally by json library since it's missing
|
||||
* protocol version field used by the method.
|
||||
* @return serialized component in string form
|
||||
* @see #toString(ProtocolVersion)
|
||||
*
|
||||
* @return serialized component in string form
|
||||
* @see #toString(ProtocolVersion)
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -162,9 +173,10 @@ public class IChatBaseComponent {
|
||||
/**
|
||||
* Serializes this component with colors based on client version.
|
||||
* If client version is <1.16, HEX colors will be converted to legacy colors.
|
||||
* @param clientVersion
|
||||
* client version to adapt component for
|
||||
* @return serialized string
|
||||
*
|
||||
* @param clientVersion
|
||||
* client version to adapt component for
|
||||
* @return serialized string
|
||||
*/
|
||||
public String toString(ProtocolVersion clientVersion) {
|
||||
return toString(clientVersion, false);
|
||||
@@ -173,11 +185,12 @@ public class IChatBaseComponent {
|
||||
/**
|
||||
* Serializes this component with colors based on client version.
|
||||
* If client version is <1.16, HEX colors will be converted to legacy colors.
|
||||
* @param clientVersion
|
||||
* client version to adapt component for
|
||||
* @param sendTranslatableIfEmpty
|
||||
* whether empty translatable should be sent if text is empty or not
|
||||
* @return serialized string
|
||||
*
|
||||
* @param clientVersion
|
||||
* client version to adapt component for
|
||||
* @param sendTranslatableIfEmpty
|
||||
* whether empty translatable should be sent if text is empty or not
|
||||
* @return serialized string
|
||||
*/
|
||||
public String toString(ProtocolVersion clientVersion, boolean sendTranslatableIfEmpty) {
|
||||
if (extra == null) {
|
||||
@@ -211,9 +224,10 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Returns organized component from colored text
|
||||
* @param originalText
|
||||
* text to convert
|
||||
* @return organized component from colored text
|
||||
*
|
||||
* @param originalText
|
||||
* text to convert
|
||||
* @return organized component from colored text
|
||||
*/
|
||||
public static IChatBaseComponent fromColoredText(String originalText){
|
||||
Preconditions.checkNotNull(originalText, "text");
|
||||
@@ -299,11 +313,12 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Returns true if text contains legacy color request at defined RGB index start
|
||||
* @param text
|
||||
* text to check
|
||||
* @param i
|
||||
* current index start
|
||||
* @return true if legacy color is defined, false if not
|
||||
*
|
||||
* @param text
|
||||
* text to check
|
||||
* @param i
|
||||
* current index start
|
||||
* @return true if legacy color is defined, false if not
|
||||
*/
|
||||
private static boolean containsLegacyCode(String text, int i) {
|
||||
if (text.length() - i < 9 || text.charAt(i+7) != '|') return false;
|
||||
@@ -312,7 +327,8 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Converts this component into a simple text with legacy colors (the closest match if color is set to RGB)
|
||||
* @return The simple text format
|
||||
*
|
||||
* @return The simple text format
|
||||
*/
|
||||
public String toLegacyText() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -323,11 +339,12 @@ public class IChatBaseComponent {
|
||||
/**
|
||||
* Appends text to string builder, might also add color and magic codes if they are different
|
||||
* from previous component in chain.
|
||||
* @param builder
|
||||
* builder to append text to
|
||||
* @param previousFormatting
|
||||
* colors and magic codes in previous component
|
||||
* @return wew formatting, might be identical to previous one
|
||||
*
|
||||
* @param builder
|
||||
* builder to append text to
|
||||
* @param previousFormatting
|
||||
* colors and magic codes in previous component
|
||||
* @return new formatting, might be identical to previous one
|
||||
*/
|
||||
private String append(StringBuilder builder, String previousFormatting) {
|
||||
String formatting = previousFormatting;
|
||||
@@ -347,7 +364,8 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Returns colors and magic codes of this component
|
||||
* @return used colors and magic codes
|
||||
*
|
||||
* @return used colors and magic codes
|
||||
*/
|
||||
private String getFormatting() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -365,7 +383,8 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Returns raw text without colors, only works correctly when component is organized
|
||||
* @return raw text in this component and all child components
|
||||
*
|
||||
* @return raw text in this component and all child components
|
||||
*/
|
||||
public String toRawText() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -378,7 +397,8 @@ public class IChatBaseComponent {
|
||||
|
||||
/**
|
||||
* Converts the component into flat text with used colors (including rgb) and magic codes
|
||||
* @return converted text
|
||||
*
|
||||
* @return converted text
|
||||
*/
|
||||
public String toFlatText() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -395,9 +415,10 @@ public class IChatBaseComponent {
|
||||
* Returns the most optimized component based on text. Returns null if text is null,
|
||||
* organized component if RGB colors are used or simple component with only text field
|
||||
* containing the whole text when no RGB colors are used
|
||||
* @param text
|
||||
* text to create component from
|
||||
* @return The most performance-optimized component based on text
|
||||
*
|
||||
* @param text
|
||||
* text to create component from
|
||||
* @return The most performance-optimized component based on text
|
||||
*/
|
||||
public static IChatBaseComponent optimizedComponent(String text){
|
||||
if (text == null) return null;
|
||||
|
||||
@@ -29,10 +29,10 @@ public class TextColor {
|
||||
/**
|
||||
* Constructs new instance as a clone of the provided color.
|
||||
*
|
||||
* @param color
|
||||
* color to create a clone of
|
||||
* @throws IllegalArgumentException
|
||||
* if color is {@code null}
|
||||
* @param color
|
||||
* color to create a clone of
|
||||
* @throws IllegalArgumentException
|
||||
* if color is {@code null}
|
||||
*/
|
||||
public TextColor(TextColor color) {
|
||||
Preconditions.checkNotNull(color, "color");
|
||||
@@ -45,10 +45,10 @@ public class TextColor {
|
||||
/**
|
||||
* Constructs new instance from provided 6-digit hex code string
|
||||
*
|
||||
* @param hexCode
|
||||
* a 6-digit combination of hex numbers as a string
|
||||
* @throws IllegalArgumentException
|
||||
* if hexCode is {@code null}
|
||||
* @param hexCode
|
||||
* a 6-digit combination of hex numbers as a string
|
||||
* @throws IllegalArgumentException
|
||||
* if hexCode is {@code null}
|
||||
*/
|
||||
public TextColor(String hexCode) {
|
||||
Preconditions.checkNotNull(hexCode, "hex code");
|
||||
@@ -58,12 +58,12 @@ public class TextColor {
|
||||
/**
|
||||
* Constructs new instance from provided 6-digit hex code and forced legacy color
|
||||
*
|
||||
* @param hexCode
|
||||
* 6-digit combination of hex numbers as a string
|
||||
* @param legacyColor
|
||||
* color to use for legacy clients instead of using the closest legacy color
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code hexCode} is {@code null} or {@code legacyColor} is {@code null}
|
||||
* @param hexCode
|
||||
* 6-digit combination of hex numbers as a string
|
||||
* @param legacyColor
|
||||
* color to use for legacy clients instead of using the closest legacy color
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code hexCode} is {@code null} or {@code legacyColor} is {@code null}
|
||||
*/
|
||||
public TextColor(String hexCode, EnumChatFormat legacyColor) {
|
||||
Preconditions.checkNotNull(hexCode, "hex code");
|
||||
@@ -76,10 +76,10 @@ public class TextColor {
|
||||
/**
|
||||
* Constructs new instance from provided legacy color
|
||||
*
|
||||
* @param legacyColor
|
||||
* legacy color to construct the instance from
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code legacyColor} is {@code null}
|
||||
* @param legacyColor
|
||||
* legacy color to construct the instance from
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code legacyColor} is {@code null}
|
||||
*/
|
||||
public TextColor(EnumChatFormat legacyColor) {
|
||||
Preconditions.checkNotNull(legacyColor, "legacy color");
|
||||
@@ -90,14 +90,14 @@ public class TextColor {
|
||||
/**
|
||||
* Constructs new instance with red, green and blue values
|
||||
*
|
||||
* @param red
|
||||
* red value
|
||||
* @param green
|
||||
* green value
|
||||
* @param blue
|
||||
* blue value
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code red}, {@code green} or {@code blue} is out of range ({@code 0-255})
|
||||
* @param red
|
||||
* red value
|
||||
* @param green
|
||||
* green value
|
||||
* @param blue
|
||||
* blue value
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code red}, {@code green} or {@code blue} is out of range ({@code 0-255})
|
||||
*/
|
||||
public TextColor(int red, int green, int blue) {
|
||||
Preconditions.checkRange(red, 0, 255, "red");
|
||||
@@ -130,7 +130,8 @@ public class TextColor {
|
||||
|
||||
/**
|
||||
* Returns {@code red} value
|
||||
* @return red value
|
||||
*
|
||||
* @return red value
|
||||
*/
|
||||
public int getRed() {
|
||||
if (rgb == -1) rgb = Integer.parseInt(hexCode, 16);
|
||||
@@ -139,7 +140,8 @@ public class TextColor {
|
||||
|
||||
/**
|
||||
* Returns {@code green} value
|
||||
* @return green value
|
||||
*
|
||||
* @return green value
|
||||
*/
|
||||
public int getGreen() {
|
||||
if (rgb == -1) rgb = Integer.parseInt(hexCode, 16);
|
||||
@@ -148,7 +150,8 @@ public class TextColor {
|
||||
|
||||
/**
|
||||
* Returns {@code blue} value
|
||||
* @return blue value
|
||||
*
|
||||
* @return blue value
|
||||
*/
|
||||
public int getBlue() {
|
||||
if (rgb == -1) rgb = Integer.parseInt(hexCode, 16);
|
||||
@@ -159,7 +162,8 @@ public class TextColor {
|
||||
* Returns the closest legacy color of this color object.
|
||||
* If the color was defined in constructor, it's returned.
|
||||
* Otherwise, the closest color is calculated the then returned.
|
||||
* @return closest legacy color
|
||||
*
|
||||
* @return closest legacy color
|
||||
*/
|
||||
public EnumChatFormat getLegacyColor() {
|
||||
if (legacyColor == null) legacyColor = loadClosestColor();
|
||||
@@ -168,7 +172,8 @@ public class TextColor {
|
||||
|
||||
/**
|
||||
* Returns the rgb combination as a 6-digit hex code string
|
||||
* @return the rgb combination as a 6-digit hex code string
|
||||
*
|
||||
* @return the rgb combination as a 6-digit hex code string
|
||||
*/
|
||||
public String getHexCode() {
|
||||
if (hexCode == null) hexCode = String.format("%06X", rgb);
|
||||
@@ -178,7 +183,8 @@ public class TextColor {
|
||||
/**
|
||||
* Converts the color into a valid color value used in color field in chat component.
|
||||
* That is either 6-digit hex code prefixed with '#', or lowercase legacy color.
|
||||
* @return the color serialized for use in chat component
|
||||
*
|
||||
* @return the color serialized for use in chat component
|
||||
*/
|
||||
public String toString() {
|
||||
EnumChatFormat legacyEquivalent = EnumChatFormat.fromRGBExact(getRed(), getGreen(), getBlue());
|
||||
@@ -191,7 +197,8 @@ public class TextColor {
|
||||
|
||||
/**
|
||||
* Returns true if legacy color was forced with a constructor, false if not
|
||||
* @return true if forced, false if not
|
||||
*
|
||||
* @return true if forced, false if not
|
||||
*/
|
||||
public boolean isLegacyColorForced() {
|
||||
return legacyColorForced;
|
||||
@@ -202,9 +209,10 @@ public class TextColor {
|
||||
* If the entered string is null, returns null.
|
||||
* If it's prefixed with '#', it's considered as a hex code.
|
||||
* Otherwise, it is considered being a lowercase legacy color.
|
||||
* @param string
|
||||
* string from color field in chat component
|
||||
* @return An instance from specified string or null if string is null
|
||||
*
|
||||
* @param string
|
||||
* string from color field in chat component
|
||||
* @return An instance from specified string or null if string is null
|
||||
*/
|
||||
public static TextColor fromString(String string) {
|
||||
if (string == null) return null;
|
||||
|
||||
@@ -63,7 +63,8 @@ public class RGBUtils {
|
||||
|
||||
/**
|
||||
* Returns instance of this class
|
||||
* @return instance
|
||||
*
|
||||
* @return instance
|
||||
*/
|
||||
public static RGBUtils getInstance() {
|
||||
return instance;
|
||||
@@ -74,11 +75,12 @@ public class RGBUtils {
|
||||
* This method is called on every property initialization to convert formats
|
||||
* once instead of on every refresh, if possible. Because of that, parameter
|
||||
* {@code ignorePlaceholders} exists to not break raw placeholder identifiers
|
||||
* @param text
|
||||
* original text
|
||||
* @param ignorePlaceholders
|
||||
* whether placeholders should be ignored or not
|
||||
* @return text where everything is converted to #RRGGBB
|
||||
*
|
||||
* @param text
|
||||
* original text
|
||||
* @param ignorePlaceholders
|
||||
* whether placeholders should be ignored or not
|
||||
* @return text where everything is converted to #RRGGBB
|
||||
*/
|
||||
public String applyFormats(String text, boolean ignorePlaceholders) {
|
||||
Preconditions.checkNotNull(text, "text");
|
||||
@@ -96,11 +98,12 @@ public class RGBUtils {
|
||||
* Converts TAB's RGB format (#RRGGBB) into bukkit one
|
||||
* (&x&r&r&g&g&b&b) for modern
|
||||
* clients (1.16+), for legacy clients it will use the closest color.
|
||||
* @param text
|
||||
* text to convert
|
||||
* @param rgbClient
|
||||
* whether client accepts RGB or not
|
||||
* @return converted text
|
||||
*
|
||||
* @param text
|
||||
* text to convert
|
||||
* @param rgbClient
|
||||
* whether client accepts RGB or not
|
||||
* @return converted text
|
||||
*/
|
||||
public String convertToBukkitFormat(String text, boolean rgbClient) {
|
||||
if (text == null) return null;
|
||||
@@ -124,9 +127,10 @@ public class RGBUtils {
|
||||
|
||||
/**
|
||||
* Converts all hex codes in given string to legacy codes
|
||||
* @param text
|
||||
* text to convert
|
||||
* @return translated text
|
||||
*
|
||||
* @param text
|
||||
* text to convert
|
||||
* @return translated text
|
||||
*/
|
||||
public String convertRGBtoLegacy(String text) {
|
||||
if (text == null) return null;
|
||||
@@ -158,9 +162,10 @@ public class RGBUtils {
|
||||
/**
|
||||
* Returns true if entered string is a valid 6-digit combination of
|
||||
* hexadecimal numbers, false if not
|
||||
* @param string
|
||||
* string to check
|
||||
* @return {@code true} if valid, {@code false} if not
|
||||
*
|
||||
* @param string
|
||||
* string to check
|
||||
* @return {@code true} if valid, {@code false} if not
|
||||
*/
|
||||
public boolean isHexCode(String string) {
|
||||
Preconditions.checkNotNull(string, "string");
|
||||
@@ -174,11 +179,12 @@ public class RGBUtils {
|
||||
|
||||
/**
|
||||
* Returns true if text contains legacy color request at defined RGB index start
|
||||
* @param text
|
||||
* text to check
|
||||
* @param i
|
||||
* current index start
|
||||
* @return {@code true} if legacy color is defined and valid, {@code false} otherwise
|
||||
*
|
||||
* @param text
|
||||
* text to check
|
||||
* @param i
|
||||
* current index start
|
||||
* @return {@code true} if legacy color is defined and valid, {@code false} otherwise
|
||||
*/
|
||||
private static boolean containsLegacyCode(String text, int i) {
|
||||
if (text.length() - i < 9 || text.charAt(i+7) != '|') return false;
|
||||
|
||||
@@ -7,8 +7,10 @@ public interface RGBFormatter {
|
||||
|
||||
/**
|
||||
* Reformats RGB codes in provided text into #RRGGBB format
|
||||
* @param text - text to format
|
||||
* @return reformatted text
|
||||
*
|
||||
* @param text
|
||||
* text to format
|
||||
* @return reformatted text
|
||||
*/
|
||||
String reformat(String text);
|
||||
}
|
||||
@@ -10,17 +10,23 @@ public interface GradientPattern {
|
||||
|
||||
/**
|
||||
* Applies gradients in provided text and returns text using only #RRGGBB
|
||||
* @param text - text to be reformatted
|
||||
* @return reformatted text
|
||||
*
|
||||
* @param text
|
||||
* text to be reformatted
|
||||
* @return reformatted text
|
||||
*/
|
||||
String applyPattern(String text, boolean ignorePlaceholders);
|
||||
|
||||
/**
|
||||
* Returns gradient text based on start color, text and end color
|
||||
* @param start - start color
|
||||
* @param text - text to be reformatted
|
||||
* @param end - end color
|
||||
* @return reformatted text
|
||||
*
|
||||
* @param start
|
||||
* start color
|
||||
* @param text
|
||||
* text to be reformatted
|
||||
* @param end
|
||||
* end color
|
||||
* @return reformatted text
|
||||
*/
|
||||
default String asGradient(TextColor start, String text, TextColor end) {
|
||||
//lazy support for magic codes in gradients
|
||||
|
||||
@@ -38,16 +38,16 @@ public abstract class ConfigurationFile {
|
||||
* Constructs new instance and attempts to load specified configuration file.
|
||||
* If file does not exist, default file is copied from {@code source}.
|
||||
*
|
||||
* @param source
|
||||
* Source to copy file from if it does not exist
|
||||
* @param destination
|
||||
* File destination to use
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code destination} is null
|
||||
* @throws IllegalStateException
|
||||
* if file does not exist and source is null
|
||||
* @throws IOException
|
||||
* if I/O operation with the file unexpectedly fails
|
||||
* @param source
|
||||
* Source to copy file from if it does not exist
|
||||
* @param destination
|
||||
* File destination to use
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code destination} is null
|
||||
* @throws IllegalStateException
|
||||
* if file does not exist and source is null
|
||||
* @throws IOException
|
||||
* if I/O operation with the file unexpectedly fails
|
||||
*/
|
||||
protected ConfigurationFile(InputStream source, File destination) throws IOException {
|
||||
Preconditions.checkNotNull(destination, "destination");
|
||||
@@ -76,7 +76,8 @@ public abstract class ConfigurationFile {
|
||||
|
||||
/**
|
||||
* Returns simple name of the file
|
||||
* @return simple name of the file
|
||||
*
|
||||
* @return simple name of the file
|
||||
*/
|
||||
public String getName() {
|
||||
return file.getName();
|
||||
@@ -84,7 +85,8 @@ public abstract class ConfigurationFile {
|
||||
|
||||
/**
|
||||
* Returns the root value map
|
||||
* @return the root value map
|
||||
*
|
||||
* @return the root value map
|
||||
*/
|
||||
public Map<String, Object> getValues(){
|
||||
return values;
|
||||
@@ -99,11 +101,11 @@ public abstract class ConfigurationFile {
|
||||
* {@code defaultValue} is not {@code null}, value is inserted, {@link #save()}
|
||||
* called and {@code defaultValue} returned.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file
|
||||
*/
|
||||
public Object getObject(String path, Object defaultValue) {
|
||||
Object value = values;
|
||||
@@ -126,9 +128,9 @@ public abstract class ConfigurationFile {
|
||||
* Returns config option with specified path. If option is not present,
|
||||
* {@code null} is returned.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from configuration file or null if not present
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from configuration file or null if not present
|
||||
*/
|
||||
public Object getObject(String path) {
|
||||
return getObject(path, null);
|
||||
@@ -149,11 +151,11 @@ public abstract class ConfigurationFile {
|
||||
* Returns value from map without case sensitivity of the key. Returns
|
||||
* {@code null} if no such key is found.
|
||||
*
|
||||
* @param map
|
||||
* map to get value from
|
||||
* @param key
|
||||
* case-insensitive key name
|
||||
* @return map value from case-insensitive key
|
||||
* @param map
|
||||
* map to get value from
|
||||
* @param key
|
||||
* case-insensitive key name
|
||||
* @return map value from case-insensitive key
|
||||
*/
|
||||
private Object getIgnoreCase(Map<Object, Object> map, String key) {
|
||||
for (Entry<Object, Object> entry : map.entrySet()) {
|
||||
@@ -166,9 +168,9 @@ public abstract class ConfigurationFile {
|
||||
* Returns config option with specified path as {@code String}. Returns {@code null} if
|
||||
* option is not present.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from file or null if not present
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from file or null if not present
|
||||
*/
|
||||
public String getString(String path) {
|
||||
return getString(path, null);
|
||||
@@ -179,11 +181,11 @@ public abstract class ConfigurationFile {
|
||||
* and {@code defaultValue} is not {@code null}, value is inserted, {@link #save()} called
|
||||
* and {@code defaultValue} returned.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code String}
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code String}
|
||||
*/
|
||||
public String getString(String path, String defaultValue) {
|
||||
Object value = getObject(path, defaultValue);
|
||||
@@ -195,9 +197,9 @@ public abstract class ConfigurationFile {
|
||||
* Returns config option with specified path as {@code List<String>}. Returns {@code null} if
|
||||
* option is not present.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from file or null if not present
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from file or null if not present
|
||||
*/
|
||||
public List<String> getStringList(String path) {
|
||||
return getStringList(path, null);
|
||||
@@ -208,11 +210,11 @@ public abstract class ConfigurationFile {
|
||||
* and {@code defaultValue} is not {@code null}, value is inserted, {@link #save()} called
|
||||
* and {@code defaultValue} returned.
|
||||
*
|
||||
* @param path
|
||||
* Path of the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code List<String>}
|
||||
* @param path
|
||||
* Path of the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code List<String>}
|
||||
*/
|
||||
public List<String> getStringList(String path, List<String> defaultValue) {
|
||||
Object value = getObject(path, defaultValue);
|
||||
@@ -231,9 +233,9 @@ public abstract class ConfigurationFile {
|
||||
* Returns config option with specified path as {@code Integer}. Returns {@code null} if
|
||||
* option is not present.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from file or null if not present
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from file or null if not present
|
||||
*/
|
||||
public Integer getInt(String path) {
|
||||
return getInt(path, null);
|
||||
@@ -244,11 +246,11 @@ public abstract class ConfigurationFile {
|
||||
* and {@code defaultValue} is not {@code null}, value is inserted, {@link #save()} called
|
||||
* and {@code defaultValue} returned.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code Integer}
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code Integer}
|
||||
*/
|
||||
public Integer getInt(String path, Integer defaultValue) {
|
||||
Object value = getObject(path, defaultValue);
|
||||
@@ -265,11 +267,11 @@ public abstract class ConfigurationFile {
|
||||
* and {@code defaultValue} is not {@code null}, value is inserted, {@link #save()} called
|
||||
* and {@code defaultValue} returned.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code Boolean}
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code Boolean}
|
||||
*/
|
||||
public boolean getBoolean(String path, boolean defaultValue) {
|
||||
Object value = getObject(path, defaultValue);
|
||||
@@ -282,11 +284,11 @@ public abstract class ConfigurationFile {
|
||||
* and {@code defaultValue} is not {@code null}, value is inserted, {@link #save()} called
|
||||
* and {@code defaultValue} returned.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code Double}
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param defaultValue
|
||||
* Value to be inserted and returned if option is not present
|
||||
* @return value from configuration file as {@code Double}
|
||||
*/
|
||||
public Double getDouble(String path, double defaultValue) {
|
||||
Object value = getObject(path, defaultValue);
|
||||
@@ -302,9 +304,9 @@ public abstract class ConfigurationFile {
|
||||
* Returns config option with specified path as {@code Map<K, V>}. If the option
|
||||
* is not present or value is not a {@code Map}, new empty {@code Map} is returned.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from configuration file as {@code Map<K, V>}
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return value from configuration file as {@code Map<K, V>}
|
||||
*/
|
||||
public <K, V> Map<K, V> getConfigurationSection(String path) {
|
||||
if (path == null || path.length() == 0) return (Map<K, V>) values;
|
||||
@@ -320,9 +322,9 @@ public abstract class ConfigurationFile {
|
||||
* Returns {@code true} if the file has option with specified path, {@code false}
|
||||
* if not.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return {@code true} if present, {@code false} if not
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @return {@code true} if present, {@code false} if not
|
||||
*/
|
||||
public boolean hasConfigOption(String path) {
|
||||
return getObject(path) != null;
|
||||
@@ -331,10 +333,10 @@ public abstract class ConfigurationFile {
|
||||
/**
|
||||
* Sets value to the specified path and saves the file to disk by calling {@link #save()}.
|
||||
*
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param value
|
||||
* Value to save
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param value
|
||||
* Value to save
|
||||
*/
|
||||
public void set(String path, Object value) {
|
||||
set(values, path, value);
|
||||
@@ -345,13 +347,13 @@ public abstract class ConfigurationFile {
|
||||
* Sets value to the specified map with specified path and value. This is an internal method
|
||||
* that correctly creates maps to separate sections using "{@code .}".
|
||||
*
|
||||
* @param map
|
||||
* Map to insert value to
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param value
|
||||
* Value to save
|
||||
* @return the first argument to allow chaining
|
||||
* @param map
|
||||
* Map to insert value to
|
||||
* @param path
|
||||
* Path to the option with sections separated with "{@code .}"
|
||||
* @param value
|
||||
* Value to save
|
||||
* @return the first argument to allow chaining
|
||||
*/
|
||||
private Map<String, Object> set(Map<String, Object> map, String path, Object value) {
|
||||
if (path.contains(".")) {
|
||||
@@ -375,11 +377,11 @@ public abstract class ConfigurationFile {
|
||||
* Returns the real key name without case sensitivity from map. If not found, inserted key
|
||||
* is returned.
|
||||
*
|
||||
* @param map
|
||||
* Map to check keys of
|
||||
* @param key
|
||||
* Key to find
|
||||
* @return The real key name
|
||||
* @param map
|
||||
* Map to check keys of
|
||||
* @param key
|
||||
* Key to find
|
||||
* @return The real key name
|
||||
*/
|
||||
private String getRealKey(Map<?, ?> map, String key) {
|
||||
for (Object mapKey : map.keySet()) {
|
||||
@@ -391,8 +393,8 @@ public abstract class ConfigurationFile {
|
||||
/**
|
||||
* Detects header of a file (first lines of file starting with #).
|
||||
*
|
||||
* @throws IOException
|
||||
* if I/O operation fails
|
||||
* @throws IOException
|
||||
* if I/O operation fails
|
||||
*/
|
||||
private void detectHeader() throws IOException {
|
||||
header = new ArrayList<>();
|
||||
@@ -409,8 +411,8 @@ public abstract class ConfigurationFile {
|
||||
* Inserts header back into file. This is required after calling {@link #save()}, because
|
||||
* it destroys the header.
|
||||
*
|
||||
* @throws IOException
|
||||
* if I/O operation fails
|
||||
* @throws IOException
|
||||
* if I/O operation fails
|
||||
*/
|
||||
public void fixHeader() throws IOException {
|
||||
if (header == null) return;
|
||||
|
||||
@@ -36,18 +36,18 @@ public class YamlConfigurationFile extends ConfigurationFile {
|
||||
* Constructs new instance and attempts to load specified configuration file.
|
||||
* If file does not exist, default file is copied from {@code source}.
|
||||
*
|
||||
* @param source
|
||||
* Source to copy file from if it does not exist
|
||||
* @param destination
|
||||
* File destination to use
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code destination} is null
|
||||
* @throws IllegalStateException
|
||||
* if file does not exist and source is null
|
||||
* @throws YAMLException
|
||||
* if file has invalid YAML syntax
|
||||
* @throws IOException
|
||||
* if I/O operation with the file unexpectedly fails
|
||||
* @param source
|
||||
* Source to copy file from if it does not exist
|
||||
* @param destination
|
||||
* File destination to use
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code destination} is null
|
||||
* @throws IllegalStateException
|
||||
* if file does not exist and source is null
|
||||
* @throws YAMLException
|
||||
* if file has invalid YAML syntax
|
||||
* @throws IOException
|
||||
* if I/O operation with the file unexpectedly fails
|
||||
*/
|
||||
public YamlConfigurationFile(InputStream source, File destination) throws YAMLException, IOException {
|
||||
super(source, destination);
|
||||
|
||||
@@ -11,14 +11,15 @@ public interface PlayerLoadEvent extends TabEvent {
|
||||
/**
|
||||
* Gets the player that was loaded.
|
||||
*
|
||||
* @return the player that was loaded
|
||||
* @return the player that was loaded
|
||||
*/
|
||||
TabPlayer getPlayer();
|
||||
|
||||
/**
|
||||
* Returns true if player was loaded because they joined,
|
||||
* false if the player was loaded because tab reload command was executed
|
||||
* @return true if player joined, false if plugin was reloaded
|
||||
*
|
||||
* @return true if player joined, false if plugin was reloaded
|
||||
*/
|
||||
boolean isJoin();
|
||||
}
|
||||
@@ -27,16 +27,21 @@ public interface PlaceholderManager {
|
||||
|
||||
/**
|
||||
* Detects placeholders in text using %% pattern and returns list of all detected identifiers
|
||||
* @param text - text to detect placeholders in
|
||||
* @return list of detected identifiers
|
||||
*
|
||||
* @param text
|
||||
* text to detect placeholders in
|
||||
* @return list of detected identifiers
|
||||
*/
|
||||
List<String> detectPlaceholders(String text);
|
||||
|
||||
/**
|
||||
* Adds placeholder to list of used placeholders and assigns this feature as using it,
|
||||
* which will then receive refresh() if values changes
|
||||
* @param identifier - placeholder identifier
|
||||
* @param feature - feature using the placeholder
|
||||
*
|
||||
* @param identifier
|
||||
* placeholder identifier
|
||||
* @param feature
|
||||
* feature using the placeholder
|
||||
*/
|
||||
void addUsedPlaceholder(String identifier, TabFeature feature);
|
||||
|
||||
|
||||
@@ -8,11 +8,21 @@ public interface PlayerPlaceholder extends Placeholder {
|
||||
|
||||
/**
|
||||
* Calls the placeholder request function and returns the output.
|
||||
* If the placeholder thrown an exception, it is logged in {@code placeholder-errors.log}
|
||||
* If the placeholder threw an exception, it is logged in {@code placeholder-errors.log}
|
||||
* file and "ERROR" is returned.
|
||||
* @param p
|
||||
* player to get placeholder value for
|
||||
* @return value placeholder returned or "ERROR" if it threw an error
|
||||
*
|
||||
* @param p
|
||||
* player to get placeholder value for
|
||||
* @return value placeholder returned or "ERROR" if it threw an error
|
||||
*/
|
||||
Object request(TabPlayer p);
|
||||
|
||||
/**
|
||||
* Returns last known value for given player.
|
||||
*
|
||||
* @param player
|
||||
* player to get last value for
|
||||
* @return last known value for entered player
|
||||
*/
|
||||
String getLastValue(TabPlayer player);
|
||||
}
|
||||
@@ -6,5 +6,28 @@ public interface RelationalPlaceholder extends Placeholder {
|
||||
|
||||
void updateValue(TabPlayer viewer, TabPlayer target, Object value);
|
||||
|
||||
/**
|
||||
* Calls the placeholder request function and returns the output.
|
||||
* If the placeholder threw an exception, it is logged in {@code placeholder-errors.log}
|
||||
* file and "ERROR" is returned.
|
||||
*
|
||||
* @param viewer
|
||||
* player looking at output of the placeholder
|
||||
* @param target
|
||||
* player the placeholder is displayed on
|
||||
* @return value placeholder returned or "ERROR" if it threw an error
|
||||
*/
|
||||
Object request(TabPlayer viewer, TabPlayer target);
|
||||
|
||||
/**
|
||||
* Returns last known value for given players. First player is viewer,
|
||||
* second player is target.
|
||||
*
|
||||
* @param viewer
|
||||
* viewer of the placeholder
|
||||
* @param target
|
||||
* target who is the text displayed on
|
||||
* @return last known value for entered player duo
|
||||
*/
|
||||
String getLastValue(TabPlayer viewer, TabPlayer target);
|
||||
}
|
||||
@@ -4,5 +4,19 @@ public interface ServerPlaceholder extends Placeholder {
|
||||
|
||||
void updateValue(Object value);
|
||||
|
||||
/**
|
||||
* Calls the placeholder request function and returns the output.
|
||||
* If the placeholder threw an exception, it is logged in {@code placeholder-errors.log}
|
||||
* file and "ERROR" is returned.
|
||||
*
|
||||
* @return value placeholder returned or "ERROR" if it threw an error
|
||||
*/
|
||||
Object request();
|
||||
|
||||
/**
|
||||
* Returns last known value of the placeholder.
|
||||
*
|
||||
* @return last known value
|
||||
*/
|
||||
String getLastValue();
|
||||
}
|
||||
@@ -40,13 +40,13 @@ public class PacketBuilder {
|
||||
* Converts custom packet into platform-specific packet by calling a function from
|
||||
* {@link #buildMap}.
|
||||
*
|
||||
* @param packet
|
||||
* Packet to build
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflection fails
|
||||
* @param packet
|
||||
* Packet to build
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflection fails
|
||||
*/
|
||||
public Object build(TabPacket packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
Preconditions.checkNotNull(packet, "packet");
|
||||
@@ -57,13 +57,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutBoss class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutBoss packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -72,13 +72,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutChat class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutChat packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -87,13 +87,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutPlayerInfo class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutPlayerInfo packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -102,13 +102,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutPlayerListHeaderFooter class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutPlayerListHeaderFooter packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -117,13 +117,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutScoreboardDisplayObjective class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutScoreboardDisplayObjective packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -132,13 +132,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutScoreboardObjective class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutScoreboardObjective packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -147,13 +147,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutScoreboardScore class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutScoreboardScore packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -162,13 +162,13 @@ public class PacketBuilder {
|
||||
/**
|
||||
* Constructs platform-specific PacketPlayOutScoreboardTeam class based on custom packet class
|
||||
*
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* Custom packet to be built
|
||||
* @param clientVersion
|
||||
* Protocol version of player to build the packet for
|
||||
* @return Platform-specific packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutScoreboardTeam packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return packet;
|
||||
@@ -179,11 +179,12 @@ public class PacketBuilder {
|
||||
* and translates RGB to legacy colors. If string is not that long, the original string is returned.
|
||||
* RGB codes are converted into legacy, since cutting is only needed for <1.13.
|
||||
* If {@code string} is {@code null}, empty string is returned.
|
||||
* @param string
|
||||
* String to cut
|
||||
* @param length
|
||||
* Length to cut to
|
||||
* @return string cut to {@code length} characters
|
||||
*
|
||||
* @param string
|
||||
* String to cut
|
||||
* @param length
|
||||
* Length to cut to
|
||||
* @return string cut to {@code length} characters
|
||||
*/
|
||||
public String cutTo(String string, int length) {
|
||||
if (string == null) return "";
|
||||
@@ -207,11 +208,11 @@ public class PacketBuilder {
|
||||
* If {@code clientVersion} is < 1.12, the text is cut to {@code length} characters if
|
||||
* needed and returned.
|
||||
*
|
||||
* @param text
|
||||
* Text to convert
|
||||
* @param clientVersion
|
||||
* Version of player to convert text for
|
||||
* @return serialized component for 1.13+ clients, cut string for 1.12-
|
||||
* @param text
|
||||
* Text to convert
|
||||
* @param clientVersion
|
||||
* Version of player to convert text for
|
||||
* @return serialized component for 1.13+ clients, cut string for 1.12-
|
||||
*/
|
||||
public String jsonOrCut(String text, ProtocolVersion clientVersion, int length) {
|
||||
if (text == null) return null;
|
||||
@@ -226,13 +227,13 @@ public class PacketBuilder {
|
||||
* Converts platform-specific instance of player info packet into
|
||||
* {@link PacketPlayOutPlayerInfo} object.
|
||||
*
|
||||
* @param packet
|
||||
* platform-specific info packet
|
||||
* @param clientVersion
|
||||
* Version of client receiving the packet
|
||||
* @return The packet converted into {@link PacketPlayOutPlayerInfo}
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* platform-specific info packet
|
||||
* @param clientVersion
|
||||
* Version of client receiving the packet
|
||||
* @return The packet converted into {@link PacketPlayOutPlayerInfo}
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public PacketPlayOutPlayerInfo readPlayerInfo(Object packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
return null;
|
||||
@@ -242,11 +243,11 @@ public class PacketBuilder {
|
||||
* Converts platform-specific instance of objective packet into
|
||||
* {@link PacketPlayOutScoreboardObjective} object.
|
||||
*
|
||||
* @param packet
|
||||
* platform-specific objective packet
|
||||
* @return The packet converted into {@link PacketPlayOutScoreboardObjective}
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* platform-specific objective packet
|
||||
* @return The packet converted into {@link PacketPlayOutScoreboardObjective}
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public PacketPlayOutScoreboardObjective readObjective(Object packet) throws ReflectiveOperationException {
|
||||
return null;
|
||||
@@ -256,11 +257,11 @@ public class PacketBuilder {
|
||||
* Converts platform-specific instance of display objective packet into
|
||||
* {@link PacketPlayOutScoreboardDisplayObjective} object.
|
||||
*
|
||||
* @param packet
|
||||
* platform-specific display objective packet
|
||||
* @return The packet converted into {@link PacketPlayOutScoreboardDisplayObjective}
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @param packet
|
||||
* platform-specific display objective packet
|
||||
* @return The packet converted into {@link PacketPlayOutScoreboardDisplayObjective}
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public PacketPlayOutScoreboardDisplayObjective readDisplayObjective(Object packet) throws ReflectiveOperationException {
|
||||
return null;
|
||||
|
||||
@@ -42,16 +42,16 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
* Constructs new instance with given parameters and
|
||||
* {@link me.neznamy.tab.api.protocol.PacketPlayOutBoss.Action}.ADD action
|
||||
*
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param name
|
||||
* BossBar title
|
||||
* @param pct
|
||||
* BossBar progress
|
||||
* @param color
|
||||
* BossBar color
|
||||
* @param overlay
|
||||
* BossBar style
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param name
|
||||
* BossBar title
|
||||
* @param pct
|
||||
* BossBar progress
|
||||
* @param color
|
||||
* BossBar color
|
||||
* @param overlay
|
||||
* BossBar style
|
||||
*/
|
||||
public PacketPlayOutBoss(UUID id, String name, float pct, BarColor color, BarStyle overlay) {
|
||||
Preconditions.checkNotNull(id, "uuid");
|
||||
@@ -70,8 +70,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
* Constructs new instance with given parameters and
|
||||
* {@link me.neznamy.tab.api.protocol.PacketPlayOutBoss.Action}.REMOVE action
|
||||
*
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
*/
|
||||
public PacketPlayOutBoss(UUID id) {
|
||||
Preconditions.checkNotNull(id, "uuid");
|
||||
@@ -83,10 +83,10 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
* Constructs new instance with given parameters and
|
||||
* {@link me.neznamy.tab.api.protocol.PacketPlayOutBoss.Action}.UPDATE_PCT action
|
||||
*
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param pct
|
||||
* BossBar progress
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param pct
|
||||
* BossBar progress
|
||||
*/
|
||||
public PacketPlayOutBoss(UUID id, float pct) {
|
||||
Preconditions.checkNotNull(id, "uuid");
|
||||
@@ -99,10 +99,10 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
* Constructs new instance with given parameters and
|
||||
* {@link me.neznamy.tab.api.protocol.PacketPlayOutBoss.Action}.UPDATE_NAME action
|
||||
*
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param name
|
||||
* BossBar title
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param name
|
||||
* BossBar title
|
||||
*/
|
||||
public PacketPlayOutBoss(UUID id, String name) {
|
||||
Preconditions.checkNotNull(id, "uuid");
|
||||
@@ -116,12 +116,12 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
* Constructs new instance with given parameters and
|
||||
* {@link me.neznamy.tab.api.protocol.PacketPlayOutBoss.Action}.UPDATE_STYLE action
|
||||
*
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param color
|
||||
* BossBar color
|
||||
* @param overlay
|
||||
* BossBar style
|
||||
* @param id
|
||||
* BossBar uuid
|
||||
* @param color
|
||||
* BossBar color
|
||||
* @param overlay
|
||||
* BossBar style
|
||||
*/
|
||||
public PacketPlayOutBoss(UUID id, BarColor color, BarStyle overlay) {
|
||||
Preconditions.checkNotNull(id, "uuid");
|
||||
@@ -137,12 +137,12 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
* Constructs new instance with given parameters and
|
||||
* {@link me.neznamy.tab.api.protocol.PacketPlayOutBoss.Action}.UPDATE_PROPERTIES action
|
||||
*
|
||||
* @param darkenScreen
|
||||
* Darken screen flag
|
||||
* @param playMusic
|
||||
* Play music flag
|
||||
* @param createWorldFog
|
||||
* Create fog flag
|
||||
* @param darkenScreen
|
||||
* Darken screen flag
|
||||
* @param playMusic
|
||||
* Play music flag
|
||||
* @param createWorldFog
|
||||
* Create fog flag
|
||||
*/
|
||||
public PacketPlayOutBoss(UUID id, boolean darkenScreen, boolean playMusic, boolean createWorldFog) {
|
||||
Preconditions.checkNotNull(id, "uuid");
|
||||
@@ -159,7 +159,7 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
* {@link #darkenScreen} adds {@code 1}, {@link #playMusic} {@code 2} and {@link #darkenScreen} {@code 4}
|
||||
* to the final value.
|
||||
*
|
||||
* @return the bitmask
|
||||
* @return the bitmask
|
||||
*/
|
||||
public byte getFlags(){
|
||||
byte value = 0;
|
||||
@@ -177,7 +177,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #color}
|
||||
* @return color
|
||||
*
|
||||
* @return color
|
||||
*/
|
||||
public BarColor getColor() {
|
||||
return color;
|
||||
@@ -185,7 +186,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #overlay}
|
||||
* @return style
|
||||
*
|
||||
* @return style
|
||||
*/
|
||||
public BarStyle getOverlay() {
|
||||
return overlay;
|
||||
@@ -193,7 +195,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #name}
|
||||
* @return name
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -201,7 +204,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #id}
|
||||
* @return id
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
public UUID getId() {
|
||||
return id;
|
||||
@@ -209,7 +213,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #pct}
|
||||
* @return progress
|
||||
*
|
||||
* @return progress
|
||||
*/
|
||||
public float getPct() {
|
||||
return pct;
|
||||
@@ -217,7 +222,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #action}
|
||||
* @return packet action
|
||||
*
|
||||
* @return packet action
|
||||
*/
|
||||
public Action getAction() {
|
||||
return action;
|
||||
@@ -225,7 +231,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #darkenScreen}
|
||||
* @return darkenScreen
|
||||
*
|
||||
* @return darkenScreen
|
||||
*/
|
||||
public boolean isDarkenScreen() {
|
||||
return darkenScreen;
|
||||
@@ -233,7 +240,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #createWorldFog}
|
||||
* @return createWorldFog
|
||||
*
|
||||
* @return createWorldFog
|
||||
*/
|
||||
public boolean isCreateWorldFog() {
|
||||
return createWorldFog;
|
||||
@@ -241,7 +249,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #playMusic}
|
||||
* @return playMusic
|
||||
*
|
||||
* @return playMusic
|
||||
*/
|
||||
public boolean isPlayMusic() {
|
||||
return playMusic;
|
||||
@@ -250,8 +259,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
/**
|
||||
* Sets {@link #darkenScreen} to specified value
|
||||
*
|
||||
* @param darkenScreen
|
||||
* Darken screen flag
|
||||
* @param darkenScreen
|
||||
* Darken screen flag
|
||||
*/
|
||||
public void setDarkenScreen(boolean darkenScreen) {
|
||||
this.darkenScreen = darkenScreen;
|
||||
@@ -260,8 +269,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
/**
|
||||
* Sets {@link #createWorldFog} to specified value
|
||||
*
|
||||
* @param createWorldFog
|
||||
* Create fog flag
|
||||
* @param createWorldFog
|
||||
* Create fog flag
|
||||
*/
|
||||
public void setCreateWorldFog(boolean createWorldFog) {
|
||||
this.createWorldFog = createWorldFog;
|
||||
@@ -270,8 +279,8 @@ public class PacketPlayOutBoss implements TabPacket {
|
||||
/**
|
||||
* Sets {@link #playMusic} to specified value
|
||||
*
|
||||
* @param playMusic
|
||||
* Play music flag
|
||||
* @param playMusic
|
||||
* Play music flag
|
||||
*/
|
||||
public void setPlayMusic(boolean playMusic) {
|
||||
this.playMusic = playMusic;
|
||||
|
||||
@@ -17,10 +17,10 @@ public class PacketPlayOutChat implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
*
|
||||
* @param message
|
||||
* Chat message to be sent
|
||||
* @param type
|
||||
* Message position
|
||||
* @param message
|
||||
* Chat message to be sent
|
||||
* @param type
|
||||
* Message position
|
||||
*/
|
||||
public PacketPlayOutChat(IChatBaseComponent message, ChatMessageType type) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
@@ -36,7 +36,8 @@ public class PacketPlayOutChat implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #message}
|
||||
* @return message
|
||||
*
|
||||
* @return message
|
||||
*/
|
||||
public IChatBaseComponent getMessage() {
|
||||
return message;
|
||||
@@ -44,7 +45,8 @@ public class PacketPlayOutChat implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #type}
|
||||
* @return type
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public ChatMessageType getType() {
|
||||
return type;
|
||||
|
||||
@@ -21,10 +21,10 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters.
|
||||
*
|
||||
* @param action
|
||||
* Packet action
|
||||
* @param entries
|
||||
* Affected entries
|
||||
* @param action
|
||||
* Packet action
|
||||
* @param entries
|
||||
* Affected entries
|
||||
*/
|
||||
public PacketPlayOutPlayerInfo(EnumPlayerInfoAction action, PlayerInfoData... entries) {
|
||||
Preconditions.checkNotNull(action, "action");
|
||||
@@ -36,10 +36,10 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters.
|
||||
*
|
||||
* @param action
|
||||
* Packet action
|
||||
* @param entries
|
||||
* Affected entries
|
||||
* @param action
|
||||
* Packet action
|
||||
* @param entries
|
||||
* Affected entries
|
||||
*/
|
||||
public PacketPlayOutPlayerInfo(EnumPlayerInfoAction action, List<PlayerInfoData> entries) {
|
||||
Preconditions.checkNotNull(action, "action");
|
||||
@@ -55,7 +55,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #action}
|
||||
* @return packet action
|
||||
*
|
||||
* @return packet action
|
||||
*/
|
||||
public EnumPlayerInfoAction getAction() {
|
||||
return action;
|
||||
@@ -63,7 +64,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #entries}
|
||||
* @return affected entries
|
||||
*
|
||||
* @return affected entries
|
||||
*/
|
||||
public List<PlayerInfoData> getEntries() {
|
||||
return entries;
|
||||
@@ -99,18 +101,18 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
* Constructs new instance with given parameters. Suitable for
|
||||
* {@link EnumPlayerInfoAction}.ADD_PLAYER action
|
||||
*
|
||||
* @param name
|
||||
* Player's name
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param skin
|
||||
* Player's platform-specific skin object
|
||||
* @param latency
|
||||
* Player's ping
|
||||
* @param gameMode
|
||||
* Player's GameMode
|
||||
* @param displayName
|
||||
* Player's display name
|
||||
* @param name
|
||||
* Player's name
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param skin
|
||||
* Player's platform-specific skin object
|
||||
* @param latency
|
||||
* Player's ping
|
||||
* @param gameMode
|
||||
* Player's GameMode
|
||||
* @param displayName
|
||||
* Player's display name
|
||||
*/
|
||||
public PlayerInfoData(String name, UUID uniqueId, Skin skin, int latency, EnumGamemode gameMode, IChatBaseComponent displayName) {
|
||||
Preconditions.checkNotNull(uniqueId, "uuid");
|
||||
@@ -126,10 +128,10 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
* Constructs new instance with given parameters. Suitable for
|
||||
* {@link EnumPlayerInfoAction}.UPDATE_GAME_MODE action
|
||||
*
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param gameMode
|
||||
* Player's GameMode
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param gameMode
|
||||
* Player's GameMode
|
||||
*/
|
||||
public PlayerInfoData(UUID uniqueId, EnumGamemode gameMode) {
|
||||
Preconditions.checkNotNull(uniqueId, "uuid");
|
||||
@@ -141,10 +143,10 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
* Constructs new instance with given parameters. Suitable for
|
||||
* {@link EnumPlayerInfoAction}.UPDATE_LATENCY action
|
||||
*
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param latency
|
||||
* Player's ping
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param latency
|
||||
* Player's ping
|
||||
*/
|
||||
public PlayerInfoData(UUID uniqueId, int latency) {
|
||||
Preconditions.checkNotNull(uniqueId, "uuid");
|
||||
@@ -156,10 +158,10 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
* Constructs new instance with given parameters. Suitable for
|
||||
* {@link EnumPlayerInfoAction}.UPDATE_DISPLAY_NAME action
|
||||
*
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param displayName
|
||||
* Player's display name
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param displayName
|
||||
* Player's display name
|
||||
*/
|
||||
public PlayerInfoData(UUID uniqueId, IChatBaseComponent displayName) {
|
||||
Preconditions.checkNotNull(uniqueId, "uuid");
|
||||
@@ -171,8 +173,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
* Constructs new instance with given parameter. Suitable for
|
||||
* {@link EnumPlayerInfoAction}.REMOVE_PLAYER action
|
||||
*
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
* @param uniqueId
|
||||
* Player's uuid
|
||||
*/
|
||||
public PlayerInfoData(UUID uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
@@ -186,7 +188,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #latency}
|
||||
* @return latency
|
||||
*
|
||||
* @return latency
|
||||
*/
|
||||
public int getLatency() {
|
||||
return latency;
|
||||
@@ -194,8 +197,9 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Sets {@link #latency} to specified value
|
||||
* @param latency
|
||||
* Latency to use
|
||||
*
|
||||
* @param latency
|
||||
* Latency to use
|
||||
*/
|
||||
public void setLatency(int latency) {
|
||||
this.latency = latency;
|
||||
@@ -203,7 +207,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #displayName}
|
||||
* @return displayName
|
||||
*
|
||||
* @return displayName
|
||||
*/
|
||||
public IChatBaseComponent getDisplayName() {
|
||||
return displayName;
|
||||
@@ -211,8 +216,9 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Sets {@link #displayName} to specified value
|
||||
* @param displayName
|
||||
* Display name to use
|
||||
*
|
||||
* @param displayName
|
||||
* Display name to use
|
||||
*/
|
||||
public void setDisplayName(IChatBaseComponent displayName) {
|
||||
this.displayName = displayName;
|
||||
@@ -220,7 +226,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #uniqueId}
|
||||
* @return uniqueId
|
||||
*
|
||||
* @return uniqueId
|
||||
*/
|
||||
public UUID getUniqueId() {
|
||||
return uniqueId;
|
||||
@@ -228,8 +235,9 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Sets {@link #uniqueId} to specified value
|
||||
* @param uniqueId
|
||||
* UUID to use
|
||||
*
|
||||
* @param uniqueId
|
||||
* UUID to use
|
||||
*/
|
||||
public void setUniqueId(UUID uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
@@ -237,7 +245,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #name}
|
||||
* @return name
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -245,8 +254,9 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Sets {@link #name} to specified value
|
||||
* @param name
|
||||
* name to use
|
||||
*
|
||||
* @param name
|
||||
* name to use
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
@@ -254,7 +264,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #gameMode}
|
||||
* @return gameMode
|
||||
*
|
||||
* @return gameMode
|
||||
*/
|
||||
public EnumGamemode getGameMode() {
|
||||
return gameMode;
|
||||
@@ -262,8 +273,9 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Sets {@link #gameMode} to specified value
|
||||
* @param gameMode
|
||||
* GameMode to use
|
||||
*
|
||||
* @param gameMode
|
||||
* GameMode to use
|
||||
*/
|
||||
public void setGameMode(EnumGamemode gameMode) {
|
||||
this.gameMode = gameMode;
|
||||
@@ -271,7 +283,8 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #skin}
|
||||
* @return skin
|
||||
*
|
||||
* @return skin
|
||||
*/
|
||||
public Skin getSkin() {
|
||||
return skin;
|
||||
@@ -279,8 +292,9 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
|
||||
|
||||
/**
|
||||
* Sets {@link #skin} to specified value
|
||||
* @param skin
|
||||
* Skin to use
|
||||
*
|
||||
* @param skin
|
||||
* Skin to use
|
||||
*/
|
||||
public void setSkin(Skin skin) {
|
||||
this.skin = skin;
|
||||
|
||||
+12
-10
@@ -18,10 +18,10 @@ public class PacketPlayOutPlayerListHeaderFooter implements TabPacket {
|
||||
* Constructs new instance with given parameters. They are converted to {@link IChatBaseComponent}
|
||||
* using {@link IChatBaseComponent#optimizedComponent(String)} method.
|
||||
*
|
||||
* @param header
|
||||
* TabList header
|
||||
* @param footer
|
||||
* TabList footer
|
||||
* @param header
|
||||
* TabList header
|
||||
* @param footer
|
||||
* TabList footer
|
||||
*/
|
||||
public PacketPlayOutPlayerListHeaderFooter(String header, String footer) {
|
||||
Preconditions.checkNotNull(header, "header");
|
||||
@@ -33,10 +33,10 @@ public class PacketPlayOutPlayerListHeaderFooter implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters.
|
||||
*
|
||||
* @param header
|
||||
* TabList header
|
||||
* @param footer
|
||||
* TabList footer
|
||||
* @param header
|
||||
* TabList header
|
||||
* @param footer
|
||||
* TabList footer
|
||||
*/
|
||||
public PacketPlayOutPlayerListHeaderFooter(IChatBaseComponent header, IChatBaseComponent footer) {
|
||||
Preconditions.checkNotNull(header, "header");
|
||||
@@ -52,7 +52,8 @@ public class PacketPlayOutPlayerListHeaderFooter implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #header}
|
||||
* @return header
|
||||
*
|
||||
* @return header
|
||||
*/
|
||||
public IChatBaseComponent getHeader() {
|
||||
return header;
|
||||
@@ -60,7 +61,8 @@ public class PacketPlayOutPlayerListHeaderFooter implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #footer}
|
||||
* @return footer
|
||||
*
|
||||
* @return footer
|
||||
*/
|
||||
public IChatBaseComponent getFooter() {
|
||||
return footer;
|
||||
|
||||
+11
-8
@@ -20,12 +20,13 @@ public class PacketPlayOutScoreboardDisplayObjective implements TabPacket {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
* @param slot
|
||||
* Display slot
|
||||
* @param objectiveName
|
||||
* Internal name of the objective
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
*
|
||||
* @param slot
|
||||
* Display slot
|
||||
* @param objectiveName
|
||||
* Internal name of the objective
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardDisplayObjective(int slot, String objectiveName) {
|
||||
Preconditions.checkNotNull(objectiveName, "objective name");
|
||||
@@ -41,7 +42,8 @@ public class PacketPlayOutScoreboardDisplayObjective implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #slot}
|
||||
* @return slot
|
||||
*
|
||||
* @return slot
|
||||
*/
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
@@ -49,7 +51,8 @@ public class PacketPlayOutScoreboardDisplayObjective implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #objectiveName}
|
||||
* @return objectiveName
|
||||
*
|
||||
* @return objectiveName
|
||||
*/
|
||||
public String getObjectiveName() {
|
||||
return objectiveName;
|
||||
|
||||
+22
-16
@@ -27,14 +27,16 @@ public class PacketPlayOutScoreboardObjective implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters.
|
||||
*
|
||||
* @param action
|
||||
* Packet action (0 = add, 1 = remove, 2 = update title)
|
||||
* @param objectiveName
|
||||
* objective name, up to 16 characters long
|
||||
* @param displayName - title
|
||||
* @param renderType - display type
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
* @param action
|
||||
* Packet action (0 = add, 1 = remove, 2 = update title)
|
||||
* @param objectiveName
|
||||
* objective name, up to 16 characters long
|
||||
* @param displayName
|
||||
* title
|
||||
* @param renderType
|
||||
* display type
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardObjective(int action, String objectiveName, String displayName, EnumScoreboardHealthDisplay renderType) {
|
||||
Preconditions.checkRange(action, 0, 2, "action");
|
||||
@@ -50,10 +52,10 @@ public class PacketPlayOutScoreboardObjective implements TabPacket {
|
||||
/**
|
||||
* Constructs new packet with given objective name and 1 (unregister) action.
|
||||
*
|
||||
* @param objectiveName
|
||||
* objective name, up to 16 characters long
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
* @param objectiveName
|
||||
* objective name, up to 16 characters long
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardObjective(String objectiveName) {
|
||||
Preconditions.checkNotNull(objectiveName, "objective name");
|
||||
@@ -72,7 +74,8 @@ public class PacketPlayOutScoreboardObjective implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #displayName}
|
||||
* @return displayName
|
||||
*
|
||||
* @return displayName
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
@@ -80,7 +83,8 @@ public class PacketPlayOutScoreboardObjective implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #objectiveName}
|
||||
* @return objectiveName
|
||||
*
|
||||
* @return objectiveName
|
||||
*/
|
||||
public String getObjectiveName() {
|
||||
return objectiveName;
|
||||
@@ -88,7 +92,8 @@ public class PacketPlayOutScoreboardObjective implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #renderType}
|
||||
* @return renderType
|
||||
*
|
||||
* @return renderType
|
||||
*/
|
||||
public EnumScoreboardHealthDisplay getRenderType() {
|
||||
return renderType;
|
||||
@@ -96,7 +101,8 @@ public class PacketPlayOutScoreboardObjective implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #action}
|
||||
* @return packet action
|
||||
*
|
||||
* @return packet action
|
||||
*/
|
||||
public int getAction() {
|
||||
return action;
|
||||
|
||||
@@ -22,16 +22,16 @@ public class PacketPlayOutScoreboardScore implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
*
|
||||
* @param action
|
||||
* Packet action
|
||||
* @param objectiveName
|
||||
* Objective name
|
||||
* @param player
|
||||
* Affected player
|
||||
* @param score
|
||||
* Player's score
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
* @param action
|
||||
* Packet action
|
||||
* @param objectiveName
|
||||
* Objective name
|
||||
* @param player
|
||||
* Affected player
|
||||
* @param score
|
||||
* Player's score
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code objectiveName} is null or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardScore(Action action, String objectiveName, String player, int score) {
|
||||
Preconditions.checkNotNull(action, "action");
|
||||
@@ -52,7 +52,8 @@ public class PacketPlayOutScoreboardScore implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #action}
|
||||
* @return packet action
|
||||
*
|
||||
* @return packet action
|
||||
*/
|
||||
public Action getAction() {
|
||||
return action;
|
||||
@@ -60,7 +61,8 @@ public class PacketPlayOutScoreboardScore implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #objectiveName}
|
||||
* @return objective name
|
||||
*
|
||||
* @return objective name
|
||||
*/
|
||||
public String getObjectiveName() {
|
||||
return objectiveName;
|
||||
@@ -68,7 +70,8 @@ public class PacketPlayOutScoreboardScore implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #player}
|
||||
* @return player
|
||||
*
|
||||
* @return player
|
||||
*/
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
@@ -76,7 +79,8 @@ public class PacketPlayOutScoreboardScore implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #score}
|
||||
* @return score
|
||||
*
|
||||
* @return score
|
||||
*/
|
||||
public int getScore() {
|
||||
return score;
|
||||
|
||||
@@ -72,13 +72,13 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
* Constructs new instance with given parameters. Private constructor used
|
||||
* internally to validate team name and set action.
|
||||
*
|
||||
* @param action
|
||||
* Packet action (0 = create team, 1 = remove team, 2 = update team info,
|
||||
* 3 = add entries, 4 = remove entries)
|
||||
* @param name
|
||||
* Team name, up to 16 characters long
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
* @param action
|
||||
* Packet action (0 = create team, 1 = remove team, 2 = update team info,
|
||||
* 3 = add entries, 4 = remove entries)
|
||||
* @param name
|
||||
* Team name, up to 16 characters long
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
*/
|
||||
private PacketPlayOutScoreboardTeam(int action, String name) {
|
||||
Preconditions.checkNotNull(name, "team name");
|
||||
@@ -90,22 +90,22 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters and 0 (CREATE) action
|
||||
*
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @param prefix
|
||||
* Prefix of players in team
|
||||
* @param suffix
|
||||
* Suffix of players in team
|
||||
* @param visibility
|
||||
* NameTag visibility rule
|
||||
* @param collision
|
||||
* Collision rule
|
||||
* @param players
|
||||
* Affected entities
|
||||
* @param options
|
||||
* bitmask of team options
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @param prefix
|
||||
* Prefix of players in team
|
||||
* @param suffix
|
||||
* Suffix of players in team
|
||||
* @param visibility
|
||||
* NameTag visibility rule
|
||||
* @param collision
|
||||
* Collision rule
|
||||
* @param players
|
||||
* Affected entities
|
||||
* @param options
|
||||
* bitmask of team options
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardTeam(String team, String prefix, String suffix, String visibility, String collision, Collection<String> players, int options) {
|
||||
this(0, team);
|
||||
@@ -125,10 +125,10 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters and 1 (REMOVE) action
|
||||
*
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardTeam(String team) {
|
||||
this(1, team);
|
||||
@@ -137,20 +137,20 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
/**
|
||||
* Constructs new instance with given parameters and 2 (UPDATE_TEAM_INFO) action
|
||||
*
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @param prefix
|
||||
* Prefix of players in team
|
||||
* @param suffix
|
||||
* Suffix of players in team
|
||||
* @param visibility
|
||||
* NameTag visibility rule
|
||||
* @param collision
|
||||
* Collision rule
|
||||
* @param options
|
||||
* bitmask of team options
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @param prefix
|
||||
* Prefix of players in team
|
||||
* @param suffix
|
||||
* Suffix of players in team
|
||||
* @param visibility
|
||||
* NameTag visibility rule
|
||||
* @param collision
|
||||
* Collision rule
|
||||
* @param options
|
||||
* bitmask of team options
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardTeam(String team, String prefix, String suffix, String visibility, String collision, int options) {
|
||||
this(2, team);
|
||||
@@ -170,14 +170,14 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
* Constructs new instance with given parameters and 3 (ADD_PLAYERS) if {@code add} is {@code true},
|
||||
* 4 (REMOVE_PLAYERS) if {@code add} is {@code false} action.
|
||||
*
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @param players
|
||||
* Affected entities
|
||||
* @param add
|
||||
* {@code true} if players should be added, {@code false} if removed from team
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
* @param team
|
||||
* Team name, up to 16 characters long
|
||||
* @param players
|
||||
* Affected entities
|
||||
* @param add
|
||||
* {@code true} if players should be added, {@code false} if removed from team
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is null, empty or longer than 16 characters
|
||||
*/
|
||||
public PacketPlayOutScoreboardTeam(String team, Collection<String> players, boolean add) {
|
||||
this(add ? 3 : 4, team);
|
||||
@@ -194,7 +194,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #name}
|
||||
* @return team name
|
||||
*
|
||||
* @return team name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -202,7 +203,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #playerPrefix}
|
||||
* @return playerPrefix
|
||||
*
|
||||
* @return playerPrefix
|
||||
*/
|
||||
public String getPlayerPrefix() {
|
||||
return playerPrefix;
|
||||
@@ -210,7 +212,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #playerSuffix}
|
||||
* @return playerSuffix
|
||||
*
|
||||
* @return playerSuffix
|
||||
*/
|
||||
public String getPlayerSuffix() {
|
||||
return playerSuffix;
|
||||
@@ -218,7 +221,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #nameTagVisibility}
|
||||
* @return nameTagVisibility
|
||||
*
|
||||
* @return nameTagVisibility
|
||||
*/
|
||||
public String getNameTagVisibility() {
|
||||
return nameTagVisibility;
|
||||
@@ -226,7 +230,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #collisionRule}
|
||||
* @return collisionRule
|
||||
*
|
||||
* @return collisionRule
|
||||
*/
|
||||
public String getCollisionRule() {
|
||||
return collisionRule;
|
||||
@@ -235,8 +240,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
/**
|
||||
* Sets {@link #color} to specified color
|
||||
*
|
||||
* @param color
|
||||
* color to use
|
||||
* @param color
|
||||
* color to use
|
||||
*/
|
||||
public void setColor(EnumChatFormat color) {
|
||||
this.color = color;
|
||||
@@ -244,7 +249,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #color}
|
||||
* @return color
|
||||
*
|
||||
* @return color
|
||||
*/
|
||||
public EnumChatFormat getColor() {
|
||||
return color;
|
||||
@@ -252,7 +258,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #players}
|
||||
* @return players
|
||||
*
|
||||
* @return players
|
||||
*/
|
||||
public Collection<String> getPlayers() {
|
||||
return players;
|
||||
@@ -260,7 +267,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #options}
|
||||
* @return team options
|
||||
*
|
||||
* @return team options
|
||||
*/
|
||||
public int getOptions() {
|
||||
return options;
|
||||
@@ -268,7 +276,8 @@ public class PacketPlayOutScoreboardTeam implements TabPacket {
|
||||
|
||||
/**
|
||||
* Returns {@link #action}
|
||||
* @return packet action
|
||||
*
|
||||
* @return packet action
|
||||
*/
|
||||
public int getAction() {
|
||||
return action;
|
||||
|
||||
@@ -10,25 +10,28 @@ public class Skin {
|
||||
/** Skin value */
|
||||
private final String value;
|
||||
|
||||
/** Skin signature */
|
||||
/** Skin signature, can be null */
|
||||
private final String signature;
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
*
|
||||
* @param value
|
||||
* skin value
|
||||
* @param signature
|
||||
* skin signature
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code value} is {@code null}
|
||||
*/
|
||||
public Skin(String value, String signature) {
|
||||
Preconditions.checkNotNull(value, "value");
|
||||
Preconditions.checkNotNull(signature, "signature");
|
||||
this.value = value;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns skin value
|
||||
*
|
||||
* @return skin value
|
||||
*/
|
||||
public String getValue() {
|
||||
@@ -37,6 +40,7 @@ public class Skin {
|
||||
|
||||
/**
|
||||
* Returns skin signature
|
||||
*
|
||||
* @return skin signature
|
||||
*/
|
||||
public String getSignature() {
|
||||
@@ -45,6 +49,7 @@ public class Skin {
|
||||
|
||||
/**
|
||||
* Returns user-friendly representation of this object
|
||||
*
|
||||
* @return user-friendly representation of this object
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,8 @@ public interface TabPacket {
|
||||
|
||||
/**
|
||||
* Returns user-friendly string representation of the packet
|
||||
* @return user-friendly string representation of the packet
|
||||
*
|
||||
* @return user-friendly string representation of the packet
|
||||
*/
|
||||
String toString();
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public interface Line {
|
||||
* Returns configured raw text of this line. Placeholders
|
||||
* remain in raw format.
|
||||
*
|
||||
* @return raw text of this line
|
||||
* @return raw text of this line
|
||||
*/
|
||||
String getText();
|
||||
|
||||
@@ -22,8 +22,8 @@ public interface Line {
|
||||
* keep placeholders up to date. If value is identical to previous
|
||||
* one, nothing happens.
|
||||
*
|
||||
* @param text
|
||||
* Raw text to display in the line
|
||||
* @param text
|
||||
* Raw text to display in the line
|
||||
*/
|
||||
void setText(String text);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public interface Scoreboard {
|
||||
* scoreboards from config use name they were defined with. This value is
|
||||
* used internally and in /tab announce scoreboard command.
|
||||
*
|
||||
* @return custom name of this scoreboard
|
||||
* @return custom name of this scoreboard
|
||||
*/
|
||||
String getName();
|
||||
|
||||
@@ -23,8 +23,8 @@ public interface Scoreboard {
|
||||
* Returns raw title of this scoreboard. Placeholders stay in their
|
||||
* raw format.
|
||||
*
|
||||
* @return scoreboard title
|
||||
* @see #setTitle(String)
|
||||
* @return scoreboard title
|
||||
* @see #setTitle(String)
|
||||
*/
|
||||
String getTitle();
|
||||
|
||||
@@ -39,9 +39,9 @@ public interface Scoreboard {
|
||||
* <p>
|
||||
* Calling this method with same title as before will not do anything.
|
||||
*
|
||||
* @param title
|
||||
* New title to use with placeholder support
|
||||
* @see #getTitle()
|
||||
* @param title
|
||||
* New title to use with placeholder support
|
||||
* @see #getTitle()
|
||||
*/
|
||||
void setTitle(String title);
|
||||
|
||||
@@ -50,9 +50,9 @@ public interface Scoreboard {
|
||||
* in game (first line is on top). This list should only be used for reading,
|
||||
* for adding/removing lines see {@link #addLine(String)} and {@link #removeLine(int)}.
|
||||
*
|
||||
* @return list of lines in this scoreboard
|
||||
* @see #addLine(String)
|
||||
* @see #removeLine(int)
|
||||
* @return list of lines in this scoreboard
|
||||
* @see #addLine(String)
|
||||
* @see #removeLine(int)
|
||||
*/
|
||||
List<Line> getLines();
|
||||
|
||||
@@ -60,10 +60,10 @@ public interface Scoreboard {
|
||||
* Adds line with specified text on the bottom of scoreboard. Supports
|
||||
* placeholders, which will automatically be refreshed.
|
||||
*
|
||||
* @param text
|
||||
* Text to display
|
||||
* @see #getLines()
|
||||
* @see #removeLine(int)
|
||||
* @param text
|
||||
* Text to display
|
||||
* @see #getLines()
|
||||
* @see #removeLine(int)
|
||||
*/
|
||||
void addLine(String text);
|
||||
|
||||
@@ -71,12 +71,12 @@ public interface Scoreboard {
|
||||
* Removes line with specified index. Index starts at {@code 0} and ends at
|
||||
* {@link #getLines()}.size()-1.
|
||||
*
|
||||
* @param index
|
||||
* Index of line to remove, starting at 0
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if the index is out of range (index < 0 || index >= {@link #getLines()}.size())
|
||||
* @see #getLines()
|
||||
* @see #addLine(String)
|
||||
* @param index
|
||||
* Index of line to remove, starting at 0
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if the index is out of range (index < 0 || index >= {@link #getLines()}.size())
|
||||
* @see #getLines()
|
||||
* @see #addLine(String)
|
||||
*/
|
||||
void removeLine(int index);
|
||||
|
||||
|
||||
@@ -29,15 +29,15 @@ public interface ScoreboardManager {
|
||||
* Client can only see up to 15 lines at a time, however you can define
|
||||
* more, if some of them only consist of placeholder that might be empty.
|
||||
*
|
||||
* @param name
|
||||
* Internal name of the scoreboard
|
||||
* @param title
|
||||
* The scoreboard title
|
||||
* @param lines
|
||||
* Lines of text in scoreboard (supports placeholders)
|
||||
* @return The new scoreboard with given parameters
|
||||
* @throws NullPointerException
|
||||
* if {@code name} or {@code lines} is {@code null}
|
||||
* @param name
|
||||
* Internal name of the scoreboard
|
||||
* @param title
|
||||
* The scoreboard title
|
||||
* @param lines
|
||||
* Lines of text in scoreboard (supports placeholders)
|
||||
* @return The new scoreboard with given parameters
|
||||
* @throws NullPointerException
|
||||
* if {@code name} or {@code lines} is {@code null}
|
||||
*/
|
||||
Scoreboard createScoreboard(String name, String title, List<String> lines);
|
||||
|
||||
@@ -47,7 +47,7 @@ public interface ScoreboardManager {
|
||||
* or using {@link #createScoreboard(String, String, List)}.
|
||||
* Map value is reference to the actual scoreboard.
|
||||
*
|
||||
* @return map of registered scoreboards
|
||||
* @return map of registered scoreboards
|
||||
*/
|
||||
Map<String, Scoreboard> getRegisteredScoreboards();
|
||||
|
||||
@@ -57,14 +57,14 @@ public interface ScoreboardManager {
|
||||
* {@link #resetScoreboard(TabPlayer)}. If the player already sees
|
||||
* this scoreboard, nothing will happen.
|
||||
*
|
||||
* @param player
|
||||
* Player to send scoreboard to
|
||||
* @param scoreboard
|
||||
* Scoreboard to display
|
||||
* @throws NullPointerException
|
||||
* if {@code player} or {@code scoreboard} is {@code null}
|
||||
* @see #hasCustomScoreboard(TabPlayer)
|
||||
* @see #resetScoreboard(TabPlayer)
|
||||
* @param player
|
||||
* Player to send scoreboard to
|
||||
* @param scoreboard
|
||||
* Scoreboard to display
|
||||
* @throws NullPointerException
|
||||
* if {@code player} or {@code scoreboard} is {@code null}
|
||||
* @see #hasCustomScoreboard(TabPlayer)
|
||||
* @see #resetScoreboard(TabPlayer)
|
||||
*/
|
||||
void showScoreboard(TabPlayer player, Scoreboard scoreboard);
|
||||
|
||||
@@ -72,12 +72,12 @@ public interface ScoreboardManager {
|
||||
* Returns {@code true} if player has custom scoreboard set using
|
||||
* {@link #showScoreboard(TabPlayer, Scoreboard)}, {@code false} if not.
|
||||
*
|
||||
* @param player
|
||||
* Player to check
|
||||
* @return {@code true} if player has custom scoreboard set using API,
|
||||
* {@code false} if not
|
||||
* @see #showScoreboard(TabPlayer, Scoreboard)
|
||||
* @see #resetScoreboard(TabPlayer)
|
||||
* @param player
|
||||
* Player to check
|
||||
* @return {@code true} if player has custom scoreboard set using API,
|
||||
* {@code false} if not
|
||||
* @see #showScoreboard(TabPlayer, Scoreboard)
|
||||
* @see #resetScoreboard(TabPlayer)
|
||||
*/
|
||||
boolean hasCustomScoreboard(TabPlayer player);
|
||||
|
||||
@@ -86,10 +86,10 @@ public interface ScoreboardManager {
|
||||
* and re-enables internal display logic with conditions. If player does not
|
||||
* have any forced scoreboard, nothing happens.
|
||||
*
|
||||
* @param player
|
||||
* Player to hide custom scoreboard from
|
||||
* @see #showScoreboard(TabPlayer, Scoreboard)
|
||||
* @see #hasCustomScoreboard(TabPlayer)
|
||||
* @param player
|
||||
* Player to hide custom scoreboard from
|
||||
* @see #showScoreboard(TabPlayer, Scoreboard)
|
||||
* @see #hasCustomScoreboard(TabPlayer)
|
||||
*/
|
||||
void resetScoreboard(TabPlayer player);
|
||||
|
||||
@@ -99,11 +99,11 @@ public interface ScoreboardManager {
|
||||
* {@link #toggleScoreboard(TabPlayer, boolean)} or
|
||||
* {@link #setScoreboardVisible(TabPlayer, boolean, boolean)}.
|
||||
*
|
||||
* @param player
|
||||
* Player to get visibility status of
|
||||
* @return {@code true} if visible, {@code false} if disabled
|
||||
* @see #setScoreboardVisible(TabPlayer, boolean, boolean)
|
||||
* @see #toggleScoreboard(TabPlayer, boolean)
|
||||
* @param player
|
||||
* Player to get visibility status of
|
||||
* @return {@code true} if visible, {@code false} if disabled
|
||||
* @see #setScoreboardVisible(TabPlayer, boolean, boolean)
|
||||
* @see #toggleScoreboard(TabPlayer, boolean)
|
||||
*/
|
||||
boolean hasScoreboardVisible(TabPlayer player);
|
||||
|
||||
@@ -113,14 +113,14 @@ public interface ScoreboardManager {
|
||||
* visibility, scoreboard is toggled. If {@code sendToggleMessage} is {@code true},
|
||||
* toggle message defined in configuration is sent.
|
||||
*
|
||||
* @param player
|
||||
* Player to set visibility for
|
||||
* @param visible
|
||||
* New visibility status
|
||||
* @param sendToggleMessage
|
||||
* whether to send toggle message if status changed or not
|
||||
* @see #toggleScoreboard(TabPlayer, boolean)
|
||||
* @see #hasScoreboardVisible(TabPlayer)
|
||||
* @param player
|
||||
* Player to set visibility for
|
||||
* @param visible
|
||||
* New visibility status
|
||||
* @param sendToggleMessage
|
||||
* whether to send toggle message if status changed or not
|
||||
* @see #toggleScoreboard(TabPlayer, boolean)
|
||||
* @see #hasScoreboardVisible(TabPlayer)
|
||||
*/
|
||||
void setScoreboardVisible(TabPlayer player, boolean visible, boolean sendToggleMessage);
|
||||
|
||||
@@ -129,12 +129,12 @@ public interface ScoreboardManager {
|
||||
* hides it. If hidden, shows it. If {@code sendToggleMessage} is {@code true},
|
||||
* toggle message defined in configuration is sent.
|
||||
*
|
||||
* @param player
|
||||
* Player to toggle scoreboard for
|
||||
* @param sendToggleMessage
|
||||
* Whether to send toggle message or not
|
||||
* @see #hasScoreboardVisible(TabPlayer)
|
||||
* @see #setScoreboardVisible(TabPlayer, boolean, boolean)
|
||||
* @param player
|
||||
* Player to toggle scoreboard for
|
||||
* @param sendToggleMessage
|
||||
* Whether to send toggle message or not
|
||||
* @see #hasScoreboardVisible(TabPlayer)
|
||||
* @see #setScoreboardVisible(TabPlayer, boolean, boolean)
|
||||
*/
|
||||
void toggleScoreboard(TabPlayer player, boolean sendToggleMessage);
|
||||
|
||||
@@ -143,13 +143,13 @@ public interface ScoreboardManager {
|
||||
* time (in milliseconds). Scoreboard name is either defined in config, or
|
||||
* through API in {@link #createScoreboard(String, String, List)}.
|
||||
*
|
||||
* @param scoreboard
|
||||
* Scoreboard from config or registered via API
|
||||
* @param duration
|
||||
* Duration in milliseconds
|
||||
* @throws IllegalArgumentException
|
||||
* if no scoreboard was found with such name or {@code duration}
|
||||
* is < 0.
|
||||
* @param scoreboard
|
||||
* Scoreboard from config or registered via API
|
||||
* @param duration
|
||||
* Duration in milliseconds
|
||||
* @throws IllegalArgumentException
|
||||
* if no scoreboard was found with such name or {@code duration}
|
||||
* is < 0.
|
||||
*/
|
||||
void announceScoreboard(String scoreboard, int duration);
|
||||
|
||||
@@ -157,9 +157,10 @@ public interface ScoreboardManager {
|
||||
* Returns player's currently displayed scoreboard. This can be either with
|
||||
* configuration, overridden with commands or the API. Will return {@code null}
|
||||
* if player does not see any scoreboard due to not meeting any display condition.
|
||||
* @param player
|
||||
* player to get active scoreboard of
|
||||
* @return player's active scoreboard or {@code null} if player has no scoreboard
|
||||
*
|
||||
* @param player
|
||||
* player to get active scoreboard of
|
||||
* @return player's active scoreboard or {@code null} if player has no scoreboard
|
||||
*/
|
||||
Scoreboard getActiveScoreboard(TabPlayer player);
|
||||
}
|
||||
@@ -8,32 +8,47 @@ public interface ThreadManager {
|
||||
|
||||
/**
|
||||
* Starts a task in new thread and measures how long it took to process
|
||||
* @param feature - feature to add cpu usage to
|
||||
* @param type - usage type to add cpu usage to
|
||||
* @param task - the task
|
||||
*
|
||||
* @param feature
|
||||
* feature to add cpu usage to
|
||||
* @param type
|
||||
* usage type to add cpu usage to
|
||||
* @param task
|
||||
* the task
|
||||
*/
|
||||
Future<Void> runMeasuredTask(TabFeature feature, String type, Runnable task);
|
||||
|
||||
/**
|
||||
* Starts a task in new thread and measures how long it took to process
|
||||
* @param feature - feature to add cpu usage to
|
||||
* @param type - usage type to add cpu usage to
|
||||
* @param task - the task
|
||||
*
|
||||
* @param feature
|
||||
* feature to add cpu usage to
|
||||
* @param type
|
||||
* usage type to add cpu usage to
|
||||
* @param task
|
||||
* the task
|
||||
*/
|
||||
Future<Void> runMeasuredTask(String feature, String type, Runnable task);
|
||||
|
||||
/**
|
||||
* Runs task in a new thread
|
||||
* @param task - the task
|
||||
*
|
||||
* @param task
|
||||
* the task
|
||||
*/
|
||||
Future<Void> runTask(Runnable task);
|
||||
|
||||
/**
|
||||
* Starts a new task with defined repeat interval that measures cpu usage
|
||||
* @param intervalMilliseconds - task interval
|
||||
* @param feature - feature to add cpu usage to
|
||||
* @param type - usage type to add cpu usage to
|
||||
* @param task - the task
|
||||
*
|
||||
* @param intervalMilliseconds
|
||||
* task interval
|
||||
* @param feature
|
||||
* feature to add cpu usage to
|
||||
* @param type
|
||||
* usage type to add cpu usage to
|
||||
* @param task
|
||||
* the task
|
||||
*/
|
||||
RepeatingTask startRepeatingMeasuredTask(int intervalMilliseconds, TabFeature feature, String type, Runnable task);
|
||||
|
||||
@@ -41,11 +56,16 @@ public interface ThreadManager {
|
||||
|
||||
/**
|
||||
* Runs task with a delay and measures how long it took to process
|
||||
* @param delayMilliseconds - how long to run the task after
|
||||
* @param feature - feature to add cpu usage to
|
||||
* @param type - usage type to add cpu usage to
|
||||
* @param task - the task
|
||||
* @return future allowing to cancel the task
|
||||
*
|
||||
* @param delayMilliseconds
|
||||
* how long to run the task after
|
||||
* @param feature
|
||||
* feature to add cpu usage to
|
||||
* @param type
|
||||
* usage type to add cpu usage to
|
||||
* @param task
|
||||
* the task
|
||||
* @return future allowing to cancel the task
|
||||
*/
|
||||
Future<?> runTaskLater(int delayMilliseconds, TabFeature feature, String type, Runnable task);
|
||||
|
||||
|
||||
@@ -6,92 +6,138 @@ public interface TeamManager {
|
||||
|
||||
/**
|
||||
* Makes player's NameTag globally invisible
|
||||
* @see #showNametag(TabPlayer)
|
||||
* @see #hasHiddenNametag(TabPlayer)
|
||||
*
|
||||
* @param player
|
||||
* player to hide nametag of
|
||||
* @see #showNametag(TabPlayer)
|
||||
* @see #hasHiddenNametag(TabPlayer)
|
||||
*/
|
||||
void hideNametag(TabPlayer player);
|
||||
|
||||
/**
|
||||
* Hides player's NameTag for specified player until it's shown again
|
||||
* @param viewer - player to hide NameTag for
|
||||
*
|
||||
* @param player
|
||||
* player to hide nametag of
|
||||
* @param viewer
|
||||
* player to hide NameTag for
|
||||
*/
|
||||
void hideNametag(TabPlayer player, TabPlayer viewer);
|
||||
|
||||
/**
|
||||
* Makes player's NameTag visible again
|
||||
* @see #hideNametag(TabPlayer)
|
||||
* @see #hasHiddenNametag(TabPlayer)
|
||||
*
|
||||
* @param player
|
||||
* player to show nametag of
|
||||
* @see #hideNametag(TabPlayer)
|
||||
* @see #hasHiddenNametag(TabPlayer)
|
||||
*/
|
||||
void showNametag(TabPlayer player);
|
||||
|
||||
/**
|
||||
* Shows player's NameTag for specified viewer if it was hidden before
|
||||
* @param viewer - player to show NameTag back for
|
||||
*
|
||||
* @param player
|
||||
* player to show nametag of
|
||||
* @param viewer
|
||||
* player to show NameTag back for
|
||||
*/
|
||||
void showNametag(TabPlayer player, TabPlayer viewer);
|
||||
|
||||
/**
|
||||
* Return whether player has hidden NameTag or not
|
||||
* @return Whether player has hidden NameTag or not
|
||||
* @see #hideNametag(TabPlayer)
|
||||
* @see #showNametag(TabPlayer)
|
||||
*
|
||||
* @param player
|
||||
* player to check nametag visibility status of
|
||||
* @return Whether player has hidden NameTag or not
|
||||
* @see #hideNametag(TabPlayer)
|
||||
* @see #showNametag(TabPlayer)
|
||||
*/
|
||||
boolean hasHiddenNametag(TabPlayer player);
|
||||
|
||||
/**
|
||||
* Returns true if NameTag is hidden for specified viewer, false if not
|
||||
* @param viewer - player to check visibility status for
|
||||
* @return true if hidden, false if not
|
||||
*
|
||||
* @param player
|
||||
* player to check visibility status of
|
||||
* @param viewer
|
||||
* player to check visibility status for
|
||||
* @return true if hidden, false if not
|
||||
*/
|
||||
boolean hasHiddenNametag(TabPlayer player, TabPlayer viewer);
|
||||
|
||||
/**
|
||||
* Unregisters player's team and no longer handles it, as well as disables anti-override for teams.
|
||||
* This can be resumed using resumeTeamHandling(). If team handling was paused already, nothing happens.
|
||||
*
|
||||
* @param player
|
||||
* player to pause team handling of
|
||||
*/
|
||||
void pauseTeamHandling(TabPlayer player);
|
||||
|
||||
/**
|
||||
* Resumes team handling if it was before paused using pauseTeamHandling(), if not, nothing happens
|
||||
*
|
||||
* @param player
|
||||
* player to resume team handling of
|
||||
*/
|
||||
void resumeTeamHandling(TabPlayer player);
|
||||
|
||||
/**
|
||||
* Returns true if team handling is paused for this player using pauseTeamHandling(), false if not, or
|
||||
* it was resumed already using resumeTeamHandling
|
||||
* @return true if paused, false if not
|
||||
*
|
||||
* @param player
|
||||
* player to check handling status of
|
||||
* @return true if paused, false if not
|
||||
*/
|
||||
boolean hasTeamHandlingPaused(TabPlayer player);
|
||||
|
||||
/**
|
||||
* Forces new team name for the player until this method is called again with null argument and
|
||||
* performs all actions to change player's team name
|
||||
* @param teamName - forced team name
|
||||
*
|
||||
* @param player
|
||||
* player to set team name of
|
||||
* @param teamName
|
||||
* forced team name
|
||||
*/
|
||||
void forceTeamName(TabPlayer player, String teamName);
|
||||
|
||||
/**
|
||||
* Returns forced team name of player or null if not forced
|
||||
* @return forced team name of player or null if not forced
|
||||
*
|
||||
* @param player
|
||||
* player to check forced team name of
|
||||
* @return forced team name of player or null if not forced
|
||||
*/
|
||||
String getForcedTeamName(TabPlayer player);
|
||||
|
||||
|
||||
/**
|
||||
* Forces collision rule for the player. Setting it to null will remove forced value
|
||||
* @param collision - forced collision rule
|
||||
*
|
||||
* @param player
|
||||
* player to set collision rule of
|
||||
* @param collision
|
||||
* forced collision rule
|
||||
*/
|
||||
void setCollisionRule(TabPlayer player, Boolean collision);
|
||||
|
||||
/**
|
||||
* Returns forced collision rule or null if collision is not forced using setCollisionRule
|
||||
* @return forced value or null if not forced
|
||||
*
|
||||
* @param player
|
||||
* player to get forced collision of
|
||||
* @return forced value or null if not forced
|
||||
*/
|
||||
Boolean getCollisionRule(TabPlayer player);
|
||||
|
||||
/**
|
||||
* Sends update team's properties packet of player's team to everyone
|
||||
* @param player - player to update team data of
|
||||
*
|
||||
* @param player
|
||||
* player to update team data of
|
||||
*/
|
||||
void updateTeamData(TabPlayer player);
|
||||
|
||||
@@ -116,10 +162,10 @@ public interface TeamManager {
|
||||
* On first call, nametags of all players will become invisible for specified
|
||||
* player. On second call, they will become visible again.
|
||||
*
|
||||
* @param player
|
||||
* player to toggle nametag visibility view for
|
||||
* @param sendToggleMessage
|
||||
* {@code true} if configured toggle message should be sent, {@code false} if not
|
||||
* @param player
|
||||
* player to toggle nametag visibility view for
|
||||
* @param sendToggleMessage
|
||||
* {@code true} if configured toggle message should be sent, {@code false} if not
|
||||
*/
|
||||
void toggleNameTagVisibilityView(TabPlayer player, boolean sendToggleMessage);
|
||||
|
||||
@@ -128,9 +174,9 @@ public interface TeamManager {
|
||||
* {@link #toggleNameTagVisibilityView(TabPlayer, boolean)} or using a command,
|
||||
* {@code false} if not.
|
||||
*
|
||||
* @param player
|
||||
* player to check
|
||||
* @return {@code true} if hidden, {@code false} if not
|
||||
* @param player
|
||||
* player to check
|
||||
* @return {@code true} if hidden, {@code false} if not
|
||||
*/
|
||||
boolean hasHiddenNameTagVisibilityView(TabPlayer player);
|
||||
}
|
||||
@@ -5,12 +5,12 @@ package me.neznamy.tab.api.util;
|
||||
* Used in {@link me.neznamy.tab.api.protocol.PacketBuilder} to
|
||||
* call build method for packet classes, which may throw an
|
||||
* exception due to reflection.
|
||||
* @param <A>
|
||||
* First function argument
|
||||
* @param <B>
|
||||
* Second function argument
|
||||
* @param <C>
|
||||
* Function return type
|
||||
* @param <A>
|
||||
* First function argument
|
||||
* @param <B>
|
||||
* Second function argument
|
||||
* @param <C>
|
||||
* Function return type
|
||||
*/
|
||||
public interface BiFunctionWithException<A, B, C> {
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ public class BukkitEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Listener to PlayerQuitEvent to remove player data and forward the event to features
|
||||
* @param e quit event
|
||||
*
|
||||
* @param e
|
||||
* quit event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onQuit(PlayerQuitEvent e){
|
||||
@@ -33,7 +35,9 @@ public class BukkitEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Listener to PlayerJoinEvent to create player data and forward the event to features
|
||||
* @param e join event
|
||||
*
|
||||
* @param e
|
||||
* join event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
@@ -43,7 +47,9 @@ public class BukkitEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Listener to PlayerChangedWorldEvent to forward the event to features
|
||||
* @param e world changed event
|
||||
*
|
||||
* @param e
|
||||
* world changed event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onWorldChange(PlayerChangedWorldEvent e){
|
||||
@@ -53,7 +59,9 @@ public class BukkitEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Listener to PlayerChangedWorldEvent to forward the event to features
|
||||
* @param e command preprocess event
|
||||
*
|
||||
* @param e
|
||||
* command preprocess event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
|
||||
@@ -225,9 +225,10 @@ public class BukkitPacketBuilder extends PacketBuilder {
|
||||
|
||||
/**
|
||||
* Builds entity destroy packet with given parameter
|
||||
* @return destroy packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @return destroy packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutEntityDestroy packet) throws ReflectiveOperationException {
|
||||
try {
|
||||
@@ -245,9 +246,9 @@ public class BukkitPacketBuilder extends PacketBuilder {
|
||||
/**
|
||||
* Builds entity spawn packet with given parameters
|
||||
*
|
||||
* @return entity spawn packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* @return entity spawn packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutSpawnEntityLiving packet) throws ReflectiveOperationException {
|
||||
Object nmsPacket;
|
||||
@@ -278,9 +279,10 @@ public class BukkitPacketBuilder extends PacketBuilder {
|
||||
|
||||
/**
|
||||
* Builds entity teleport packet with given parameters
|
||||
* @return entity teleport packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @return entity teleport packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object build(PacketPlayOutEntityTeleport packet) throws ReflectiveOperationException {
|
||||
Object nmsPacket;
|
||||
@@ -360,11 +362,14 @@ public class BukkitPacketBuilder extends PacketBuilder {
|
||||
|
||||
/**
|
||||
* Builds entity BossBar packet
|
||||
* @param packet - packet to build
|
||||
* @param clientVersion - client version
|
||||
* @return entity BossBar packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @param packet
|
||||
* packet to build
|
||||
* @param clientVersion
|
||||
* client version
|
||||
* @return entity BossBar packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
private Object buildBossPacketEntity(PacketPlayOutBoss packet, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
if (packet.getAction() == Action.UPDATE_STYLE) return null; //nothing to do here
|
||||
@@ -392,8 +397,10 @@ public class BukkitPacketBuilder extends PacketBuilder {
|
||||
|
||||
/**
|
||||
* A method taken from minecraft code used to convert double to int
|
||||
* @param paramDouble double value
|
||||
* @return int value
|
||||
*
|
||||
* @param paramDouble
|
||||
* double value
|
||||
* @return int value
|
||||
*/
|
||||
private int floor(double paramDouble){
|
||||
int i = (int)paramDouble;
|
||||
@@ -402,10 +409,12 @@ public class BukkitPacketBuilder extends PacketBuilder {
|
||||
|
||||
/**
|
||||
* Converts minecraft IChatBaseComponent into TAB's component class. Currently, does not support show_item hover event on 1.16+.
|
||||
* @param component - component to convert
|
||||
* @return converted component
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @param component
|
||||
* component to convert
|
||||
* @return converted component
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
private IChatBaseComponent fromNMSComponent(Object component) throws ReflectiveOperationException {
|
||||
if (!nms.ChatComponentText.isInstance(component)) return null; //paper
|
||||
@@ -462,11 +471,14 @@ public class BukkitPacketBuilder extends PacketBuilder {
|
||||
|
||||
/**
|
||||
* Converts TAB's IChatBaseComponent into minecraft's component. Currently, does not support hover event.
|
||||
* @param component - component to convert
|
||||
* @param clientVersion - client version used to decide RGB conversion
|
||||
* @return converted component
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @param component
|
||||
* component to convert
|
||||
* @param clientVersion
|
||||
* client version used to decide RGB conversion
|
||||
* @return converted component
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object toNMSComponent(IChatBaseComponent component, ProtocolVersion clientVersion) throws ReflectiveOperationException {
|
||||
Object obj;
|
||||
|
||||
@@ -43,7 +43,9 @@ public class BukkitPipelineInjector extends PipelineInjector {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given player
|
||||
* @param player - player to inject
|
||||
*
|
||||
* @param player
|
||||
* player to inject
|
||||
*/
|
||||
public BukkitChannelDuplexHandler(TabPlayer player) {
|
||||
Preconditions.checkNotNull(player, "player");
|
||||
@@ -91,9 +93,11 @@ public class BukkitPipelineInjector extends PipelineInjector {
|
||||
|
||||
/**
|
||||
* Removes all real players from team if packet does not come from TAB and reports this to override log
|
||||
* @param packetPlayOutScoreboardTeam - team packet
|
||||
* @throws ReflectiveOperationException
|
||||
* nmsGameMode
|
||||
*
|
||||
* @param packetPlayOutScoreboardTeam
|
||||
* team packet
|
||||
* @throws ReflectiveOperationException
|
||||
* nmsGameMode
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void modifyPlayers(Object packetPlayOutScoreboardTeam) throws ReflectiveOperationException {
|
||||
|
||||
@@ -49,8 +49,9 @@ public class BukkitPlatform extends Platform {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given plugin parameter
|
||||
* @param plugin
|
||||
* plugin instance
|
||||
*
|
||||
* @param plugin
|
||||
* plugin instance
|
||||
*/
|
||||
public BukkitPlatform(JavaPlugin plugin) {
|
||||
super(new BukkitPacketBuilder());
|
||||
@@ -131,7 +132,8 @@ public class BukkitPlatform extends Platform {
|
||||
|
||||
/**
|
||||
* Returns online players from Bukkit API
|
||||
* @return online players from Bukkit API
|
||||
*
|
||||
* @return online players from Bukkit API
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Player[] getOnlinePlayers() {
|
||||
@@ -201,7 +203,8 @@ public class BukkitPlatform extends Platform {
|
||||
|
||||
/**
|
||||
* Returns status of LibsDisguises plugin presence
|
||||
* @return {@code true} if plugin is enabled, {@code false} if not
|
||||
*
|
||||
* @return {@code true} if plugin is enabled, {@code false} if not
|
||||
*/
|
||||
public boolean isLibsDisguisesEnabled() {
|
||||
return libsDisguises;
|
||||
@@ -211,8 +214,9 @@ public class BukkitPlatform extends Platform {
|
||||
* Sets LibsDisguises presence status to provided value. This is used
|
||||
* to disable LibsDisguises hook in case the plugin is not correctly loaded
|
||||
* for any reason to avoid error spam in the hook.
|
||||
* @param enabled
|
||||
* New status of LibsDisguises presence
|
||||
*
|
||||
* @param enabled
|
||||
* New status of LibsDisguises presence
|
||||
*/
|
||||
public void setLibsDisguisesEnabled(boolean enabled) {
|
||||
libsDisguises = enabled;
|
||||
@@ -220,7 +224,8 @@ public class BukkitPlatform extends Platform {
|
||||
|
||||
/**
|
||||
* Returns Essentials' main class if the plugin is installed, {@code null} if not
|
||||
* @return Essentials instance or {@code null} if plugin is not installed
|
||||
*
|
||||
* @return Essentials instance or {@code null} if plugin is not installed
|
||||
*/
|
||||
public Essentials getEssentials() {
|
||||
return (Essentials) essentials;
|
||||
@@ -238,9 +243,10 @@ public class BukkitPlatform extends Platform {
|
||||
|
||||
/**
|
||||
* Gets protocol version of requested player and returns it.
|
||||
* @param player
|
||||
* Player to get protocol version of
|
||||
* @return protocol version of the player
|
||||
*
|
||||
* @param player
|
||||
* Player to get protocol version of
|
||||
* @return protocol version of the player
|
||||
*/
|
||||
public int getProtocolVersion(Player player) {
|
||||
if (protocolSupport){
|
||||
@@ -256,9 +262,10 @@ public class BukkitPlatform extends Platform {
|
||||
|
||||
/**
|
||||
* Returns protocol version of requested player using ProtocolSupport
|
||||
* @param player
|
||||
* Player to get protocol version of
|
||||
* @return protocol version of the player using ProtocolSupport
|
||||
*
|
||||
* @param player
|
||||
* Player to get protocol version of
|
||||
* @return protocol version of the player using ProtocolSupport
|
||||
*/
|
||||
private int getProtocolVersionPS(Player player){
|
||||
try {
|
||||
@@ -274,9 +281,10 @@ public class BukkitPlatform extends Platform {
|
||||
|
||||
/**
|
||||
* Returns protocol version of requested player using ViaVersion
|
||||
* @param player
|
||||
* Player to get protocol version of
|
||||
* @return protocol version of the player using ViaVersion
|
||||
*
|
||||
* @param player
|
||||
* Player to get protocol version of
|
||||
* @return protocol version of the player using ViaVersion
|
||||
*/
|
||||
private int getProtocolVersionVia(Player player, int retryLevel){
|
||||
try {
|
||||
|
||||
@@ -48,20 +48,19 @@ public class BukkitTabPlayer extends ITabPlayer {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given bukkit player and protocol version
|
||||
* @param p
|
||||
* bukkit player
|
||||
* @param protocolVersion
|
||||
* Player's protocol network id
|
||||
*
|
||||
* @param p
|
||||
* bukkit player
|
||||
* @param protocolVersion
|
||||
* Player's protocol network id
|
||||
*/
|
||||
public BukkitTabPlayer(Player p, int protocolVersion){
|
||||
super(p, p.getUniqueId(), p.getName(), "N/A", p.getWorld().getName(), protocolVersion);
|
||||
try {
|
||||
handle = NMSStorage.getInstance().getHandle.invoke(player);
|
||||
playerConnection = NMSStorage.getInstance().PLAYER_CONNECTION.get(handle);
|
||||
if (NMSStorage.getInstance().CHANNEL != null)
|
||||
channel = (Channel) NMSStorage.getInstance().CHANNEL.get(NMSStorage.getInstance().NETWORK_MANAGER.get(playerConnection));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
TAB.getInstance().getErrorManager().printError("Failed to get playerConnection or channel of " + p.getName(), e);
|
||||
TAB.getInstance().getErrorManager().printError("Failed to get playerConnection of " + p.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +108,9 @@ public class BukkitTabPlayer extends ITabPlayer {
|
||||
* Handles PacketPlayOutBoss packet send request using Bukkit API,
|
||||
* since the API offers everything we need and makes us not need to
|
||||
* deal with NMS code at all.
|
||||
* @param packet
|
||||
* packet request to handle using Bukkit API
|
||||
*
|
||||
* @param packet
|
||||
* packet request to handle using Bukkit API
|
||||
*/
|
||||
private void handle(PacketPlayOutBoss packet) {
|
||||
BossBar bar = bossBars.get(packet.getId());
|
||||
@@ -157,8 +157,9 @@ public class BukkitTabPlayer extends ITabPlayer {
|
||||
/**
|
||||
* Handles PacketPlayOutBoss packet request for 1.9+ clients on
|
||||
* 1.8 servers using ViaVersion API instead of using Wither.
|
||||
* @param packet
|
||||
* packet request to handle using ViaVersion API
|
||||
*
|
||||
* @param packet
|
||||
* packet request to handle using ViaVersion API
|
||||
*/
|
||||
private void handleVia(PacketPlayOutBoss packet) {
|
||||
com.viaversion.viaversion.api.legacy.bossbar.BossBar bar;
|
||||
@@ -202,12 +203,13 @@ public class BukkitTabPlayer extends ITabPlayer {
|
||||
|
||||
/**
|
||||
* Sets BossBar flag to requested target value.
|
||||
* @param bar
|
||||
* BossBar to set flag of
|
||||
* @param targetValue
|
||||
* Target value of the flag
|
||||
* @param flag
|
||||
* Flag to set value of
|
||||
*
|
||||
* @param bar
|
||||
* BossBar to set flag of
|
||||
* @param targetValue
|
||||
* Target value of the flag
|
||||
* @param flag
|
||||
* Flag to set value of
|
||||
*/
|
||||
private void processFlag(BossBar bar, boolean targetValue, BarFlag flag) {
|
||||
if (targetValue && !bar.hasFlag(flag)) bar.addFlag(flag);
|
||||
@@ -216,12 +218,13 @@ public class BukkitTabPlayer extends ITabPlayer {
|
||||
|
||||
/**
|
||||
* Sets BossBar flag to requested target value.
|
||||
* @param bar
|
||||
* BossBar to set flag of
|
||||
* @param targetValue
|
||||
* Target value of the flag
|
||||
* @param flag
|
||||
* Flag to set value of
|
||||
*
|
||||
* @param bar
|
||||
* BossBar to set flag of
|
||||
* @param targetValue
|
||||
* Target value of the flag
|
||||
* @param flag
|
||||
* Flag to set value of
|
||||
*/
|
||||
private void processFlagVia(com.viaversion.viaversion.api.legacy.bossbar.BossBar bar, boolean targetValue, BossFlag flag) {
|
||||
if (targetValue && !bar.hasFlag(flag)) bar.addFlag(flag);
|
||||
@@ -283,4 +286,15 @@ public class BukkitTabPlayer extends ITabPlayer {
|
||||
public int getGamemode() {
|
||||
return getPlayer().getGameMode().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
try {
|
||||
if (NMSStorage.getInstance().CHANNEL != null)
|
||||
return (Channel) NMSStorage.getInstance().CHANNEL.get(NMSStorage.getInstance().NETWORK_MANAGER.get(playerConnection));
|
||||
} catch (IllegalAccessException e) {
|
||||
TAB.getInstance().getErrorManager().printError("Failed to get channel of " + getName(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,8 @@ public class Main extends JavaPlugin {
|
||||
* Initializes all used NMS classes, constructors, fields and methods.
|
||||
* Returns {@code true} if everything went successfully and version is marked as compatible,
|
||||
* {@code false} if anything went wrong or version is not marked as compatible.
|
||||
* @return {@code true} if server version is compatible, {@code false} if not
|
||||
*
|
||||
* @return {@code true} if server version is compatible, {@code false} if not
|
||||
*/
|
||||
private boolean isVersionSupported(){
|
||||
List<String> supportedVersions = Arrays.asList(
|
||||
|
||||
@@ -9,6 +9,7 @@ import me.neznamy.tab.shared.features.TabExpansion;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
@@ -55,6 +56,9 @@ public class BukkitTabExpansion extends PlaceholderExpansion implements TabExpan
|
||||
String output = PlaceholderAPI.setPlaceholders(player, placeholder);
|
||||
return TAB.getInstance().getPlaceholderManager().findReplacement(placeholder, output);
|
||||
}
|
||||
if (identifier.startsWith("placeholder_")) {
|
||||
TAB.getInstance().getPlaceholderManager().addUsedPlaceholders(Collections.singletonList("%" + identifier.substring(12) + "%"));
|
||||
}
|
||||
return values.computeIfAbsent(p, pl -> new HashMap<>()).get(identifier);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -34,7 +34,9 @@ public class PerWorldPlayerList extends TabFeature implements Listener {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters and loads config options
|
||||
* @param plugin - plugin instance
|
||||
*
|
||||
* @param plugin
|
||||
* plugin instance
|
||||
*/
|
||||
public PerWorldPlayerList(JavaPlugin plugin) {
|
||||
super("Per world PlayerList", null);
|
||||
|
||||
@@ -50,7 +50,8 @@ public class PetFix extends TabFeature {
|
||||
|
||||
/**
|
||||
* Returns position of pet owner field based on server version
|
||||
* @return position of pet owner field based on server version
|
||||
*
|
||||
* @return position of pet owner field based on server version
|
||||
*/
|
||||
private int getPetOwnerPosition() {
|
||||
if (nms.getMinorVersion() >= 17) {
|
||||
@@ -72,9 +73,10 @@ public class PetFix extends TabFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels a packet if previous one arrived with no delay to prevent double toggle on 1.16
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
* Cancels a packet if previous one arrived with no delay to prevent double toggle since 1.16
|
||||
*
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
@Override
|
||||
public boolean onPacketReceive(TabPlayer sender, Object packet) throws ReflectiveOperationException {
|
||||
@@ -101,8 +103,9 @@ public class PetFix extends TabFeature {
|
||||
|
||||
/**
|
||||
* Removes pet owner field from DataWatcher
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@@ -116,7 +119,7 @@ public class PetFix extends TabFeature {
|
||||
if (item == null) continue;
|
||||
if (nms.DataWatcherObject_SLOT.getInt(nms.DataWatcherItem_TYPE.get(item)) == petOwnerPosition) {
|
||||
Object value = nms.DataWatcherItem_VALUE.get(item);
|
||||
if (value instanceof java.util.Optional || value instanceof com.google.common.base.Optional) {
|
||||
if (value instanceof Optional || value instanceof com.google.common.base.Optional) {
|
||||
removedEntry = item;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +133,7 @@ public class PetFix extends TabFeature {
|
||||
//<1.15
|
||||
DataWatcher watcher = DataWatcher.fromNMS(nms.PacketPlayOutSpawnEntityLiving_DATAWATCHER.get(packet));
|
||||
DataWatcherItem petOwner = watcher.getItem(petOwnerPosition);
|
||||
if (petOwner != null && (petOwner.getValue() instanceof java.util.Optional || petOwner.getValue() instanceof com.google.common.base.Optional)) {
|
||||
if (petOwner != null && (petOwner.getValue() instanceof Optional || petOwner.getValue() instanceof com.google.common.base.Optional)) {
|
||||
watcher.removeValue(petOwnerPosition);
|
||||
nms.setField(packet, nms.PacketPlayOutSpawnEntityLiving_DATAWATCHER, watcher.toNMS());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ public class WitherBossBar extends BossBarManagerImpl implements Listener {
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the class
|
||||
* @param plugin - plugin instance
|
||||
*
|
||||
* @param plugin
|
||||
* plugin instance
|
||||
*/
|
||||
public WitherBossBar(JavaPlugin plugin) {
|
||||
Preconditions.checkNotNull(plugin, "plugin");
|
||||
|
||||
+28
-14
@@ -172,8 +172,10 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns teleport packet for specified viewer
|
||||
* @param viewer - player to get location for
|
||||
* @return teleport packet
|
||||
*
|
||||
* @param viewer
|
||||
* player to get location for
|
||||
* @return teleport packet
|
||||
*/
|
||||
public PacketPlayOutEntityTeleport getTeleportPacket(TabPlayer viewer) {
|
||||
return new PacketPlayOutEntityTeleport(entityId, getArmorStandLocationFor(viewer));
|
||||
@@ -190,7 +192,8 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns general visibility rule for everyone with limited info
|
||||
* @return true if armor stand should be visible, false if not
|
||||
*
|
||||
* @return true if armor stand should be visible, false if not
|
||||
*/
|
||||
public boolean getVisibility() {
|
||||
if (manager.isArmorStandsAlwaysVisible()) return true;
|
||||
@@ -200,7 +203,8 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns general location where armor stand should be at time of calling
|
||||
* @return Location where armor stand should be for everyone
|
||||
*
|
||||
* @return Location where armor stand should be for everyone
|
||||
*/
|
||||
public Location getLocation() {
|
||||
double x = player.getLocation().getX();
|
||||
@@ -220,7 +224,8 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns Y where player is based on player's vehicle due to bukkit API bug
|
||||
* @return correct player's Y
|
||||
*
|
||||
* @return correct player's Y
|
||||
*/
|
||||
protected double getY() {
|
||||
//1.14+ server sided bug
|
||||
@@ -253,9 +258,12 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Creates data watcher with specified display name for viewer
|
||||
* @param displayName - armor stand name
|
||||
* @param viewer - player to apply checks against
|
||||
* @return DataWatcher for viewer
|
||||
*
|
||||
* @param displayName
|
||||
* armor stand name
|
||||
* @param viewer
|
||||
* player to apply checks against
|
||||
* @return DataWatcher for viewer
|
||||
*/
|
||||
public DataWatcher createDataWatcher(String displayName, TabPlayer viewer) {
|
||||
DataWatcher datawatcher = new DataWatcher();
|
||||
@@ -280,8 +288,10 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns true if display name is in fact empty, for example only containing color codes
|
||||
* @param displayName - string to check
|
||||
* @return true if it's empty, false if not
|
||||
*
|
||||
* @param displayName
|
||||
* string to check
|
||||
* @return true if it's empty, false if not
|
||||
*/
|
||||
private boolean isNameVisiblyEmpty(String displayName) {
|
||||
if (displayName.length() == 0) return true;
|
||||
@@ -293,8 +303,10 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns list of packets to send to make armor stand spawn with metadata
|
||||
* @param viewer - viewer to apply relational placeholders for
|
||||
* @return List of packets that spawn the armor stand
|
||||
*
|
||||
* @param viewer
|
||||
* viewer to apply relational placeholders for
|
||||
* @return List of packets that spawn the armor stand
|
||||
*/
|
||||
public TabPacket[] getSpawnPackets(TabPlayer viewer) {
|
||||
visible = getVisibility();
|
||||
@@ -313,8 +325,10 @@ public class BukkitArmorStand implements ArmorStand {
|
||||
|
||||
/**
|
||||
* Returns location where armor stand should be for specified viewer
|
||||
* @param viewer - player to get location for
|
||||
* @return location of armor stand
|
||||
*
|
||||
* @param viewer
|
||||
* player to get location for
|
||||
* @return location of armor stand
|
||||
*/
|
||||
public Location getArmorStandLocationFor(TabPlayer viewer) {
|
||||
return viewer.getVersion().getMinorVersion() == 8 && !manager.isMarkerFor18x() ? getLocation().clone().add(0,-2,0) : getLocation();
|
||||
|
||||
+32
-19
@@ -46,7 +46,9 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
|
||||
/**
|
||||
* Teleports armor stands to player's current location for specified viewer
|
||||
* @param viewer - player to teleport armor stands for
|
||||
*
|
||||
* @param viewer
|
||||
* player to teleport armor stands for
|
||||
*/
|
||||
public void teleport(TabPlayer viewer) {
|
||||
for (ArmorStand a : armorStandArray) a.teleport(viewer);
|
||||
@@ -62,9 +64,10 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
|
||||
/**
|
||||
* Returns {@code true} if requested player is nearby, {@code false} if not
|
||||
* @param viewer
|
||||
* Player to check for
|
||||
* @return {@code true} if player nearby, {@code false} if not
|
||||
*
|
||||
* @param viewer
|
||||
* Player to check for
|
||||
* @return {@code true} if player nearby, {@code false} if not
|
||||
*/
|
||||
public boolean isNearby(TabPlayer viewer) {
|
||||
return nearbyPlayers.contains(viewer);
|
||||
@@ -72,8 +75,10 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
|
||||
/**
|
||||
* Returns true if manager contains armor stand with specified entity id, false if not
|
||||
* @param entityId - entity id
|
||||
* @return true if armor stand with specified entity id exists, false if not
|
||||
*
|
||||
* @param entityId
|
||||
* entity id
|
||||
* @return true if armor stand with specified entity id exists, false if not
|
||||
*/
|
||||
public boolean hasArmorStandWithID(int entityId) {
|
||||
for (ArmorStand a : armorStandArray) {
|
||||
@@ -86,7 +91,9 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
|
||||
/**
|
||||
* Sets sneak value of armor stands to specified value
|
||||
* @param sneaking - new sneaking status
|
||||
*
|
||||
* @param sneaking
|
||||
* new sneaking status
|
||||
*/
|
||||
public void sneak(boolean sneaking) {
|
||||
for (ArmorStand a : armorStandArray) a.sneak(sneaking);
|
||||
@@ -112,7 +119,9 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
|
||||
/**
|
||||
* Spawns all armor stands for specified viewer and adds them into nearby players
|
||||
* @param viewer - player to spawn armor stands for
|
||||
*
|
||||
* @param viewer
|
||||
* player to spawn armor stands for
|
||||
*/
|
||||
public void spawn(TabPlayer viewer) {
|
||||
nearbyPlayers.add(viewer);
|
||||
@@ -123,7 +132,9 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
|
||||
/**
|
||||
* Sends destroy packet of all armor stands to specified player and removes them from nearby players list
|
||||
* @param viewer - player to destroy armor stands for
|
||||
*
|
||||
* @param viewer
|
||||
* player to destroy armor stands for
|
||||
*/
|
||||
public void destroy(TabPlayer viewer) {
|
||||
for (ArmorStand a : armorStandArray) a.destroy(viewer);
|
||||
@@ -147,10 +158,10 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
/**
|
||||
* Adds armor stand to list and registers it to all nearby players
|
||||
*
|
||||
* @param name
|
||||
* Unique identifier of the text line
|
||||
* @param as
|
||||
* Armor stand to add
|
||||
* @param name
|
||||
* Unique identifier of the text line
|
||||
* @param as
|
||||
* Armor stand to add
|
||||
*/
|
||||
public void addArmorStand(String name, ArmorStand as) {
|
||||
armorStands.put(name, as);
|
||||
@@ -161,9 +172,9 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
/**
|
||||
* Gets armor stand by name
|
||||
*
|
||||
* @param name
|
||||
* Name to get armor stand by
|
||||
* @return Armor stand with given name or null if not found
|
||||
* @param name
|
||||
* Name to get armor stand by
|
||||
* @return Armor stand with given name or null if not found
|
||||
*/
|
||||
public ArmorStand getArmorStand(String name) {
|
||||
return armorStands.get(name);
|
||||
@@ -172,8 +183,8 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
/**
|
||||
* Removes armor stand by given name if exists
|
||||
*
|
||||
* @param name
|
||||
* Name of line to remove
|
||||
* @param name
|
||||
* Name of line to remove
|
||||
*/
|
||||
public void removeArmorStand(String name) {
|
||||
if (!armorStands.containsKey(name)) return;
|
||||
@@ -184,7 +195,9 @@ public class BukkitArmorStandManager implements ArmorStandManager {
|
||||
|
||||
/**
|
||||
* Removes specified player from list of nearby players
|
||||
* @param viewer - player to remove
|
||||
*
|
||||
* @param viewer
|
||||
* player to remove
|
||||
*/
|
||||
public void unregisterPlayer(TabPlayer viewer) {
|
||||
if (nearbyPlayers.remove(viewer)) nearbyPlayerArray = nearbyPlayers.toArray(new TabPlayer[0]);
|
||||
|
||||
+13
-12
@@ -22,7 +22,9 @@ public class BukkitNameTagX extends NameTagX {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters and loads config options
|
||||
* @param plugin - plugin instance
|
||||
*
|
||||
* @param plugin
|
||||
* plugin instance
|
||||
*/
|
||||
public BukkitNameTagX(JavaPlugin plugin) {
|
||||
super(BukkitArmorStandManager::new);
|
||||
@@ -77,9 +79,8 @@ public class BukkitNameTagX extends NameTagX {
|
||||
private void spawnArmorStands(TabPlayer viewer, TabPlayer target) {
|
||||
if (target == viewer || isPlayerDisabled(target)) return;
|
||||
if (((Player) viewer.getPlayer()).getWorld() != ((Player) target.getPlayer()).getWorld()) return;
|
||||
if (getDistance(viewer, target) <= 48) {
|
||||
if (((Player)viewer.getPlayer()).canSee((Player)target.getPlayer()) && !target.isVanished()) getArmorStandManager(target).spawn(viewer);
|
||||
}
|
||||
if (getDistance(viewer, target) <= 48 && ((Player)viewer.getPlayer()).canSee((Player)target.getPlayer()) && !target.isVanished())
|
||||
getArmorStandManager(target).spawn(viewer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,7 +102,6 @@ public class BukkitNameTagX extends NameTagX {
|
||||
|
||||
@Override
|
||||
public void pauseArmorStands(TabPlayer player) {
|
||||
if (isPlayerDisabled(player)) return;
|
||||
getArmorStandManager(player).destroy();
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ public class BukkitNameTagX extends NameTagX {
|
||||
for (TabPlayer all : TAB.getInstance().getOnlinePlayers()) {
|
||||
getArmorStandManager(all).unregisterPlayer(disconnectedPlayer);
|
||||
}
|
||||
getArmorStandManager(disconnectedPlayer).destroy();
|
||||
TAB.getInstance().getCPUManager().runTaskLater(500, this, TabConstants.CpuUsageCategory.PLAYER_QUIT, () -> getArmorStandManager(disconnectedPlayer).destroy());
|
||||
armorStandManagerMap.get(disconnectedPlayer).destroy();
|
||||
armorStandManagerMap.remove(disconnectedPlayer); // WeakHashMap doesn't clear this due to value referencing the key
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,9 +138,12 @@ public class BukkitNameTagX extends NameTagX {
|
||||
|
||||
/**
|
||||
* Returns flat distance between two players ignoring Y value
|
||||
* @param player1 - first player
|
||||
* @param player2 - second player
|
||||
* @return flat distance in blocks
|
||||
*
|
||||
* @param player1
|
||||
* first player
|
||||
* @param player2
|
||||
* second player
|
||||
* @return flat distance in blocks
|
||||
*/
|
||||
private double getDistance(TabPlayer player1, TabPlayer player2) {
|
||||
Location loc1 = ((Player) player1.getPlayer()).getLocation();
|
||||
@@ -156,6 +159,4 @@ public class BukkitNameTagX extends NameTagX {
|
||||
public VehicleRefresher getVehicleManager() {
|
||||
return vehicleManager;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+9
-3
@@ -20,7 +20,9 @@ public class EventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
* @param feature - NameTag feature handler
|
||||
*
|
||||
* @param feature
|
||||
* NameTag feature handler
|
||||
*/
|
||||
public EventListener(BukkitNameTagX feature) {
|
||||
this.feature = feature;
|
||||
@@ -28,7 +30,9 @@ public class EventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Sneak event listener to de-spawn and spawn armor stands to skip animation
|
||||
* @param e - sneak event
|
||||
*
|
||||
* @param e
|
||||
* sneak event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSneak(PlayerToggleSneakEvent e) {
|
||||
@@ -39,7 +43,9 @@ public class EventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Respawning armor stands as respawn screen destroys all entities in client
|
||||
* @param e - respawn event
|
||||
*
|
||||
* @param e
|
||||
* respawn event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
|
||||
+13
-6
@@ -30,7 +30,9 @@ public class PacketListener extends TabFeature {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters and loads config options
|
||||
* @param nameTagX - main feature
|
||||
*
|
||||
* @param nameTagX
|
||||
* main feature
|
||||
*/
|
||||
public PacketListener(BukkitNameTagX nameTagX) {
|
||||
super(nameTagX.getFeatureName(), null);
|
||||
@@ -100,15 +102,18 @@ public class PacketListener extends TabFeature {
|
||||
|
||||
/**
|
||||
* Processes entity move packet
|
||||
* @param receiver - packet receiver
|
||||
* @param entityId - entity that moved
|
||||
*
|
||||
* @param receiver
|
||||
* packet receiver
|
||||
* @param entityId
|
||||
* entity that moved
|
||||
*/
|
||||
private void onEntityMove(TabPlayer receiver, int entityId) {
|
||||
TabPlayer pl = entityIdMap.get(entityId);
|
||||
List<Entity> vehicleList;
|
||||
if (pl != null) {
|
||||
//player moved
|
||||
if (nameTagX.isPlayerDisabled(pl)) return;
|
||||
if (nameTagX.isPlayerDisabled(pl) || !pl.isLoaded()) return;
|
||||
TAB.getInstance().getCPUManager().runMeasuredTask(nameTagX, TabConstants.CpuUsageCategory.PACKET_ENTITY_MOVE,
|
||||
() -> nameTagX.getArmorStandManager(pl).teleport(receiver));
|
||||
} else if ((vehicleList = nameTagX.getVehicleManager().getVehicles().get(entityId)) != null){
|
||||
@@ -145,8 +150,10 @@ public class PacketListener extends TabFeature {
|
||||
|
||||
private void onEntityDestroy(TabPlayer receiver, int entity) {
|
||||
TabPlayer deSpawnedPlayer = entityIdMap.get(entity);
|
||||
if (deSpawnedPlayer != null && deSpawnedPlayer.isLoaded() && !nameTagX.isPlayerDisabled(deSpawnedPlayer))
|
||||
if (deSpawnedPlayer != null && deSpawnedPlayer.isLoaded() && !nameTagX.isPlayerDisabled(deSpawnedPlayer)) {
|
||||
BukkitArmorStandManager asm = nameTagX.getArmorStandManager(deSpawnedPlayer);
|
||||
TAB.getInstance().getCPUManager().runMeasuredTask(nameTagX, TabConstants.CpuUsageCategory.PACKET_ENTITY_DESTROY,
|
||||
() -> nameTagX.getArmorStandManager(deSpawnedPlayer).destroy(receiver));
|
||||
() -> asm.destroy(receiver));
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-3
@@ -31,6 +31,7 @@ public class VehicleRefresher extends TabFeature {
|
||||
TAB.getInstance().getCPUManager().startRepeatingMeasuredTask(50,
|
||||
this, TabConstants.CpuUsageCategory.PROCESSING_PLAYER_MOVEMENT, () -> {
|
||||
for (TabPlayer inVehicle : playersInVehicle.keySet()) {
|
||||
if (!inVehicle.isOnline() || feature.getArmorStandManager(inVehicle) == null) continue; // not removed from WeakHashMap yet
|
||||
feature.getArmorStandManager(inVehicle).teleport();
|
||||
// feature.getVehicleManager().processPassengers((Entity) inVehicle.getPlayer());
|
||||
}
|
||||
@@ -67,6 +68,9 @@ public class VehicleRefresher extends TabFeature {
|
||||
@Override
|
||||
public void onQuit(TabPlayer disconnectedPlayer) {
|
||||
if (playersInVehicle.containsKey(disconnectedPlayer)) vehicles.remove(playersInVehicle.get(disconnectedPlayer).getEntityId());
|
||||
for (List<Entity> entities : vehicles.values()) {
|
||||
entities.remove((Player) disconnectedPlayer.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,8 +109,10 @@ public class VehicleRefresher extends TabFeature {
|
||||
|
||||
/**
|
||||
* Returns list of all passengers on specified vehicle
|
||||
* @param vehicle - vehicle to check passengers of
|
||||
* @return list of passengers
|
||||
*
|
||||
* @param vehicle
|
||||
* vehicle to check passengers of
|
||||
* @return list of passengers
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<Entity> getPassengers(Entity vehicle){
|
||||
@@ -123,7 +129,9 @@ public class VehicleRefresher extends TabFeature {
|
||||
|
||||
/**
|
||||
* Teleports armor stands of all passengers on specified vehicle
|
||||
* @param vehicle - entity to check passengers of
|
||||
*
|
||||
* @param vehicle
|
||||
* entity to check passengers of
|
||||
*/
|
||||
public void processPassengers(Entity vehicle) {
|
||||
for (Entity passenger : getPassengers(vehicle)) {
|
||||
|
||||
@@ -223,8 +223,9 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Creates new instance, initializes required NMS classes and fields
|
||||
* @throws ReflectiveOperationException
|
||||
* If any class, field or method fails to load
|
||||
*
|
||||
* @throws ReflectiveOperationException
|
||||
* If any class, field or method fails to load
|
||||
*/
|
||||
public NMSStorage() throws ReflectiveOperationException {
|
||||
ProtocolVersion.UNKNOWN_SERVER_VERSION.setMinorVersion(minorVersion); //fixing compatibility with forks that set version field value to "Unknown"
|
||||
@@ -255,7 +256,9 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Sets new instance
|
||||
* @param instance - new instance
|
||||
*
|
||||
* @param instance
|
||||
* new instance
|
||||
*/
|
||||
public static void setInstance(NMSStorage instance) {
|
||||
NMSStorage.instance = instance;
|
||||
@@ -263,7 +266,8 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Returns instance
|
||||
* @return instance
|
||||
*
|
||||
* @return instance
|
||||
*/
|
||||
public static NMSStorage getInstance() {
|
||||
return instance;
|
||||
@@ -494,9 +498,12 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Returns class with given potential names in same order
|
||||
* @param names - possible class names
|
||||
* @return class for specified name(s)
|
||||
* @throws ClassNotFoundException if class does not exist
|
||||
*
|
||||
* @param names
|
||||
* possible class names
|
||||
* @return class for specified names
|
||||
* @throws ClassNotFoundException
|
||||
* if class does not exist
|
||||
*/
|
||||
private Class<?> getNMSClass(String fullPath_1_17, String... names) throws ClassNotFoundException {
|
||||
if (minorVersion >= 17) {
|
||||
@@ -514,9 +521,12 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Returns class from given name
|
||||
* @param name - class name
|
||||
* @return class from given name
|
||||
* @throws ClassNotFoundException if class was not found
|
||||
*
|
||||
* @param name
|
||||
* class name
|
||||
* @return class from given name
|
||||
* @throws ClassNotFoundException
|
||||
* if class was not found
|
||||
*/
|
||||
private Class<?> getLegacyClass(String name) throws ClassNotFoundException {
|
||||
try {
|
||||
@@ -536,11 +546,16 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Returns method with specified possible names and parameters. Throws exception if no such method was found
|
||||
* @param clazz - class to get method from
|
||||
* @param names - possible method names
|
||||
* @param parameterTypes - parameter types of the method
|
||||
* @return method with specified name and parameters
|
||||
* @throws NoSuchMethodException if no such method exists
|
||||
*
|
||||
* @param clazz
|
||||
* lass to get method from
|
||||
* @param names
|
||||
* possible method names
|
||||
* @param parameterTypes
|
||||
* parameter types of the method
|
||||
* @return method with specified name and parameters
|
||||
* @throws NoSuchMethodException
|
||||
* if no such method exists
|
||||
*/
|
||||
private Method getMethod(Class<?> clazz, String[] names, Class<?>... parameterTypes) throws NoSuchMethodException {
|
||||
for (String name : names) {
|
||||
@@ -604,9 +619,12 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Returns all fields of class with defined class type
|
||||
* @param clazz - class to check fields of
|
||||
* @param type - field type to check for
|
||||
* @return list of all fields with specified class type
|
||||
*
|
||||
* @param clazz
|
||||
* class to check fields of
|
||||
* @param type
|
||||
* field type to check for
|
||||
* @return list of all fields with specified class type
|
||||
*/
|
||||
private List<Field> getFields(Class<?> clazz, Class<?> type){
|
||||
if (clazz == null) throw new IllegalArgumentException("Source class cannot be null");
|
||||
@@ -621,10 +639,14 @@ public final class NMSStorage {
|
||||
|
||||
/**
|
||||
* Returns field with specified name and makes it accessible
|
||||
* @param clazz - class to get field from
|
||||
* @param name - field name
|
||||
* @return accessible field with defined name
|
||||
* @throws NoSuchFieldException if field was not found
|
||||
*
|
||||
* @param clazz
|
||||
* class to get field from
|
||||
* @param name
|
||||
* field name
|
||||
* @return accessible field with defined name
|
||||
* @throws NoSuchFieldException
|
||||
* if field was not found
|
||||
*/
|
||||
private Field getField(Class<?> clazz, String name) throws NoSuchFieldException {
|
||||
for (Field f : clazz.getDeclaredFields()) {
|
||||
|
||||
+24
-13
@@ -20,8 +20,11 @@ public class DataWatcher {
|
||||
|
||||
/**
|
||||
* Sets value into data values
|
||||
* @param type - type of value
|
||||
* @param value - value
|
||||
*
|
||||
* @param type
|
||||
* type of value
|
||||
* @param value
|
||||
* value
|
||||
*/
|
||||
public void setValue(DataWatcherObject type, Object value){
|
||||
Preconditions.checkNotNull(type, "type");
|
||||
@@ -31,7 +34,9 @@ public class DataWatcher {
|
||||
|
||||
/**
|
||||
* Removes value by position
|
||||
* @param position - position of value to remove
|
||||
*
|
||||
* @param position
|
||||
* position of value to remove
|
||||
*/
|
||||
public void removeValue(int position) {
|
||||
dataValues.remove(position);
|
||||
@@ -39,8 +44,10 @@ public class DataWatcher {
|
||||
|
||||
/**
|
||||
* Returns item with given position
|
||||
* @param position - position of item
|
||||
* @return item or null if not set
|
||||
*
|
||||
* @param position
|
||||
* position of item
|
||||
* @return item or null if not set
|
||||
*/
|
||||
public DataWatcherItem getItem(int position) {
|
||||
return dataValues.get(position);
|
||||
@@ -48,7 +55,8 @@ public class DataWatcher {
|
||||
|
||||
/**
|
||||
* Returns helper created by this instance
|
||||
* @return data write helper
|
||||
*
|
||||
* @return data write helper
|
||||
*/
|
||||
public DataWatcherHelper helper() {
|
||||
return helper;
|
||||
@@ -56,9 +64,10 @@ public class DataWatcher {
|
||||
|
||||
/**
|
||||
* Converts the class into an instance of NMS.DataWatcher
|
||||
* @return an instance of NMS.DataWatcher with same data
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @return an instance of NMS.DataWatcher with same data
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public Object toNMS() throws ReflectiveOperationException {
|
||||
NMSStorage nms = NMSStorage.getInstance();
|
||||
@@ -83,10 +92,12 @@ public class DataWatcher {
|
||||
|
||||
/**
|
||||
* Reads NMS data watcher and returns and instance of this class with same data
|
||||
* @param nmsWatcher - NMS DataWatcher to read
|
||||
* @return an instance of this class with same values
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @param nmsWatcher
|
||||
* NMS DataWatcher to read
|
||||
* @return an instance of this class with same values
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static DataWatcher fromNMS(Object nmsWatcher) throws ReflectiveOperationException {
|
||||
|
||||
+22
-8
@@ -25,7 +25,9 @@ public class DataWatcherHelper {
|
||||
|
||||
/**
|
||||
* Constructs new instance of this class with given parent
|
||||
* @param data - data to write to
|
||||
*
|
||||
* @param data
|
||||
* data to write to
|
||||
*/
|
||||
public DataWatcherHelper(DataWatcher data) {
|
||||
Preconditions.checkNotNull(data, "dataWatcher");
|
||||
@@ -35,7 +37,8 @@ public class DataWatcherHelper {
|
||||
|
||||
/**
|
||||
* Returns armor stand flags position based on server version
|
||||
* @return armor stand flags position based on server version
|
||||
*
|
||||
* @return armor stand flags position based on server version
|
||||
*/
|
||||
private int getArmorStandFlagsPosition() {
|
||||
if (TAB.getInstance().getServerVersion().getMinorVersion() >= 17) {
|
||||
@@ -58,7 +61,9 @@ public class DataWatcherHelper {
|
||||
|
||||
/**
|
||||
* Writes entity byte flags
|
||||
* @param flags - flags to write
|
||||
*
|
||||
* @param flags
|
||||
* flags to write
|
||||
*/
|
||||
public void setEntityFlags(byte flags) {
|
||||
data.setValue(new DataWatcherObject(0, registry.getByte()), flags);
|
||||
@@ -66,8 +71,11 @@ public class DataWatcherHelper {
|
||||
|
||||
/**
|
||||
* Writes entity custom name with position based on server version and value depending on client version (RGB or not)
|
||||
* @param customName - target custom name
|
||||
* @param clientVersion - client version
|
||||
*
|
||||
* @param customName
|
||||
* target custom name
|
||||
* @param clientVersion
|
||||
* client version
|
||||
*/
|
||||
public void setCustomName(String customName, ProtocolVersion clientVersion) {
|
||||
Preconditions.checkNotNull(customName, "customName");
|
||||
@@ -94,7 +102,9 @@ public class DataWatcherHelper {
|
||||
|
||||
/**
|
||||
* Writes custom name visibility boolean
|
||||
* @param visible - if visible or not
|
||||
*
|
||||
* @param visible
|
||||
* if visible or not
|
||||
*/
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
if (TAB.getInstance().getServerVersion().getMinorVersion() >= 9) {
|
||||
@@ -106,7 +116,9 @@ public class DataWatcherHelper {
|
||||
|
||||
/**
|
||||
* Writes entity health
|
||||
* @param health - health of entity
|
||||
*
|
||||
* @param health
|
||||
* health of entity
|
||||
*/
|
||||
public void setHealth(float health) {
|
||||
if (TAB.getInstance().getServerVersion().getMinorVersion() >= 6) {
|
||||
@@ -118,7 +130,9 @@ public class DataWatcherHelper {
|
||||
|
||||
/**
|
||||
* Writes armor stand flags
|
||||
* @param flags - flags to write
|
||||
*
|
||||
* @param flags
|
||||
* flags to write
|
||||
*/
|
||||
public void setArmorStandFlags(byte flags) {
|
||||
data.setValue(new DataWatcherObject(armorStandFlagsPosition, registry.getByte()), flags);
|
||||
|
||||
+11
-6
@@ -14,8 +14,11 @@ public class DataWatcherItem {
|
||||
|
||||
/**
|
||||
* Constructs new instance of the object with given parameters
|
||||
* @param type - value type
|
||||
* @param value - value
|
||||
*
|
||||
* @param type
|
||||
* value type
|
||||
* @param value
|
||||
* value
|
||||
*/
|
||||
public DataWatcherItem(DataWatcherObject type, Object value){
|
||||
Preconditions.checkNotNull(type, "type");
|
||||
@@ -26,10 +29,12 @@ public class DataWatcherItem {
|
||||
|
||||
/**
|
||||
* Returns and instance of this class from given NMS item
|
||||
* @param nmsItem - NMS item
|
||||
* @return instance of this class with same data
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*
|
||||
* @param nmsItem
|
||||
* NMS item
|
||||
* @return instance of this class with same data
|
||||
* @throws ReflectiveOperationException
|
||||
* if thrown by reflective operation
|
||||
*/
|
||||
public static DataWatcherItem fromNMS(Object nmsItem) throws ReflectiveOperationException {
|
||||
NMSStorage nms = NMSStorage.getInstance();
|
||||
|
||||
+5
-2
@@ -13,8 +13,11 @@ public class DataWatcherObject {
|
||||
|
||||
/**
|
||||
* Constructs a new instance of this class with given parameters
|
||||
* @param position - position in DataWatcher
|
||||
* @param classType - value class type
|
||||
*
|
||||
* @param position
|
||||
* position in DataWatcher
|
||||
* @param classType
|
||||
* value class type
|
||||
*/
|
||||
public DataWatcherObject(int position, Object classType){
|
||||
this.position = position;
|
||||
|
||||
+4
-2
@@ -84,8 +84,10 @@ public class DataWatcherRegistry {
|
||||
|
||||
/**
|
||||
* Gets values of all static fields in a class
|
||||
* @param clazz class to return field values from
|
||||
* @return map of values
|
||||
*
|
||||
* @param clazz
|
||||
* class to return field values from
|
||||
* @return map of values
|
||||
*/
|
||||
private Map<String, Object> getStaticFields(Class<?> clazz, NMSStorage nms){
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
|
||||
@@ -17,8 +17,11 @@ public class Vault extends PermissionPlugin {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
* @param permission permission plugin implementation
|
||||
* @param vaultVersion vault version
|
||||
*
|
||||
* @param permission
|
||||
* permission plugin implementation
|
||||
* @param vaultVersion
|
||||
* vault version
|
||||
*/
|
||||
public Vault(Permission permission, String vaultVersion) {
|
||||
super(vaultVersion);
|
||||
|
||||
+12
-6
@@ -18,7 +18,9 @@ public class BungeeEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Disconnect event listener to forward the event to all features
|
||||
* @param e - disconnect event
|
||||
*
|
||||
* @param e
|
||||
* disconnect event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onQuit(PlayerDisconnectEvent e){
|
||||
@@ -29,8 +31,9 @@ public class BungeeEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Listener to join / server switch to forward the event to all features
|
||||
* @param e
|
||||
* switch event
|
||||
*
|
||||
* @param e
|
||||
* switch event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onSwitch(ServerSwitchEvent e){
|
||||
@@ -46,8 +49,9 @@ public class BungeeEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Listener to chat packets to forward the event to all features
|
||||
* @param e
|
||||
* chat event
|
||||
*
|
||||
* @param e
|
||||
* chat event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onChat(ChatEvent e) {
|
||||
@@ -57,7 +61,9 @@ public class BungeeEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Listener to plugin message event
|
||||
* @param event - plugin message event
|
||||
*
|
||||
* @param event
|
||||
* plugin message event
|
||||
*/
|
||||
@EventHandler
|
||||
public void on(PluginMessageEvent event){
|
||||
|
||||
+14
-7
@@ -52,7 +52,9 @@ public class BungeePipelineInjector extends PipelineInjector {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given player
|
||||
* @param player - player to inject
|
||||
*
|
||||
* @param player
|
||||
* player to inject
|
||||
*/
|
||||
public BungeeChannelDuplexHandler(TabPlayer player) {
|
||||
Preconditions.checkNotNull(player, "player");
|
||||
@@ -97,7 +99,9 @@ public class BungeePipelineInjector extends PipelineInjector {
|
||||
|
||||
/**
|
||||
* Removes all real players from packet if the packet doesn't come from TAB
|
||||
* @param packet - packet to modify
|
||||
*
|
||||
* @param packet
|
||||
* packet to modify
|
||||
*/
|
||||
private void modifyPlayers(Team packet){
|
||||
long time = System.nanoTime();
|
||||
@@ -113,9 +117,9 @@ public class BungeePipelineInjector extends PipelineInjector {
|
||||
RedisBungeeSupport redis = (RedisBungeeSupport) TAB.getInstance().getFeatureManager().getFeature(TabConstants.Feature.REDIS_BUNGEE);
|
||||
if (redis != null) {
|
||||
for (RedisPlayer p : redis.getRedisPlayers().values()) {
|
||||
if (col.contains(p.getName()) && !packet.getName().equals(p.getTeamName())) {
|
||||
if (col.contains(p.getNickName()) && !packet.getName().equals(p.getTeamName())) {
|
||||
logTeamOverride(packet.getName(), p.getName(), p.getTeamName());
|
||||
col.remove(p.getName());
|
||||
col.remove(p.getNickName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +133,8 @@ public class BungeePipelineInjector extends PipelineInjector {
|
||||
/**
|
||||
* Constructs new instance with given player
|
||||
*
|
||||
* @param player - player to inject
|
||||
* @param player
|
||||
* player to inject
|
||||
*/
|
||||
public DeserializableBungeeChannelDuplexHandler(TabPlayer player) {
|
||||
super(player);
|
||||
@@ -146,8 +151,10 @@ public class BungeePipelineInjector extends PipelineInjector {
|
||||
/**
|
||||
* Deserializes byte buf in case it is one of the tracked packets coming from backend server and returns it.
|
||||
* If the packet is not one of them, returns input
|
||||
* @param buf - byte buf to deserialize
|
||||
* @return deserialized packet or input byte buf if packet is not tracked
|
||||
*
|
||||
* @param buf
|
||||
* byte buf to deserialize
|
||||
* @return deserialized packet or input byte buf if packet is not tracked
|
||||
*/
|
||||
private Object deserialize(ByteBuf buf) {
|
||||
int marker = buf.readerIndex();
|
||||
|
||||
@@ -45,7 +45,9 @@ public class BungeeTabPlayer extends ProxyTabPlayer {
|
||||
|
||||
/**
|
||||
* Constructs new instance for given player
|
||||
* @param p - BungeeCord player
|
||||
*
|
||||
* @param p
|
||||
* BungeeCord player
|
||||
*/
|
||||
public BungeeTabPlayer(ProxiedPlayer p) {
|
||||
super(p, p.getUniqueId(), p.getName(), p.getServer() != null ? p.getServer().getInfo().getName() : "-", -1);
|
||||
@@ -91,8 +93,10 @@ public class BungeeTabPlayer extends ProxyTabPlayer {
|
||||
|
||||
/**
|
||||
* Returns packet ID for this player of provided packet class
|
||||
* @param clazz - packet class
|
||||
* @return - packet ID
|
||||
*
|
||||
* @param clazz
|
||||
* packet class
|
||||
* @return packet ID
|
||||
*/
|
||||
public int getPacketId(Class<? extends DefinedPacket> clazz) {
|
||||
Preconditions.checkNotNull(clazz, "class");
|
||||
|
||||
@@ -41,7 +41,8 @@ public class Main extends Plugin {
|
||||
|
||||
/**
|
||||
* Checks for compatibility and returns true if version is supported, false if not
|
||||
* @return true if version is compatible, false if not
|
||||
*
|
||||
* @return true if version is compatible, false if not
|
||||
*/
|
||||
private boolean isVersionSupported() {
|
||||
try {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
||||
projectVersion=3.1.0
|
||||
projectVersion=3.1.1
|
||||
|
||||
# Gradle properties
|
||||
org.gradle.daemon=true
|
||||
|
||||
@@ -3,18 +3,18 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
# API
|
||||
netty = "4.1.72.Final"
|
||||
netty = "4.1.75.Final"
|
||||
jsonSimple = "1.1.1"
|
||||
snakeyaml = "1.30"
|
||||
yamlAssist = "1.0.5"
|
||||
gson = "2.8.9"
|
||||
gson = "2.9.0"
|
||||
slf4j = "1.7.36"
|
||||
|
||||
# General
|
||||
luckperms = "5.2"
|
||||
guava = "30.1.1-jre"
|
||||
luckperms = "5.4"
|
||||
guava = "31.1-jre"
|
||||
floodgate = "2.0-SNAPSHOT"
|
||||
kotlin = "1.6.0"
|
||||
kotlin = "1.6.10"
|
||||
event = "3.0.0"
|
||||
|
||||
# Platforms
|
||||
|
||||
@@ -2,10 +2,7 @@ package me.neznamy.tab.shared;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@@ -51,7 +48,8 @@ public class CpuManager implements ThreadManager {
|
||||
private ExecutorService thread = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("TAB Processing Thread").build());
|
||||
|
||||
/** Thread pool for delayed and repeating tasks to perform sleep before submitting task to main thread */
|
||||
private final ExecutorService threadPool = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("TAB Repeating / Delayed Thread %d").build());
|
||||
private final ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newCachedThreadPool(
|
||||
new ThreadFactoryBuilder().setNameFormat("TAB Repeating / Delayed Thread %d").build());
|
||||
|
||||
/** Tasks submitted to main thread before plugin was fully enabled */
|
||||
private final List<Runnable> taskQueue = new ArrayList<>();
|
||||
@@ -100,9 +98,9 @@ public class CpuManager implements ThreadManager {
|
||||
* Submits task to TAB's main thread. If plugin is not enabled yet,
|
||||
* queues the task instead and executes once it's loaded.
|
||||
*
|
||||
* @param task
|
||||
* task to execute
|
||||
* @return future returned by executor service
|
||||
* @param task
|
||||
* task to execute
|
||||
* @return future returned by executor service
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Future<Void> submit(Runnable task) {
|
||||
@@ -113,7 +111,7 @@ public class CpuManager implements ThreadManager {
|
||||
return (Future<Void>) thread.submit(() -> {
|
||||
try {
|
||||
task.run();
|
||||
} catch (Exception | LinkageError e) {
|
||||
} catch (Exception | LinkageError | StackOverflowError e) {
|
||||
TAB.getInstance().getErrorManager().printError("An error was thrown when executing task", e);
|
||||
}
|
||||
});
|
||||
@@ -122,7 +120,7 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Returns cpu usage map of placeholders from previous time period
|
||||
*
|
||||
* @return cpu usage map of placeholders
|
||||
* @return cpu usage map of placeholders
|
||||
*/
|
||||
public Map<String, Float> getPlaceholderUsage(){
|
||||
return getUsage(placeholderUsagePrevious);
|
||||
@@ -131,7 +129,7 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Returns cpu usage map of methods previous time period
|
||||
*
|
||||
* @return cpu usage map of methods
|
||||
* @return cpu usage map of methods
|
||||
*/
|
||||
public Map<String, Float> getMethodUsage(){
|
||||
return getUsage(methodUsagePrevious);
|
||||
@@ -140,7 +138,7 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Returns map of sent packets per feature in previous time period
|
||||
*
|
||||
* @return map of sent packets per feature
|
||||
* @return map of sent packets per feature
|
||||
*/
|
||||
public Map<String, AtomicInteger> getSentPackets(){
|
||||
return sortByValue1(packetsPrevious);
|
||||
@@ -149,9 +147,9 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Converts nano map to percent and sorts it from highest to lowest usage.
|
||||
*
|
||||
* @param map
|
||||
* map to convert
|
||||
* @return converted and sorted map
|
||||
* @param map
|
||||
* map to convert
|
||||
* @return converted and sorted map
|
||||
*/
|
||||
private Map<String, Float> getUsage(Map<String, AtomicLong> map){
|
||||
Map<String, Long> nanoMap = new HashMap<>();
|
||||
@@ -171,7 +169,7 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Returns map of CPU usage per feature and type in the previous time period
|
||||
*
|
||||
* @return map of CPU usage per feature and type
|
||||
* @return map of CPU usage per feature and type
|
||||
*/
|
||||
public Map<String, Map<String, Float>> getFeatureUsage(){
|
||||
Map<String, Map<String, Long>> total = new HashMap<>();
|
||||
@@ -199,9 +197,9 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Converts nanoseconds to percent usage.
|
||||
*
|
||||
* @param nanos
|
||||
* nanoseconds of cpu time
|
||||
* @return usage in % (0-100)
|
||||
* @param nanos
|
||||
* nanoseconds of cpu time
|
||||
* @return usage in % (0-100)
|
||||
*/
|
||||
private float nanosToPercent(long nanos) {
|
||||
float percent = (float) nanos / BUFFER_SIZE_MILLIS / 1000000; //relative usage (0-1)
|
||||
@@ -212,13 +210,13 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Sorts map by value from highest to lowest
|
||||
*
|
||||
* @param <K>
|
||||
* map key type
|
||||
* @param <V>
|
||||
* map value type
|
||||
* @param map
|
||||
* map to sort
|
||||
* @return sorted map
|
||||
* @param <K>
|
||||
* map key type
|
||||
* @param <V>
|
||||
* map value type
|
||||
* @param map
|
||||
* map to sort
|
||||
* @return sorted map
|
||||
*/
|
||||
private <K, V extends Comparable<V>> Map<K, V> sortByValue(Map<K, V> map) {
|
||||
Comparator<K> valueComparator = (k1, k2) -> {
|
||||
@@ -233,11 +231,11 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Sorts map by value from highest to lowest
|
||||
*
|
||||
* @param <K>
|
||||
* map key type
|
||||
* @param map
|
||||
* map to sort
|
||||
* @return sorted map
|
||||
* @param <K>
|
||||
* map key type
|
||||
* @param map
|
||||
* map to sort
|
||||
* @return sorted map
|
||||
*/
|
||||
private <K> Map<K, AtomicInteger> sortByValue1(Map<K, AtomicInteger> map) {
|
||||
Comparator<K> valueComparator = (k1, k2) -> {
|
||||
@@ -251,11 +249,11 @@ public class CpuManager implements ThreadManager {
|
||||
|
||||
/**
|
||||
* Sorts keys by map nested values from highest to lowest and returns sorted list of keys
|
||||
* @param <K>
|
||||
* map key type
|
||||
* @param map
|
||||
* map to sort
|
||||
* @return list of keys sorted from the highest map value to lowest
|
||||
* @param <K>
|
||||
* map key type
|
||||
* @param map
|
||||
* map to sort
|
||||
* @return list of keys sorted from the highest map value to lowest
|
||||
*/
|
||||
private <K> List<K> sortKeys(Map<K, Map<String, Long>> map){
|
||||
Map<K, Long> simplified = new LinkedHashMap<>();
|
||||
@@ -268,12 +266,12 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Adds cpu time to specified feature and usage type
|
||||
*
|
||||
* @param feature
|
||||
* feature to add time to
|
||||
* @param type
|
||||
* sub-feature to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
* @param feature
|
||||
* feature to add time to
|
||||
* @param type
|
||||
* sub-feature to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
*/
|
||||
public void addTime(TabFeature feature, String type, long nanoseconds) {
|
||||
addTime(feature.getFeatureName(), type, nanoseconds);
|
||||
@@ -282,12 +280,12 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Adds cpu time to specified feature and usage type
|
||||
*
|
||||
* @param feature
|
||||
* feature to add time to
|
||||
* @param type
|
||||
* sub-feature to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
* @param feature
|
||||
* feature to add time to
|
||||
* @param type
|
||||
* sub-feature to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
*/
|
||||
public void addTime(String feature, String type, long nanoseconds) {
|
||||
featureUsageCurrent.computeIfAbsent(feature, f -> new ConcurrentHashMap<>()).computeIfAbsent(type, t -> new AtomicLong()).addAndGet(nanoseconds);
|
||||
@@ -296,12 +294,12 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Adds used time to specified key into specified map
|
||||
*
|
||||
* @param map
|
||||
* map to add usage to
|
||||
* @param key
|
||||
* usage key
|
||||
* @param time
|
||||
* nanoseconds to add
|
||||
* @param map
|
||||
* map to add usage to
|
||||
* @param key
|
||||
* usage key
|
||||
* @param time
|
||||
* nanoseconds to add
|
||||
*/
|
||||
private void addTime(Map<String, AtomicLong> map, String key, long time) {
|
||||
map.computeIfAbsent(key, k -> new AtomicLong()).addAndGet(time);
|
||||
@@ -310,10 +308,10 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Adds placeholder time to specified placeholder
|
||||
*
|
||||
* @param placeholder
|
||||
* placeholder to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
* @param placeholder
|
||||
* placeholder to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
*/
|
||||
public void addPlaceholderTime(String placeholder, long nanoseconds) {
|
||||
addTime(placeholderUsageCurrent, placeholder, nanoseconds);
|
||||
@@ -322,10 +320,10 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Adds method time to specified method
|
||||
*
|
||||
* @param method
|
||||
* method to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
* @param method
|
||||
* method to add time to
|
||||
* @param nanoseconds
|
||||
* time to add
|
||||
*/
|
||||
public void addMethodTime(String method, long nanoseconds) {
|
||||
addTime(methodUsageCurrent, method, nanoseconds);
|
||||
@@ -334,8 +332,8 @@ public class CpuManager implements ThreadManager {
|
||||
/**
|
||||
* Increments packets sent by 1 of specified feature
|
||||
*
|
||||
* @param feature
|
||||
* feature to increment packet counter of
|
||||
* @param feature
|
||||
* feature to increment packet counter of
|
||||
*/
|
||||
public void packetSent(String feature) {
|
||||
packetsCurrent.computeIfAbsent(feature, f -> new AtomicInteger()).incrementAndGet();
|
||||
@@ -372,25 +370,37 @@ public class CpuManager implements ThreadManager {
|
||||
|
||||
@Override
|
||||
public Future<?> runTaskLater(int delayMilliseconds, TabFeature feature, String type, Runnable task) {
|
||||
return threadPool.submit(() -> {
|
||||
try {
|
||||
Thread.sleep(delayMilliseconds);
|
||||
runMeasuredTask(feature, type, task);
|
||||
} catch (InterruptedException pluginDisabled) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
try {
|
||||
return threadPool.submit(() -> {
|
||||
try {
|
||||
Thread.sleep(delayMilliseconds);
|
||||
runMeasuredTask(feature, type, task);
|
||||
} catch (InterruptedException pluginDisabled) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
} catch (OutOfMemoryError e) {
|
||||
TAB.getInstance().getErrorManager().criticalError("Failed to create new delayed task, active thread count: " +
|
||||
threadPool.getActiveCount() + " / " + threadPool.getPoolSize(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<?> runTaskLater(int delayMilliseconds, Runnable task) {
|
||||
return threadPool.submit(() -> {
|
||||
try {
|
||||
Thread.sleep(delayMilliseconds);
|
||||
submit(task);
|
||||
} catch (InterruptedException pluginDisabled) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
try {
|
||||
return threadPool.submit(() -> {
|
||||
try {
|
||||
Thread.sleep(delayMilliseconds);
|
||||
submit(task);
|
||||
} catch (InterruptedException pluginDisabled) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
} catch (OutOfMemoryError e) {
|
||||
TAB.getInstance().getErrorManager().criticalError("Failed to create new delayed task, active thread count: " +
|
||||
threadPool.getActiveCount() + " / " + threadPool.getPoolSize(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,14 +64,14 @@ public class DynamicText implements Property {
|
||||
* Constructs new instance with given parameters and prepares
|
||||
* the formatter for use by detecting placeholders and reformatting the text.
|
||||
*
|
||||
* @param listener
|
||||
* Feature which should receive refresh method if placeholder changes value
|
||||
* @param owner
|
||||
* Player this text belongs to
|
||||
* @param rawValue
|
||||
* Raw value using raw placeholder identifiers
|
||||
* @param source
|
||||
* Source of the text used in debug command
|
||||
* @param listener
|
||||
* Feature which should receive refresh method if placeholder changes value
|
||||
* @param owner
|
||||
* Player this text belongs to
|
||||
* @param rawValue
|
||||
* Raw value using raw placeholder identifiers
|
||||
* @param source
|
||||
* Source of the text used in debug command
|
||||
*/
|
||||
public DynamicText(String name, TabFeature listener, TabPlayer owner, String rawValue, String source) {
|
||||
this.name = name;
|
||||
@@ -86,8 +86,8 @@ public class DynamicText implements Property {
|
||||
* Finds all placeholders used in the value and prepares it for
|
||||
* String formatter using %s for each placeholder.
|
||||
*
|
||||
* @param value
|
||||
* raw value to analyze
|
||||
* @param value
|
||||
* raw value to analyze
|
||||
*/
|
||||
private void analyze(String value) {
|
||||
List<String> placeholders0 = new ArrayList<>();
|
||||
@@ -130,10 +130,10 @@ public class DynamicText implements Property {
|
||||
* Changes raw value to new provided value and performs all
|
||||
* operations related to it. Changes source as well.
|
||||
*
|
||||
* @param newValue
|
||||
* new raw value to use
|
||||
* @param newSource
|
||||
* new source of the text
|
||||
* @param newValue
|
||||
* new raw value to use
|
||||
* @param newSource
|
||||
* new source of the text
|
||||
*/
|
||||
public void changeRawValue(String newValue, String newSource) {
|
||||
if (rawValue.equals(newValue)) return;
|
||||
@@ -147,7 +147,7 @@ public class DynamicText implements Property {
|
||||
/**
|
||||
* Returns source of the raw value or {@code "API"} if it comes from an API call
|
||||
*
|
||||
* @return source of the value
|
||||
* @return source of the value
|
||||
*/
|
||||
public String getSource() {
|
||||
return temporaryValue == null ? source : "API";
|
||||
|
||||
@@ -33,8 +33,8 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message into errors.log file
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param message
|
||||
* message to print
|
||||
*/
|
||||
public void printError(String message) {
|
||||
printError(message, null, false);
|
||||
@@ -43,10 +43,10 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message and stack trace into errors.log file
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
*/
|
||||
public void printError(String message, Throwable t) {
|
||||
printError(message, t, false);
|
||||
@@ -55,12 +55,12 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message and stack trace into errors.log file
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
* @param intoConsoleToo
|
||||
* if the message should be printed into console as well or not
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
* @param intoConsoleToo
|
||||
* if the message should be printed into console as well or not
|
||||
*/
|
||||
public void printError(String message, Throwable t, boolean intoConsoleToo) {
|
||||
printError(message, t, intoConsoleToo, errorLog);
|
||||
@@ -69,14 +69,14 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message and stack trace into specified file
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
* @param intoConsoleToo
|
||||
* if the message should be printed into console as well or not
|
||||
* @param file
|
||||
* file to print error to
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
* @param intoConsoleToo
|
||||
* if the message should be printed into console as well or not
|
||||
* @param file
|
||||
* file to print error to
|
||||
*/
|
||||
public void printError(String message, Throwable t, boolean intoConsoleToo, File file) {
|
||||
Throwable error = t;
|
||||
@@ -96,16 +96,16 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message and stack trace into specified file
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param error
|
||||
* thrown error
|
||||
* @param intoConsoleToo
|
||||
* if the message should be printed into console as well or not
|
||||
* @param file
|
||||
* file to print error to
|
||||
* @param message
|
||||
* message to print
|
||||
* @param error
|
||||
* thrown error
|
||||
* @param intoConsoleToo
|
||||
* if the message should be printed into console as well or not
|
||||
* @param file
|
||||
* file to print error to
|
||||
*/
|
||||
private void printError(String message, List<String> error, boolean intoConsoleToo, File file) {
|
||||
private synchronized void printError(String message, List<String> error, boolean intoConsoleToo, File file) {
|
||||
try {
|
||||
if (!file.exists()) Files.createFile(file.toPath());
|
||||
if (file.length() > 1000000) return; //not going over 1 MB
|
||||
@@ -133,10 +133,10 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message thrown by placeholder and stack trace into placeholder-errors.log file
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
*/
|
||||
public void placeholderError(String message, Throwable t) {
|
||||
printError(message, t, false, placeholderErrorLog);
|
||||
@@ -145,10 +145,10 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message thrown by placeholder and stack trace into placeholder-errors.log file
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown stack trace elements
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown stack trace elements
|
||||
*/
|
||||
public void placeholderError(String message, List<String> t) {
|
||||
printError(message, t, false, placeholderErrorLog);
|
||||
@@ -157,14 +157,14 @@ public class ErrorManager {
|
||||
/**
|
||||
* Writes message into buffer and console if set
|
||||
*
|
||||
* @param buf
|
||||
* writer to write message to
|
||||
* @param message
|
||||
* message to write
|
||||
* @param forceConsole
|
||||
* whether to send into console even without debug mode
|
||||
* @throws IOException
|
||||
* if I/O writer operation fails
|
||||
* @param buf
|
||||
* writer to write message to
|
||||
* @param message
|
||||
* message to write
|
||||
* @param forceConsole
|
||||
* whether to send into console even without debug mode
|
||||
* @throws IOException
|
||||
* if I/O writer operation fails
|
||||
*/
|
||||
private void write(BufferedWriter buf, String prefix, String message, boolean forceConsole) throws IOException {
|
||||
buf.write(dateFormat.format(new Date()) + IChatBaseComponent.fromColoredText(prefix).toRawText() + message + System.getProperty("line.separator"));
|
||||
@@ -174,10 +174,10 @@ public class ErrorManager {
|
||||
/**
|
||||
* Prints error message and stack trace into errors.log file as well as the console
|
||||
*
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
* @param message
|
||||
* message to print
|
||||
* @param t
|
||||
* thrown error
|
||||
*/
|
||||
public void criticalError(String message, Throwable t) {
|
||||
printError(message, t, true);
|
||||
@@ -187,11 +187,11 @@ public class ErrorManager {
|
||||
* Parses integer in given string and returns it.
|
||||
* Returns second argument if string is not valid.
|
||||
*
|
||||
* @param string
|
||||
* string to parse
|
||||
* @param defaultValue
|
||||
* value to return if string is not valid
|
||||
* @return parsed integer or {@code defaultValue} if input is invalid
|
||||
* @param string
|
||||
* string to parse
|
||||
* @param defaultValue
|
||||
* value to return if string is not valid
|
||||
* @return parsed integer or {@code defaultValue} if input is invalid
|
||||
*/
|
||||
public int parseInteger(String string, int defaultValue) {
|
||||
try {
|
||||
@@ -205,11 +205,11 @@ public class ErrorManager {
|
||||
* Parses float in given string and returns it.
|
||||
* Returns second argument if string is not valid.
|
||||
*
|
||||
* @param string
|
||||
* string to parse
|
||||
* @param defaultValue
|
||||
* value to return if string is not valid
|
||||
* @return parsed float or {@code defaultValue} if input is invalid
|
||||
* @param string
|
||||
* string to parse
|
||||
* @param defaultValue
|
||||
* value to return if string is not valid
|
||||
* @return parsed float or {@code defaultValue} if input is invalid
|
||||
*/
|
||||
public float parseFloat(String string, float defaultValue) {
|
||||
try {
|
||||
@@ -223,11 +223,11 @@ public class ErrorManager {
|
||||
* Parses double in given string and returns it.
|
||||
* Returns second argument if string is not valid.
|
||||
*
|
||||
* @param string
|
||||
* string to parse
|
||||
* @param defaultValue
|
||||
* value to return if string is not valid
|
||||
* @return parsed float or {@code defaultValue} if input is invalid
|
||||
* @param string
|
||||
* string to parse
|
||||
* @param defaultValue
|
||||
* value to return if string is not valid
|
||||
* @return parsed float or {@code defaultValue} if input is invalid
|
||||
*/
|
||||
public double parseDouble(String string, double defaultValue) {
|
||||
try {
|
||||
@@ -240,11 +240,11 @@ public class ErrorManager {
|
||||
/**
|
||||
* Makes interval divisible by 50 and sends error message if it was not already or was 0 or less
|
||||
*
|
||||
* @param name
|
||||
* name of animation used in error message
|
||||
* @param interval
|
||||
* configured change interval
|
||||
* @return fixed change interval
|
||||
* @param name
|
||||
* name of animation used in error message
|
||||
* @param interval
|
||||
* configured change interval
|
||||
* @return fixed change interval
|
||||
*/
|
||||
public int fixAnimationInterval(String name, int interval) {
|
||||
if (interval == 0) {
|
||||
@@ -267,11 +267,11 @@ public class ErrorManager {
|
||||
/**
|
||||
* Returns the list if not null, empty list and error message if null
|
||||
*
|
||||
* @param name
|
||||
* name of animation used in error message
|
||||
* @param list
|
||||
* list of configured animation frames
|
||||
* @return the list if it's valid, singleton list with {@code "<Invalid Animation>"} otherwise
|
||||
* @param name
|
||||
* name of animation used in error message
|
||||
* @param list
|
||||
* list of configured animation frames
|
||||
* @return the list if it's valid, singleton list with {@code "<Invalid Animation>"} otherwise
|
||||
*/
|
||||
public List<String> fixAnimationFrames(String name, List<String> list) {
|
||||
if (list == null) {
|
||||
@@ -284,8 +284,8 @@ public class ErrorManager {
|
||||
/**
|
||||
* Sends a startup warn message into console
|
||||
*
|
||||
* @param message
|
||||
* message to print into console
|
||||
* @param message
|
||||
* message to print into console
|
||||
*/
|
||||
public void startupWarn(String message) {
|
||||
TAB.getInstance().sendConsoleMessage("&c" + message, true);
|
||||
@@ -294,12 +294,12 @@ public class ErrorManager {
|
||||
/**
|
||||
* Sends a startup warn about missing object parameter
|
||||
*
|
||||
* @param objectType
|
||||
* object type missing parameter
|
||||
* @param objectName
|
||||
* name of object
|
||||
* @param attribute
|
||||
* missing parameter
|
||||
* @param objectType
|
||||
* object type missing parameter
|
||||
* @param objectName
|
||||
* name of object
|
||||
* @param attribute
|
||||
* missing parameter
|
||||
*/
|
||||
public void missingAttribute(String objectType, Object objectName, String attribute) {
|
||||
startupWarn(objectType + " \"&e" + objectName + "&c\" is missing \"&e" + attribute + "&c\" attribute!");
|
||||
@@ -307,7 +307,8 @@ public class ErrorManager {
|
||||
|
||||
/**
|
||||
* Returns anti-override.log file
|
||||
* @return anti-override.log file
|
||||
*
|
||||
* @return anti-override.log file
|
||||
*/
|
||||
public File getAntiOverrideLog() {
|
||||
return antiOverrideLog;
|
||||
|
||||
@@ -57,10 +57,10 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls refresh(TabPlayer, boolean) on all features
|
||||
*
|
||||
* @param refreshed
|
||||
* player to refresh
|
||||
* @param force
|
||||
* whether refresh should be forced or not
|
||||
* @param refreshed
|
||||
* player to refresh
|
||||
* @param force
|
||||
* whether refresh should be forced or not
|
||||
*/
|
||||
public void refresh(TabPlayer refreshed, boolean force) {
|
||||
for (TabFeature f : values) f.refresh(refreshed, force);
|
||||
@@ -69,13 +69,13 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onPlayerInfo(TabPlayer, Object) on all features
|
||||
*
|
||||
* @param receiver
|
||||
* packet receiver
|
||||
* @param packet
|
||||
* an instance of custom packet class PacketPlayOutPlayerInfo
|
||||
* @return altered rebuilt packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflective operation fails
|
||||
* @param receiver
|
||||
* packet receiver
|
||||
* @param packet
|
||||
* an instance of custom packet class PacketPlayOutPlayerInfo
|
||||
* @return altered rebuilt packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflective operation fails
|
||||
*/
|
||||
public Object onPacketPlayOutPlayerInfo(TabPlayer receiver, Object packet) throws ReflectiveOperationException {
|
||||
if (receiver.getVersion().getMinorVersion() < 8) return packet;
|
||||
@@ -97,8 +97,8 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onQuit(TabPlayer) on all features
|
||||
*
|
||||
* @param disconnectedPlayer
|
||||
* player who disconnected
|
||||
* @param disconnectedPlayer
|
||||
* player who disconnected
|
||||
*/
|
||||
public void onQuit(TabPlayer disconnectedPlayer) {
|
||||
if (disconnectedPlayer == null) return;
|
||||
@@ -116,8 +116,8 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onJoin(TabPlayer) on all features
|
||||
*
|
||||
* @param connectedPlayer
|
||||
* player who connected
|
||||
* @param connectedPlayer
|
||||
* player who connected
|
||||
*/
|
||||
public void onJoin(TabPlayer connectedPlayer) {
|
||||
if (!connectedPlayer.isOnline()) return;
|
||||
@@ -141,10 +141,10 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onWorldChange(TabPlayer, String, String) on all features
|
||||
*
|
||||
* @param playerUUID
|
||||
* player who switched world
|
||||
* @param to
|
||||
* name of the new world
|
||||
* @param playerUUID
|
||||
* player who switched world
|
||||
* @param to
|
||||
* name of the new world
|
||||
*/
|
||||
public void onWorldChange(UUID playerUUID, String to) {
|
||||
TabPlayer changed = TAB.getInstance().getPlayer(playerUUID);
|
||||
@@ -163,18 +163,18 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onServerChange(TabPlayer, String, String) on all features
|
||||
*
|
||||
* @param playerUUID
|
||||
* player who switched server
|
||||
* @param to
|
||||
* name of the new server
|
||||
* @param playerUUID
|
||||
* player who switched server
|
||||
* @param to
|
||||
* name of the new server
|
||||
*/
|
||||
public void onServerChange(UUID playerUUID, String to) {
|
||||
TabPlayer changed = TAB.getInstance().getPlayer(playerUUID);
|
||||
if (changed == null) return;
|
||||
String from = changed.getServer();
|
||||
((ITabPlayer)changed).setServer(to);
|
||||
if (!isFeatureEnabled(TabConstants.Feature.PIPELINE_INJECTION)) ((ITabPlayer)changed).clearRegisteredObjectives();
|
||||
((ProxyTabPlayer)changed).sendJoinPluginMessage();
|
||||
if (!isFeatureEnabled(TabConstants.Feature.PIPELINE_INJECTION)) onLoginPacket(changed);
|
||||
for (TabFeature f : values) {
|
||||
if (!f.overridesMethod("onServerChange")) continue;
|
||||
long time = System.nanoTime();
|
||||
@@ -187,11 +187,11 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onCommand(TabPlayer, String) on all features
|
||||
*
|
||||
* @param sender
|
||||
* command sender
|
||||
* @param command
|
||||
* command line including /
|
||||
* @return {@code true} if command should be cancelled, {@code false} if not
|
||||
* @param sender
|
||||
* command sender
|
||||
* @param command
|
||||
* command line including /
|
||||
* @return {@code true} if command should be cancelled, {@code false} if not
|
||||
*/
|
||||
public boolean onCommand(TabPlayer sender, String command) {
|
||||
if (sender == null) return false;
|
||||
@@ -208,11 +208,11 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onPacketReceive(TabPlayer, Object) on all features
|
||||
*
|
||||
* @param sender
|
||||
* packet sender
|
||||
* @param packet
|
||||
* IN packet coming from player
|
||||
* @return {@code true} if packet should be cancelled, {@code false} if not
|
||||
* @param sender
|
||||
* packet sender
|
||||
* @param packet
|
||||
* IN packet coming from player
|
||||
* @return {@code true} if packet should be cancelled, {@code false} if not
|
||||
*/
|
||||
public boolean onPacketReceive(TabPlayer sender, Object packet){
|
||||
boolean cancel = false;
|
||||
@@ -232,10 +232,10 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onPacketSend(TabPlayer, Object) on all features
|
||||
*
|
||||
* @param receiver
|
||||
* packet receiver
|
||||
* @param packet
|
||||
* OUT packet coming from the server
|
||||
* @param receiver
|
||||
* packet receiver
|
||||
* @param packet
|
||||
* OUT packet coming from the server
|
||||
*/
|
||||
public void onPacketSend(TabPlayer receiver, Object packet){
|
||||
for (TabFeature f : values) {
|
||||
@@ -253,8 +253,8 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onLoginPacket(TabPlayer) on all features
|
||||
*
|
||||
* @param packetReceiver
|
||||
* player who received the packet
|
||||
* @param packetReceiver
|
||||
* player who received the packet
|
||||
*/
|
||||
public void onLoginPacket(TabPlayer packetReceiver) {
|
||||
((ITabPlayer)packetReceiver).clearRegisteredObjectives();
|
||||
@@ -269,12 +269,12 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onDisplayObjective(TabPlayer, PacketPlayOutScoreboardDisplayObjective) on all features
|
||||
*
|
||||
* @param packetReceiver
|
||||
* player who received the packet
|
||||
* @param packet
|
||||
* the packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflective operation fails
|
||||
* @param packetReceiver
|
||||
* player who received the packet
|
||||
* @param packet
|
||||
* the packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflective operation fails
|
||||
*/
|
||||
public void onDisplayObjective(TabPlayer packetReceiver, Object packet) throws ReflectiveOperationException {
|
||||
long time = System.nanoTime();
|
||||
@@ -291,10 +291,10 @@ public class FeatureManagerImpl implements FeatureManager {
|
||||
/**
|
||||
* Calls onObjective(TabPlayer, PacketPlayOutScoreboardObjective) on all features
|
||||
*
|
||||
* @param packetReceiver
|
||||
* player who received the packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflective operation fails
|
||||
* @param packetReceiver
|
||||
* player who received the packet
|
||||
* @throws ReflectiveOperationException
|
||||
* if reflective operation fails
|
||||
*/
|
||||
public void onObjective(TabPlayer packetReceiver, Object packet) throws ReflectiveOperationException {
|
||||
long time = System.nanoTime();
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
package me.neznamy.tab.shared;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import me.neznamy.tab.api.TabFeature;
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
import me.neznamy.tab.api.placeholder.PlayerPlaceholder;
|
||||
import me.neznamy.tab.shared.permission.LuckPerms;
|
||||
import me.neznamy.tab.shared.permission.None;
|
||||
import me.neznamy.tab.shared.permission.PermissionPlugin;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.event.EventSubscription;
|
||||
import net.luckperms.api.event.group.GroupDataRecalculateEvent;
|
||||
import net.luckperms.api.event.user.UserDataRecalculateEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Permission group manager retrieving groups from permission plugin
|
||||
@@ -29,60 +21,19 @@ public class GroupManager extends TabFeature {
|
||||
/** List of group permissions to iterate through if {@link #groupsByPermissions} is {@code true} */
|
||||
private final List<String> primaryGroupFindingList = TAB.getInstance().getConfiguration().getConfig().getStringList("primary-group-finding-list", Arrays.asList("Owner", "Admin", "Helper", "default"));
|
||||
|
||||
/** UserDataRecalculateEvent LuckPerms event listener */
|
||||
private EventSubscription<UserDataRecalculateEvent> luckPermsSub;
|
||||
|
||||
/** GroupDataRecalculateEvent LuckPerms event listener */
|
||||
private EventSubscription<GroupDataRecalculateEvent> luckPermsSub2;
|
||||
|
||||
/**
|
||||
* Constructs new instance with given permission plugin, loads
|
||||
* event listeners and registers group placeholder.
|
||||
*
|
||||
* @param plugin
|
||||
* Detected permission plugin
|
||||
* @param plugin
|
||||
* Detected permission plugin
|
||||
*/
|
||||
public GroupManager(PermissionPlugin plugin) {
|
||||
super("Permission group refreshing", "Refreshing group");
|
||||
super("Permission group refreshing", null);
|
||||
this.plugin = plugin;
|
||||
if (plugin instanceof LuckPerms) {
|
||||
TAB.getInstance().getPlaceholderManager().registerPlayerPlaceholder("%group%", -1, TabPlayer::getGroup).enableTriggerMode();
|
||||
luckPermsSub = LuckPermsProvider.get().getEventBus().subscribe(UserDataRecalculateEvent.class, this::updatePlayer);
|
||||
luckPermsSub2 = LuckPermsProvider.get().getEventBus().subscribe(GroupDataRecalculateEvent.class, this::updateGroup);
|
||||
} else if (plugin instanceof None && !groupsByPermissions){
|
||||
TAB.getInstance().getPlaceholderManager().registerPlayerPlaceholder("%group%", -1, p -> TabConstants.DEFAULT_GROUP);
|
||||
} else {
|
||||
TAB.getInstance().getPlaceholderManager().registerPlayerPlaceholder("%group%", 1000, this::detectPermissionGroup);
|
||||
addUsedPlaceholders(Collections.singletonList("%group%"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes UserDataRecalculateEvent
|
||||
*
|
||||
* @param event
|
||||
* Event to process
|
||||
*/
|
||||
private void updatePlayer(UserDataRecalculateEvent event) {
|
||||
TAB.getInstance().getCPUManager().runTaskLater(50, this, TabConstants.CpuUsageCategory.LUCKPERMS_USER_RECALCULATE_EVENT, () -> {
|
||||
TabPlayer p = TAB.getInstance().getPlayer(event.getUser().getUniqueId());
|
||||
if (p == null) return; // player not loaded yet
|
||||
refresh(p, false);
|
||||
((PlayerPlaceholder)TAB.getInstance().getPlaceholderManager().getPlaceholder("%group%")).updateValue(p, p.getGroup());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes GroupDataRecalculateEvent
|
||||
*
|
||||
* @param event
|
||||
* Event to process
|
||||
*/
|
||||
private void updateGroup(GroupDataRecalculateEvent event) {
|
||||
TAB.getInstance().getCPUManager().runTaskLater(50, this, TabConstants.CpuUsageCategory.LUCKPERMS_GROUP_RECALCULATE_EVENT, () -> {
|
||||
for (TabPlayer player : TAB.getInstance().getOnlinePlayers()) {
|
||||
refresh(player, false);
|
||||
((PlayerPlaceholder)TAB.getInstance().getPlaceholderManager().getPlaceholder("%group%")).updateValue(player, player.getGroup());
|
||||
TAB.getInstance().getCPUManager().startRepeatingMeasuredTask(1000, this, TabConstants.CpuUsageCategory.GROUP_REFRESHING, () -> {
|
||||
for (TabPlayer all : TAB.getInstance().getOnlinePlayers()) {
|
||||
((ITabPlayer)all).setGroup(detectPermissionGroup(all));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -90,9 +41,9 @@ public class GroupManager extends TabFeature {
|
||||
/**
|
||||
* Detects player's permission group using configured method and returns it
|
||||
*
|
||||
* @param player
|
||||
* Player to detect permission group of
|
||||
* @return Detected permission group
|
||||
* @param player
|
||||
* Player to detect permission group of
|
||||
* @return Detected permission group
|
||||
*/
|
||||
public String detectPermissionGroup(TabPlayer player) {
|
||||
return groupsByPermissions ? getByPermission(player) : getByPrimary(player);
|
||||
@@ -101,9 +52,9 @@ public class GroupManager extends TabFeature {
|
||||
/**
|
||||
* Returns player's permission group from detected permission plugin
|
||||
*
|
||||
* @param player
|
||||
* Player to get permission group of
|
||||
* @return Permission group from permission plugin
|
||||
* @param player
|
||||
* Player to get permission group of
|
||||
* @return Permission group from permission plugin
|
||||
*/
|
||||
private String getByPrimary(TabPlayer player) {
|
||||
try {
|
||||
@@ -118,15 +69,15 @@ public class GroupManager extends TabFeature {
|
||||
* Returns player's permission group based on highest permission
|
||||
* or {@link TabConstants#DEFAULT_GROUP} if player has no permission.
|
||||
*
|
||||
* @param player
|
||||
* Player to get permission group of
|
||||
* @return Highest permission group player has permission for
|
||||
* or {@link TabConstants#DEFAULT_GROUP} if player does not have any
|
||||
* @param player
|
||||
* Player to get permission group of
|
||||
* @return Highest permission group player has permission for
|
||||
* or {@link TabConstants#DEFAULT_GROUP} if player does not have any
|
||||
*/
|
||||
private String getByPermission(TabPlayer player) {
|
||||
for (String group : primaryGroupFindingList) {
|
||||
if (player.hasPermission(TabConstants.Permission.GROUP_PREFIX + group)) {
|
||||
return String.valueOf(group);
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return TabConstants.DEFAULT_GROUP;
|
||||
@@ -136,7 +87,7 @@ public class GroupManager extends TabFeature {
|
||||
* Returns {@code true} if assigning by permissions is configured,
|
||||
* {@code false} if not.
|
||||
*
|
||||
* @return {@code true} if assigning by permissions, {@code false} if not
|
||||
* @return {@code true} if assigning by permissions, {@code false} if not
|
||||
*/
|
||||
public boolean isGroupsByPermissions() {
|
||||
return groupsByPermissions;
|
||||
@@ -145,22 +96,9 @@ public class GroupManager extends TabFeature {
|
||||
/**
|
||||
* Returns detected permission plugin
|
||||
*
|
||||
* @return detected permission plugin
|
||||
* @return detected permission plugin
|
||||
*/
|
||||
public PermissionPlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh(TabPlayer p, boolean force) {
|
||||
((ITabPlayer)p).setGroup(TAB.getInstance().getPlaceholderManager().getPlaceholder("%group%").getLastValue(p));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
if (luckPermsSub != null) {
|
||||
luckPermsSub.close();
|
||||
luckPermsSub2.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,11 @@ import me.neznamy.tab.api.ProtocolVersion;
|
||||
import me.neznamy.tab.api.TabFeature;
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
import me.neznamy.tab.api.chat.IChatBaseComponent;
|
||||
import me.neznamy.tab.api.placeholder.PlayerPlaceholder;
|
||||
import me.neznamy.tab.api.protocol.*;
|
||||
import me.neznamy.tab.api.protocol.PacketPlayOutChat.ChatMessageType;
|
||||
import me.neznamy.tab.api.team.TeamManager;
|
||||
import me.neznamy.tab.api.util.Preconditions;
|
||||
import me.neznamy.tab.shared.event.impl.PlayerLoadEventImpl;
|
||||
import me.neznamy.tab.shared.features.NickCompatibility;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
@@ -78,18 +80,18 @@ public abstract class ITabPlayer implements TabPlayer {
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
*
|
||||
* @param player
|
||||
* platform-specific player object
|
||||
* @param uniqueId
|
||||
* Player's unique ID
|
||||
* @param name
|
||||
* Player's name
|
||||
* @param server
|
||||
* Player's server
|
||||
* @param world
|
||||
* Player's world
|
||||
* @param protocolVersion
|
||||
* Player's game version
|
||||
* @param player
|
||||
* platform-specific player object
|
||||
* @param uniqueId
|
||||
* Player's unique ID
|
||||
* @param name
|
||||
* Player's name
|
||||
* @param server
|
||||
* Player's server
|
||||
* @param world
|
||||
* Player's world
|
||||
* @param protocolVersion
|
||||
* Player's game version
|
||||
*/
|
||||
protected ITabPlayer(Object player, UUID uniqueId, String name, String server, String world, int protocolVersion) {
|
||||
this.player = player;
|
||||
@@ -99,24 +101,23 @@ public abstract class ITabPlayer implements TabPlayer {
|
||||
this.world = world;
|
||||
this.version = ProtocolVersion.fromNetworkId(protocolVersion);
|
||||
this.bedrockPlayer = TAB.getInstance().isFloodgateInstalled() && FloodgateApi.getInstance() != null && FloodgateApi.getInstance().isFloodgatePlayer(uniqueId);
|
||||
String group = TAB.getInstance().getGroupManager().detectPermissionGroup(this);
|
||||
permissionGroup = group != null ? group : TabConstants.DEFAULT_GROUP;
|
||||
this.permissionGroup = TAB.getInstance().getGroupManager().detectPermissionGroup(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets player's property with provided key to provided value. If it existed,
|
||||
* the raw value is changed. If it did not exist, it is created.
|
||||
*
|
||||
* @param feature
|
||||
* Feature creating the property
|
||||
* @param identifier
|
||||
* Property's unique identifier
|
||||
* @param rawValue
|
||||
* Raw value with raw placeholders
|
||||
* @param source
|
||||
* Source of raw value
|
||||
* @return {@code true} if property did not exist or existed with different raw value,
|
||||
* {@code false} if property existed with the same raw value already.
|
||||
* @param feature
|
||||
* Feature creating the property
|
||||
* @param identifier
|
||||
* Property's unique identifier
|
||||
* @param rawValue
|
||||
* Raw value with raw placeholders
|
||||
* @param source
|
||||
* Source of raw value
|
||||
* @return {@code true} if property did not exist or existed with different raw value,
|
||||
* {@code false} if property existed with the same raw value already.
|
||||
*/
|
||||
private boolean setProperty(TabFeature feature, String identifier, String rawValue, String source, boolean exposeInExpansion) {
|
||||
DynamicText p = (DynamicText) getProperty(identifier);
|
||||
@@ -135,8 +136,8 @@ public abstract class ITabPlayer implements TabPlayer {
|
||||
/**
|
||||
* Sets team name to given value
|
||||
*
|
||||
* @param name
|
||||
* Team name to use
|
||||
* @param name
|
||||
* Team name to use
|
||||
*/
|
||||
public void setTeamName(String name) {
|
||||
teamName = name;
|
||||
@@ -145,8 +146,8 @@ public abstract class ITabPlayer implements TabPlayer {
|
||||
/**
|
||||
* Sets team name note to given value
|
||||
*
|
||||
* @param note
|
||||
* New team name note
|
||||
* @param note
|
||||
* New team name note
|
||||
*/
|
||||
public void setTeamNameNote(String note) {
|
||||
teamNameNote = note;
|
||||
@@ -155,8 +156,8 @@ public abstract class ITabPlayer implements TabPlayer {
|
||||
/**
|
||||
* Marks the player as loaded and calls PlayerLoadEvent
|
||||
*
|
||||
* @param join
|
||||
* {@code true} if this is a player join, {@code false} if reload
|
||||
* @param join
|
||||
* {@code true} if this is a player join, {@code false} if reload
|
||||
*/
|
||||
public void markAsLoaded(boolean join) {
|
||||
onJoinFinished = true;
|
||||
@@ -167,24 +168,22 @@ public abstract class ITabPlayer implements TabPlayer {
|
||||
/**
|
||||
* Changes player's group to provided value and all features are refreshed.
|
||||
*
|
||||
* @param permissionGroup
|
||||
* New permission group
|
||||
* @param permissionGroup
|
||||
* New permission group
|
||||
*/
|
||||
public void setGroup(String permissionGroup) {
|
||||
Preconditions.checkNotNull(permissionGroup, "permissionGroup");
|
||||
if (this.permissionGroup.equals(permissionGroup)) return;
|
||||
if (permissionGroup != null) {
|
||||
this.permissionGroup = permissionGroup;
|
||||
} else {
|
||||
this.permissionGroup = TabConstants.DEFAULT_GROUP;
|
||||
}
|
||||
this.permissionGroup = permissionGroup;
|
||||
((PlayerPlaceholder)TAB.getInstance().getPlaceholderManager().getPlaceholder("%group%")).updateValue(this, permissionGroup);
|
||||
forceRefresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets player's world to given value
|
||||
*
|
||||
* @param name
|
||||
* Name of the new world
|
||||
* @param name
|
||||
* Name of the new world
|
||||
*/
|
||||
public void setWorld(String name) {
|
||||
world = name;
|
||||
@@ -193,8 +192,8 @@ public abstract class ITabPlayer implements TabPlayer {
|
||||
/**
|
||||
* Sets player's server to given value
|
||||
*
|
||||
* @param name
|
||||
* Name of the new server
|
||||
* @param name
|
||||
* Name of the new server
|
||||
*/
|
||||
public void setServer(String name) {
|
||||
server = name;
|
||||
|
||||
@@ -16,8 +16,8 @@ public abstract class Platform {
|
||||
/**
|
||||
* Constructs new instance with given parameter
|
||||
*
|
||||
* @param packetBuilder
|
||||
* Platform's packet builder
|
||||
* @param packetBuilder
|
||||
* Platform's packet builder
|
||||
*/
|
||||
protected Platform(PacketBuilder packetBuilder) {
|
||||
this.packetBuilder = packetBuilder;
|
||||
@@ -27,18 +27,22 @@ public abstract class Platform {
|
||||
* Calls platform-specific load event.
|
||||
* This method is called when plugin is fully enabled.
|
||||
*/
|
||||
public void callLoadEvent(){}
|
||||
public void callLoadEvent(){
|
||||
//do nothing by default, old event system will be removed
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls platform-specific player load event.
|
||||
* This method is called when player is fully loaded.
|
||||
*/
|
||||
public void callLoadEvent(TabPlayer player){}
|
||||
public void callLoadEvent(TabPlayer player){
|
||||
//do nothing by default, old event system will be removed
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns platform-specific packet builder implementation
|
||||
*
|
||||
* @return platform-specific packet builder
|
||||
* @return platform-specific packet builder
|
||||
*/
|
||||
public PacketBuilder getPacketBuilder(){
|
||||
return packetBuilder;
|
||||
@@ -47,7 +51,7 @@ public abstract class Platform {
|
||||
/**
|
||||
* Detects permission plugin and returns it's representing object
|
||||
*
|
||||
* @return the interface representing the permission hook
|
||||
* @return the interface representing the permission hook
|
||||
*/
|
||||
public abstract PermissionPlugin detectPermissionPlugin();
|
||||
|
||||
@@ -60,15 +64,15 @@ public abstract class Platform {
|
||||
* Creates an instance of {@link me.neznamy.tab.api.placeholder.Placeholder}
|
||||
* to handle this unknown placeholder (typically a PAPI placeholder)
|
||||
*
|
||||
* @param identifier
|
||||
* placeholder's identifier
|
||||
* @param identifier
|
||||
* placeholder's identifier
|
||||
*/
|
||||
public abstract void registerUnknownPlaceholder(String identifier);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this platform is a proxy, {@code false} if a game server
|
||||
*
|
||||
* @return {@code true} if this platform is a proxy, {@code false} if a game server
|
||||
* @return {@code true} if this platform is a proxy, {@code false} if a game server
|
||||
*/
|
||||
public abstract boolean isProxy();
|
||||
|
||||
@@ -76,9 +80,9 @@ public abstract class Platform {
|
||||
* Performs platform-specific plugin manager call and returns the result.
|
||||
* If plugin is not installed, returns {@code null}.
|
||||
*
|
||||
* @param plugin
|
||||
* Plugin to check version of
|
||||
* @return Version string if plugin is installed, {@code null} if not
|
||||
* @param plugin
|
||||
* Plugin to check version of
|
||||
* @return Version string if plugin is installed, {@code null} if not
|
||||
*/
|
||||
public abstract String getPluginVersion(String plugin);
|
||||
|
||||
@@ -86,7 +90,7 @@ public abstract class Platform {
|
||||
* Returns name of default config file for this platform
|
||||
* as it appears in the final jar in root directory.
|
||||
*
|
||||
* @return name of default config file for this platform
|
||||
* @return name of default config file for this platform
|
||||
*/
|
||||
public abstract String getConfigName();
|
||||
}
|
||||
@@ -116,10 +116,10 @@ public class TAB extends TabAPI {
|
||||
* Constructs new instance with given parameters and sets this
|
||||
* new instance as {@link me.neznamy.tab.api.TabAPI} instance.
|
||||
*
|
||||
* @param platform
|
||||
* Platform interface
|
||||
* @param serverVersion
|
||||
* Version the server is running on
|
||||
* @param platform
|
||||
* Platform interface
|
||||
* @param serverVersion
|
||||
* Version the server is running on
|
||||
*/
|
||||
public TAB(Platform platform, ProtocolVersion serverVersion, String serverVersionString, File dataFolder, Object logger) {
|
||||
this.platform = platform;
|
||||
@@ -145,9 +145,9 @@ public class TAB extends TabAPI {
|
||||
* Returns player by TabList UUID. This is required due to Velocity
|
||||
* as player uuid and TabList uuid do not match there at some circumstances
|
||||
*
|
||||
* @param tabListId
|
||||
* TabList id of player
|
||||
* @return player with provided id or null if player was not found
|
||||
* @param tabListId
|
||||
* TabList id of player
|
||||
* @return player with provided id or null if player was not found
|
||||
*/
|
||||
public TabPlayer getPlayerByTabListUUID(UUID tabListId) {
|
||||
return playersByTabListId.get(tabListId);
|
||||
@@ -256,8 +256,8 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Adds specified player to online players
|
||||
*
|
||||
* @param player
|
||||
* Player to add
|
||||
* @param player
|
||||
* Player to add
|
||||
*/
|
||||
public void addPlayer(TabPlayer player) {
|
||||
data.put(player.getUniqueId(), player);
|
||||
@@ -268,8 +268,8 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Removes specified player from online players
|
||||
*
|
||||
* @param player
|
||||
* Player to remove
|
||||
* @param player
|
||||
* Player to remove
|
||||
*/
|
||||
public void removePlayer(TabPlayer player) {
|
||||
data.remove(player.getUniqueId());
|
||||
@@ -280,7 +280,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns instance of this class
|
||||
*
|
||||
* @return instance of this class
|
||||
* @return instance of this class
|
||||
*/
|
||||
public static TAB getInstance() {
|
||||
return instance;
|
||||
@@ -289,8 +289,8 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Changes instance of this class to new value
|
||||
*
|
||||
* @param instance
|
||||
* Instance to set variable to
|
||||
* @param instance
|
||||
* Instance to set variable to
|
||||
*/
|
||||
public static void setInstance(TAB instance) {
|
||||
TAB.instance = instance;
|
||||
@@ -299,7 +299,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@code true} if floodgate plugin is installed, {@code false} if not
|
||||
*
|
||||
* @return {@code true} if floodgate plugin is installed, {@code false} if not
|
||||
* @return {@code true} if floodgate plugin is installed, {@code false} if not
|
||||
*/
|
||||
public boolean isFloodgateInstalled() {
|
||||
return floodgate;
|
||||
@@ -308,7 +308,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns TAB's group manager used to refresh player groups from other plugins
|
||||
*
|
||||
* @return group manager instance
|
||||
* @return group manager instance
|
||||
*/
|
||||
public GroupManager getGroupManager() {
|
||||
return (GroupManager) featureManager.getFeature(TabConstants.Feature.GROUP_MANAGER);
|
||||
@@ -317,7 +317,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #platform}
|
||||
*
|
||||
* @return {@link #platform}
|
||||
* @return {@link #platform}
|
||||
*/
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
@@ -326,7 +326,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #cpu}
|
||||
*
|
||||
* @return {@link #cpu}
|
||||
* @return {@link #cpu}
|
||||
*/
|
||||
public CpuManager getCPUManager() {
|
||||
return cpu;
|
||||
@@ -335,7 +335,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #errorManager}
|
||||
*
|
||||
* @return {@link #errorManager}
|
||||
* @return {@link #errorManager}
|
||||
*/
|
||||
public ErrorManager getErrorManager() {
|
||||
return errorManager;
|
||||
@@ -344,7 +344,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #configuration}
|
||||
*
|
||||
* @return {@link #configuration}
|
||||
* @return {@link #configuration}
|
||||
*/
|
||||
public Configs getConfiguration() {
|
||||
return configuration;
|
||||
@@ -353,7 +353,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #disabled}
|
||||
*
|
||||
* @return {@link #disabled}
|
||||
* @return {@link #disabled}
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
@@ -362,7 +362,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #command}
|
||||
*
|
||||
* @return {@link #command}
|
||||
* @return {@link #command}
|
||||
*/
|
||||
public TabCommand getCommand() {
|
||||
return command;
|
||||
@@ -371,7 +371,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #disabledCommand}
|
||||
*
|
||||
* @return {@link #disabledCommand}
|
||||
* @return {@link #disabledCommand}
|
||||
*/
|
||||
public DisabledCommand getDisabledCommand() {
|
||||
return disabledCommand;
|
||||
@@ -380,7 +380,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #serverVersionString}
|
||||
*
|
||||
* @return {@link #serverVersionString}
|
||||
* @return {@link #serverVersionString}
|
||||
*/
|
||||
public String getServerVersionString() {
|
||||
return serverVersionString;
|
||||
@@ -389,7 +389,7 @@ public class TAB extends TabAPI {
|
||||
/**
|
||||
* Returns {@link #dataFolder}
|
||||
*
|
||||
* @return {@link #dataFolder}
|
||||
* @return {@link #dataFolder}
|
||||
*/
|
||||
public File getDataFolder() {
|
||||
return dataFolder;
|
||||
@@ -441,11 +441,10 @@ public class TAB extends TabAPI {
|
||||
|
||||
@Override
|
||||
public void sendConsoleMessage(String message, boolean translateColors) {
|
||||
if (translateColors) message = EnumChatFormat.color(message);
|
||||
if (logger instanceof java.util.logging.Logger) {
|
||||
((java.util.logging.Logger) logger).info(message);
|
||||
} else if (logger instanceof org.slf4j.Logger) {
|
||||
((Logger) logger).info(message);
|
||||
((java.util.logging.Logger) logger).info(translateColors ? EnumChatFormat.color(message) : message);
|
||||
} else if (logger instanceof Logger) {
|
||||
((Logger) logger).info(translateColors ? EnumChatFormat.color(message) : message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ public class TabConstants {
|
||||
public static final String PLAYER_RESPAWN = "Player Respawn";
|
||||
public static final String PLUGIN_MESSAGE = "PluginMessageEvent";
|
||||
public static final String REDIS_BUNGEE_MESSAGE = "PubSubMessageEvent";
|
||||
public static final String LUCKPERMS_USER_RECALCULATE_EVENT = "UserDataRecalculateEvent";
|
||||
public static final String LUCKPERMS_GROUP_RECALCULATE_EVENT = "GroupDataRecalculateEvent";
|
||||
public static final String VANISH_CHANGE = "Vanish status change";
|
||||
public static final String ANTI_OVERRIDE = "Anti override";
|
||||
|
||||
@@ -49,6 +47,7 @@ public class TabConstants {
|
||||
public static final String RAW_PACKET_OUT = "Packet reading (out)";
|
||||
|
||||
public static final String PLACEHOLDER_REFRESHING = "Refreshing placeholders";
|
||||
public static final String GROUP_REFRESHING = "Refreshing groups";
|
||||
|
||||
public static final String V1_8_0_BUG_COMPENSATION = "Compensating for 1.8.0 bugs";
|
||||
public static final String REFRESHING_NAME_TAG_VISIBILITY = "Refreshing NameTag visibility";
|
||||
@@ -78,6 +77,7 @@ public class TabConstants {
|
||||
|
||||
public static final String LAYOUT_FIXED_SLOTS = "Layout (Fixed slots)";
|
||||
public static final String LAYOUT_PLAYER_SLOTS = "Layout (Player slots)";
|
||||
public static final String LAYOUT_LATENCY = "Layout (Updating latency)";
|
||||
|
||||
public static final String NAMETAGS_TEAM_REGISTER = "NameTags (Team register)";
|
||||
public static final String NAMETAGS_TEAM_UNREGISTER = "NameTags (Team unregister)";
|
||||
@@ -225,6 +225,7 @@ public class TabConstants {
|
||||
public static final String PING_SPOOF = "PingSpoof";
|
||||
public static final String SORTING = "sorting";
|
||||
public static final String LAYOUT = "layout";
|
||||
public static final String LAYOUT_LATENCY = "layout-latency";
|
||||
public static final String NICK_COMPATIBILITY = "nick";
|
||||
public static final String PIPELINE_INJECTION = "injection";
|
||||
public static final String BOSS_BAR = "BossBar";
|
||||
|
||||
@@ -33,16 +33,16 @@ public class TabRepeatingTask implements RepeatingTask {
|
||||
/**
|
||||
* Constructs new instance with given parameters and starts the task.
|
||||
*
|
||||
* @param exe
|
||||
* Executor service to submit the repeating task to
|
||||
* @param runnable
|
||||
* Task to run periodically
|
||||
* @param feature
|
||||
* Feature creating this task, used in cpu command output
|
||||
* @param type
|
||||
* Sub-feature creating this task, used in cpu command output
|
||||
* @param interval
|
||||
* Interval in milliseconds how often to submit the task to main thread
|
||||
* @param exe
|
||||
* Executor service to submit the repeating task to
|
||||
* @param runnable
|
||||
* Task to run periodically
|
||||
* @param feature
|
||||
* Feature creating this task, used in cpu command output
|
||||
* @param type
|
||||
* Sub-feature creating this task, used in cpu command output
|
||||
* @param interval
|
||||
* Interval in milliseconds how often to submit the task to main thread
|
||||
*/
|
||||
public TabRepeatingTask(ExecutorService exe, Runnable runnable, TabFeature feature, String type, int interval) {
|
||||
if (interval < 0) throw new IllegalArgumentException("Interval cannot be negative");
|
||||
|
||||
@@ -145,8 +145,10 @@ public class CpuCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns colored usage from provided usage
|
||||
* @param usage - usage
|
||||
* @return colored usage
|
||||
*
|
||||
* @param usage
|
||||
* usage
|
||||
* @return colored usage
|
||||
*/
|
||||
private String colorize(String usage, float threshold1, float threshold2) {
|
||||
float percent = Float.parseFloat(usage.replace(",", "."));
|
||||
|
||||
@@ -43,8 +43,11 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Performs debug on player and displays output
|
||||
* @param sender - command sender or null if console
|
||||
* @param analyzed - player to be analyzed
|
||||
*
|
||||
* @param sender
|
||||
* command sender or null if console
|
||||
* @param analyzed
|
||||
* player to be analyzed
|
||||
*/
|
||||
private void debug(TabPlayer sender, TabPlayer analyzed) {
|
||||
TAB tab = TAB.getInstance();
|
||||
@@ -89,7 +92,8 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns group choice logic
|
||||
* @return group choice logic
|
||||
*
|
||||
* @return group choice logic
|
||||
*/
|
||||
private String getGroupChoiceLogic() {
|
||||
if (TAB.getInstance().getGroupManager().isGroupsByPermissions()) {
|
||||
@@ -101,7 +105,8 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns sorting type
|
||||
* @return sorting type
|
||||
*
|
||||
* @return sorting type
|
||||
*/
|
||||
private String getSortingType() {
|
||||
NameTag nametag = (NameTag) TAB.getInstance().getTeamManager();
|
||||
@@ -114,8 +119,10 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns all info about player's group
|
||||
* @param analyzed - player to check group of
|
||||
* @return all info about player's group
|
||||
*
|
||||
* @param analyzed
|
||||
* player to check group of
|
||||
* @return all info about player's group
|
||||
*/
|
||||
private String getGroup(TabPlayer analyzed) {
|
||||
if (TAB.getInstance().getGroupManager().isGroupsByPermissions()) {
|
||||
@@ -126,8 +133,10 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns team name of specified player
|
||||
* @param analyzed - player to get team name of
|
||||
* @return team name of specified player
|
||||
*
|
||||
* @param analyzed
|
||||
* player to get team name of
|
||||
* @return team name of specified player
|
||||
*/
|
||||
private String getTeamName(TabPlayer analyzed) {
|
||||
if (TAB.getInstance().getTeamManager() != null) {
|
||||
@@ -143,8 +152,10 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns team name note of specified player
|
||||
* @param analyzed - player to get team name note of
|
||||
* @return team name note of specified player
|
||||
*
|
||||
* @param analyzed
|
||||
* player to get team name note of
|
||||
* @return team name note of specified player
|
||||
*/
|
||||
private String getTeamNameNote(TabPlayer analyzed) {
|
||||
if (TAB.getInstance().getTeamManager() != null &&
|
||||
@@ -156,7 +167,8 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns list of extra properties if unlimited nametag mode is enabled
|
||||
* @return list of extra properties
|
||||
*
|
||||
* @return list of extra properties
|
||||
*/
|
||||
public List<String> getExtraLines(){
|
||||
if (!TAB.getInstance().getFeatureManager().isFeatureEnabled(TabConstants.Feature.UNLIMITED_NAME_TAGS)) return new ArrayList<>();
|
||||
@@ -170,10 +182,15 @@ public class DebugCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Shows value and source of player's property
|
||||
* @param sender - command sender or null if console
|
||||
* @param analyzed - analyzed player
|
||||
* @param property - property name
|
||||
* @param disabled - if feature the property belongs to is disabled or not
|
||||
*
|
||||
* @param sender
|
||||
* command sender or null if console
|
||||
* @param analyzed
|
||||
* analyzed player
|
||||
* @param property
|
||||
* property name
|
||||
* @param disabled
|
||||
* if feature the property belongs to is disabled or not
|
||||
*/
|
||||
private void showProperty(TabPlayer sender, TabPlayer analyzed, String property, boolean disabled) {
|
||||
if (disabled) {
|
||||
|
||||
@@ -12,10 +12,14 @@ public class DisabledCommand {
|
||||
|
||||
/**
|
||||
* Performs command and return messages to be sent back
|
||||
* @param args - command arguments
|
||||
* @param hasReloadPermission - if player has permission to reload or not
|
||||
* @param hasAdminPermission - if player has admin permission or not
|
||||
* @return list of messages to send back
|
||||
*
|
||||
* @param args
|
||||
* command arguments
|
||||
* @param hasReloadPermission
|
||||
* if player has permission to reload or not
|
||||
* @param hasAdminPermission
|
||||
* if player has admin permission or not
|
||||
* @return list of messages to send back
|
||||
*/
|
||||
public List<String> execute(String[] args, boolean hasReloadPermission, boolean hasAdminPermission) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.neznamy.tab.shared.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
import me.neznamy.tab.shared.TAB;
|
||||
@@ -82,20 +82,20 @@ public class GroupCommand extends PropertyCommand {
|
||||
|
||||
private void sendGroupInfo(TabPlayer sender, String group) {
|
||||
sendMessage(sender, "&f=== Group &9" + group + "&f ===");
|
||||
for (Map.Entry<String, String> entry : TAB.getInstance().getConfiguration().getGroups().getGlobalSettings(group).entrySet()) {
|
||||
for (Map.Entry<String, Object> entry : TAB.getInstance().getConfiguration().getGroups().getGlobalSettings(group).entrySet()) {
|
||||
sendRawMessage(sender, " " + entry.getKey() + ": " + entry.getValue());
|
||||
}
|
||||
for (Map.Entry<String, Map<String, String>> entry : TAB.getInstance().getConfiguration().getGroups().getPerWorldSettings(group).entrySet()) {
|
||||
for (Map.Entry<String, Map<String, Object>> entry : TAB.getInstance().getConfiguration().getGroups().getPerWorldSettings(group).entrySet()) {
|
||||
if (entry.getValue() == null) continue;
|
||||
sendMessage(sender, "&6World " + entry.getKey() + ":&e");
|
||||
for (Map.Entry<String, String> properties : entry.getValue().entrySet()) {
|
||||
for (Map.Entry<String, Object> properties : entry.getValue().entrySet()) {
|
||||
sendRawMessage(sender, " " + properties.getKey() + ": " + properties.getValue());
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Map<String, String>> entry : TAB.getInstance().getConfiguration().getGroups().getPerServerSettings(group).entrySet()) {
|
||||
for (Map.Entry<String, Map<String, Object>> entry : TAB.getInstance().getConfiguration().getGroups().getPerServerSettings(group).entrySet()) {
|
||||
if (entry.getValue() == null) continue;
|
||||
sendMessage(sender, "&3Server " + entry.getKey() + ":&b");
|
||||
for (Map.Entry<String, String> properties : entry.getValue().entrySet()) {
|
||||
for (Map.Entry<String, Object> properties : entry.getValue().entrySet()) {
|
||||
sendRawMessage(sender, " " + properties.getKey() + ": " + properties.getValue());
|
||||
}
|
||||
}
|
||||
@@ -103,10 +103,15 @@ public class GroupCommand extends PropertyCommand {
|
||||
|
||||
/**
|
||||
* Saves new group settings into config
|
||||
* @param sender - command sender or null if console
|
||||
* @param group - affected group
|
||||
* @param type - property type
|
||||
* @param value - new value
|
||||
*
|
||||
* @param sender
|
||||
* command sender or null if console
|
||||
* @param group
|
||||
* affected group
|
||||
* @param type
|
||||
* property type
|
||||
* @param value
|
||||
* new value
|
||||
*/
|
||||
private void saveGroup(TabPlayer sender, String group, String type, String value, String server, String world){
|
||||
if (value.length() > 0){
|
||||
@@ -123,4 +128,14 @@ public class GroupCommand extends PropertyCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> complete(TabPlayer sender, String[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
Set<String> groups = new HashSet<>(TAB.getInstance().getConfiguration().getGroups().getAllEntries());
|
||||
groups.add("_DEFAULT_");
|
||||
return groups.stream().filter(group -> group.toLowerCase().startsWith(arguments[0].toLowerCase())).collect(Collectors.toList());
|
||||
}
|
||||
return super.complete(sender, arguments);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MySQLCommand extends SubCommand {
|
||||
|
||||
@@ -101,24 +102,32 @@ public class MySQLCommand extends SubCommand {
|
||||
|
||||
private void upload(YamlPropertyConfigurationFile file, PropertyConfiguration mysqlTable) {
|
||||
for (String name : file.getAllEntries()) {
|
||||
for (Map.Entry<String, String> property : file.getGlobalSettings(name).entrySet()) {
|
||||
mysqlTable.setProperty(name, property.getKey(), null, null, property.getValue());
|
||||
for (Map.Entry<String, Object> property : file.getGlobalSettings(name).entrySet()) {
|
||||
mysqlTable.setProperty(name, property.getKey(), null, null, toString(property.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, Map<String, String>> world : file.getPerWorldSettings(name).entrySet()) {
|
||||
for (Map.Entry<String, Map<String, Object>> world : file.getPerWorldSettings(name).entrySet()) {
|
||||
if (world.getValue() == null) continue;
|
||||
for (Map.Entry<String, String> property : world.getValue().entrySet()) {
|
||||
mysqlTable.setProperty(name, property.getKey(), null, world.getKey(), property.getValue());
|
||||
for (Map.Entry<String, Object> property : world.getValue().entrySet()) {
|
||||
mysqlTable.setProperty(name, property.getKey(), null, world.getKey(), toString(property.getValue()));
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Map<String, String>> server : file.getPerServerSettings(name).entrySet()) {
|
||||
for (Map.Entry<String, Map<String, Object>> server : file.getPerServerSettings(name).entrySet()) {
|
||||
if (server.getValue() == null) continue;
|
||||
for (Map.Entry<String, String> property : server.getValue().entrySet()) {
|
||||
mysqlTable.setProperty(name, property.getKey(), server.getKey(), null, property.getValue());
|
||||
for (Map.Entry<String, Object> property : server.getValue().entrySet()) {
|
||||
mysqlTable.setProperty(name, property.getKey(), server.getKey(), null, toString(property.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String toString(Object obj) {
|
||||
if (obj instanceof List) {
|
||||
return ((List<Object>)obj).stream().map(Object::toString).collect(Collectors.joining("\n"));
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> complete(TabPlayer sender, String[] arguments) {
|
||||
return getStartingArgument(Arrays.asList("download", "upload"), arguments[0]);
|
||||
|
||||
@@ -55,6 +55,10 @@ public class NameTagCommand extends SubCommand {
|
||||
sendMessage(sender, getMessages().getUnlimitedNametagModeNotEnabled());
|
||||
return;
|
||||
}
|
||||
if (nameTagX.hasDisabledArmorStands(sender)) {
|
||||
sendMessage(sender, getMessages().getArmorStandsDisabledCannotPreview());
|
||||
return;
|
||||
}
|
||||
nameTagX.toggleNametagPreview(sender);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,10 +73,15 @@ public class PlayerCommand extends PropertyCommand {
|
||||
|
||||
/**
|
||||
* Saves new player settings into config
|
||||
* @param sender - command sender or null if console
|
||||
* @param player - affected player
|
||||
* @param type - property type
|
||||
* @param value - new value
|
||||
*
|
||||
* @param sender
|
||||
* command sender or null if console
|
||||
* @param player
|
||||
* affected player
|
||||
* @param type
|
||||
* property type
|
||||
* @param value
|
||||
* new value
|
||||
*/
|
||||
public void savePlayer(TabPlayer sender, String player, String type, String value, String server, String world){
|
||||
if (value.length() > 0){
|
||||
|
||||
@@ -75,10 +75,15 @@ public class PlayerUUIDCommand extends PropertyCommand {
|
||||
|
||||
/**
|
||||
* Saves new player settings into config
|
||||
* @param sender - command sender or null if console
|
||||
* @param player - affected player
|
||||
* @param type - property type
|
||||
* @param value - new value
|
||||
*
|
||||
* @param sender
|
||||
* command sender or null if console
|
||||
* @param player
|
||||
* affected player
|
||||
* @param type
|
||||
* property type
|
||||
* @param value
|
||||
* new value
|
||||
*/
|
||||
public void savePlayer(TabPlayer sender, TabPlayer player, String type, String value, String server, String world){
|
||||
if (value.length() > 0){
|
||||
|
||||
@@ -34,8 +34,11 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameters
|
||||
* @param name - command name
|
||||
* @param permission - permission requirement
|
||||
*
|
||||
* @param name
|
||||
* command name
|
||||
* @param permission
|
||||
* permission requirement
|
||||
*/
|
||||
protected SubCommand(String name, String permission) {
|
||||
this.name = name;
|
||||
@@ -44,7 +47,9 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Registers new subcommand
|
||||
* @param subcommand - subcommand to register
|
||||
*
|
||||
* @param subcommand
|
||||
* subcommand to register
|
||||
*/
|
||||
public void registerSubCommand(SubCommand subcommand) {
|
||||
getSubcommands().put(subcommand.getName(), subcommand);
|
||||
@@ -52,7 +57,8 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Returns name of this command
|
||||
* @return name of this command
|
||||
*
|
||||
* @return name of this command
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -60,8 +66,10 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Returns whether player has permission to run this command or not
|
||||
* @param sender - player who ran command or null if console
|
||||
* @return true if sender has permission or is console, false otherwise
|
||||
*
|
||||
* @param sender
|
||||
* player who ran command or null if console
|
||||
* @return true if sender has permission or is console, false otherwise
|
||||
*/
|
||||
public boolean hasPermission(TabPlayer sender) {
|
||||
return hasPermission(sender, permission);
|
||||
@@ -69,9 +77,12 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Returns whether player has given permission or not
|
||||
* @param sender - player who ran command or null if console
|
||||
* @param permission - permission to check for
|
||||
* @return true if sender has permission or is console, false otherwise
|
||||
*
|
||||
* @param sender
|
||||
* player who ran command or null if console
|
||||
* @param permission
|
||||
* permission to check for
|
||||
* @return true if sender has permission or is console, false otherwise
|
||||
*/
|
||||
public boolean hasPermission(TabPlayer sender, String permission) {
|
||||
if (permission == null) return true; //no permission required
|
||||
@@ -82,8 +93,11 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Sends messages to the command sender with colors translated
|
||||
* @param sender - player or console to send the message to
|
||||
* @param messages - messages to send
|
||||
*
|
||||
* @param sender
|
||||
* player or console to send the message to
|
||||
* @param messages
|
||||
* messages to send
|
||||
*/
|
||||
public void sendMessages(TabPlayer sender, List<String> messages) {
|
||||
messages.forEach(m -> sendMessage(sender, m));
|
||||
@@ -91,8 +105,11 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Sends message to the command sender with colors translated
|
||||
* @param sender - player or console to send the message to
|
||||
* @param message - the message to sent
|
||||
*
|
||||
* @param sender
|
||||
* player or console to send the message to
|
||||
* @param message
|
||||
* the message to sent
|
||||
*/
|
||||
public void sendMessage(TabPlayer sender, String message) {
|
||||
if (message == null || message.length() == 0) return;
|
||||
@@ -105,8 +122,11 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Sends message to the command sender without colors translated
|
||||
* @param sender - player or console to send the message to
|
||||
* @param message - the message to sent
|
||||
*
|
||||
* @param sender
|
||||
* player or console to send the message to
|
||||
* @param message
|
||||
* the message to sent
|
||||
*/
|
||||
public void sendRawMessage(TabPlayer sender, String message) {
|
||||
if (message == null || message.length() == 0) return;
|
||||
@@ -119,8 +139,10 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Returns all players whose name start with given string
|
||||
* @param nameStart - beginning of the name
|
||||
* @return List of compatible players
|
||||
*
|
||||
* @param nameStart
|
||||
* beginning of the name
|
||||
* @return List of compatible players
|
||||
*/
|
||||
public List<String> getOnlinePlayers(String nameStart){
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
@@ -136,9 +158,12 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Performs command complete and returns list of arguments to be shown
|
||||
* @param sender - command sender
|
||||
* @param arguments - arguments inserted in chat so far
|
||||
* @return List of possible arguments
|
||||
*
|
||||
* @param sender
|
||||
* command sender
|
||||
* @param arguments
|
||||
* arguments inserted in chat so far
|
||||
* @return List of possible arguments
|
||||
*/
|
||||
public List<String> complete(TabPlayer sender, String[] arguments) {
|
||||
String argument;
|
||||
@@ -167,8 +192,11 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Performs the command
|
||||
* @param sender - command sender or null if console
|
||||
* @param args - arguments of the command
|
||||
*
|
||||
* @param sender
|
||||
* command sender or null if console
|
||||
* @param args
|
||||
* arguments of the command
|
||||
*/
|
||||
public abstract void execute(TabPlayer sender, String[] args);
|
||||
|
||||
|
||||
@@ -64,7 +64,9 @@ public class TabCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Sends help menu to the sender
|
||||
* @param sender - player who ran command or null if from console
|
||||
*
|
||||
* @param sender
|
||||
* player who ran command or null if from console
|
||||
*/
|
||||
private void help(TabPlayer sender){
|
||||
if (hasPermission(sender, TabConstants.Permission.COMMAND_ALL)) {
|
||||
|
||||
@@ -170,9 +170,12 @@ public class WidthCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* Returns line of text with characters that build specified text width
|
||||
* @param width - with to display
|
||||
* @param c - character to set click action to
|
||||
* @return line of text with characters that build specified text width
|
||||
*
|
||||
* @param width
|
||||
* with to display
|
||||
* @param c
|
||||
* character to set click action to
|
||||
* @return line of text with characters that build specified text width
|
||||
*/
|
||||
private IChatBaseComponent getText(int width, int c) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
@@ -204,10 +207,8 @@ public class WidthCommand extends SubCommand {
|
||||
} else {
|
||||
suggestions.add("<amount>");
|
||||
}
|
||||
} else if (arguments.length == 3) {
|
||||
if (arguments[0].equalsIgnoreCase("set")) {
|
||||
suggestions.add("<new width>");
|
||||
}
|
||||
} else if (arguments.length == 3 && arguments[0].equalsIgnoreCase("set")) {
|
||||
suggestions.add("<new width>");
|
||||
}
|
||||
return getStartingArgument(suggestions, arguments[arguments.length - 1]);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,9 @@ public class Configs {
|
||||
|
||||
/**
|
||||
* Constructs new instance with given parameter
|
||||
* @param tab - tab instance
|
||||
*
|
||||
* @param tab
|
||||
* tab instance
|
||||
*/
|
||||
public Configs(TAB tab) {
|
||||
this.tab = tab;
|
||||
@@ -67,10 +69,11 @@ public class Configs {
|
||||
|
||||
/**
|
||||
* Loads all configuration files and converts files to latest version
|
||||
* @throws IOException
|
||||
* if File I/O operation fails
|
||||
* @throws YAMLException
|
||||
* if files contain syntax errors
|
||||
*
|
||||
* @throws IOException
|
||||
* if File I/O operation fails
|
||||
* @throws YAMLException
|
||||
* if files contain syntax errors
|
||||
*/
|
||||
public void loadFiles() throws YAMLException, IOException {
|
||||
messages = new MessageFile();
|
||||
@@ -84,10 +87,11 @@ public class Configs {
|
||||
|
||||
/**
|
||||
* Loads config.yml and some of its values
|
||||
* @throws IOException
|
||||
* if File I/O operation fails
|
||||
* @throws YAMLException
|
||||
* if files contain syntax errors
|
||||
*
|
||||
* @throws IOException
|
||||
* if File I/O operation fails
|
||||
* @throws YAMLException
|
||||
* if files contain syntax errors
|
||||
*/
|
||||
public void loadConfig() throws YAMLException, IOException {
|
||||
config = new YamlConfigurationFile(Configs.class.getClassLoader().getResourceAsStream(tab.getPlatform().getConfigName()), new File(tab.getDataFolder(), "config.yml"));
|
||||
@@ -118,9 +122,12 @@ public class Configs {
|
||||
|
||||
/**
|
||||
* Returns value of hidden config option with specified path if it exists, defaultValue otherwise
|
||||
* @param path - path to value
|
||||
* @param defaultValue - value to return if option is not present in file
|
||||
* @return value with specified path or default value if not present
|
||||
*
|
||||
* @param path
|
||||
* path to value
|
||||
* @param defaultValue
|
||||
* value to return if option is not present in file
|
||||
* @return value with specified path or default value if not present
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getSecretOption(String path, T defaultValue) {
|
||||
|
||||
@@ -16,12 +16,6 @@ import java.util.*;
|
||||
*/
|
||||
public class Converter {
|
||||
|
||||
/**
|
||||
* Creates new instance of this class
|
||||
*/
|
||||
public Converter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts animation file from old format with everything under "animations" key
|
||||
* to new format which does not use the redundant key anymore.
|
||||
@@ -30,6 +24,7 @@ public class Converter {
|
||||
* to call this method, even if conversion is not needed.
|
||||
* <p>
|
||||
* This change was made from 2.8.10 -> 2.9.0
|
||||
*
|
||||
* @param animations
|
||||
* animation file to convert
|
||||
*/
|
||||
@@ -44,6 +39,7 @@ public class Converter {
|
||||
/**
|
||||
* Converts all configuration files from 2.9.2 into new 3.0.0 format and saves a copy
|
||||
* of old files into a new "old_configs" folder.
|
||||
*
|
||||
* @param currentConfig
|
||||
* currently detected config.yml file
|
||||
* @throws IOException
|
||||
@@ -95,16 +91,15 @@ public class Converter {
|
||||
|
||||
/**
|
||||
* Creates a new "old_configs" folder and moves all files in TAB's folder into it.
|
||||
*
|
||||
* @throws IOException
|
||||
* if thrown by file move operation
|
||||
*/
|
||||
private void moveOldFiles() throws IOException {
|
||||
File folder = TAB.getInstance().getDataFolder();
|
||||
File oldFolder = new File(folder, "old_configs");
|
||||
if (!oldFolder.exists() && !oldFolder.mkdirs()) throw new RuntimeException("Failed to convert configuration to v3: Failed to create old_configs folder");
|
||||
File[] files = folder.listFiles();
|
||||
if (files == null) throw new IllegalStateException("Failed to convert configuration to v3: old_configs is not a folder");
|
||||
for (File file : files) {
|
||||
Files.createDirectories(oldFolder.toPath());
|
||||
for (File file : Objects.requireNonNull(folder.listFiles())) {
|
||||
if (!file.isFile()) continue; //old_configs folder
|
||||
Files.move(file.toPath(), new File(folder.getPath() +
|
||||
File.separator + "old_configs" + File.separator + file.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
@@ -174,7 +174,7 @@ public class MessageFile extends YamlConfigurationFile {
|
||||
," &7Reloads plugin and config"
|
||||
," &8>> &3&l/tab &9group&3/&9player &3<name> &9<property> &3<value...>"
|
||||
," &7Do &8/tab group/player &7to show properties"
|
||||
," &8>> &3&l/tab ntpreview"
|
||||
," &8>> &3&l/tab nametag preview"
|
||||
," &7Shows your nametag for yourself, for testing purposes"
|
||||
," &8>> &3&l/tab announce bar &3<name> &9<seconds>"
|
||||
," &7Temporarily displays bossbar to all players"
|
||||
@@ -230,4 +230,8 @@ public class MessageFile extends YamlConfigurationFile {
|
||||
public String getNameTagsShown() {
|
||||
return getString("nametags-shown", "&aNametags of all players were shown to you");
|
||||
}
|
||||
|
||||
public String getArmorStandsDisabledCannotPreview() {
|
||||
return getString("armorstands-disabled-cannot-use-preview", "&cYour armor stands are disabled, therefore you cannot use preview feature");
|
||||
}
|
||||
}
|
||||
Loaded 100 of 164 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user