diff --git a/gradle.properties b/gradle.properties index a450eab..6d1d608 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -group = net.sparklypower +group = net.sparklypower.sparklypaper version = 1.17-R0.1-SNAPSHOT mcVersion = 1.17 packageVersion = 1_17_R1 -tuinityRef = 357d4e9755d5d4d2c1199e2594589e4e26090a7b +tuinityRef = d3a0c9bdacb75e9e87cf70adb3bfac492f037f2d org.gradle.jvmargs=-Xmx2G diff --git a/patches/api/0001-Fix-NotePlayEvent.patch b/patches/api/0001-Fix-NotePlayEvent.patch new file mode 100644 index 0000000..a474627 --- /dev/null +++ b/patches/api/0001-Fix-NotePlayEvent.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kieran Wallbanks +Date: Mon, 21 Jun 2021 12:33:45 +0100 +Subject: [PATCH] Fix NotePlayEvent + + +diff --git a/src/main/java/org/bukkit/event/block/NotePlayEvent.java b/src/main/java/org/bukkit/event/block/NotePlayEvent.java +index a3887067d1b65fb100ac1407a43c455f5d215510..676b31f6f38d4e85cd4bd16ccf42cbc39a5d8423 100644 +--- a/src/main/java/org/bukkit/event/block/NotePlayEvent.java ++++ b/src/main/java/org/bukkit/event/block/NotePlayEvent.java +@@ -58,9 +58,7 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { + * Overrides the {@link Instrument} to be used. + * + * @param instrument the Instrument. Has no effect if null. +- * @deprecated no effect on newer Minecraft versions + */ +- @Deprecated + public void setInstrument(@NotNull Instrument instrument) { + if (instrument != null) { + this.instrument = instrument; +@@ -71,9 +69,7 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { + * Overrides the {@link Note} to be played. + * + * @param note the Note. Has no effect if null. +- * @deprecated no effect on newer Minecraft versions + */ +- @Deprecated + public void setNote(@NotNull Note note) { + if (note != null) { + this.note = note; diff --git a/patches/api/0002-More-note-block-events.patch b/patches/api/0002-More-note-block-events.patch new file mode 100644 index 0000000..17c6dad --- /dev/null +++ b/patches/api/0002-More-note-block-events.patch @@ -0,0 +1,142 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kieran Wallbanks +Date: Thu, 11 Feb 2021 13:16:44 +0000 +Subject: [PATCH] More note block events + + +diff --git a/src/main/java/ml/beancraft/haricot/event/block/NoteBlockPlaceEvent.java b/src/main/java/ml/beancraft/haricot/event/block/NoteBlockPlaceEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..2a22bb7c80884bde59cafaff2b50f99d44504998 +--- /dev/null ++++ b/src/main/java/ml/beancraft/haricot/event/block/NoteBlockPlaceEvent.java +@@ -0,0 +1,44 @@ ++package ml.beancraft.haricot.event.block; ++ ++import org.bukkit.block.Block; ++import org.bukkit.block.data.type.NoteBlock; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.block.BlockEvent; ++import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.NotNull; ++ ++public class NoteBlockPlaceEvent extends BlockEvent { ++ private static final HandlerList handlers = new HandlerList(); ++ ++ private final ItemStack itemInHand; ++ private NoteBlock data; ++ ++ public NoteBlockPlaceEvent(@NotNull Block block, @NotNull NoteBlock data, @NotNull ItemStack itemInHand) { ++ super(block); ++ this.data = data; ++ this.itemInHand = itemInHand; ++ } ++ ++ public @NotNull ItemStack getItemInHand() { ++ return itemInHand; ++ } ++ ++ public @NotNull NoteBlock getData() { ++ return data; ++ } ++ ++ public void setData(@NotNull NoteBlock data) { ++ this.data = data; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/ml/beancraft/haricot/event/block/NoteBlockUpdateEvent.java b/src/main/java/ml/beancraft/haricot/event/block/NoteBlockUpdateEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..c1d8b37cb43d09244014963eb73f64e816d2b1cb +--- /dev/null ++++ b/src/main/java/ml/beancraft/haricot/event/block/NoteBlockUpdateEvent.java +@@ -0,0 +1,80 @@ ++package ml.beancraft.haricot.event.block; ++ ++import org.apache.commons.lang.Validate; ++import org.bukkit.block.Block; ++import org.bukkit.block.data.type.NoteBlock; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.block.BlockEvent; ++import org.jetbrains.annotations.NotNull; ++ ++/** ++ * Called when the data of a note block changes. Note that this may not be called for ++ * every note block update and might be called multiple times for one cause. ++ */ ++public class NoteBlockUpdateEvent extends BlockEvent implements Cancellable { ++ private static final HandlerList handlers = new HandlerList(); ++ ++ private final NoteBlock oldData; ++ private NoteBlock newData; ++ private boolean cancelled; ++ ++ /** ++ * Constructs a new note block update event. ++ * @param theBlock the block that is being updated ++ * @param oldData the data the block had before the update ++ * @param newData the data this block is going to have after the update ++ */ ++ public NoteBlockUpdateEvent(@NotNull Block theBlock, @NotNull NoteBlock oldData, @NotNull NoteBlock newData) { ++ super(theBlock); ++ this.oldData = oldData; ++ this.newData = newData; ++ this.cancelled = false; ++ } ++ ++ /** ++ * Gets the data of the note block before the update. ++ * @return the data ++ */ ++ public @NotNull NoteBlock getOldData() { ++ return this.oldData; ++ } ++ ++ /** ++ * Gets the data that the note block will have after this event. ++ * @return the data ++ */ ++ public @NotNull NoteBlock getNewData() { ++ return this.newData; ++ } ++ ++ /** ++ * Sets the data that the note block will have after this event. ++ * @param data the data ++ */ ++ public void setNewData(@NotNull NoteBlock data) { ++ Validate.notNull(data, "Data cannot be null"); ++ this.newData = data; ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} diff --git a/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper.patch b/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper.patch new file mode 100644 index 0000000..6414a14 --- /dev/null +++ b/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Wed, 23 Jun 2021 21:07:43 -0300 +Subject: [PATCH] new fork who dis - Rebrand to SparklyPaper + + +diff --git a/build.gradle.kts b/build.gradle.kts +index ab8de6c4e3c0bea2b9f498da00adf88e987d2364..8fc6315cf8afa10866f7a15c7a02f0d88f113007 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -36,7 +36,7 @@ repositories { + } + + dependencies { +- implementation(project(":Tuinity-API")) // Tuinity ++ implementation(project(":SparklyPaper-API")) // SparklyPaper + implementation("com.destroystokyo.paper:paper-mojangapi:1.16.5-R0.1-SNAPSHOT") // Tuinity + // Paper start + implementation("org.jline:jline-terminal-jansi:3.12.1") +@@ -88,7 +88,7 @@ tasks.jar { + attributes( + "Main-Class" to "org.bukkit.craftbukkit.Main", + "Implementation-Title" to "CraftBukkit", +- "Implementation-Version" to "git-Tuinity-$implementationVersion", // Tuinity ++ "Implementation-Version" to "git-SparklyPaper-$implementationVersion", // SparklyPaper + "Implementation-Vendor" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date()), // Paper + "Specification-Title" to "Bukkit", + "Specification-Version" to project.version, +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index f3bf6270c7735869083559f907c65d95144dbe6f..c16b276f69b6a2302dc52e3d10df1f4c825ff097 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -1714,7 +1714,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! ++ return "SparklyPaper"; // SparklyPaper - SparklyPaper > // Tuinity - Tuinity > //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! + } + + public SystemReport fillSystemReport(SystemReport systemreport) { +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index 130a088e694b85f7d56620352f044161ea56caf3..29eb6d5c43871ef7d6479864178e3b6e015903f8 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -230,7 +230,7 @@ import javax.annotation.Nullable; // Paper + import javax.annotation.Nonnull; // Paper + + public final class CraftServer implements Server { +- private final String serverName = "Tuinity"; // Tuinity // Paper ++ private final String serverName = "SparklyPaper"; // SparklyPaper // Tuinity // Paper + private final String serverVersion; + private final String bukkitVersion = Versioning.getBukkitVersion(); + private final Logger logger = Logger.getLogger("Minecraft"); +diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +index 001b1e5197eaa51bfff9031aa6c69876c9a47960..5f8a74e5edaac1c5f158513a54d4d60eff737875 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +@@ -11,7 +11,7 @@ public final class Versioning { + public static String getBukkitVersion() { + String result = "Unknown-Version"; + +- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/com.tuinity/tuinity-api/pom.properties"); // Tuinity ++ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/net.sparklypower.sparklypaper/sparklypaper-api/pom.properties"); // SparklyPaper // Tuinity + Properties properties = new Properties(); + + if (stream != null) { diff --git a/patches/server/0002-Add-Paperweight-1.1.6-bug-workaround.patch b/patches/server/0002-Add-Paperweight-1.1.6-bug-workaround.patch new file mode 100644 index 0000000..ba7303b --- /dev/null +++ b/patches/server/0002-Add-Paperweight-1.1.6-bug-workaround.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Sun, 4 Jul 2021 23:31:42 -0300 +Subject: [PATCH] Add Paperweight 1.1.6 bug workaround + + +diff --git a/build.gradle.kts b/build.gradle.kts +index 8fc6315cf8afa10866f7a15c7a02f0d88f113007..feb4e39df30aa62b1c45096a0dbff1de28477579 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -184,7 +184,7 @@ abstract class IncludeMappings : BaseTask() { + } + + val includeMappings = tasks.register("includeMappings") { +- inputJar.set(tasks.fixJarForReobf.flatMap { it.outputJar }) ++ inputJar.set(tasks.shadowJar.flatMap { it.archiveFile }) // SparklyPaper, from Airplane + mappings.set(tasks.reobfJar.flatMap { it.mappingsFile }) + } + diff --git a/patches/server/0003-Fix-NotePlayEvent.patch b/patches/server/0003-Fix-NotePlayEvent.patch new file mode 100644 index 0000000..78190ea --- /dev/null +++ b/patches/server/0003-Fix-NotePlayEvent.patch @@ -0,0 +1,117 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kieran Wallbanks +Date: Mon, 21 Jun 2021 14:23:50 +0100 +Subject: [PATCH] Fix NotePlayEvent + + +diff --git a/src/main/java/net/minecraft/world/level/block/NoteBlock.java b/src/main/java/net/minecraft/world/level/block/NoteBlock.java +index f8e58d9f71703139a736d93e7f1996e027a29444..253709d7194d47bd8fb9e976967fd1e84b92fd51 100644 +--- a/src/main/java/net/minecraft/world/level/block/NoteBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/NoteBlock.java +@@ -61,10 +61,9 @@ public class NoteBlock extends Block { + private void play(Level world, BlockPos blockposition, BlockState data) { // CraftBukkit + if (world.getBlockState(blockposition.above()).isAir()) { + // CraftBukkit start +- org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.getValue(NoteBlock.INSTRUMENT), data.getValue(NoteBlock.NOTE)); +- if (!event.isCancelled()) { ++ // Paper start - move NotePlayEvent call to fix instrument/note changes + world.blockEvent(blockposition, this, 0, 0); +- } ++ // Paper end + // CraftBukkit end + } + +@@ -93,10 +92,14 @@ public class NoteBlock extends Block { + + @Override + public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int type, int data) { +- int k = (Integer) state.getValue(NoteBlock.NOTE); ++ // Paper start - move NotePlayEvent call to fix instrument/note changes ++ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, pos, state.getValue(INSTRUMENT), state.getValue(NOTE)); ++ if (!event.callEvent()) return false; ++ int k = event.getNote().getId(); + float f = (float) Math.pow(2.0D, (double) (k - 12) / 12.0D); + +- world.playSound((Player) null, pos, ((NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT)).getSoundEvent(), SoundSource.RECORDS, 3.0F, f); ++ world.playSound(null, pos, org.bukkit.craftbukkit.util.CraftMagicNumbers.getNoteBlockInstrument(event.getInstrument()).getSoundEvent(), SoundSource.RECORDS, 3.0F, f); ++ // Paper end + world.addParticle(ParticleTypes.NOTE, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.2D, (double) pos.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D); + return true; + } +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index edf7e8d65d7f67f2f34490fdb766eca7d3b17aee..886ae3b042457a9eda62b8169270f050cde00d82 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -119,6 +119,7 @@ public final class CraftMagicNumbers implements UnsafeValues { + // Paper start + private static final Map> ENTITY_TYPE_ENTITY_TYPES = new HashMap<>(); + private static final Map, org.bukkit.entity.EntityType> ENTITY_TYPES_ENTITY_TYPE = new HashMap<>(); ++ private static final com.google.common.collect.BiMap INSTRUMENT_NOTE_BLOCK_INSTRUMENT = com.google.common.collect.EnumBiMap.create(org.bukkit.Instrument.class, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class); + + static { + for (org.bukkit.entity.EntityType type : org.bukkit.entity.EntityType.values()) { +@@ -126,6 +127,16 @@ public final class CraftMagicNumbers implements UnsafeValues { + ENTITY_TYPE_ENTITY_TYPES.put(type, net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()))); + ENTITY_TYPES_ENTITY_TYPE.put(net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())), type); + } ++ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.PIANO, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.HARP); ++ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.BASS_DRUM, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.BASEDRUM); ++ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.SNARE_DRUM, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.SNARE); ++ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.STICKS, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.HAT); ++ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.BASS_GUITAR, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.BASS); ++ for (org.bukkit.Instrument instrument : org.bukkit.Instrument.values()) { ++ if (!INSTRUMENT_NOTE_BLOCK_INSTRUMENT.containsKey(instrument)) { ++ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.valueOf(instrument.name())); ++ } ++ } + // Paper end + for (Block block : net.minecraft.core.Registry.BLOCK) { + BLOCK_MATERIAL.put(block, Material.getMaterial(net.minecraft.core.Registry.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT))); +@@ -199,6 +210,12 @@ public final class CraftMagicNumbers implements UnsafeValues { + public static org.bukkit.entity.EntityType getEntityType(net.minecraft.world.entity.EntityType entityTypes) { + return ENTITY_TYPES_ENTITY_TYPE.get(entityTypes); + } ++ public static net.minecraft.world.level.block.state.properties.NoteBlockInstrument getNoteBlockInstrument(org.bukkit.Instrument instrument) { ++ return INSTRUMENT_NOTE_BLOCK_INSTRUMENT.get(instrument); ++ } ++ public static org.bukkit.Instrument getInstrument(net.minecraft.world.level.block.state.properties.NoteBlockInstrument instrument) { ++ return INSTRUMENT_NOTE_BLOCK_INSTRUMENT.inverse().get(instrument); ++ } + // Paper end + // ======================================================================== + // Paper start +diff --git a/src/test/java/org/bukkit/InstrumentTest.java b/src/test/java/org/bukkit/InstrumentTest.java +new file mode 100644 +index 0000000000000000000000000000000000000000..f0847a52ca12bbd11f69b5d93bfde8ea39feb2ec +--- /dev/null ++++ b/src/test/java/org/bukkit/InstrumentTest.java +@@ -0,0 +1,29 @@ ++package org.bukkit; ++ ++import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; ++import org.bukkit.craftbukkit.util.CraftMagicNumbers; ++import org.junit.Test; ++ ++import static org.junit.Assert.assertNotNull; ++ ++public class InstrumentTest { ++ ++ @Test ++ public void testGetNoteBlockInstrument() { ++ // ensure there is a NoteBlockInstrument for each Instrument ++ for (Instrument instrument : Instrument.values()) { ++ NoteBlockInstrument noteBlockInstrument = CraftMagicNumbers.getNoteBlockInstrument(instrument); ++ assertNotNull("no NoteBlockInstrument for Instrument " + instrument.name(), noteBlockInstrument); ++ } ++ } ++ ++ @Test ++ public void testGetInstrument() { ++ // ensure there is an Instrument for each NoteBlockInstrument ++ for (NoteBlockInstrument noteBlockInstrument : NoteBlockInstrument.values()) { ++ Instrument instrument = CraftMagicNumbers.getInstrument(noteBlockInstrument); ++ assertNotNull("no Instrument for NoteBlockInstrument " + noteBlockInstrument.name(), instrument); ++ } ++ } ++ ++}