Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Use generics for bossbars
Dieser Commit ist enthalten in:
Ursprung
49d51de263
Commit
84ee4410a6
1
TODOLIST
1
TODOLIST
@ -1,7 +1,6 @@
|
|||||||
Migrate EntityUtil to be cool
|
Migrate EntityUtil to be cool
|
||||||
Fix 1.9to1.8
|
Fix 1.9to1.8
|
||||||
Migrate listeners in BaseProtocol
|
Migrate listeners in BaseProtocol
|
||||||
Fix BossBar to use Generics
|
|
||||||
Register Listeners Properly
|
Register Listeners Properly
|
||||||
Fix commands
|
Fix commands
|
||||||
Handle injector errors
|
Handle injector errors
|
||||||
|
@ -7,37 +7,28 @@ import us.myles.ViaVersion.api.boss.BossColor;
|
|||||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ViaBossBar extends CommonBoss {
|
public class ViaBossBar extends CommonBoss<Player> {
|
||||||
// TODO: Fix to use generics
|
|
||||||
|
|
||||||
public ViaBossBar(String title, float health, BossColor color, BossStyle style) {
|
public ViaBossBar(String title, float health, BossColor color, BossStyle style) {
|
||||||
super(title, health, color, style);
|
super(title, health, color, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar addPlayer(Object player) {
|
public BossBar addPlayer(Player player) {
|
||||||
if (player instanceof Player){
|
addPlayer(player.getUniqueId());
|
||||||
addPlayer(((Player) player).getUniqueId());
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("The addPlayer argument has to be a Bukkit player on this platform");
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar addPlayers(Object... players) {
|
public BossBar addPlayers(Player... players) {
|
||||||
for (Object p : players)
|
for (Player p : players)
|
||||||
addPlayer(p);
|
addPlayer(p);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar removePlayer(Object player) {
|
public BossBar removePlayer(Player player) {
|
||||||
if (player instanceof Player){
|
removePlayer(player.getUniqueId());
|
||||||
removePlayer(((Player) player).getUniqueId());
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("The removePlayer argument has to be a Bukkit player on this platform");
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import us.myles.ViaVersion.api.Via;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class BossBar {
|
public abstract class BossBar<T> {
|
||||||
/**
|
/**
|
||||||
* Get the current title
|
* Get the current title
|
||||||
*
|
*
|
||||||
@ -72,8 +72,10 @@ public abstract class BossBar {
|
|||||||
*
|
*
|
||||||
* @param player The player
|
* @param player The player
|
||||||
* @return The BossBar object
|
* @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());
|
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
|
* @param players list of players
|
||||||
* @return The BossBar object
|
* @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());
|
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
|
* @param player The player
|
||||||
* @return The BossBar object
|
* @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());
|
throw new NotImplementedException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public abstract class CommonBoss extends BossBar {
|
public abstract class CommonBoss<T> extends BossBar<T> {
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private String title;
|
private String title;
|
||||||
private float health;
|
private float health;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren