#help-development
1 messages · Page 405 of 1
what class you put them in is upto you
you do not need to make a string object for every entry in your config
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
the config is already loaded into memory so it already contains ALL of your strings in a map
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
A constants file for paths
thats what I often use
Hmmm
simplifies fetching config data and a single point to modify paths
Yeah that is true
Does a Map#get() loop through every element in the map? I assume that's really inefficient
it does not
Is that not a good alternative? key -> value?
how you access yoru map is upto you
Yeah you are right about that
a Map stores by Hash value
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/
I see, but how do you implement configurations + lang
Do you do anything different to what's in ?config
do it on chunk load and its a very minimal thing
Do you getConfig# every time you need something? Do you store it somewhere?
Caveat should be noted as you increase in elements if the buckets dont increase or you get an odd amount of elements and either have too little or too many buckets you will have degraded performance and even there is still a limit only because there isnt infinite time lol
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.
Ok yeah perfect
Yes i was ofc assuming no collisions
However most people dont need or shouldnt need to worry about time complexities until it is an issue
But then, do you access it like I said above? getConfig#getString(Translation.Whatever)
No. I never access any config files after my plugin is enabled.
I load everything into concrete classes.
Ok that's exactly what I thought
Do you store stuff in a list of strings? hashmap?
Or you turn that data into an object
ooooooo
Alright alright, thanks a lot. That showed me exactly what I needed to know
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.
I see
I like what you did with translations
Do you do something similar with config values?
Just dont over use enums
Yeah
They are handy but they do come with a catch for using them lol
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
Alright fair, gotcha
Smile how do you load the values into the enum?
I assume your Message.sendInfo# method gets the value
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
he probably modifies it on startup
Wait wut
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
ooooo
You can put objects in an enum
So he replaces the path with the value on startup
probably the value
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
Ok ok time to code a bit
Just stuff inside the enum new whateverobect() lol
Use resource bundle api if u gonna go with a language locale thingy
How to check if an itemstack can be placed when right clicked?
Omg
Lowercase
Reeeeee
pitchfork time!
phon prob

Material#isBlock
is ender crystal a block?
uhh
that's specific
wouldn't say so
it's also only applicable under certain circumstances
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
alex back 
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
to be fair, I was on my phone
lots of stuff goes out the window when I am on my phone because it is too much of a pain otherwise lol

