#help-development

1 messages ยท Page 54 of 1

quaint mantle
#

should i wait and learn javascript or python first and then come back to java

crude charm
#

or just learn java

quaint mantle
#

idk what to do

crude charm
#

Just do it

floral drum
#

@echo basalt I found this online

crude charm
#

no reason to stall for 2 weeks "should I learn this", you could've been ahead

quaint mantle
#

ya

floral drum
quaint mantle
#

im gonna come back later

#

take a break

echo basalt
crude charm
quaint mantle
#

ya

#

is java beginner friendly

quiet ice
#

Any well-known non-esoteric lang is beginner friendly if you do the right thing

quaint mantle
#

oh ok

#

im gonna take a break

#

bc i have been coding since last night

quiet ice
#

If you want to write a search engine in java you are going find that java is not beginner friendly, so would you with probably any other language

quaint mantle
#

ok

#

so maybe python or javascript

tardy delta
#

what the

drowsy pawn
#

hello what a problem

quiet ice
#

[0-9]{1,6}

quaint mantle
#

why is this happening? I've tried everything that i could think of

#
        at java.util.ArrayList.forEach(ArrayList.java:1513) ~[?:?]
        at me.outspending.gencoreplus.Dropping.GenDrop$1.run(GenDrop.java:36) ~[GenCorePlus-1.0.0.jar:?]
        at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.jar:git-Paper-81]
        at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.jar:git-Paper-81]
        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1491) ~[paper-1.19.jar:git-Paper-81]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.19.jar:git-Paper-81]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1415) ~[paper-1.19.jar:git-Paper-81]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1188) ~[paper-1.19.jar:git-Paper-81]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:303) ~[paper-1.19.jar:git-Paper-81]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]```
#

code: (DEBUG)

    public static void removePlayerGenerator(Player plr, Location loc) {
        Bukkit.broadcastMessage(plr + " // " + loc);
        Bukkit.broadcastMessage(map.get(plr.getUniqueId()).toString());
        if (!map.get(plr.getUniqueId()).contains(loc)) return;
        map.get(plr.getUniqueId()).remove(loc);
        Bukkit.broadcastMessage(map.get(plr.getUniqueId()).toString());
    }```
#

everything is set

quiet ice
quaint mantle
quiet ice
#

Or no that here is arraylist

#

Use CopyOnWriteArrayList then

quiet ice
quaint mantle
#

would i just cast it to the correct one?

quiet ice
#

The root cause is that you have something like

for (Object o : collection) {
    collection.remove();
}

which is not possible for any instance of ArrayList

#

I am not too sure if CopyOnWriteArrayList allows concurrent modification though, but I guess you can always try it out

quiet ice
#

Though uh, it really seems as if you rather want a Set there

quaint mantle
quiet ice
#

You just need to modify the new ArrayList<>() into a new CopyOnWriteArrayList<>()

quaint mantle
#

im only editing the value

#

because the copyonwrite is only 1 arg

quiet ice
#

However if order does not matter I'd really use public static Map<UUID, Set<Location>> map = new HashMap<>();
And then have something like map.put(id, ConcurrentHashMap.newKeySet()); when you insert the collection into the map

steel orchid
#

hey there, do you guys know why this could be red?

tardy delta
#

bruh is sqlite not able to create a database by code lol

quiet ice
#

didn't define the maven repository?

steel orchid
quiet ice
#

intelliJ
Invalidate caches and restart

tardy delta
#

intellij moment

steel orchid
#

okay it works now thanks

#

nevermind it turned red again

#

seems like it fails to transfer from the repository

quiet ice
#

Repositories could be down idk

quaint mantle
#
@EventHandler
    public void AnvilEvent(PrepareAnvilEvent event){
        if(!(event.getView().getPlayer() instanceof Player)){return;};
        Player p = (Player) event.getView().getPlayer();
        p.sendMessage("called");
        ItemStack item = event.getInventory().getItem(0);
        ItemStack item2 = event.getInventory().getItem(1);

        Enchantment enchant = Enchantment.PROTECTION_ENVIRONMENTAL;
        ItemStack check = new ItemStack (Material.ENCHANTED_BOOK, 1);
        //check.addEnchantment(enchant, 4);


        ItemMeta stackMeta = check.getItemMeta();
        stackMeta.addEnchant(enchant, 4, true);
        check.setItemMeta(stackMeta);



        if(item == item2){
            if(item == check) {
                ItemStack result = new ItemStack(Material.ENCHANTED_BOOK, 1);
                result.addEnchantment(enchant, 5);
                event.getInventory().setRepairCost(38);
                event.setResult(result);
            } else {
                p.sendMessage("not the right check type");
            }

        }
        else{
            p.sendMessage("not the same item");
        }

    }

not the same item gets printed when it was the item that i wanted to check for ๐Ÿคทโ€โ™‚๏ธ

full perch
full perch
quaint mantle
#

guys are there like tutorials on how to make room gens?

quiet ice
#

(So more or less the System hashcode)

#

Though two objects with identical System hashcode may have different identities

full perch
#

Well what I know is, if you have 2 strings with the same contents but not having string1 = string2 but rather string1 = "hi" string2 = new String("hi") or something like that, == doesn't say they are equal, lemme find an example

quiet ice
#

same applies to the Integer, Double, and any other instance of Object

#

The fact that "hi" == "hi" and "h" + "i" == "hi" return true is only caused because of the constant pool

worldly ingot
#

FeelsIntern()Man

quaint mantle
tardy delta
#

uhh CREATE DATABASE not working in sqlite?

full perch
worldly ingot
#

SQLite doesn't really have any concept of databases

#

Each individual SQLite file is a database

#

So if you want to CREATE DATABASE test, you would just make a new file called test.db (or whatever extension tbh)

tender shard
#

it's also quite unusual to do CREATE DATABASE yourself, normally people don't have any permissions to create new databases

quaint mantle
worldly ingot
#

Same applies though

ancient plank
#

SQLite mmm

tender shard
#

most hosters I know give you only 1 database, or only allow to create new ones through their web panel

worldly ingot
#

SQLite has some oddities. You can't ALTER TABLE table ADD COLUMN name details IF NOT EXISTS in it either

#

IF NOT EXISTS isn't supported for ADD COLUMN, you just have to listen for an exception

tardy delta
#

hmm i think the issue is a sql syntax exception then

