#help-development

1 messages · Page 405 of 1

eternal oxide
#

near teh botton is using multiple configs

#

what class you put them in is upto you

#

you do not need to make a string object for every entry in your config

regal scaffold
#

I didn't ask "Using custom configurations".

Do you guys use built in fileconfiguration to do your big configs?
Or what good alternatives is there

Meaning I know how to do with with that resource but I was wondering if people use different resources for that

eternal oxide
#

the config is already loaded into memory so it already contains ALL of your strings in a map

regal scaffold
#

Currently I'm using a combination of getConfig() where I need it and storing the paths somewhere

#

But just doesn't seem the best using that every single line there is a message for example

eternal oxide
#

A constants file for paths

regal scaffold
#

Yup

#

That's what I have

#

So that is what's recommended then

eternal oxide
#

thats what I often use

regal scaffold
#

Hmmm

eternal oxide
#

simplifies fetching config data and a single point to modify paths

regal scaffold
#

Yeah that is true

#

Does a Map#get() loop through every element in the map? I assume that's really inefficient

eternal oxide
#

it does not

regal scaffold
#

Is that not a good alternative? key -> value?

eternal oxide
#

how you access yoru map is upto you

regal scaffold
#

Yeah you are right about that

eternal oxide
#

a Map stores by Hash value

lost matrix
# regal scaffold Does a Map#get() loop through every element in the map? I assume that's really i...

Really depends on the implementation of the map.
But i dont know a Map impl where this inefficient approach is used.
Generally you would use a HashMap which uses hash buckets underneath
to provide a O(1) time complexity. This means the map will be as fast with 10
elemts as it is with 10.000 elements.
You can read more about that in 3.1 of this forum post where i explain
shortly how time complexity works:
https://www.spigotmc.org/threads/guide-beginners-guide-on-improving-your-codes-performance.396161/

regal scaffold
#

I see, but how do you implement configurations + lang

#

Do you do anything different to what's in ?config

smoky oak
#

do it on chunk load and its a very minimal thing

regal scaffold
#

Do you getConfig# every time you need something? Do you store it somewhere?

wet breach
lost matrix
#

I generate my language files dynamically. There are different approaches but i would not
write my lang files from hand. In this case i used an enum, write the default values in there
and let the user translate what is needed in the generated language file.

regal scaffold
#

Ok yeah perfect

lost matrix
wet breach
#

However most people dont need or shouldnt need to worry about time complexities until it is an issue

regal scaffold
#

But then, do you access it like I said above? getConfig#getString(Translation.Whatever)

lost matrix
regal scaffold
#

Ok that's exactly what I thought

#

Do you store stuff in a list of strings? hashmap?

lost matrix
#

In this case i use an enum

#

With a mutable field

wet breach
#

Or you turn that data into an object

lost matrix
#

Last line shows translation usage

regal scaffold
#

ooooooo

#

Alright alright, thanks a lot. That showed me exactly what I needed to know

lost matrix
#

But explore a bit. Translations are always a hustle. Ive also used a system where i literally
replaced text in outgoing packets because i could just be really lazy in my code and
not worry about translations. But that felt a bit hacky.

regal scaffold
#

I see

#

I like what you did with translations

#

Do you do something similar with config values?

wet breach
#

Just dont over use enums

regal scaffold
#

Yeah

wet breach
#

They are handy but they do come with a catch for using them lol

regal scaffold
#

What's the catch?

#

Can't leave me hanging like that

wet breach
#

Enums are static

#

Stuff too many in a single class and you enounter various issues optimizations by the jvm being among the few lesser known ones

regal scaffold
#

Alright fair, gotcha

#

Smile how do you load the values into the enum?

#

I assume your Message.sendInfo# method gets the value

wet breach
#

You just put the value in the parenthesis

#

Have an example

regal scaffold
#

lol I know that

#

I mean

#

His first parameter is path, second is default

#

Path doesn't convert automatically to the config value

#

So I assume his Message#sendInfo method does that call

remote swallow
#

he probably modifies it on startup

wet breach
regal scaffold
#

Wait wut

remote swallow
#

im guessing from his var names, that enum gets loaded into translations.yml on start up if not exists, if it does it just modifies the enum

regal scaffold
#

ooooo

wet breach
#

You can put objects in an enum

regal scaffold
#

So he replaces the path with the value on startup

remote swallow
#

probably the value

wet breach
#

Thr enum cant change but the object can

#

Or the value as its better known like epic said

#

You can even use an enum to create objects too

regal scaffold
#

Ok ok time to code a bit

wet breach
#

Just stuff inside the enum new whateverobect() lol

ivory sleet
#

Use resource bundle api if u gonna go with a language locale thingy

small current
#

How to check if an itemstack can be placed when right clicked?

rotund ravine
#

Lowercase

#

Reeeeee

eternal oxide
#

pitchfork time!

remote swallow
#

phon prob

orchid gazelle
small current
echo basalt
#

uhh

#

that's specific

#

wouldn't say so

#

it's also only applicable under certain circumstances

green falcon
#

anyone know a good plugin to store arbitrary persistent user data and sync it across multiple spigot instances? I saw HuskSync looks like a somewhat decent solution but also MySQL Player Data Bridge

tender shard
#

what issue?

#

it's working fine

eternal night
#

alex back paperOhhh

rough drift
#

Is there any way I can replicate the effect of clicking on a sheep with wheat?

#

I came up with

if(entity instanceof Breedable breedable) {
  breedable.setBreed(true);
  // play effect
}
#

This should work right? Though some mobs that extend Animals such as Sheep have loveModeTicks

#

I figure that setting breed to true will override that

wet breach
#

lots of stuff goes out the window when I am on my phone because it is too much of a pain otherwise lol

river oracle
regal scaffold
#

Man, Copilot is nuts

remote swallow
#

activate windows

regal scaffold
#

It's so smart

#

I format too often cba

remote swallow
#

it saves the key to ur microsoft account

regal scaffold
#

Not after years

remote swallow
#

ah

tender shard
regal scaffold
#

Hey, I have reached another "issue"

My placeholder manager

#

Currently I have like 40 placeholders for everything. But this method is getting kinda crazy, it's so big now

#
        placeholders.put("%current_upgrade_members_tier%", ultraChest.getCurrentUpgradeMembersTier());
        placeholders.put("%current_upgrade_members_value%", ultraChest.getCurrentUpgradeMembersValue());
        placeholders.put("%next_upgrade_members_tier%", ultraChest.getNextUpgradeMembersTier());
        placeholders.put("%next_upgrade_members_value%", ultraChest.getNextUpgradeMembersValue());

imagine that but 50 instead of 4

#

What can I do to manage this better

#

PlaceholderAPI is not an option*

green falcon
#

extra verbosity is readability really ya? thats why we have code folding

ivory sleet
#

Not always

hazy parrot
#
 @Suppress("UNCHECKED_CAST")
    private fun <T> getPlaceholderMap(entity: T): Map<String, String> {
        val fields = entity!!::class.members
            .filterIsInstance<KProperty1<*, *>>()
            .map { it as KProperty1<T, *> }.filter { it.visibility != KVisibility.PRIVATE }
        return buildMap {
            fields.forEach {
                val value = when (val uncheckedVal = it.get(entity)) {
                    is Float -> String.format("%.2f", uncheckedVal)
                    else -> uncheckedVal.toString()
                }
                this["%${it.name}"] = value
            }
        }
    }
#

and entity being for example

data class NodeInfo(private val node: Node, private val nodeStatus: NodeStatus, val runningServers: Int, val ramUsed: Long, val diskUsed: Float, val cpuUsed: Double) {
    val name = node.name!!
    val description = node.description ?: ""
    val location = node.retrieveLocation().execute().shortCode!!
    val maintenance = if (node.hasMaintanceMode()) "On" else "Off"
    val allocationsCount = node.retrieveAllocations().execute().size
    val ramLimit = node.memoryLong
    val memoryUsageBar: String
        get() = MemoryBar(ramUsed, ramLimit).toString()
    val diskLimit = (node.diskLong.toFloat()) / 1024
    val status = nodeStatus.message
    val statusEmoji = nodeStatus.emoji
}
#

