#help-development
1 messages · Page 933 of 1
mobs
arrows
etc
Entity nearestEntity = null;
double nearestDistanceSquared = Double.MAX_VALUE;
for (Entity entity : player.getWorld().getEntities()) {
if (entity.equals(player)) continue;
double distanceSquared = entity.getLocation().distanceSquared(player.getLocation());
if (distanceSquared < nearestDistanceSquared) {
nearestEntity = entity;
nearestDistanceSquared = distanceSquared;
}
}``` like this?
Yeah
Is there a simple way to check if an enchantment is illegal (above vanilla value)
Enchantment#getMaxLevel
how do i make replenish and make it take 1 of the drops?
i cant find a way to remove drops and make it work with external auto pickup plugins
Hello, I'm using com. github. Anon8281.universalScheduler. UniversalRunnable and with this code:```java
FallingLeaves.getScheduler().runTaskTimer(new UniversalRunnable() {
@Override
public void run() {
Location previousLocation = leaf.getLocation().clone();
Location nextLocation = previousLocation.clone().add(nextx, FALL_SPEED, nextz);
if(nextLocation.getBlock().getType().isSolid()){
leaf.remove();
cancel();
} else {
leaf.teleport(nextLocation);
}
}
}, 1L, 1L);```
I get this error: [22:30:33 WARN]: [FallingLeaves] Global task for FallingLeaves v1.0 generated an exception java.lang.IllegalStateException: Not scheduled yet at io.github.paulem.universalScheduler.UniversalRunnable.checkScheduled(UniversalRunnable.java:138) ~[dist-1.0.jar:?] at io.github.paulem.universalScheduler.UniversalRunnable.isCancelled(UniversalRunnable.java:23) ~[dist-1.0.jar:?] at io.github.paulem.fallingleaves.leaves.Leaf$1.run(Leaf.java:56) ~[dist-1.0.jar:?] at io.github.paulem.universalScheduler.foliaScheduler.FoliaScheduler.lambda$runTaskTimer$2(FoliaScheduler.java:65) ~[dist-1.0.jar:?] at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[paper-1.20.4.jar:?] at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[paper-1.20.4.jar:?] ...
I tried checking with isCancelled, but I can't find something to avoid this error
why not BukkitRunnable?
so it supports spigot, paper and folia
where is that code located?
im guessing its the cancel
in a method to create an textdisplay and manipulating it with this scheduler after
TextDisplay leaf = spawnLocation.getWorld().spawn(spawnLocation, TextDisplay.class, (display) -> {
display.setBillboard(Display.Billboard.CENTER);
display.setBackgroundColor(Color.fromARGB(0, 0, 0, 0));
display.setText(finalColor + "🍂");
display.setBrightness(new Display.Brightness(5, 5));
});
double nextx = SafeRandom.generateDouble();
double nextz = SafeRandom.generateDouble();
FallingLeaves.getScheduler().runTaskTimer(new UniversalRunnable() {
@Override
public void run() {
Location previousLocation = leaf.getLocation().clone();
Location nextLocation = previousLocation.clone().add(nextx, FALL_SPEED, nextz);
if(nextLocation.getBlock().getType().isSolid()){
leaf.remove();
cancel();
} else {
leaf.teleport(nextLocation);
}
}
}, 1L, 1L);```
Dont create a runnable for each leaf. Just start a runnable when the server starts, and add leafes to the runnable.
humm good idea
so it'll solve this?
I'll follow that, you're the magician x)
I'm trying to make my plugin the most optimized possible so it's perfect, thanks
you could also check try to run the code once before actually creating the timer, so it doesnt instantly cancel if it passes the condition
Better write it in ASM then
💀
so run this
Location previousLocation = leaf.getLocation().clone();
Location nextLocation = previousLocation.clone().add(nextx, FALL_SPEED, nextz);
if(nextLocation.getBlock().getType().isSolid()){``` before creating the task
yeah good idea
I have something similar but not the same code
Humm, I'll have to do some PDC
no need to clone the location as its already a clone
Location are confusing, some method returns a location and some others return void and clone is not really required...
itemmeta from itemstack can be null?
you're doesn't have itemmeta...
Yes, for Air
Only for air
oh, thanks
java.util.ConcurrentModificationException: ???
Trying to remove from a collection while looping over it most likely
ooh
Use an iterator
removeIf
wow wow wo
what should I do? x)
Here is my code```java
getScheduler().runTaskTimer(new UniversalRunnable() {
@Override
public void run() {
for(Player player : getServer().getOnlinePlayers()){
if(!player.isFlying() &&
!player.isSleeping() &&
!player.isDead() &&
!player.isInWater() &&
!player.isInvisible()) {
List<Block> leavesBlocks = LeavesUtil.getSomeLeaves(player.getLocation(), 10);
if (leavesBlocks == null) return;
for (Block block : leavesBlocks) {
Location spawnLocation = block.getLocation().add(0, Leaf.FALL_SPEED, 0);
if(!spawnLocation.getBlock().getType().isSolid()){
Leaf.createLeaf(spawnLocation);
}
}
}
}
}
}, 20L, 40L);
getScheduler().runTaskTimer(new UniversalRunnable() {
@Override
public void run() {
for(TextDisplay leaf : registeredLeaves){
double nextx = SafeRandom.generateDouble();
double nextz = SafeRandom.generateDouble();
Location previousLocation = leaf.getLocation();
Location nextLocation = previousLocation.add(nextx, Leaf.FALL_SPEED, nextz);
if(nextLocation.getBlock().getType().isSolid()){
registeredLeaves.remove(leaf);
leaf.remove();
} else {
leaf.teleport(nextLocation);
}
}
}
}, 1L, 1L);```
(I removed Location#clone)
Make registeredLeaves a LinkedList and call removeIf instead of iterating
oh okay thanks
registeredLeaves.removeIf(leaf -> {
if(isInvalid(leaf)) {
return true;
}
// Do something with valid leaf
return false;
});
oh thanks
I replace is invalid by my condition?
Hummm```java
getScheduler().runTaskTimer(new UniversalRunnable() {
@Override
public void run() {
for (TextDisplay leaf : registeredLeaves) {
double nextx = SafeRandom.generateDouble();
double nextz = SafeRandom.generateDouble();
Location previousLocation = leaf.getLocation();
Location nextLocation = previousLocation.add(nextx, Leaf.FALL_SPEED, nextz);
registeredLeaves.removeIf(leafToRemove -> {
if(nextLocation.getBlock().getType().isSolid()) {
leaf.remove();
return true;
}
// Valid leaf
leaf.teleport(nextLocation);
return false;
});
}
}
}, 1L, 1L);```
thanks, I'm going to try
This doesnt work
removeIf iterates over all leafs
Yeag
okay thanks
Really interesting LinkedList
it seems powerful
Here we go again```java
registeredLeaves.removeIf(leaf -> {
// PDC enregistrer variables nextx et nexty + PDC spécifique pour dire que c'est une feuille, supprimer toutes les feuilles existantes au démarrage du serveur
double nextx = SafeRandom.generateDouble();
double nextz = SafeRandom.generateDouble();
Location previousLocation = leaf.getLocation();
Location nextLocation = previousLocation.add(nextx, Leaf.FALL_SPEED, nextz);
if(nextLocation.getBlock().getType().isSolid()) {
leaf.remove();
return true;
}
// Valid leaf
leaf.teleport(nextLocation);
return false;
});```
it's working! Thanks 😄
I learned a new java skill x)
anyone can give me some advices or ways to improve it? about my plugin code base iam working on? iam gonna screen share if anyone interested :-:
someone told me programming is never ending learning process :0
iam trying to push my self to learn more advanced stuff
like better ways for data handling , data strcuture
etc
read Effective Java book :p
did
nice
I'll also add a code where if the player doesn't see the leaf, then I'll not make it spawn
I could then make more leaves in front of him and getting better performances
not simple to do as you have to account for 1st/3rd person view
oops was reaching out for my phone
how spawn entity in spigot ?
World#spawn
why does my entire os freeze for like half a second, or a quarter, when i click start.cmd for my minecraft server
even my audio freezes XD
The server likes to use as much resources as possible when starting
have you set a max heap size?
How do you do that
the -Xmx flag
its just max heap allocation
I think I've fixed it
Now it doesn't freeze my system anymore
monitor the jar on startup, is it cpu or memory
I've got 32gb of ram
Is it dedodated ram
Make sure to set minimum heap
-Xms6G -Xmx6G
Starting the server like this gives the server all the resources upfront and prevents some other issues with the heap when it starts out less then the max and then needs to increase its allocation
?flags
Aikar's garbage collection flags: https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
He didn't get the reference ;-;
How many dedicated wams do i need to run doom
is there a better way to make something that applies to the player for x amount of time they are ONLINE?
my solution was log the amount of time they have played and check if it's been more than x time since
is that the best way to do it?
How do you log your player time? Do you have a loop that runs every tick or so and increase a counter ?
Can you further elaborate what should happen
let's say I give a "curse" to a player and for x time they try to do cirtain things other things happen
like they can't eat or something
and yeah would I have to have a repeating task that checks if player curses are over?
Are the curse time limited or "numbers of actions" limited?
good idea
Use pdc and store it in the player pdc
1.12.2 😭
No need for external saving of this data
A good reason to update lol. Well just use a yaml file i guess. Should be sufficient.
yeah
Is there a recommended inv gui library out of the many out there
InventoryFramework
That XML looks powerful
https://github.com/Noxcrew/interfaces-kotlin also exists
Is it possible to change the required level to receive enchantments from the enchantment table for a specific player by lowering it, for example, from level 30 to 15?
I already wouldn't use it because it calls itself a framework
There is a Enchantprepareevent or smth maybe you can have a look at that
Seems like a you issue
the cpu is going to 107%/100%, just wanted to ask why is the cpu load so much and what can i do to reduce it?
100% isnt really much, depends what cpu the server is using
If you want to find out which part of your server draws the most resources then i would recommend profiling with spark.
And make sure your CPU is utilized by the MC server and not another application. (Check with htop)
they're most likely using a panel like ptero, which would be fully dockerized
doubt they would have other apps running on the container
alr
what about memory
any idea?
how can i make a wall of barrier blocks to make player not enter certain area?
currently i am doing Location blockLocation = playerLocation.clone().add(playerLocation.getDirection()); but idk how to make a wall out of it
What do you know about the geometry of the wall?
if its just a square use a bounding box and iterate the axis
currently i am taking move event and if its in area (rectangle) i am placing a block in front of a player
Do you want to actually place wall blocks or do you want only one player blocked.
Because placing a barrier block will prevent any player from going through.
A hacked client can just walk right through fake blocks
Because they dont exist on the server
so just cancel player move event?
I would just double up. Place barrier blocks and create a smaller area which throws the player back when he tries to enter (as a backup)
Tricky part is deciding when to place the wall.
Do you just send the entire wall to the player?
currently i wanted to place like 9 blocks in front of a player when he tries to enter the area
every time he tries to enter using player move event
since cpus typically have multiple cores these days, 100% means 1 core is being used, but even then this isn't necessarily accurate
you could have 2 cores at 50% and that is still 100%
Ok
Didn't know it's my issue if things are called wrong
If I do that my system freezes for like 250ms when starting up
my entire windows freezes
package net.jamnetwork.fireballfight.listeners;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import static net.jamnetwork.fireballfight.SpigotPlugin.placedBlocks;
public class EntityExplodeListener implements Listener {
@EventHandler
public void onBlockExplode(EntityExplodeEvent event) {
// Iterate through the exploded blocks
for (Block block : event.blockList()) {
// Check if the exploded block's location is in the placedBlocks list
if (!placedBlocks.contains(block.getLocation())) {
// If the block is not in the placedBlocks list, cancel the event to prevent its destruction
event.setCancelled(true);
System.out.println("Cancelled event");
} else
{
// If the block is in the placedBlocks list, remove it from the list
placedBlocks.remove(block.getLocation());
System.out.println("Passed event");
}
}
}
}
the "passed event" is getting printed but the block in game is not getting destroyed
any solutions?
statically importing a field named placedBlocks is crazy 
nah its in the main class of the plugin
now it works i thought that cancelling the event would work but it didnt xD
updated scripts XD
List<Location> removableBlocks = new ArrayList<>();
event.setCancelled(true);
// Iterate through the exploded blocks
for (Block block : event.blockList())
{
// Check if the exploded block's location is in the placedBlocks list
if (placedBlocks.contains(block.getLocation()))
{
placedBlocks.remove(block.getLocation());
removableBlocks.add(block.getLocation());
}
}
for (Location location : removableBlocks)
{
location.getBlock().setType(org.bukkit.Material.AIR);
removableBlocks.remove(location);
}
this will not work, what
it has to throw concurrent modification exception
doesn't matter, you can't remove/add stuff to a list if you're iterating over it like that
(also, you don't have to if the removableBlocks list is within the event method)
how the fuck can that run
and it does not throw a single error ?
am I the one who is wrong here ?
guys pls help, I'm questioning my whole existance over this
whats the problem
nope doesn't throw a single error
@valid burrow u see anything wrong here?
my problem is that the code this guy wrote should be throwing an exception at the last line
show the whole code where are the other lists
only if it actually contains anything
plugin main class
event class
package net.jamnetwork.fireballfight.listeners;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.ArrayList;
import java.util.List;
import static net.jamnetwork.fireballfight.SpigotPlugin.placedBlocks;
public class EntityExplodeListener implements Listener
{
@EventHandler
public void onBlockExplode(EntityExplodeEvent event)
{
List<Location> removableBlocks = new ArrayList<>();
event.setCancelled(true);
// Iterate through the exploded blocks
for (Block block : event.blockList())
{
// Check if the exploded block's location is in the placedBlocks list
if (placedBlocks.contains(block.getLocation()))
{
placedBlocks.remove(block.getLocation());
removableBlocks.add(block.getLocation());
}
}
for (Location location : removableBlocks)
{
location.getBlock().setType(org.bukkit.Material.AIR);
}
}
}
it’s probably empty
what plugin can i use to spawn players at the same place they left at?
-> #help-server
that is default minecraft
oh god
xd
this code wont work and even if it would theres a lot of improvment
dw though we can help you
nah
ok, good, I am not crazy
XD
wdum nah xd
what exactly are u trying to do broski
remove certain blocks from the explosion?
when i not added the removableBlocks.remove(location); it worked and when i added it i didnt tested it
so i tested it with and without it
with it throws error
and without no errors
like the blocks placed by a PLAYER and in SURVIVAL can only be broken or destroyed with an exlosion
can't wait for players to place water and lava to make (cobble)stone
they wont be able to
you should definitely use OOP cause u are making a gamemode
cuz its a fireballfight
well anyways jusr make a list IN THE EVENT CLASS
and on one server
you can use PDC on blocks that are placed by players and add a NamespacedKey...
only one game can run
thats kinda pointless he can just cache
in explosion, enumarate though the list, check PDC, etc..
too complicated for me :D
only for tile entities (unless you use alex's library)
But not needed
plus when game shuts down i will loop thru the list and remove all blocks
dont do it
just make a Arraylist in the evnt class @slate surge
who is alex and yeah PDC works only on tile entities
and make 2 listeners
one for placing
one for explosion
oh and one for manual breaking
no
what if server shuts down or reloads during the game
your lists are in your main class
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
if (event.getPlayer().getGameMode() == GameMode.SURVIVAL)
{
Location location = event.getBlock().getLocation();
placedBlocks.add(location);
}
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event)
{
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
{
return;
}
Location location = event.getBlock().getLocation();
if (!placedBlocks.contains(location))
{
event.setCancelled(true);
placedBlocks.remove(location);
event.getPlayer().sendMessage(getFormattedMessage("&4 You can only break blocks placed during the game!"));
}
}```
umm
ok so ig i will move the session based configuartion to a seprate class
just make ur lists of breakable blocks in the event class
and then make it private
and static
i want to access the class thru multiple classes
then make a getter
nah
its not gonna be a public plugin its gonna be only on my server
and nowhere else
and it wont work if its shit coded
it will
or it will be very inefficient
all of your code is possible in like 40 lines in 1 class
thats what i hav to account for
for a starter any code is good DrVosss
the entire plugin 💀
my second plugin is this
yeah but thats no reason to not fix known mistakes
but so it be
yeah that's ok, you'll learn through mistakes like we all do
its your plugin
whut
the part u showed me yes ofc not an entire gamemode
XD
If you do plan on making more stuff, you better start learning good practices early
It might be hard to re-learn how to do stuff the right way
event class:
placed blocks
3 listeners for modifying everything
public shutdown method to remove all blocks <- called from main on disable
getter for blocks if still necessary
thats it
Hello, If I want to make a system that does a specific thing when you for example kill a certain amount of zombies, am I forced to manage zombie kills for each player in order to do that? (Getting kills, setting kills and saving kills of zombies ofc)
Yes
Well, I think statistics keep track of kills for each mob type, but it’s probably better to manage it yourself
need to use aikar flags
Well sort of, it saves statistics for all mob kills not a specific mob as far as I am aware. I need it only for 1 type and wanted to make sure I am forced to manage them myself because if there's already a way to access them then I don't need to bother managing it
I am
Mob kill statistics exist
weird
do you mean the Statistic enum?
No, I mean the minecraft feature, idk how to access those from the API
Yeah I am talking about an API feature
It's in the api
how do I access it
Yeah you want Player#getStatistic(Statistic, EntityType)
The statistic would be KILL_ENTITY
ooh I didnt know you can provide an entity, tysm :D
hello hello
once is enough
/j
i have a quick question regarding the VaultAPI. basically i found a plugin project that one of my close friends had sent me years ago that had implemented the VaultAPI, and i spent pretty much all night just looking over all the code, reformatting, cleaning it up, etc, but for whatever reason the pom.xml file was missing so I made a new one and tried to implement the API myself however I am getting an error that basically says the 1.7 API isnt found. I cant seem to figure it out on my own whether it be due to exhaustion from staying up, just being dumb, or if it has something to do with the API itself.
Does this statistics reset on player death?
no
Sounds like he didnt have a maven project but you are trying to use it as one.
How do you compile your project?
CraftBukkit is, yes
No statistics are reset on death
I'm using IntelliJ, made sure that I have maven installed and fully setup and everything before I started, it's been a hot minute since I've worked on anything so I just hopped onto this as a sort of refresher.
So what now... do they reset on death or no
that would be unfortunate lol
what do you mean by persistent
Then that's perfect
Alright, now how do you compile the project?
They persist restarts and all that
*He is speaking about Vault v 1.7 not spigot 1.7
too bad it doesn't have PLACED_BLOCK xD If it already has MINE_BLOCK ..
it does im sure, probably used instead of placed ?
I was just running the main package that has all the files in it
and then taking the result out of the target folder
once its generated
Yeah block placement is handled by USE_ITEM
Just save blocks placed in a map :p
Maybe my phrasing was a bit confusing because a single comma changes the whole meaning of the sentence lol. What I meant (and correctly wrote) was "There are no statistics that get reset on death"
"time since last death"
that would "reset" upon death :D
Well it would change not reset :p
If you want to use maven, then you should never manually add any jars to your project.
Every dependency should only be added to your pom.
After that you can only compile with the maven goals and not by "running the project" because this builds artifacts
on default, which ignores the pom.xml
so
- Make sure to not have any dependencies added to the project
- Check if your pom has all dependencies
- Run the maven goals
cleanand thenpackage(IJ has buttons on the top right for that)
I could deal with that by saving it in per-player config but I was looking for a more... convenient solution lol
has anyone seen some packet visualizer like pakkit thats updated for 1.20.4
Statistics are literally that but just already setup for you to use so you don't bother managing it
Yeah so find placed block statistics for me
all about the BLOCK I can find is:
Coll said it gets handled by USE_ITEM
Ohhh
so it's all combined?
drinking, eating, blah blah blah
"USE"
look it up on wiki, but yes
thanks, i thought some of the errors were related to the API but now it seems there are 16 completely unrelated errors that seem to be because the code is just old, so I'll have to figure those out before I'll be able to test it all out
Well that sucks even more XD
I mean, you can only place blocks, you can't eat them
p.getStatistic(Statistic.USE_ITEM, Material.BONE_BLOCK); maybe something like this
I mean I didn't know you could USE blocks, like eat them and stuff... As far as I know, you can PLACE them
Not sure tho, i havent actually used it before iirc
nevermind, a lot more than 16... fml lol
ye, my point is that for blocks, the only thing that will ever increase the stat is placing them
USE is using something from your inventory, and when you place a block you are interacting with it which is also using it
so effectively, it is "BLOCK_PLACE" stat
Hi uhh , i have a problem i use CompletableFeature for my user loading
but its not loaded..
becuase when i try to grab the user :
it tells me null
race condition ?
the loading completes after the PlayerJoinEvent gets fired would be my guess
but idk how completablefeature works
In the AsyncPlayerPreLoginEvent you should not start CompletableFutures.
Load your data blocking there
ok so i should not use CompletableFeature in AsyncPlayerPreLoginEvent
its okay to use CompletableFeature in AsyncPlayerPreLoginEvent but dont use CompletableFuture :p
Lol
didn't understand you??
Re-read your message and his message
Yeah it's fine to use if you just .join it
i removed the CompletableFeature
i think if i join it , there will be more bugs?
and some users won'e be loaded?
what if 30 or 40 player's joining at the same time
would'nt that make it lagging a bit?
The AsyncPlayerPreLoinEvent is async. It doesnt run on the main thread.
You could just Thread.sleep() for a second there and the server wouldnt notice.
On what thread does it run tho
On a separate thread
What about we sleep the netty thread
Not recommended
ah yes, lets disconnect the networking
Pretty sure it runs on the netty thread
On one of the netty threads
mhm
Yeah but using a netty thread... not a good idea... unless if you need to do some weird shit XD Just use the spigots AsyncPlayerPreLoginEvent as it also runs on the same thread as netty so..


Dont want to use the netty thread? Use the netty thread in the AsyncPlayerPreLoginEvent
Proof or didnt happen
Does anyone know of a good tutorial or library for creating packet-based holograms? I’m used to armorstand entities but heard packets are more efficient
Bold to call that a thread pool
lol
not my patch 
actually, Alfie Cleveland <alfeh@me.com> created the initial patch for dat
back to studying I go 
im so close man 😭
sus
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
how do i get these to work ^? im pretty sure once i get these working all the errors will be gone
It's not that hard
Let's start by doing it ourselves so we can learn a little
Import spigot, not spigot-api
You might need to run buildtools
i am dumb struggling to figure this out, i changed it to remove API in the dependancies, cleaned, and packaged, cleaned and compiled, and cleaned and built but no dice
Are you using maven/gradle or are you importing the dependency directly?
maven 🙂
Show me your pom.xml
i cannot verify my spigot account because i dont have access too the email I used and it wont let me use my other account so I cannot post images unfortunately, what would be the best way to send it your way
?paste
Yeah you're importing spigot 1.20.4 and you're trying to use 1.8 nms
yea this code is really old, i attempted to update to "import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;" instead
That's still 1.17
You want 1_20_R3
For craftbukkit
And the rest is obfuscated
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
You can search the mojang equivalent here
Or map your pom.xml to use mojang mappings if you want to write NMS without a hassle
Is anyone familiar with ocelot entity tracker? https://www.spigotmc.org/resources/ocelot.73853/
?nms
No, I've worked with that author before
Yeah that one
how do u get all configuration sections in a FileConfiguration
how do i loop through every key
getKeys
true or false for param
pass each through https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/ConfigurationSection.html#isConfigurationSection(java.lang.String) to see if it's a section
The fact is that I have such a problem custom NMS entity sometimes, if you go far away, appears in a suspended state at the player's position and then disappears when moving somewhere (that is, loading another chunk)? the fact is that I spawn a zombie and replace it with an id for an id npc while the player receives the PacketPlayOutSpawnEntityLiving packet. this way I get an NPC with AI, but if I move away, I sometimes see afterimages of the NPC, it strangely changes its position, maybe I should add handling of the npc unloading event this line java if (controller.isVisible(event.getSource(), getTrackerFor(zombie)) == BooleanResult.TRUE) { that uses Ocelot api did not fix the problem java @EventHandler public void onPlayerChunkLoad(PlayerChunkLoadEvent event) { for (CraftHusk zombie : manager.getZombiesInWorldChunk(event.getSource().getWorld(), event.getX(), event.getZ())) { if (controller.isVisible(event.getSource(), getTrackerFor(zombie)) == BooleanResult.TRUE) { System.out.println("zombie"); FakePlayer fakePlayer; try { fakePlayer = FakePlayer.create("", "", event.getSource().getWorld(), event.getSource().getLocation()); } catch (IOException e) { throw new RuntimeException(e); } event.getManager().showTo(event.getSource(), fakePlayer.getBukkitEntity(), zombie.getEntityId()); } } }
isConfigurationSection isn't static so i'm not sure where to get an instance
code
Are you sending a destroy packet when the chunk is unloaded?
no
FileConfiguration implements ConfigurationSection
As it's a sort of root section
I have the code for this, but the position of the NPC is changing. and the code will work to get static npcs in a chunk
Well, I'm confused about the positions
here's what I'm doing, how do I get the npcs to be destroyed?
import org.bukkit.craftbukkit.v1_20_R3.;
import net.minecraft.server.;
so like this?
how do i fix this? i want my plugin to work on both 1.20.1 and 1.19.4
[15:38:19 ERROR]: [ModernPluginLoadingStrategy] Could not load plugin 'FastNick-1.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.20
at org.bukkit.craftbukkit.v1_19_R3.util.CraftMagicNumbers.checkSupported(CraftMagicNumbers.java:382) ~[paper-1.19.4.jar:git-Paper-550]
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:119) ~[paper-1.19.4.jar:git-Paper-550]
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:35) ~[paper-1.19.4.jar:git-Paper-550]
at io.papermc.paper.plugin.entrypoint.strategy.modern.ModernPluginLoadingStrategy.loadProviders(ModernPluginLoadingStrategy.java:116) ~[paper-1.19.4.jar:git-Paper-550]
at io.papermc.paper.plugin.storage.SimpleProviderStorage.enter(SimpleProviderStorage.java:39) ~[paper-1.19.4.jar:git-Paper-550]
at io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enter(LaunchEntryPointHandler.java:36) ~[paper-1.19.4.jar:git-Paper-550]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.loadPlugins(CraftServer.java:431) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:273) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1104) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-550]
at java.lang.Thread.run(Thread.java:833) ~[?:?]```
Define api-version as 1.19
Develop with 1.19 and set your api version to 1.19
You go study
I am waiting on the printer to print my three paragraphs of the hgb
lol
will that make it work with 1.20 as well?
Yes
Because you are using nms. NMS and Craftbukkit are not compatible for multiple versions.
Thats why Spigot exists in the first place. Its compatible with multiple versions.
the error is happening in this meathod at EntityPlayer watcher = (EntityPlayer) ((CraftPlayer) target).getHandle();
You can only use spigot-api if you want your code to run on multiple versions.
Not net.minecraft.server (nms) imports and no CraftBukkit imports (like CraftPlayer)
oh, is there a way to do the same thing using only spigot-api then?
stop reposting the question
(i just forgot to ping so he probs didnt see it thats all)
valid.
With ProtocolLib probably
how do I get NPCs in an unloaded chunk through manager or tracker(ocelot) in 1.16.5 if an NPC with the same ID as a zombie was spawned to display zombies as an npc with AI?
I can't figure out how to send the destroy packet
I hope you have a manager that keeps track of that. Didnt i recommend you weeks ago to use libraries like citizens and LibsDisguises?
yes, but my manager only tracks static NPCs and does not work on 1.16.5 with moving npcs or rather zombies, but something does not work
i have protocollib, i just dont know how to get the same function as EntityPlayer watcher = (EntityPlayer) ((CraftPlayer) target).getHandle(); without using craftbukkit
I can't get zombies in a chunk
which is unloaded, and accordingly I cannot get the ID of the NPC
my manager: https://pastes.dev/IdTzKrFKc5
can you look at getZombiesInWorldChunk method?
That class is not even close to a manager
what can I do to improve it?
(item.hasItemMeta() && item.getItemMeta().hasDisplayName()) ? item.getItemMeta().getDisplayName() : item.getType().toString().replace("_", " ");
is this the best way to get the name of an item even if it's not named like Oak Planks? or is there a way to get the capitilizations correctly as well?
yo guys. Does anyone know if there’s an easy way to make an old plugin (1.7) usable for higher versions? 1.12 and up
The default name is a translatable component. The client decides how it is named.
I'd personally first of all remove all methods not related to the manager
you have some math operations in there that shouldnt be there
so that's the best way?
or some reflection utils which also shouldnt be there
In many cases a 1.7 plugin should work for 1.12
Oh sorry mistake on my side I meant mod like zip for own mod folder
I still haven't figured out what to add to track of the NPCs and what should I do to make my class called "manager"?
i told you a few messages ago
?
you told me what to delete, not what to add
btw remove the inner class as well
it doesnt make sense there
without it, it cannot correctly compare the coordinates of the chunk
should I also move the hideFrom and showTo methods?
If it is used in another class, you should separate it
i wasnt quite there when the conversation started, what is ur manager managing?
npcs, right?
custom zombies
How can I check if a player can has access to (break blocks, interact, etc) in specific location with PlayerInteractEvent respecting other plugins?
I found Player#breakBlock(boolean) but, it will actually break the block.
I'd make a custom entity class add the show, hide methods into the custom entity (if you want to make them packet based) then you can extend to make a custom zombie and you create a customentitymanager managing whatever you need to manage there
i saw online that i should create a different class for each version i want to support, how would i do that?
Sumeru why do you insist on writing this from scratch? I feel like you simply need more experience with writing spigot plugins
as well as general programming experience to pull this off. You are running against a wall for months now while continuing to
run into similar issues every day. There are libraries you can use which solved the hardest part for you already and let you focus
on writing content instead of building a system like that. Im 99% sure that what im seeing here will not work properly in the end
and will cause massive lags and instabilities for any server that tries to run this code.
Thats why im not answering to your "what can I do to improve it" questions anymore because ive tried giving you the fundamentals
weeks ago.
how can I convert &#FFFFFF into &x&r&r&g&g&b&b ?
Check if the BlockBreakEvent was cancelled with a high listener priority.
I'm trying to check if player has access inside a PlayerInteractEvent event.
The only workaround is to fire the BlockPlaceEvent yourself
Is there a quick maven shade filter I can setup to exclude all other dependency plugin's plugin.yml's but still keep mine? I tried this but it removes my plugin.yml as well:
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>plugin.yml</exclude>
</excludes>
</filter>
create an include but set the artifact as your plugin
You should never shade a dependency which has a plugin.yml
Oh okay, thank you 🙂
its valid to do so, it just depends whether or not the plugin relies on its main class or not
but even if it does, doesn't mean everything in it doesn't work
why not? doesn't it make it easier for the end user if they don't have to download and install another plugin?
not necessarily
especially if the JAR im adding is a marketed as a shadable API?
some plugins are not designed to run without their main class lol
In >95% of cases you will make the plugin you are shading completely useless
not sure if its that great, I mean most of the time the plugin instance being passed in plugins doesn't need to be specific to which plugin
wouldn't shading a plugin cause issues since you're loading the plugin twice if there's 2 shaded plugins?
since they are not making use of plugin specific things
This is the plugin im shading: https://www.spigotmc.org/resources/decentholograms-1-8-1-20-4-papi-support-no-dependencies.96927/
Does it not imply that I'm able to do this?
this only happens if its main class is invoked
ah
Probably more like 98% honestly. I cant imagine a single plugin which works without their onEnable
you can add it as a provided dependency
But in that case you still have to have the plugin JAR installed on the server right?
Yeah this will 100% break
I probably wouldn't say that much, as I said, most of the DI isn't specific to the plugin itself just that it needs a plugin instance. Unless it does a lot in its main class, you can easily work around the main class issue
Yeah idk why it says that
better than causing issues in the future
If your dependency is another plugin, then the user has to download and install that plugin
lol ok thanks, this is what confused me
Hi, I have a question with protocollib. So i search a way to force player to dl a texture pack with a custom prompt (for now i found only this to do what I need). I found a packet named "SEND_RESOURCE_PACK" with no infomation on the wiki.vg and on internet. Did you have information on this packet ???
ye ok but when i want to use this packet i can't
A similar packet can be sent during configuration stage:
https://wiki.vg/Protocol#Add_Resource_Pack_.28configuration.29
Why not?
Why do you want to use a packet in the first place?
Spigot has an API for this
i just can't. my IDE don't show me this packet and when i decopile protocollib i found another packet
what game version is CraftBukkit v1_20_R1 for? like 1.20, 1.20.1, 1.20.2, what
for custom promt to ?
im trying this but i cant seem to get the right craftplayer for 1.19.
this doesnt work:
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
the only one that does is for version 1.20
so how do i replace a CraftPlayer with the spigot way of doing it?
Spigot has no API for intercepting packets. You need to use ProtocolLib for that.
This method looks really ugly.
What should I do to make it look more clean?
private List<String> getStrings(DangerUpdateEvent event, ItemMeta m) {
final List<String> lore = new ArrayList<>(m.getLore() != null ? m.getLore() : List.of());
if(m.getLore() == null) {
lore.add(0, "Dangerous Item! Danger level: " + event.getNewDanger());
} else {
if (m.getLore().get(0).contains("Dangerous Item!")) {
lore.set(0, "Dangerous Item! Danger level: " + event.getNewDanger());
} else {
lore.add(0, "Dangerous Item! Danger level: " + event.getNewDanger());
}
}
return lore;
}
use guard clauses
invert if statements and return instead of using else
To be clear, Intellij automatically generated that method because it was along the lines of 'extract thing from long surrounding method'
im pretty sure intellij doesnt change the method and just extracts it
alright
I know what you mean but how can i apply it in that method
is this good?
private List<String> getStrings(DangerUpdateEvent event, ItemMeta m) {
final List<String> lore = new ArrayList<>(m.getLore() != null ? m.getLore() : List.of());
if (m.getLore() != null) {
if (!m.getLore().get(0).contains("Dangerous Item!") && !m.getLore().get(0).contains("\uD83D\uDDE1")) {
lore.add(0, "\uD83D\uDDE1 " + event.getNewDanger());
return lore;
}
lore.set(0, "\uD83D\uDDE1 " + event.getNewDanger());
return lore;
}
lore.add(0, "\uD83D\uDDE1 " + event.getNewDanger());
return lore;
}
(I refactored the string to a simpler one)
For readability rename m to meta, that's my two cents
If only one could store information in a form that wasn't lore on items 
Valid
Besides that, it's good?
guard clauses
I'd probably need more context and try to do something else because it does kinda look ugly I agree
But I'll leave that to somebody else
and you probably want pdc
Wait true though
pdc?
Not good for storing data
?pdc
?pdc
dont compare strings, use pdc
And especially don't compare inventories by titles btw lol
I already use it
Why do you check for info with lore then
"i", "m", "j" PLEASE don't do that
I feel like I'm reading decompiled code
Invert this statement
if (m != null) {
// do
}
Into this
if (m == null) {
return;
}
// do
You'll have less intended code if you use these guard clauses in your code and it'll become more readable
it is a code style really
https://www.youtube.com/watch?v=CFRhGnuXG-4&pp=ygUgd2h5IHlvdSBzaG91bGRuJ3QgbmVzdCB5b3VyIGNvZGU%3D Cool video on this topic
I'm a Never Nester and you should too.
Access to code examples, discord, song names and more at https://www.patreon.com/codeaesthetic
Correction: At 2:20 the inversion should be "less than or equal", not "less than"
Is it a code style to not have 10 levels of indentation?
I mean kinda yes you're right but like
E.g. at my school I am kinda banned from using break, continue and return unless there is no other way out. So you generally get a stupid amount of useless helper vars and stuff
Wtf
Mind you that most of my peers haven't programmed a lot of java. Hell, they wouldn't even know that hashmaps exist
That's on them lol
Yeah, but by extension teachers won't be able to understand more advanced programming paradigms because a person programming java in their free time for more than a year is a once in a lifetime event
How can i show a number like this: 3b, instead of the whole number?
Why wouldn't the teacher teach those who are not versed in Java yet
And be the experienced ones be
Integer.toHexString or something
but the number could be higher than integer limit
Though when there are no style rules that apply I do use continue, break and return rather frequently; but I wouldn't discourage from people using nesting.
More often than not, nesting is not a problem. These days we do not write code on paper, nor print it out on paper. With IDEs being able to scroll (I surmise that eclipse is even able of automatically scrolling), there really isn't a readability concern outside of reading github code or screenshots - but with code being generally a "write once, read never" affair, fanatic style guidelines are not necessarily a requirement.
nvm just Double.toHexString
i'll try that
What is your "number" defined as?
double
That exists?
it does
write once, read never
Sorry but I have to disagree with this mindset in regards of any maintained code.
You are right in the manner that IDEs do a lot of heavylifting for us, they allow us to see the start/end of a block, thus mitigating the problem of nesting for the most part
The only maintained code I really write are APIs, where there are more stringent rules - yes.
It is shown like this xd
But I also like reading my code with eyes, sometimes not using a mouse or anything
Double.toHexString didn't work
And when there's zero, one or, well, two indents in a function, it is much easier to read than if it is 10
Oh, you didn't want hexadecimal strings
Should've specified it a bit further.
But no, there is no method that does it in java ready-made
I can do it checking the value I guess
You'll probably end up using a method such as
public static String formatNumber(int number) {
if (number < 1000) {
return String.valueOf(number);
}
int exp = (int) (Math.log(number) / Math.log(1000));
char unit = "kMBT".charAt(exp - 1);
return String.format("%.2f%c", number / Math.pow(1000, exp), unit);
}
(though this one is for ints [but easily portable to doubles] and not really efficent [e.g. constants could be cached], but at least it was an example I had easily at hand)
Hi i need help with some Date and TimeUtils :L
That's a cool solution, I'd probably just do something like stringify and see the length
But this is more fancy (and probably faster :D)
when i claim the pacakge it should say :
24 hour , 59m .. and go down :
Does anyone know how I can make older mods work for newer versions?
Try getMapList("nether_effects")
you'd need to cast to int beforehand though
And work from there
or long - whichever applies best
Yep
so, what is the query?
Rewrite them for newer versions
like that?
Oh I See, nothing else I can do?
is there any plugin that add dinosorus and dragons like rlcraft ???/
I think you're in the wrong channel but yes MythicMobs and ModelEngine4 with Oraxen
noooo this is development channel . so i ask here ... if there isn't any plugin ... i will create one
Block#setType(Material)
ok
i can show you the code i have rn .
getTime is : enum for diffrent types
the one i have is daily , so it should be 24h
what's the difference between getX and getBlockX?
I suggest you just run getMapList("nether_effects") and print the results (do the same with getConfigurationSection(..)) just to see what you get when running these and to know how to work with them
getX is not necessarily a whole number, e.g. 42.2348
that works
ah
getBlockX is a whole number specifically denoting the X of the block
this is the time i get :
and what is the problem here? Same as last time?
yes the time is incorrect , and it dose not decrease
how do i make intellij not generate .iml files?
Does it at least decrease each time you refresh the view? And how incorrect is it?
no it does not do that , i was thinking about making a runnable for all online / offline players and it will decrease 1 second from it ..
but that's bad
I think you should save the timestamp of then the time should end and compare against it instead of saving its duration
If I understand your problem correctly
The only cool thing ive seen so far from v22 is JEP447
The rest is meh
is there a template for docs for ur plugin? (not javadocs)
like advancedenchantments' docs
AE doesn't use javadocs I think
they use gitbooks
gitbooks?
yes
the idea is that you write docs under another doc system like Sphinx
look at https://optifine.rtfd.io
I usually go for just-the-docs
this is written in rST for Sphinx
yes
then what did the person that made the docs that ill read to make the docs read
For just-the-docs you just have to write markdown.
Sphinx is built with python iirc
how do i even setup one before doing anything
https://just-the-docs.github.io/just-the-docs/
Read the getting started section
Just the Docs is a responsive Jekyll theme with built-in search that is easily customizable and hosted on GitHub Pages.
👍
Its auto hosted on github
forever?
i dont think i need coding
im legit just building it
clicking stuff
oh god do i really have to write out the entire syntax im using
this is gonna be pain
what's your syntax?
whats the best version to develop for spigot atm?
Latest maybe
1.20.4
latest ideally
1.20.4 is the best
1.8.9 community rn:
1.8.9 should be dead
hate it
can't even listen to PacketType.Play.Server.CHAT to get messages from a player before sending it to others
hypixel laughing in 40k players rn
it's just broken asf
... events?
?
nevermind
They dont really use spigot and they have a ton of developers writing custom software for them.
Hypixel is not an argument for 1.8
Parts of hypixel run on 1.19 iirc
wait what?
it's an amalgamation
Well yeah
Was it spigot at the time?
a heavily modified fork of spigot
They probably have rewritten minecraft already
But it's been modified so much it's barely spigot anymore
Its unrecognizable at this point
I think /about used to say it.
hypixel gonna migrate to 1.20 anyways pretty sure, at least skyblock will
no but really, does anyway have any idea how I would do that?
packetevents may be helpful
https://github.com/retrooper/packetevents-example/blob/2.0/npc-tracker/src/main/java/main/PacketEventsPacketListener.java you can do stuff like this
Does the event not fire before its sent to others
I don't think there is a big difference between what I am trying to do with protocollib and packetevents lib
What are you trying to do?
so, when a player texts something to a chat, it's checked and if the message is not appropriate it's not shown to other players who marked some words they don't want to see in the chat
AsyncPlayerChatEvent
Sounds like you should just use the chat event
ah yes I used it before, forgot to switch
tbh does not make any difference
a lot simpler
doesn't work for me if there is installed a chat plugin like essentials chat
does this only save config.yml?
yep
how do i save messages.yml as well?
pretty sure theres a save method
saveResource
yea, this is what I get when I try the code above
The packet doesnt contain any String fileds
is this plib
I'm unsure why you're using a packet listener for this at all
The chat event's recipients list is mutable. You can remove recipients
You may completely destroy chat signing if that's the case, but I can't imagine you care much if you're hiding chat from specific users anyways
what does the replace true do?
if it should replace the current file
It will always overwrite the existing file on disk, yes
It replaces when its true
so if a player makes a change it wont let them?
Pretty much
on plugin load , yeah
oh so its gotta be false right?
It will copy whatever values you have set in your plugin's binary
usually yeah
each user has his own list of words he does not want to see in the chat, so I actually have to account for all of them
Yeah, that's fine. You can still adjust the recipients list
in my case (very inefficient) i just cancel the event and broadcast the message to the players that can see it
how do i get the value of this from my messages.yml file?
get()
Can someone tell me why this doesn't work in spigot 1.8.8?
String actionBarMessage = ChatColor.RED + "" + currentHealth + "/" + maxHealth;
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(actionBarMessage));
}```
?1.8
Too old! (Click the link to get the exact time)
?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.
Uhhh how does hypixel do it then?
It has an actionbar. Show us more code
Don't think so
that would make sense then
Uh I can't send my entire code.... I don't have discord nitro
?paste
And I can't post files either
We're having a problem on our server where we take more damage when specificaly falling in lava with armor on. And if we die, we keep all items but lose our levels. We do not have keep inventory on, and it's the only circumstance where it happens. We notice that the HP drains quickly instead of doing tick damage. And it's only when being in lava not on fire. All armor does the same. Does anyone know a fix or have anyone experianced something similar?
unless youre making a plugin that has this problem
Some plugin does that
how can i do the same thing for messages.yml?
custom config?
yeah
That's my code
You should update the health display when the player takes damage or heals. That would be more efficient.
Please try this plugin without any other plugins installed. Some plugins spam the actionbar.
I don't have any other plugins
ah, didn't know this
thanks, you saved my day
This is my own one that I'm making and I kind of need to use the actionbar
then try what they said
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
you used two arguments
for a one argument function
please learn how to debug error mesages
I'm used to making forge mods 💀
https://helpch.at/docs/1.8.8/org/bukkit/entity/Player.Spigot.html#sendMessage(net.md_5.bungee.api.chat.BaseComponent)
not support actionbar, that's all
likely not through the API
Working with software thats almost a decade old is masochistic
i dont get why ppl still use that
Is 1.20.4 easier to work with?
yes
alrighty
and supported
and you can make plugins for 1.8.8 and they can also work fine
Undecided if this is increases readability or not. (Instead of having condition || condition || condition)
doesn't mean you'll get much help around a decade old version
what the hell is that symbol
Bitwise OR?
idt that increases readability
Permission bitflags
just adds complexity
i understand what its doing from the names
It's not a decade old YET
yet
Too old! (Click the link to get the exact time)
?1.8
Too old! (Click the link to get the exact time)
ah
?1,,,8
¿1.8
I will send all of you to the shadow realm
I literally copy and pasted my code from 1.8.8 that didn't work and now in 1.20.4 it works 💀
Are you german?
why does this matter
Just asking lol
Who telleth thyself this fib?
Bro your username is literally floGESTANKBRATWURST
Ah...
right
German to the max
question is: whos more german? me or smile
Well.. my cover is blown. Time to exile into argentina.
erm what
Fr
Wouldn't be surprised if half the discord would be german XD
Dont fr me
im old and grumpy about this chinese spy app lingo
lmaoo
Awww, you want a Maultasche or Bratwurst with Ketchup to calm down?
do you want a currywurst?
Döner?
How old? 🤔
rad and me just putting a whole feast together
real
29 
old
That isn't old smh
At what point does iterating over all placeholders hurt perfomance?
am i allowed to say "boah alter" now?
Only one of us can be true and I know what I'd be arguing for
i know its just a java question but how do i access this is another class? sorry for the basic question
static
And another appears. Now we are already 3
:(
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
i tried that
dependency injection is better than static
Placeholders should have a unique symbol to determine their content.
Example:
#placeholder#
After that you parse all placeholders in a text. In this case the result would be placeholder.
This content can then be used for a hash lookup.
https://imgur.com/a/cyACWNK what could be the reason for this result, as can be seen in the screenshot, the chunk in which the entity was spawned at certain coordinates was not loaded at the start of the plugin, but everything works fine when I call through the command
Thanks, one question do you know what O(?) means and some numbers? I heard hashmaps are fast because some O formula
Smile is now writing an essay on big O notation
im scared
The big O notation is used to describe time complexity of algorithms and data structures.
Its not a total description about how long something takes, but how well it scales with n (the number of elements).
For example a .contains() check on an ArrayList is O(n)
Meaning if
n = 1 -> 2ms
then
n = 20 -> 40ms
n = 100 -> 200ms
and so on.
So the time linearly scales with the number of elements in the list.
Hash structures usually have an average of O(1) meaning constant time.
n = 1 -> 2ms
n = 20 -> 2ms
n = 100 -> 2ms
This means it doesnt matter how many elements you have in the structure.
What Big O does this have
Thanks, so hashmaps are extremely fast
jesus reflection looks painful
as I understand it, is it a bad idea to load the chunk manually? maybe should create a scheduler to give the chunk time to load, or that's not the point
Cuz it is lol
https://www.spigotmc.org/threads/guide-beginners-guide-on-improving-your-codes-performance.396161/
In this (quite old) guide i tackle the most common collections and their time complexity
Doesn't increase readability and seems unnecessary in this specific situation, but can be extremely convenient as a boolean-equivalent to += when working with a for loop
Came to the same conclusion
If I ban a player and they try to log in, will AsyncPreLoginEvent or whatever it was called still fire?
probably does, as that event gets called before ban validaiton AFAIK
But where is remove for sets :c
You could quickly test it on your own server
You should ban yourself, now!
i love https://tryitands.ee
I always have a server running on my phone, as well as IJ and mc java
imagine not
🤷
by learning c
C minecraft server when
google a repo
I think you should write a minecraft server implementation using nothing but Unsafe because yes
There is a C++ impl out there
that doesnt even make sense
bash mc server is better
Ikr

