#help-development
1 messages ยท Page 349 of 1
not sure why there is confusion in how to handle your own objects
That is what im asking!!
What is the best way for retriving the data form the packet? Using an event-listening system or something more simple, like a run(Packet packet) method
same way you send packets
I think you mis-understand the events
the events purpose isn't for retrieving data
if you want to do xy with the Object directly, just execute it on Constructor
the purpose of them is after you have your data, you want to notify things of this data as they may want to do something with it
Yeah that is what im trying to figure the best way
so, the obtaining of the packet, and parsing its data should be kept with the rest of the packet stuff until you get your object, then if you want stuff to be notified of it you would execute your events with the data part of the event
that is what im confused and dont really know what to chose here
I am not sure why this is even a choice to you
regardless of which you do, you still need to parse your packet
Atm i harcode like this, using Json to test
the only optional thing here is whether you want to setup an event system or not
Hi, I'm making a plugin for an UHC and there are several things I have to do with the plugin but I couldn't figure it out even with some tutorials, maybe someone can help me, I need to create custom death messages and chats a bit specific
Context of custom chats
||I have to do 3 chats, because it is a 6vs6 UHC with couples there will be 3 different chats, 1 will be global, I want to use an @, for example when putting "@Who died?" is displayed for all 12 players. Then for teams of 6 with the use of !, that by putting for example "!Where do we meet?" it will only be sent to those 6 of that team, and that by simply not putting anything it is only shown to your partner. Thank you very much in advance. If anyone knows of a plugin (for 1.16.5 in spigot) that allows me to do that, I would greatly appreciate it.||
this is help development
what the heck is an UHC
Frost did know i explain what i need?
is that some kind of electronical device lol
Its a mini game
I thought it was to ask for help about plugins
no
I told you the only optional thing is the event system
you still have to parse your packet regardless
sorry, where should I ask for help?
for help about plugins, you should ask on the plugin's discord
Yes forget about packet parsing, i already have that done in the RedisListener itself
or in #help-server but the chance that anyone here can help is small
I am trying to make the plugin by myself tho. Thanks
Well either you want help in regards to making a plugin, that is you are making it or if that isn't the case you want help to find a plugin that does this
oh then you're right here
I'm asking for help to make it
an option you can do is make use of conversation api
listen to the AsyncPlayerChatEvent, then check if it starts with ? or !, and if yes, cancel the event, and send the message manually to all the players you want to have them receive it
then the only thing is whether or not you want an event system
it isn't required but you might want it if you are making an API as it makes it easier for those that might need to do something with that data
Can I use multiple values?, like I said I need to use 2
That is what i was asking, what is better using an event system or something different, because i just need when any packet is received, you should be able to run code
ik but im asking for recommendations ๐
just get the first char of the message string, then check whether it starts with !, or ?, or none of those
its not like using an event system is unefficient or anything
it just depends on what you are wanting, what you are comfortable in using
etc
thanks, I think now I can start somewhere
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
String message = event.getMessage();
if(message.startsWith("!")) {
// Do your global chat stuff
} else if(message.startsWith("@")) {
// Do your team chat stuff
} else {
// Do your normal chat stuff
}
}
sth like that
right, thanks and sorry for losting your time and also you too DaeFist
E.
that moment when you got several unique ideas but are too lazy to start making any of them
Answering to? I get confused sorry
oh weird, ithought you re answering someone
I am making a minigame and I want to let the user define play regions for each team which the team will not be able to get out off while in a match, is there any effective way to do this without worldguard/worldedit api(s)?
For that type of things i use something like a cuboid region
So then i dont depend on third parties libs or apis
As far you should only code on newer versions, you can make use of BoundingBox
yeah I only plan on making 1.13+ plugins
I'll look into BoundingBox, thank you
the thing is
I actually want the player to select a 2D region, which would be the floor of the play area
and then the "box" will cover infinite height
BoudingBox already implements the cuboid idea, so if he use it he have everythign served
yeah
minion are u free bro?
I need to talk with you i have some questions to do but im really confused
hmnn ok i will wait once you are free, because its something really confusing
Hello, I'm not sure this is the right channel but I was wondering how would I make my API compile inside other plugins from my local files thank you. I'm using Maven.
Add the project in your dependencies and it should pick it up if it's in your .m2 local repo for maven. If not you may need to do a mvn clean install for the api to add it to your maven local repo
Alright thank you ๐
Hi i want to make pig npc will attack player using EntityCreature use
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(10.0D);
but it got this error Cannot invoke "net.minecraft.server.v1_16_R3.AttributeModifiable.setValue(double)" because the return value of "org.nightmcc.bosses.mcs.CustomEntity.getAttributeInstance(net.minecraft.server.v1_16_R3.AttributeBase)" is null
can someone help?
I guess pigs don't have that attribute ๐
maybe you need to create the attribute & add it to the entity somehow before setting its value? I'm not really versed in attributes
who said pigs cant do damage
thank you let me google that
can you help?
lol
I mean, I can certainly do some damage
emotional damage
exactly
๐ณ
bruh ur name
Also use the API for attributes
is there a way to make it so a prefix is automatically attached to all messages that the plugin sends to players? my plugin has tons of messages and I dont want to manually add "prefix +" to all of them
sounds like a design problem
well, what other way can I use to send messages to players
you could design your plugin to pull strings from a file you configure
so that it isn't hardcoded completely, or design the messages to check like a message manager for the messages to send
but in either case neither of these are going to get around the fact you just might have to re-design how you are doing it so as in the future it isn't difficult to change it later
that is, should have made it dynamic in the messages to begin with
sometimes, you have to break things to make them better
the strings arent hardcoded yeah
thinking about it however, I could make one function which takes in the player to send the message to, and the message and that function would automatically attach the prefix and all
and if I want to make any changes to all the messages, I only have to change one line of code
the messages themselves are grabbed from a file
Utils.sendMessage(player, message)
just append the messasge there
or the prefix
Utils who?
Utils you
Hello, I'm trying to apply skins to npc using citizens API, but doesn't spawn the skin i'dd want. Here is my code:
NPCRegistry registry = CitizensAPI.getNPCRegistry();
NPC npc = registry.createNPC(EntityType.PLAYER, "npc test");
World world=Bukkit.getWorlds().get(0);
Location loc=new Location(world,-41,200,-120);
SkinTrait skinTrait = npc.getTrait(SkinTrait.class);
skinTrait.setTexture(...,...)
npc.spawn(loc);
Try using getOrAddTrait
and I do setTexture after ?
Yes
Are all veriables saved for ever? like if i set a veriable: x to a location. Will that location stay saved in x even after restart or updating the plugin?
No
if not how do i make it save for ever
You will need to save and load it from a file
so save in a file and then load from that file?
if its never gonna change you can probably re-make that variable on enable
Doesn't work, it's not the skin I want. What are the texture signatures and values ? :/
So it does add the skin?
The skin I want is a dwarf picked from mineskin, instead, I get a black woman
no joke
Send the link to that skin
Looks fine now show your code
NPCRegistry registry = CitizensAPI.getNPCRegistry();
net.citizensnpcs.api.npc.NPC npc = registry.createNPC(EntityType.PLAYER, "npc test");
World world= Bukkit.getWorlds().get(0);
Location loc=new Location(world,-41,200,-120);
SkinTrait skin=npc.getOrAddTrait(SkinTrait.class);
skin.setTexture([value copied from mineskin],[signature copied from mineskin]);
npc.spawn(loc);
NPCRegistry registry = CitizensAPI.getNPCRegistry();
net.citizensnpcs.api.npc.NPC npc = registry.createNPC(EntityType.PLAYER, "npc test");
World world= Bukkit.getWorlds().get(0);
Location loc=new Location(world,-41,200,-120);
SkinTrait skin=npc.getOrAddTrait(SkinTrait.class);
skin.setTexture("ewogICJ0aW1lc3RhbXAiIDogMTY1NDgzNDA4NTUxNCwKICAicHJvZmlsZUlkIiA6ICJmNTgyNGRmNGIwMTU0MDA4OGRhMzUyYTQxODU1MDQ0NCIsCiAgInByb2ZpbGVOYW1lIiA6ICJGb3hHYW1lcjUzOTIiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWQxMWU3OWZmMjk2ZDZmYTdlNTc5Y2U5NjE5ZWVkZjM3OGJlMGJjODNkYjZkOGI3NWVlMzBhOTQ4NDg5ZGZmZCIKICAgIH0KICB9Cn0=","uVSLHxoBBBWOGLOuVmm/u8/jhFoZsjlxIew4Ah/CwGMJY32hCD+bns/CSk+gjq34Tb0WyUpcdcwtYp1S6ejE5EV/34O7O1/R5neIEJKYzHJx3MoJjU2eCE9cB/zsuDnjHl7Kwz7MW1Yv7StcUaXaXirjHv3JjERxda+76kPVnA9bJ7wdP4N5DptCUuh9OIjwWR4ZCxX9DOD3yzmvdTjidfczcToAnrOumLGvZTGlfSESY9MUBgkfZM75sKGpgH9dgGC0pKE4AMi8BmbtvbnByWdqOGHzA91E9GccVqr1UUikO7f73suJaO303pF52jyIfMxxr2jY5fvhMbv5x+GdYmJdfYGOpFeJ/ud1GMhW+QR8bjYKX8bTipmmDCsTvIeRCclr4Pfz69iYILemwjsZDSN0sLN2gb2zFaFr6sDXSt39LyvBgINBdhSjbfsFRJ5Yn64Y3ejJ1GzvVtvK0+ZcY3WouX/jEpMCwoVn0ew7UGfoG/HedlrxC3gBhW3W0Rw+LwxfGh5Cj5XgrhFlXLzYherMHK0YbPIBSrp+dU5u81wQABswUfreJVShFcrH+XCtfvO4C4rHqF463HR1pGQXPKIXjTQrSRW7iv6AaDENuIwBp7kMQGz2JR6PZn9QUWp1Slcg9THKg3oQtCJWvBqS7xLD75b+RSyjqGO//sq90Mc=");
npc.spawn(loc);
hm looks fine
you got the right skin ?
because when reloading the server, it changes skin
now it's a sort of mage women
I haven't tested the code but the skin texture value is correct
I feel like my server has dementia lul
You can decode the texture value since it's base64
in it is the link to the skin you want
I haven't verified the signature though
Try setting fetchDefaultSkin to false
"Expected 0 arguments found 1" what
How can i add multilanguage support in to my plugin?
Depends on how you want it to work
Do you want a resource pack with language files?
Do you want to detect the client language and show that?
Or do you just want a simple setting?
Also what version are you making the plugin for
I created a folder containing all the differtent language files, ad just whant to get the file with the language and the strings from it
1.12
Just load them like any other file
I assume it's a yaml file
yes
so use the config api
But how can i make it create the folder with the files, like the default config?
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
new File(JavaPlugin.getDataFolder(), "folder").mkdirs
Let them read the wiki
what is the @Transient methode from kotlin in java?
Java has the transient keyword
ohh ups
IntelliJ iirc has a way to convert kotlin to java, but also java to kotlin
Ye but wouldnt say the transpilation is too bad
Adding skins to npc using citizens API
p.getWorld().getBlockAt(p.getLocation()).setType(Material.BIRCH_SIGN);
Sign sign = (Sign) p.getWorld().getBlockAt(p.getLocation()).getState();
sign.setLine(0, "line");
It doesn't work
setLine()
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Bruh I can't upload an image
?img
Not verified? Upload screenshots here: https://prnt.sc/
I'm using spigot
import org.bukkit.block.data.type.Sign;
in BlockFromToEvent can i somehow get the original water source?
im figuring out who placed it
industrial revolution
Interesting topic for this Sunday
Is it about making new steam engine on Hydrogen
How would I'll be able to shot particles like this?
So is there basically a way to give them a direction?
What happened to event?
show the rest of your code on the right
you didnt define it
What should I do?
public void onSomeEvent(@Notnull EventName event) {```
you're missing the event on the right of PlayerJoinEvent
also I could be tripping but I think its @NotNull
thank you
ij always tells u what to use
how would you set the maximum enchant level for a certain enchantment table? for example i open an enchantment table via a gui, how would i be able to manipulate the maximum enchantment level
it shouldn't be used for some things
ij gives bad advice
idk i dont use annotations anyway
it makes a mess
well it also suggests using notnull method thing too
imagine annotating every parameter
you double your line length
what is it for anyway?
ides right
cant comments to the same
which is annoying when some people come here with problems, and its an NPE but because they used that requireNonNull or notnull or whatever it is, it hides the problem as some other problem instead of an NPE lol
PrepareItemEnchantEvent to display your lower enchants, EnchantItemEvent to apply the one clicked on. IIRC, you gotta store what you generated yourself.
alr ty
?paste
frost, or someone else do you maybe know how to get the water source for BlockFromToEvent?
Objects#requireNonNull throws an NPE
@NotNull shouldn't do anything on it's own - but IJ could be doing some shenanigans there
to let other developer's know what they should expect while using ur code
ie. annotating a method with Nullable, it lets other devs know a method or field can return null when accessed or invoked, so they can properly handle it
those annotations are also in reference to something by the Java team themselves iirc, its JSR-305 i believe
also its cool if you use java library in kotlin for example, string defined with @NotNull will be String, otherwise it will be String!
The JSR annotations are not that great
The event doesn't have the info, that's for sure, so tbh... I'd recursively follow the adjacent water blocks until I find a source block, haha. That should be blazing fast anyways, as there are not that many blocks until a source by the constraint of max flow distance.
now another thing i need to know who placed that source
im afraid of memory leaks long term tho
they are more or less the reference for stuff like jetbrains annotations tho arent they
i'd need to keep track of each water placed by player
Weak map, lol
they are more than a reference
theyre like a specification 
Mojang uses them for example, but pretty much every mod loader remaps them to IJ annots
ive never used that, what if for example the water flow takes ages
when entries are broken?
In practice? Perhaps. In theory, no - they are the standard implementation there
ye
jetbrains ones are simply the superior implementation idk
eclipse also has their own annotations but even as an eclipse user I don't use them
native would be the best lmao
Not completely sure what you mean :-: You just want to know which player made a block break by water, right? So make a WeakHashMap<Block, Player> entry in PlayerBucketEmptyEvent and then, in BlockFromToEvent, follow the water until you find a source block, check if it's in that map, and if so, you got the info you need. If the block get's garbage collected, the entry will just disappear from the map. If you're afraid that a player might destroy the source before the flow reaches the destroyed block, use a custom implementation of the weak map which stores the entry for x more ticks, I'm sure there's a way to do that. Otherwise, you could also listen for destroys of that water-block yourself and remove the weak-concept all together. Just some ideas, you'd have to experiment on that yourself.
otherwise we have a shit ton of implementations
Guys pls help me.Why this code didnt send me a messages in discord?
https://paste.md-5.net/ikaxoxugip.java
15:06:19 [INFO] DiscordSRV enabled! Sending discord message...
15:06:19 [SEVERE] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
15:06:19 [SEVERE] SLF4J: Defaulting to no-operation (NOP) logger implementation
15:06:19 [SEVERE] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
15:06:21 [SEVERE] SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
15:06:21 [SEVERE] SLF4J: Defaulting to no-operation MDCAdapter implementation.
15:06:21 [SEVERE] SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
15:06:21 [SEVERE] [Server thread] INFO JDA - Login Successful!
15:06:22 [SEVERE] [JDA MainWS-WriteThread] INFO WebSocketClient - Connected to WebSocket
Im trying to make DiscordSRV for infdev 20100618 (Ported poseidon project)
๐ for what
๐
So
Why it message didn't send?
i have no idea, might be a good idea to talk with ppl at discordsrv
Does it matter if map/list is initiated in class or in constructor?
Usually no
what happened
version mismatch
ur plugin has been compiled on a more recent version
downgrade ur compiled version or upgrade your java version ur server runs on
thank you
No, but initializing them inline with their declaration is ugly, :(
how to compile .jar to plugins folder directly to use pom.xml
personally im a fan of doing it the ugliest way
private final Map<String, String> headers = new HashMap<>() {
{
put("Connection", "close");
}
};```
initializing with a preset key/value 
mvn clean package
oh wait
yes
what error
beautiful
Cannot find 'org.apache.maven.plugins:maven-jar-plugin:2.5'
try using version 3.3.0 (current latest)
same
send full pom then
ok wait
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mng.minecraft</groupId>
<artifactId>MinecraftPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MinecraftPlugin</name>
<description>Minecraft plugin</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>https://github.com/%github%</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<outputDirectory>%mydirectory%</outputDirectory>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
is there a way to asynchronously wait for a player to type a specific phrase in chat inside a method?
I am trying to make a setup system for my minigame plugin
the Conversation api might have something of use
so if the player types "done", it completes that part of the setup and moves onto the next
Inside a method?
oh
what should i do
That should work. You may want to restart your IDE then
And clean caches and stuff
https://www.spigotmc.org/threads/spigot-conversation-guide.434956/ see if this is something u might want to use @misty ingot, its built in to Bukkit api
wow thx it works
if (data.getString("setup-stage").equalsIgnoreCase("set map spawn")) {
// send message
player.sendMessage(plugin.setup_messages.get("SetMapSpawn"));
// wait for player to type "set" in chat
Bukkit.getPluginManager().registerEvents(new Listener() {
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
if (event.getPlayer().equals(player)) {
if (event.getMessage().equalsIgnoreCase("set")) {
// set spawn
data.set("spawn", player.getLocation());
// send message
player.sendMessage(plugin.setup_messages.get("MapSpawnSet"));
// set next stage
data.set("setup-stage", "set team spawns");
// save data
try {
data.save(new File(plugin.getDataFolder() + "/maps/" + mapName + "/data.yml"));
} catch (Exception e) {
throw new RuntimeException(e);
}
// start next stage
setupProcess(player, mapName, data);
// unregister listener
AsyncPlayerChatEvent.getHandlerList().unregister(this);
}
}
}
}, plugin);
}
this is what I came up with, is anything wrong here?
not anything that's immediately clear from what i can tell
you should really create a proper framework thingy for that
probably
instead of listening everywhere
Yeah i will make a proper class for it
throwing runtimeexception questionable behaviour 
I just wrote that code, chill out
conversation api 
We are allowed to edit code right?
of course lol
dang it, i forgot a semicolon.
oh well
better restart
its shit
better make ur own
Just have a Map<String, Runnable> for phrase listener registry, and if message contains key, remove and run runnable.
I know, but if you use requireNotNull on an object. And you subsequently make that object null or it becomes null and then you try to do something with it, the way the stacktrace is for it doesn't make it obvious that the object is null. Whenever I see it happen to someone I will save the output from that to show you.
Imagine that was actually the case lol
Actually good idea, then i could also just have a player chat listener running without needing to create and destroy so many
All i need to check is that the message matches the required phrase
Yep, but maybe it could even be improved a bit by supporting cancellation through cancel in chat, or by making requests timeoutable, by adding a creation time-stamp as well as a timeout checker task. Just make sure that you don't end up with a lot of unexpected map entries which never got called because the user cancelled the process which will then later fire randomly whenever they seem to match something.
yay
i finally learned how to use classloaders to make my own plugin extension system
now i can bundle my jobs in a seperate jar files
I wonder if i would extend url classloader
but i dont seem to think a reason why
but bukkits extends it for some reason
only downside to this is u have to re expose spigot to interact with it ;/
eh
but you're right
for more functionality i would need to cast down to bukkit implementation of that object
to get plugin's instance
:/
Hello !
I have a question about Spigot and BungeeCord.
What would happen If I create a plugin who support both (and I install this plugin on both) and create a command bungee side and the a command with the same label spigot side ?
Is there any priority?
I do actually plan on having those features
URLClassloader does grab resources from folder/jar right?
Hey guys whatโs the best and most efficient way to code it in my mini game so if a player dies they get teleported to a spot instead of actually dying and get healed.
i wanna say bungee takes priority since it's the middleman
bungee should win
but u can always just try it and see
Ty ๐
Is there a way to be like if the damage is more then my health then tp to x position?
you're talking about cancelling death menu right?
off the top of my head i remember having to use like Thread.currentThread().setResourceClassLoader (or whatever the method is) to load non-class files from externally loaded jars
but i mightve just been stupid
Iโm doing it one way but I feel like thereโs a more efficient way because the way Iโm doing it takes a lot of ram
how does dying take a lot of ram
Negative reactions incoming in 3... 2... 1...
i feel like you're not cleaning up your list or maps
after death
alr, now i need to implement proper api and classes for my roleplay job plugin and i would be good to go
Youโre supposed to stay on the map after death but the issue I was having was that I had to manually input how much damage players should die on. So I was wondering can I do something like if the damage is higher then my health then do this?
eh i gave up on that one
@dry yacht can also store the exact player to target with the requests using this, wouldnt want some random in chat to confirm my setups for me
Just like in Far cry 5 County officer said, sometimes its best to leave some things alone
idea from bed rn but
on PlayerDeathEvent, set respawn location, and then force respawn player?
Can I just do that?
That means that they would have to die first.
well, taking more damage than available health usually means u die
You should listen for the PlayerDamageEvent and check values there.
I donโt want them to go to the death menu
Yes, but the PlayerDeathEvent is fired once you die. Meaning that you get hit with the death screen.
Is there a way to cancel it?
?jd-s for me got an unrelated idea
is there any difference in terms of performance if i need the instance of the class and I use findClass() and newInstance() instead of doing Class.ForName() and newInstance()
static blocks should be still initialized if i use first option
right?
since new instance is made?
Classloader question
does forName call findClass internally
im laying in bed, i dont remember and i cba to look
Oh yeah, of course, I totally forgot that you need to scope requests to a player. You should probably create a ChatRequest (or similar) wrapper which stores the string and timestamp, as you very likely will add multiple fields in the future, like a Runnable for cancellation too, for example. This way you don't need multiple maps. Also, make sure to remove from the map on PlayerQuitEvent, to avoid memory-leaks.
There is, but you won't achieve it by cancelling the death event. (You shouldn't really be cancelling that event as it will cause many problems) You need to listen for for the EntityDamgeEvent, check if the damaged entity is a player, then compare how much damage was given vs how much health the player has. If it's enough to kill them, then cancel that event, and switch them to spectator or what not.
wouldnt be that Class.forName() creates dummy object
just to initialize static blocks
or is it somehow hotstopintrinsic
ie depends on jvm
itself
yep yep good idea
I'm always laying in bed while developing, happy that I don't got that attitude, otherwise nothing would get done, lol
i dont own a laptop.
:(
Any reason you aren't using the Conversation API for this?
yeah, why should I?
Lib >> API
Well from what you're describing, it seems like an appropriate use for it.
no, that'd be stupid
how does it initialize the class then
I'm sorry what?
It just initialized it?
if so, why does findClass() doesnt do that
it has to have some special black hole dark matter stuff
to make it work
by initialize i mean initialize static blocks
findClass() returns class object but doesnt do that while Class.forName() does that
Yeah, I mean Class#findClass0 is a native method
So figure out how it does it. Hint: It doesn't involve Java code
Independent libraries which can be separately maintained, updated and just used as in composition with a project are far superior to these inflexible, set-in-stone and version-dependent bukkit APIs.
so it should be implemented internally
i think there's no difference if you need an instance which one is faster to compute
since both are getting initialized anyways, but with class.forname() it would try to initialize twice
since newInstance() also initializes the class if the object is created first time
maybe couple ns at max
I agree with this to a certain extent. However, what api methods are set in stone? You can do quite a lot with the API now. I find it hard to justify using a library when I can get what I need out of the bukkit api.
newInstance would be a serious security risk
You'd need to use Unsafe#allocateInstance
Which would be equally stupid
why newInstance is a security risk?
I'm talking about the case of "I need another little feature in there". I cannot just fork it and extend it, if I don't want to be bound to the latest version, whenever that releases, if they accept my PR. I strongly dislike that way of adding functionality.
Also, most really useful APIs have been added way too late. Libs have done that kind of stuff for ages. I hate being bound to versions.
It's calling the constructor?
Constructor#newInstance()
that wasn't the point geol was making methinks
can you further elaborate by what youre defining as a security risk?
Oh, that's nice to know, ๐
You're running arbitrary code when it shouldn't run
Ah, fair enough. I get that. Things like yaml comments or nbt were the most annoying things for me. I found it really annoying to have to use a library just to get that functionality, but thankfully that was added in 1.18.2 and 1.13.2 respectively.
discord doesnt recognize IntelliJ as an activity wtf
but in that case JavaPluginLoader class would be a security risk too
SSVM implements the method as follows @mortal hare :
- https://github.com/xxDark/SSVM/blob/master/src/main/java/dev/xdark/ssvm/natives/ClassNatives.java#L107
- https://github.com/xxDark/SSVM/blob/87a9959fb3c2142382325bf548ad90f1586f8bd3/src/main/java/dev/xdark/ssvm/util/VMHelper.java#L1197
- https://github.com/xxDark/SSVM/blob/87a9959fb3c2142382325bf548ad90f1586f8bd3/src/main/java/dev/xdark/ssvm/VirtualMachine.java#L647
- https://github.com/xxDark/SSVM/blob/87a9959fb3c2142382325bf548ad90f1586f8bd3/src/main/java/dev/xdark/ssvm/mirror/SimpleInstanceJavaClass.java#L188
good 
since it calls JavaPlugin constructor
im developing an addon system for my plugin
When calling the constructor very early some stuff might not have been initialized yet which results in NPEs at best and absolute fire at worst
I really recommend looking at how SSVM implements Class#forName0
It never allocates an instance of that class in the whole process
I really appreciate the bukkit API, don't get me wrong. I would hate to write low level stuff like just spawning and managing entities myself, that would be a huge pain. They're doing a great job, but we need to differentiate between core functionality and APIs which build on top of that. All the abstractions should be kept outside, in libs. No need to set anything in stone, to depend on any specific version. Some people would again strongly disagree with me on this one, but I'm totally convinced that this is the way to go.
The ideal for me is having many smaller libraries which do what I want, which are transparent and don't contain many transitive dependencies, which I can then compile together and dead-code-eliminate what I don't need.
wdym by very early
i still dont get your point
this would be so nice
Just after clinit
in most cases it doesn't matter - java works exactly like that.
But once you use reflection - it does matter
so how i can be sure that classes are loaded
and are ready to be used in an instance
Plus the constructor of our JavaPlugin would run twice if Class#forName0 were to indeed create an instance
And surprise ... it does not. I wonder why ๐ค
This is why I'm personally working this way, :). I'd love to see a future where nobody discriminates against any versions only because we collectively screwed up the architecture and boxed ourselves into this little prison.
It most definitely can be done, and I'm gonna proof this with some resources I will hopefully release sometime in the future. There are many great APIs already doing it, like NBT API.
i get that reflection instantiation is not safe, but how can i instantiate the class then
safely
yeah thats also the reason why I dont wanna touch nms
Plus it would be absolutely garbage for performance. There are tens of thousands of classes on a fully loaded JVM. That would mean tens of thousands of allocations that are unnecessary
Class#forName?
You mean running the constructor?
construct it
You run it when it is appropriate to run it
Well you should know that
You will need to call the constructor before you use it - that's obvious. Whether you run it way before it depends on your usecase and I can't really tell you more about it than "figure it out yourself"
im using newInstance to instanciate an addon object, at the the plugin's enable.
It might be useful to do that in the constructor of your plugin - but as I said, everything depends on usecases
oh i think i get it what you mean about that safety stuff rn
you were debating of whether to use class.forname or the second method to initialize the class
and then construct it?
right?
if anything, itd be nice to see newer bukkit api stuff backported (like PDCs), but this would require Spigot team to maintain legacy versions to some degree :v
I was debating about whether Class#forName creates an instance of the class
yea but you misguided yourself and started to talk about the safety of instantiating classes
with newIntance()
Hi, so I was following a article on the Bukkit forums on how to add a delay to an event and in this part it is telling me to remove the VanillaCustomItems plugin from inside the public Events(VanillaCustomItems plugin) {...
public static VanillaCustomItems plugin;
public Events(VanillaCustomItems plugin) {
this.plugin = plugin;
}
that's obvious enough rn its a native method, it doesnt create an instance
but i dont get it what you were talking about the safety of newInstance()
from what I understand you were talking that newInstance() alone is not safe as Class.forName() to instanciate class since class could be not fully resolved at that time
im sorry it is just so hard to understand, since class loading is a new dimension for me rn
so?
its a static field
so what is your question?
IDE is probably yelling at them for setting value of a static object from non-static context
just remove the static modifier from the field 
Or use Class name instead of this keyword to access the field
or that ig
when I do that it says, " Cannot resolve symbol 'plugin' "
How would that solve the issue in a broad manner? Many people are already running servers and are very unlikely going to update frequently.
This approach is just wrong and falls apart for so many reasons. Again, libraries are to be preferred. Their maintainers become experts in those domains and make the best implementation they can, which is simultaneously dispersing the immense workload which just comes with modding a game like that.
those who stay on the old version should acknowledge the fact that they're working with an old software
You said if anything, thus kinda talking down on what I suggested.
Server owners normally update as soon as they can. The only thing holding them back in most cases is plugin updates and world changes.
Acknowledge that fact - yes - but they should only be limited by the actual functional difference. Not by the stupidity of the architecture we've locked ourselves into.
Or optifine version releases, if you're an actual decent server owner, xD.
false. I was talking that it would be stupid for Class#forName0 to invoke newInstance due to the safety concerns
people still using optifine for performance are the obsolete 
also, in my main class where I have the event registered:
getServer().getPluginManager().registerEvents(new Events(), this);
It gives this error on the "Events()" part, "Expected 1 arguments but found 0"
u gotta do new Events(this)
oh ok then, you scare the shit out me then, since I thought my code was a hazard, and not the idea of the implementation of JVM lol
thx that fixed it
hi. how can I create an empty blockstate just with the Position of a block?
this being said, i still switch to OptiFine away from Fabric ASAP when previews are available, ill take the absolute monolith of a mod that OF is over 50 separate single-function mods that fabric encourages
Fabric Sodium > Optifine
sodium doesnt provide any higher benefit than optifine for me :p
i havent used forge or optifine for at least 3 years
and i dont miss it
especially with the mod support it provides
both for the client and the server
at the same time
and some shaders i occasionally use are still partially broken on Iris, not faulting Iris though, OF being closed-source makes it a bit hard
I fps limit myself when i play minecraft
less cpu
with high power comes high electricity bill
Me playing Apex Legends isn't great for the electricity bill
anybody playing Apex isnt good for the electric bill
CPU 100% GPU 100%
Star Citizen type beat ๐ช
limits your fps when you're minimized the game or went afk
I have 4 core 4 threads
I have 2 cores 4 threads
12c/24tr amd ryzen 9 3900x
Daily worries of the modern age, sad but very true, lol
i average 30fps in Star Citizen in high detail scenes like starports
rtx 2060 but i dont think im gpu bottlenecking in SC
i wonder where on what class should i store user data regarding the job
job class
or the user class
.//push
both have cons
well, which one has the less annoying con
Guess why, because games are too badly written to properly utilize more than 4 virtual cores anyways, lmao.
both have
i5-3470
if i store it inside a map of user manager, i would get issues whenever i would want to index available jobs
a bit old innit
if i store it inside a map of job manager i would get issues whenever i would want to index player's data
since it would be fragmented inside different job classes
transitivity problem
too bad that the java doenst have pointers :/
two pointers for the same map
voila done
i3 
ive only had bad (sloowwwww) experiences with i3's, maybe intel just has shit laptop cpus for that level
but still havent managed to upgrade the cpu
i literally spent only 20 bucks to upgrade my ram from 8gb to 16gb
kek
thinkin abt upgrading to 32 or 64
but if i go 64 ill need to swap out my current sticks (2x8gb)
i mixed ram, but i managed to find one stick so similar on the market, that even the chips serial codes match up
it was just a different arrangement and manufacturer
if i havent bought that stick i would've needed to pay 80 bucks
ill probably stick to same lineup, just the non-rgb variant this time x)
for the same shit
why? isnt 16gb enough?
i peak at 11-12gb at most
not for Star Citizen ๐
it uses 10gb of ram on its own, and then winblows uses the fckin rest of it
I have 32 gigs of ram and boy do i love it
12gb enough for rust
debloat it
use Revision OS
best iso
cba to custom rom my windows
besides, more ram = more upscaling for my anime pictures
I used before debloated win 8.1 it used around 700mb of ram at startup ๐
then i can go higher resolution
i like stock windows 11
that win 8.1 iso was so clean that it matched the linux ram usage
it idled at like 6GB on my machine
win10 isnt much better but i save an extra 2GB by using it
i'll switch when they would add top taskbar support
my windows 10 machine idles at like 4+ GB ๐
if firefox tabs are at the top why start menu couldnt lmao
you move your mouse at the top much more and it easier to move at the top then down
this probably wont happen ever (and doesnt... need to?) as iirc microsoft is redoing the system UI to look more like macOS (bottom = taskbar, top = file menu(or well for windows, status icons))
if it doesnt i would probs switch to linux or on the worst case use third party start menu
Debian ๐ช until APT accidentally uninstalls a core system package
Arch ๐ช now that archinstall exists, i might finally try it out
My friend uses fedora he said he really likes it
Fedora is meh
I've been using it for over 2 years now and the amount of bugs haven't been that great
The WM and whatever shit they are using for sound needs to be improved in terms of stability
the only OS i actually had issues trying to daily was Ubuntu i think
ironic, since its supposed to be one of the good ones
but every day was a new problem
these days it isn't that good
my main issue was nvidia drivers, the install was just so fucked for no reason
and then i think it ended up breaking a bunch of other stuff like Steam's Proton
//Push because .getBlock().getState() is waaaaaayyyy too unperformant
ironically just switching to the Kubuntu flavour fixed that whole debacle, so i guess they package some better stuff in, but it was just so annoying trying to do different workarounds with no success on plain old Ubuntu
declaration: package: org.bukkit, interface: RegionAccessor
that'll just do the same?
id imagine
imma try rq
I wanna send a shit load of block changes to the client, but Player#sendBlockChanges needs a BlockState
and I only have the blockdata
Gotcha
yep, still the same
just looked at spigotmc stash, this method effectively just does getBlock().getState()
woopsi
xD
its interesting bc in minecraft itself its actually the opposite behaviour (at least from what i remember), u get the Block from the BlockState instead, but this is only 1.8 era knowledge
and ideas on that?
Does anyone know how to stop an event from running again for a set amount of time? I can't figure it out, all the things on google are to delay it not stop it from happening again.z
ex:
Player right clicks Item
Player is teleported up 1 block
Player right clicks Item within delay time
Chat Message "You Must wait (# of seconds) before doing that again"
Player right clicks Item after delay time
Player is teleported up 1 block
...
store unix timestamp or smth time unit of the the time he clicked
then do subtraction math currentTime - oldTime > 0.5second then allow do something
no repeating tasks, no lag just two variables with the current and the old time
just remember that the player can log on or log off to bypass
that
if you wouldnt handle it properly
Okay I will try that thx
is pitch vertically or horizontally from players perspective?
pitch is up and down, so vertical
okok
ty
is there a way to get player direction (north south east west)
or I need to check all possibilities using yaw degrees
How are you building the plugin?
Maven
Entity#getFacing, which is what the Player inherits.
Could you show your pom
You're not depending on actionbar api
also if you're on 1.19.3 you don't need that
The spigot api can already send actionbars
how
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(str))
which one?
second?
Yep, second. The first is java GUI stuff, haha
Funny that your IDE didn't limit the number of choices there based on the available signatures of sendMessage.
uh oh
How do I get the Integer value out of this Hashmap?
public static HashMap<Player, Integer> map = new HashMap<>();
get()
^^
Integer
Expression expected
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
you get the player
whats that Integer doing there
I am trying to set it as a number to represent a time in seconds
When the Identifier masquerading as an expression got busted, lol
How do I umm... do it in a if statement.. i dont know how to English.
how do i do like this below
ex:
HashMap stores player and integer value
gets player
gets integer value
if player has integer value > 0 then:
send message "Wait {integer value} second(s)!"
command doesn't execute
@dry yacht I just realised that in setup parts like setting the team player limit, I'd also need the user to input (any) number(s)
instead of a specific message
i dont know what im doing
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
also consider storing a Timestamp instead if you are making a command cooldown kinda thing
but how would I like get the player that the timestamp belongs to tho
try actually clicking one of those links up there
i am
good
when do you want to execute that code?
You could have a validator predicate with your runnable, in essence a Function<String, Boolean>, which returns false if the message wasn't accepted. Until that returns true, you just don't remove the entry from the map. That's one more reason to have a wrapper for these types of requests, as you'd probably also want a player reference to send an error message.
all i want to do is, to make it so the player can only make the event happen after 15 seconds of last time the same player made the event happen last time
and its not as simple as i thought
Just save timestamp when player should be able to execute again, if timestamp - currentTime > 0 it's on CD for next (timestamp-currentTime) /1000 seconds
@glacial shell store player instance and timestamp of last time the command was executed in a HashMap
now everytime they make the task happen, check if 15 seconds have passed since the timestamp and do your thing
it actually is pretty easy
cant really help further than this
k
then listen for an event and get the player from there
How can i get inventory title from Inventory object?
Ok, thanks
me being happy that we finally use ij in college
hmm what looks cleaner?
//push
2
Though I'd use 1 but make the if statement inline
guys how i can teleport a player with cords to a world ?
the stupid thing is that my assert thing cannot combine a string supplier and objects as placeholders
as i dont want to call getOrdinalName when its not needed
@EventHandler(priority= EventPriority.HIGH)
public void onPlayerUse(PlayerInteractEvent e){
Player p = e.getPlayer();
Block block = e.getClickedBlock();
Action action = e.getAction();
if (action.equals(Action.RIGHT_CLICK_BLOCK)) {
if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "Clear Axe")) {
Location location = block.getLocation();
p.sendMessage("You have clicked a block at " + location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ() + "!");
e.setCancelled(true);
}
}
}
I want to get the block location when I clicked right button.
But it doesn't work well.
If I clicked my right button at block, it send message twice.
because 2 hands
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
Well
Let's break down basic worldedit
In 2D, you can represent a square with 2 points
topLeft and bottomRight
but it is in 3d
So 0,0 -> 10,10 is a 10x10 square, with an area of 100
In 3d you can also represent it with 2 points
min and max
so
(-10, -10, -10) -> (10, 10, 10) is a 20x20x20 cuboid
With a volume of uhh
8000? cubic blocks
mental math here
isnt it 21x21x21
uhh yeah
meth
idfk
Anyways
Those 2 points represent the 2 opposite corners
Now
Let's say you want to fill that area
You can just loop in each axis
and set the blocks
example
Anyone know of a library for generating points in various 3D spaces?
for(int blockX = min.getBlockX(); blockX <= max.getBlockX(); blockX++) {
for(int blockY = min.getBlockY(); blockY <= max.getBlockY(); blockY++) {
for(int blockZ = min.getBlockZ(); blockZ <= max.getBlockZ(); blockZ++) {
...
}
}
}
And that's literally how you fill a cuboid
You can then do some checks inside
oh
Like if you only want hollow anything that's not minX, minY, minZ, maxX, maxY, maxZ
or you can make like 8 separate loops
This is basic 3d math
bedrock, beacon, red concrete, red glass, netherite block <- this is what i want to except
*these are
ignore extension
ok
hi, is there a way to access the persistentdatacontainer of an OfflinePlayer even if its offline? i cant do OfflinePlayer#getPlayer cuz it returns null if its not online
You most likely need to access the NBT files directly
alr
I doubt you can do that through bukkit though
But there are APIs for that kind of stuff
so do u know how to access the nbt directly?
I'd probably use NBT-API or just nms
how do u do it with nms?
uhh
just load player files
access the file, read the nbt off the filestream
and you'll have a big tag
then you need to like parse that tag
I have a basic nms guide (click on my profile, it's in my about me)
and uhh
I've done something like this in the past
like 2 years ago
How to check that block.getType() contains exceptArr
ArrayUtils#contains
Should i have to use foreach?
Hello guys,
I'm creating a 1.8.8 spigot plugin, but I got some graphical issues.
When I launch my local server, I don't get any of these bugs, but when it's an online server, I got them.
These bugs occurred when I'm trying to move an item in my inventory, but these items go back to their source when I close my inventory.
Do anyone knows why ?
Too old! (Click the link to get the exact time)
alr, i have one more question, when does Player#hasPlayedBefore turn true?
but when exactly?
what do you mean?
pretty sure it just checks if the player file exists
what does it say when i check it on PlayerJoinEvent?
that was my question... when are the files created?
another one
I remember working on this implementation with choco
wait you guys wrote sendBlockChanges? lol
hhahahha aight
and why the heck does it need a BlockState instead of a BlockData?
how long after that is it false?
didn't spigot propose a method for multi block change too 
I feel like I recall a choco PR
as I've said
yes it is
does not exist for me
how to check left click on block?
PlayerInteractEvent
๐
obfuscation
they are linked to literally everything
@EventHandler(priority= EventPriority.HIGH)
public void onPlayerUse(PlayerInteractEvent e){
Player p = e.getPlayer();
if (e.getHand() != EquipmentSlot.HAND) {
Block block = e.getClickedBlock();
Location location = block.getLocation();
if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "Clear Axe")) {
p.sendMessage("You have clicked a block at " + location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ() + "!");
plugin.rightZone.put(p, location);
e.setCancelled(true);
}
} else {
Block block = e.getClickedBlock();
Location location = block.getLocation();
if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "Clear Axe")) {
p.sendMessage("You have broken a block at " + location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ() + "!");
plugin.leftZone.put(p, location);
e.setCancelled(true);
}
}
}
right click message sent twice