according to that, for example "%status" will resolve to nodeStatus.message

regal scaffold
#

Jesus

regal scaffold
#

@lost matrix You use ACF in all your plugins right

native gale
#

Is there a way to deduce, how many exp will renaming an item take?

regal scaffold
#

wym?

hazy parrot
#

Copilot is probably most hyped and least useful tool I ever encountered

regal scaffold
rotund ravine
#

It’s nice

#

Nicer than bukkit

hazy parrot
# regal scaffold No way

I never found it useful aside for simple copy, paste tasks, I even disabled it rn because it's pretty annoying to always suggest crappy code

regal scaffold
#

Well yeah

#

The options are

#

Doing that or using acf

lost matrix
regal scaffold
#

I mean ACF is considered a decent command lib as far as I know

#

Definitely seems fine if you don't dig too deep

lost matrix
#

It has a steep learning curve and is really hard to master

regal scaffold
#

A bit confusing at the start

#

I can tell

#

Like I'm just staring

#

At idk wtf

#

What's confusing me rn is how can you have a command with any parameters, where is it even getting those parameters from

#
    @Default
    @Subcommand("list")
    @Syntax("<+tag> [page] or [page]")
    @CommandCompletion("@residencelist")
    @Description("Lists all of your or another players residences.")
    public static void onList(Player player, String[] args) {}
#

For example

#

That's what acf is

#

It's an example from their wiki. I'm just trying to understand it

lost matrix
#

You need to look into context resolvers. They are used to resolve an argument (String) into
an instance of your parameter (T)

regal scaffold
#

Ahhhh I see that part now

lost matrix
regal scaffold
#

Straight from their wiki so idk

#

wym no

#

It's literally straight from the wiki

native gale
#

Sorry, I think you misunderstood me. What I mean is ```java
double deduceExp(ItemStack stack, String name) {
// returns how many EXP will it take to rename the item
}

regal scaffold
#

idk why he uses it but yeah, odd

#

What

#

the f

#

Ok I sort of understand contexts

lost matrix
#

Those are the default context resolvers

regal scaffold
#

yeah yeah I noticed

#

So pretty much they have a way to convert parameters straight into "objects"

#

I mean it's kinda cool

#

I gotta be honest tho

#

You can tell aikar makes libraries and not plugins

#

Bukkit implementation it is

#

It's so massive

#

Wait so @lost matrix What you're saying is

#

I can have a command like /block add

That will automatically get the block the player would be looking at using custom context resolvers

#

So I will have the block as parameter from the start

remote swallow
#

you shouldnt need a context resolver for that, you just get what block the player is looking at

#

if you have /block add MATERIAL you would need a context resolver iirc

regal scaffold
#

Oh you are right, I checked it the wrong way

remote swallow
#

you also can use just Player player, instead of CommandSender

regal scaffold
#

If I have an enum with


NAME("path","value");

How do I populate the "value" field on startup

brave sparrow
#

What do you mean

regal scaffold
#

I have an enum containing elements that have a path field ( preset ) and a value field ( startup ) to get stuff from my config file.

I want to assign the correct value to each element on startup from the config using their own path value

#

But since it's an enum I'm a bit confused on how to do that correctly. I know how to get the value I just don't know how to correctly assign it

brave sparrow
#

You do it in the enum’s constructor, but you need to make sure the enum doesn’t get referenced until after the plugin is loaded

quasi flint
#

why enum?

regal scaffold
#

Oh ok! I got it then

#

So if my enum is called ConfigPath

    ConfigPath(String path, String value) {
        this.path = path;
        this.value = plugin.getConfig().getString(path, value);      
    }

That would do the trick right?

#

Or alternatively I could just do it every time I need it instead

eternal oxide
#

add a getValue method to the enum

brave sparrow
regal scaffold
#

Gotcha

brave sparrow
#

You don’t need to be fetching it every time, but you also don’t need to fetch it all at once

regal scaffold
#

Now I'm thinking tho...

#

What if some of these values aren't a string but they're something else like a StringList

eternal oxide
#

fetching from config is fine as that is already in memory

regal scaffold
#

Then I can't do it this way

eternal oxide
#

it's just a map lookup

brave sparrow
#

You can

eternal oxide
regal scaffold
#

Yeah yeah I got it

#

Different things

#

This is a path

#

Just the path

#

I should make a different thing to get whatever is behind it

#

Which could just be getConfig()#getWhatever

#

Can't mix them up

brave sparrow
#

Alternatively you could do it with just the path I guess

#

It wouldn’t be the cleanest thing

#

But you could do something like

regal scaffold
#

Well if I have an enum of paths, I can just use getConfig()getList(Enum.WHATEVER)

brave sparrow
#

public <T> T getValue(Function<String, T> configLoader)

regal scaffold
#

And if I want I can make something to summarize getConfig()getList into more stuff I need

brave sparrow
#

But you probably don’t need to do it that way lol

solar mauve
analog thicket
tawdry cedar
#

Using Simple-Yaml and Java Swing btw

eternal oxide
#

you need to load the yaml file before you add to it

#

then save

tawdry cedar
#

Did I really forget that 🤦 LOL

#

Thank you

visual laurel
#
java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:233) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:53) ~[patched_1.17.1.jar:git-Purpur-1428]
        at dev.bentech.hideandseekplugin.HideAndSeekCommand.<init>(HideAndSeekCommand.java:17) ~[hideandseekplugin-1.0-SNAPSHOT.jar:?]
        at dev.bentech.hideandseekplugin.HideAndSeekPlugin.onEnable(HideAndSeekPlugin.java:11) ~[hideandseekplugin-1.0-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[patched_1.17.1.jar:git-Purpur-1428]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:323) ~[patched_1.17.1.jar:git-Purpur-1428]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1233) ~[patched_1.17.1.jar:git-Purpur-1428]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:322) ~[patched_1.17.1.jar:git-Purpur-1428]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalStateException: Initial initialization
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:236) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:53) ~[patched_1.17.1.jar:git-Purpur-1428]
        at dev.bentech.hideandseekplugin.HideAndSeekPlugin.<init>(HideAndSeekPlugin.java:6) ~[hideandseekplugin-1.0-SNAPSHOT.jar:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
        at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
        at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) ~[?:?]
        at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) ~[?:?]
        at java.lang.Class.newInstance(Class.java:645) ~[?:?]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:85) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.1.jar:git-Purpur-1428]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:419) ~[patched_1.17.1.jar:git-Purpur-1428]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:322) ~[patched_1.17.1.jar:git-Purpur-1428]
        ... 3 more
[17:03:59 INFO]: [[Simple Hide and Seek]] Disabling Hideandseekplugin v1.0-SNAPSHOT```
Heya, I've created a 1.17.1 plugin and trying to run it but it isnt working and disables with this error, i get no errors in IntelliJ, any ideas on a fix?
brave sparrow
#

You can’t make a new instance of your plugin class

brisk estuary
#

Hey. I want to create a custom item that disappears after some time. Does anybody know if it is possible?

#

It must disappear even if it is inside a chest

dry yacht
# brisk estuary Hey. I want to create a custom item that disappears after some time. Does anybod...

It surely is possible, but I don't think it'll be trivial. You basically have two options: Either track the item to always know it's location (inventory/container, chunk if it's dropped) or scan all possible containers and entities of all chunks ever created, which is... not really viable.

Another third way, which would be easier, is to just destroy the item when it's used, as that also effectively limits it's lifetime. Who cares if it's in some sort of chest, if it cannot be used or even taken out of the chest without being removed.