Hi alex!
activate windows
it saves the key to ur microsoft account
Not after years
ah
wazzup
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*
extra verbosity is readability really ya? thats why we have code folding
Not always
I use reflection in kotlin, not sure if that will be reliable to you
@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
Jesus
@lost matrix You use ACF in all your plugins right
Is there a way to deduce, how many exp will renaming an item take?
wym?
Copilot is probably most hyped and least useful tool I ever encountered
No way
tf
Pretty much
Still debating if using it or just using bukkit impl
I mean
It’s nice
Nicer than bukkit
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
Look for a decent command lib or write your own. But Bukkit has such a barebones approach that
i would never use it as is.
I mean ACF is considered a decent command lib as far as I know
Definitely seems fine if you don't dig too deep
It has a steep learning curve and is really hard to master
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
You need to look into context resolvers. They are used to resolve an argument (String) into
an instance of your parameter (T)
Ahhhh I see that part now
And String[] is something i have never used in acf
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
}
idk why he uses it but yeah, odd
What
the f
Ok I sort of understand contexts
Those are the default context resolvers
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
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
Oh you are right, I checked it the wrong way
you also can use just Player player, instead of CommandSender
If I have an enum with
NAME("path","value");
How do I populate the "value" field on startup
What do you mean
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
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
why enum?
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
add a getValue method to the enum
I would say you should have it cache once you’ve retrieved it once
Gotcha
You don’t need to be fetching it every time, but you also don’t need to fetch it all at once
Now I'm thinking tho...
What if some of these values aren't a string but they're something else like a StringList
fetching from config is fine as that is already in memory
Then I can't do it this way
it's just a map lookup
If the values are going to be that varied you probably shouldn’t do it that way
You can
This was not in your design pattern when you were told to use an enum
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
Alternatively you could do it with just the path I guess
It wouldn’t be the cleanest thing
But you could do something like
Well if I have an enum of paths, I can just use getConfig()getList(Enum.WHATEVER)
public <T> T getValue(Function<String, T> configLoader)
And if I want I can make something to summarize getConfig()getList into more stuff I need
But you probably don’t need to do it that way lol
https://pastecode.io/
paste here, use java syntax, i can't access md-5.net for some reason
I fixed the circle getting bigger and bigger, but everything is just off about the stuff. So I'm starting over.
Using Simple-Yaml and Java Swing btw
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?
You can’t make a new instance of your plugin class
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
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.
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.
I fixed that error and now im getting this error instead:
?paste
Paste it there
That basically means that the event will have to scan all slots of all containers always, scan each of their PDCs, to find items marked for removal. That sounds expensive.
No
it only has ot scan for a specific item and check a byte on it's PDC IF found
You only check the chest they’re opening
Not all containers always
yep, only each chest as it opens. not a heavy load
Show us your onEnable
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.
It’s not expensive because you amortize it over time
Thanks for the tips guys
yes, still not a heavy load. hardly any at all
Ok, let’s see your HiderFoundListener
you need a static handler list which you forgot
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
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.
It’s not expensive at all
Great mindset. Death by a thousand cuts, :).
ah yeah, thanks
Premature optimization is the root of all evil
well I think there is a middleground between premature optimization and setting yourself up for failure
It's called non-pessimization, not optimization. Optimizing is something completely different.
There is
Whatever, not going to pollute the chat with this kindergarten anymore. The person who asked needs to decide on their own.
And scanning 30 slots is not going to have any measurable difference on the performance of the server
Because you have to do that on all ever opened containers, for no good reason whatsoever.
if you can easily solve the problem with a less expensive method you should go for it
Yes, for ever from the point on that the feature got implemented
You’re not easily solving the problem, you’re sacrificing part of the solution to avoid a minor execution
It's not a do once thing, as you don't know how many of these items are around
okay well then I read wrong
If they do know and it's only temporary, that's another thing. I'm not so sure about that tho
well maybe all existing ones are just shite
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.
Avoiding 30 cheap if statements is a micro optimization at best
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.
If they want the item to vanish when it expires then having it disappear on use is not the desired effect
The item I want to implement is basically a resource used in other recipes. It must expire/disappear after 1 day.
I said that it's a compromise. It's up to Voper to decide.
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
So you can either make it disappear so that nobody could ever see it again, or you just make the workbench eat it up if it's lifetime elapsed. This is totally up to you, as you now know both ways.
whats the difference, the item will be destroyed in any case no?
^
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
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
There’s not really a performance loss anyway
The maximum size of an inventory is 36
well not really but I get your point
You’re running it on a redstone computer if that causes you issues
lmao
i think byte wasnt suggesting it would impact your performance to do one loop
its just like a mindset thing ig
It’s premature optimization
There’s no reason to sacrifice functionality when the desired implementation comes with no actual cost to it
okay
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
anyways i think we solved the problem
I agree
Hi , how to make command in jycraft ?
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"
ouch that's going to be slow
Looks like jycraft hasn't been updated in 8 years
Lol but in 8 year past , make command is Available !
if you know Python it's not a great leap to Java
yeah I wouldnt use that xD
and just start using java instead or make another project haha
The lengths python devs will go to not touch grass
https://paste.md-5.net/ahovoyixoc.java
you're starting to spawn entity from a wrong location, please take a deeper look at my code
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?
Well the one you replied to is fixed. I only had one error and that was a little jump in the start of my animation. (In another video way up)
and yea choco is right, make radius constant
wait
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...
does anyone know an use case for PotionEffectWrapper?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectTypeWrapper.html
declaration: package: org.bukkit.potion, class: PotionEffectTypeWrapper