daring lark
#
        ItemStack[] matrix = inventory.getMatrix();
        if(matrix.length < 9) return;
        for(RpgItems item : RpgItems.values()) {
            if(inventory.getResult() != null) {
                if(inventory.getResult().isSimilar(item.getItem().getItemStack())) return;
            }
            for(int i = 0; i < 9; i++) {
                if(item.getItem().getRecipe().getIngredients().containsKey(i)) {
                    if(matrix[i] == null) {
                        log("null");
                        break;
                    }
                    if(!matrix[i].isSimilar(item.getItem().getItemStack())) {
                        log("other");
                        break;
                    }
                } else {
                    log("no recipe");
                    break;
                }
                inventory.setResult(item.getItem().getItemStack());
                return;
            }
        }
    }``` did anyone know why my item is always other even when it's not?
iron glade
#

You should go down with fps instead of pixels usually

tardy delta
#

uhh dont see any syntax mistakes i made

vocal cloud
#

Do you need commas between statements? I only remember my MYsql

#

THONK nvm

#

It's a list and I can't read

civic wind
#

T

tardy delta
#

hehe

civic wind
#

https://hastebin.com/ifowuyorew.java https://hastebin.com/arizemeloz.swift

I get this error on the toggling off, of the freeze command.. Also my events don't seem to be working (Yes they are registered in Main) This is the error:

tardy delta
#

i hope you know the 2nd one will overwrite the original entry?

civic wind
#

So i don't need armorcontents too, contents will get armor anyway?

tardy delta
#

uhh not sure about that, i think not

#

?jd-s

undone axleBOT
civic wind
#

Anyway, my problem is the error and the events

#

I can play about with content saving later

eternal night
#

getContents is enough

#

it should include everything

civic wind
#

Okay

eternal night
#

setArmorContents makes no sense

#

you are passing in a way too large item stack array

#

which is causing you this error

civic wind
#

Yes, i've removed this. My issue is the error but I think i've found a solution myself

tardy delta
#

how is the player inv length 4 :/

civic wind
#

I fixed my issues.

tardy delta
#

ah nice my plugin just disables when reloading the server

wet breach
#

seems like you don't refresh the connection

tardy delta
#

wdym by refreshing?

wet breach
#

how you do that, is have a method that checks if its null and if so, establish a connection and return it

tardy delta
#

well that error occurs cuz the plugin isnt fully enabled :/

wet breach
#

Well you can lose the file reference with sqlite with the server reload, so you need to refresh the reference

sterile token
tardy delta
#

im using hikaricp with sqlite :/

sterile token
#

oh hikari ๐Ÿคข

wet breach
#

hikaricp does not work with sqlite

tardy delta
#

r-really?

wet breach
#

it does absolutely nothing because sqlite is file based

iron glade
tardy delta
#

so is h2

#

and it worked with h2 ._.

wet breach
#

that is fine, but there is no such thing as connection pooling for file based DB's

#

yes you can use hikaricp to initiate a connection, but you can easily do it yourself too. And the point of hikaricp is connection pooling

tardy delta
#

ah bruh this sucks then

wet breach
#

what is the point of using a lib if you can't use its main function

sterile token
tardy delta
#

doesnt connection pooling work with a file based db then?

wet breach
#

no

tardy delta
wet breach
#

main reason it doesn't work with files is because of IO blocking on files

sterile token
tardy delta
#

ah ye what i was guessing

#

lets remake that damn class again then pff

wet breach
#

hikaricps manual tells you this too btw

#

or did

#

should have read the manual

sterile token
#

Agree

#

Hikari sucks....

wet breach
#

it doesn't suck

sterile token
#

Yeah bruh

tardy delta
#

"did" yes

sterile token
#

I have use it with Mysql and was a disaster

wet breach
#

most likely because you configured hikari incorrectly

sterile token
wet breach
#

the thing most people don't do

#

is use the method that hikari provides after you have a connection object

#

to fetch a connection from the pool

wet breach
sterile token
#

na im really bad with docs

ancient plank
#

jdbc ftw

sterile token
#

If they are not self explained really good i dont understand

tardy delta
#

they were pretty straightforward to me

river oracle
wet breach
#

I am not sure about other languages

#

but they have example docs and API docs

river oracle
#

his english isn't very good so

#

I wouldn't expect him to understand everything they are tryna say

sterile token
wet breach
shy rock
#

Making a mob rn getting an error on super(EntityType.SILVERFISH, ((CraftWorld)) loc.getWorld()) on ((CraftWorld)

river oracle
tardy delta
#

or leave it as null and override the getConnection method?

#

probs the latter

sterile token
#

Dont use hikari sucks

tardy delta
#

bruh

#

cuz?

sterile token
#

I have told you

#

Just use JDBC

tardy delta
#

cuz you had some bad experiences with it and mysql?

sterile token
#

Dont f** please....

wet breach
sterile token
#

Okay?

tardy delta
#

very based ๐Ÿค“

sterile token
tardy delta
#

im even more rude

#

/jk

golden kelp
#

hello spigot geeks, this not so creative person wants some stupid AF AND DUMB AND ULTRA DUMB plugin ideas so i can make a youtube video and get 1 billion views

tardy delta
#

im gettin angry when stuff doesnt work lol

wet breach
sterile token
tardy delta
#

do we need the datasource in the sqlite class?

sterile token
golden kelp
#

no brag but i made the 100th fork of vault

quiet ice
golden kelp
wet breach
golden kelp
#

it seems sus

wet breach
#

so as long as they get ran, which you could do in onEnable() then no it doesn't need to be in that class specificaly

sterile token
#

Its not necessary

tardy delta
#

lets change the constructor too then :/

quiet ice
sterile token
golden kelp
#

It says "HackServer" so that might be a bit against TOS

quiet ice
sterile token
#

If you are going to said stupid things please don do it....

quiet ice
golden kelp
#

Oh sorry ty

quiet ice
#

Generated at runtime

sterile token
#

Are you using ASM?

quiet ice
#

Yeah, but I'll guess I'll dump it into a file and see how decompilers react to it

tardy delta
#

anyways gn lol

wet breach
#

are you by chance running any scripts in there?

quiet ice
quaint mantle
#

on InventoryClickEvent im setting the eventcancelled to true if its if(ChatColor.stripColor(event.getView().getTitle()).equalsIgnoreCase("Items for Sale")) { this inventory but whenever i open this inventory i cant move stuff from the normal plays inventory is this normal or did i do something wrong

quaint mantle
sterile token
#

I would recommend comparing using full object

quaint mantle
#

so comparing the inventory object to the one i made

#

?

wet breach
#

or is that the class that gets generated

sterile token
quaint mantle
#

Custom inventory

sterile token
#

Ok

quiet ice
sterile token
#

So on the event get the top inventory

quaint mantle
#

if(event.getInventory().equals(PlayerTradeItems.inventoryTradeItems(player))) ?

sterile token
#

You can do it event.getViews().getTopInventory() if im not wrong

quaint mantle
#

oh

#

kk

quiet ice
#

Ah you mean that

sterile token
quaint mantle
#

try it

quiet ice
#

It's just static block that calls the injectHackloader method

sterile token
#

The top inventory would be the custom one

wet breach
#

I am going to assume its quite possible it has to do with the bytes

#

maybe you don't have the order correct?

quiet ice
#

The class failed the very primitive early verifiers, so it's one of the core attributes of the class that are invaldi

sterile token
wet breach
#

for example, statics are intialized in the order they appear in the source file

quaint mantle
quiet ice
quiet ice
wet breach
quaint mantle
#

im trying to make the result of the anvil display protection 5

    @EventHandler
    public void AnvilClick(InventoryClickEvent e){
        Player p = (Player) e.getView().getPlayer();
        ItemStack p5 = new ItemStack(Material.ENCHANTED_BOOK, 1);
        EnchantmentStorageMeta meta = (EnchantmentStorageMeta) p5.getItemMeta();
        meta.addStoredEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 5, true);
        p5.setItemMeta(meta);
        if (e.getClickedInventory() instanceof AnvilInventory){
            p.sendMessage("click");
            if(e.getClickedInventory().contains(p5)){
                p.sendMessage("click2");
                if(!(e.getClickedInventory().getItem(2) == null)){
                    e.getClickedInventory().getItem(2).removeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL);
                    e.getClickedInventory().getItem(2).addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 5);
                }
            }
        }
    }
wet breach
quiet ice
#
java.lang.IllegalArgumentException: Invalid class name (must be an internal class name): de.geolykt.enchantments_plus.compatibility.hackloader.asm.tree.ClassNode@b9aedae

Oh lol, now to understand why it is happening

wet breach
#

ah there we go

quiet ice
worldly ingot
quiet ice
wet breach
quiet ice
#

I have no idea how you found it though

quaint mantle
worldly ingot
#

Make use of setResult(ItemStack) though instead of setting the item directly

#

Other than that, should work fine

wet breach
#

notice it is refering to the initialization?

#

the only place you have init, is at line 44

quiet ice
#

That is clinit

worldly ingot
#

Which is class initialization

quiet ice
#

init is the normal constructor

wet breach
#

class initialization

worldly ingot
#

cl init
class initialize

wet breach
#

you are generating the class, like you said

quiet ice
#

(plus it wouldn't even run if it failed the verifier which it did)

wet breach
#

anyways, the line was found where it is erroring ๐Ÿ˜›

#

suppose we could just move forward from there even if you don't understand how I found it XD

quiet ice
#
[20:14:52 ERROR]: Could not load 'plugins/enchantments-plus-4.1.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.VerifyError: Constructor must call super() or this() before return
Exception Details:
  Location:
    de/geolykt/enchantments_plus/compatibility/hackloader/HackServer.<init>(Lorg/bukkit/Server;)V @5: return
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: 2a2b b500 0ab1                         

Well at least I understand this error message

civic wind
#

Anyone know why the getRightClicked() and hasMeta() checks are pulling errors? Don't know any other way of doing it

quaint mantle
quiet ice
#

And it passed the verifier!

[20:17:54 WARN]: Caused by: java.lang.IllegalArgumentException: Can not set static org.bukkit.Server field org.bukkit.Bukkit.server to de.geolykt.enchantments_plus.compatibility.hackloader.HackServer
[20:17:54 WARN]:     at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
[20:17:54 WARN]:     at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
[20:17:54 WARN]:     at java.base/jdk.internal.reflect.UnsafeStaticObjectFieldAccessorImpl.set(UnsafeStaticObjectFieldAccessorImpl.java:79)
[20:17:54 WARN]:     at java.base/java.lang.reflect.Field.set(Field.java:799)
[20:17:54 WARN]:     at enchantments-plus-4.1.0.jar//de.geolykt.enchantments_plus.compatibility.hackloader.Hackloader.injectHackloader(Hackloader.java:170)

(and yes I understand what I did wrong there too)

quaint mantle
civic wind
quiet ice
#

It's probably .hasItemMeta

civic wind
#

wb rightclicked?

quiet ice
#

?jd-s for the other method I'd need to check

undone axleBOT
quaint mantle
quiet ice
#

getRightClicked is PlayerInteractEntityEvent

civic wind
quiet ice
#

You have PlayerInteractEvent

civic wind
#

Yeah

quiet ice
#

So you need to put this in another listener

civic wind
#

What? I need it in this one, I'm checking for right click, then running a command after various other checks

quiet ice
#

Then you gotta find a workaround, can't listen to two events at the same time

civic wind
#

ahh hmm

#

Any ideas? lol

quiet ice
#

would need to see the entire source of that listener

civic wind
quiet ice
#

You probably can just swap out the PlayerInteractEvent with PlayerInteractEntityEvent without any issues

#

Unless you want to listen if the player also interacts with a block

civic wind
#

It's a freeze command, Its an ice block, if they right click another player with it it runs the command

#

So i can interactentity?

civic wind
quiet ice
#

Consult the documentation that really should not be witchcraft

civic wind
#

Nevermind, done it ๐Ÿ™‚

vestal matrix
#

how long does it take for a premium resource to get accepted? all forums ive found are 4 yrs old

waxen plinth
#

About 4 years

naive bolt
waxen plinth
#

Plugin is disabled

#

Seems pretty clear to me

naive bolt
#

why would that be

waxen plinth
#

In /pl is your plugin green or red

naive bolt
#

red

waxen plinth
#

And do you see any errors on startup

waxen plinth
naive bolt
#

im restarting i will check

waxen plinth
#

It's probably disabled due to a startup error

naive bolt
#

yep many errors

livid tundra
#

what order are the items returned by playerinventory.getcontents() in, and does it include all items? (empty slots, off hand, ect.)

quaint mantle
#

how do I check if an Itemstack is a type of an armor piece ?

ItemStack item;
if(item.getType().isArmor()){ //isArmor ?
  // is armor
}
naive bolt
severe oak
#

Cannot invoke "ca.nicbo.invadedlandsevents.event.InvadedEventManager.getCurrentEvent()" because "this.eventManager" is null

iron glade
quaint mantle
#

I figured I also can do it like this

#
Material m = item.getType();
String name = m.name().toLowerCase();

if (name.contains("helmet") || name.contains("chestplate") || name.contains("leggings") || name.contains("boots")){
  //do stuff
}

#

can you prevent the anvil from giving you a result btw ? ๐Ÿค”

last swift
#

I have a scoreboard that updates every second with a different time, but for some reason randomly the scoreboard stops updating and becomes blank. Is this a common issue or is it most likely something with my code?

crisp steeple
#

are you sure the if statement is true?

quiet ice
#

Update: It is indeed possible to use the processClass method to transform plugin classes. That being said it might not work in java versions beyond Java 17 as you need to sun.misc.Unsafe class in order to overwrite the final CraftMagicNumbers#INSTANCE field

worldly ingot
#

Wow that sounds like an absolutely horrible idea

ancient plank
#

sounds like a great idea

echo basalt
#

sounds like a solid idea

quiet ice
#

Time to inject malware into those plugin classes \s

echo basalt
#

join message plugin
does http requests

vocal cloud
#

I mean it's either that or fork

sterile mason
#

What is the 1.19 equivalent to the CraftPlayer (Intellij wont find the package to import)? I want to find out the players ping.

quiet ice
#

It's still CraftPlayer

#

?bundler

#

?bootstrap this is likely your issue

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

civic wind
#

No errors, just doesnt return anything

desert frigate
#

If I set persistent data on a entity then kill it. Does it still have the data?

winter pagoda
#

Whats the packet for loading blocks

remote spade
quiet ice
civic wind
#

The command doesn't return a single thing

#

I type it, does nothing

winter pagoda
#

when joining and the server sends all the packets for the blocks to load in

quiet ice
#

Did you debug using sysout?

remote spade
# civic wind I do

Then you don't have the permission, double check it or make yourself op

civic wind
#

I am op

remote spade
#

Can you please try debugging?

civic wind
#

I've even removed the permission, still nothing

quiet ice
#

For Mojmap it is ClientboundLevelChunkWithLightPacket @winter pagoda

remote spade
civic wind
#

in the Main class

remote spade
#

breh

civic wind
#

It's been a long day

#

LOL

quiet ice
#

Shouldn't that return a command not found message?

shy rock
#

public class IRONSILVERFISH extends EntitySilverfish {
anybody knows why EntitySilverfish gets red and doesn't do an import?

quiet ice
#

Do you depends on spigot or spigot-api

shy rock
#

spigot

quiet ice
#

If so are you using mojmap or nah

shy rock
quiet ice
#

I have no clue then

civic wind
quiet ice
#

Your formatting style is ... questionable

vocal cloud
#

Don't use display name to find items. Use the PDC

sterile mason
quiet ice
#

Even then it is because you check for the ampersand, but you need to check ยง

civic wind
#

Actually I can use my cc utils

civic wind
modest tartan
#

I need help understanding this error please, the only reference to UGPlayerProfile in this code is that its inside an instance of UGPlayerProfile

[13:01:23 WARN]: [Ultragens] Task #3 for Ultragens v1.0 generated an exception
java.lang.NullPointerException: Cannot invoke "com.earthagar.ultragens.Database.getGenerator(String)" because the return value of "com.earthagar.ultragens.UGPlayerProfile.access$000(com.earthagar.ultragens.UGPlayerProfile)" is null
        at com.earthagar.ultragens.UGPlayerProfile$Spawner$1.run(UGPlayerProfile.java:110) ~[ultragens-1.0-shaded.jar:?]
Generator gen = db.getGenerator(blComp.getString("genID"));
eternal oxide
#

blComp.getString("genID") is null

modest tartan
#

But then why is it saying that the main class is null?

eternal oxide
#

its not

#

the return value of "com.earthagar.ultragens.UGPlayerProfile.access$000(com.earthagar.ultragens.UGPlayerProfile)" is null

modest tartan
#

right is that not saying what I just said?

eternal oxide
#

the return value, not main is null

quiet ice
#

It means that the field (blComp) is null

#

Or db is null idk

modest tartan
#

hmm I'll debug more

quiet ice
#

No, db is null

#

Javac generates a synthetic accessor method (access$000) since db is private and you are in a different class than it was declared at

modest tartan
#

crap you're right

#

I had it private, I removed that and I'm about to test

sterile mason
#

i have the spigot api version 1.19.2-R0.1-SNAPSHOT dependency implemented but cant import the org.bukkit.craftbukkit package. Whats wrong?

#

or is there any other way that i can find out the players ping?

eternal night
#

Player#getPing ?

wide creek
#

I am learning how to code plugins, and keep running into this error:

Method invocation 'getType' may produce 'NullPointerException

it happens whenever I am dealing with block related stuff (the error pops up when I try Block block = event.getHitBlock(); unless I add if (block != null). Is there any other way to fix this besides adding a bunch of if (block != null) statements?

#
package me.cryptopig.myfirstplugin.listeners;

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ExpBottleEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerJoinEvent;

import static org.bukkit.Bukkit.getServer;

public class RandomListeners implements Listener {
    String playerName;

    @EventHandler
    public void onProjectileHitEvent(ProjectileHitEvent event) {
        Block block = event.getHitBlock();
        if (block != null) && (block.getType() == Material.dirt) {
            block.breakNaturally();
        }
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        getServer().broadcastMessage( "Someone has joined the server." );
        playerName = event.getPlayer().getPlayerListName();
        event.setJoinMessage("Welcome to the server, " + playerName + "!");

    }

    @EventHandler
    public void onLeaveBed(PlayerBedLeaveEvent event) {
        Player player = event.getPlayer();
        player.setHealth(player.getHealth() - 3);
        player.sendMessage("You have left a bed! Hope  you had a good sleep!");


    }

}



My code btw

quiet ice
wide creek
#

how do i tell intellij to shut up lol

quiet ice
#

I'm an eclipse user

wide creek
#

i c

#

i will just google it then

#

ty tho ๐Ÿ™:

eternal night
river oracle
worldly ingot
#

Well... no... that's just a good error. Your IDE is doing a good job

#

ProjectileHitEvent#getHitBlock() can return null. You should be null checking it

quiet ice
#

That is extremely true

worldly ingot
#

You can remove that null check if you want, but you're going to get exceptions in your console every single time any projectile hits an entity

wide creek
#

ah alr

#

i'll just add a bunch of assert statements then ๐Ÿคท

worldly ingot
#

Or... block != null

#

I can't believe I'm saying this, but languages like Kotlin have the Elvis (?) operator which will do both. block?.getType() == Material.WHATEVER)

#

I don't use Kotlin nor do I really advise you learning it, especially if you're just starting to learn Java, but figured I'd at least mention it because the Kotlin nutcases don't shutup about null safety lol

wide creek
#

okok, thanks a lot!

ancient plank
#

elvis

quaint mantle
#

is there an event for when a player makes a successful trade w a villager

#

?

#

or makes a trade through merchant gui

eternal oxide
#

?jd-s and search trade or villager

undone axleBOT
ancient plank
#

javadocs are witchcraft !!1

echo basalt
#

Javadocs are hackers

dim bronze
worldly ingot
ivory sleet
patent fox
#

How many degrees is yaw? 360?

karmic stirrup
#

-180

iron glade
#

wdym if a console message is sent?

glossy marsh
#

Hello, I'm workin on an plugin 1.18.2, where i shoot snowballs with a speed of 10 balls / s, but the LivingEntity I hit only gets damage on every 5th hit or so.

Does anyknow knows whats going on there?

iron glade
#

Tried debugging?

glossy marsh
upper vale
#

players get invulnerability ticks after being damaged

glossy marsh
glossy marsh
rapid aspen
#

someone have a simple plugin source with /tpa /tpaccept and /tpadeny

rapid aspen
#

i want just the tpa so i can use in my plugin

iron glade
#

Why don't you code it yourself, it's not that difficult

modest garnet
#

hey, so i have a "rank" system which stores the rank as a char. 'a', 'b' etc
when i can "getRank()" it returns a char
how can i set the rank to the next letter in the alphabet, when i only have a char

for example

getRank() returns 'a' so i need to setRank('b') but how would i get 'b'

#

does that make sense

latent dew
#

because plugins, essentials, permissionsex doesn't work in versions 1.18.2

delicate lynx
#

permission sex

iron glade
latent dew
#

when i put plugins on my server they just turn red and don't work

delicate lynx
#

pretty sure you can just +1 to a char and it goes to the next one

iron glade
#

or smth like that if it exists ^^

modest garnet
#

mah

eternal oxide
#

(char)char.getNumericValue()+1;

modest garnet
#

oh right

modest garnet
eternal oxide
#

is your getRank() returning a char or a String?

modest garnet
eternal oxide
#

Character.getNumericValue(rank)

worldly ingot
#

A char won't have that method, but a Character will

#

ye

young knoll
#

char is just a fancy uhhโ€ฆ

#

Some kind of primitive

azure hawk
#

Whenever i try to pickup an item this comes

young knoll
#

Event_PickupAndCraft line 32

eternal night
#

no one saw that

young knoll
#

Looks like you are trying to add to an immutable list

delicate lynx
#

well you're also checking if a list contains an itemstack, but the list is for strings

azure hawk
#

bruh

#

ok

#

xd

#

thx

modest garnet
delicate lynx
#

go to whatever characters are after the alphabet

azure hawk
#

When i put the item in the inv nothing happens

#

why

shadow gazelle
#

Could I somehow "refill" the inventory I'm making?

#

I'm saving the contents to a file and it saves just fine, but when I go to look at the modified one and call a new instance of the InventoryHolder, nothing in the inventory changes even though it should be pulling everything from the file

#

actually

#

I wonder if it's an ownership issue...

#

the items that I put in don't stay, it just gets reset

#

Still doesn't really explain why the stuff pulled from the config isn't being set as the inventory contents

#

or it can just not load the items

#

what

#

fml

#

I forgot the s in groups

opal sluice
#

I don't know if it's bc of that or something else

#

but I'm not making any modification on iteration of a hashmap

#

so I don't know where to look ^^'

shadow gazelle
opal sluice
#

And it doesn't point to any plugin's class

shadow gazelle
#

Probably better to ask in the Paper server

opal sluice
#

Ok, gonna try there, thanks ^^

odd sentinel
#

is there any consistent interface I can use to tell if a block is "usable" but doesn't store items like an anvil, crafting table, smithing table

shadow gazelle
#

Does Container cover all of those?

odd sentinel
#

not all no

#

well maybe some implement it without any sub interfaces, let me check

shadow gazelle
#

ah, yep

#

no smithing table

#

also no anvil

#

Assuming IDEA isn't high

odd sentinel
#

ya nothing I can see

#

I already am using InventoryHolder anyway which is a higher interface

shadow gazelle
#

What are you trying to do?

odd sentinel
#

I just want to know when a player right clicks them. I was hoping to avoid hard coding a list of materials

shadow gazelle
#

huh, I don't think those even have a block interface in Bukkit

odd sentinel
#

ya I wasn't seeing anything. was hoping someone knew otherwise

shadow gazelle
#

Paper doesn't even have interfaces for them

charred pollen
#

is there a way to format the entity health when adding it to message?

shadow gazelle
#

Format how?

charred pollen
#

when i add like 100 max health and text shows me like 70.5391593593

#

just want the 70

#

or 70.5

shadow gazelle
#

you could use Math#round()

charred pollen
#

thanks

opal sluice
gleaming grove
#

Is it possible to do something like this with YamlConfiguration ?

iron glade
waxen plinth
#

Is there no way to get the burn time of an item other than by just keeping a map manually?

kind hatch
gleaming grove
#
  1. because I will use custom property names in YAML, 2. even Bukkit use this approach
kind hatch
iron glade
#

is that an image as background lol

gleaming grove
gleaming grove
kind hatch
# gleaming grove is this common approach? does server owers not be confused by lack of `-` syntax...

The most user friendly approach is the example I provided. You can use the dash, but it makes it a little harder for server owners to write their configs properly.
The only downsides to this approach are all development related. I'm not sure if that example can be grabbed as a list directly as you would need to iterate over that section to get the skin you want. (You would be doing that anyways if you were converting it to a list, but ๐Ÿคทโ€โ™‚๏ธ )

I like to keep my configs simple to read and write. So things like serialized bukkit objects are not found in the configs that I make. How you structure your config really depends on how easy you want the end user to modify it.

gleaming grove
#

Right, even this approach will be easier to me easier for generic mapping to objects

drowsy helm
#

Java is saying the method doesnt exist. e is the same class as im editing wtf

worldly ingot
#

hidetoPlayer

#

vs hideToPlayer

drowsy helm
#

omg im dumb

#

thanks choco lol

worldly ingot
#

It's the simple things we miss

vocal cloud
#

A second pair of eyes is always useful lol

crude charm
#

Mongo is bar far the best db and no one will change my mind

dusk flicker
#

agree

crude charm
#

It so good to work with

dusk flicker
#

yeah

#

but everything has a usecase

crude charm
#

Having a getter and setter then one line to store / change it

๐Ÿ˜

drowsy helm
#

How do i cancel entity collisions with a remapped entity

#

iirc regular nms had a method to override

desert frigate
#

does the persistant data container ever get deleted?

drowsy helm
#

unless you do it manually, no

#

it is nbt, it stays with the entity

desert frigate
#

hm

#

i see

gleaming grove
#

Is it possible to display custom ShapedRecipe here?

worldly ingot
#

Yes. Force the player to discover the recipe

#

Player#discoverRecipe(NamespacedKey)

glossy lily
#

anyone know how to get a Rotation from where a projectile hit? i want to make it so an item frame is placed wherever said projectile hits

#

?whereami

glossy lily
#

the original message

glossy lily
#

somehow this is automatically done for me

quaint mantle
#

They mean if you can update your server to 1.19

#

Once done, update the API in your IDE

#

Once these two are done, SkullMeta will include the method that you need.
Let me know how it went ๐Ÿ‘๐Ÿป

sharp flare
crude charm
#

Why is my boolean not staying true?

    public boolean editing;

        public void onClick(Player player, int slot, ClickType clickType) {

            player.closeInventory();
            editing = true;
            player.sendMessage(CC.translate("&aPaste a new token for the discord bot - this will require a restart of the bot!"));
            player.sendMessage(String.valueOf(editing));
//prints true

        }
//different class
    public BotConfigMenu botConfigMenu = new BotConfigMenu();


    @EventHandler
    public void handleBotConfig(AsyncPlayerChatEvent event) {

        Player player = event.getPlayer();

        player.sendMessage("test");
//prints

        player.sendMessage(String.valueOf(botConfigMenu.editing));
//prints false

        if (botConfigMenu.editing) { //doesn't run this code
            plugin.getDiscordFile().set("bot.token", event.getMessage());
            botConfigMenu.editing = false;
            player.sendMessage(CC.translate("&aYour discord token has been updated to &f" + event.getMessage()));
            new BotConfigMenu().open(player);
        }

    }
glossy lily
#

might need that again soon

sharp flare
#

Mb didn't read whats below it

glossy lily
#

all good all good

sharp flare
crude charm
sharp flare
#

Re use the same object which holds the updated boolean value

crude charm
#

Unless you mean make a new boolean and get the value from that one

sharp flare
#

Is the first class above the BotConfigMenu?

glossy scroll
#

is BotConfigMenu editingstatic?

crude charm
glossy scroll
#

ok

#

then you need

#

?di

undone axleBOT
crude charm
#

Or could I make it static

#

I know di

glossy scroll
crude charm
#

Thats abuse

glossy scroll
#

also why is it public??

sharp flare
#

You can reference a singleton object but dependency injection is much better

glossy scroll
#

more conventional to just make it private and use a getter, no?

crude charm
#

Using @Getter would make it a private method?

#

am I wrong?

sharp flare
#

You gotta make it static then, or encapsulate it and use getter setters

glossy scroll
#

well currently its public

#

which is, fine... but getters are better

crude charm
#

Aight so it'll work if I just do

@Getter
@Setter
boolean sdifoghu;

boolean = true;

other class

class.getSdfighdi;
glossy scroll
#

you can use a public getter on a private variable

#

oh im not familiar with lombok

#

i generally dislike annotation processors (dont hurt me, just personal preference)

crude charm
#

Lombok is amazing

#

especially when working with alot of variables for mongo

#

and I mean alot

#

My player data class stores around 100 variables

#

and I just go @Getter @Setter without having to make one for each

#

saves like 1000 lines

sharp flare
#

100 variables......

crude charm
#

Well yeah - this is a massive plugin

glossy scroll
#

i mean 100 variables is doable

#

just use wrappers when necessary too

crude charm
#

I do

glossy lily
#

how would one identify where a memory leak is coming from

river oracle
#

take a look at maps and stuff

glossy lily
#

can anyone give me a list of things that cause them

glossy scroll
#

you could use eclipse's memory analyzer tool

glossy lily
sharp flare
glossy scroll
crude charm
glossy scroll
#

are the biggest cause

glossy scroll
#

heap dump + MAT from eclipse

glossy lily
#

collections as in lists?

glossy scroll
#

if you have any maps that can me migrated to WeakHashMap, i would look into it!

glossy lily
#

nope

#

used to

glossy scroll
#

yea your best bet is to use eclipse MAT with a heap dump

glossy lily
#

only list i currently have is a list for empty lore

#

which is just a list with nothing in it

glossy scroll
#

when using MAT, it can give you a leak suspects report

#

there are many articles online that also explain some vocab

glossy lily
#

alright ill try that

#

should i use spark to make the heap dump

glossy scroll
glossy scroll
#

i think MAT may be able to create one of a current runtime? im unsure tho, may also require vm flags

glossy lily
#

ill just use spark

glossy scroll
#

can spark make heap dumps?

glossy lily
#

/spark heapdump is a command

glossy scroll
#

i mean if it works it works ig

#

MAT will also give a leak suspects report

#

when it comes to spigot servers

#

theres always a leak suspect that involves the world/level, you need to ignore that one

river oracle
glossy lily
#

yes

#

i only have spark and my plugin

#

i wonder if i could add custom skins to my wip blood splatters

#

i imagine it would probably take a while to take the skin, put a blood overlay on it, and then change it to the outputted file

#

will play with that idea though

glossy scroll
#

you could always cache it async when the player logs

glossy lily
#

ooh yeah

#

or just when the player joins with a new skin for the first time, create a folder for that player which contains their skin with different blood overlays

spare marsh
#

Okay, so this might sound nooby but I have a question. Is it easier to send a JSON String from socket to socket carrying the data needed or whole objects like Packets? For example my own PlayerWinPacket and then the client getting the Object and casting it to that object or Sending a json containing the type of object as string and then retrieving the data from there?

glossy lily
#

might take up alot of storage so they'll be auto deleted after 3 days of inactivity

glossy scroll
#

json is easiest to read in a text form

#

but if you need something more efficient that takes up little space and doesnt need to be human readable, a serliaized packet approach could work as well

spare marsh
#

Yeah I'm okay with the serializing part, just asking which one would be more convenient.

glossy scroll
#

just up to what your goals are

spare marsh
#

It's a little hard here cause both work for me but Can't decide which one to go with xd

glossy scroll
#

i mean

spare marsh
#

If let's say, an exception occurs, It would be easier to get the data from the object received just getting the string form of the JSON object to see what is wrong with it wouldn't it?

glossy scroll
#

yes, gson adapters are typically easier to work with

spare marsh
#

Ah got it thanks.

glossy scroll
#

when working with plain text over the internet

#

its never a bad idea to encrypt if you can

#

just use a pair of keys on each end to encrypt/decrypt data

#

i suppose if your data isnt confidential or private you dont need to worry about that step lol

#

its also a bit overkill anyways for mc server

spare marsh
#

Yeah just need data like Integers and Strings from a certain event. Nothing too serious...

desert frigate
#
target.damage(10)
if(target.isDead()) {
...
}```
I want to damage the entity then check if it died from that damage or not but this code doesn't seem to work
spare marsh
#