eternal oxide
#

store the creation time on the item (PDC). Start a timer, delete it when the time runs out (if held by a player). listen to InventoryOpenEvent and delete any expired items.

visual laurel
brave sparrow
#

?paste

undone axleBOT
brave sparrow
#

Paste it there

dry yacht
brave sparrow
#

No

eternal oxide
#

it only has ot scan for a specific item and check a byte on it's PDC IF found

brave sparrow
#

You only check the chest they’re opening

brave sparrow
#

Not all containers always

eternal oxide
#

yep, only each chest as it opens. not a heavy load

brave sparrow
dry yacht
#

Yeah, I get that, but you're still having to do that for all chests opened, as you don't know this ahead of time. So all ever opened chests will get a full scan.

visual laurel
brave sparrow
brisk estuary
#

Thanks for the tips guys

eternal oxide
brave sparrow
brave sparrow
#

Aha

#

Ok now HiderFoundEvent please

visual laurel
brave sparrow
#

That’s your problem

#

The handler list methods are returning null

pseudo hazel
#

you need a static handler list which you forgot

brave sparrow
dry yacht
# eternal oxide yes, still not a heavy load. hardly any at all

Didn't say heavy even once. I called it expensive, which it is. It's total overkill. If the item offers some special effect, just remove it when it's trying to be used after it's lifetime elapsed and notify the player. That's a compromise to not increase workload on every chest block container opening. What if the player keeps it in their inventory? Do you also scan inventory slots on every chest opening?

This decision is up to the person who asked the question tho, so I guess it has been answered plenty already.

brave sparrow
dry yacht
#

Great mindset. Death by a thousand cuts, :).

visual laurel
brave sparrow
#

Premature optimization is the root of all evil

pseudo hazel
#

well I think there is a middleground between premature optimization and setting yourself up for failure

dry yacht
#

It's called non-pessimization, not optimization. Optimizing is something completely different.

dry yacht
#

Whatever, not going to pollute the chat with this kindergarten anymore. The person who asked needs to decide on their own.

brave sparrow
#

And scanning 30 slots is not going to have any measurable difference on the performance of the server

dry yacht
#

Because you have to do that on all ever opened containers, for no good reason whatsoever.

pseudo hazel
#

if you can easily solve the problem with a less expensive method you should go for it

dry yacht
#

Yes, for ever from the point on that the feature got implemented

brave sparrow
dry yacht
#

It's not a do once thing, as you don't know how many of these items are around

pseudo hazel
#

okay well then I read wrong

dry yacht
#

If they do know and it's only temporary, that's another thing. I'm not so sure about that tho

pseudo hazel
#

well maybe all existing ones are just shite

dry yacht
#

I was just proposing the idea that removing the item when it's used is cheaper than checking on every container opening, as they probably already have a routine for use detection in place.

#

If you don't agree with that, it's either personal preference or ignorance.

brave sparrow
#

Avoiding 30 cheap if statements is a micro optimization at best

dry yacht
#

I don't care if it's micro, but it should be the first thing coming to mind to somebody who uses their brain while programming.

brave sparrow
#

If they want the item to vanish when it expires then having it disappear on use is not the desired effect

brisk estuary
#

The item I want to implement is basically a resource used in other recipes. It must expire/disappear after 1 day.

dry yacht
brave sparrow
#

If they want it to expire and it’s trivial to make it expire with no real cost, there’s no reason to have it not expire

dry yacht
pseudo hazel
#

whats the difference, the item will be destroyed in any case no?

brave sparrow
#

^

pseudo hazel
#

oh I see

#

yeah

brave sparrow
#

It’s also still taking up space in their chest until they actively get rid of it

#

Which I can see being fairly annoying in large quantities

pseudo hazel
#

plus it would not be as bad if there are multiple of those items in a container, then its no performance loss to loop through the container as you need to check them all anyways

brave sparrow
#

There’s not really a performance loss anyway

#

The maximum size of an inventory is 36

pseudo hazel
#

well not really but I get your point

brave sparrow
#

You’re running it on a redstone computer if that causes you issues

pseudo hazel
#

lmao

#

i think byte wasnt suggesting it would impact your performance to do one loop

#

its just like a mindset thing ig

brave sparrow
#

It’s premature optimization

#

There’s no reason to sacrifice functionality when the desired implementation comes with no actual cost to it

pseudo hazel
#

okay

brave sparrow
#

It’s not a matter of implementing it with care and not doing things unnecessarily, it’s a matter of actually not implementing it and implementing something similar to avoid checking 36 slots when a chest opens

pseudo hazel
#

anyways i think we solved the problem

brave sparrow
#

I agree

quaint mantle
#

Hi , how to make command in jycraft ?

chrome beacon
#

What is that

quaint mantle
# chrome beacon What is that

a plugin or api for making plugin with python in minecraft ! just search google but in docs is not write " How to make Command " Lol but write " How to Spawn Chicken"

chrome beacon
#

Looks like jycraft hasn't been updated in 8 years

quaint mantle
eternal oxide
#

if you know Python it's not a great leap to Java

pseudo hazel
#

yeah I wouldnt use that xD

#

and just start using java instead or make another project haha

vocal cloud
#

The lengths python devs will go to not touch grass

solar mauve
#

this time, you are rotating around z axis

#

learn math bro, there are plenty types of tutorials out there about sin, cos, vectors, dot product, equations, and stuff

#

take a careful look at your video, see how your shape is floating at 90 and 180 degrees

#

ok anyways

#

is anybody familiar with minecraft skins?

#

what is the color limit for a minecraft skin?

#

24 bits? 32 bits? 64?

#

or 256 highcolor?

analog thicket
solar mauve
tardy delta
#

gotta learn python for ai 🥹

#

super().__init__(0, -1) 🥹

solar mauve
# analog thicket Well the one you replied to is fixed. I only had one error and that was a little...
WorldServer world = ((CraftWorld) player.getWorld()).getHandle();

stand = new EntityArmorStand(world, center.getX(), center.getY() + 3, center.getZ()); // instantiate with a defined position
stand.n(true); // set marker (tiny)

conn.sendPacket(new PacketPlayOutSpawnEntityLiving(stand)); // spawn object
conn.sendPacket(new PacketPlayOutEntityMetadata(stand.getId(), stand.getDataWatcher(), true)); // send metadata

idk, i am spawning it like this, maybe there are some differences between versions in spawning and setting locations, idk...

rare flicker
eternal night
#

that is the API way of implementing PotionEffectType for the static constant values you get via PotionEffectType

tardy delta
#

i learnt what enums are today in college 💀

tardy delta
#

teacher asked me "oh is this easy for you"

rare flicker
rare flicker
eternal night
#

what ?

#

when you create a potion effect

analog thicket
solar mauve
eternal night
#

PotionEffectType is abstract because it is also implemented internal in the server (for some reason)

analog thicket
#

I found out it was there was an extra 1 on x. Didn't find out why tough.

thorn crypt
#

Yo, I’m trying to make a thing that when you right click a armorstand it open a GUI and you can edit some thing, but what is the best way to store the clicked armorstand to make edit on it when I do inventoryclick event ?

eternal night
#

store the uuid of the clicked armor stand in the inventory holder

#

retrieve it on click

thorn crypt
#

I’ll try that, thank you

rare flicker
# eternal night PotionEffectType is abstract because it is also implemented internal in the ser...

i get that but you can still do this

public static final PotionEffectType SHIVERING = new PotionEffectType(0, new NamespacedKey(OMCPlugin.i, "someKey")) {
    
    @Override
    public boolean isInstant() {
        // TODO Auto-generated method stub
        return false;
    }
    
    @Override
    public String getName() {
        // TODO Auto-generated method stub
        return null;
    }
    
    @Override
    public double getDurationModifier() {
        // TODO Auto-generated method stub
        return 0;
    }
    
    @Override
    public Color getColor() {
        // TODO Auto-generated method stub
        return null;
    }
};
public void applyPotionEffects(Player p) {
    p.addPotionEffect(new PotionEffect(SHIVERING, 60 * 20, 1));
}
eternal night
#