that is the API way of implementing PotionEffectType for the static constant values you get via PotionEffectType
i learnt what enums are today in college 💀
teacher asked me "oh is this easy for you"
i'm struggling to see the use though since you can just instantiate a new potionEffecTtype
bruuuuuh
Yeah im thinking it has something to do with the animation before that one. There was an up animation before the rotating
or you spawned it at a wrong location
PotionEffectType is abstract because it is also implemented internal in the server (for some reason)
I found out it was there was an extra 1 on x. Didn't find out why tough.
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 ?
store the uuid of the clicked armor stand in the inventory holder
retrieve it on click
I’ll try that, thank you
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));
}
yea
is that pretty to do for all potion effect types ?
no
is hence a simple implementation useful ?
yes
for some reason this cooldown isn't working, is there something wrong with the code?

you can't really extend potionEffectType and have a static instance cleanly
wait yes you can
ghdfhgdfhfg
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"

that looks like code my teacher writes
man i saw some weird code in class today


weird, i'll check the rest
public class cooldown which holds a map of cooldowns 🤔
Before u do u havent said the most important part
What are you wanting it to do and where is it called ?
It's supposed to put a 1sec cooldown after the item is used
this is where it should be used
Oh boy weve got quite a bit to unpack here
How do I use the InventoryHolder ? I don't find out how to use them 🤔
||https://docs.papermc.io/paper/dev/custom-inventory-holder|| might work as a tutorial
why spoiler
because its a paper link 😅
x)
banned
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
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?
Nah Im helping him out by gettin em to think about it
yeah I see now haha
hi, if i folow this guide after enabling iptables and doing the comand the server become inaccesible
What's wrong with that? name.playSound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
declaration: package: org.bukkit.event.inventory, enum: InventoryType
I don't understand how InventoryHolder work can someone explain me how do I store armorstand's uuid in it and retrieve it ? 🥲
I do this comand
iptables -I INPUT ! -s ip -p tcp --dport 25560:25570 -j DROP
then
dpkg-reconfigure iptables-persistent
Question 1: A: Uh, Public static void which means it will make a space in memory automatically, Question 2: A: per player. Question 3: A: I'm not sure, ive never done this before lol.
And fgs save that documentation as it is the most valuable tool in ur tool kit
do you have a custom class that extends InventoryHolder?
Yes sir
i dont think its avillable for me ?>?
inventory type is not the same as inventory
make a new variable called like armorstand of type uuid
Brilliant okay fantastic.
I get to answer question 1 by saying erm: wrong?
Void is what is returned. Legit think about the word "void" .... what do you think "void" returns?
like that ?
and then just put the armor stand uuid in it, which should be easy enough
what does static mean
the inventory interface is only implemented for inventory types that need their own interface
My bad I removed it
Nothing, so should I remove the void?
an enderchest is just a normal chest in regards to the inventory size
@pseudo hazel
and then I think you can get it back when you use world.getentity(uuid) or something
but you see now u have a problem. You are gonna return something but erm... during boot up? U want it to record a cool down the moment the server runs? That dont sound right does it? :S
yes something like that
keep in mind java code style would be armorstandUuid or armorstandUUID
no underscores
Ok
No, so then what should I change?
but thats basically it
so how i can do the check for the EnderChest?
Inventory#getType
since you made it private you need getters and setters to actually get the object
returns you an InventoryType
No so then what should I change
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
You are not tracking who has the inventory open correctly. You can get the viewrers
How can I fix it to track who has the inventory opened correctly ?
the click event should tell you who clicked
That doesn't really help me, and even if I got who view it (I have it) how do I see if the player can click in even after another player opened it ?
its your inventory so you need to keep track of who can or can;t use it
Any way to get the amount of a block of type broken by a player starting from a certain timestamp?
Can I just store the value in the pdc of the player?
I mean yeah you can
Would you reccommend doing it though?
It really depends on your use case
If it doesn't need to be persistent, you can just use map
yo
does worldguard guard the whole world
or can i select certain regieons
I do. Yeah, thanks.
@quaint mantle can I get more FPS IRL now?
Region, but pretty sure you can set global flags
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?
declaration: package: org.bukkit.entity, interface: Entity
since when ; -;)
... What?
You are called sodium
Do server freeze when async task calls method from another class?
I didn't laugh at your joke
Ok
Everything called in your async task also is async
If task is ran async, it will be async
Oh ok
But you can schedule sync tasks in your async task if you want
oh i remember why i didn't use this actually
this returns true if the head is above water
there location is there feet so it probably bases it off that
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
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
Is it possible to access the spigot Web API from a webserver (not associated with the Minecraft server)
not unless you make it possible
meh that only refers to the swimming pose though no?
Depends on how you define "possible". There are many ways to define a common API which makes accessing everything you need possible, but as soon as you expose something mighty on the internet, you'll have to think about security as well.
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
I think illusion ment to use this boolean value as an early return before going into the calculations of eye-hight, block-getting as well as waterlog checks and the like. It would keep a lot of code from needlessly executing while swimming in big oceans, for example.
Ohhh, I'm sorry, I completely misread your question. You want the spigotmc.org API, not your spigot server's data.
yeah
What data is it that you need? That will decide the way you'll have to handle it
what look sorted list of eventpriority by weight
I want to get all my uploaded resources data, which I have the link to do everything with. I've done similar things with plugins for testing. However, whenever I do anything outside of the server (aka outside the SpigotAPI) the API throws the following error:
(Reason: CORS header ‘Access-Control-Allow-Origin’ missing)
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
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.
it's half the work
correct, always run the cheapest checks first
Okay i'll check it out 😄 thank you.
Sad that we can't use the already setup spigot web api
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)
I didn't even know that spigot had a public API itself. Where did you get documentation on it? Or have you just checked browser traffic and found the endpoint this way? I'm currently not sure whether spigot is rendered serverside, thus the question.
EOFException ocurrs when you try to read data that kinda doesn't exist
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
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))));
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
BukkitPacket is just my custom class nothing inside, it just for forge client
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
but the message.toString() return some string, message is byte[] what recevied from forge client,
hey there, does anybody knows the color depth of minecraft skins?
256? 16b? 32b? 64b?
It's literally a base64 encoded png
So most likely
8 bit / channel
256 so?
256 yea
ty
The middle of a block is 0.5, 0.5, 0.5 right?
block pos + that yes
Alright thanks
What language are plugin descriptions written in for spigot forums
Any tips on tools to use to make them look nicer?
how you are getting the packet? (from netty, from start)
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:
- get the bytebuf
- read length
- read bytes
- 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);
}
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?
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.
i'll stick with my list then , this function is for a library and making it version dependant because of nms would be pretty annoying
might try reflection though
Just wanted to let you know about the alternative. The Material enum constants you're checking on are bound to >= 1.13 anyways, and the API I mentioned has been there since (at least) then. Reflect would work out.
Maybe it's really better to maintain that small list. Depends on how comfortable and efficient you are with reflect.
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
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.
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);
}
}
}
}
}
player.getInventory().getItemInMainHand()
and check whether it converges with is?
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?
OK, I did a check for the right slots. But now how to check that the item is in a certain EquipmentSlot?
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);
}
}
}
Sorry. I had to edit my class I posted as I spotted a goof. lmao.
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
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
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
if (Tag.FISH.contains(ItemStack.getType())) {
//do something
}
Tag.FISH.isTagged
thanks
depending on bungecord too? not shown in your SS
hm?
Yeah, how do I fix it?
where are you depending on bungecord?
honestly not sure
?paste your pom
and your compiler source/target should, be at least 1.8
still conflicting
vscode
oh, good luck
lol
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
Can you give like a example of what the function would take in and return?
I'm not quite sure I understand 100%
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)
declaration: package: org.bukkit, interface: Tag
Ah
You would need to get the actual Tag from getValues()
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
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
wait can you explain what’s the proper way to do it then
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
}```
shouldnt you use getKeys false in that case
and that should return a string key
oh wait i didnt read enough

ignore me
i'm getting red underlines
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()
... learn Java please I'll help in the future
anyone know if there’s some kind of in depth documentation on how the transaction system changed in 1.19
me?
i been using java for years lmao, i know what the error means
Is there a way to set the world of a bounding box? I see now way to change what world it spawns in
im just letting him know that the method he told me to use isn't correct
any packet wizards here? stuck on how to use PacketPlayOutEntityMetadata in 1.19.3
i ended up using reflection for this, couldn't really find a valueOf method or anything
tag = (Tag<Material>) Tag.class.getDeclaredField(itemString.toUpperCase()).get(null);
?jd-s
Hey would anyone know why ItemMeta.setCustomModelData aint showing up as a method of me in 1.17.1?
Registry maybe?
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);```
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/733/overview implements Registry#getTag(NamespacedKey), so not currently possible, no
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
In the interm @ornate patio you can use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#getTag(java.lang.String,org.bukkit.NamespacedKey,java.lang.Class)
hmm i'll look into it
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.
its for 1.19.3, is it okay to use?
should be
ok.
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.
if you just need the uuid use mojang api
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.
Is it really difficult to just look at the javadocs and read?
Instead of asking a million questions
?jd-s
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
Is there a way to add tab whitespace to a message sent to the player?
\t gives an odd character
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
Ya pretty much the "Character not found" box. Ah ok, I was hoping to use it to align multiple data sets on multiple lines.
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
Ya I am having to look at a Resource Packs right now. I have a command system built for my plugin but I'd like to get a custom GUI into place without requiring mods.
well, a GUI doesnt normally require a tab character
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
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
Could you put in THIS
it looks like you have too many parameters in your method. remove harvestedBlock and itemsHarvested
```java
//CODE
This?
when premium player change their nickname then at offline mode server he still have same uuid?
No not guaranteed
Offline servers generally need to implement their own login system as uuid is no longer really reliable
Offline mode is based on name
Unless you have some system that gets their real uuid if they have premium, then u will be safe
Yep that
you have any example of this system, i mean api for that
No
But search on spigot for login systems
If I recall correctly, some of them had something around that
just create it :d
PLayerLoginListener
saving player data to config/database
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
The problem is that this is not a guarantee, sure spigot uses that, but it’s changeable
you dont specify the block in the thing
it should be
onHarvest(PlayerHarvestBlockEvent e)
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.
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
its either we dont notice it or dont know the answer to it
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
im guessing this
ope
he left
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"
It's ok to bump stuff... no one minds unless you're dumb aobut it
yeah
bump @remote swallow

im very confused of what that means, what you trying to do with that
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
ohhhhh that makes sense
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
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?
Are you sure the path is right?
yea
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
It is also strange because after restarting the server, I works for one time and after updating something of the maps, it doesn't
if its only modified once you could add a boolean that you can read to know if something happend, or if its a set value that you could get another time and those fields are modified you just check if its different
ok, thx anyway
I guess instead of a boolean, I could add a "version"
yeah
are you using a configuration serializer?
I don't think so
I assume something will be null of you expect certain data that isnt there
Indeed
Then that is your indicator it is different
My custom Objects are ConfigurationSerializable
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
Adding a version identifier would be better and smart in the beginning
?paste the serializers used there
?paste
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
Well, I just need to know what to add, I guess just if something is null, initialize it to default would be good enough
I need the Position because I don't want to save the map.
I thought is easier that way
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?
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
As in
class Ser1 implements ConfigurationSerializable {
private Ser2 ser2;
}
class Ser2 {}
looking at it the Position object is null, somewhere the Position var is null
I don't think that that is the problem
I save the yaw and pitch as null when not set
if the obj wasnt null but the values were it would still add the x,y,z fields
yea
I don't understand
at my map I didn't set a spawn or other values yet
so they are null
that would be why theyre null
Мне нужен кодер
yes.
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
But that doesn't make the whole map LinkedHashSet null
when trying to get it from the config
he did also want a "you place 1 ladder you place 3"
im pretty sure my brain hasnt turned on yet, so ive got no idea whats going on. Best to wait for a few others to help
You can only have one null value on the set as the set doesnt allow duplicate values
If you do so it makes it all null
ok, no. I think there should be no null value in the Set
because what should be null. Max the value of a map key could be null and they aren't in a set
I miss understood
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
?paste show some code
Dont use server reload especially if your plugin isnt coded to handle it
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
and here some images
ok, that makes sence
but why should the config in memory be different from the one in the file?
where?
Because yml doesn't want to save Material properly
Its not about being different its about object references no longer being valid. If the reference isnt valid it returns null regardless of what you do. Now it could be your plugin is coded in such a way that something causes the plugin to refresh references or obtain new ones. Thus the random failures with reloads
?paste
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
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Does BlockBreakEvent trigger in ANY case that the block will get broken?
Piston? Mobs?
So if I want to make a specific block unbreakable by all those things
I need to check for each one individually?
yes
You could just set the tag
?
tag?
You have caught my attention
Pretty sure there is one otherwise mojang would have to code fpr all those things too for bedrock
Let me checj
bedrock is a hardness value in the Material data
But like, I want only a specific player to break it just want to prevent everything else
?jd-s
Modifying teh hardness of a Block is possible, but it is not easy and requires you use reflection
imho no
So I think events is the way to go
the client will still ghost teh block at times
Why can't all the events be in one place...
they are technically
Well....
just search for Event and you have all of them
it was either mfnalex or 7smile7 who wrote a class for modifying Material data but it's not 100% reliable
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
no
Cause technically only block that explodes is tnt
explode is for things like beds in the nether
Oh
entity explode event is tnt, creepers etc
tnt block doesn;t explode
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
Then all you have to do is check of if its your block and the right player and let it break
enderman counts?
block break event, Entities/tnt, endermen, pistons
If you set the hardness level to -1 you dpnt have to check for all those things lol
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
Blockdamageevent still gets thrown
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
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
But eventually I need the player to be able to break it
I just need to make it inmune to everything else
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
What if I set it to -1 and make a button inside the GUI that's called "pickup"
You can simulate it breaking by just removing it and spawning it on the ground as an item at the same time
So I make it fully invincible unless you press the button
You could do that too
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
Yes it has to be placed to modify it. Unfortunately will require some nms
So there's no way to set the hardness while it's an item in inventory
No, because that gets set when the block is created
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
You can just set pdc flag to item and set hardness when placed according to that
Anyways time to drive home
That' is true
Damn i like that solution
But this still requires nms
And so far I haven't needed it
Just go for it :P
You'll learn good abstraction ciz I'm assuming you'll need it for multiple versions
Can someone help me on making my own server public? I did port forwarding and firewall but still doesn't work
If you are sure you did everything correct, contact your isp
There is not much we can do
Also no reason to cross post across multiple channels
email be like: "hello sir i am making a minecraft server but it doesnt work" 💀
Pls fix
Okay Thanks
Any acf experts around? smile?
?ask
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!
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?
Give to yourself if no player
ah
And give 1 if no number
atleast use a Player object
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
you will get a syntax error when you did not provide a player name
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
Oh
if(playerName == null) return;
if (!(sender instanceof Player player)) return;
player.doSomething();
Just have optional player
And if player is null, it is executed by console/command block?
Well, if it's executed by console should have a player
I think maybe separating
Is better for this
What
Only allow Player sender
Console is not a player
I mean, if sent by console, player shouldn't be optional
I'm gonna split it
And use @optional Player
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
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
what exactly r u trying to achieve
Whats the question?
@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) {
What about optional default player?
Optional means the value is null if not provided
like plugin dev income?
I want to default to the sender if no player is provided
I would do a simple null check
Ok cool that's how I was doing it
Thought acf had something else fancy
Thanks smile
It has but i think you should start with just a simple null check
Alright cool, thanks
block is well, block. BlockData is data inside of block, for example how many bites of cake is left, and state is well explained in docs
Represents a captured state of a block, which will not change automatically.
So if I want a chest I just want the Block
i assume that good percentage of guys here learned or started learning java because of mc
nah, you are doing it right with block state
mc is literally how I have my current job
It's not related at all to mc but I learned a lot of core concepts from plugins/mods
its always easier to learn something if you are interested in doing it