#help-development
1 messages · Page 1363 of 1
no space after : on author. And make sure you're not using tabs.
how do i know if im using tabs?
I just built fine using latest buildtools
High light the empty spots if it high lights more then 1 space its good.
its taking forever to clone
not for me
I mean
alright its good i think
How would I generate a multi part structure like a bastion through a plugin
1.15 MiB/s to clone Paper but 6 KiB/s to clone Bukkit?
I highly doubt its an issue with my internet
unless theres some broken thing between me and where the stash is hosted
I just ran build tools in a few minutes. No longer than usual
I get you ran it fine
but I'm more concerned that I can't even clone from the stash
so my question is this: can you try a fresh run in a fresh dir?
Just wondering does anyone know how to disable jumping or sprinting?
yep, sec
Cancel the packet.
Or toggle sprint event
Alright thanks
running now
Np. And I think paper has a jump event.
I'm seeing stuff about adding your own structures, but I want to generate a structure in an existing world
Windows, so it has to download and install git
i dont have to export after every edit, right?
git version 2.30.1.windows.1
Windows uses PortableGit
fair
its cloning now
I have a feeling something is up
#general seems to support that
considering I can't even view the stash via browser
build finished
That was a clean buidl just from my newBuild script. that curl downloads BuildTools then runs it
still zero plugins :(((
I'm getting an error while running this part of my code (MySQL) com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value:
public void addPoint(UUID uuid, int point) {
try {
PreparedStatement ps = plugin.SQL.getConnection().prepareStatement("UPDATE test SET POINT=? WHERE UUID=?");
ps.setInt(1, (getKarma(uuid) + point));
ps.setString(2, uuid.toString());
ps.executeUpdate();
} catch(SQLException e) {
e.printStackTrace();
}
}
public int getPoint(UUID uuid) {
try {
PreparedStatement ps = plugin.SQL.getConnection().prepareStatement("SELECT POINT FROM test WHERE UUID=?");
ps.setString(1, uuid.toString());
ResultSet rs = ps.executeQuery();
int point = 0;
if (rs.next()) {
point = rs.getInt("POINT");
return point;
}
} catch(SQLException e) {
e.printStackTrace();
}
return 0;
}```
[14:12:29] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 5169ms or 103 ticks behind
i have that warning does that mean something?
like fro why it wont register my plugin?
Then the route from EU to wherever the spigot stash is is messed up
I'm UK
how i can get bungee servers into ServerInfo[] or something else
Do you mean on Spigot or on the bungee proxy?
bungee
I need to get the names of all the servers and then use the command to output all their names separated by commas
sure, i can just add their names right into code but if i add server i don't want add servers in code
getProxy().getServers()
ProxyServer.getInstance.getProxy().getServers() ?
How can I create a potion with a custom double amplifier because PotionEffect only accepts int amplifier values normally
how do you imagine the potion level in decimal?
plugin.getProxy()
whatever your plugin instance is
whatever class of yours extends plugin
Command
getServers() returns a map of all server names and their serverInfo
and how get list of servers from this?
getKeys()
and how get servers amount?
then you'd have to access the map and read the serverInfo mapped to each key
i can get key if i know what equal this key but i don't know it
You seem to not understand what a Map is
How can I build Spigot excluding some set of patches?
yes i need get all servers name to put into this list
plugin.getProxy().getServers().getKeys()
you already asked that
yes
and I answered
where
right at your cursor in that image
if you cant understand what elgar has said then you need to spend more time learning java
...
я нихуя не понял, ебаный пендос не может ответить на 1 ёбаный вопрос
спасибо блять
I think..... 70% of people come here and they don't know Java well
Ahm. I think you just roasted yourself
no need for swearing under your breath in russian in a text app
it's fine if your talking
lmao
cuz the first thing that comes to peoples minds when they think of java is minecraft: java edition
so naturally they either want to make mods or plugins
oh lol, they think learning Java is learning minecraft Java edition lol
oh wow I just translated that message
Sorry I helped and gave you ever answer you asked for
anyone know why a plugin would not compile?
im trying to run a basic program
and my server isnt registering it
doesn't compile? Do you get a jar?
then it compiles
drop the jar in here
you have plugin.yml but no code
it's a jar, just nothing is included there. Only the plugin.yml
so how do i comile eevrything?
what IDE are you using?
he's using eclipse and the built in ides tools, don't know about eclipse enough to help him with that
yes
see conversation in #help-server ^^
goto export jar and in the left window expand the project and make sure src is ticked
ok ill try
Whats a best way to make a plugin that would work good with a resource pack? I want to import multiple custom made models with textures etc. to my resource pack, then for example create a custom mob with spigot, no problem, however I would also want to assign it a custommodeldata, is something like this possible? I thought this could work in a similar way like datapacks, I'm more experienced with Java than Command blocks 😄
this?
Untick .settings in the left, and in the right untick .classpath and .project
yes
swag, ill run it
So I used this to remove an item from a player, but if the item is damaged it does pass the check but it doesn't remove the item. How can I fix this in the best way possible?
if (player.getInventory().contains(mat, amount)) {
player.getInventory().removeItem(new ItemStack[] { new ItemStack(mat, amount) });
why an array for a single item?
Good point, got it from internet
if (player.getInventory().contains(mat, amount)) {
player.getInventory().removeItem(new ItemStack(mat, amount));
also check the return of the removeItem attempt. If it returns an empty map it believes it succeeded. If it fails it will contain the item that failed.
So if it fails I can check what item failed?
yes
Alrighty
in the returned map
ty
can someone help me with it #help-development message
uhh quick question, how would this lead to a StackOverflow on spawn?
@Override
public void tick()
{
((EntityInsentient)this).tick();
}
Currently trying to override the EntityCat's tick method but trying to keep all the pre-stuff but as soon as I spawn the cat it crashes the server with a StackOverflow error spam
um, you are calling the same method. Infinite loop.
shouldnt EntityInsentient-ification for this call the tick from that class?
you are calling yrou own tick method, try super.tick
thing is super.tick wont do it
since I dont want the Cat's tick method, just the previous classes tick
java.lang.IllegalArgumentException: Server lobby (priority 0) is not defined
what does that mean
its a bungeecord server so idk
Did you make a plugin for bungeecord?
no should i
Yes you can cast, try (EntityInsentient)super.tick();. No idea what EntityInsentient is though.
is the correct place to ask this question
Whats a best way to make a plugin that would work good with a resource pack? I want to import multiple custom made models with textures etc. to my resource pack, then for example create a custom mob with spigot, no problem, however I would also want to assign it a custommodeldata, is something like this possible? I thought this could work in a similar way like datapacks, I'm more experienced with Java than Command blocks smile
Anyone notice spigot api maven builds are being weird?
nvm lol
my builds are failing
EntityInsentient is basically the base class for all the entities that well are insentient, so basically everything that lives and isnt a player (NMS stuff)
Spigot is down in some regions at the moment
oh F is it fine in the UK?
Im in the UK.... and no
probably an issue on my end then
its fine in the UK
thanks either way
Ohh, i mean that i am in the UK and it is down @outer crane
it Must be ISP specific. Virgin here
some1 else in #general said it was down in the Uk as well
oh ISP is Virgin 🙂
possible
Sky here
dead for me too
Yes, same here
not even the cloudflare timeout
Doesn't maven cache the api?
lemme restart my system see if it fixes it
ahhh, ok
still failing for me cuz my cache expired probably
I refreshed and its fine for me, but thats not help for you
Nah, its defo down for me
works through the proxy fine
ok restarted system and it works for me so it looks like it was an issue on my end
I'm getting an error while running this part of my code (MySQL) com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value:
public void addPoint(UUID uuid, int point) {
try {
PreparedStatement ps = plugin.SQL.getConnection().prepareStatement("UPDATE test SET POINT=? WHERE UUID=?");
ps.setInt(1, (getKarma(uuid) + point));
ps.setString(2, uuid.toString());
ps.executeUpdate();
} catch(SQLException e) {
e.printStackTrace();
}
}
public int getPoint(UUID uuid) {
try {
PreparedStatement ps = plugin.SQL.getConnection().prepareStatement("SELECT POINT FROM test WHERE UUID=?");
ps.setString(1, uuid.toString());
ResultSet rs = ps.executeQuery();
int point = 0;
if (rs.next()) {
point = rs.getInt("POINT");
return point;
}
} catch(SQLException e) {
e.printStackTrace();
}
return 0;
}```
Asked a couple of times already and nobody have helped out yet so I'll just try to ask once more
Is that the whole error?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
does any one has any clue why age of sugar cane goes back to age 0 from max 15
is that a glitch ?
when i am coding tab completer do i need to use different classes with different onCommand methods?
In the file, that's line 65 I guess and its ps.setString(2, uuid.toString());, all the relevant stuff for the error is in the box above
ima just send the full file ye
do that.
https://pastebin.com/YSS3tnGe here is the full file in case
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
any one has any clue xd
FYI there is a new feature where you can drag in your class and it will show us with a built viewer
Try google maybe idk lol
tried
player.getInventory().addItem(item);``` how do I give a player a specific amount of an item?
nothing usful to find
@quaint mantle, you know what might be the issue?
do I just loop it?
o I do it there.. lmao
declaration: package: org.bukkit.inventory, class: ItemStack
No. Set the amount on the ItemStack
Off didn't scroll down ;/ sorry the other people already awnsered
That error is saying your database column for POINT is a Double not an integer
.
okey so my command executor will be in tabcompleter yes?
wherever you have your CommandExecutor you implement Tab completer
okay thanks
I usually have an abstract base class and then override in my command classes
what event is triggered on a spawn egg place? PlayerInteractEvent?
it shoudl be ProjectileHitEvent
why would that be
because its a Projectile
Check the event projectile to see if its a SpawnEgg
ah okay thanks
is it possible to use
slr.addIngredient(3, Material.FLINT);
but instead of having Material.FLINT, having an ItemStack
so far i have this
public static void FlyCookieTier1(){
//ingredients
ItemStack ing0 = new ItemStack(Material.EMERALD,1);
//ItemMeta ing0meta = ing0.getItemMeta();
//ing0meta.setDisplayName("Fly Cookie Tier 1 ing 0");
//ing0.setItemMeta(ing0meta);
//final product
ItemStack finalProd = new ItemStack(Material.COOKIE);
ItemMeta meta = finalProd.getItemMeta();
meta.setDisplayName(ChatColor.GOLD + "Fly Cookie Tier 1 ");
ArrayList<String> lore = new ArrayList<String>();
lore.add(ChatColor.GRAY + "Use this item for");
lore.add(ChatColor.GRAY + "5 minutes of Fly!");
meta.setLore(lore);
finalProd.setItemMeta(meta);
//item creation
ShapelessRecipe recipe = new ShapelessRecipe(ing0);
recipe.addIngredient(2,ing0);
getServer().addRecipe(recipe);
}```
but i get an error in recipe.addIngredient(2,ing0) because you cant use an item stack there
i found this the other day tho
new RecipeChoice.ExactChoice
wich worked with shaped recipe
Bonjour je suis français et j’ai besoin d’aide j’essaye de paramettee le plugin mysql player data bridge mais cela ne veux pas ce synchronisiez pouvez vous m’aider
but i dont know how to use it with shapeless recipe
English please 
Hello I am French and I need help I am trying to configure the mysql player data bridge plugin but this does not want this synchronize can you help me
Guys what is the best source to learn spigot api????
Learn Java. Then use the Javadocs
Yes thanks
wb getting the person who plopped down the spawn egg
Is there a way to get how many blocks a player has broken, period?
I know there's statistics
But that's per-block
It takes ~300ms to get all of the blocks broken by a player with that method
Which is far too slow
Hm maybe just track it yourself
Loop through everything the first time and then track the rest yourself
@EventHandler
public void onPlace(final PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getItem().getType() == Material.MONSTER_EGG) {
Entity i = e.getPlayer().getWorld().spawnEntity(e.getClickedBlock().getLocation(), ((SpawnEggMeta) e.getItem().getItemMeta()).getSpawnedType());
if (i.getType() == EntityType.GHAST) {
// blah blah
}
}
}
@EventHandler
private void onPlace(final CreatureSpawnEvent e) {
if (e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) {
e.setCancelled(true);
}
}
kinda ugly
Guys i know that i have to learn java first but after java where is sources to learn spigot api???????????
package index
Really javadocs will teach me spigot api!!!
If you know Java you don't need anything else
Java can do anything
And most beginner things are not bukkit-specific
Well, JVM-languages are all largely compatible
Careful now, let's not get too ahead of oursevles 🙃
whats something Java can't do?
Java ME flashbacks
:)
Hmm
c# > java
I mean it cant be able to do everything
name one thing it can't do
Guys after learning java i cannot write a mobile app i have to learn its framewirks and api and librarys to make mobile app not everyone who learned java can do everything
Lmaoo idk, an OS written in java?
Android
javascript* can do anything
HUMAN can do anything
physical media is forever
you ever tried changing an item meta with your bare hands?
buy laser disc
@daring sierra are u boy dude ur name is weird!!!!
Scratches disc
look at my discord name

U r a boy
It is weird too
I am a weird person 
Yeah u r
Well, I struggle alot with gender identity, but I was born a boy if that's what you mean. You can call me whatever
Hello whatever
Lol
whats so funny
Idk what's the lots of laugh about being dysphoric
I dont get it
Call me whatever u want!!!😂
ruude
he's just another troll + off topic
U guys went off topic
interestingly enough you never tried to end it
I think minecraft have weird developers
I think you have weird
😕
Dude the dog is the weird
tf is up with you?
you eat weird
such as you
Guys ima joking
funny totally laughed
Ty
idk whats weird about me but thanks?
so you mad when you call people the wrong pronouns (probably) but when they say they dont mind you also get mad 🤔
U are weird bro ima joking!!!
Ima joking guys
lmao
Ty bro
😐
what is this guy trying to achieve

Dude ima not trying to achieve thing
probably a kid messing around in various discords.
Guys move to #general
true
that would be me 🎉
It is not a joke
Ima joke
another funny joke
*points gun* laugh.
Idk what's up with people asking everyone for their genders, its akward asf
It is. Also it's PotionEffectType
thanks
Hi im very new to coding, i was wondering how i open a .class file. I tried to open it with notepad and visual studio, Neither worked. I have java Oracle but dont know how to open the file
lol... Notepad.
Before touching spigot in any way you should def learn java on some other platform.
ok
Btw i created an API for tracking player placed blocks on the idea from earlier using a PersistentDataType<int[], int[]> and the PDC of chunks ^^
https://github.com/Flo0/PlayerBlockTracker
I think its worth adding as a resource to spigot tomorrow when im sure that it doesnt trash the performance.
in 1.16.5 when I spawn an ArmorStand, it spawn in invisible mode, how can I fix that?
It does not unless you do some stuff to the ArmorStand
Nice on teh idea of the move. Will it move between chunks?
if I only spawn the armorstand, it appears in invisible mode
I have this peace of code:
ArmorStand as = (ArmorStand) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
as.setArms(true);
as.setBasePlate(true);
Yes i made sure that it checks that. Its pretty dynamic so its theoretically even possible to move the tracking between worlds.
nice
Did you make sure that your server allows spawning of ArmorStands and that no other plugin alters them?
where do I see if it allows that?
I mean
when I spawn an ArmorStand, I know it spawned because the block where it appeared it can't be clickable, I need to destroy the armorstand to be able to click that block again
Make sure that your plugin is the only one on the server.
Also place a normal ArmorStand and check if it happens to all ArmorStands.
hey guys, i need help, idk why this is line is returning null ```
Location skyblockLobby = new Location(Bukkit.getWorld("skyblock"),0,150,0);
player.teleport(skyblockLobby);
i mean, its returning this error: Could not pass event InventoryClickEvent to Plugin v0.1 org.bukkit.event.EventException: null
that means that it probably means the world "skyblock" isn't loaded
how do i load it?
Is "skyblock" a world you defined and created?
yes
did you create it first?
yup
okok ty elgarl
new WorldCreator("skyblock").createWorld();
Yeah
still not working
i did this if statement ```java
if(getServer().getWorld("skyblock").equals(null)){
new WorldCreator("skyblock").createWorld();
}
I'm using Mob#setTarget on a sheep, but it's not working as anticipated. The sheep simply doesn't follow the target. Any suggestions?
No no no. createWorld loads the world
ahhh
And also, never EVER use .equals for null checking
makes sense
always use ==
okok ty for the tip
np
does anyone know an efficient way of generating a name that's not a real MC account name?
==
im not used to program in java lol
yeah I see that
seems sketchy
hmmmm
.equals is to compare object instances. == is for primitives, enums and null
hmm ok ty
i can obviously just merge a random amount of words together and check it against mojangs servers but eh
loop through all names and cache then just sync every second
and have a set of strings to check
🤡
lmao
now it teleports the player but stills showing this error: Could not pass event InventoryClickEvent to Plugin v0.1 org.bukkit.event.EventException: null
show the full error
?paste
ItemMeta meta = clicked.getItemMeta();
worked ty
or actually, thats not it. clicked is null
i made another thing
ok
i made this if you want to know if(ChatColor.stripColor(clicked.getItemMeta().getDisplayName()).equals("Skyblock"))
its not showing the error anymore
It won;t you are just hiding it in the stripColor method
it will never be true if clicked is null
so no error but its never going to be true
it is true
look at where you are setting clicked
but it is going inside the if statement
where do you set a value to clicked?
ItemStack clicked = event.getCurrentItem();
I'm beginning to thing line 269 was not your error line
it was the error, but perhaps you miscounted in your IDE
maybe
is there anyway to store the player inv or do i need to store it in database?
ItemStacks are serializable
if you only need it temporarily you could use an InventorySnapshot
else database
im trying to make a network so for exemple now im making a skyblock and i need to store the player inv somewhere
Do you mean you want to send the players inventory from one server to another?
no
i want to store for example the skyblock inv of a player in the skyblock map, the survival inv of a player in the survival map
etc
then database/file
or
it would be possible to store in the PDC of the player, but that will get rather large if you have too many types.
so, how do i store them in the db?
saving to file would be simplest as ItemStacks are already serializable
All you have to do is store the inventory slot and the ItemStack it contains.
so, i create an bidimensional array to store both things?
hello I do playSound and the sound only plays for half a second
why does age of cactus and sugarcane restarts back to 0 insted of staying 15 ?
other crops when they reach max age they don't restart
is there any way to fix that
they loop to zero so they can continue growing. placing a new block on top
A sound plays for as long as the sound is supposed to.
Nvmm
if its only 0.5 seconds then its only a 0.5 second recording
No it's a custom second
Sound
It was supposed to play ofr 40 seconds, but i discovered that it plays at a location not to the player
I believe it needs to be a mono sound to play at the players location
thats the range it can be heard at
yeah thats what i needed
if you change it to a mono sound you can play it on the player and it will follow him
oh how do I do that
how do I change it into a mono sound
no idea. I'm not an audiphile
then I think for me the best solution would be if players places cactus editing age to 1
so 0 will represent fully grown
because I am droping tokens
yep I only need them so players can't spam
farming tokens
for example I am giving tokens when player farms
but if cactus age is 0 after they fully grow
that is the problem
because they can just spam click place old cactus block and try to get tokens
for the same block
so best option is in case player places cactus I should change block data age to 1
and then cactus need to to do 15 steps to get back to 0
and they need to wait
to get tokens
if u get what I mean
can u send the documentation?
You could just keep track of blocks that got placed by players and dont give tokens for those.
Yep, only give tokens for the blocks that grow on top
u can place cactus on top of each other
yes, use 7smile7's plugin he just wrote and it tracks all blocks placed
Then dont give tokens for any blocks that got placed by a player...
all you have to do is ask if its a player placed block
whats a anum in Sound that sounds like a WOOSH like flying etc
but a loud WOOSH
Aha
enum*
https://github.com/Flo0/PlayerBlockTracker
Just made this actually... Just download the jar from the releases and add it to your server. Then you can use the API by adding the maven dependency.
ok thanks I will maybe use it in future for mining drops xd
for farming age will do
anybrony know jooq? i need halp ;-; how exactly do u work with variables than can be null or not null
by the way that protocollib code which u shared last night
solwed big time problem
those dudes which were glitching my friend server were so confused
xD
Nice
Is there a way to make a chest look like its open without using packets?
not really
maybe you could get away with sending block packets
but not sure
(and that method for Player class)
I don't know shit about packets tho
is that going to be a problem?
I'm assuming that's going to be a problem
I'll go and learn them rq
did you try even looking at the docs? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Lidded.html#open()
declaration: package: org.bukkit.block, interface: Lidded
cc @paper viper
oh
my bad
i didn't know that existed
sorry
🥲
in that case, you could do something like this
final Block myBlock = ...;
if (myBlock.getType() == Material.CHEST) {
final Chest chest = (Chest) block.getState();
final Lidded lid = (Liddeed) chest;
lid.open();
}
So i am trying to create a challenge plugin where random mobs fall from the sky and for some reason hostile mobs are not spawning but if i spawn a hostile mob using a test command from the same plugin it works fine. here is the method to spawn the mobs
>
[00:10:15 WARN]: [Skyblock] Task #16313 for (my plugin) v1.3 generated an exception
java.lang.OutOfMemoryError: GC overhead limit exceeded
>
[00:10:21 FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
``` on a 10Gb server with only me on it after around 40 minutes of uptime
memory leak? and if so, what r my possibilities for finding out what exactly it is
i want to use several lists in one function, i would use for (UUID playerID : blueTeam1v1) { for one list, but how would i also include redTeam1v1 for example?
you could just create a 3rd list by adding the blueteam list to the redteam list and iterating through that
yeah but that takes processing power
is there a way to just use both existing lists?
Anyone know a white particle?
snow?
elaborate more
The impact preformance would be very low (practically unnoticeable) and any other way would be just as much if not more impact
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html heres a list, try using stuff like SNOWBALL or SNOW_SHOVEL
declaration: package: org.bukkit, enum: Particle
Okay
ill use ur solution if i cant find a way to do mine, ty tho
_ _
i have 2 teams which i want when the game is over to display a message in the big text that shows up on ur screen then tp them to spawn
bro i wish i could help, i aint that good to help w/ memory leaks
^
just add both lists
parallel computing would be overkill
so i should just make a combined list?
yes
np
can someone help with this?
#help-development message
try adding System.out.println to your if statements and see where it doesnt pop u0p
You are probably creating objects and not releasing them.
found the stacktrace
every 10 ticks, i call my class that runs through inventories applying custom stats and such, and in this class (idek if this is the reason of the memory leak, or if it just happened to run out of memory right here) but it's a class with around 25 final doubles per player, but the line is where i access my sql database and declare and initalize a final double to the user's health that's found in the sql database
the gc's meant to run through this and clean up though is it not? since it's not static, nor outside the scope of a function
the class is tied to a hashmap with the player(s)
only if you are relasing all object when finished. You shoudl be reusing
lemme try to visualize for you
every 10 ticks is a lot. thats twice a second
?paste
#1 the system can surely take it, it's a beast of a pc
#2, it may be 15 or 30, unsure
plus it's only one player, being me
then you have a serious memory leak
public final class CustomPlayer {
public static HashMap<UUID, CustomPlayer > stats = new HashMap<>();
final private Player p;
private double maxHealth;
private double mana;
public CustomPlayer (Player p) {
stats.put(p.getUniqueId(), this);
this.p = p;
}
private void setMana(double mana) {
this.mana = mana + 100;
}
private void updateStats(final Player p) {
final double health = MainPlugin.getInstance().sql.getHealth(p.getUniqueId());
p.setMaxHealth(health + maxHealth + 21);
p.setHealthScale(40);
setMana(health);
}
}```
an example of the class, shortened to the important parts and used parts
and again, it doesn't look like it could occur from here
No way to tell without seeing actual code thats in use
hence why i think the stacktrace only chose this place as it was allocating/creating new memory pointer or wtv for health at the time when it was around at 8.9Gb/9Gb and that's when it froze up
^ need you to verify if that's possible
and that the memory leak could be elsewhere
What does this null exception mean? I've never dealt with anything like this, here's my class https://github.com/dev-stan/RickChat/blob/master/src/dev/stan/plugin/RickChat.java
impossible to tell just from that code
and i'm like 98% sure it's that, because i've been using the same code for a while for that
hm
with me only happening to stand still throughout the entire duration, that means it has to be from a bukkit repeatingTask right?
considering the [Alchemy] Task #19200 for Alchemy v1.3 generated an exception being spammed with hella different task ids in numbers spanning out 100 of an interval each
Github link is a 404 and your null is in RickChat line 50
There is no way to tell without seeing code
bruh
it sounds like you have a god class. Everything in a single class
how do i make the big screen covering text appear for a player
what are they called
i might be able to diagnose it myself given that i simply just understood how the gc works and how memory leaks happen
title
title
.sendTitle()
Are you using repeating tasks or running a new one each time?
onEnable() runs a fuction that creates 4 syncrepeatingtasks which r unassigned
i'm sure this isn't good to have, and neither do i think it's the cause, but inside one of my syncrepeatingtask i was creating a new instance of random every 13.5 seconds
given that the gc wouldn't have picked that up it is
is player.setTitle fade in, fade out and duration in miliseconds or ticks
ticks always
alright ty
Create a global random and use that
yea i just switched to my static one
to save me time playtesting it, whats a good tick amount for fading in and out?
but is Random expensive enough to have caused it do you think, w 10gbs or no?
but that would still not account for a 10 gig memory leak
well how many seconds do you want it to be
yeah
thought so
if i had some grafana monitoring
this would be a lot easier
since everytime i run my cmd to check mem usage it just looks fine
like i needa know if it just spikes immediately or slowly rises up
leave it at default -1,-1,-1
thats what im asking lol, i know its 20 tps, but im asking if yall know a good amount of time a fade in should last
might want to test it urself
^ as long as you're not dragging over ftp everytime, why not just build and /rl
how can u have duration at -1?
-1 means use the default
I'm still pretty new to java, could someone explain why this code works perfectly ```java
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("rick")) {
player.sendMessage(prefix + this.getCustomConfig().getString("messages.default.base-command"));
}
return false;
}```
but when I add String prefix = ChatColor.translateAlternateColorCodes('&', this.getCustomConfig().getString("messages.default.prefix")); above the function I get a null pointer exception
ok
elgar, any good library you have in mind for this or something to make it easier, or should i go for a basic influxdb?
your getCustomConfig method is returning null i suppose
I would just look over the code myself and spot the leak. For you I can;t advise
one more question, whats the default time? i dont see it in the docs for player.sendTitle
whats the particle that happens when a mob dies? The white poof
I think -1 actually makes it use the last times sent
Why is it returning null? And can I change that<?
easy enough for someone like you ha
the defaults are in the docs though
or the path is null
All timings values may take a value of -1 to indicate that they will use the last value sent (or the defaults if no title has been displayed).
stay - time in ticks for titles to stay. Defaults to 70.
fadeOut - time in ticks for titles to fade out. Defaults to 20.```
The path is there, the file exists and works without declaring the string
whats the particle that happens when a mob dies? The white poof
thank you, i shouldve been more attentive
does the path have a value?
I'm really not sure, how can I give it one?
hellppp
looks to me like you have a prefix value
can you show us the getCustomConfig() method?
oh yeah the prefix
Here's my class, I followed a guide on configs by md https://paste.md-5.net/opetirepos.java
remove line 24. You can;t initialize that variable before the config has been initialized
there you go
I'm guessing it would work if I put it under the command function?
and remove implements Listener as that class is not using a Listener
gotcha
yes, if u put it inside the onCommand thing, or you can initialize the variable on onEnable.
You have to initialize the prefix variable in onEnable after createCustomConfig, otherwise it will always be null
after you called the createCustomConfig method
How can I use this string in other methods and classes? I can't just make it public
you have a getCustomConfig. just past an instance of this main class to any other class that needs access
so new ChatListener(this), this);
save the instance in yoru Chatlistener as plugin and you can get access in ChatPlugin using plugin.getCustomConfig()
you will also be able to access plugin.prefix as its public
Hmm, for some reason I can't use this.prefix in the same class though
if you moved the whole thing into a method it has become a local variable
Yup, I can't make it public though
you need to define it where you did in line 24 like public String prefix;
do the same thing as before but initialize the variable on onEnable.
and intialize it after you create your config
gotcha, thank you!
Hmm, prefix and color still return null even though they were initialized after the config, any idea why this could be happening? ```java
public String prefix;
public String color;
@Override
public void onEnable(){
getServer().getPluginManager().registerEvents(new ChatListener(), this);
createCustomConfig();
String prefix = ChatColor.translateAlternateColorCodes('&', this.getCustomConfig().getString("messages.default.prefix"));
String color = ChatColor.translateAlternateColorCodes('&', this.getCustomConfig().getString("messages.default.color"));
}
you do prefix = ...
no need String prefix = ...
or you can do this.prefix = ...
you're creating local variable right there.
Yup, and I"m making it public above
^ adding String at the beginning you are creating local variables that go out of scope outside the onEnable.
but you're not initializing the "public" prefix and color
So I should initialize the variables in onEnable and then "fill" them?
remove String from before teh color and prefix in onEnable
public String prefix;
public String color;
@Override
public void onEnable(){
getServer().getPluginManager().registerEvents(new ChatListener(), this);
createCustomConfig();
this.prefix = ChatColor.translateAlternateColorCodes('&', this.getCustomConfig().getString("messages.default.prefix"));
this.color = ChatColor.translateAlternateColorCodes('&', this.getCustomConfig().getString("messages.default.color"));
}```
guys, i was thinking, how can i store an hashmap into an yml file
depends on the key and value ig
sure, you can do that since ItemStack is ConfigurationSerializable.
but how can i store an entire inv to an hashmap?
getContents() then store by index
Base64 would be bloat when ItemStack is already serializable
and theres no reason to encrypt it nor make it unreadable
just .getContents() and loop over storing each ItemStack thats not AIR or null against its index in the map
That can then be pushed straight to a file.
You could put it in a list and just store the list
you could but then you get nulls and AIR
True
the index is the slot right?
it would be
it worked, though I'm still not sure how to use the config from other classes, this throws me a "plugin already initialized" error which is understandable since i'd be enabling it again player.sendMessage(new RickChat().getCustomConfig().getString("messages.respond.help"));
yes, thats wrong
Don’t create an instance of your main class
Use dependency injection and pass it through constructors
I told you above to pass an instance. new ChatListener(this), this);
Why would I create an instance of the current class if I'm trying to retrieve some information from the main rickChat class
You can only have ONE instance of your class which extends JavaPlugin. You pass that around (as I showed you).
and how do i use an hashmap?
never did that
Thats fairly basic Java. Not something I'm here to teach.
ty
sry if i never learned java 🙂
hashmaps are basically a data structure where you can put a value in it and have a key associated with it to unlock that value later
put(key, value)
ty, what u sent to me helped me a lot
get(key) ....... which returns that value
for spigot you could do ........put(player, "hello world")
.......get(player)..... returns "hello world"
hope that helps
what do you think about this? ```java
HashMap<Integer, ItemStack> inv = new HashMap<Integer,ItemStack>();
for(int i = 0; i < player.getInventory().getSize(); i++){
if(!player.getInventory().getItem(i).equals(Material.AIR) && player.getInventory().getItem(i) != null){
inv.put(i,player.getInventory().getItem(i));
}
}
yup, helped me a lot
i think thats it
what are you asking about it
getInventory().getContents()
in what line?
I guess yoru code shoudl work
you basically reinvented a list with indexes as keys
check for null first using ==, then check for AIR
yep, he's putting it into a map so he can push to file
ohhhhh i see
So he need the slot index to store too
sure yeah that makes more sense
if hes trying to save inventory contents though doesnt it get more complicated with enchantments and stuff
wdym, where should i write that?
HashMap<Integer, ItemStack> inv = new HashMap<>();
for(int i = 0; i < player.getInventory().getSize(); i++){
ItemStack item = player.getInventory().getItem(i);
if(item != null && item.getType() != Material.AIR){
inv.put(i,item);
}
}```
is there a discord for ProtcolLib
No, Itemstacks are serializable
the line number 4 is getting an error
now you have the map you can simply getConfig().set("inventory", inv);
Operator '!=' cannot be applied to 'org.bukkit.inventory.ItemStack', 'org.bukkit.Material'
ah sorry, item.getType()
why am i getting an error while i try to set the inv data to my db?
'set(java.lang.String, java.lang.Object)' in 'org.bukkit.configuration.MemorySection' cannot be applied to '(java.lang.String)'
show you line of code you are setting
public void saveInv(Player player){
HashMap<Integer, ItemStack> inv = new HashMap<>();
for(int i = 0; i < player.getInventory().getSize(); i++){
ItemStack item = player.getInventory().getItem(i);
if(item != null && item.getType() != (Material.AIR)){
inv.put(i,item);
}
}
this.getSkyblockDB().set("");
}
but i have custom config files
then put it in whatever file you want
oh
it still needs a path and the data
what you will do is instead of storing it under the "skyblock" path, you want to use the player.getUniqueId().toString()
already fixed but ty
that way you have multiple player inventories in one file
yes, and thats what i want
so this.getSkyblockDB().set(player.getUniqueId().toString(), inv);
yh
yes, it becomes a ConfigurationSection
all the time I will loop through each keys and set it on the config.
is there any way to get the counted items from the config file? (like, i have 2 swords and 3 axes it ill return 5 items)
not from the file easily, you can count Material types in the Inventory
im asking that cuz everytime the playe joins the skyblock i need to load the inv thing to his inventory
You don;t need to know.
all you will do is the same in reverse and each item has the slot it came from stored
you will be putting every item back exactly where it came from
can you cast PacketContainers in protocollib?
like im a similar way if you know an Entity is a Wolf you could cast it to a Wolf
yes, but for the for loop
i was thinking if i do for(int i = 0; i < 36; i++) but thats a kinda no sense doing that since i also have to place the armor
so on join, get the ConfigurationSection.
ConfigurationSection section = this.getSkyblockDB().getConfigurationSection(player.getUniqueId());
if (section == null) return;
player.getInventory().clear();
for(String path: section.getKeys(false)) {
ItemStack item = section.getItemStack(path);
player.getInventory.setItem(path, item);
Don't forget to clear the players inventory before you go about setting the new contents
yes 🙂
that's fucking awesome
You may also want to check section != null before you start looping
nvm
is possible to save the inv at the event onPlayerQuitEvent?
sure
save when they quit or change worlds
anyone know protocol lib here
I kind of do
Whats your issue with plib?
can you cast from a PacketContainer to a more specific packet type
like in spigot how you can go from Entity --> Wolf
like if I knew a packet was a CHAT type could I cast it to something more specific with methods just for that packet type
No. The PacketContainer is just a wrapper for any arbitrary packet. But you can write more specific wrapper for the types you need.
I believe there is also a repo that has some of those.
its returning an error
Ah okay, ill stick with the container for now. Im just having a problem understanding how exactly someone would know to code this
Cannot resolve method 'setItem(java.lang.String, org.bukkit.inventory.ItemStack)'
like how would they know that .getDoubles() etc etc will change those specific field you know
Integer.parseInt(path)
is there documentation on each specific packet like the Explosion one
This information comes from reading the protocol specifications.
https://wiki.vg/Protocol#Explosion
did that but still not loading the inv
that will fix the error. As for loading, did you save the inventory and checked it is in teh file?
okay i havent seen this yet, do you have some sort of tutorial explaining how to use it i can follow?
you need to save the config everytime you modify it using #set
but its what im looking for so thanks for that
You just need to read into each packet by its own. Then you can get the fields from top to bottom. So the first Float has the index 0 then next Float has the index 1 and so on.
Then for each type it starts from 0 again.
ohhhh
i see that, X Y Z
0 1 2
great that makes sense!
so would there be any reason this isnt working for me?
Your chat message has to be a proper json String with the accepted properties. You can achieve that by either using the TextComponent API or if you want to create something more raw then you could use Gson.
Ill send you an examlpe.
But here is the chat packet:
https://wiki.vg/Protocol#Chat_Message_.28clientbound.29
because i want to send it not receiving
it is saying that this section is null "Players." + player.getUniqueId() + ".inv"
This is how your json Strings have to be structured:
https://wiki.vg/Chat#Processing_chat
(Scroll to the top)
okay ill try to wrap my head around it
i was hoping it would be as easy as sending a string back
toString()
on the getUniqueId()
what is saying that is null?
thanks for the help
yes
and yes toString()
your .inv is empty, so you have not saved your config after adding an inventory
no, i saved it
good. thats not the one you posted
it is a glitch cuz when i get back on the server it dont loads the inv and then when i disconnect it clears the inv in db cuz i has no items
are you getting the message or is the for loop running?
This might work. Didnt test:
public PacketContainer createSimpleChatPacket(final String message) {
final PacketContainer container = new PacketContainer(Server.CHAT);
// Write the chat message using ProtocolLibs chat message wrapper
final StructureModifier<WrappedChatComponent[]> chatStructureMod = container.getChatComponentArrays();
final WrappedChatComponent component = WrappedChatComponent.fromText(message);
chatStructureMod.write(0, new WrappedChatComponent[]{component});
// Setting the display type
container.getChatTypes().write(0, ChatType.CHAT);
// Setting the UUID to 0 | 0 so it always gets displayed (according to the protocol specifications)
container.getUUIDs().write(0, new UUID(0L, 0L));
return container;
}
i think the loop is running
cuz im not getting the msg
so I tried calling an AsyncPlayerChatEvent instead to send the message but it didnt work and my log says: AsyncPlayerChatEvent cannot be triggered asynchronously from another thread.
do a getLogger().info in the for loop of path to make sure it is running. If it is you will need to delay calling the method for 1 tick after you join
Packet listeners are async
v
You need to sync back to the main thread
Any reason why you dont want to just send the message to the player?
because my event handler for AsyncPlayerChat adds all the different rankings and colors and stuff to the message
and when i just do Player.sendMessage() it goes around that i guess
now, the section is returning null
You need to actually send the message async in order for the AsyncPlayerChatEvent to trigger.
so if I used just PlayerChatEvent it would work?
make sure there is data in the config to load
how to install
whats the main difference between Async and main thread events?
Probably
That the main thread event runs on the main thread and the async event might not.
PlayerChatEvent is depreciated
that might be why im using Async
Btw plugin messages are not catched by the chat events.
You still have to call the event from the main thread
it is
I mean i was assuming if I created a new event and called it then it would be caught later on
how can i call the event from the main thread then. what does that mean exactly?
Right
check for typos etc. There is no reason for it to be null
Bukkit.getScheduler.RunTask
You simply run Bukkit.getPluginManager().callEvent(Event); in a sync context.
okay ill try doing that
And you can always get a sync context by using the BukkitScheduler and running runTask() like Coll suggested
You could change from a ConfigurationSection to a MemorySection
okay so runTask() will run whatever task thats in it Synch
some1 can help?
would it even make sense to call an AsyncEvent from Sync context
this is returning null ConfigurationSection section = this.getSkyblockDB().getConfigurationSection("Players." + player.getUniqueId().toString() + ".inv");
Yes. Whatever you execute in there will be scheduled for the next tick and be executed on the main thread.
gotta ask what was the point of blocking out the UUID lol
@kindred solar idk what the rules are but you are sending every error and piece of code you have and not doing any of your own debugging it seems. try some print statements and stuff
try java MemorySection section = this.getSkyblockDB().get("Players." + player.getUniqueId().toString() + ".inv");
okay thanks for sharing ill try some things out
thanks for the help
i just do that cuz there is no good info on internet 🙂
WDYM he said to, try some print statements and stuff to debug
right but a null pointer is sortve something that can be figured out with print statements usually. im not trying to be rude just trying to make you a better debugger
it will pay off to learn the skills
I'm off to bed within the next few minutes so be quick
i already debbuged everything
have you tried the MemorySection?
My bud got sunburned 2 days ago and now we literally have 10cm of snow on the streets. What is happening?
not working
still null or what?
wait
the 5g in the microchip implants is activating
class java.util.HashMap cannot be cast to class org.bukkit.configuration.MemorySection (java.util.HashMap is in module java.base of loader 'bootstrap';
ok its working. The reason you got that is because its not a fresh start
it currently has your Map that you inserted. If it was a fresh start it would be a MemorySection
You can easily stop that error by reloading yoru config
so after you save, reload
let me know it works so I can goto bed
wdym with reload the config, reseting it?
same UK here
night
is it better to save it to a base64 if you want to save the inventory in SQL?
IDK, why did they block out fc45f33e-8812-47e5-85bf-55a0e00d8cef?
but then like, include screenname so you could look it up anyway 😮
@summer scroll depends, is it like, serialized and how?
so it will only have 2 strings.
and 3 colums on the sql
player uuid, inventory, and armor
Nah not really been trying to do that more but forgetting.
Hey i have a problem bungeecord only forwards uuid to one server and the other one is random
Enable bungeecord mode in all spigot subservers
I did
Someone knows how to cancel villager's trade event? :c
🤷
Or ill rather check again
Oh i had bungeecord false on one server
I have a question where do i get uuid from what event at bungeecord preloginevent it gives me null
[16:47:44 INFO]: [Core] Enabling Core v1.0-SNAPSHOT
[16:47:44 INFO]: [Core] [MONGO] Attempting to connect to the database...
[16:47:44 INFO]: [Core] [MONGO] Connected to the database! Using MongoStorage as storage.
[16:47:44 INFO]: [Core] [MONGO] Initializing collections, this may take a while!
[16:47:44 INFO]: [Core] [MONGO] Successfully initialized the collections!
[16:47:44 INFO]: [Core] Setting up maps...
setting up maps takes 10 years
Try InventoryClickEvent
@worn tundra can u mb plz help me
whats your problem
lol
this
Is that your plugin?
yes
What file?
1 sec
What's it doing with that file?
private static void setupMaps() {
printConsole(CC.GREEN + "[Core] Setting up maps...");
if(Core.getInstance().doesStorageFileExist()) {
Core.getInstance().getServer().getConsoleSender().sendMessage(CC.RED + "MongoStorage " +
"is required to get the inventory map!");
return;
}
Nice
public boolean doesStorageFileExist() {
return getResource("filestorage.txt") != null;
}
and #getResource?
@Override
public InputStream getResource(String filename) {
if (filename == null) {
throw new IllegalArgumentException("Filename cannot be null");
}
try {
URL url = getClassLoader().getResource(filename);
if (url == null) {
return null;
}
URLConnection connection = url.openConnection();
connection.setUseCaches(false);
return connection.getInputStream();
} catch (IOException ex) {
return null;
}
}
Interesting.. Have you tried deeper debugging with the advanced debugging method called Sout?
Try placing some print functions inside the getResource method at different points
another thiong
and see how far the code goes
ye
Ahh yep