yea

#

is that pretty to do for all potion effect types ?

#

no

#

is hence a simple implementation useful ?

#

yes

hexed falcon
#

for some reason this cooldown isn't working, is there something wrong with the code?

rare flicker
#

oh

#

OOOOHHH

#

okay i got it

eternal night
rare flicker
#

you can't really extend potionEffectType and have a static instance cleanly

#

wait yes you can

#

ghdfhgdfhfg

livid dove
#

just got back from work so couldnt keep the topic going.

To clarify what I was asking is less "We wanna make this utterly work ayeeee" and more "We know it can effect tps, but removing AI and collision hypothetically should remove most the TPS issues, are there any other issues we are missing before we go and do the funni plugin writing"

eternal night
tardy delta
#

man i saw some weird code in class today

eternal night
orchid gazelle
hexed falcon
tardy delta
#

public class cooldown which holds a map of cooldowns 🤔

livid dove
#

What are you wanting it to do and where is it called ?

hexed falcon
#

this is where it should be used

livid dove
#

Oh boy weve got quite a bit to unpack here

thorn crypt
eternal night
pseudo hazel
#

why spoiler

eternal night
#

because its a paper link 😅

thorn crypt
#

x)

remote swallow
livid dove
# hexed falcon It's supposed to put a 1sec cooldown after the item is used

Question 1:

Your setupCooldown method. What is it declared as. A public static.... something....

What does that something mean

Question 2: Is it a global cool down for every player (one player does it, everyone gets a cooldown) or is it per player?

Question 3: if question 2's answer is "per player" why are you attempting to "setup a cooldown" the moment the server is booted up?

#

Steaf

#

its to help em out

#

i know

pseudo hazel
#

oh

#

I thought you asked the question xD

twin venture
#

hello , quick question , about InventoryClickEvent
Inventory clickedInventory = event.getClickedInventory();
if (clickedInventory instanceof PlayerInventory ||
clickedInventory instanceof AnvilInventory ||
clickedInventory instanceof EnchantingInventory) {
return;
}

#

is there one for EnderChest?

#

EnderChestInventory?

livid dove
pseudo hazel
#

yeah I see now haha

frosty cairn
#

hi, if i folow this guide after enabling iptables and doing the comand the server become inaccesible

tawdry parcel
#

What's wrong with that? name.playSound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);

thorn crypt
#

I don't understand how InventoryHolder work can someone explain me how do I store armorstand's uuid in it and retrieve it ? 🥲

frosty cairn
#

I do this comand
iptables -I INPUT ! -s ip -p tcp --dport 25560:25570 -j DROP
then
dpkg-reconfigure iptables-persistent

hexed falcon
livid dove
pseudo hazel
twin venture
#

i dont think its avillable for me ?>?

eternal night
#

inventory type is not the same as inventory

pseudo hazel
#

make a new variable called like armorstand of type uuid

livid dove
pseudo hazel
#

and then just put the armor stand uuid in it, which should be easy enough

#

what does static mean

eternal night
thorn crypt
hexed falcon
eternal night
#

an enderchest is just a normal chest in regards to the inventory size

thorn crypt
#

@pseudo hazel

pseudo hazel
#

and then I think you can get it back when you use world.getentity(uuid) or something

livid dove
pseudo hazel
#

yes something like that

#

keep in mind java code style would be armorstandUuid or armorstandUUID

#

no underscores

thorn crypt
#

Ok

hexed falcon
pseudo hazel
#

but thats basically it

twin venture
eternal night
#

Inventory#getType

pseudo hazel
#

since you made it private you need getters and setters to actually get the object

eternal night
#

returns you an InventoryType

livid dove
#

No so then what should I change

thorn crypt
#

Yo I got a problem, when I compare the inventory with the created inventory if another player open the inventory, the old player can take every item in it

eternal oxide
#

You are not tracking who has the inventory open correctly. You can get the viewrers

thorn crypt
eternal oxide
#

the click event should tell you who clicked

thorn crypt
eternal oxide
#

its your inventory so you need to keep track of who can or can;t use it

quaint mantle
#

Any way to get the amount of a block of type broken by a player starting from a certain timestamp?

eternal oxide
#

not unless you track it

#

statistics are totals

quaint mantle
#

Can I just store the value in the pdc of the player?

ivory sleet
#

I mean yeah you can

quaint mantle
#

Would you reccommend doing it though?

hazy parrot
#

It really depends on your use case

#

If it doesn't need to be persistent, you can just use map

quaint goblet
#

yo
does worldguard guard the whole world
or can i select certain regieons

quaint mantle
orchid gazelle
#

@quaint mantle can I get more FPS IRL now?

hazy parrot
rare flicker
#

How can i accurately check if a player is in water?
currently i check for waterlogged blocks, but have to manually check for : Water, kelp, seagrass, tall_seagrass, bubble columns

is there a way to automate that?

remote swallow
rare flicker
#

since when ; -;)

quaint mantle
orchid gazelle
quaint mantle
#

Do server freeze when async task calls method from another class?

quaint mantle
orchid gazelle
orchid gazelle
hazy parrot
quaint mantle
#

Oh ok

orchid gazelle
#

But you can schedule sync tasks in your async task if you want

rare flicker
#

this returns true if the head is above water

remote swallow
#

there location is there feet so it probably bases it off that

orchid gazelle
#

What you are looking for is to check if the player is UNDERwater, not IN water huh?

#

Then you can just use your location and write a method to compare the Type to all the Types you want

echo basalt
#

under water is checked by getting the eye location and seeing if it's equal or below the water line

#

so you'll need to check for water levels for that stuff

#

you can simplify half the process and the cheapest check is probably a isSwimming check

granite burrow
#

Is it possible to access the spigot Web API from a webserver (not associated with the Minecraft server)

opal juniper
#

not unless you make it possible

opal juniper
dry yacht
granite burrow
#

I want to get the information from my spigot account to display on a website/discord bot how much plugins I have made with links to each. I know its possible to get that using the Xenforo Resource Manager API, however, it doesn't seem to work on website when I tired it

dry yacht
dry yacht
granite burrow
#

yeah

dry yacht
#

What data is it that you need? That will decide the way you'll have to handle it

tawdry echo
#

what look sorted list of eventpriority by weight

granite burrow
#

idk if im allowed to share links here so I didnt post the link I used to get that, but its just using the getResourcesByAuthor part of the API

dry yacht
# granite burrow I want to get all my uploaded resources data, which I have the link to do everyt...

I've used https://spiget.org/ before, which basically crawls spigot and caches the results, as far as I know. It's a nice API, which should allow you to list your own resources. It also should have a CORS wildcard on it's responses.

echo basalt
echo basalt
granite burrow
quaint mantle
#

I success to recevie byte[] from forge client, but how to decode it? I tried with ByteArrayDataInput in = ByteStreams.newDataInput(message); String subchannel = in.readUTF(); but it not work, it return java.lang.IllegalStateException: java.io.EOFException tried byte[].toString() and String subchannel = new String(byte[], StandardCharsets.UTF_8); but it return ☻UnpooledHeapByteBuf(ridx: 0, widx: 32, cap: 32/32)

dry yacht
echo basalt
#

Byte streams aren't like json where you know what's the next key type

#

If you try to read an int (32 bits aka 4 bytes), and only have 2 bytes left, you reach an EOFException

#

If there's no UTF data, and you're trying to read UTF data, you'll face an EOFException

#

I'd probably study the forge protocol a bit more before trying to read data blindly

quaint mantle
#

