Skip to content

Commit

Permalink
drop old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulu13022002 committed Jan 6, 2025
1 parent b91d217 commit 7d4e855
Show file tree
Hide file tree
Showing 34 changed files with 41 additions and 958 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

/**
* Represents the applicable target for a {@link Enchantment}
*
* @deprecated enchantment groupings are now managed by tags, not categories
*/
@Deprecated(since = "1.20.5", forRemoval = true)
public enum EnchantmentTarget {
/**
* Allows the Enchantment to be placed on all items
Expand Down
2 changes: 1 addition & 1 deletion paper-api/src/main/java/org/bukkit/inventory/ItemType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3041,7 +3041,7 @@ private static <M extends ItemType> M getItemType(@NotNull String key) {
* Get the {@link CreativeCategory} to which this item type belongs.
*
* @return the creative category. null if does not belong to a category
* @deprecated creative categories no longer exist on the server
<!-- * @deprecated use #getCreativeCategories() -->
*/
@Nullable
@Deprecated(since = "1.20.6")
Expand Down
4 changes: 2 additions & 2 deletions paper-api/src/main/java/org/bukkit/map/MapPalette.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public static byte matchColor(@NotNull Color color) {
}
}

// Minecraft has 143 colors, some of which have negative byte representations
// Minecraft has 248 colors, some of which have negative byte representations
return (byte) (index < 128 ? index : -129 + (index - 127));
}

