#help-development
1 messages · Page 232 of 1
wahat
yeah there is
what api version do you have
like dependency
because where im looking its not deprecated
and exists
im using 1.8
declaration: package: org.bukkit.inventory, class: ItemStack
this is 1.19.2 javadocs
1.8 materials are different @pine island
thats not how it works
the material is the same the durability per item stack dictates if it is a gapple or a god apple
love how they are looking at itemstack, and then trying using a method from one thing to another as if like they should because they said so
lmao
i realised it.
what if i check if its Enchanted would that do it-?
look
// create items
ItemStack goldenApple = new ItemStack(Material.GOLDEN_APPLE, /* amount */ 1,
/* data value (durability) */ 0);
ItemStack enchGoldenApple = new ItemStack(Material.GOLDEN_APPLE, /* amount */ 1,
/* data value (durability) */ 1);
// to check if its a god apple
if (item.getType() == Material.GOLDEN_APPLE && item.getDurability() == 1) {
}
no bruh
You’ll get used to the snarky comments
https://github.com/CanaryModTeam/CanaryLib/blob/master/src/main/java/net/canarymod/api/inventory/ItemType.java is a brilliant example of why Bukkit's old Material API is insufficent
i liked the durability values system tho
Bukkit only enumerates the first integer, but not the second (which is the data value (durability))
easy to change shit like wool colors
Well to group multiple items we have Tags
true
but no easy way to randomize a color of wool
or can you get a collection of materials under a certain tag
And to change colors you'll only copy & paste your monolithic class with the goal of doing exactly that (https://github.com/Geolykt/EnchantmentsPlus/blob/4xx/src/main/java/de/geolykt/enchantments_plus/util/ColUtil.java being an example for such a class)
random number generator?
in 1.19.2 you cant just provide a 0-15 number as a color
each color of each block is a different id
so Material
wish Wicked Ways was mixed better the vocals are quiet but its so good
whats the enchantment name for mending?
yeah
mending i think
Mending
lmao
couldnt find it
I donno, seems pretty 1.9+-only to me
oh yeah
you can implement it yourself
event when you receive experience
add durability
if it is a damagable
Adding new enchantments is pain
no thank you
true
Although adding mending is relatively easier thanks to one not having to mess with the enchantment table, but the anvil still exists soooo - still big pain
I'm just talking about raw implementation work - not the enchantments themselves; anvils and plugin interop is rather cumbersome
Hell, I have an entire ASM transformer dedicated for slimefun interop
anyway to get past this? (other than changing the items meta)
addUnsafeEnch
thank you for giving this idea, makes my life sm easier
mans stalking me
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
for (Player p : Bukkit.getOnlinePlayers()) {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_DEATH, SoundCategory.AMBIENT, 2f, 1f);
}
}, 0, 1);
``` :)
im thinking random block breaks whilst theyre mining or regenerating blocks
packet cancelling
random noises
I am trying to make a plugin that spawns custom entities with nms but when I try to set the custom name, I need a weird object... does anyone know how I can do this?
piglinBrute.setCustomName(what);
what is it, hover on the function and check what are the parameters
Mojmaps refer to text literal components as Component.literal("The name")
There are some added builder, formatting, etc. methods
lol no i looked up gui
thanks
I am trying to spawn custom entities and I get this error when I use this code. How can I do this differently to make it work?
How would I make a player walk through a block (if possible 2 blocks high so it's the player's size). Maybe it is possible to convert the block to falling sand but with a texture idk? Or how would I check if the player is touching a certain block so I teleport it on the other side?
How can i destroy an item after its done getting renamed in an anvil
public class anvil implements Listener {
@EventHandler
public void renameCheck(InventoryEvent event) {
//get result of Anvil
InventoryType inventoryType = event.getInventory().getType();
if(inventoryType == InventoryType.ANVIL) {
String[] customItems = new String[]
{
"~Angel's Apple~",
"~Movement Rod"
};
String ItemName = event.getInventory().getItem(2).getItemMeta().getDisplayName();
if(contains(customItems, ItemName)) {
//destroy the item they just made
}
}
}
public boolean contains(String[] arr, String targetValue) {
for(String s: arr){
if(s.equals(targetValue))
return true;
}
return false;
}
}
Me exporting with maven be like: [3,24] package javax.annotation does not exist
I swear I am gonna fuck up Eclipse or either Maven
why do people still use eclipse instead of intellij
idk
Idk
Eclipse is probably more reliable for starters lmao
Ur using it
Not true
but I already wanna f*ck it up
What am I even supposed to add, to just prevent that bug I posted above? xd
Eclipse is known to do random shit for no reason
Yes. I remember getting errors on code, that wasn't even error before.
Add intellij to your program list lol
like...
I got an error on player.setGameMode(GameMode.CREATIVE);
while it was on correct place, and correct used
xd
Clearly incorrect
why didn't you install intellij
Psh
bruh its over midnight
I got Bukkit and Spigot related errors as well before xd
I fixed them by adding the repo and deps into the POM
now an javax.annoation is the problem because of support for PAPI lmao
it can't find @Nullable lol
and now it cannot find a simple dot
WHY CAN'T A DOT BE FOUND?!
FFUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU-
How can I list ALL the contents in a config StringList. (For example:)
Test:
test1
test2
^ I want it to list "test1" and "test2" but the size of the list would be random as players can add items to the list.
You can do lists in the config
.getList()
Test:
- "item"
- "otheritem"
No, it is a colon.
And it's config.getStringList()
Test:
test2:
Is it for a list?
either works
Or do you want test and test 2 to also have config stuff
You want getKeys(false)
It will get you the keys of all children under that parent
Yes but how would I print it to the player as "home1, home2"
Y- You have it. getKeys()
Yes well its config.getConfigurationSection(homes.players).getKeys(false)
Okay thanks.
I'd figured that was self explanatory, but yeah
I would personally avoid handling home saves in a YAML file because that file may get large fast. Generally the better alternative is to make use of some database schema
I'm getting this error when I run this code for damage event. Anyone know what I can do differently to fix this?
If you want to handle an EntityDamageByEntityEvent, you should listen for an EntityDamageByEntityEvent, not an EntityDamageEvent
ah ok
thanks, this worked
If you have múltiple checks of event cause I would use a switch which is faster than having múltiple if-else
how do i put player in a different world?
if i have a world called "one" and a world called "two"
how would i switch the player between the two
teleport them?
what
player.teleport(Location)
i'm confused as to what you're asking
what do you mean put them in a different world file?
and why would you even do that?
im trying to load a different world for bedwars
one world is tghe lobby
when i run a command
it teleports me / loads a different world file
right...
but player data is stored in the main world anyways which is the lobby
^ i think, not 100% sure
Only of you store all players. But you generally end up with a bunch of small files which is equally bad since most harddrives are not formatted for small block sectors
i have a world creation thingy that creates worlds.
i just dont know how to make the player load it
so basically i have a map, and theirs a command that copies the map, but after that, the player dosent load it
and deleating the original world folder and running the server will just generate a new one
every single time the copied world name is different
Is there any way to pause the player's login while we load their data?
Use prelogin event for that
Ah yeah perfect
I need to make a command that will have possibly a few thousand lines of code, whats the best way to do this?
um why???
use other classes
what does your command do?
So a main command class that calls other classes?
Ill get the lsit
pretty much just controls the game manager is all, such as forcing maps and a team selector
Have your main command class just parse the subcommand
And have a class for each subcommand
And an interface called subcommand
ok ty!
They are going to get you a list 🙃
What happens if you try to get something from the config which doesnt exist?
null
Try it and see? Or check the docs
😱
why spend the time testing it when I can just ask
Or you can check the docs which takes even less time
not true
it required 3. My response was almost instant
Required 3? Buttons?
nice voice
what if he uses Eclipse or Netbeans or maybe he is on crack like me and uses VSCODE

i forgot the hotkey for doing that on vscode I use that feature so little I usually just try and see even tho its less efficent
It is bold of you to assume everyone has such fancy tools
i think eclipse has it
you'd have to look it up
if it doesn't get a proper IDE lol
why are you making stuff in npp lmao
All I needed for this small proj was a text editor
?jd-s also exists and is just as easy to traverse
idk man, there is loads of text. Can you make another video to show everyone?
Someone is obviously too lazy to work a computer. Funny they rather use something not suited for the task but the crossing point for them is reading docs or sesrching lol
Umm
Weird question, I'm learning Java/Plugin development, does anyone know a plugin idea that I could make for learning purposes? I wan't to make a plugin to improve my skills but I can't think of any ideas to make, that isn't just simple single event plugins
custom items
theres different ways you approach it depending on your knowledge, so once you do it once, you can come back and do it again with improved knowledege
oh good idea! important thing to learn too;
probably some of the most fun plugins to make aswell
I am creating a command with a TON of different possibility’s, do I call a method for the different subcommands or do I create a new object to run the code?
Not sure on how Java handles memory leaks and performance
depends on the context
what is the command for exactly
is each subcommand related
or completely different
Completely different features, it handles my gsme manager
yeah probably different classes for each subcommand
do you have any links to videos/articles for this? I'm only finding people suggesting other plugins and not actual coding of one
using a command framework will make your life much easier
nah i dont have any sorry
alright no worries ill keep looking, thanks anyway!
Would I create a new instance so new SetClass or SetClass.start(sender, args)
Which would you recommend
check out ACF
Aikar Command Framework
from the guy who makes paper
it's great
Ok tyvm
didnt he step back from doing tons to paper
no clue
yeah he did
Java doesn't handle memory leaks. Otherwise they wouldn't be memory leaks
Pink color gone
😢
;o it's back
discord mobile be like:
Nearly missed my train lmao
Oh you meant mine? Or yours?
mobile discord does that a lot
Its your discord. My nitro is on autopay lmao
If mine goes away it means magically I can't afford $10
im gonna say that would only happen if someone steals your identity
what else do you expect
You don't have a ticket?
I do
They normally don't check if they Cant barely move thro the People standing right
Too much People in here
Man doing one wagon in ten minutes
That's how it be. Show ticket or leave lol
Europe moment?
there are no real memory leaks in java. at least not what you would understand under a memory leak.
In Europe it's not something we like
We call them kanary
And there are entire Facebook groups to warn people about ticket checking
It's not that we are not honest, these people are generally just very rude
;/
And charge for no reason
Trains aren't that expensive for students anyway
And all other forms
Yeah same here
Oh wait no
Uni student iirc get free (I might be wrong) but high schoolers get 50% off
Uni students get a lot of benefits
Cheaper food in some bars
Etc etc
germany be like: hey, you dont have a ticket? pay 60€ and leave. idc how you get home.
meanwhile drunk, drugged or homeless people without a ticket: have a great day
Or just argue the entire way
At least you will get to the place you want
nah then they drag you out of the bus continue there
they only stay for one ride
police wont say anything
"you should've simply paid your ticket"
and if you defend yourself you are the one guilty
Well you record entire situation, report the guard and demand money for the damages
Ez fix
Well they violated your rights
They have the same rights as normal citizen
Unless you are a danger
Then they can use force as defense
Oh shit it's help development
💀
Hey guys how to center a div
impossible
how do you completely disable the join message
just set it to null?
oh yeah
Does anyone know an effective way to create a visible out-line of a cube, without the use of particles?
Making an area-trigger plugin, and initially I planned on using particles to out-line to selected area before "confirming" the trigger area, although I don't think this will be very server friendly in the bigger areas?
You can use structure block outlines for mid sized areas
never heard of them, will look them up now!
the entity or the bullets they fire?
Use falling blocks to outline 
You can make players see fake blocks?
Send block change
I have similar question.... how do I spawn block with nms please? 😄
you dont
Maybe armorstand?
falling block then
okay I'll look it up thanks 😄
hi , i have a problem i dont know why for some reason only location value is not being saved in json file ..
other values , like boolean , strings , etc is saved once i stop the server , but not the location
[i have method to save the file once i stop the server]
no errors or anything .. it just not save it in json file [Location] .. ideas?
yeah, my idea would be that it doesnt save it to the json file
code?
we need some code
other values is saved correctly without any problem
one moment , iam opening intellij idea .
its not giving me any errors while saving :L
so idk what's wrong why its not saving ,-,
ok cool
Simple Location is just a util class , i tried with normal Location and its the same .
other values , are working and saving without any problem , like for example chance :
all these values are saved and working
Does SimpleLocation implement ConfigurationSerializable?
but this one is not ..
let me check
Or wait are you using bukkits config stuff or something else?
its a bit complex
Gson?
So well, in this case you probably wanna register an implementation of TypeAdapter<SimpleLocation> to your gson instance
alr
PreparedStatement ps2 = plugin.sql.connection().prepareStatement("INSERT IGNORE INTO cuud (PLAYER, UUID, MUTED, BANNED, REASON, BY, SERVER, MVP, PREMIUM) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); - in what way is this wrong?
near 'BY, SERVER, MVP, PREMIUM) VALUES ('NeonOwlGery', 'uuid' at line 1
ah I got it then
lmao
weird. the plugin connects to MySQL but still throws an error that no operation allowed after connection close
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Most likely closing the connection somewhere, which means you can't do operations
but where?
Only area I close it is when the plugin gets disabled
howelse can it be disabled? xd
Well, given we have no code or anything else we can't tell you
This is a method PAPI can call upon requesting the placeholder to check it:
public String getPremium(UUID uuid) {
try {
PreparedStatement ps = plugin.sql.connection().prepareStatement("SELECT * FROM `users` WHERE `UUID` = ?");
ps.setString(1, uuid.toString());
ResultSet rs = ps.executeQuery();
if (rs.next()) {
if (rs.getString("PREMIUM").equals("TRUE")) {
return "§aVan";
} else {
return "§cNincs";
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return "§cHiba";
}
it gets errorred saying operation is closed
I love not closing prepared statements
Ahh, try-with-resource resources is the best
if (params.equals("premium")) {
return plugin.sql.getPremium(player.getUniqueId());
}
and this is what PAPI does btw
^^^^ pls try-with-resource
wut
try (PreparedStatement ps = plugin.sql.connection().prepareStatement(...)) {
}
That, it's a wonderful thing. Auto closes it
try (
final PreparedStatement statement = plugin.sql.connection().prepareStatement("...")
) {
}
cool kids put it on a new line
or so I heard
Cool kids don't care what line it's on as long as it works
hmm, true that is what cool kids do
.use {} 😌

Only thing that could be wrong here is something happening to plugin.sql.connection() but without the full source, we cannot tell you what's wrong
using this method throws errors as well
it leads to a variable over Loader (Main)
So the connection is being either closed or severed for some reason
little one I learned to never use any other variable for MySQL
always use one
in the case
Loader: public MySQL sql = new MySQL(this);
and with di or what I just call it
public Loader plugin;
public MySQL(Loader plugin) {
this.plugin = plugin;
}
thats what I do .-.
also you can do getWarnings() as well
probably are not registering your events
but what does your connection code look like for sql?
I have a feeling that your problem lies in how you are connecting or creating the connection object
I mean your IDE is not smart enough to know that registering the listener means that the method is called
the minecraft development plugin fixes that but marking them as used when annotated etc
Thanks to IntelliJ lol
just wondering why tf did I just switch to that lol
how would intellij now 
public void connect() throws ClassNotFoundException, SQLException {
if (!isConnected()) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + name + "?useSSL=false", user, pass);
Bukkit.getLogger().info("Connected to MySQL");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
it connects
just closes or something? xd
wait it doesnt has plugin.sql
ohshit
this isn't correct
unless you are shading in your own mysql driver
in which case you are going to have problems since spigot also shades the mysql driver
no, but there shouldn't be cj in there
isnt the cj less deprecated?
it should becom.mysql.jdbc.Driver
shading in dependencies in multiple jars wont cause problems right
its just inefficient
it can, just depends
but the mysql driver is different because whatever loads the driver first onto the path, that is the driver that is used for everything
hm
still causes the same error btw
which error is that?
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Your connection is closing
most likely due to incorrect user and password
?paste
You should use a connection pool btw
Rather than one persistent connection
well connection pool isn't going to help with this problem
connection pool can come after this is resolved lol
Well I think part of the issue is just that mysql is closing the inactive connection after a while
private String host = "localhost";
private String port = "3306";
private String name = "database";
private String user = "root";
private String pass = "";
humm
they all correct
even database just renamed lmao
@trim creek is it always failing to connect
I can't read what it says
(reupload for privacy reasons lol)
(SELECT DISTINCT User, Host FROM mysql.user ) UNION (SELECT DISTINCT User, Host FROM mysql.db ) UNION (SELECT DISTINCT User, Host FROM mysql.tables_priv ) UNION (SELECT DISTINCT User, Host FROM mysql.columns_priv ) UNION (SELECT DISTINCT User, Host FROM mysql.procs_priv ) ORDER BY User ASC, Host ASC
this is what I was able to copy lol
basically it can't get the users for some reason
I want the bottom portion about the error
bottom code:
(SELECT DISTINCT User, Host FROM mysql.user ) UNION (SELECT DISTINCT User, Host FROM mysql.db ) UNION (SELECT DISTINCT User, Host FROM mysql.tables_priv ) UNION (SELECT DISTINCT User, Host FROM mysql.columns_priv ) UNION (SELECT DISTINCT User, Host FROM mysql.procs_priv ) ORDER BY User ASC, Host ASC
response?
the error message
probably nothing
at the bottom
paste it here or translate what it says
the error message is what will tell me more in what is wrong
Érvénytelen kucslfájl a táblához: db
all this reads
"invalid keyfile for table: db"
I guess I should install a newer version of XAMPP xD
I have been using this since 2019 XD
your temp directory is either not setup correctly for mysql or you ran out of disk space
second cannot be possible
it can depending where temp directory is located
how can I checkthat?
in mysql settings for where ever is designated the spot for temp directory
either it isn't configured, or it ran out of space only two things that will throw that error you are seeing
this doesn't seems right...
max connection at once is 43
but the total connections are 201?!
your settings are probably all out of whack for mysql
probably
max connections should be at 2000
imma try modify what I can
oh poop
shutdown mysql server before you do
that won't disable localhost/phpmyadmin right?
for the time being yes, you can't modify settings properly from phpmyadmin anyways
any settings changed from there are only temporary
wouldn't worry about that for the time being
would just recommend shutting down the mysql server and go appropriately setup the config file for mysql lol
i dont see anything being incorrect
something went wrong with site lmao
not sure why you are worrying about the site...
?paste
# enable-named-pipe uncomment this line
apparently you didn't read the warning below
anyways still looking
if you don't want to use unix sockets
then comment those out
idk what those are
since you are on windows and your plugins don't make use of such, just go ahead and comment those out
I didn't even knew I had plugins installed lol
#socket="C:/xampp/mysql/mysql.sock"
#socket="C:/xampp/mysql/mysql.sock"
I meant the plugin you are making
you are not making it use unix sockets, and I am not entirely sure if mysql implements windows unix sockets yet
since that is relatively new
# bind-address="127.0.0.1" uncomment this since we are telling mysql not to use sockets so we need to tell it an ip to bind to
and yes, mysql does have plugins
or plugins you could install for it, in case you were curious
I never modified the file btw
only this time
for the first time
I was like
"oh well it works and I understand nothing about those, so I won't edit them"
btw months ago users worked well
hmmm
it didn't threw any errors...
POG
it somehow is fixed
gonna add maxconnections as well
change max packet size to 128M
ok
to where I added max conects right?
yes
alright that is all for now, tomorrow if you are here I can help and show you how to fine tune it and change those values to be more optimal. But for now those should work
need to let mysql run for like a few hours before you can fine tune 😛
ideally a day or so
now that is fixed, we can now try and fix your plugin

I do plugins since like... almost 1 and a half year...
but develope server since like 6 years
anyways, if you can keep mysql DB server running for like 24 hours and then I can show you how to fine tune it to be super optimal
so I ain't that good yet :D
and fine tuning should be done every once in a while as things change you know
my mum will not be happy for this.. xd
you see, we have inflation here, and gas and electricity prices are high at the moment
and just "keeping the PC alive overnight" is not that allowed xd
but I will try my best to hide it
Ah ok, well let it run as long as you can then
if you have to shut it down, then shut it down
we can work with whatever it has saved lol
true
anyways, have fun now with your working mysql server 😄
Thank you :D
users still don't work but I already don't mind 😹
the only thing I mind is that the plugin is able to connect to it and it works xd
Can I set this name?
does anyone know why MCP Mapping Viewer doesn't work anymore?
Use screamingsandals
should i set game rules like this?
world.setGameRuleValue("announceAdvancements", "false");
Hi sry but how can i do that if(player.getDisplayName().equals(appolon or lesteur)) {
(appolon is a String and same for lesteur)
thats NMS
I want MCP
They have every mapping available
this is all I can see from them
and I don't think that MCP will be under NMS
ave should be Minecraft
but it can't find it
Mojang nor any other searches
^ also you're searching in mojmaps
I've previously used this line of code to set the message format in chat in the AsyncPlayerChatEvent. However it seems that newer versions of Minecraft causes an "message has been modified by the server" warning to the player next to the message. Is there a way of setting the "format" that won't show that warning?
event.setFormat(player.getDisplayName() + " §7» " + (player.hasPermission("chat.white") ? "§f" : "§7") + msg);
you'd have to use the preview event to set the format
Ah, I see. Thanks!
How would I make a player walk through a block (if possible 2 blocks high so it's the player's size). Maybe it is possible to convert the block to falling sand but with a texture idk? Or how would I check if the player is touching a certain block so I teleport it on the other side?
a falling block can be anything if you change it
but can i change a normal block into a falling block
so i can walk through it
maybe with sendBlockChange
?
ez
./execute if entity @a[x=<xcoord>,y=<ycoord>,z=<zcoord>,distance..1] run <command>
not very good to do in a plugin
That’s not Java though
It is.
Still not code
i dont think you understand what this is
That’s what the server is about
what spigot runs
Lol
Replaying so other can maybe see it
to be fair, a plugin could run the execute command
not suggesting that be the recommended method, but I mean if execute is what you know how to use, then it is a solution, albeit not the most optimal one XD
Hello , i have specfic value in json , i want to save :
is it possible to specify the value ?
bcz its saving everything but not this value .. idk why its really weird ..
How can i create a clickable button witch doesn' t execute a command but a method or something else
?
my current problem is :
all this is editable , and its changed when i restart the server :
but preview location is not updating :
i have been googling for hours xD
maybe...just maybe
it would be more helpful to us if you showed the code
because at this point, we have no idea either and have no clue in how it is being set or attempted to be set
this is how iam saving this json files ,
and it does save all values , expect this one "preview-location"
all thes values are saved , updated when i close the server :
expect this one ..
how about the code where you are parsing the json stuff?
or are you not grabbing and parsing the json?
see attached code
this values :
working just fine , updated when i close the server ..
but not previewlocation
iam just shocked , why it would'nt work ???????? its just weird -.-
cuz it doesnt know how to save locations
Fourteen beat me to it
wouldnt be surprised if it threw an exception too
take it away fourteen, learn them something new
write a typeadapter
that isn't where exceptions happen
dunno what that expose thing is doing anyways
but why other values don't need an adaptder xd?
cuz those are primitives or strings
meh
i have a system for spawning the player :
and it does work just fine
it save the data with no probllems
why adding @Expose if i default gson::toJson would take all the fields anyway?
if you really wanna exclude them, make them transient
throw back to conclure saying
so the solutions before you, is to either make a typeadapter like suggested by fourteenbrush
or turn location into a string
wanted to show mine but my chrome seems to be broken
witch one is better?
most likely fourteenbrushs recommendation as it is more versatile and can be applied elsewhere later on if you need it
what I suggested is just a way to make it work
wouldn't help you necessarily to turn that data back into a location
i know i have everything else working
i have a player object and the player gets offline, what is the return value of player.getName() ?
same name
the player objects retains its properties but player::isOnline returns false
i wouldnt suggest working with invalidated player objects anyhow
i have this OLD code but for some reason
line 53 is throwing npe
maybe show the linenumbers lmao
lmao
xd
return value of countdown::get is null
cuz the entry is not in the map
its not set
and only gets removed in 59
why shouldn't it be
i guess killer.getName() returns something else other than the original
i should have the killerName out of the runnable but its an old code
your run method is technically an inner anonymous class and thus does not have access to the method constructor variables
i just want to know why
it returns the killers name
Killer from the method constructor of void play() is not accessible to your run method
because run is inside the bukkitrunnable anonymous class
do you not know what an anonymous class is?
alright, they are handy, but when it comes to accessing stuff outside of it, they are limited
a class in disguise
your problem is that it isn't able to obtain the reference of killer
the code is so shit i have to fix it i don't even need the hashmap i can just put the int inside the class
so
what should i do
killer.getLocation()
how can i access this
inside the class
i could get rid of the killerName
make a static variable to hold killer above BukkitRunnable or don't use an anonymous class
you could just make a proper class or proper inner class instead
and pass it that way
:c
just make a class that implements runnable, and pass that class object to bukkitrunnable
that looks like an inner class to me
bukkitscheduler where
pass your variable for killer to that runnable class
yeah?
wouldn't make it static
ij
hi , iam not sure if iam doing it write .. :
it could be static, but probably really don't want it to be since you want multiple tasks
so how can i cancel the task inside the runnable
cancel()
you can cancel runnables
bukkitrunnable extends runnable
You can't
A Runnable is a functional interface containing a single run method
so should i extend the bukkitrunnable class
Yeah
^ Do that
thanks
there is another issue
i have a player data thing
i initialize it on join
and destroy it on quit
for each player
ok there is some advancment here :
but somehow the return value of the player data on player damage is null
how i can change it to preview-location xd?
afk
is it possible xd?
why creating two files
create the inner file and if it doesnt exist call file::mkDirs
and file::createNewFile
so it works?
just make a JSONObject?
i want it to be saved to "preview-location"
do your fancy annotation?
mm?
so if i want to make it preview-location i need to do it like this :
right xD?
just put the annotation above ur location field that says how to name it?
u sure u removed the prev json file so it doesnt get written again?
do i really need to do that ..?
iam using the gson builder on allot of diffrent things , won't that break how does it work?
you mean this
when serializing or deserializing a custom class, it checks if a typeadapter is present or otherwise tries to (de)serialize it themselves
i see
Is there a way to play custom playsounds?
you need break;'s probably
How to prevent falling blocks from becoming solids when touching ground
this is what I have java @EventHandler(priority=EventPriority.LOWEST) public void onFallingBlockLand(EntityChangeBlockEvent event) { Entity ent = event.getEntity(); if (event.getEntityType() == EntityType.FALLING_BLOCK) { event.setCancelled(true); } }
but it just makes the block dissapear
Try setting the priority to highest
btw, what java version can I use for 1.19.2+ plugins?
probably wont change anything
yeah it doesn't
@twin venture dont dm send it here
2 Questions: 1. Is there a way to stop that Zombies are dying from the sun? 2. How can I'll add a Zombie a head
this isnt the correct way to compare lore right-?
it isn't
give them fire res?
but comparing lore is already always kind of not good
But they still burning?
welll im comparing it w a string
Well lore comparison usually is for "hey I want to know if this item is my custom item"
which
use PDC instead
https://bukkit.org/threads/stop-zombies-from-burning.105301/ use this and steal inspire ur code
how on earth do i do that
?pdc
🤡 indeed
nbt API 😩
ughhh cant i just compare lore this is sm work for a private plugin
I mean sure
its a list of strings
if you want to know if it contains another specific string
there is the .contains method
use the contains method got it
just don't cry about when you want to change the item lore
and all your legacy items no longer work

its fine ill refactor it i guess 💀
1.8 players just can't figure out how to delete the decimal to get to 1.18
Second question how can I set a Zombie a helmet?
?jd-s
declaration: package: org.bukkit.entity, interface: LivingEntity
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/LivingEntity.html#getEquipment() same way you'd do it for players, but with a living entity
declaration: package: org.bukkit.entity, interface: LivingEntity
Guys, I need a very good anti xray plugin
how do you prevent a players fall damage when teleporting them
right now its still being preserved
I tried doing Player#setVelocity
to all 0's but it didn't do anything
public boolean teleport(Player player) {
final Optional<Location> location = getLocation();
if (location.isPresent() && getCharge() > 0) {
Location loc = location.get().clone();
player.setVelocity(new Vector(0, 0, 0)); // still keeps fall damage
player.teleport(loc);
player.getWorld().playSound(loc, Sound.BLOCK_RESPAWN_ANCHOR_DEPLETE, 1, 1);
setCharge(getCharge() - 1);
return true;
}
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0f, 1.0f);
return false;
}
final String worldName = locationArray[0];
final double x = Double.parseDouble(locationArray[1]);
final double y = Double.parseDouble(locationArray[2]);
final double z = Double.parseDouble(locationArray[3]);
return Optional
.of(new Location(TeleportersAddition.getPlugin().getServer().getWorld(worldName), x, y, z));
Whats even more confusing to me is I'm building the location from cordinates
don't mind the awful code I'm sorry :*(
can't you add the player to a Set before calling teleport()..., then listen to PlayerDamageEvent, cancel it if the player is in the Set, then after teleporting, you remove them from the set again?
in fact you don'T even need a set, you can just use a field
Player currentlyTeleportedPlayer = null;
then set it to some player on teleport, in the event check if the currentlyTeleportedPlayer is null, if not cancel event
then set it to null again
oh thats true I thought you could maybe stop the velocity with the player
is hashset O(n) for checking contains
why not just use a boolean
you can never teleport more than one player at once
only one after the other
the class the teleport method is in a wrapper object
iam using this api , there is a class called SimpleLocation , and SimpleLocationParser
private boolean someoneIsTeleporting = false;
public void teleportSomeone(Player player) {
someoneIsTeleporting = true;
player.teleport(...);
someoneIsTeleporting = false;
}
@EventHandler
public void onDamage(PlayerDamageEvent event) {
if(someoneIsTeleporting) event.setCancelled(true);
}
@river oracle
this should always work
i'd have to use use a hashset since I'm dealing with the object being a wrapper for an itemstack that has no persistent data outside of its PDC
so I can let this object be GC'd
what's wrong with the code I sent? I mean you do call .teleport on a bukkit Player object, right?
why dont you wanna write a typeadapter?
no I have to call this method from my object
i did , it didn't work
I don't see how I could get the boolean working tbh hashset will be easier impl wise
then set it to true in your custom teleport() method
i sent you the 2 classes , i found them on google , and it didn't work
Talking about this class :
HashSet contains is O(1) and ArrayList contains is O(n)
okay maybe I'm not understanding what you mean tbh which is likely I'll send my class setup
how does hashset achieve O(1) contains
I'm interested in the impl
?paste
yeah well I was wrong
one sec
On average, the contains() of HashSet runs in O(1) time. Getting the object's bucket location is a constant time operation. Taking into account possible collisions, the lookup time may rise to log(n) because the internal bucket structure is a TreeMap.
then you werent using it correctly
add it as a typeadapter and let gson take care of it
sec
it wraps a hash map
anyway, TLDR:
contains() in a Set is usually faster while add in a Set is usually slower
It uses a unique key to instantly look up the object
which is best case O(1) if there are no collisions
it performs some math to estimate the bucket the data will be in
i think
but tbh who cares about what's faster? You will never have more than 100 players in your list or set 😄
i care
I wouldnt spend a second thinking about it, I would have just used a Set
true was just curious
that's ofc a valid reason
Depends on the set
bad mindset
that is why I said "usually"
It’s backed by a hashmap
no, it's called "premature optimization" and it's usually wasted time
^
Example on how to use it , will be great !
No point in a lot of premature optimization
nobody cares if your operation took 2ns or 9ns if the server still has 295172285ns leftover in this tick
Write it like an essay
using a table vs a list is not a time consuming thing, its good practice
I would simply think "Do I ever need to keep an order or want to have one element in this more than once?" If yes, Set, if no, List
erm
other way around
obviously
lol
if you can always try to write it to be as fast as possible otherwise changing it later will take more time than if you did it initially
thats what i follow
if you decide to use a map vs a list later you gotta change names and shit
depends. if you simply say it's a Collection<Player>, then all you have to change is new HashSet<>() to new ArrayList<>()
just doing GSON gson = GsonBuilder.newBuilder().registerTypeAdapter(Location.class, new LocationTypeAdapter()).build() or smth
you cant add shit to that though
right
oh
what you cannot do is to insert at certain index or something
yeah, it doesn't have get(0)
but a map is not a collection
HashSet has no index either
that's true, a map is not a collection
i did that .. but now its not working at all ..
but why would they need a map? all they want to know is whether this player needs to get fall damage cancelled
hashset is backed by a map
yeah but it doesnt expose it
and we generalized the conversation to optimization in general
define not working
Yep said that smh
generalized is that a word
you removed the old entry so it gets overwritten?
yeah okay but I was just talking about this case
In this case, it doesn't matter at all whether they use a list or set
Where?
no not if they dont have a ton of players
though if they do it every time someone takes damage
they could ofc also check if it's fall damage before checking the collection
which might be multiple people multiple times per tick
Luckily damage is not playermove
or, as I suggested, simply use a boolean 😄
there is no errors or anything it just it stop working ..
yeah
it can never happen that two players take damage at the exact same time
multiple players can take damage in one tick yeah
unless people run of those weird forks that promise to make the main thread "async"
I mean why would that work on a singlethreaded server
show code
in one tick, yeah, but still it would be like this:
It doesn't matter what he reccomended I ended up going with a hashset anyways lol but yea the boolean would work
Teleport does not cause the fall damage that is done a tick after when it has computed it
- I set the boolean to true
- I teleport a player
- The event gets called
- I check if it's true, then cancel
- I set it to false again
and only now can this happen for another player, the boolean is already false again
this will always work
a tick later means there is enough time for more players to be tped
id use hash set i dont think you can guarentee order and amount
are you sure?
Yeah
nothing changed :
Teleport != damage
even in the same tick
well then the boolean won't work ofc
you cant ensure order
if it would happen the same tick, a boolean would be enough
start tick
Player1 tped
Player2 tped
Player1 takes dmg
Player2 takes dmg
well @river oracle can't you just call player.setFallDistance(0.0F) before calling teleport?
Most likely
yes
then just do that
Or set their velocity to 0
they would still have fall distance
they already tried setting the velocity
Oh i see, been a while
but im pretty sure commands are processed in a different tick phase than world ticks in which fall damage would occur
or item click
whatever
💀 that is smart
I was looking for something like this