@desert frigate Use EntityDamageEvent to check if the damage killed the entity

iron glade
#

check if the target's health minus the amount you want to damage is <= 0

desert frigate
desert frigate
#

not really an event

iron glade
#

Yeah than check if the damage is >= the target's health, if so kill it, otherwise set it's health minus the amount you wanna remove

desert frigate
#

there isnt a event

iron glade
#

and it's not working?

desert frigate
#

no it worls

#

works

#

i didnt say it didnt work

iron glade
#

okay, just the code you posted didn't work then?

desert frigate
#

this works

#

is there a way to "predict" the amount of exp a mob will drop

stoic oar
#

I was just wondering what the most optimal method for damaging entities near a location is.
My current method:
world.getNearbyEntities returns a collection, so I loop through all the mobs in the world, see if the collection contains that mob, and do damage to it
that seems like a bad way to do it though

sharp flare
#

Delay it by 2L or 1L, just debug it if it's not getting the new health

desert frigate
#

what-

#

i said it worked

young knoll
quaint mantle
#

guys does anyone here play hypixel skyblock?

river oracle
quaint mantle
#

:sadge:

weary cobalt
#

I feel like this is a pretty basic question, so just going to apologize in advance.

I'm wanting to create a Bungeecord Party plugin that when a player connects to a server, information about their party is sent to the Server, so that information can be used in the Minigame plugin for creating teams and such. I'm not sure what the best way to go about this would be, and I'm yet to find any good resources online.