this what i send from client byte[] bytesTask = "mot hai ba bon// nam// sau// bay".getBytes(StandardCharsets.UTF_8); PluginMessages.sendMessage(new BukkitPacket(new FriendlyByteBuf(Unpooled.wrappedBuffer(bytesTask))));

echo basalt
#

Hmm

#

Seems like you're just wrapping the bytes

#

Actually I'm not sure how the BukkitPacket class works

#

I'd probably do a writeInt(array.length), writeArray(array)

#

and then just

#

byte[] array = new byte[readInt()]

#

and read the contents

quaint mantle
#

BukkitPacket is just my custom class nothing inside, it just for forge client

echo basalt
#

Are you sure that your buffer is actually being written then?

#

You could just be creating a buffer and never actually writing the packet

#

I don't have much context to work with

quaint mantle
#

but the message.toString() return some string, message is byte[] what recevied from forge client,

solar mauve
#

hey there, does anybody knows the color depth of minecraft skins?

#

256? 16b? 32b? 64b?

echo basalt
#

So most likely

#

8 bit / channel

solar mauve
echo basalt
#

256 yea

solar mauve
#

ty

analog thicket
#

The middle of a block is 0.5, 0.5, 0.5 right?

opal juniper
#

block pos + that yes

analog thicket
#

Alright thanks

regal scaffold
#

What language are plugin descriptions written in for spigot forums

#

Any tips on tools to use to make them look nicer?

solar mauve
#

you need to specify the string size in bytebuf , you don't know where is to end the reading data, thats why you are getting the exception, write an int, then, write data, specify the string length in that int, and read it like that, juts like mc:

  1. get the bytebuf
  2. read length
  3. read bytes
  4. instantiate the new string
    public String readString() {

        int size = readVarInt();

        if (size < 0) {
            throw new DecoderException("The received encoded string buffer length is less than zero!");
        }

        byte[] bytes = new byte[size];
        buffer.readBytes(bytes, 0, size);

        return new String(bytes, Charsets.UTF_8);
    }
undone yarrow
#

Is it possible to detect impact when mounting an animal? For example, you're riding a vehicle that goes fast, but then you hit it against a blockade, and it should go boom.

#

I guess it's possible to detect the change in velocity

#

but what about dismounting and braking?

dry yacht
# rare flicker How can i accurately check if a player is in water? currently i check for waterl...

That's a really interesting question, but I sadly found no answer within the bukkit API, even after some digging. The only way I found was using NMS. CraftWorld#getHandle returns you the WorldServer, which offers a method called getFluid. You pass a block-position, it passes you the Fluid instance. And that then has a method called isEmpty. If you negate that, you know whether the block is water or not, simple and without all these edge-cases. Calling this on the eye-location works a treat.

So you either have to stick to your method of checking and maintain the list (adding new blocks as they come in with new versions), or try to access the information that way.

rare flicker
#

might try reflection though

dry yacht
rare flicker
#

never really tried but it ain't black magic, just need to call functions while blind is all.
ideally i try reflection in a try catch and use the hardcoded list + log a warn on fail

vernal oasis
#

I made a forum post, Choco replied but the answer does not work.

I'm working on a Plugin for 1.19.3 but I can't figure out how to determine the advancement type, Task, Goal, and Challenge. I've tried many things but they've not worked, and every time I think I have a solution, it's a deprecated action from an older version.

I need to getType() function, or something that can reliably get the Advancement type, not hard coded as I plan on adding custom advancements.

verbal slate
#

Hey guys! Who knows how to do it right? I want certain actions to take place when the player places an item in the EquipmentSlot. I understood that this should be done in PlayerItemHeldEvent, but I do not know how to get the value of the main hand slot in this case.

    @EventHandler
    public void onPlayerHeldItem(PlayerItemHeldEvent e) {
        Player p = e.getPlayer();
        int slot = e.getNewSlot();
        ItemStack is = p.getInventory().getItem(e.getNewSlot());
        if (slot == 5 || slot == 6 || slot == 7 || slot == 8) {
            if (Main.isArtifact(is)) {
                if (Main.isArtifactOwner(is, p.getUniqueId().toString())) {
                    Artifact art = null;
                    for (Map.Entry<String, Artifact> set : Main.getArtifacts().entrySet()) {
                        if (set.getKey().contains(is.getItemMeta().getDisplayName())) {
                            art = set.getValue();
                        }
                    }
                    if (art != null) {
                        for (PotionEffect effect : art.getEffects()) {
                            if (!p.hasPotionEffect(effect.getType())) {
                                p.addPotionEffect(effect);
                            }
                        }
                    } else {
                        p.sendMessage(prefix + Main.getConfigString("messages.noOwner"));
                        is.setAmount(0);
                    }
                } else {
                    if (Main.isDeprecated(is)) {
                        p.sendMessage(prefix + Main.getConfigString("messages.deprecatedArtifact"));
                        is.setAmount(0);
                    }
                }
            }
        }
    }
remote swallow
#

player.getInventory().getItemInMainHand()

verbal slate
#

and check whether it converges with is?

fickle ivy
#

Hey, Need some advice. Got this functino ``` private boolean checkWorld(String world) {
ConfigUtilities config = new ConfigUtilities(plugin, "coords.yml");
for (String key : config.getConfig().getConfigurationSection("stops").getKeys(false)) {
String worldb = config.getConfig().getString("stops." + key + ".Location.world");
if (worldb.equalsIgnoreCase(world)) {

        }else{

        }


    }
    return true;
}```   It cycles through a list of places stored in a coords file.  What I am planning is send EACH location to another class to check to see if the location is within x blocks of player.  In the end, if NO locations are within x blocks of the player it will add the players location to the coords file.  What would be the best way to do that?  Should I just define a string then have it change it if the distance class returns true or some other way?
#

or maybe a boolean?

verbal slate
#

Conditionally, I can get an EquipmentSlot from an Artifact object, and I need to check its match with the item slot

#

oh, got it

#
                        EquipmentSlot slot = art.getEquipmentSlot();
                        for (PotionEffect effect : art.getEffects()) {
                            if (!p.hasPotionEffect(effect.getType())) {
                                if (p.getInventory().getItem(slot).equals(isNew)) {
                                    p.addPotionEffect(effect);
                                }
                            }
                        }
fickle ivy
#

Sorry. I had to edit my class I posted as I spotted a goof. lmao.

quaint mantle
#

can somemone make me a plugin were when you die you drop a head that is used to put bad potion effects on the player such as
Slowness
Mining fatigue
Blindness (not too high)
Lower Heath (by 2 ish)
Weakness
2x Hunger
Glowing
Slow Falling
bad Luck

undone axleBOT
ornate patio
#

how do i check if an item falls under a specific tag

#

for example check if an item is either cod, salmon, pufferfish, or tropical fish

remote swallow
#
if (Tag.FISH.contains(ItemStack.getType())) {
    //do something
}
eternal oxide
#

Tag.FISH.isTagged

ornate patio
#

thanks

vernal oasis
#

Any idea why this is occuring?

eternal oxide
#

depending on bungecord too? not shown in your SS

vernal oasis
#

hm?

eternal oxide
#

thats what your error says

#

bungecord-chat 1.16

vernal oasis
#

Yeah, how do I fix it?

eternal oxide
#

where are you depending on bungecord?

vernal oasis
#

honestly not sure

eternal oxide
#

?paste your pom

undone axleBOT
vernal oasis
eternal oxide
#

you have no bungecord in there, run a clean on your project

#

clean/clear cache

vernal oasis
#

Nothing changed?

eternal oxide
#

and your compiler source/target should, be at least 1.8

vernal oasis
#

still conflicting

eternal oxide
#

your error/warnign does not match your pom

#

using intelij?

vernal oasis
#

vscode

eternal oxide
#

oh, good luck

vernal oasis
#

lol

ornate patio
#

is it possible to search for a tag from a string

#

I need users to be able to enter a tag from in the config file

#

and then use that tag to verify if certain items are allowed through a filter