Expand All @@ -457,7 +457,7 @@ public static byte matchColor(@NotNull Color color) {
@Deprecated(since = "1.6.2", forRemoval = true) // Paper
@NotNull
public static Color getColor(byte index) {
// Minecraft has 143 colors, some of which have negative byte representations
// Minecraft has 248 colors, some of which have negative byte representations
return colors[index >= 0 ? index : index + 256];
}

Expand Down
60 changes: 0 additions & 60 deletions paper-api/src/test/java/org/bukkit/BukkitMirrorTest.java

This file was deleted.

14 changes: 0 additions & 14 deletions paper-api/src/test/java/org/bukkit/NamespacedKeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ public void testValidFromString() {
assertNull(NamespacedKey.fromString("foo:bar:bazz"));
}

@org.junit.jupiter.api.Disabled // Paper - Fixup NamespacedKey handling
@Test
public void testFromStringEmptyInput() {
assertThrows(IllegalArgumentException.class, () -> NamespacedKey.fromString(""));
}

@Test
public void testFromStringNullInput() {
assertThrows(IllegalArgumentException.class, () -> NamespacedKey.fromString(null));
Expand Down Expand Up @@ -75,12 +69,4 @@ public void testBelowLength() {
new NamespacedKey("loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas",
"loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas").toString();
}

@org.junit.jupiter.api.Disabled // Paper - Fixup NamespacedKey handling
@Test
public void testAboveLength() {
assertThrows(IllegalArgumentException.class, () -> new NamespacedKey("loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas",
"loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas/"
+ "loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas").toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -546,46 +546,6 @@ public void testIsVector() {
assertFalse(section.isVector("doesntExist"));
}

@Test
@org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server")
public void testGetItemStack_String() {
ConfigurationSection section = getConfigurationSection();
String key = "exists";
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);

section.set(key, value);

assertEquals(value, section.getItemStack(key));
assertNull(section.getString("doesntExist"));
}

@Test
@org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server")
public void testGetItemStack_String_ItemStack() {
ConfigurationSection section = getConfigurationSection();
String key = "exists";
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);
ItemStack def = new ItemStack(Material.STONE, 1);

section.set(key, value);

assertEquals(value, section.getItemStack(key, def));
assertEquals(def, section.getItemStack("doesntExist", def));
}

@Test
@org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server")
public void testIsItemStack() {
ConfigurationSection section = getConfigurationSection();
String key = "exists";
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);

section.set(key, value);

assertTrue(section.isItemStack(key));
assertFalse(section.isItemStack("doesntExist"));
}

@Test
public void testGetConfigurationSection() {
ConfigurationSection section = getConfigurationSection();
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions paper-generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ fun TaskContainer.registerGenerationTask(
val projectDirs = args.mapNotNull { project.rootProject.findProject(it)?.projectDir }
if (projectDirs.isNotEmpty()) {
args(projectDirs)
systemProperty("paper.updatingMinecraft", providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean())
if (rewrite) {
systemProperty("typewriter.lexer.ignoreMarkdownDocComments", true)
inputs.files(projectDirs.map { it.resolve("src/main/java") })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package io.papermc.generator.rewriter.types.simple;

import com.mojang.logging.LogUtils;
import io.papermc.typewriter.replace.SearchMetadata;
import io.papermc.typewriter.replace.SearchReplaceRewriter;
import java.awt.Color;
import net.minecraft.world.level.material.MapColor;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;

public class MapPaletteRewriter extends SearchReplaceRewriter {

private static final Logger LOGGER = LogUtils.getLogger();
private static final boolean UPDATING = Boolean.getBoolean("paper.updatingMinecraft");

@Override
protected void insert(SearchMetadata metadata, StringBuilder builder) {
int count = 0;
for (@Nullable MapColor mapColor : MapColor.MATERIAL_COLORS) {
if (mapColor == null) {
continue;
Expand All @@ -24,7 +30,12 @@ protected void insert(SearchMetadata metadata, StringBuilder builder) {
builder.append("new %s(0x%06X),".formatted(color.getClass().getSimpleName(), color.getRGB() & 0x00FFFFFF));
}
builder.append('\n');
count++;
}
}

if (UPDATING) {
LOGGER.warn("There are {} map colors, check CraftMapView#render for possible change and update md5 hash in CraftMapColorCache", count);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class CraftMapColorCache implements MapPalette.MapColorCache {

private static final String MD5_CACHE_HASH = "E88EDD068D12D39934B40E8B6B124C83";
private static final String MD5_CACHE_HASH = "E88EDD068D12D39934B40E8B6B124C83"; // 248 colors
private static final File CACHE_FILE = new File("map-color-cache.dat");
private byte[] cache;
private final Logger logger;
Expand All @@ -31,10 +31,16 @@ public CraftMapColorCache(Logger logger) {
this.logger = logger;
}

private static CraftMapColorCache dryRun() {
CraftMapColorCache mapColorCache = new CraftMapColorCache(Logger.getGlobal());
mapColorCache.cache = new byte[256 * 256 * 256];
mapColorCache.buildCache();
return mapColorCache;
}

// Builds and prints the md5 hash of the cache, this should be run when new map colors are added to update the MD5_CACHE_HASH string
public static void main(String[] args) {
CraftMapColorCache craftMapColorCache = new CraftMapColorCache(Logger.getGlobal());
craftMapColorCache.buildCache();
CraftMapColorCache craftMapColorCache = CraftMapColorCache.dryRun();
try {
byte[] hash = MessageDigest.getInstance("MD5").digest(craftMapColorCache.cache);
System.out.println("MD5_CACHE_HASH: " + CraftMapColorCache.bytesToString(hash));
Expand Down Expand Up @@ -151,7 +157,7 @@ public boolean isCached() {

@Override
public byte matchColor(Color color) {
Preconditions.checkState(this.isCached(), "Cache not build jet");
Preconditions.checkState(this.isCached(), "Cache not build yet");

return this.cache[this.toInt(color)];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
package org.bukkit.craftbukkit.scoreboard;

import com.google.common.collect.ImmutableBiMap;
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.RenderType;

public final class CraftScoreboardTranslations {
static final int MAX_DISPLAY_SLOT = 19;
@Deprecated // Paper
static final ImmutableBiMap<DisplaySlot, String> SLOTS = ImmutableBiMap.<DisplaySlot, String>builder()
.put(DisplaySlot.BELOW_NAME, "below_name")
.put(DisplaySlot.PLAYER_LIST, "list")
.put(DisplaySlot.SIDEBAR, "sidebar")
.buildOrThrow();

private CraftScoreboardTranslations() {}

public static DisplaySlot toBukkitSlot(net.minecraft.world.scores.DisplaySlot minecraft) {
if (true) return DisplaySlot.NAMES.value(minecraft.getSerializedName()); // Paper
return CraftScoreboardTranslations.SLOTS.inverse().get(minecraft.getSerializedName());
return DisplaySlot.NAMES.value(minecraft.getSerializedName()); // Paper
}

public static net.minecraft.world.scores.DisplaySlot fromBukkitSlot(DisplaySlot slot) {
if (true) return net.minecraft.world.scores.DisplaySlot.CODEC.byName(slot.getId()); // Paper
return net.minecraft.world.scores.DisplaySlot.CODEC.byName(CraftScoreboardTranslations.SLOTS.get(slot));
return net.minecraft.world.scores.DisplaySlot.CODEC.byName(slot.getId()); // Paper
}

static RenderType toBukkitRender(ObjectiveCriteria.RenderType display) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import net.minecraft.world.entity.LivingEntity;
import org.bukkit.support.environment.Normal;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -26,7 +27,7 @@ public static Stream<ClassInfo> parameters() {
.whitelistPackages("net.minecraft")
.scan()
) {
for (final ClassInfo subclass : scanResult.getSubclasses("net.minecraft.world.entity.LivingEntity")) {
for (final ClassInfo subclass : scanResult.getSubclasses(LivingEntity.class.getName())) {
final MethodInfoList setItemSlot = subclass.getDeclaredMethodInfo("setItemSlot");
if (!setItemSlot.isEmpty()) {
classInfo.add(subclass);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import net.minecraft.world.level.block.Block;
import org.bukkit.support.environment.Normal;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -26,7 +27,7 @@ public static Stream<ClassInfo> parameters() {
.whitelistPackages("net.minecraft")
.scan()
) {
for (final ClassInfo subclass : scanResult.getSubclasses("net.minecraft.world.level.block.Block")) {
for (final ClassInfo subclass : scanResult.getSubclasses(Block.class.getName())) {
final MethodInfoList playerDestroy = subclass.getDeclaredMethodInfo("playerDestroy");
if (!playerDestroy.isEmpty()) {
classInfo.add(subclass);
Expand Down
Loading

0 comments on commit 7d4e855

Please sign in to comment.