If someone could help me out with this or point me in the right direction, it would be much appreciated. Thanks ๐Ÿ™‚

severe oak
desert frigate
#

e.g the item gets thrown into lava or the mob gets killed

river oracle
#

Well yea wouldn't that only make sense

#

That'd mean it would nolonger exist to persist on

weary cobalt
lime moat
#

Is there a way that you can prompt a resource pack even if they declined the first prompt?

#

I'm trying to make a command to allow the users to get the prompt even once they declined it.

crude charm
#

?bin

earnest forum
#

?paste

undone axleBOT
crude charm
earnest forum
#
public boolean syncNickName = plugin.getDiscordFile().getBoolean("bot.syncnickname");
#

will not update

#

when the file updates

#

it is set to the value that the file has AT THAT CURRENT TIME

crude charm
#

What about here?

earnest forum
#

u arent doing

#
syncNickname = false
#

anywhere

#

i searched through ur whole class

crude charm
#

Would that update it in the config though? In my Boolean I use #get, will it work to update?

earnest forum
#

no

#

you have to update both

crude charm
#

Aight

#

like this?

earnest forum
#

yes

crude charm
#

Aight ill give it a try, thanks

earnest forum
#

also your if statements are inverted

crude charm
#

fr?

#

ah yes

#

I see