rough ibex
#

Can you give like a example of what the function would take in and return?

#

I'm not quite sure I understand 100%

ornate patio
#

let's just say the input is String tagName, ItemStack item

#

example tagname "FISHES"

#

the program will use the string "FISHES" to do Tag.FISHES.isTagged(item)

rough ibex
#

what type is Tag

#

is it some kind of Map?

ornate patio
rough ibex
#

Ah

eternal oxide
#

You would need to get the actual Tag from getValues()

ornate patio
#

ah okay

#

thanks

#

also another quick question

#

lets say i have a config file like so:

egg-recipes:
    built-in:
        squid: ink_sac
        silverfish: cobblestone
        zombie_villager: diamond_block
        villager: emerald_block
        wandering_trader: lead
        ...
#

is this an efficient way to loop through each mob-item relationship:

for (String spawnEggName : plugin.getConfig().getConfigurationSection("egg-recipes.built-in").getKeys(true)) {
    String ingredientName = plugin.getConfig().getString("egg-recipes.built-in." + spawnEggName);
}
#

it looks a little cursed to me idk

#

i feel like i should be able to loop through key value pairs like a map

eternal oxide
#

no need to pull from teh config for each one, you are using getKeys(true) so it contains a full sub map

#

all you are getting though is teh built-in

#

ah yep

#

ignore that

#

yes it would work but you are doing it wrong by pulling each one from the config

ornate patio
#

wait can you explain what’s the proper way to do it then

eternal oxide
#

String ingredientName = spawnEggName.getValue();

#

your getKeys(true) will not return a string

#

it will return a map/section

#
for (MemorySection spawnEggs : plugin.getConfig().getConfigurationSection("egg-recipes.built-in").getKeys(true)) {
    String eggName = spawnEggs.getKey();
    String ingredientName = spawnEggs.getValue();
    // do stuff
}```
remote swallow
#

shouldnt you use getKeys false in that case

#

and that should return a string key

#

oh wait i didnt read enough

#

ignore me

ornate patio
#

Thanks

ornate patio
#

wrong method?

#

i found that I can do this instead:
Map.Entry<String, Object> spawnEggs : plugin.getConfig().getConfigurationSection("egg-recipes.built-in").getValues(true).entrySet()

river oracle
#

... learn Java please I'll help in the future

inland siren
#

anyone know if there’s some kind of in depth documentation on how the transaction system changed in 1.19

ornate patio
#

i been using java for years lmao, i know what the error means

warped shell
#

Is there a way to set the world of a bounding box? I see now way to change what world it spawns in

ornate patio
#

im just letting him know that the method he told me to use isn't correct

swift karma
#

any packet wizards here? stuck on how to use PacketPlayOutEntityMetadata in 1.19.3

ornate patio
rotund ravine
#

?jd-s

undone axleBOT
ornate patio
#

yeah i checked docs ofc

#

_ _
also since when were blank spawn eggs removed?

marsh burrow
#

Hey would anyone know why ItemMeta.setCustomModelData aint showing up as a method of me in 1.17.1?

ornate patio
#

how would that work

#

if its a little complicated its fine cause what i have works

unique gate
#

I'm running a 1.8 spigot server. Sometimes I change the biome over a certain area using the worldedit api. The problem is that when the biome is changed, the chunks aren't updated, so the players either have to relog or go out of render distance and back in to see the chunks with the new biome. So my question is how can I update chunks for nearby players?

I've tried to use the PacketPlayOutMapChunk packet, but it's causing chunk errors that make the blocks invisible

#
Player player = hippoPlayer.getPlayer();
net.minecraft.server.v1_8_R3.Chunk nmsChunk = ((CraftWorld) world).getHandle().getChunkAt(player.getLocation().getBlockX(), player.getLocation().getBlockZ());
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, true, 65535);
((CraftPlayer)hippoPlayer.getPlayer()).getHandle().playerConnection.sendPacket(packet);```
worldly ingot
#

though with that being said, you'd have to check each Registry for your Tag, unless you know which Registry you're wanting to look in

ornate patio
#

hmm i'll look into it

quaint mantle
#

Player player = Bukkit.getPlayer(name);

#

will the code i posted above return a Player object with its uuid?

#

even if the player is offline?

#

i am trying to get a player object from command.

drowsy helm
#

no

#

Bukkit.getOfflinePlayer

quaint mantle
#

but

#

it has a line going through it.

#

can i still use it?

drowsy helm
#

yeah its deprecated

#

you can still use but it might be removed in later versions

quaint mantle
#

its for 1.19.3, is it okay to use?

drowsy helm
#

should be

quaint mantle
#

ok.

drowsy helm
#

if you want to avoid deprecation you can use mojang api

#

but thats a pain in the ass

quaint mantle
#

i dont exactly need the player uuid if the player has never joined.

#

and another question, what does it return if the player has never joined?

#

is the OfflinePlayer object null?

#

or is the uuid field null?

#

i just need the uuid.

drowsy helm
#

if you just need the uuid use mojang api

quaint mantle
#

i could but it is rate-limited.

#

dont know how many people will use it.

#

besides, i dont exactly need it if the player has never joined the server before.

wet breach
#

Is it really difficult to just look at the javadocs and read?

#

Instead of asking a million questions

#

?jd-s

undone axleBOT
wet breach
#

Reason get player by name is deprecated isnt because it will be removed as it wont. It is deprecated to warn players can change their name

sacred wyvern
#

Is there a way to add tab whitespace to a message sent to the player?

#

\t gives an odd character

rough ibex
#

What does it show?

#

If it shows some dotted box, that is on purpose because of the font, you will need to use 4 spaces

sacred wyvern
rough ibex
#

Yeah, there's no default space for the tab

#

you can manually do it with a font resource pack but that's too much work

#

also the tab is a static amount of space, it doesn't adapt

sacred wyvern
rough ibex
#

well, a GUI doesnt normally require a tab character

sacred wyvern
#

True, I'm starting with commands for now to get the initial admin framework in place and then hoping to be able to use GUI's to create an easier interface.

#

It needs text inputs though and that seems to be a tricky thing

sick epoch
#

Hello ! i have a problem with my Java plugin of break block event ^^ can anyone help me ?

#

The Error
Jobs v1.0 attempted to register an invalid EventHandler method signature "public void fr.clemkill.legendjobs.Listeners.LumberJack.PlayerHarvestBlockEvent(org.bukkit.event.player.PlayerHarvestBlockEvent,org.bukkit.block.Block,java.util.List)" in class fr.clemkill.legendjobs.Listeners.LumberJack

#

The code :
public class LumberJack implements Listener {

@EventHandler
public void PlayerHarvestBlockEvent(PlayerHarvestBlockEvent e, Block harvestedBlock, List itemsHarvested){

    Player player = e.getPlayer();
    Material bloc = Material.OAK_LOG;

    if (e.getHarvestedBlock().getType() == bloc) {

        player.sendMessage("Vous gagnez 1 xp");

    }

}

}

#

Main class

public final class LegendJobs extends JavaPlugin {

@Override
public void onEnable() {
    // Plugin startup logic
    System.out.print("Enabling Jobs...");
    getCommand("jobs").setExecutor(new jobsCmd(this));
    getServer().getPluginManager().registerEvents(new LumberJack(),this);
}

@Override
public void onDisable() {
    // Plugin shutdown logic
}

}

#

Thank youuu 🙂

#

@everyone

analog thicket
#

Could you put in THIS

weak kayak
ivory sleet
tawdry echo
#

when premium player change their nickname then at offline mode server he still have same uuid?

ivory sleet
#

No not guaranteed

#

Offline servers generally need to implement their own login system as uuid is no longer really reliable

frank kettle
#

Unless you have some system that gets their real uuid if they have premium, then u will be safe

analog thicket
tawdry echo
frank kettle
#

No

#