and getting a blockstate from blocks based on a blockdata for 100000 times a tick is hella unefficient
you were already told, why cant you listen??
so I need it to work with blockdata
so just use that
this is about time you use packets
I checked the event by two events
they accept blockstates only, too lol
BlockBreakEvent and PlayerInteraction
But it caused error when I used BlockBreakEvent
^ I've fully remade this
but
some of it works
protocollib fake blocks
with like
click detection and all
doesnt disappear when you click and all
per-player blocks
it's nice
this looks like I would need 10000000 hours to implement this
yes
and then you get into lighting and all
it's a pain
I think I've spent like 2 weeks straight working on fake blocks
yeah now that does not help me
I just need to send BlockChanges with BlocKData instead of BlockState lol
"a bit"
why does sendBlockChanges even need a BlockState at all?
reposting after 4 minutes does not help
wait let me pull 1.19.3
aight
app//com.destroystokyo.paper.profile.CraftPlayerProfile.copyProfileProperties(CraftPlayerProfile.java:213)
[19:45:17] [Paper Watchdog Thread/ERROR]: app//com.destroystokyo.paper.profile.CraftPlayerProfile.copyProfileProperties(CraftPlayerProfile.java:202) app//com.destroystokyo.paper.profile.CraftPlayerProfile.completeFromCache(CraftPlayerProfile.java:174) app//org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaSkull.setProfile(CraftMetaSkull.java:89) app//org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaSkull.setOwningPlayer(CraftMetaSkull.java:209) com.alonsoaliaga.alonsotags.AlonsoTags.buildPlayerHeadItem(AlonsoTags.java:1407)
com.alonsoaliaga.alonsotags.AlonsoTags.openTags(AlonsoTags.java:1147)```
what is this error?
uhh
contact author
on spigot
alonsotags got random here on error
??
something tells me you don't deserve the "dev" in your discord name
huh?
okay ill remove it but will you help me?
ill get banned on paper if i ask help for older versions like 1.16.5
contact alonsoaliaga
Graphical bugs spigot 1.8.8 online
I'm getting an error saying that 'time' is null, which it is at the start, but it is later set as an Integer (like it is supposed to be). I can't figure out how to set it as an Integer temporarily (that Integer being 0), so it still later can be set as another Integer, without being overwritten by the 0 Integer.
Could someone tell me how I would do this?
oh oh
you should not have said this
@worldly ingot this impl isn't usable
why
wdym? lol

"this impl isn't usable". Yeah I have noticed that the whole afternoon lol
because you need to use craftbukkit's block states
very unusuable smh
as soon as I step out of the 16 block range from my spawners, they don't work... I thought editing the entity-activation-range would change it? Anyone have any ideas??
actually
watch till you find out PDC won't work with custom PDC implementations
It literally only lets you send blocks that are already sent to the client
what
creating fps spikes in the process
If you want to work on an alternative solution we can do that within the hour, choco
List<BlockState> states = new ArrayList<>();
for (int x = 0; x <= 10; x++) {
for (int y = 0; y <= 10; y++) {
for (int z = 0; z <= 10; z++) {
BlockState state = world.getBlock(x, y, z).getState();
state.setType(Material.AIR);
states.add(state);
}
}
}
player.sendBlockChanges(states);
This literally works
#getState() returns a snapshot
thats a blockstate

and blockstates need a real block to exist
no
mm that's a cringe way to impl this
How do I manually get the type of World?
BlockState blockstate = new Location(player.getWorld(), block.getX(), block.getY(), block.getZ()).getBlock().getState();
blockstate.setBlockData(block.getBlockdata());
states.add(blockstate);
thats what im doing
and this literally drains my server performance to hell
not using p.getWorld()
Let's just add a secondary impl then
plz let me update my blocks with BlockData lmao xd
You can clean up that impl real quick by dropping 2 instance creations
BlockState state = world.getBlockState(x, y, z);
Now you don't instantiate a Location or Block
I mean, BlockState works nicely.... Its literally a combination of position and block data
that calls the same
and I need to create a Location for it since my block is not a Block
That's fine. I passed in an x, y, and z
It would be cool if we could instantiate a FakeBlockState or a BlockStateCopy(Location, BlockData) or something
yes
this line can be problematic
How do I see if an Integer is null, because when I try to use an if statement, it says the Integer needs to be an Integer..
BlockState blockstate = new Location(player.getWorld(), block.getX(), block.getY(), block.getZ()).getBlock().getState();```
This is nonsensical.
```java
BlockState blockState = block.getState();```
where's that line?
What you are doing is creating a location at a block's x, y, and z, getting the Block again, then calling getState lol
his block variable isn't a bukkit block
I mean, the only reason you'd need a fake block state is if you want to avoid copying the data of the block that exists
which I guess is what I give you there
^
Okay, so then fall back to this
Still not creating a Location or Block
that does the same thing
I still don't think it's a great idea to fetch stuff like the block's type and chunk data and all of that
to override it afterwards
It does the same thing but you're not instantiating 2 random objects that you're immediately discarding
while still destroying my server performance
It's faster
sure, tho your chunk should be loaded
they are
the operations to fetch its internal block states hence are pretty damn fast
yea you override it and you could avoid that with some "FakeBlockState"
but bleh
That method doesn't guarantee how it will work for unloaded chunks
wow now thats gonna improve it by 10%
have you considered that a client does not like a multi block change packet of your size ?
this is WAYYY to much. This is in a small scale
lol
I don't know how you think you could improve it because there's really no improveable means of doing this imo
well
Maybe if you're sending one block type, sure
The first improvement we can do is ditch the CraftBlockState class in itself
idfk i dont use linux