earnest forum
#

if syncNickname is false you want to set it to be true

crude charm
#

disable to enable

#

yeah

earnest forum
#

yea

crude charm
#

Working now, tysm

#

might be ugly af

#

but it works

#

so what does it matter

lime moat
#

I have an event that handles if it declines and it triggers that every time.

drowsy helm
lime moat
#

Well, I have it on โ€œpromptโ€, but if I decline the first initial prompt, I want a command that prompts them even if they declined the first initial prompt.

#

If that makes sense

drowsy helm
#

if you decline it will automatically switch that to decline

lime moat
#

Hmm, is there no way to make that not happen?

drowsy helm
#

nope

#

just kick them and tell them to enable it

lime moat
#

Dang, thatโ€™s unfortunate. Yeah, Iโ€™ll kick them and tell them to enable it, thank you very much!

eternal oxide
#

I believe there is

#

if they don;t have the resource pack it will disconnect them with a message

eternal oxide
#

player.setResourcePack("pack_url", hash, "This server requires you enable resource packs!", true);

lime moat
#

I see, Iโ€™ll try this out tomorrow! Thank you for the response :)

eternal oxide
#

If the result of that event is DENY you kick them

drowsy helm
#

first line will auto kick them iirc

#

dont need to listen to status event

eternal oxide
#