But search on spigot for login systems

#

If I recall correctly, some of them had something around that

vital sandal
#

PLayerLoginListener
saving player data to config/database

hazy parrot
#

You can also look at the 3rd block of the uuid. If it starts with a 4 the uuid is a Online uuid, if it starts with 3 it is offline

ivory sleet
quaint mantle
#

it should be

#

onHarvest(PlayerHarvestBlockEvent e)

fickle ivy
#

Just curious what it takes to get help here. I have asked several times and each time my question goes ignored yet everyone else's get answered pretty quick.

regal scaffold
#

How can I compare if a object I saved as a serialized PDC is the same as the current object as in it has the same fields.

I'm thinking like, what if I change the PDC object in the future, if I try to access a field that wasn't originally there it would give big errors

remote swallow
regal scaffold
#

Nah ebic, mostly we don't want to.... makes total sense

#

We couldn't possibly miss the question or not know the answer, that would be outrageous

#

I guess we gotta go back 10 hours

remote swallow
#

ope

#

he left

regal scaffold
#

LOL

#

f

#

Mans was wondering why no one answered his question 10 hours ago

remote swallow
#

i think the better response to that was to, realise no one answered after 30 min, so just reply to the message saying "anyone know"

regal scaffold
#

It's ok to bump stuff... no one minds unless you're dumb aobut it

remote swallow
#

yeah

remote swallow
regal scaffold
#

It's been 3 minutes, I'm entitled

#

😆

remote swallow
#

im very confused of what that means, what you trying to do with that

regal scaffold
#

Well, I have a object that I store inside a pdc

#

but if I add something new to the object

#

The current existing pdcs obviously don't have that data

#

so big errors

remote swallow
#

ohhhhh that makes sense

regal scaffold
#

So either I need a way to ?convert it? but for that I need to know that it's different

#

So how do I do either of those lol

torpid blaze
#

Hey,
I am trying to code a minigame with multiple maps which properies I want to save in a yml file. Each may has a name so I save them as a HashMap for easy use.

My Problem is now, that when I try to get all saved maps, I often get null in return even though I have samed one. Also if I try to only get the name using getKeys.

Anyone any idea what I am doing wrong?

regal scaffold
#

Are you sure the path is right?

torpid blaze
#

yea

regal scaffold
#

I would give you some debugging steps but I would wait for someone that knows more about FileConfiguration to speak cause they'll probably solve it way quicker

torpid blaze
#

It is also strange because after restarting the server, I works for one time and after updating something of the maps, it doesn't

remote swallow
regal scaffold
remote swallow
#

yeah

regal scaffold
#

That seems more complicated

#

Than just.... making sure it doesn't change

#

xd

remote swallow
torpid blaze
#

I don't think so

wet breach
regal scaffold
#

Indeed

wet breach
#

Then that is your indicator it is different

torpid blaze
regal scaffold
#

Ebic suggested a boolean hasChanged but I thought a int version would be more adaptive

#

So like a version for the object pdc

#

And then I would know what to add

wet breach
#

Adding a version identifier would be better and smart in the beginning

remote swallow
undone axleBOT
regal scaffold
#

I was called smart by frost

#

😍

#

My life is accomplished

torpid blaze
#

?paste

undone axleBOT
torpid blaze
#

That Is My Map and Position object

wet breach
#

The only thing that will be hard about versioning is whether or not you want to continue supporting old data or just wipe it completely if its too old

regal scaffold
#

Well, I just need to know what to add, I guess just if something is null, initialize it to default would be good enough

torpid blaze
#

I need the Position because I don't want to save the map.
I thought is easier that way

regal scaffold
#

Now that you mentioend it

#

But another question, if I have a Class that I'm serializing, and there's a field in that that is not primite but another Class that I need to serialize, do I need to add serialization stuff to the subclass too?

wet breach
#

Well from one version to the next its not hard. But over time you end up with a class for various conversions of the data lol

regal scaffold
#

As in

class Ser1 implements ConfigurationSerializable {

  private Ser2 ser2;

}

class Ser2 {}
remote swallow
torpid blaze
#

I don't think that that is the problem

#

I save the yaw and pitch as null when not set

remote swallow
#

if the obj wasnt null but the values were it would still add the x,y,z fields

torpid blaze
#

yea

#

I don't understand

#

at my map I didn't set a spawn or other values yet

#

so they are null

remote swallow
#

that would be why theyre null

quaint mantle
#

Мне нужен кодер

regal scaffold
#

yes.

quaint mantle
#

Я плачу &

#

remote swallow
undone axleBOT
regal scaffold
#

tf ebic

#

Oh lmao

#

That's the guy paying a $1.20 for a plugin

remote swallow
#

ohhh

#

i remember that

torpid blaze
#

when trying to get it from the config

regal scaffold
#

I might've called him an idiot before that but that's beyond the point

remote swallow
#

he was that ladder guy right

#

or is that someone else

regal scaffold
#

He was the guy that wanted nodes like rust

remote swallow
#

he did also want a "you place 1 ladder you place 3"

regal scaffold
#

Oh lol

#

What a smart plugin

remote swallow
wet breach
#

If you do so it makes it all null

torpid blaze
#

ok, no. I think there should be no null value in the Set

wet breach
#

You said you use null

#

Which you shouldnt

torpid blaze
#

because what should be null. Max the value of a map key could be null and they aren't in a set

torpid blaze
#

I tried just again and it is like this:
After reloading the server, the getSections or getKeys method is not returning null until I change something at the map values and save it into the file

#

and when reloading again, it is working again for one time

#

That makes no sence

eternal oxide
#

?paste show some code

undone axleBOT
wet breach
#

You obviously dont check if the cpnfig in memory is null as that is what a server reload does. You also dont check if the references you have are suddenly null as well

#

Which is what will happen if you reload

torpid blaze
#

but why should the config in memory be different from the one in the file?

eternal oxide
#

why are you streaming into a new Map when you call the constructor?

#

just pass bs

torpid blaze
#

where?

eternal oxide
#

102 and 112

#

map.put("blocks", blocks);

torpid blaze
#

Because yml doesn't want to save Material properly

wet breach
torpid blaze
#

?paste

undone axleBOT
torpid blaze
#

Thats my Config Class

#

How could it happen that the reference is null?

wet breach
#

Because the server gets rid of them

#

But looking at your code it makes sense now with all the static usage

#

Remove the statics and go learn about static so you know when to use them and to properly use them. Otherwise all its going to do is cause you problems like you are having

#

Also learn di

#

?di

undone axleBOT
regal scaffold
#

Does BlockBreakEvent trigger in ANY case that the block will get broken?

#

Piston? Mobs?

eternal oxide
#

Called when a block is broken by a player.

#

says in the javadoc

wet breach
#

Piston has its own event

#

And so do mobs

regal scaffold
#

So if I want to make a specific block unbreakable by all those things

#

I need to check for each one individually?

eternal oxide
#

yes

regal scaffold
#

No way to add "invincibility" to it otherwise

#

Alright

#

ty

wet breach
#

You could just set the tag

regal scaffold
#

?

eternal oxide
#

tag?

regal scaffold
#

You have caught my attention

wet breach
#

Pretty sure there is one otherwise mojang would have to code fpr all those things too for bedrock

#

Let me checj

eternal oxide
#

bedrock is a hardness value in the Material data

regal scaffold
#

But like, I want only a specific player to break it just want to prevent everything else

#

?jd-s

undone axleBOT
eternal oxide
#

Modifying teh hardness of a Block is possible, but it is not easy and requires you use reflection

regal scaffold
#

Is it really worth it?

#

Cause I still need players to be able to break it

eternal oxide
#

imho no

regal scaffold
#

So I think events is the way to go

eternal oxide
#

the client will still ghost teh block at times

regal scaffold
#

Why can't all the events be in one place...

remote swallow
#

they are technically

regal scaffold
#

