#help-development
1 messages Ā· Page 219 of 1
you might want to consider saving your data in yml instead of pdc too
Why do you need to copy the pdc?
im making an item builder
im still wondering what the purpose of this method is https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataContainer.html#getAdapterContext()
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
and i combine everything on build step
Then you can just keep track of the data types
?
it is for serializing and deserializing
what am i gonna set the key to then
To what ever the input was to the item builder
but then i must keep track of 3 things no?
builder.pdc(key, type, value) and track that
i guess it has its purpose on the craftbukkit side
yes
but map has two entries only
then make a map with two entries š¤·āāļø
You can use 2 maps or create an object
or when you want to transfer the data to somewhere else or need to convey the data to something else, makes it easier to serialize that data to do so
oh good idea olivo
it has only one method so how
hmm i think i start understanding
Hey, I'm kinda struggling on how to make animal attack players with pathfinder, I manage to make the animal (i'm testing with sheep) aggressive towards player but it doesn't attack at all.
This is the code: https://paste.md-5.net/yepumudiru.css
When I try to build with maven (I'm using remapped 1.17) I get this error
How to fix it ?
Send your pom
(why specifically 1.17, isnt latest minor ver 1.17.1?)
alright wait
hey, im trying to build a 1.8.8 with buildtools but get following error:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1914) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1512) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268) at java.net.URL.openStream(URL.java:1092) at com.google.common.io.Resources$UrlByteSource.openStream(Resources.java:72) at com.google.common.io.ByteSource.read(ByteSource.java:296) at com.google.common.io.Resources.toByteArray(Resources.java:98) at org.spigotmc.builder.Builder.download(Builder.java:1083) at org.spigotmc.builder.Builder.main(Builder.java:416) at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
Mojang has moved their downloads of old versions so it broke stuff. Good time to update
update buildtools
should have the latest version
Well you donāt
That also doesn't work with 1.18.2
didnt methods change in 1.18?
Have you ran BuildTools?
methods of remapping
i did for 1.17
With the remapped argument
Yeh
Also why would it work on 1.18.2 if you haven't run BuildTools
I built all versions
Did you reload your pom after editing it
Yep
mongo weird
You can still do that in one operation though
thats what verano said and i didnnt find it tho
if i have this kind of setup where homes is a collection
lets follow copilot ig
If this is accepting user input
Make sure sql injection is not possible
sql injection in mongodb hmm yes
MongoDB doesn't use SQL
from now on my name is fourteendoggo'; drop tables users -- :)
Lol
You can give a player the book and tell them to write in it
Opening the book menu only works with signed books as far as I'm aware
Give the player a book and quil
Send them a message
Then listen to the https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerEditBookEvent.html
declaration: package: org.bukkit.event.player, class: PlayerEditBookEvent
As I said you tell them to open it
.
No
is there crouch check the easy way?
or i must keep track myself
ah i mustve missed it
thx
why does i have this error java.lang.ClassNotFoundException: com.mongodb.client.MongoClients whereas Mongo is shaded inside jar
because
when i do mvn clean install i have org.mongodb:mongo-java-driver:jar:3.12.11 in the shaded jar.
idk if it's that
i just have my package
in hastebin ?
because
[13:52:02 ERROR]: Couldn't pass ProxyInitializeEvent to hc_proxylogin
java.lang.NoClassDefFoundError: com/mongodb/client/MongoClients
at fr.fokpi.hcproxylogin.manager.StartupManager.load(StartupManager.java:13) ~[?:?]
at fr.fokpi.hcproxylogin.HCProxyLogin.onProxyInitialization(HCProxyLogin.java:41) ~[?:?]
at fr.fokpi.hcproxylogin.Lmbda$1.execute(Unknown Source) ~[?:?]
at com.velocitypowered.proxy.event.UntargetedEventHandler$VoidHandler.lambda$buildHandler$0(UntargetedEventHandler.java:47) ~[velocity.jar:3.1.1]
at com.velocitypowered.proxy.event.VelocityEventManager.fire(VelocityEventManager.java:598) ~[velocity.jar:3.1.1]
at com.velocitypowered.proxy.event.VelocityEventManager.lambda$fire$5(VelocityEventManager.java:479) ~[velocity.jar:3.1.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: com.mongodb.client.MongoClients
at com.velocitypowered.proxy.plugin.PluginClassLoader.loadClass0(PluginClassLoader.java:83) ~[velocity.jar:3.1.1]
at com.velocitypowered.proxy.plugin.PluginClassLoader.loadClass(PluginClassLoader.java:60) ~[velocity.jar:3.1.1]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 9 more
u think i need to add mongodb in artifact ?
i just click on build and build artifact
yes
i already have clean package
Is possible to give the same visual effect has when getting in spectator mode and becoming a mob like the creeper'
?
i did that and after i need to build artifact ?
i have HCProxyLogin-devBuild and original-HCProxyLogin-devBuild
but hcproxylogin-devbuild size is 17Mo because it have all dependency
iirc maven shade has a minimize option
yes thx a lot and there is a way to shade just one dependency ?
because the rest is already included
whats the diff between
Bukkit.getServer()#dispatchCommand(player, "spawn")
and
Player#performCommand("spawn")
Probably nothing
one calls the other
lol
and if command is not registered i need to force player to say something with / right?
ye
type deal
idfk how it works
I just remember forced commands not firing events
because the commandmanager was jank
so I had to make my own command map class
Is there a way to get the name of an offlineplayer just by his UUID?
not anymore I'm pretty sure mojang got rid of that API \
oh interesting
Yeah but the player could be offline since 3 weeks
They didn't
And I still need his name
You can make a request to mojang servers
I thought they removed the one that allowed quereing requests to mojang servers due to user privacy no
so there is no way todo it with just spigot?
Name history got removed. You can still see the current name
ahhh ok
Try using getName on the offline player
Okay thx
It might work if the player has joined before
Yeah he has to be
What version
^^
Protocollib can do it
how can i do it with protocollib
can i detect when player take item from creative inventory (if i can how? ) ?
i can only change it on login or anytime while the player is online?
declaration: package: org.bukkit.event.inventory, class: InventoryCreativeEvent
i guess
You can't
Creative mode is stupid
It's very client-authoritative and hardly tells the server anything at all
thanks
packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME);
ArrayList<PlayerInfoData> pd = new ArrayList<PlayerInfoData>();
WrappedGameProfile profile = new WrappedGameProfile(player.getUniqueId(), name);
WrappedChatComponent name2 = WrappedChatComponent.fromText(name);
pd.add(new PlayerInfoData(profile, 0, EnumWrappers.NativeGameMode.SURVIVAL, name2));
packet.getPlayerInfoDataLists().write(0, pd);
try {
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
ProtocolLibrary.getProtocolManager().sendServerPacket(p, packet);
}
} catch (InvocationTargetException e) {
e.printStackTrace();
}```
shouldnt this update the nametag?
anyone can help
....
i just did and it didnt work
thats why i ask
if anyone know how can i chnage a player's nametag please tell me
i cant seem to find anything anywhere
this just changed the tab name btw
wdym
Look at and already existing plugin and see how they do it
Or try figuring it out by looking at mc source
https://paste.md-5.net/acepijexog.java dont question the jank or unfinished parts or broadcast messages, but for some reason my for loop will only run twice from the messages and then does nothing else
ive beein searching everything i could for 2 hours+, even source codes, nothing helped. so if its possible to do that, any help would be appreciated
i can get how many block is specific biome from 0 0 ?
aight if anyone can help me on that just ping me
ig i cant do anything else
havent looked into this at all, but have you tried Player#setDisplayName?
yes didnt work at all
how can i do that?
Reflection
it is posible?
anyone have any idea why invStack could be null, it worked before even if the item was nothing
Bukkit can be a bit inconsistent when it comes to air item and null
So always check both
wait this makes teams prefixes and suffixes not to work?
try {
Field field = gameProfile.getClass().getDeclaredField("name");
field.setAccessible(true);
field.set(gameProfile, name);
} catch (Exception e) {
e.printStackTrace();
}
for(Player p : Bukkit.getServer().getOnlinePlayers()) {
p.hidePlayer(player);
p.showPlayer(player);
}```
Wdym?
Yeah prefixes and teams are name based
You will need to modify the teams as well
how can i check if a player enters the bed? whats the eventhander for that?
what should i modify
PlayerEnterBedEvent
The team members
thank you
or is this sth else
Yeah
oh ok
And the entry should be the player name
How to make short dash?
I mean not speed effect for short time,
If you click, it moves quickly to direction of the vector you're looking at
names cant be colored right?
They can
Use the teams
aight
Change the player velocity
Isn't Velocity the value used when player moved by Arrow key?
You can add to the players current velocity to launch them
will the player be abble to dash up? if yes do p.setVelocity(p.getEyeLocation().getDirection().multiply(int));
something like this
sender.sendMessage("§4§lUsage: /gamemode <creative,survival,spectator,adventure> " + ((if (sender instanceof Player)) ? "<player>" : "[player]"));
I think i'm losing it, I cant see any errors in this
And what is the problem
^
Anyone here have experience with the InventoryCreativeEvent
you have an extra parentheses
I do?
closing, at the end
ugh discord messed that up
oh lol
I am just extremely blind
sender.sendMessage("§4§lUsage: /gamemode <creative,survival,spectator,adventure> " + (sender instanceof Player ? "<player>" : "[player]"));
ye
you have to do it like that @wary topaz
thanks
Would anyone here happen to have experience with the InventoryCreativeEvent
Specifically detecting when a player either takes an item from the inventory or deletes an item through the inventory
getComputedBiome vs getBiome ?
anyone use google sites? i gotta a 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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
One does not exist in the spigot api the other one does
thanks
A player picking up an item from a slot counts as deleting the item
oh yeah, and I already detect that so thats not a worry then
wait- I already have that all covered then :o
I just need to deal with commands
how might I have a scoreboard that keeps track of a score when a certain event happens
lol oddly specific
can anyone herlp with reading item stacks from config
error or anything?
last img
says "is is null"
first image shows "is"
s is just
wait lemme send better
lol
Show the code where is is null
but how do i read from file
lol
i saved itemstack on file no?
or is it saved wrong did i miss something
u can check now
can I dm you about setting up vsc for java? lmao
nvm i think it was one of the items cus of material type
didnt wrk
you do you, but really wouldn't recommend it
intellij is built for java, vsc is not
anyone good with regex
Pattern.compile("<delay=([^<>]+)>", 2); I got this code and I understand most of it but can't figure out what would it be this <>
square brackets will match any of the characters inside
the ^ at the front will 'invert' the characters
so [^<>] will match any character that isn't a gt/lt sign
although by default regex is greedy so I don't think thats needed? .+ would work too
he says
thanks
using a flag of 2 is really disgusting
anyone know if i can make my gradle build script run a command/type in the terminal
How can i give more armor protection points to a armor?
thats useful as hell
anyone that's reading the code has to look up what the value of each of the escapes are and manually work out the bitmask in their head
š¤¢
for the most part gradle docs are very good
exec is nice
gradle > maven
boutta make a project that nukes your pc if you compile it
You need to save and paste the link here
?nohello
give them chance hes hopefully typing a question ahah
lol
h
Had a feeling you would send that lmao
lmao
im currently trying to compile my project using nms and maven and it says it cannot accesss the specified classes. i've gone through the 1.17 release thread and tried using the remapped mojang classifer as well as the SpecialSource maven plugin but it cannot retrieve the jar from anywhere
i already ran buildtools 1.19 with --remapped flag but it doesn't seem to recognize it
p sure maven's trying to pull the jar from my local m2 repo org/spigotmc/spigot/jar/... instead of org/spigotmc/spigot/...
yes there it is
what do you mean by doesn't recognise it
it can't find the artifact
Could not find artifact org.spigotmc:spigot:jar:remapped-mojang:1.19-R0.1-SNAPSHOT
Try to run Maven import with -U flag (force update snapshots)
i haven't actually used special source with maven but on first glance the pom looks okay?
does build tools run successfully?
yup
Make sure you ran BuildTools for 1.19 and not 1.19.2
Also make sure BuildTools has finished running
i'll rerun buildtools and give it a shot
what command are you running?
Olivo was right, i was running buildtools for 1.19.2, my apologies
Keep in mind your plugin may not support 1.19.2 now
why isn't this working?
public static void createEntityPacket(String name, Location location, List<Player> players) {
World world = ((CraftWorld) location.getWorld()).getHandle();
EntityArmorStand armorStand = new EntityArmorStand(world, location.getX(), location.getY(), location.getZ());
armorStand.setInvisible(true);
armorStand.setNoGravity(true);
armorStand.setCustomNameVisible(true);
armorStand.setCustomName(IChatBaseComponent.a(name));
players.forEach(player -> {
((CraftPlayer) player).getHandle().b.sendPacket(new PacketPlayOutSpawnEntityLiving(armorStand));
});
}```
spawns but doesn't set name or invisible
im pretty sure that all the other data is sent in the metadata packet
No ask here I'll respond when I can
even after fixing my nms dependency it seems to have the same effect upon compilation
cannot access com.mojang.authlib.GameProfile
game profile isn't a part of spigot anymore as far as im aware
and how would i display that
gradle docs are weird and really dont supply much info, Do you know if workingDir wants the cmd location or java file location then am i correct in saying commandLine("my command to send in cmd") should be ran
the dependency already comes bundled with nms dependency doesn't it
it will be what all the other paths are relative to
so if you are trying to run a server, you would want the workingdir to be the server root because that's where the server looks for files, and then the commandLine would be relative to the workingdir
anyone :/
yep
don't have an ide open so I don't know what it relates to in nms
im trying to make it auto reload the plugin (with plugwoman) in an already running cmd instances
what the flying fuck are you on about
then you wouldn't be running a command in the command line
only way I can think to do it is with RCON or I imagine there would be a way to attach itself to a currently running process similar to how intellij debugger works?
but that's getting pretty involved for a gradle task
I'm too lazy to right click to reply to messages so hopefully it's clear who im talking to
if intellij run configs had a method for running something in terminal i could probably just boot a server in intellij and do it that way
but sadly they dont, only debug stuff and i dont think that has any way to run stuff in the terminal either
you most certainly can run a server through intellij
just couldnt find anything on the run config to do anything in it
I misread that
okay i got
players.forEach(player -> {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
entityPlayer.b.sendPacket(new PacketPlayOutEntityMetadata(armorStand.getId(), entityPlayer.getDataWatcher(), true));
entityPlayer.b.sendPacket(new PacketPlayOutSpawnEntityLiving(armorStand));
});``` but still don't work
I think easiest way would be through RCON honestly, but I think the protocol is pretty complicated to work with using the standard java library
are you using groovy or gradle dls?
i just found a config for "Remote JVM Debug" so i guess i could connect through that
potentially?
depends if you want to go through intellij or gradle
lemme open intellij
if i could figure out anyway to make it just run 1 command in cmd or terminal or RCON would make it so much easier debug'ing this plugin
if manually reloading is impacting you that much, maybe the easier solution would be to find a way to not have to reload so much
you said you are debugging, what are you debugging?
ive got a for loop to go over a players inv to check for an item when they right click
checking its a specific item, it should be so it removes it and replaces it for another
although I guess its just a programmer mentality to spend more time trying to automate a solution, when doing it manually for as long as you needed to would be faster
except its saying that item isnt correct
I can almost guarantee that would be easier
intellij debugger is amazing
you can either attach it to the task (remote or local) or just straightup launch the server with an intellij build conf
and then debug rather than run
place breakpoints where you need to and step through each line of code, and it will tell you what the value is of each variable and what the return of each line is
i found an ij plugin like a month ago that had options for reloading the plugin except it booted the server with gui and i cant remember the name of it
bloat imo
learn to use the intellij debugger properly and it will make your life easier
hello devs , i have a question does java 17 support :
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
i think so
java 17 ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
i get this error :#
java 17 ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
alr bet, were you able to setup a custom maven project for spigot plugins?
i wanna make like a template so I don't have to re-set it up everytime
You need to load the mysql dependency. Either shade it or use the libraries section of the plugins.yml
but it works fine for 1.8.8 paper
that use java 8 ..
It shouldn't have anything to do with the Java version
then is it something to do with minecraft server versions?
It was probably included with Paper back then but not anymore
oh what should i use then?
i do remember jdbc being included before
something that work on all versions ..?
Shade and relocate the dependency
thanks
Doesn't support all versions
ah yes missed that
is there a way to use custom models / textures with spigot?
You can use a resource pack
hm
Make a maven archetype can't help you from there I forgot how its been ages
Yeah I just use the Minecraft development plugin for Intellij
So I've also forgotten how to make an archetype ;/
How can i set i item unbreakble with nbtCompounds?
Set the unbreakable flag to true
Not sure why you want to use nms for that though
I wrote it wrong and was not working
Hey.. I made a Server on pebblehost today and put in my plugins. all worked until it stoped to give me the config data... now I can't config my plugins anymore when I put them in and Idk what to do
What does it say in the logs
Also this is a question for #help-server
oh damn I'm sorry
nothing actually
anyone have any ideas why my for loop on a players inventory (with null/air check) is only running 3 times
?paste code
Inventory playerInventory = event.getPlayer().getInventory();
Send the entire method
How many items are in your inventory
i did not know that Inventory was a Iterable<ItemStack> wow
You're beaking at first air
Iām interested in making a sort of chest locking plugin where the player sets an item pattern in a popup inventory. In turn, when that pattern is entered correctly it opens the chest inventory they were originally trying to lock. How would I go at storing each individual item pattern, as well as the actual chest theyāre bringing up?
Would I do that with a hash map of uuids and j have a separate item stack array as the uuids matching value?
also feel like there is a lot of code duplication here, there's probably a way to clean this up by moving it to a method or something similar
You can use PDC
?pdc
yeah, was just getting it to work before i unjankified it
Would this be a valid approach though?
What if I write it into a config file?
Which would create a new key for each uuid and j store their items that way
Or is that just an overly complicated way of doing it when I could j use this
using a pdc is a lot less complicated and is a lot less error prone than serialising the hashmap into a config
How can i get a player current generic.armor point?
Okay
Thank u both
Player#getAttribute(Attribute.GENERIC_ARMOR)
I created a armor witch changes the player Generic_armor when a player wears it but it doesn' t add it
How can i make it add
does anyone use google sites?
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
deja vu
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
I have another question pls how can I know where a player execute a command?
Eh how do I check for every single ore type if they are broken?
Kinda donāt wanna do
If (event.getBlock().equals(Material.COAL_ORE) or ā¦ā¦ā¦)
Do I make a list or something?
What version are you making the plugin for?
Why is my tps on 17.11 but my servers uses 3 cores out of 6? and the RAM uses 3GB out of 10?
wtf
hello loveley people does someone know a plugin that makes furnaces faster and hoppers faster?
because the TPS has nothing to do with your cores or RAM
but why is it sinking?
probably a plugin which "skips" ticks
the server doenst use all performance
like slowing down, blocking
and since there is no "hey, you lost a tick, here, i got it for you" mechanism, it just continues
so it skips the ticks it couldnt process
and that leads to a lower TPS
how do i make my server load slow chunks?
like slow chunk loading so my tps doesnt drop
still #help-server
oh okay
is it lagging with the low tps or not?
most likely
and how can i fix it? xd
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yes it can have but most likely not
Minecraft uses mostly 1 core, so having 100x cores wont help, you need fast singlecore to have good peformance
lagging can be caused by multiplw things, if ur processor is slow, some plugins have memory leaks or i/o blocking operations
Hello, how can I make this event only work in an allowed world?
public void killEvent(PlayerDeathEvent e) {
String PitchMain = (this.config.getString("KillEvent.Pitch"));
Player killed = e.getEntity();
if (killed.getKiller() instanceof Player) {
Player killer = killed.getKiller();
killer.setHealth(Double.parseDouble(this.config.getConfig().getString("KillEvent.Vida")));
killer.playSound(killer.getLocation(), Sound.valueOf(this.config.getString("KillEvent.Sonido").toUpperCase()), 10.0F, Float.parseFloat(PitchMain));
}
}```
if config.getConfig().getStringList("allowed-worlds").contains(killed.getWorld().getName()))
hello everyone it seems that i am having trouble with this project, ive tried lots of ways to fix it but sadly none of them worked, I made a killstreak code, but i think this code will not work because it doesn't check if the killer dies properly so the killestreak can reset, anyone know how to fix it and make it functional?
Code:
@EventHandler
public void onPlayerDeath(PlayerDeathEvent pde){
Player victim= pde.getEntity().getPlayer();
Player killer = pde.getEntity().getKiller();
if(killer instanceof Player){
killstreak ++;
if(killstreak == 2){
//
killer.getWorld().dropItem(killer.getLocation(),new ItemStack(Material.DIAMOND));
killer.getKiller().getKiller().getKiller().spawnParticle(PAR);
}
if(killer.isDead()) {
killstreak = 0;
}
}
else {
return;
}
}```
edit: ignore the particle summoning line of code, that was just a test
yeah there probably is lol
that defenitly helped :D
Use a Map<UUID, Integer> to store the killstreaks for each player
You can't store everyone's killstreak using one variable
Maybe something called collections
Could be that as well but i feel like ppl understand arrays and lists but not maps
Yeah maps are more default
Because they are hash table based
oh ok that makes alot more sense, since its similar to an array and can store data for multiple players + thanks!
šš
For every death event make sure to reset the killstreak of the player that died
yep
Then check if the killer is not null
gotchya thanks!
If it is not null you can add 1 to the killers streak
mhm
If the killer is null that means that the player didn't die to a player
Is there any utility method, which allow to evaluate a condition and allows you to run actions depending if the condition is true or false?
You mean like an if statement?
lol
Thank you!!
im in my main class and im tryibng to make a hashmap but it doesn't allow me to use "Public"
Lower case p for public
An you can't use public inside other methods. So move it outside the onEnable() method
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.
I think Udemy should be on that learnjava link, it may be paid courses but they are really insightful haha. It's where I learned a heap of it.
What would .save be replaced with?
https://mclo.gs/DEqcpNN This is what I used for file creation. May not be the best way but it does work well.
its a txt file though
https://www.w3schools.com/java/java_files_create.asp
I think this might do the thingm
not sure though
The class I sent you should still work. As it doesn't specify the file type. You do that when you call the methods to create the files
oh alr thanks
Since this is now deprecated, how do I register a new objective?
https://github.com/OmegaWeaponDev/Stylizer/blob/master/src/main/java/me/omegaweapondev/stylizer/utilities/SettingsHandler.java Here's an example of how it's used.
What do I put in the Criteria.createa()?
Well I just want to make a simple scoreboard
So just Criteria.Dummy?
It's only an example. Don't copy paste the full thing. Just the methods. AS it's apart of a custom library that I use
o
Hello guys, I'm trying to create a command in my main class, but it is asking me for a parameter and I don't know which one (I'm kinda new in parameters)
I always use my plugins Name as the main class š
Like 99% of people do xD
People are silly if they don't
how is it static abuse?
That last command, you didnt add the params
Naming a variable variable is a bad idea. It will be confusing and is too generic. It does not tell you what the variable is.
If I wanted to register the command on the variable, how could I do it? I'm kinda new
Alright, I'll keep it in mind then c;
something similar, but with less lines hahaha
So the best is to name the variable what they store?
ternary operator?
Yes. Like if it's a variable for warps. You call it warps or similar. So you can tell what the variable is by it's name without needing to find it's declaration just to see what it is
Also please fallow the ?conventions
Yeah something like that, but ternary is for operations which returns something
Thank you so much for the advices!
Thank you so much! this is a good way to reduce code
No but, I call the variable
So I don't have to write all the thing
again
What did I do wrong :c
variable aint an object (technically it can be, but this is an easy definition for someone that doesn't fully know java)
?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.
do i have to pass a hashmap to an events class for it to work
Thank you
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Again, rename that variable. It's bad naming conventions
there c;
Fixed!
Thank you c;
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.
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. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
change listarWarps to listarwarps (no captial in command names)
Any idea where spigot handles default values for config (ie when config.yml doesn't have some value but inside of resources folder it has)
It's not saving my warps
D;
No I mean, I'm trying to create warps (/setwarp "Name") and then add it to an arraylist, so that when I execute (/listarwarps) it shows me all the saved warps
This is my code for adding warps to an arraylist
is there an event if you shift an item into another container?
like shifting item in chest
Best way to do it, is when you start the server, load the warps into a map from the file, then access them from that map. When you stop the server, save the map contents to a file.
Hmmm yes, but this would be for keeping them in the server right?
Even if it closes
what about the /listarwarps command
If the server closes, it should save the warps that are in the map to a file. Then pulls them from the config into the map on start.
thx
That way it isn't constantly reading to a file. Which can save on performance slightly.
Oh that's a nice point
But, right now I executed (/setwarp (name)) command
Can't find the proper Criteria for a scoreboard.
And when I want it to show me the saved warps (the arraylist)
there's nothin there
:c
show us where you're listing the warps
If it's only a small amount of reading an not all the time, no you won't see a difference. But Aside from performance, it's also good coding convention.
You mean where the arraylist is?
can u get the title from the Inventory class somehow?
No I mean the command that lists the warps, you only showed us the command that creates them
Yeah, it's probably because you are passing a new warps instance rather than the same one.
pass warpList instead of a new instance that should solve your issue
?learnjava! moment again
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. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
Ok let's see if I understood this, when I get a command and I say (new) I'm meaning that when the user executes that command It's gonna "start" a new method
Alright, that's a bit clearer, anyways I'll have to continue practicing
Thank you so much guys ā¤ļø
This is the first "Plugin" I'm making and I'm trying to create anything that comes to my mind on it
no true
Pro Tip: Don't over complicate a plugin at the start. Add the main crucial features first. Once testing and working as expected. Then you can expand to more optional features.
Yes! Well, the first thing my plugin had was, a command to change your nick with colours and all that stuff
It works propperly on that
okay...
Now I wanted to use a bit of OOP, (which is the course I'm seeing in the University)
There's just a few things that I have to understand, first, how instances work (I mean, the point you just showed me about sending something to the first instance and not showing in the second) and second the "this"
Thank you c;
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Saved c;
di is the main part you need to understand really.
can i get the final slot of the item which got moved?
Alright I will read all the documentation you guys sent me
So that I can understand and get many things clear
Thank you guys for the support ā¤ļø
That's a nice advice! I use to mostly spend my night time coding, and only 3 days ago I began with the creation of plugins
I just made a new teleport command to the created warps! It's working!
FREE JAVA LESSONS
^don't mind this dude, he's inferior
it's odd
basically uses reflections to analyze the class
- Grab the class
- Get all methods annotated by @EventHandler
- Get their params
\-> If, the param length is not 1, or the first param can't be assigned to an Event, we throw an error message
\-> Otherwise, we wrap it around a RegisteredListener and stick it in the HandlerList
If I ever wanted to recreate Hypixelās friend system. What should I do if player A removes player B? I know this could be easy if I take player B from database and remove their friendship but what if player B is already online?
How can I communicate my plugin with all servers inside a network?
this is why you use Redis as a cache
And why you should start from the bottom and learn your way up instead of copying hypixel from scratch with no experience
Iāll be honest, itās not even related to a friends system nor a Hypixel gamemode but I found that the issue is in common with it.
Okay
Well, friendships are relations
so we can start by using a relational database, like SQL
and you want to let player B know that he got removed or what?
How can I host redis? I mean, Pterodactyl and Multicraft gives you MySQL databases but how can I get redis?
Redis is always used as an intermediary cache as it has a lower latency
I mean, how can normal people without coding experience get in hands of redis?
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker
if a server is distributed it most likely needs redis anyways
for things like RedisBungee
I have a dude with github
Why github is not opening pull request for merging when working on the dev branch?
By any chance. Any body knows a cheap Redis hosting? lol
raspberry!!!
š¤£
I mean for normal people
Its the chepest option
I mean to use this in a Spigot plugin
but they cost like 100$ us
but small
not everyone can get them
What about that 13 yo kid who just prefers to host everything online?
Oh lmao i thought they were like 20-30$
I would try using the redis atlas/cloud
They give access to 1 redis db
I mean, the same way there are Minecraft hostings, there should be redis hostings š¤Ø
pretty sure you can get a free cloud
and you can self-host too
indeed
Is it possible to self host through a bungee plugin? lol
some host provide them
obviously not
this dude is trying to make hytale
hahaha
just accept that some of your users are not gonna have redis and your customer base will be slightly reduced
or... make your own impl for broke people
Because bungee doesnt its not sincronized with severs directly
bungee can be bypassed in a weird way
like it just serves as a link between servers but spigot doesn't know what bungees it belongs to, natively
ImLUssion ping spoof, Ping spoof Imlussion
no comment.
no
no you don't
Yes laddy
I need you to help with the chaineable
š
I have everything else working
Just unable to make the chaineable thing
Also shity github, for none reason is not doing any more merge pull request into main brainch automatically
š”
if (plugin.getResource("rules.txt") == null) {
It does not accept .exists so how do I check if its not a thing?>
It's nullable, so that's right
hasnt created the file
let me send the code
plugin.saveResource("rules.txt", false);
} else {
sender.sendMessage("ok");
}```
JavaPlugin#getResource() is nullable
?jd-s
do not repeat.
oh. Are you trying to check if the rules.txt exists in the plugins/YourPlugin dir?
yes
Do u want to use my file handler tho? https://paste.md-5.net/eponaroraz.java
thank you verano
//Create a reference to textfile.txt
File myfile = new File("files/textfile.txt");
//Check if textfile.txt exists in the referenced location
if(myfile.exists())
{
//textfile.txt exists, so it can be opened
}
else
{
//textfile.txt does not exist
}
Use something like this.
wait thats yaml config
Because it's a rules file. txt is fine
its a rules file
rules.yml xd
how do I set where I want to rules file goes to it just goes to my server file not resource
wouldnt work
You can check if Files#notExists() instead for an in-line without having to create a File instance
Didn't I give you a copy of what I use for files. Just use something similar to what I showed you.
Nvm
if (Files.notExists(plugin.getDataFolder().toPath().resolve("rules.txt")))
i didnt understand where to put it
pd: Only java 14 up
What?
thanks choco š
The NIO Files class has been in the JDK since Java 7 ;p
It's actually technically the preferred file system API
One of the most obnoxious things about saveResource() tbh
You have to do that file check yourself and just not call saveResource()
https://mclo.gs/DEqcpNN
https://github.com/OmegaWeaponDev/Stylizer/blob/master/src/main/java/me/omegaweapondev/stylizer/utilities/SettingsHandler.java
This is what I use. Both are two seperate classes. It makes file creation easy. Obviously would need to be changed for your own needs.
thanks @jagged monolith
It may not be the best way for file handling. But it works fine
hope they update the saveresource soon
š
okay my next question
when a player executes /rules i want it to send the messages in the rules.txt file:
*line by line
Not sure if it will work for txt files, but basically you'll want to get the messages as a list or array and just send the message to the player
Could I have some help with that?
public void broadcastAnnouncements() {
Random rand = new Random();
List<String> messages = new ArrayList<>(configFile.getConfigurationSection("Announcement_Messages.Messages").getKeys(false));
String announcement = messages.get(rand.nextInt(messages.size()));
for(Player player : Bukkit.getOnlinePlayers()) {
if(configFile.getBoolean("Announcement_Messages.Messages." + announcement + ".Hover.Enabled")) {
sendWithHover(player, announcement);
} else {
sendWithoutHover(player, announcement);
}
}
}
That's an example of how I get a few messages from a file and pick a random one and send to player. But instead of broadcasting and picking one randomly, you'd just want to send all of them
Not sure if the same getConfigurationSection() etc.. methods will work on text files though. never tried it
iirc its only on FIleConfiguration
No it will not thatās yml only
Thought so.
CHECK my code bruh
Is what you need
Take a small look
verano any way to do this?
i dont know how to parse text sorry
o
google search should help
I've always used yml files as it's easier.
i did it
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/nio/file/Files.html#readAllLines(java.nio.file.Path) is probably what you're looking for.
declaration: module: java.base, package: java.nio.file, class: Files
i just added Scanner sc = new Scanner(file);
while (sc.hasNextLine())
System.out.println(sc.nextLine());
}
try {
sc = new Scanner(rulesfile);
} catch (IOException e) {
throw new RuntimeException(e);
}
while (sc.hasNextLine())
System.out.println(sc.nextLine());```
For anyone else who has the problom here is how I fixed it.
Scanner is a good way of doing it. Otherwise #help-development message This would be a good recommended way
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Do nms packets not come with the built spigot jar from buildtools?
if your coding with spigot
use maven or gradle
more specifically for nms use maven
they do kind of depends how you have your coding setup done
Has anyone had errors with guice on 1.15.2? https://mclo.gs/zSuraSm
works fine on 1.19.2
Only then did I realize that the reverse proxy plug-in could not be started.
guice is shaded: https://github.com/kejonaMC/CrossplatForms/blob/dev/spigot/build.gradle.kts
seems like guice is throwing an exception... then the message gets formatted or something, and then bukkit fails to load a guice class? not sure.
I forgot when guice was included in bukkit
but I know it was in a more recent version
though you shuold probably stop coding for 1152 its old no one uses it
how i can handle snowman spawning? 1.17.1
Emotionally? Iām not sure any single human can handle something like that
Snowman spawning is too much š¢
i fuonddddd
They do
i think i broke discord ;P
You may find the answer here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html. Tip: try searching time
Yo Guys, I'm trying to interact event but it called twice
I tried to test like below (version on 1.19.2
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Action action = event.getAction();
EquipmentSlot e = event.getHand();
if (Objects.equals(event.getHand(), EquipmentSlot.HAND)) {
player.sendMessage("test");
}
}
How can I fixed it ?
Yeah I know that, but What's different checkevent.gethand and event.getHand(); upper?
Oh wait I hadn't seen the check, the upper should be the same. This is how I do it in one of my plugins https://github.com/KevinDaGame/VoxelSniper-Reimagined/blob/f458fa99be8468e5f3627e076615c63f353df6ba/VoxelSniperSpigot/src/main/java/com/github/kevindagame/voxelsniper/VoxelSniperListener.java#L42
Are you sure you aren't double registering it?
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Action action = event.getAction();
EquipmentSlot e = event.getHand();
if (event.getHand() != EquipmentSlot.HAND) return;
player.sendMessage("test");
}
Hey can someone make me a custom plugin
No, I'm registering once
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new JobListener(), plugin);
@quaint mantle can you make me a custom plugin
hm... double registering mean is the other plugin's register too?
Yeah I guess the same way
I remember having an issue with this but not how I solved it
Oh,,
Oh yeah
If you are within rightclick range, it fires once for the interact on block and once for rightclick in general I think
Try checking event.getAction
Oh Ok
Totally forgot because we handle it in a different class
Oh, Something like this?
if (event.getHand() != EquipmentSlot.OFF_HAND) {
if (event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
player.sendMessage("test");
}
}
if (event.getHand() == EquipmentSlot.HAND && event.getAction() == Action.RIGHT_CLICK_AIR) {
player.sendMessage("test");
}
that works, or like this. I prefer less indentation
Oh yeah, I remember that making sense
Oh yeah, forgot that existed, that's what I do myself lmao
Oh, Upper
if (event.getHand() == EquipmentSlot.HAND && event.getAction() == Action.RIGHT_CLICK_AIR) {
player.sendMessage("test");
}
``` this?
if(event.getHand() != EquipmentSlot.HAND) return;
if (event.getAction() != Action.RIGHT_CLICK_AIR) return;
player.sendMessage("test");
If it works, it works.
This also works, but without indentation
Hmm
I think it works perfectly, But it works imperfectly
Lmao
I don't know what is off hand
same as left hand?
Oh yeah you're right, offhand is the secondary hand, can be left or right depending on the players setting, most have it as the left hand
hi anybody got experience with nintendo 3ds files?
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
hey, is there an way to check the value of an yml config key?
getKeys() only shows the keys itself but i want to see the values of these
configsection:
key1:
subkey: "hello"
Use the keys to get the values?
but how?
i'll send the code i currently have
thats a piece of my code.
basically what i want to do is, if the key has an specific value it should do different things in an gui inventory.
Why are you trying to check booleans as strings
because if i check it as an boolean there is an red error. it wants an string instead of an boolean
Also why are you mixing components and legacy colors
The key isn't the value
It's the key
You need to get the value from the key
yes and that was the main question. how do i get the value of an key
thats what i dont know. and i dont find anywhere in the internet
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
yes i know how to get a single value from the config but i need to loop through all values in an specific config section
in the right order
and get the values
thats what difficult
okay
How can i play a sound to nearby player but with different volumes?
Play sound has a volume argument
Can you send me an exaple?
declaration: package: org.bukkit.entity, interface: Player
declaration: package: org.bukkit, interface: World
Depending on what you want
try ChatColor.stripColor
you probably want to work with a pdc entry instead of comparing displayname tho
?pdc
it worked when I tried with player.getItemInMainHand
but the problem with that is if I consume it in off hand the item in main hand gets removed instead of the potion
setVelocity is so weird lets be honest
Hm why?
Yes
you can't event setVelocity(x, 64, y) properly
without delaying 1 tick if there is a block above you
how do i add skripts to spigot?
?
can someone tell me how to fix this?
set utf8 in your text editor
and project settings too
also update your project, maybe you forgor
while working with guis, do you use a gui api or just code the gui yourself using events?
ive got an anvil and the crafting table fully functional using hardcoded events
own code
do i move to an api for readability or keep it that way
alr
cuz you know
sometimes you need multi-paged inv
for your very specific case
no lib can do this for me
thx worked
inventory.setContents(ItemStack[]);
smh me going async with saving players and pool is closed before they are saved
bruh bson not accepting that name?
š„²
this not working either lol
player-uuid not getting accepted too bruh this is cursed
internal code not useful at all
And what is it ItemStack? Null value?
bruuh
Can I make something like this with datapacks or plugins?
No but, when you get further away it gets bigger and you can see it away from like 1000 blocks
That part is easy, I just don't know if it is possible to make it get bigger as you get further away without mods
just spawn it infront of the player if he's looking at that point
with that you fake the distance
that looks like too much documents lol
Won't it be buggy as I have to uptade it in like milliseconds at times?
you only have to update it if the player is moving
inventory::getSize()?
No, if they are moving their camera
its including, armor and off hand probably
yeah, if the player is moving, correct.
Is this possible with datapacks?
mongo drivin me crazy lol
unless you have some magic going on a players inventory will be 36
static abuse
That's static abuse but which line