yes you do, if they have it disabled the first line will be completely ignored

#

Players can disable server resources on their client, in which case this method will have no affect on them. Use the PlayerResourcePackStatusEvent to figure out whether or not the player loaded the pack!

lime moat
#

I have another question, how difficult would it be to log if a user has enabled a texture pack or not? For example, store their name into a file with something like texture-pack: false or texture-pack: true?

drowsy helm
#

Ah

lime moat
#

Iโ€™m trying to make a server that runs with and without a texture pack, but I just canโ€™t wrap my head around how to do this in a file ๐Ÿ˜…

eternal oxide
#

Can;t be done reliably. Once they log off or change the setting you won;t know

#

you can ensure everyone on yoru server has downloaded the pack is all

drowsy helm
#

yeah if they change settings that will void that config useless

drowsy helm
#

wait wrong reply lol

lime moat
#

I see, what appears to happen though, is I have setResoucePack on a join event and if they log off the server and log in again with the texture pack option disabled, itโ€™ll stay disabledโ€ฆ

Then if they change it to prompt, it prompts them & enable just enables it.

drowsy helm
#

having a server that runs with and without

#

sounds like a pain in the ass

lime moat
#

I think in theory it could work, just may be a bit buggy

lime moat
drowsy helm
#

ah

eternal oxide
lime moat
#