Well....

remote swallow
#

just search for Event and you have all of them

eternal oxide
#

it was either mfnalex or 7smile7 who wrote a class for modifying Material data but it's not 100% reliable

regal scaffold
#

Yeah it's fien I'll just check all the events in the game ig

#

I have a question tho

#
public class BlockExplodeEvent
extends BlockEvent
implements Cancellable
Called when a block explodes
#

Does that specifically mean tnt

eternal oxide
#

no

regal scaffold
#

Cause technically only block that explodes is tnt

eternal oxide
#

explode is for things like beds in the nether

regal scaffold
#

Oh

remote swallow
#

entity explode event is tnt, creepers etc

eternal oxide
#

tnt block doesn;t explode

wet breach
#

There is actually a few block tags you can use to make it immune to mobs and then of you set hardness level to -1 nothing can break it

regal scaffold
#

Wait so, what are the ways a block can be broken

#

Players

#

Creeper

wet breach
#

Then all you have to do is check of if its your block and the right player and let it break

terse ore
#

enderman counts?

regal scaffold
#

Chest

#

So no

remote swallow
#

block break event, Entities/tnt, endermen, pistons

regal scaffold
#

Frost I like your idea but not sure how to implement it

#

Safe way is events

wet breach
#

If you set the hardness level to -1 you dpnt have to check for all those things lol

regal scaffold
#

I mean I guess

#

Do I just check for BlockBreakEvent with hardness at -1?

#

I thought it wouldn't even be triggered if the Block can't be broken at all

wet breach
#

Blockdamageevent still gets thrown

regal scaffold
#

What if a creeper blows the block up while the player is trying to break it

#

Cause I assume aftert blockdamageEvent gets thrown, I would set the hardness back up to allow it to be broken if it's a player

wet breach
#

Nothing in the game can break a block with hardness being negative exception being dragon and withers unless you set the block tags for it to be immune

regal scaffold
#

But eventually I need the player to be able to break it

#

I just need to make it inmune to everything else

wet breach
#

Yes and so all you need is blockdamage event

#

Check the stage and of its the last stage or time or whatever and its your block and the right player allow it to break

regal scaffold
#

What if I set it to -1 and make a button inside the GUI that's called "pickup"

wet breach
#

You can simulate it breaking by just removing it and spawning it on the ground as an item at the same time

regal scaffold
#

So I make it fully invincible unless you press the button

wet breach
#

You could do that too

regal scaffold
#

Is hardness a tag for the block or item?

#

Like if I set it to the chest, does it have to be placed?

#

Or I can set it as a nbttag

wet breach
#

Yes it has to be placed to modify it. Unfortunately will require some nms

regal scaffold
#

So there's no way to set the hardness while it's an item in inventory

wet breach
#

No, because that gets set when the block is created

regal scaffold
#

Gotcha

#

Alright, ty

wet breach
#

Should say generated

#

The game doesnt look at the item for it it just pulls the values from the defaults for it

#

But you can modify its nbt data for it

hazy parrot
wet breach
#

Anyways time to drive home

regal scaffold
#

Damn i like that solution

#

But this still requires nms

#

And so far I haven't needed it

river oracle
#

Just go for it :P

#

You'll learn good abstraction ciz I'm assuming you'll need it for multiple versions

sharp zenith
#

Can someone help me on making my own server public? I did port forwarding and firewall but still doesn't work

hazy parrot
#

There is not much we can do

#

Also no reason to cross post across multiple channels

tardy delta
#

email be like: "hello sir i am making a minecraft server but it doesnt work" 💀

hazy parrot
#

Pls fix

regal scaffold
#

Any acf experts around? smile?

hazy parrot
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

regal scaffold
#

I'm trying to make a command give an item to a player.

    @Subcommand("giveitem")
    @CommandCompletion("@players @range:1-64")
    public static void onGiveItem(CommandSender sender, @Optional String playerName, @Optional Integer amount) {}
#

And I was thinking that I need to do a bunch of checks to make sure the player exists, the item amount and such

#

Does ACF have a way to simplify this?

tardy delta
#

why is the player optional

#

do Player target

regal scaffold
#

Give to yourself if no player

tardy delta
#

ah

regal scaffold
#

And give 1 if no number

tardy delta
#

atleast use a Player object

regal scaffold
#

Yes but

#

What if the name provided isn't a player

#

Big errors

#

So what I'm asking is, is there a way to check this using ACF or do I need to do ifs inside the command

#
        Player player = null;
        if (playerName == null && sender instanceof Player){
            player = (Player) sender;
        }

stuff like that

remote swallow
#

why use command sender then

#

if you just get a player instance

tardy delta
#

you will get a syntax error when you did not provide a player name

regal scaffold
#

Console?

#

It's actually something like this if I'm not wrong

        if (playerName == null && sender instanceof Player){
            player = (Player) sender;
        }
        if (playerName == null & !(sender instanceof Player)) {
            // no player
            return;
        }

        if (playerName != null) {
            player = Bukkit.getPlayer(playerName);
            if (player == null) {
                //player not found
                return;
            }
        }
#

What I'm wondering is if ACF has a way to simply that

#

Or do I need to do all that every time I want to have an @optional player in the command

tardy delta
regal scaffold
#

Oh

remote swallow
#
if(playerName == null) return;
if (!(sender instanceof Player player)) return;
player.doSomething();
regal scaffold
#

So I need to change the declaration

tardy delta
#

idk i havent been working with acf for half a year

#

just ask in their discord ig

regal scaffold
#

I mean

#

@lost matrix you probably know this but I asked in there anyways

hazy parrot
#

Just have optional player

#

And if player is null, it is executed by console/command block?

regal scaffold
#

Well, if it's executed by console should have a player

#

I think maybe separating

#

Is better for this

regal scaffold
#

Only allow Player sender

hazy parrot
#

Console is not a player

regal scaffold
#

I mean, if sent by console, player shouldn't be optional

#

I'm gonna split it

#

And use @optional Player

quaint mantle
#

the way you had it originally was better than splitting it, just return early if the target is null and the sender is not a player. Otherwise set target = (Player) sender if the target is null and that will cover both cases (target will be the player you specify if it isn't null, player sender if it is).

#

Not sure if there are contexts in ACF like there are in some other command frameworks; those will let you create a context to set the target to be the sender automatically if the target is null

regal scaffold
#

Yeah indeed, I kept investigating and got it

#

Contexts are great

#

If I use

getTargetBlockExact()
``` and I want to check if the block is a Chest I need to getState right?
#
sender.getTargetBlockExact(6).getState() instanceof Chest

I still can't understand really the difference between Block, BlockState and BlockData

ivory sleet
#

what exactly r u trying to achieve

regal scaffold
#
    @Subcommand("giveitem")
    @Syntax("<player> <amount>")
    @Description("Gives a specified player a number of chest items")
    @CommandCompletion("@players @range:1-64")
    public static void onGiveItem(CommandSender sender, @Optional Player playerName, @Optional @Default("1") Integer amount) {
 
lost matrix
#

You can use Player in ACF as an argument.

#

Use OnlinePlayer

regal scaffold
#

What about optional default player?

lost matrix
#

Optional means the value is null if not provided

ivory sleet
#

like plugin dev income?

regal scaffold
#

I want to default to the sender if no player is provided

lost matrix
regal scaffold
#

Ok cool that's how I was doing it

#

Thought acf had something else fancy

#

Thanks smile

lost matrix
#

It has but i think you should start with just a simple null check

regal scaffold
#

Alright cool, thanks

hazy parrot
regal scaffold
#

So if I want a chest I just want the Block

hazy parrot
#

i assume that good percentage of guys here learned or started learning java because of mc

hazy parrot
quaint mantle
#

It's not related at all to mc but I learned a lot of core concepts from plugins/mods

hazy parrot
#

its always easier to learn something if you are interested in doing it