Skip to content

Commit

Permalink
Replace fastutil Int2ObjectOpenHashMap with hppc IntObjectHashMap
Browse files Browse the repository at this point in the history
Closes #497 without significant plugin JAR file size change
  • Loading branch information
Krakenied committed Mar 7, 2023
1 parent 5a28efa commit 9399366
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
30 changes: 21 additions & 9 deletions bukkit/build.gradle
Expand Up @@ -48,19 +48,21 @@ repositories {
dependencies {
compileOnly project(':common')
// Paper
compileOnly 'io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT'
compileOnly('io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT') {
exclude(group: 'it.unimi.dsi', module: 'fastutil') // exclude fastutil just to don't use it (for 1.8 support)
}
// ASkyBlock
compileOnly ('com.wasteofplastic:askyblock:3.0.9.4') { transitive = false }
compileOnly('com.wasteofplastic:askyblock:3.0.9.4') { transitive = false }
// AuthLib
compileOnly ('com.mojang:authlib:1.5.21') { transitive = false }
compileOnly('com.mojang:authlib:1.5.21') { transitive = false }
// BentoBox
compileOnly ('world.bentobox:bentobox:1.22.0-SNAPSHOT') { transitive = false }
compileOnly('world.bentobox:bentobox:1.22.0-SNAPSHOT') { transitive = false }
// Citizens
compileOnly ('net.citizensnpcs:citizensapi:2.0.30-SNAPSHOT') { transitive = false }
compileOnly('net.citizensnpcs:citizensapi:2.0.30-SNAPSHOT') { transitive = false }
// CoreProtect
compileOnly 'net.coreprotect:coreprotect:21.2'
// EssentialsX
compileOnly ('net.essentialsx:EssentialsX:2.19.7') { transitive = false }
compileOnly('net.essentialsx:EssentialsX:2.19.7') { transitive = false }
// FabledSkyblock
compileOnly 'com.songoda:skyblock:2.3.30'
// IridiumSkyblock TODO fix whenever repo is up
Expand All @@ -82,15 +84,15 @@ dependencies {
// SCore
compileOnly 'com.github.Ssomar-Developement:SCore:3.4.7'
// ShopGUIPlus
compileOnly ('com.github.brcdev-minecraft:shopgui-api:3.0.0') { transitive = false }
compileOnly('com.github.brcdev-minecraft:shopgui-api:3.0.0') { transitive = false }
// Slimefun4
compileOnly 'com.github.Slimefun:Slimefun4:RC-32'
// SuperiorSkyblock2
compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:2022.9'
// uSkyBlock
compileOnly ('com.github.rlf:uSkyBlock-API:2.8.3') { transitive = false }
compileOnly('com.github.rlf:uSkyBlock-API:2.8.3') { transitive = false }
// VotingPlugin
compileOnly ('com.bencodez:votingplugin:6.9.5') { transitive = false }
compileOnly('com.bencodez:votingplugin:6.9.5') { transitive = false }

// IridiumSkyblock
compileOnly fileTree(dir: 'libs', includes: ['*.jar'])
Expand All @@ -101,6 +103,8 @@ dependencies {
implementation 'com.zaxxer:HikariCP:4.0.3'
// slf4j
implementation 'org.slf4j:slf4j-nop:1.7.36'
// hppc
implementation 'com.carrotsearch:hppc:0.9.1'
}

tasks.build {
Expand All @@ -111,5 +115,13 @@ shadowJar {
relocate 'org.bstats', 'com.leonardobishop.quests.libs.bstats'
relocate 'com.zaxxer.hikari', 'com.leonardobishop.quests.libs.hikaricp'
relocate 'org.slf4j', 'com.leonardobishop.quests.libs.slf4j'
relocate 'com.carrotsearch.hppc', 'com.leonardobishop.quests.libs.hppc'

minimize {
exclude(dependency('org.bstats:.*:.*'))
exclude(dependency('com.zaxxer:.*:.*'))
exclude(dependency('org.slf4j:.*:.*'))
}

archiveClassifier.set('')
}
@@ -1,5 +1,6 @@
package com.leonardobishop.quests.bukkit.menu;

import com.google.common.primitives.Ints;
import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin;
import com.leonardobishop.quests.bukkit.config.BukkitQuestsConfig;
import com.leonardobishop.quests.bukkit.menu.element.*;
Expand All @@ -12,7 +13,6 @@
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.List;

public abstract class PaginatedQMenu extends QMenu {
Expand Down Expand Up @@ -106,7 +106,7 @@ public void populate(String customElementsPath, List<MenuElement> menuElementsTo
// this won't check if static elements overlap normal ones first but i don't care
int maxSize = pageSize - (backMenuElement == null ? 0 : 9);
BukkitQuestsConfig config = (BukkitQuestsConfig) plugin.getQuestsConfig();
if ((menuElements.isEmpty() ? 0 : Collections.max(menuElements.keySet())) + 1 > maxSize
if ((menuElements.isEmpty() ? 0 : Ints.max(menuElements.keys)) + 1 > maxSize
|| menuElements.size() + menuElementsToFill.size() + customStaticElements > maxSize) {
MenuElement pageNextMenuElement = new PageNextMenuElement(config, this);
MenuElement pagePrevMenuElement = new PagePrevMenuElement(config, this);
Expand Down Expand Up @@ -151,7 +151,7 @@ public void populate(String customElementsPath, List<MenuElement> menuElementsTo
}

this.minPage = 1;
this.maxPage = (menuElements.isEmpty() ? 0 : Collections.max(menuElements.keySet())) / pageSize + 1;
this.maxPage = (menuElements.isEmpty() ? 0 : Ints.max(menuElements.keys)) / pageSize + 1;
}

private void fillStaticMenuElements(int slot, MenuElement[] staticMenuElements) {
Expand Down
@@ -1,15 +1,15 @@
package com.leonardobishop.quests.bukkit.menu;

import com.carrotsearch.hppc.IntObjectHashMap;
import com.leonardobishop.quests.bukkit.menu.element.MenuElement;
import com.leonardobishop.quests.common.player.QPlayer;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.Nullable;

public abstract class QMenu {

protected final QPlayer owner;
protected final Int2ObjectOpenHashMap<MenuElement> menuElements = new Int2ObjectOpenHashMap<>();
protected final IntObjectHashMap<MenuElement> menuElements = new IntObjectHashMap<>();

public QMenu(QPlayer owner) {
this.owner = owner;
Expand Down

0 comments on commit 9399366

Please sign in to comment.