True, but back to the fileโ€ฆ how would I log it? Haha

eternal oxide
#

It will tell you if its disabled

drowsy helm
#

why do you need to log it?

eternal oxide
#

listen in the event and log their status

drowsy helm
#

just listen to the event and store it in mem

lime moat
#

Hmmm, okay. Iโ€™ve never stored anything that can be added, for example player data, so this will be quite interesting to figure out

eternal oxide
#

if you kick them in the event for having it disabled you can know for sure everyone thats online is using your pack

#

well, using both, the setPack and the event

lime moat
#

Yeah, Iโ€™m not sure if players would quit the server if it requires something like that though

eternal oxide
#

setPack kicks them if they decline it, the event kick them if its disabled.

lime moat
#

I just have a few debatable questions ๐Ÿ˜‚

drowsy helm
#
Map<UUID, Boolean> resourcePackStatus = new HashMap<>();

@EventHandler
public void onJoin(PlayerJoinEvent event){
  //set resourcepack
}

@EventHandler
public void resourcepackStatus(PlayerResourcePackSTatusEvent event){
  if status == declines or  failed download
   resourcePackStatus.put(player, false)
  else
   resourcePackStatus.put(player, true)

}```
#

then you can keep track of who has what

lime moat
#

I see, would this not fail if they log out of the server/the server restarts?

drowsy helm
#

no

#

they rejoin, and it sets the status again

#

its updated each time they join

lime moat
#

Oh perfect! Then, can I use these variables elsewhere?

eternal oxide
#

If the server restarts no one is online so no data to keep

drowsy helm
#

yeah obviously use a better structure

#

but thats the general flow of how it should go

lime moat
#

Gotcha, Iโ€™ll be trying this out tomorrow! I really appreciate your guysโ€™ help, I wouldโ€™ve for sure spent a week on this without you guys haha

brave goblet
#

does player death event only work for players? or

#
    @EventHandler
    public void onPlayerDead (PlayerDeathEvent e) {
        if (e.getEntity() instanceof Player) {
            //some code here
        }
    }

Cause i saw this code and was like hmmmmmmmmm ๐Ÿค”

drowsy helm
#

its in the name lol

#

EntityDeathEvent for any entity

brave goblet
drowsy helm
#

sorta useless you can blind cast it

brave goblet
#

alright

tender shard
sonic sky
#

Does Location#add() and Location#remove() change the location object or does it return a clone of the instance?

tender shard
sonic sky
#

Ah, that's probably why my plugin isn't working lol

tender shard
#

you can just do myLocation.clone().add(...) instead

weary cobalt
#

I'm trying to connect my Bungeecord and Spigot servers through PluginMessages and am struggling to figure out how use this effectively..

All I want to do is send a message from spigot plugin -> bungeecord, and have bungeecord return something. Basically, I want to create a "getter" to get a value from bungeecord and send it to the spigot server upon request from the spigot server.

I have experience with spigot programming, but little to no experience with bungeecord. If someone could guide me in the right direction that would be great. I've looked at multiple resources online with little to no information on how to do what I'm trying to do. The basic PluginMessage tutorials and forums havenโ€™t really helped me..

if anyone could help me, that would be great ๐Ÿ™‚

sonic sky
#

Thought so, thanks ๐Ÿ˜

shadow zinc
#

what is wrong with this code any why might give a stack overflow error?

#
    public static void unregisterGUI(InventoryGUI inventoryGUI) {
        if (inventoryGUI != null) {
            for (InventoryItem inventoryItem : inventoryGUI.getInventoryItems()) {
                if (inventoryItem.getAction() != null && inventoryItem.getAction() instanceof OpenInventory) {
                    unregisterGUI(((OpenInventory) inventoryItem.getAction()).inventoryGUI);
                }
            }
            if (!inventoryGUI.getPages().isEmpty()) {
                for (InventoryGUI page : inventoryGUI.getPages()) {
                    unregisterGUI(page);
                }
            }
            inventoryManager.remove(inventoryGUI);
        }
    }```
weary cobalt
drowsy helm
shadow zinc
#

do you need more code?

drowsy helm
#

assuming that for loop is calling the same inventory

#

make sure java unregisterGUI(((OpenInventory) inventoryItem.getAction()).inventoryGUI); isnt calling the same inventoryGUI

#

and you should be sweet

shadow zinc
#

is that .equals or ==

#

I can never remember

drowsy helm
#

== should do fine

shadow zinc
#

It appears that it didnt work

drowsy helm
#

wait so OpenInventory has an inventoryGUI right

#

why do you need to unregister it, unless it's already registered?

shadow zinc
#

yeah any inventoryGUI has to be registered

drowsy helm
#

probably better ways of coding that

#

seems uncessary

shadow zinc
#

register on open?

#

check if its not registered first obviously

drowsy helm
#

yeah

#

well it's hard to tell. I have no clue how your system works

shadow zinc
#

My code is public if you want to take a quick look

drowsy helm
#

sure

#

wait why are you trying to unregister the output of the openInventory anyway

shadow zinc
#

because I don't want previous inventories taking up memory

#

its constructed for each time it is opened

drowsy helm
#

gotcha

#

so new instance for each opened inv

shadow zinc
#

yeah, that way if you are doing database queries or something else weird it won't be old data

#

I could add an update method, but for now this should be enough

drowsy helm
#

why not make GUIAction just point to a class that extens InventoryGUI

#

and instantiate it when its called

#

say i had 10 GUIActions for one inventory, that would mean it makes 10 extra inventories, and thus 9 theoretically useless ones

#

unless im understanding incorrectly

shadow zinc
#

GUIAction is any action, not just open Inventory

#

I just made an OpenInventory action for ease of mind

drowsy helm
#

yeah but i mean when OpenInventory.action is called, create the inventory on demand

#

instead of having an instance already waiting

shadow zinc
#

Oh thats what I'm doing rn lol

drowsy helm
#

oh lol

#

yeah but either one of those forloops in unregisterGUI is calling itself recursively

#

meaning either the OpenInventory GUIAction or pages contains itself

#

or one of the pages of either contains the parent gui

shadow zinc
#

no thats very unlikely

#

I mean it might

drowsy helm
#

well thats the only reason it would be calling recursively

shadow zinc
#

well the gui I am testing shouldn't have a gui because it doesn't meet the conditions

#

a page is just an overflow inventory

drowsy helm
#

just print out the gui name or something in unregisterGUI and it will tell you what is calling itself

shadow zinc
#

and my action looks something like this now

