#help-development
1 messages · Page 1718 of 1
I do "Checkpoint 1", "Checkpoint"2", "Checkpoint 3"
When you forget to build
I do running 1 running 2 running 3
and then 3 hours later I do running -1 running -2 running -3
I just do
1 2 3 4 "1 in loop" "2 in loop" 5 6 7 8 9 10
Damnit
1 2 3 is bad because it is annoying to remove
or when I get bored of numbers I swap to the alphabet
It really makes no sense that it only errored the first time when that was the issue
Imagine not attaching a debugger to debug properly :p
that's most of the reason why I use the class, I just ctrl-click and can instantly see everywhere I have debug messages to remove them
attaching debuggers is frequently not an option
I can just ctrl+z remove the debug messages when I find the issue
It's an option with plugins
frequently it isn't
Explain
bug only happens in x server that isn't yours
give em debug messages and let god sort em out
me not needing debugging because i write good code that never fails
cry normie
me publishing my code immediately after coding it, because my code never fails
i agree with you fellow sigma male
me posting the resources without a jar file because my code is so powerful that actually writing it might destroy the planet, and just talking about it is good enough
😟
I had a bug that happened only on my server because I accidentally set an essentials permission incorrectly
uh
He is the Chosen one
2 hours and redam helping
POV: IntelliJ not saving to file after pressing the power off button
I will avoid introducing bugs and performance issues into your server if you pay me to not create code that might lead to doing it
truly an amazing business model
my not programming as a service has a 100% uptime and a whopping 0% impact on server performance
and it saves incalculable amounts of potential lag your server might've otherwise had
also it is open source and entirely bug free
and it will run on any server version right out of the box
Anyone know how I'd simulate player damage with a fake player (entity id only)?
ID 1 - take damage anim
idk, you'd need to dig into spigot jar
what i would do is to fool somehow the server that specific player is online, that way the server would treat your fake player as real one and thus it would take damage like a normal player
but you would need to dig down how does the player handling works in server
I'm so confused
I got to the bottom of the .damage() method and this is what I found
protected void ac() {
this.velocityChanged = true;
}```
do you send packets per player?
Not really
do you send specific packet to the player to display the human?
I mean I can if I need to
or have you fooled the server that player is in the server which is fake via NMS
i can't explain it properly sorry
if you send packets manually, server doesnt know anything about it, thus it doesnt act normally as its desynced with server, and only the clients see it
Yeah
I wanna find out exactly what packet the server sends when .damage() gets called
it sends animation packet and position packets
you can prove that by lagging yourself out and trying to hit player midair
it wouldnt fall
when you lag
that's another topic
yeah, that's what you need to really find out
by digging down
or googling it
i've never played around with NPCs much
Hi quick question
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
So, I am trying to make this container type of Inventory. I want this inventory to allow a player to only be able to put an item in the slot #4 but the issue is that when on InventoryClickEvent, it also takes my hotbar's slots as the ones I am testing for to cancel the event. For example, slot #5 is just a display pane so it cancels the event but if I grab the item from slot 5 on my hotbar it won't cancel
Yeah but discord on mobile didn’t render
Yeah Idk discord mobile just sucks somewhat too bad
Lol, yeah I was typing.
Even stuff like this isn’t fixed yet
Well
InventoryClickEvent#getRawSlot and getSlot exist
Difference?
Look it up
?jd-s
@ivory sleet Smells
well its kinda hybrid data structure
trie is used primarily for strings
but i use it for node searching
i really need to benchmark this
it really isn't hard to setup
afaik their github had a good tutorial
there are also a few example projects
yea
Just make sure to not run anything on your machine or need it for the next few hours if you are testing a few more methods xD
i need quick and dirty benchmark
to check if my optimization really works
it should be noticeable
well the examples will show you how easy the setup is
pretty easy
but if you do not care about long warm-ups etc, just write your own benchmarks
the tool is designed for proper benchmarks, running multiple benchmarks, doing some cute outlier detection etc
i dont really care because the performance difference should be noticeable by a lot not by nanoseconds
yea then that tool is probably not what you are looking for
you might be fine literally just using a stopwatch
(not a physical one xD)
both googles and apache provide one
Or just system.nanoTime
🦍
well "optimized" one takes 0.004ms to find the argument node
lets see about unoptimized one
these are rough numbers
interesting results! Apparently trie datastructure returns worse results than unoptimized equalsIgnore check with multiple arguments.
So you wasted time with a micro optimization that didn't even help? :p
"Optimized": 0.004 ms,
"Unoptimized": 0.0005 ms
no i think i know why
equals ignore check is faster because there's not so many commands registered in command dispatcher
so its quick to do linear search for it
while trie datastructure has constant search time
of string length
it takes 4000ns to find the argument, but it should be constant time no matter if there's 1 command or 1000 commands registered
while equalsIgnore check would struggle to check 1000 command nodes till it found the match
Using Trie, search complexities can be brought to optimal limit (key length)
Why would you have 1000 commands
Logger mongoLogger = Logger.getLogger( "com.mongodb" );
mongoLogger.setLevel(Level.SEVERE); // e.g. or Log.WARNING, etc.
Can do something like this
In your code
Will only show Severe Issues
wish it worked, slapped it at the top of my onEnable
It should work
so rn it's on top of my onEnable method
and i connect to the db in another class
that is instanciated after
Yeah that wasn't working for me either
player.spigot.sendMessage
A d v e n t u r e
and for some reason mongo's retarded
also i don't understand why does my mongo log 10x more compared to other tutorials
It's two arguments...
im tryna disable logging
How what
I recommend to use Logback then
Specify a logback.xml
And change where the log output is going
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.7</version>
</dependency>```
That is the version I switched to to avoid logspam
isnt 3.12 like from years ago
Probably
This project was from a year ago
lemme try
java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory is in unnamed module of loader 'app'; ch.qos.logback.classic.LoggerContext is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @3136318f)
at me.kill05.**.**.onEnable(**.java:46) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-785]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-785]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-785]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-785]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-785]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:594) ~[patched_1.16.5.jar:git-Paper-785]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-785]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1069) ~[patched_1.16.5.jar:git-Paper-785]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-785]
at java.lang.Thread.run(Thread.java:831) [?:?]
using the imports the guy said
same for the "single liner"
or player.spigot().sendMessage(ChatMessageType.ACTION_BAR, message);
ah
Hey, does anyone have an idea how to make mobs spawn normally outside of the worldborder?
No one? :/
How would i use hex codes instead ChatColor?
?google "spigot hex codes"
Google your question before asking it:
https://www.google.com/
LOL
ChatColor.of
bungee import ^
What about it
tip: remove the ? after links
ok
@Override
public ChatColor getColor() {
return net.md_5.bungee.api.ChatColor.of("#FFFF");
} ```
could i just
You are missing two F's
But yes
Also you should probably use net.md_5.bungee.api.ChatColor anyway
it needs a maven dependency
like if i were to do
@Override
public ChatColor getColor() {
return net.md_5.bungee.api.ChatColor.of("#\w\w\w");
}```
alr i was going of what u said w this
whats the import for it
That is the import
awk wait
holy fuvckl i cant put images in here
the required type is org.bukkit.ChatColor
since i used the ChatColor import
from bukkit
@Override
public ChatColor getColor() {
return net.md_5.bungee.api.ChatColor.of("ffff00");
}```
so like
what would i put instead of ChatColor
Remove the import then
Wanna do some "XP Level = Border Size"-Stuff, so its important that mobs can spawn outside the border. Got the idea from a Youtuber, and he made it working somehow, sadly he didnt explain it :/
Set the world border per player
Wait, thats a thing? Always thought there was only 1 border
Packets
@timber whale ChatColor.of(Color) >>>
Hmm, okay, gonna look into that. thanks for the idea!
is it actually possible to make one character a gradient color? guess not?
since rgb is a thing since.... about 1.16?
You want a single character to be more than 1 color?
that was basically my question
No
sad
oof
what part
None of those characters are more than 1 color
unsus
the transition makes it look like its a gradient on 1 character, well made
I'm guessing it is something like
&1&9&3&b
and to see it like
111111
&11&91&31&b1
What
&1&9&3&b are color codes
\u00A711\u00A791\u00A731\u00A7b1
is that what you want
- |-
&11&91&31&b1
or you want server list plugin
runTaskAsynchronously
does every money check (even cached) cause lag?
wdym money check?
If you don't want to use the awful legacy color format, you can use something like MiniMOTD
Makes gradients super easy too ^
is there anyway to spawn drops with packets ?
i mean the animation of the drop
an item
it can be floating...
If a plugin listens for economy changes it can cause a lot of lag
Stefatorus did something that was queueing vault changes
so plugins that listen for that wouldn't lag that much anymore
Any decent eco will fire events to notify plugins of changes.
can you somehow make mongo shut up, half of my logs are mongo info
are you using a lib for mongo?
yes, this is my maven import
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.3.2</version>
</dependency>```
have anyone tried this?
this seems like perfect platform for minigames
its a blank server, that only communicates with server - client
basically you can hardcode your own server software
ohh so you gotta code everything into it
on top of this
multithreading also
for example you don't need world saving feature, you don't code it
perfect for HCF, Skyblock servers
yes
i really need to take a look to this later
tho how much do you have to code yourself? what does it provide?
it provides only packet level communication
you need to code almost everything yourself
i think it does have some form of implementation
they do have inventory API's
and entity API
as far i can see
i guess you need to code mob behaviour too
it does have api
for that
it does have API for almost everything
but its a modular in a way
that you can not include it in the server at all
unless it has nasty or stupid problems this looks the perfect api to use for servers with hundreds of players and with a lot of custom features
too bad it's only for 1.17 but still
Only concern is the amount of static they use, I mean it’s a good idea but all the code isn’t quite goodly written imo
well i guess you could code the behaviour of everything?
yeah i agree with conclure
didnt check code but if it's not good well
but i dont have time
"goodly" 😆
Idk, I probably wouldn’t do tdd with minestom rn
the multithreading part also looks interesting
yeah lol
anyways does anyone know how can I stop mongo from logging everything in my console? this is my maven import ^
tinker with java's logger class i guess
well logger does the job of outputting to the file so there should be a way to remove mongodb from file buffer stream
I've also tried to use LoggerFactory with some code a guy posted on stackoverflow but that gives me a classcastex
this was the ex
yeah :c
solution, dont use mongo /s
maybe mongodb settings have settings to disable logs
Doubt
inside the driver
they use sl4j or i forgot the logging api
usually they dont add ways for users to customise it within the api
you'd have to do some logger stuff
You shoudl be able to add a Handler to the Bukkit.getLogger()
is there any way to change the player's skin via spigot
how would i do that
Bukkit.getLogger().addHandler(new Handler...)
implement an Anonymous
then in check the record.getname() to see which loggers messages come fron
once you have teh logger name you can see which one you want to filter
um
type as I did without the three ... then press whatever your IDE has for auto complete
CTRL+space for Eclipse
without the three?
periods
do Set Slot Packets also work for chest inventory/anvil inventory/any inventory or is it reserved for player's inventory?
are onLoad, onDisable methods not ran on minecrafts main thread?
pls help?
Bukkit.getLogger().addHandler(new ConsoleHandler() {
@Override
public void publish(LogRecord record) {
System.out.println("Logger: " + record.getLoggerName() + " : " + record.getMessage());
}
});```
there's no Spigot API dedicated to Skins, you need to use a little bit of NMS/OBS
lets you find the correct logger name
then you can ignore any from a specific logger at a specific level
you would need to use com.mojang.authlib package to retrieve player's skin data
google it @quaint mantle
ok
The only statics we have is in MinecraftServer, I do not really see the problem but feel free if you have suggestion
it doesnt send anything when mongo logs
but PaperSpigot afaik has an API for you to change the skin without the hassle of using gameprofiles and packets
^
then mongo is not going through the bukkit log4j
also some dude found a way to get 4K quality skins without client modifications
via microsoft's education edition skin servers
lmfao
Well what’s the reason behind the static fields in the first place?
any other mongo libs i can use
i cant have half of my console spammed with useless data
Just create a logback.xml for mongo
You can set teh logging level for all elements of it
Probably Log4j2 not logback
can I put the .xml under the src package?
no clue
Hey there! Is there a list of recommendable utility libraries for Spigot? I have found SpigotUtils but am uncertain whether it is the go-to. I just want some config stuff but honestly you can't have too much utility functions
you can try redlib
You put the logback.xml in your resources folder
how i could add nms classes using maven
Have worked with it, can be quite obscure at times but once set up properly really nice console output
redlib is very pog
Thank you
kk done, this is what's inside
<appender name="CONSOLE"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%-4relative [%thread] %-5level %logger{30} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.mongodb.driver.connection" level="INFO" additivity="true"/>
<root level="OFF">
<appender-ref ref="CONSOLE" />
</root>
</configuration>```
Hello, i need some help,
https://paste.md-5.net/gacuxarara.java
I have this code, all works but when i get to
} else if (e.getView().getTitle().equals(ChatColor.GOLD + "Confirm your creation")){
and after, that code doesn't work
Looks good though I don't really know. I can send you a sample for discord bots. If this works though epic
Please send the error that is thrown.
so im digging down nms and i found this private synchronized boolean register(@NotNull String label, @NotNull Command command, boolean isAlias, @NotNull String fallbackPrefix) {
why is this synchronised
not in the console
Check wheter getTitle returns String. If so, leave out the ChatColor part
hold on im getting the dep and i'll try
i cant seem to find what causes commands to be registered async
I think it has something to do with multithreading safety
yes it does but the question is where does it do asynchronously
It is to avoid race conditions. Simply put, mark a method as synchronized and it can only be run by one thread at a time.
that's not what im asking
wdym by that?
oh zero clue
Plugins could utilize asynchronous stuff, even so networking stuff.
Otherwise your game would freeze if you request a player list from a server for example (unless solved with a websocket, idk how mc does it)
Guys, I was making a plugin and everything was working but now suddenly my plugin can't load, it gives this error:
https://paste.gg/p/anonymous/288fe64a7b2e447b9cd433cc3fa423b2
i think its security measure, because second overloaded register method that executes provided above register method is not synchronized
ok so my logback is under the resources folder and it contains
<appender name="CONSOLE"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%-4relative [%thread] %-5level %logger{30} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>```
do i have to do anything else?
because it doesnt work
Talking to me?
dude it cant fucking be that i spend more time tryna disable logs compared to implementing mongo
the more i look into NMS, the more disgusted i feel
That's what NMS is for basically
I have few classes and main class, which one do you want to see?
I need help with my bungeecord server so everytime i got my servers up one of the server is on and everytime i try to join that i stay there for a second then it sends me back to the lobby saying " The server you were previously on went down, you have been connected to fallback server "
I wanna see your recycle bin
that invokes getConfig() method
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
All classes contain that
this channel is dedicated specifically for programming
according to the stack: live.bbgc.mc.Discord.java maybe if im correct
bump
bump
How can I disable mongo console logging
Sorry to tag you but nvm it didn't fix
I don't get the point of Score#isScoreSet(). I tried creating an objective without any score and then doing : Objective#getScore("")#isScoreSet() and it returns true
It should return false
live.bbgc.mc.Discord class
show me
dovidas, it is now giving me error for a different line because the line which it was giving error, I fixed that
now the line which is giving error is
if (plugin.getConfig().getBoolean("UseDiscordBot")) {
And as it says in error, it is not able to detect plugin.getConfig()
But I have set plugin to main class
tag me if helping
What's the best practice to store/access the main plugin instance?
because while this might work i doubt its the intended solution...
public static Echo that = null;
@Override
public void onEnable(){
this.that = this;}
Just pass it through the constructor or a method
Doggo is back!
well the reason i ask is because i need to access the instance in static methods like the event listeners
Why are the event listeners static in the first place
Yaaaaa
I'm currently working on an infinite item plugin. But I can't figure out how to make the item infinite.
urgh what i meant is that i need to access the instance in methods that dont have a pointer/variable with that instance like for example onCommand methods and i wanted to know if theres a better solution than what im doing up there
tag it and if its used with that tag restore it
?do I believe this goes over dependency injection which is what you’d normally use
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
thx
which is basically the same thing with extra steps
It’s not about steps
If you care about making your code as small as possible then use static only
But you will make your code fragile, rigorous and immobile
eh fair enough
Quick question: What is the best way to query whether a player has walked to a certain coordinate?
In my case, I would like to check whether a player has walked to a certain z coordinate. If this is the case, the player is teleported to another position. I have already tried the following:
@EventHandler
public void playerMoveListener(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(player.getLocation().getZ() >= Main.instance.getConfig().getDouble("destination.z")) {
player.teleport(Main.instance.getConfig().getLocation("start.location"));
}
}
destination.z and start.location are values that I have inserted in the config of the plugin as follows:
Main.instance.getConfig().set("start.location", player.getLocation().toString());
Main.instance.getConfig().set("destination.z", player.getLocation().add(0, -1, 24).getBlock().getLocation().getZ());
start.location is the location to which the player should be teleported if he crosses the z coordinate, which is stored in direction.z.
Can anyone help me with this?
does the player.teleport function phrase strings back into coordinates?
also I'd recommend checking every second or so with a sceduled task instead of checking every tick the player is moving
though depending on the situation either could be better
How can I disable mongo console logging
dont know if it helps but this only fires once per right click for me IIRR
public static void onInteract(PlayerInteractEvent e){
if(e.getHand().equals(EquipmentSlot.HAND)
&&(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK))```
That is essentially what I am doing already.
can we see the entire check?
dumb question but dont have those checks to be done with .equals with Enums not being a primitive data type?
a == b is true if and only if a is b
And since enum members are global, there’s ever only going to be one existing during runtime we can use the instance equality check or whatever you’d call it
public static BBCore plugin;
public void onEnable() {
plugin = this;
}
how do I set the title of an item to be BaseComponent[]?
what class are you trying to access the config in?
I don't believe you
someone ban that guy its a phising link
Don't do that please
nobody told us what else
Set main class object as private and create static getter
How do I make spigots "talk" with bungee? So that I could invoke commands on bungee and they would execute on specified spigot server and return the response? Without players being needed, so no plugin messaging? I'm open for everything, no matter the difficulty.
I need help with my bungeecord server so everytime i got my servers up one of the server is on and everytime i try to join that i stay there for a second then it sends me back to the lobby saying " The server you were previously on went down, you have been connected to fallback server "
Im having problems making an editable recipe. its not giving off any errors but when I try making the item is just doesnt work. Ive pasted the relevant code here: https://paste.md-5.net/icunosugul.cs
Check the logs on Spigot server and check the disconnect reason.
Ok
How can I disable mongo console logging
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.3.2</version>
</dependency>
``` my maven import
fixed it, forgot to add .toUpperCase on a getMaterial()
There was nothing no reason
is there any way to send a player a actionbar message? e.g. p.sendActionbar("somethin")
i believe thats a paper method, but i think you can use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.Spigot.html#sendMessage(net.md_5.bungee.api.ChatMessageType,java.util.UUID,net.md_5.bungee.api.chat.BaseComponent)
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
RabbitMQ message broker
How do I add things to a config using only code? I want to append my plugins config so that the new things exist and work immediately.
Ideally load the config from the data folder, loop through and check if some of the paths are missing values if so write those values to the memory config and save
do you do that with the config.isConfigurationSection to check wether it has that already?
thx
for example we have a pos1 and pos2
1: x: 10 y: 20 z: 10
2: x: 11 y: 21 z: 11
and we want to check if a location is inside this area
also I was thinking more of something that adds paths to the config.
can i detect when the server receive a packet without use protocol lib ?
that shouldnt matter, since the approaches are explained
public static void inventoryClick(InventoryClickEvent event){
int slot = event.getSlot();
ItemStack stack = event.getInventory().getItem(slot);}
Why does stack equals null even if there's an item in my cursor and in the clicked slot?
rawSlot
wait are they counted differently?
why dont you just do ItemStack stack = event.getCurrentItem()?
slot number is important
does the getSlot or the getRawSlot use this id system?
https://proxy.spigotmc.org/3688e503e566241a19c46cd48cf3cba962c553fe?url=https%3A%2F%2Fwiki.vg%2Fimages%2Fthumb%2F1%2F13%2FInventory-slots.png%2F300px-Inventory-slots.png
wait i am in the player inventory i havent opened anything else. Why isnt it working then?
yeah you might wanna use the raw slot
what is it supposed to be doing?
check if the second from the top row is clicked and echo the material of whatever'S there
if(17<slot&&slot<27){ works but the item is null
I think i might need more of the code to check for some stuff
ok
int slot = event.getRawSlot();
if(18<slot&&slot<26){
Player player = (Player) event.getWhoClicked();
player.sendMessage("Stack at "+slot+" requested");
ItemStack stack = event.getInventory().getItem(slot);
player.sendMessage("Stack equals null result: "+(stack == null));}```
The real joke is that it tells me the id of the slot clicked but still tells me its null even if i am clicking onto an item
and the reason why I'm doing it this way is because i dont want to see a stacktrace every time it is null
couldnt you just do the ItemStack stack = event.getCurrentItem() to get the item?
as said before I need to get it with stack ids since the location is important. I also need to get the item to the right of that
you still have the id dont you
well yes but that still means throwing the slot id +1 into the function is returning null.
and i need to get the itemStack of that slot, too
try getClickedInventory()?
ok nice
thanks for the help i guess
on another tangent, getSlot and getRawSlot only equal in the player inventory right?
thats the difference
wdym
the 2016?
this is how i defined the vars
what name did you give the Scoreboard?
^
i mean the name of the scoreboard. did you include "2016" in the name?
no
oh ok
wow i got it working first time
well it seems to be that the health is 20 and the absorption is 16
yeah thats better. or you could just add them together
That still didn't help me with fixing my issue ;-;
if(event.getInventory().getType() != InventoryType.PLAYER) {return;}```
Why does that code say it's not a player inventory when I am clicking in my inventory
Are you clicking in your inventory while in creative mode?
What are you trying to do?
checking if i am clicking in the inventory
like i only want to trigger if i havent opened any crafting / storage windows
could someone let me a guide that explains how to set a command to an entity? pls
ah got it. It was getClickedInventory. Why thats different from getInventory in a inventoryClickEven beats me tho
So like you want to do something if it is not crafting/chest inventory?
nvm nice
What do you mean by setting a command to an entity?
for example
i'm creating a pl that creates an armour stand and has different options also i would like to add that the player can set a command when clicking on it
Write the commands in the PDC of the ArmorStand
PDC?
PersistentDataContainer
but the player can set/change a command there?
Sure
do you know any guide?
Point defense Cannon incoming
wha
XD
?pdc
Example:
private static final NamespacedKey COMMAND_KEY = NamespacedKey.fromString("test:command-key");
public void setCommand(final ArmorStand armorStand, final String command) {
final PersistentDataContainer container = armorStand.getPersistentDataContainer();
container.set(COMMAND_KEY, PersistentDataType.STRING, command);
}
public String getCommand(final ArmorStand armorStand) {
final PersistentDataContainer container = armorStand.getPersistentDataContainer();
return container.get(COMMAND_KEY, PersistentDataType.STRING);
}
you could also make the setCommand a boolean and make it return true if it was sucessfully set. (in case it already existed or something)
Anyone to help me with my issue?
need code to help you fix the mistake. it seems like your plugin instance is null
Your "plugin" field is null
ive had that a couple times when I set my instance = this in the onEnable at the wrong point
That is the weirdest part because this plugin was working perfectly fine before now suddenly it started giving this error
?paste the code?
private static BBCore plugin;
Discord Discord = new Discord();
public BBCore() throws LoginException {
}
@Override
public void onEnable() {
plugin = this;
Does your Discord constructor use the plugin field?
yes
Then plugin will always be null. onEnable is called much much later.
public BBCore plugin = BBCore.getPlugin();
private static BBCore plugin;
Discord discord;
@Override
public void onEnable() {
plugin = this;
discord = new Discord();
This should fix it
Hi! How can i execute this line of code as a player?
Rcd.setScore(1);
What is Rcd?
descriptive variables 101
@outer steeple
a score
` if (e.getHand().equals(EquipmentSlot.HAND)) {
if (a.equals(Action.RIGHT_CLICK_AIR)) {
player.sendMessage("rcd set to 1");
ScoreboardManager m = Bukkit.getScoreboardManager();
Scoreboard b = m.getNewScoreboard();
Objective o = b.registerNewObjective("Rcd","Rcd");
o.setDisplaySlot(DisplaySlot.SIDEBAR);
o.setDisplayName(ChatColor.DARK_AQUA +"Rcd");
Score Rcd = o.getScore(player);
Rcd.setScore(3);
player.setScoreboard(b);
}
}
}`
this is my code
i think i found it
Score Rcd = o.getScore(player); here i set the players score to 1 but i cant reset the score with a command for some reason
@opal juniper ?
how i could add nms classes using maven?
Ok
What do you mean by add them
i dont have the nms classes
what would be the best way to store a yml config file or a loot table type thing, then use this config to fill inventories in game with loot? i have been struggling with how i should do this.
i already do this but..
Show your pom
^
@opal juniper i fixed it. 🙂
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
have you run build tools
i tried but i get errhor
Well you need to install 1.12.2 to your m2
send me the run command to build tools
what is m2
Your local repository
what
java -jar BuildTools.jar --rev 1.12.2
dont worry about it
no
automatilly ?
ok
let it run
downloading git go brrr
hey mans
basically i want to use the registerEvent
but im trying to understand
what is an EventExecutor
i want to make like an event listener builder
so you can simply use
ListenerBuilder.event(EventClass.class).*other methods*.execution(event -> {});
with a player list heart scoreboard, is there a way to hide the empty hearts?

and now
it says "please wait" so just wait
Anyone know what the hit sound is?
Like which one in the Sound enum
I looked through pretty much all of them
no
?
Hey,
Do anyone know how I can get the ip adress and port of my bungeecord?
I want to get it in my bungeecord plugin.
Pretty sure it doesn't exist
Nvm it got added in 1.8.1
Anyway NMS might be the only option
Running into the issue where org.bukkit.plugin.Plugin.getDataFolder folder doesn't exist
How do I uh make it exist
do you have a config.yml in your jar?
Yes
then call saveDefaultConfig()
Woah it's actually a plugin.yml
Is that even a valid naming? Nvm it is for a different more critical purpose
So I made a plugin that just teleport players somewhere on the join event, however when players haven't been in the server yet they don't get teleported. Any clue as to why?
delay your teleport.
Hi, I'm trying to do a plugin that detects packets that takes a long time to process, how do I capture the time to handle for every packet or every event?
Do you happen to know the reasoning why it doesn't work?
Just curious
in the onJoin event the player is not fully logged in yet. If they have not been on the server before extra things have to happen like creating their data
delay teleport a few ticks and it will work fine
you should delay it for all players
Yeah I've delayed it with 5 ticks
have you tried to set max player health to something else
if this is dynamical to scaled player health its possible
why doesn't PlayerJoinEvent implement Cancellable :/
You should be using AsyncPlayerPreLoginEvent if you want to cancel
thats a point - i always forget about that one
CODE https://pastebin.com/jmsvgC5q
ERROR https://pastebin.com/eBRMEbHy
its a custom coded economy any idea how i fix or a alternative storage method?
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.
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.
um use json
Need full error
ok 1s
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.
So why aren't you using a database like sqlite or JSON
im not to sure how thats why
JsonObject jsonObject = new jsonObject();
jsonObject.addProperty(UUID.randomUUID(), 1);
try (FileWriter fileWriter = new FileWriter(jsonFile)) {
new Gson().toJson(jsonObject, fileWriter);
} catch (IOException e) {
...
}
how do i store and fetch the data?
This still doesn't look like the full error
there is no other [Server thread/WARN]
File jsonFile = new File("ex.json")
if (jsonFile.exists()) {
try (FileReader fileReader = new FileReader(jsonFile)) {
BufferedReader bufferedReader = new BufferedReader(fileReader);
JsonObject jsonObject = new JsonStreamParser(bufferedReader).next().getAsJsonObject();
jsonObject.get
...
} catch (IOException e) {
...
}
}
Those are 2 methods for saving + loading json
just examples
what would yall recommend SQL or JSON?
Both have their uses
SQL is good for when data is shared between servers/websites.
json is more simple
Hello, is it somehow possible to convert a WorldEdit-BlockState into a Bukkit-BlockState?
Look at BukkitAdapter
I would ask in the EngineHub discord
what causes less lag and less chance of overload?
wrong direction
Look at how it converts and reverse engineer it
bruh
Or ask Engine hub
Do some research!
I personally use JSON as I have no need for data to be stored in an external database and I haven't had a problem with it
Bytebuffers everywhere is my philosophy
lol
Do you need useless String concentration? No. Store the data raw
well worldedit is multiplatform plugin, so there should be some kind of wrapper for bukkit blockstates in worldedit source code somewhere
if there werent any blockstates for bukkit API there should be at least some kind of wrapper for NMS block data
which even that, could be converted to bukkit blockstates easily via craftbukkit ABI
Thanks 👍
Anyone know why PacketPlayOutEntityTeleport multiplies location values by 32?
it uses it for absolute positioning
anyone know how to create maps with gson
like
{
"something1": {
"something2": "something",
"something3": "something"
}
}
basically im taking two variables and trying to format them like that
lol rip dead support
literally first result:
Gson gson = new Gson();
String json = gson.toJson(myObject);
and it says it works for maps too
Always good to just do what you want in java and convert to json if you're not for sure
lol
so like i just do like String this = gson.toJson(thing) and then gson.toJson(this, writer)?
lol nope thats not it
"[\n {\n \"playeruuid\": \"10c85c47-62d3-404a-83bf-c344014e7e7b\",\n \"effect\": \"explosion\"\n }\n]"
this is my output lol
why isnt it converting the \n into lines
what is your map looking like?
like whats the type of the key and value
when i print it when its through toJson once, it almost does it right
@arctic moth create the Gson using GsonBuilder and disableHtmlEscaping
it does
[
{
"playeruuid": "10c85c47-62d3-404a-83bf-c344014e7e7b",
"effect": "random"
}
]
thats because you shouldnt covert it into string. if you're gonna write it to a file, only do gson.toJson
and also that too
lol
strange enough, i never had encountered this issue before
did you enable html escaping or something?
no
so i just want to do it like that but instead of those brackets i want curly brackets and ofc the map needs a key
@paper viper
public static void saveNotes() throws IOException {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
File file = new File(plugin.getDataFolder().getAbsolutePath() + "/playereffects.json");
file.getParentFile().mkdir();
file.createNewFile();
Writer writer = new FileWriter(file, false);
gson.toJson(notes, writer);
writer.flush();
writer.close();
}
public class Note {
private String playeruuid;
private String effect;
public String getPlayerUUID() {
return playeruuid;
}
public void setPlayerUUID(String playeruuid) {
this.playeruuid = playeruuid;
}
public String getEffect() {
return effect;
}
public void setEffect(String effect) {
this.effect = effect;
}
public Note(String playeruuid, String effect) {
this.playeruuid = playeruuid;
this.effect = effect;
}
}
couple things first tho.
- don't make your saveNotes() method static. it is not a utility method. Because it's void, it makes the method impure.
- use try-with-resources on your Writer.
new File(plugin.getDataFolder().getAbsolutePath(), "playereffects.json")instead ofnew File(plugin.getDataFolder().getAbsolutePath() + "/playereffects.json")- i have no idea what
notesis
and also, it seems to be static abuse, because the only way really is if notes is static too
lol
?
its gonna take u ages to fix that...
thats why you dont use it the first place
smh
btw notes is an arraylist that has all the notes to be added to the json
i did that just while i got the json set up
Ic
ill get from the json once that stuffs working
gtg brb
ping me with the answer so i can find it
im just confused on what you are doing...
that literally tells me nothing
i dont get what you are talking about and switching between maps, lists
idk what you are saying
can you give me a step by step thing of what you are doing?
you’re tryna save data to JSON?
I saw a good video on this actually
lol
Uhh lemme try find
what is your goal
like
your original intention
cause this is def an XY problem lmao
Java Tutorial showing you how to parse Simple Json String into POJO Objects.
We'll be using:
- IntelliJ Community Edition to code with: https://www.jetbrains.com/idea/download
- Maven to manage our dependencies: https://maven.apache.org/
Easy fix
i just need to store the uuid and effect of each player that joins the server
So just store a list
dude dont use jackson if gson is already in spigot
🤦♂️
Gson is great
Or use a ImutableMap<K,V>
Gson also works well with POJO for mongo
Yeah
Mongo can already handle POJO
I know
I don’t usually use json or gson.. kinda just use Mongo documents 🙌🏽
Well technically it’s JSON but like
Shush
Gson is a library for working with JSON
I just like serialization better for GSON
^
isnt mongo like a database thing
yes
like mongodb
wait i think ik an ez solution but idk if it works with gson
cuz i would rlly only need uuid : effect
but the thing is gson uses a variable for the key
anyone know a workaround?
@paper viper or someone
lol srry i keep pinging u
but im so impatient
ik in python its simple af to do that but idk how to get that to work with gson
lol
Hello
It is very simple in java also
I want to check if the block a mob moves through or is standing on (A bee) is air. I have done CAVE_AIR, AIR and VOID_AIR but won't work for some reason
https://www.youtube.com/watch?v=BbI8FdQOKNs This guy is probably the best to know how gson works.
In this video you'll get started with Gson. Gson is a library to (de)serialize JSON from and to Java objects:
►Introduction: [0:07]
►Gson Setup: [1:15]
►JSON Basics: [1:57]
►Serialization (from Java object to JSON): [4:21]
►Deserialization (from JSON to Java object): [6:52]
►Summary: [8:54]
Tip: turn on subtitles to deal with my accent. A short...
?xy
Asking about your attempted solution rather than your actual problem
Is there a way to make an armorstand look like it's moving forward? I currently have it so that it gets teleported forward every tick, is there a better way to do it?
add velocity to it
I have a runTaskLater task, which sends a player a message after 60 seconds. If the player goes offline before it sends the message, will it throw an error after the 60 seconds?
Do I have to check if fromPlayer and playerTo are still online?
fromPlayer.sendMessage(colorCode("&cA duel request to &6" + playerTo.getName() + "&c expired."));
When I don't do it, it doesn't move java new BukkitRunnable() { int counter = 0; private Vector vector; @Override public void run() { if (counter == 0) { vector = skull.getLocation().getDirection(); } if (counter == 50) { this.cancel(); } counter++; skull.setRotation(counter * 20, counter * 20); skull.setVelocity(vector);
normalize it
It still won't move if I do that
you're just rotating it
that's a different thing
I want it to move while rotating
and that part works when I teleport it every tick
is there a decently easy method to switch bungeecord servers without having the dirt background with the "loading world"?
give ur players a great pc
the loading background is for: changing world, server, joining server,... and default in mc. but if a pc is good enough, the time they appear is very, like very little
like only 5 to 10 frames
thanks but that does not answer my question
what if i don't tell the client to load the world and instead just replace the blocks in the current world?
will it work?
:(
that's an idea I've had for years
never reconnect someone, just fake all the chunk data around them
I'd be very surprised no one has done a proof of concept by now
?
😂
The changing screen is so quick it's not worth it
You'd just be replacing it with a flash to void
?paste
does anyone sees something i can make better?
https://paste.md-5.net/maqixagaji.java
Why is blockowner a field
Hi! Is there any way to check recently created threads? Like you get from crash reports, but without actually crashing the server? Thanks
Thread.getAllStackTraces().keySet() mb
then I guess you could check its state
idk if there an actual way to check when they were created
Alright, thanks!
How do I check if a value in a int[] array is set
if I do (new int[69])[6] it gives 0 even if I don’t set it so how do I check if I actually set it
I don't think i have any errors with this right?
SpawnRemove spawnRemove;
SpawnSet spawnSet;
PlayerDamagePlayer playerDamagePlayer;
PlayerDeathRespawn playerDeathRespawn;
PlayerJoinLeave playerJoinLeave;
Language language;
LocationsData locationsData;
PlayerData playerData;
LangUtil langUtil;
FantomUtils fantomUtils;
LocationsUtils locationsUtils;
@Override
public void onEnable() {
spawnRemove = new SpawnRemove(this, locationsData, langUtil, locationsUtils);
spawnSet = new SpawnSet(this, locationsData, langUtil, locationsUtils);
playerDamagePlayer = new PlayerDamagePlayer(this, fantomUtils, langUtil);
playerDeathRespawn = new PlayerDeathRespawn(this, locationsData, fantomUtils, langUtil);
playerJoinLeave = new PlayerJoinLeave(this, fantomUtils);
language = new Language(this);
locationsData = new LocationsData(this);
playerData = new PlayerData(this);
langUtil = new LangUtil(this, language);
locationsUtils = new LocationsUtils(this, locationsData);
fantomUtils = new FantomUtils(this, playerData);```
in my constructor in other class it still the normal null error...
wdym null error
cant invoke this because this is null, just a basic error
but i cant even figure it out 😂
nvm wrong language
primitive arrays are always initialized with a "default" value, which is 0 in this case. If you need three states, you can use the class equivalent - so Integer[] - which would be filled with null. alternatively you could set the values to -1 initially and consider that your "unset" value
which one is erroring
thanks
that assumes that -1 would otherwise be an invalid number
you're initializing things that use other things before those other things are initialized
Does anyone have a simple example of dependency injection (dont throw me the spigot wiki)
The basic concept
MainClass.java
private ConfigRegistry registry;
public class MainClass extends JavaPlugin {
@Override
public void onEnable() {
this.registry = new ConfigRegistry(this);
Configuration config = this.registry.load("exampleconfig.yml");
}
@Nullable
public ConfigRegistry getConfigRegistry() {
return this.registry;
}
}
ConfigManager.java
public class ConfigRegistry {
private final JavaPlugin plugin;
public ConfigRegistry(JavaPlugin plugin) {
Objects.requireNonNull(plugin, "Failed to construct configuration registry! JavaPlugin object cannot be null!");
this.plugin = plugin;
}
// String path or URL path, doesnt matter, its an example.
@Nullable
public Configuration loadConfig(String path) {
// Your code for loading config, by getting the main plugin config via. this.plugin.getConfig()
}
}
Basically dependency injection is the design principle where you pass the required the objects in constructor arguments or set the depedencies of the object via setters, rather than accesing them via static fields or making the object create the object for himself.
Oh ok thank you
its used to tighten your code, aka to make it more encapsulated
and its easier to read the code, because searching what static method returns is not fun and kinda slower
- 90% of the people in this discord will yell at you they see it (sometimes referred to as static abuse depending on the circumstance)
although only about 0.5% of that 90% actually have an idea of why its considered bad and what cases its fine
oh ok lol
There are very specific use cases for static
utility classes for example
I only really use them for utilities which is an acceptable use
statics are like functions in c
they could be accessed almost everywhere
if its included as an include inside the file
if you have a class that is instanced in a lot of places but has a field you need to be the same across all, like a Map, then you'd make teh Map private static
