aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch270
1 files changed, 270 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch
new file mode 100644
index 0000000000..e23c45c318
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/bossevents/CustomBossEvent.java.patch
@@ -0,0 +1,270 @@
+--- a/net/minecraft/server/bossevents/CustomBossEvent.java
++++ b/net/minecraft/server/bossevents/CustomBossEvent.java
+@@ -2,6 +2,7 @@
+
+ import com.google.common.collect.Sets;
+ import java.util.Collection;
++import java.util.Iterator;
+ import java.util.Set;
+ import java.util.UUID;
+ import net.minecraft.nbt.CompoundTag;
+@@ -11,19 +12,33 @@
+ import net.minecraft.network.chat.Component;
+ import net.minecraft.network.chat.ComponentUtils;
+ import net.minecraft.network.chat.HoverEvent;
+-import net.minecraft.network.chat.Style;
+ import net.minecraft.resources.ResourceLocation;
+ import net.minecraft.server.level.ServerBossEvent;
+ 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 {
++
+ private final ResourceLocation id;
+ private final Set<UUID> players = Sets.newHashSet();
+ private int value;
+ private int max = 100;
++ // CraftBukkit start
++ private KeyedBossBar bossBar;
+
++ 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;
+@@ -66,118 +81,164 @@
+
+ public void setValue(int value) {
+ this.value = value;
+- this.setProgress(Mth.clamp((float)value / (float)this.max, 0.0F, 1.0F));
++ this.setProgress(Mth.clamp((float) value / (float) this.max, 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));
++ this.setProgress(Mth.clamp((float) this.value / (float) max, 0.0F, 1.0F));
+ }
+
+ public final Component getDisplayName() {
+- return ComponentUtils.wrapInSquareBrackets(this.getName())
+- .withStyle(
+- style -> 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> serverPlayerList) {
+ Set<UUID> set = Sets.newHashSet();
+ Set<ServerPlayer> set1 = Sets.newHashSet();
++ Iterator iterator = this.players.iterator();
+
+- for (UUID uUID : this.players) {
+- boolean flag = false;
++ UUID uuid;
++ boolean flag;
++ Iterator iterator1;
+
+- for (ServerPlayer serverPlayer : serverPlayerList) {
+- if (serverPlayer.getUUID().equals(uUID)) {
++ while (iterator.hasNext()) {
++ uuid = (UUID) iterator.next();
++ flag = false;
++ iterator1 = serverPlayerList.iterator();
++
++ while (true) {
++ if (iterator1.hasNext()) {
++ ServerPlayer entityplayer = (ServerPlayer) iterator1.next();
++
++ if (!entityplayer.getUUID().equals(uuid)) {
++ continue;
++ }
++
+ flag = true;
+- break;
+ }
+- }
+
+- if (!flag) {
+- set.add(uUID);
++ if (!flag) {
++ set.add(uuid);
++ }
++ break;
+ }
+ }
+
+- for (ServerPlayer serverPlayer1 : serverPlayerList) {
+- boolean flag = false;
++ iterator = serverPlayerList.iterator();
+
+- for (UUID uUID1 : this.players) {
+- if (serverPlayer1.getUUID().equals(uUID1)) {
++ ServerPlayer entityplayer1;
++
++ while (iterator.hasNext()) {
++ entityplayer1 = (ServerPlayer) iterator.next();
++ flag = false;
++ iterator1 = this.players.iterator();
++
++ while (true) {
++ if (iterator1.hasNext()) {
++ UUID uuid1 = (UUID) iterator1.next();
++
++ if (!entityplayer1.getUUID().equals(uuid1)) {
++ continue;
++ }
++
+ flag = true;
+- break;
+ }
+- }
+
+- if (!flag) {
+- set1.add(serverPlayer1);
++ if (!flag) {
++ set1.add(entityplayer1);
++ }
++ break;
+ }
+ }
+
+- for (UUID uUID : set) {
+- for (ServerPlayer serverPlayer2 : this.getPlayers()) {
+- if (serverPlayer2.getUUID().equals(uUID)) {
+- this.removePlayer(serverPlayer2);
+- break;
++ iterator = set.iterator();
++
++ while (iterator.hasNext()) {
++ uuid = (UUID) iterator.next();
++ Iterator iterator2 = this.getPlayers().iterator();
++
++ while (true) {
++ if (iterator2.hasNext()) {
++ ServerPlayer entityplayer2 = (ServerPlayer) iterator2.next();
++
++ if (!entityplayer2.getUUID().equals(uuid)) {
++ continue;
++ }
++
++ this.removePlayer(entityplayer2);
+ }
+- }
+
+- this.players.remove(uUID);
++ this.players.remove(uuid);
++ break;
++ }
+ }
+
+- for (ServerPlayer serverPlayer1 : set1) {
+- this.addPlayer(serverPlayer1);
++ iterator = set1.iterator();
++
++ while (iterator.hasNext()) {
++ entityplayer1 = (ServerPlayer) iterator.next();
++ this.addPlayer(entityplayer1);
+ }
+
+ return !set.isEmpty() || !set1.isEmpty();
+ }
+
+ public CompoundTag save() {
+- CompoundTag compoundTag = 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 list = new ListTag();
++ CompoundTag nbttagcompound = new CompoundTag();
+
+- for (UUID uUID : this.players) {
+- list.add(NbtUtils.createUUID(uUID));
++ 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();
++
++ nbttaglist.add(NbtUtils.createUUID(uuid));
+ }
+
+- compoundTag.put("Players", list);
+- return compoundTag;
++ nbttagcompound.put("Players", nbttaglist);
++ return nbttagcompound;
+ }
+
+ public static CustomBossEvent load(CompoundTag nbt, ResourceLocation id) {
+- CustomBossEvent customBossEvent = new CustomBossEvent(id, Component.Serializer.fromJson(nbt.getString("Name")));
+- customBossEvent.setVisible(nbt.getBoolean("Visible"));
+- customBossEvent.setValue(nbt.getInt("Value"));
+- customBossEvent.setMax(nbt.getInt("Max"));
+- customBossEvent.setColor(BossEvent.BossBarColor.byName(nbt.getString("Color")));
+- customBossEvent.setOverlay(BossEvent.BossBarOverlay.byName(nbt.getString("Overlay")));
+- customBossEvent.setDarkenScreen(nbt.getBoolean("DarkenScreen"));
+- customBossEvent.setPlayBossMusic(nbt.getBoolean("PlayBossMusic"));
+- customBossEvent.setCreateWorldFog(nbt.getBoolean("CreateWorldFog"));
++ CustomBossEvent bossbattlecustom = new CustomBossEvent(id, Component.Serializer.fromJson(nbt.getString("Name")));
+
+- for (Tag tag : nbt.getList("Players", 11)) {
+- customBossEvent.addOfflinePlayer(NbtUtils.loadUUID(tag));
++ 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 nbtbase = (Tag) iterator.next();
++
++ bossbattlecustom.addOfflinePlayer(NbtUtils.loadUUID(nbtbase));
+ }
+
+- return customBossEvent;
++ return bossbattlecustom;
+ }
+
+ public void onPlayerConnect(ServerPlayer player) {
+ if (this.players.contains(player.getUUID())) {
+ this.addPlayer(player);
+ }
++
+ }
+
+ public void onPlayerDisconnect(ServerPlayer player) {