#
    @Override
    public void action(InventoryClickEvent event) {
        if (inventoryGUI != null) {
            InventoryUtil.registerGUI(inventoryGUI);
            Player player = (Player) event.getWhoClicked();
            player.openInventory(inventoryGUI.getInventory());
            return;
        }
        throw new IllegalArgumentException("Inventory GUI does not exist.");
    }```
#

creating the inventory in it is a bit iffy but registering works for me

#

its also slightly irritating that you need to open the inventory using the inventory util instead of player.openinventory

drowsy helm
#

where are you creating the OpenInventory action itself

shadow zinc
#

in my other project, its on a command

drowsy helm
#

i feel this is more a matter of just refactoring data flow. you shouldnt need that many steps to unregister it

shadow zinc
#

I have thought about keeping a map of a players inventories and looping through that map to unregister it

drowsy helm
#

for my manager i just unregister it on close

shadow zinc
#

yeah the problem is that you can go back to your previous inventory

#

unregistering it would be problematic

drowsy helm
#

cant you just create a new instance again

shadow zinc
#

possibly, but that require me changing the inventory construction all together

#

possibly using a consumer?

drowsy helm
#

public class TestInventory extends CustomInventory {
    public TestInventory(MinecraftEnhanced plugin, Player player){
        super(plugin, player, UnicodeSpaceUtil.getNeg(8) + "&r&f\uF004", 27);
        for(int i = 0; i < 9; i++){
            int finalI = i;
            slotMap.put(i, e -> {
                Inventory inv = new TestInventory(plugin, player).getInventory();
                player.openInventory(inv);
            });
        }
    }

    @Override
    public Inventory getInventory() {
        return Bukkit.createInventory(this, size, Util.formatColour(title));
    }
}

This is my data flow for if i want to open the same inventory again

#

just create a new instance, it will auto close, unregistering it

#

no need to manually unregister

shadow zinc
#

that is better, but for me that would change a lot of things

#

and I don't know if reconstructing the gui on navigation is entirely effective

#

then again, neither is my unregister method

drowsy helm
#

effective or efficient?

shadow zinc
#

both

drowsy helm
#

i mean, you can reconstruct it with just the player right

#

dont need any external data

#

efficiency wise - its really negligible

#

creating an inventory barely uses any cpu cycles

shadow zinc
#

so how would I go about doing that?

#

I keep thinking about using a consumer with the instructions and then calling that on open

drowsy helm
#

on open -> register the inventory
on close -> unregister
open another inventory -> create new instance and register

#

thats how most people do it

#

rather than having the instance waiting to be opened, create it on demand

shadow zinc
#

oh right, I was definitely over complicating that

#

so here I do both

#
                    //Make sure it wasn't just another inventory being opened.
                    if (!InventoryUtil.getInventoryManager().isGUI(player.getOpenInventory().getTopInventory())
                    && player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) {
                        if (gui.getOpenOnClose() != null) {
                            InventoryUtil.openInventory(player, gui.getOpenOnClose());
                            return;
                        }
                    }
                    if (gui.isUnregisterOnClose()) {
                        InventoryUtil.unregisterGUI(gui);
                    }```
#

breadcrumb lets say

#

and then unregister

#

alright I will test that out

#

well it works, thanks for the help. Something you just need to talk things over to realize how dumb you are actually being.

drowsy helm
#

lmao no stress

young knoll
#

UnicodeSpaceUtil

#

Smart

drowsy helm
young knoll
#

Yeah I should get me some of that

#

My negative space stuff is currently very ugly

drowsy helm
#

you want the src?

young knoll
#

That would be great

young knoll
#

Converting to binary and using that, clever

#

Thanks

drowsy helm
#

nws

zealous osprey
young knoll
#

Yes

crude charm
#

Just want to confirm my memory that this is a key

#

so if I get all keys in a for loop then it will get all the ranks

young knoll
#

Yes

zealous osprey
#

Yes, you can also get every key by using the ".getKeys(true)" method I believe. Which would also return things like name, prefix,... If my memory serves me right

earnest forum
#

yes

#

returns

#

etc

crude charm
#

well

#

thats not what I want

earnest forum
#

so use false

#

getKeys(false)

crude charm
#

I wanna just get a name for all the ranks and get that seperatly

#

aight thanks

gloomy arrow
#
private @NotNull ShapedRecipe craftCocaine() {

        ItemStack cocaine = new ItemStack(Material.SUGAR);
        cocaine.addUnsafeEnchantment(Enchantment.DURABILITY, 1);

        ItemMeta cocaineMeta = cocaine.getItemMeta();
        assert cocaineMeta != null;
        cocaineMeta.setDisplayName(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Cocaina");
        cocaineMeta.setLore(Arrays.asList(
                ChatColor.AQUA + "" + ChatColor.ITALIC + "Cocaina pura",
                ChatColor.DARK_PURPLE + "Cuidado con los efectos..."
        ));
        cocaineMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        cocaine.setItemMeta(cocaineMeta);

        ShapedRecipe shapedRecipe = new ShapedRecipe(new NamespacedKey(this, "pure_cocaine"), cocaine);

        shapedRecipe.shape("SSS", "SSS", "SSS");
        shapedRecipe.setIngredient('S', Material.SUGAR);

        return shapedRecipe;

    }
#

One question, have changed the way you make custom recipes?

drowsy helm
#

Nope

#

Give me a kilo and Iโ€™ll tell you how to do it

gloomy arrow
#

I am not getting the craft

#

Then, in the onEnable method, I register the recipe

drowsy helm
#

Show

crude charm
#

If I wanted to get say the suffix for all, how would I? Like for every key I want to get the suffix

ivory sleet
#

You can iterate through all the keys at the same level and then invoke getConfigurationSection followed by getString where you pass the "suffix" as the path (ofc always check for nullability)

remote swallow
#

On your cocainMeta.setDisplayName if you have the ChatColor.'s put .toString() on it to not havr an empty string

ivory sleet
#

The way they do it works just fine

earnest forum
#

+ "" already does .toString()

ivory sleet
#

No it doesnt

earnest forum
#

concatenation does

ivory sleet
#

It does String::valueOf

earnest forum
#

whats the difference?

ivory sleet
#

Null safety

#

null -> "null"

small current
olive lance
#

Man why 9 sugar > cocaine. Put some leaves in the recipe

rough drift
#

Owner, name, prefix and then suffix

ancient plank
#

toner.bame

grim ice
#

im bored

young knoll
#

Remake hypixel skyblock fully 1:1

#

In 3 days

eternal oxide
#

I have never played a mini game

#

actually I've never played on anyone elses server

#

other than a few minutes on on streamers server

tardy delta
#

never been on hypixel or smth?

eternal oxide
#

nope

tardy delta
#

oh thats even worser than me lol

torn shuttle
#

remind me, players damaged by creeper explosions doesn't trigger the entitydamagedbyentity event right?

ebon stratus
#

Hi! How can i make it so that when the player clicks an item in my inventory it opens an website on his pc (opens that "are you sure you want to open the following website?" screen) ?

tardy delta
#

send the player a textcomponent which will open a link when clicked

tall dragon
#

yea the "open link" screen itself is client side

#

you cant force open that

tardy delta
#

might work

tall dragon
#

sincerely hoping thats a joke uhok

rough drift
ebon stratus
#

thanks

rough drift
#

there's a click component that triggers open url

tall dragon
#

yea obviously

#

but player has to click it

#

so no u cant

rough drift
#

yeah

#

can't force