3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 08:10:09 +01:00

Use generics for bossbars

Dieser Commit ist enthalten in:
Matsv 2016-09-25 18:20:42 +02:00
Ursprung 49d51de263
Commit 84ee4410a6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 97CEC2A2EA31350F
4 geänderte Dateien mit 18 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,6 @@
Migrate EntityUtil to be cool
Fix 1.9to1.8
Migrate listeners in BaseProtocol
Fix BossBar to use Generics
Register Listeners Properly
Fix commands
Handle injector errors

Datei anzeigen

@ -7,37 +7,28 @@ import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
@Getter
public class ViaBossBar extends CommonBoss {
// TODO: Fix to use generics
public class ViaBossBar extends CommonBoss<Player> {
public ViaBossBar(String title, float health, BossColor color, BossStyle style) {
super(title, health, color, style);
}
@Override
public BossBar addPlayer(Object player) {
if (player instanceof Player){
addPlayer(((Player) player).getUniqueId());
} else {
throw new IllegalArgumentException("The addPlayer argument has to be a Bukkit player on this platform");
}
public BossBar addPlayer(Player player) {
addPlayer(player.getUniqueId());
return this;
}
@Override
public BossBar addPlayers(Object... players) {
for (Object p : players)
public BossBar addPlayers(Player... players) {
for (Player p : players)
addPlayer(p);
return this;
}
@Override
public BossBar removePlayer(Object player) {
if (player instanceof Player){
removePlayer(((Player) player).getUniqueId());
} else {
throw new IllegalArgumentException("The removePlayer argument has to be a Bukkit player on this platform");
}
public BossBar removePlayer(Player player) {
removePlayer(player.getUniqueId());
return this;
}
}

Datei anzeigen

@ -6,7 +6,7 @@ import us.myles.ViaVersion.api.Via;
import java.util.Set;
import java.util.UUID;
public abstract class BossBar {
public abstract class BossBar<T> {
/**
* Get the current title
*
@ -72,8 +72,10 @@ public abstract class BossBar {
*
* @param player The player
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
*/
public BossBar addPlayer(Object player){
@Deprecated
public BossBar addPlayer(T player){
throw new NotImplementedException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
@ -90,8 +92,10 @@ public abstract class BossBar {
*
* @param players list of players
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
*/
public BossBar addPlayers(Object... players){
@Deprecated
public BossBar addPlayers(T... players){
throw new NotImplementedException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
@ -100,8 +104,10 @@ public abstract class BossBar {
*
* @param player The player
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #removePlayer(UUID)}
*/
public BossBar removePlayer(Object player){
@Deprecated
public BossBar removePlayer(T player){
throw new NotImplementedException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}

Datei anzeigen

@ -18,7 +18,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.*;
@Getter
public abstract class CommonBoss extends BossBar {
public abstract class CommonBoss<T> extends BossBar<T> {
private UUID uuid;
private String title;
private float health;