Skip to content

Commit

Permalink
api: duplicate check most ID classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Nov 29, 2024
1 parent a108456 commit c1da4a1
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 8 deletions.
9 changes: 2 additions & 7 deletions runelite-api/src/main/java/net/runelite/api/AnimationID.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ public final class AnimationID
public static final int COOKING_WINE = 7529;
public static final int FLETCHING_BOW_CUTTING = 1248;
public static final int HUNTER_LAY_BOXTRAP_BIRDSNARE = 5208; //same for laying bird snares and box traps
public static final int HUNTER_LAY_DEADFALLTRAP = 5212; //setting up deadfall trap
public static final int HUNTER_LAY_NETTRAP = 5215; //setting up net trap
public static final int HUNTER_LAY_MANIACAL_MONKEY_BOULDER_TRAP = 7259; // setting up maniacal monkey boulder trap
public static final int HUNTER_CHECK_BIRD_SNARE = 5207;
public static final int HUNTER_CHECK_BOX_TRAP = 5212;
public static final int HERBLORE_MAKE_TAR = 5249;
public static final int FLETCHING_STRING_NORMAL_SHORTBOW = 6678;
public static final int FLETCHING_STRING_NORMAL_LONGBOW = 6684;
Expand Down Expand Up @@ -149,7 +147,7 @@ public final class AnimationID
public static final int CRAFTING_LOOM = 2270;
public static final int CRAFTING_CRUSH_BLESSED_BONES = 11099;
public static final int SMITHING_SMELTING = 899;
public static final int SMITHING_CANNONBALL = 827; //cball smithing uses this and SMITHING_SMELTING
public static final int SMITHING_CANNONBALL = 827; // same as BURYING_BONES
public static final int SMITHING_ANVIL = 898;
public static final int SMITHING_IMCANDO_HAMMER = 8911;
public static final int FISHING_BIG_NET = 620;
Expand Down Expand Up @@ -255,8 +253,6 @@ public final class AnimationID
public static final int DEMONIC_GORILLA_MAGIC_ATTACK = 7225;
public static final int DEMONIC_GORILLA_MELEE_ATTACK = 7226;
public static final int DEMONIC_GORILLA_RANGED_ATTACK = 7227;
public static final int DEMONIC_GORILLA_AOE_ATTACK = 7228;
public static final int DEMONIC_GORILLA_PRAYER_SWITCH = 7228;
public static final int DEMONIC_GORILLA_DEFEND = 7224;
public static final int BOOK_HOME_TELEPORT_1 = 4847;
public static final int BOOK_HOME_TELEPORT_2 = 4850;
Expand Down Expand Up @@ -321,13 +317,12 @@ public final class AnimationID
public static final int FARMING_PLANT_SEED = 2291;
public static final int FARMING_HARVEST_FLOWER = 2292;
public static final int FARMING_MIX_ULTRACOMPOST = 7699;
public static final int FARMING_HARVEST_ALLOTMENT = 830;
public static final int FARMING_HARVEST_ALLOTMENT = 830; // same as DIG

// Lunar spellbook
public static final int ENERGY_TRANSFER_VENGEANCE_OTHER = 4411;
public static final int MAGIC_LUNAR_SHARED = 4413; // Utilized by Fertile Soil, Boost/Stat Potion Share, NPC Contact, Bake Pie
public static final int MAGIC_LUNAR_CURE_PLANT = 4432;
public static final int MAGIC_LUNAR_GEOMANCY = 7118;
public static final int MAGIC_LUNAR_PLANK_MAKE = 6298;
public static final int MAGIC_LUNAR_STRING_JEWELRY = 4412;

Expand Down
1 change: 0 additions & 1 deletion runelite-api/src/main/java/net/runelite/api/SpriteID.java
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ public final class SpriteID
public static final int TAB_QUESTS = 776;
public static final int RS2_TAB_INVENTORY = 777;
public static final int RS2_TAB_EQUIPMENT = 778;
public static final int RS2_TAB_PRAYER = 779;
public static final int TAB_PRAYER = 779;
public static final int TAB_MAGIC = 780;
public static final int RS2_TAB_FRIENDS_CHAT = 781;
Expand Down
78 changes: 78 additions & 0 deletions runelite-api/src/test/java/net/runelite/api/DistinctIdTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2024, Adam <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api;

import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
import lombok.SneakyThrows;
import net.runelite.api.clan.ClanID;
import static org.junit.Assert.fail;
import org.junit.Test;

public class DistinctIdTest
{
@Test
public void testUnique()
{
duplicateCheck(
// disabled as a few plugins rely on the dups
//AnimationID.class,
ClanID.class,
EnumID.class,
FontID.class,
GraphicID.class,
HitsplatID.class,
KeyCode.class,
ParamID.class,
ScriptID.class,
SettingID.class,
SkullIcon.class,
SoundEffectID.class,
SpriteID.class,
StructID.class,
VarClientInt.class,
VarClientStr.class,
VarPlayer.class,
Varbits.class
);
}

@SneakyThrows
private void duplicateCheck(Class<?>... classes)
{
for (Class<?> clazz : classes)
{
Set<Integer> seen = new HashSet<>();
for (Field f : clazz.getDeclaredFields())
{
if (!seen.add(f.getInt(null)))
{
fail("field with duplicate value: " + clazz.getSimpleName() + "." + f.getName());
}
}
}
}
}

0 comments on commit c1da4a1

Please sign in to comment.