Skip to content

Commit

Permalink
Testing auto release
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoxkk0 committed Mar 29, 2024
1 parent 6841459 commit d433825
Show file tree
Hide file tree
Showing 63 changed files with 387 additions and 355 deletions.
16 changes: 8 additions & 8 deletions src/main/java/io/github/cruciblemc/necrotempus/NecroTempus.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class NecroTempus {
private static NecroTempus instance;

@SidedProxy(
clientSide="io.github.cruciblemc.necrotempus.proxy.ClientProxy",
serverSide="io.github.cruciblemc.necrotempus.proxy.ServerProxy"
clientSide = "io.github.cruciblemc.necrotempus.proxy.ClientProxy",
serverSide = "io.github.cruciblemc.necrotempus.proxy.ServerProxy"
)
public static CommonProxy proxy;

Expand All @@ -44,15 +44,15 @@ public class NecroTempus {
public Logger logger;

static {
DISPATCHER.registerMessage(NTClientPacketHandler.class, NTClientPacket.class, 0, Side.SERVER);
DISPATCHER.registerMessage(BossBarPacketHandler.class, BossBarPacket.class, 1, Side.CLIENT);
DISPATCHER.registerMessage(PlayerTabPacketHandler.class, PlayerTabPacket.class, 2, Side.CLIENT);
DISPATCHER.registerMessage(TitlePacketHandler.class, TitlePacket.class, 3, Side.CLIENT);
DISPATCHER.registerMessage(ActionBarPacketHandler.class, ActionBarPacket.class, 4, Side.CLIENT);
DISPATCHER.registerMessage(NTClientPacketHandler.class, NTClientPacket.class, 0, Side.SERVER);
DISPATCHER.registerMessage(BossBarPacketHandler.class, BossBarPacket.class, 1, Side.CLIENT);
DISPATCHER.registerMessage(PlayerTabPacketHandler.class, PlayerTabPacket.class, 2, Side.CLIENT);
DISPATCHER.registerMessage(TitlePacketHandler.class, TitlePacket.class, 3, Side.CLIENT);
DISPATCHER.registerMessage(ActionBarPacketHandler.class, ActionBarPacket.class, 4, Side.CLIENT);
}

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event){
public void preInit(FMLPreInitializationEvent event) {
logger = event.getModLog();
OmniconfigAPI.registerAnnotationConfig(NecroTempusConfig.class);
proxy.preInit(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public void disablePlugin(Plugin plugin) {
public Server getServer() {
return Bukkit.getServer();
}

@Override
public boolean isEnabled() {
return isPluginEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@
@Setter
public class ActionBar {

@Getter @Setter
@Getter
@Setter
private static ActionBarManager actionBarManager = new ActionBarManager();

private int time;
private IChatComponent text;

public NBTTagCompound toNbt(){
public NBTTagCompound toNbt() {
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setInteger("time", time);
tagCompound.setString("text", text.getUnformattedText());
return tagCompound;
}

public static ActionBar fromCompound(NBTTagCompound tagCompound){
public static ActionBar fromCompound(NBTTagCompound tagCompound) {
return new ActionBar(
tagCompound.getInteger("time"),
new ChatComponentText(tagCompound.getString("text"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@

public class ActionBarManager {

public void set(HashSet<UUID> players, ActionBar tab){
public void set(HashSet<UUID> players, ActionBar tab) {
deliver(players, new ActionBarPacket(tab, ActionBarPacket.PacketType.SET));
}

public void remove(HashSet<UUID> players){
public void remove(HashSet<UUID> players) {
deliver(players, new ActionBarPacket(
new ActionBar(0, new ChatComponentText("")),
ActionBarPacket.PacketType.REMOVE)
);
}

private void deliver(HashSet<UUID> players, ActionBarPacket packet){
for(UUID uuid : players){
private void deliver(HashSet<UUID> players, ActionBarPacket packet) {
for (UUID uuid : players) {
EntityPlayerMP entityPlayerMP = ServerUtils.getPlayer(uuid);
if(entityPlayerMP != null)
if (entityPlayerMP != null)
NecroTempus.DISPATCHER.sendTo(packet, entityPlayerMP);
}
}

public static PlayerTabManager commonInstance(){
public static PlayerTabManager commonInstance() {
return new PlayerTabManager();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

import static io.github.cruciblemc.necrotempus.api.bossbar.BossBarManager.commonInstance;

public class BossBar extends BossBarComponent{
public class BossBar extends BossBarComponent {

@Getter @Setter
@Getter
@Setter
private static BossBarManager BossBarManager = commonInstance();

private BossBar() {
Expand All @@ -22,27 +23,27 @@ private BossBar(UUID uuid) {
super(uuid);
}

private BossBar(NBTTagCompound tagCompound){
private BossBar(NBTTagCompound tagCompound) {
super(tagCompound);
}

private BossBar(UUID uuid, ChatComponentText text, BossBarColor color, BossBarType type, Float percent, boolean isVisible){
private BossBar(UUID uuid, ChatComponentText text, BossBarColor color, BossBarType type, Float percent, boolean isVisible) {
super(uuid, text, color, type, percent, isVisible);
}

public static BossBar createBossBar(){
public static BossBar createBossBar() {
return new BossBar();
}

public static BossBar createBossBar(UUID uuid){
public static BossBar createBossBar(UUID uuid) {
return new BossBar(uuid);
}

public static BossBar createBossBar(NBTTagCompound nbtTagCompound){
public static BossBar createBossBar(NBTTagCompound nbtTagCompound) {
return new BossBar(nbtTagCompound);
}

public static BossBar createBossBar(UUID uuid, ChatComponentText text, BossBarColor color, BossBarType type, Float percent, boolean isVisible){
public static BossBar createBossBar(UUID uuid, ChatComponentText text, BossBarColor color, BossBarType type, Float percent, boolean isVisible) {
return new BossBar(uuid, text, color, type, percent, isVisible);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@

public enum BossBarColor {

PINK( "pink", 15466679 ),
BLUE( "blue", 47084 ),
RED( "red", 15480064 ),
GREEN( "green", 1960960 ),
YELLOW( "yellow", 15264768 ),
PURPLE( "purple", 8061164 ),
WHITE( "white", 16777215 ),
LAZY( "lazy", 47084 );
PINK("pink", 15466679),
BLUE("blue", 47084),
RED("red", 15480064),
GREEN("green", 1960960),
YELLOW("yellow", 15264768),
PURPLE("purple", 8061164),
WHITE("white", 16777215),
LAZY("lazy", 47084);

private final String identifier;
private int color;

BossBarColor(String colorIdentifier, int color){
BossBarColor(String colorIdentifier, int color) {
this.identifier = colorIdentifier;
this.color = color;
}

public static BossBarColor lazyOf(int color){
public static BossBarColor lazyOf(int color) {
BossBarColor barColor = LAZY;
barColor.color = color;
return barColor;
}

public static BossBarColor lazyOf(String color){
public static BossBarColor lazyOf(String color) {
BossBarColor barColor = LAZY;
barColor.color = ColorUtils.decodeColor(color).getRGB();
return barColor;
Expand All @@ -42,14 +42,14 @@ public String getIdentifier() {
return identifier;
}

public static BossBarColor valueOfString(String name){
public static BossBarColor valueOfString(String name) {

if(name.startsWith("$")){
if (name.startsWith("$")) {
return lazyOf(Integer.parseInt(name.substring(1)));
}

for(BossBarColor type : values()){
if(type.identifier.equalsIgnoreCase(name)){
for (BossBarColor type : values()) {
if (type.identifier.equalsIgnoreCase(name)) {
return type;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class BossBarComponent extends TimedElement {

private int lazyColor = -1;

protected BossBarComponent(NBTTagCompound nbtTagCompound){
protected BossBarComponent(NBTTagCompound nbtTagCompound) {
this.uuid = UUID.fromString(nbtTagCompound.getString("uuid"));
this.text = new ChatComponentText(nbtTagCompound.getString("text"));
this.type = BossBarType.valueOfString(nbtTagCompound.getString("type"));
Expand All @@ -32,15 +32,15 @@ protected BossBarComponent(NBTTagCompound nbtTagCompound){
this.percentage = nbtTagCompound.getFloat("percentage");
}

protected BossBarComponent(UUID uuid){
protected BossBarComponent(UUID uuid) {
this(uuid, new ChatComponentText(""), BossBarColor.PINK, BossBarType.FLAT, 1F, true);
}

protected BossBarComponent(){
protected BossBarComponent() {
this(UUID.randomUUID());
}

protected BossBarComponent(UUID uuid, ChatComponentText text, BossBarColor color, BossBarType type, Float percent,boolean isVisible){
protected BossBarComponent(UUID uuid, ChatComponentText text, BossBarColor color, BossBarType type, Float percent, boolean isVisible) {
this.uuid = uuid;
this.text = text;
this.type = type;
Expand All @@ -49,20 +49,20 @@ protected BossBarComponent(UUID uuid, ChatComponentText text, BossBarColor color
this.isVisible = isVisible;
}

public NBTTagCompound toNbt(){
public NBTTagCompound toNbt() {

NBTTagCompound nbtTagCompound = new NBTTagCompound();

nbtTagCompound.setString( "text", text.getChatComponentText_TextValue());
nbtTagCompound.setString( "type", type.getType());
nbtTagCompound.setFloat( "percentage", percentage);
nbtTagCompound.setBoolean( "isVisible", isVisible);
nbtTagCompound.setString( "uuid", uuid.toString());
nbtTagCompound.setString("text", text.getChatComponentText_TextValue());
nbtTagCompound.setString("type", type.getType());
nbtTagCompound.setFloat("percentage", percentage);
nbtTagCompound.setBoolean("isVisible", isVisible);
nbtTagCompound.setString("uuid", uuid.toString());

if(color == BossBarColor.LAZY){
nbtTagCompound.setString( "color", "$" + color.intValue());
}else{
nbtTagCompound.setString( "color", color.getIdentifier());
if (color == BossBarColor.LAZY) {
nbtTagCompound.setString("color", "$" + color.intValue());
} else {
nbtTagCompound.setString("color", color.getIdentifier());
}

return nbtTagCompound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,56 @@

public abstract class BossBarManager {

public static BossBarManager commonInstance(){
public static BossBarManager commonInstance() {
return new BossBarManager() {

@Override
public void add(UUID target, BossBar bossBar) {}
public void add(UUID target, BossBar bossBar) {
}

@Override
public void remove(BossBar bossBar) {}
public void remove(BossBar bossBar) {
}

@Override
public void remove(UUID target, BossBar bossBar) {}
public void remove(UUID target, BossBar bossBar) {
}

};
}

private static final LinkedHashMap<UUID,HashSet<UUID>> players = new LinkedHashMap<>();
private static final LinkedHashMap<UUID, HashSet<UUID>> players = new LinkedHashMap<>();

public Set<UUID> getPlayers(BossBar bossBar) {
return getOrCreatePlayers(bossBar);
}

public boolean hasPlayer(BossBar bossBar, UUID player){
public boolean hasPlayer(BossBar bossBar, UUID player) {
return getPlayers(bossBar).contains(player);
}

public boolean hasPlayers(BossBar bossBar){
public boolean hasPlayers(BossBar bossBar) {
return !getPlayers(bossBar).isEmpty();
}

public void removePlayer(UUID player, BossBar bossBar){
public void removePlayer(UUID player, BossBar bossBar) {
getPlayers(bossBar).remove(player);
remove(player, bossBar);
}

public void addPlayer(UUID player, BossBar bossBar){
public void addPlayer(UUID player, BossBar bossBar) {
getPlayers(bossBar).add(player);
add(player, bossBar);
}

public void removeAllPlayers(BossBar bossBar){
public void removeAllPlayers(BossBar bossBar) {
getPlayers(bossBar).clear();
remove(bossBar);
}

private Set<UUID> getOrCreatePlayers(BossBar bossBar){
private Set<UUID> getOrCreatePlayers(BossBar bossBar) {

if(!players.containsKey(bossBar.getUuid())){
if (!players.containsKey(bossBar.getUuid())) {
players.put(bossBar.getUuid(), new HashSet<>());
}

Expand All @@ -66,12 +69,12 @@ private Set<UUID> getOrCreatePlayers(BossBar bossBar){

public abstract void remove(UUID target, BossBar bossBar);

public void deliver(Set<UUID> players, Object packet){
public void deliver(Set<UUID> players, Object packet) {

}

public final void sync(BossBar bossBar){
for(UUID uuid : getPlayers(bossBar))
public final void sync(BossBar bossBar) {
for (UUID uuid : getPlayers(bossBar))
add(uuid, bossBar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public String getType() {
return type;
}

BossBarType(String type){
BossBarType(String type) {
this.type = type;
}

public static BossBarType valueOfString(String name){
public static BossBarType valueOfString(String name) {

String fName = name.toLowerCase().replaceAll("segmented", "notched"); // if segmented -> notched
fName = fName.replaceAll("solid", "flat"); // if solid -> flat

for(BossBarType type : values()){
if(type.getType().equalsIgnoreCase(fName)){
for (BossBarType type : values()) {
if (type.getType().equalsIgnoreCase(fName)) {
return type;
}
}
Expand Down
Loading

0 comments on commit d433825

Please sign in to comment.