aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch278
1 files changed, 278 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch
new file mode 100644
index 0000000000..5b80bb621b
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch
@@ -0,0 +1,278 @@
+--- a/net/minecraft/server/bossevents/CustomBossEvent.java
++++ b/net/minecraft/server/bossevents/CustomBossEvent.java
+@@ -17,6 +17,10 @@
+ import net.minecraft.server.level.ServerPlayer;
+ import net.minecraft.util.Mth;
+ import net.minecraft.world.BossEvent;
++// CraftBukkit start
++import org.bukkit.boss.KeyedBossBar;
++import org.bukkit.craftbukkit.boss.CraftKeyedBossbar;
++// CraftBukkit end
+
+ public class CustomBossEvent extends ServerBossEvent {
+
+@@ -24,10 +28,20 @@
+ private final Set<UUID> players = Sets.newHashSet();
+ private int value;
+ private int max = 100;
++ // CraftBukkit start
++ private KeyedBossBar bossBar;
+
+- public CustomBossEvent(ResourceLocation resourcelocation, Component component) {
+- super(component, BossEvent.BossBarColor.WHITE, BossEvent.BossBarOverlay.PROGRESS);
+- this.id = resourcelocation;
++ public KeyedBossBar getBukkitEntity() {
++ if (bossBar == null) {
++ bossBar = new CraftKeyedBossbar(this);
++ }
++ return bossBar;
++ }
++ // CraftBukkit end
++
++ public CustomBossEvent(ResourceLocation id, Component name) {
++ super(name, BossEvent.BossBarColor.WHITE, BossEvent.BossBarOverlay.PROGRESS);
++ this.id = id;
+ this.setProgress(0.0F);
+ }
+
+@@ -36,25 +50,22 @@
+ }
+
+ @Override
+- @Override
+- public void addPlayer(ServerPlayer serverplayer) {
+- super.addPlayer(serverplayer);
+- this.players.add(serverplayer.getUUID());
++ public void addPlayer(ServerPlayer player) {
++ super.addPlayer(player);
++ this.players.add(player.getUUID());
+ }
+
+- public void addOfflinePlayer(UUID uuid) {
+- this.players.add(uuid);
++ public void addOfflinePlayer(UUID player) {
++ this.players.add(player);
+ }
+
+ @Override
+- @Override
+- public void removePlayer(ServerPlayer serverplayer) {
+- super.removePlayer(serverplayer);
+- this.players.remove(serverplayer.getUUID());
++ public void removePlayer(ServerPlayer player) {
++ super.removePlayer(player);
++ this.players.remove(player.getUUID());
+ }
+
+ @Override
+- @Override
+ public void removeAllPlayers() {
+ super.removeAllPlayers();
+ this.players.clear();
+@@ -68,23 +79,23 @@
+ return this.max;
+ }
+
+- public void setValue(int i) {
+- this.value = i;
+- this.setProgress(Mth.clamp((float) i / (float) this.max, 0.0F, 1.0F));
++ public void setValue(int value) {
++ this.value = value;
++ this.setProgress(Mth.clamp((float) value / (float) this.max, 0.0F, 1.0F));
+ }
+
+- public void setMax(int i) {
+- this.max = i;
+- this.setProgress(Mth.clamp((float) this.value / (float) i, 0.0F, 1.0F));
++ public void setMax(int max) {
++ this.max = max;
++ this.setProgress(Mth.clamp((float) this.value / (float) max, 0.0F, 1.0F));
+ }
+
+ public final Component getDisplayName() {
+- return ComponentUtils.wrapInSquareBrackets(this.getName()).withStyle((style) -> {
+- return style.withColor(this.getColor().getFormatting()).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(this.getTextId().toString()))).withInsertion(this.getTextId().toString());
++ return ComponentUtils.wrapInSquareBrackets(this.getName()).withStyle((chatmodifier) -> {
++ return chatmodifier.withColor(this.getColor().getFormatting()).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(this.getTextId().toString()))).withInsertion(this.getTextId().toString());
+ });
+ }
+
+- public boolean setPlayers(Collection<ServerPlayer> collection) {
++ public boolean setPlayers(Collection<ServerPlayer> serverPlayerList) {
+ Set<UUID> set = Sets.newHashSet();
+ Set<ServerPlayer> set1 = Sets.newHashSet();
+ Iterator iterator = this.players.iterator();
+@@ -96,13 +107,13 @@
+ while (iterator.hasNext()) {
+ uuid = (UUID) iterator.next();
+ flag = false;
+- iterator1 = collection.iterator();
++ iterator1 = serverPlayerList.iterator();
+
+ while (true) {
+ if (iterator1.hasNext()) {
+- ServerPlayer serverplayer = (ServerPlayer) iterator1.next();
++ ServerPlayer entityplayer = (ServerPlayer) iterator1.next();
+
+- if (!serverplayer.getUUID().equals(uuid)) {
++ if (!entityplayer.getUUID().equals(uuid)) {
+ continue;
+ }
+
+@@ -116,12 +127,12 @@
+ }
+ }
+
+- iterator = collection.iterator();
++ iterator = serverPlayerList.iterator();
+
+- ServerPlayer serverplayer1;
++ ServerPlayer entityplayer1;
+
+ while (iterator.hasNext()) {
+- serverplayer1 = (ServerPlayer) iterator.next();
++ entityplayer1 = (ServerPlayer) iterator.next();
+ flag = false;
+ iterator1 = this.players.iterator();
+
+@@ -129,7 +140,7 @@
+ if (iterator1.hasNext()) {
+ UUID uuid1 = (UUID) iterator1.next();
+
+- if (!serverplayer1.getUUID().equals(uuid1)) {
++ if (!entityplayer1.getUUID().equals(uuid1)) {
+ continue;
+ }
+
+@@ -137,7 +148,7 @@
+ }
+
+ if (!flag) {
+- set1.add(serverplayer1);
++ set1.add(entityplayer1);
+ }
+ break;
+ }
+@@ -151,13 +162,13 @@
+
+ while (true) {
+ if (iterator2.hasNext()) {
+- ServerPlayer serverplayer2 = (ServerPlayer) iterator2.next();
++ ServerPlayer entityplayer2 = (ServerPlayer) iterator2.next();
+
+- if (!serverplayer2.getUUID().equals(uuid)) {
++ if (!entityplayer2.getUUID().equals(uuid)) {
+ continue;
+ }
+
+- this.removePlayer(serverplayer2);
++ this.removePlayer(entityplayer2);
+ }
+
+ this.players.remove(uuid);
+@@ -168,69 +179,69 @@
+ iterator = set1.iterator();
+
+ while (iterator.hasNext()) {
+- serverplayer1 = (ServerPlayer) iterator.next();
+- this.addPlayer(serverplayer1);
++ entityplayer1 = (ServerPlayer) iterator.next();
++ this.addPlayer(entityplayer1);
+ }
+
+ return !set.isEmpty() || !set1.isEmpty();
+ }
+
+ public CompoundTag save() {
+- CompoundTag compoundtag = new CompoundTag();
++ CompoundTag nbttagcompound = new CompoundTag();
+
+- compoundtag.putString("Name", Component.Serializer.toJson(this.name));
+- compoundtag.putBoolean("Visible", this.isVisible());
+- compoundtag.putInt("Value", this.value);
+- compoundtag.putInt("Max", this.max);
+- compoundtag.putString("Color", this.getColor().getName());
+- compoundtag.putString("Overlay", this.getOverlay().getName());
+- compoundtag.putBoolean("DarkenScreen", this.shouldDarkenScreen());
+- compoundtag.putBoolean("PlayBossMusic", this.shouldPlayBossMusic());
+- compoundtag.putBoolean("CreateWorldFog", this.shouldCreateWorldFog());
+- ListTag listtag = new ListTag();
++ nbttagcompound.putString("Name", Component.Serializer.toJson(this.name));
++ nbttagcompound.putBoolean("Visible", this.isVisible());
++ nbttagcompound.putInt("Value", this.value);
++ nbttagcompound.putInt("Max", this.max);
++ nbttagcompound.putString("Color", this.getColor().getName());
++ nbttagcompound.putString("Overlay", this.getOverlay().getName());
++ nbttagcompound.putBoolean("DarkenScreen", this.shouldDarkenScreen());
++ nbttagcompound.putBoolean("PlayBossMusic", this.shouldPlayBossMusic());
++ nbttagcompound.putBoolean("CreateWorldFog", this.shouldCreateWorldFog());
++ ListTag nbttaglist = new ListTag();
+ Iterator iterator = this.players.iterator();
+
+ while (iterator.hasNext()) {
+ UUID uuid = (UUID) iterator.next();
+
+- listtag.add(NbtUtils.createUUID(uuid));
++ nbttaglist.add(NbtUtils.createUUID(uuid));
+ }
+
+- compoundtag.put("Players", listtag);
+- return compoundtag;
++ nbttagcompound.put("Players", nbttaglist);
++ return nbttagcompound;
+ }
+
+- public static CustomBossEvent load(CompoundTag compoundtag, ResourceLocation resourcelocation) {
+- CustomBossEvent custombossevent = new CustomBossEvent(resourcelocation, Component.Serializer.fromJson(compoundtag.getString("Name")));
++ public static CustomBossEvent load(CompoundTag nbt, ResourceLocation id) {
++ CustomBossEvent bossbattlecustom = new CustomBossEvent(id, Component.Serializer.fromJson(nbt.getString("Name")));
+
+- custombossevent.setVisible(compoundtag.getBoolean("Visible"));
+- custombossevent.setValue(compoundtag.getInt("Value"));
+- custombossevent.setMax(compoundtag.getInt("Max"));
+- custombossevent.setColor(BossEvent.BossBarColor.byName(compoundtag.getString("Color")));
+- custombossevent.setOverlay(BossEvent.BossBarOverlay.byName(compoundtag.getString("Overlay")));
+- custombossevent.setDarkenScreen(compoundtag.getBoolean("DarkenScreen"));
+- custombossevent.setPlayBossMusic(compoundtag.getBoolean("PlayBossMusic"));
+- custombossevent.setCreateWorldFog(compoundtag.getBoolean("CreateWorldFog"));
+- ListTag listtag = compoundtag.getList("Players", 11);
+- Iterator iterator = listtag.iterator();
++ bossbattlecustom.setVisible(nbt.getBoolean("Visible"));
++ bossbattlecustom.setValue(nbt.getInt("Value"));
++ bossbattlecustom.setMax(nbt.getInt("Max"));
++ bossbattlecustom.setColor(BossEvent.BossBarColor.byName(nbt.getString("Color")));
++ bossbattlecustom.setOverlay(BossEvent.BossBarOverlay.byName(nbt.getString("Overlay")));
++ bossbattlecustom.setDarkenScreen(nbt.getBoolean("DarkenScreen"));
++ bossbattlecustom.setPlayBossMusic(nbt.getBoolean("PlayBossMusic"));
++ bossbattlecustom.setCreateWorldFog(nbt.getBoolean("CreateWorldFog"));
++ ListTag nbttaglist = nbt.getList("Players", 11);
++ Iterator iterator = nbttaglist.iterator();
+
+ while (iterator.hasNext()) {
+- Tag tag = (Tag) iterator.next();
++ Tag nbtbase = (Tag) iterator.next();
+
+- custombossevent.addOfflinePlayer(NbtUtils.loadUUID(tag));
++ bossbattlecustom.addOfflinePlayer(NbtUtils.loadUUID(nbtbase));
+ }
+
+- return custombossevent;
++ return bossbattlecustom;
+ }
+
+- public void onPlayerConnect(ServerPlayer serverplayer) {
+- if (this.players.contains(serverplayer.getUUID())) {
+- this.addPlayer(serverplayer);
++ public void onPlayerConnect(ServerPlayer player) {
++ if (this.players.contains(player.getUUID())) {
++ this.addPlayer(player);
+ }
+
+ }
+
+- public void onPlayerDisconnect(ServerPlayer serverplayer) {
+- super.removePlayer(serverplayer);
++ public void onPlayerDisconnect(ServerPlayer player) {
++ super.removePlayer(player);
+ }
+ }