#help-development
1 messages ยท Page 391 of 1
well start with something please
congrats i have 13
Runtime or Compiletime?
can i just create one like this?
i believe so, its a while since i used it
this.saveDefaultConfig() should create a config file, right?
yes
*If you have a config.yml in your resources
all of this page (https://www.spigotmc.org/wiki/creating-a-config-file/) has the this.function
thats for the case im on a class, right?
yes i have it
Okay so im having a problem, i need to get all the block in the config, but it only gets the "ENDER_CHEST", anyone would have an idea to why?
This is what i have so far
via PluginDescriptionFile#getDescription(), how can I get this kind of info?
Im so stupid...
You dont... This doesnt belong in your plugin.yml
I have to create a new config file?
I mean technically the plugin.yml is just a yml file you can read whenever you want.
But you shouldnt.
you could just store that in your config.yml
bruh sometimes they make it an array, sometimes an object
i feel the anger people have against mojang
in config.addDefault has to be the same as the config.yml in resources?
you dont need to call addDefault in most cases
so i understand this: if i have certain value in the config.yml from my resources folder i only need to call the saveDefaultConfig
and not the addDefault
correct
that's what I did in the end
Use getConfig to access it
i do not understand what you mean
like if it says it has private access
i have to create a public method?
if you need to access the config call getConfig()
yes
nvm
now wtf is 'cannot find symbol' error: FileConfiguration config = this.getConfig(); // Create variable for the config file
Well this works, but it sends the player.sendmessage three times..
A break under it does not work
After the else
where are you calling it from? show the relevant code snippet
and make sure to import FileConfiguration
nvm found a fix
how can I forcefully load decentholograms holograms? i need to access them in onEnable, but they only load after my plugin does (even though I hard-depend on the plugin)
i already asked in their discord server, but perhaps someone knows
debug log
[19:50:49] [Server thread/INFO]: All holograms: [] // my own debug
[19:50:49] [Server thread/INFO]: > Leaderboard: leaderboard_underscore_killstreaks_1 // trying to find this hologram
[19:50:49] [Server thread/INFO]: > Leaderboard: leaderboard_underscore_killstreaks_2 // trying to find this hologram
// the holograms weren't found, otherwise it would say that it did
...
[19:50:50] [Server thread/INFO]: Done (42.363s)! For help, type "help"
[19:50:50] [Craft Scheduler Thread - 1/INFO]: [DecentHolograms] Loading holograms... // as you can see, the holograms
[19:50:50] [Craft Scheduler Thread - 1/INFO]: [DecentHolograms] Loaded 2 holograms! // are loaded too late
If i wanna learn mc plugin development, what should my java level be? For example beginners, intermediate or what?
well the better you know java, the faster plugin development will go
somewhere in between, you gotta understand the programming basics, java syntax and a bit more
knowing git & maven/gradle will be a big headstart too
found a workaround!
DecentHologramsAPI.get().hologramManager.reload()
distanceSquared pls
lol
the company i visited today admitted they use chatgpt to write basic unittests lol
so how do i block shields exactly?
thats also pointless seeing as the max range is 7 or 8 blocks?
;-;
beyond that a block is untargetable
"xaked clients"
is there any event of shield use?
no
so what do i use
there is no simple way
WHAT is the hard way
if they hold a shield, check if the event isnt pyhsical cancel
what is hold event?
could see if they right clicked
^ check clicking a block and clicking air with a shield in hand
pyhsical? wdym
but we need only right/left clicks not on blocks dont we?
people can still block with their shild on blocks
if you check if it isnt physical, you get all types
what are the other types
right click block, right click air, left click block, right click block
and clicking entities
i think i need that
interactatentityevent then if you need clicking entities
if I recall, both get sent
not just one or the other
why dont i just use player hit to player event?
that doesn't make any sense
why
because one can be false the other true
wdym false
it might have been some other event
its just an enum or am i confused
either way, some of these events are weird sometimes ๐
yeah I agree with that
can i use EntityDamageByEntityEvent for blocking usage of shields???
why
?tas
I mean if you block you dont get damage
however
wow i just openened the video and answer was there
entities get a block effect though
if you block
declaration: package: org.bukkit, enum: EntityEffect
i have an idea ill just block shields to be holdable
so like this?
you probably want to cancel the click even too
declaration: package: org.bukkit.event.player, class: PlayerSwapHandItemsEvent
yeah right
inventory click event?
yes
?cc list is available at #bot-commands
thought they disabled it huh
Could not pass event PlayerTeleportEvent to DeluxeHub v3.5.2
org.bukkit.event.EventException: null
Anyone know how to fix this?
DeluxeHub is not your plugin, right?
if so, please refer to #help-server and make sure to include the entire stacktrace
?paste if it's too long
If u mean git.magma.so, i alr use it learning maven too
If statement
Switch
Loops
Functions
Do i need to know more than that?
object oriented design
Idk what thats yet, can u explain just a lik bit?
object oriented means that every class can be seen as its own object
design refers to ways in which these objects pass data and execute functions
So 10hrs course, gotta finish all of it?
i.e creating objects by using constructors and then calling methods and variables from that object
well, git.magma.so is an option, but you also might want to learn how to work with GitHub because it's the most popular atm (i think?)
idk
it wouldn't be bad for you to at least recap your knowledge, so check it out
All i know about github that we cam upload repositories to it online
10 hours sounds too much for one sitting though
^^
don't do it in one sitting then
You need to break it down in to smaller parts and actually try the code
and if you know a topic certainly, just skip it
Ofc not 1, ill split it into a week
config = this.getConfig(); (cannot find symbol) i know i have to define it but idk how. File config;?
like, if you are comfortable with if-statements, go on to the next topic
show the relevant code snippet
I do, just spent 1 day trying joptionpane and scanners
@Override
public void onEnable() {
saveDefaultConfig(); // Create config file from resources
config = this.getConfig();
FileConfiguration config = getConfig(); // Create variable for the config file
okay, scanners are pretty useful to know
config = this.getConfig() you are assigning to a variable that does not exist
you need to create the variable config at first
Yes, should be File config
Can't set the value of a variable that doesn't exist yet
and you do exactly that on the next line
no
FileConfiguration config = getConfig(); this is correct
why are you doing it twice?
omg
looks like you need a java lesson as well
?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.
They probably don't know what this means
xD
i actually use C#, its like the same
just new with spigot
nah
true lmao
similar
similar enough
That wouldn't work in C# either 
i started coding plugins with nearly 0 java knowledge and a bit of general programming knowledge lmao
rookie mistake
but somehow worked out very well
I am, i alr code python so i know basic stuff, just gotta learn the syntax
wouldn't do that again
now im getting the same error of 'cannot find symbol' in getServer().getPluginManager().registerEvents(new JoinEventListener(joinMessage), this);
saveDefaultConfig(); // Create config file from resources
FileConfiguration config = getConfig(); // Create variable for the config file
// Adding Defaults
String joinMessage = config.getString("onJoinMessage");
message();
getServer().getPluginManager().registerEvents(new JoinEventListener(joinMessage), this);```
maybe for JoinEventListener?
did you import it?
import org.bukkit.event.Listener;
So you didn't import JoinEventListener?
no i think no
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.
that's what you should do
https://www.spigotmc.org/threads/so-youve-been-told-learn-java-first.560602/ read this as well probably
yee i had it
and it worked
but idk when i deleted it
iirc there was a method to breakNaturally block with no loot? U know animation, breaking particles but no loot from block?
Im not aware of such a method. Dont think this exists.
I have a Class Called ExampleAbility which extends thisZ
abstract class InteractAbility(override val id: String) : Ability<PlayerInteractEvent>(id)
abstract class Ability<T : Event>(open val id: String) {
abstract fun getName(): String
abstract fun getDescription(): String
abstract fun getItemStack(): ItemStack
abstract fun handle(event: T)
}
Type mismatch.
Required:
Ability<Event>
Found:
ExampleAbility
auto imports like in hitting tab on an import?
Makes no sense. The code you have sent has no correlation to your error...
This looks ok
Well... you might get a problem with the way you withdraw your currency.
This could lead to people having negative currency.
and mojang does weird stuff with their recipe files
Imagine if someone buys 100 scores super fast. The money is only removed 2 or 3 ticks later and in the meantime
the user can just spam buy scores
Yes remove the money directly but if the CF returns false then you add the money back.
this is a json object right?
"key": {
"#": [
{
"item": "minecraft:sand"
},
{
"item": "minecraft:red_sand"
}
],
"X": {
"item": "minecraft:gunpowder"
}
}```
ah i see, mojang finds it funny to swap objects with arrays
Hello ! I need to clear a pretty huge area. I use this method, is the if (.isAir) making more lag or less ? i can't know right now :/ thx !
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if (!world.getBlockAt(x, y, z).getType().isAir()) {
world.setType(x, y, z, Material.AIR);
}
}
}
}
oh no no no no
that's slower
?workloaddistro
?workdistro
ty
i've rode this guide x')
it's around 500k blocks i've test it and it seams to be ok
pretty sure it wont remove 500k blocks without any lag / stalling using that method
u know x') will do more tests
how do I effectively split my plugin
like I am making a minigame plugin
and I am working on a manager that can manage multiple instances of teh minigame, but I want to build that as a separate plugin
so people can decide to get the big version or just the isolated version of the plugin
I assume I need to make 2 plugin files but im not sure what the best way is
Hi! Is there any way to figure out what plugins are listening to specific event?
explaining what this has to do with minecraft would take a while so ill just ask the question. Are gravity calculations between a few dozen to a few hundred objects faster performed on a CPU or on a GPU?
using newtonian gravity, thats precise enough
depends on how fast you can get it to and from the gpu I guess
all I know is that gpus are good at doing the same thing a lot of times
how would i know the bandwith of whatever my stuff would run on
Is it possible to make note plings longer like ding ding diiing?
no, noteblock sounds are just taken from audio files, there is no good way to elongate them
you know how when a player takes damage theres a tiny amount of time where the player is invunerable to damage, is there a way to reduce this time
if anyone has played combo duels you know what I mean
Dammit
the best way is to make a resource pack xD
Yeah but i would have to force it on players tho, i dont like that
Yes you can set no damage ticks on every entitiy, players included
How to determine if the server on spigot or paper?
how do u get the title ofan inventory?
For what purpose?
I did event.getEntity.set and theres no option for damage ticks
Simplest way i can think of Class.forName() a paper class and check for an exception.
What do you need the title for?
anyone know how to fix deluxetags it works to the point where it's {displayname} {deluxe_tag}: {messgae}
it shows {deluxe_tag} in chat when you type but don't show tag
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/LivingEntity.html#setNoDamageTicks(int)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/LivingEntity.html#setMaximumNoDamageTicks(int)
declaration: package: org.bukkit.entity, interface: LivingEntity
@quaint mantle What do you need the title for??
Let's be honest you know people only ever use it for the shitty practice of comparing what inventory is what
There's no other reason imh
Thats why im asking so i can suggest him to simply not do that
Is it possible to get the topInventory view?
Im just gonna ignore Nopox from now on...
Hey/Re do you know how to make a trapdoor reopen after a click on it ?
@EventHandler
public void onInteract(PlayerInteractEvent event) {
if(!GameState.is(GameState.GAME)) {
return;
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
if (event.getClickedBlock().getType() == Material.SPRUCE_TRAPDOOR) {
Bukkit.getScheduler().runTaskLater(RandomRace.getPlugin(), () -> {
//code that didn't work xd
}, 60L);
}
}
I can't cast my block to Opennable
You cant cast a Block to a BlockData. You need to get the BlockData from the Block and cast it to Openable.
Or even TrapDoor.
class org.bukkit.craftbukkit.v1_19_R2.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Openable yes i know x')
Yo @lost matrix, does the code you gave me to glow a block can work on a player too ?
Sure
Thanks ๐
This just means that you are casting some BlockData which is not Openable
What do I have to change to make it glow every other player for one player tho ?
yep i will try with trapdoor
@EventHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
Block block = event.getClickedBlock();
if (Tag.TRAPDOORS.isTagged(block.getType())) {
Bukkit.getScheduler().runTaskLater(this, () -> {
BlockData blockData = block.getBlockData();
if (blockData instanceof TrapDoor trapDoor) {
trapDoor.setOpen(false);
block.setBlockData(blockData);
}
}, 60L);
}
}
}
Take what you need from this
Thx !! (you're so dedicated wtf great job!)
Is it possible to check if a player is connecting via example.com and test.example.com?
Yes it is because I know some plugin that do that for dd0s protec
Again yes
Since this is help dev I assume you're making a plugin now?
Jep
how do i do this?
https://paste.md-5.net/efarigetos.rb
Olivo sorry to disturb, after you finished helping BitLukas, could you help me with something ? I'm trying to place a debug marker with packet but I can't figure out how to set it a color like red, magenta, aqua etc
First of all: Dont check custom items by their display name. Use the PDC for that.
https://www.spigotmc.org/threads/how-to-handle-custom-items.593039/
I don't recommend detecting items based on the name. You can attach a PDC tag to the item instead
;/


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!
mvn install:file -Dfile=C:\Users\Usuario\Downloads\Simple-Yaml-1.8.3.jar ??
Mainly trying to install the jar in local maven repo
Where i run the cmd?
On a project or where?
oh right
I was doing it from inside aproject
haha
๐
should be fairly obvious what needs to be corrected
What?
I couldnt process your answer
not sure why when you have no problems all other times
anyways, the output gives you what needs to be fixed
I cant fix it
I dont have admin permissions
You need to use install-file goal
Im really stupid i dont remember the password
install:file doesn't exist install-file does
your screenshot literally shows you it
On custom ExpBottleXp how do i set the condition of the item's name?
will have to see
Once 1.20 comes out I'm dropping old versions xD and doing fun things
most of the reasons for doing packet is because of some things
but depending what they have changed, it may really just not be necessary and would be more work then necessary
IE, if they make it easy to give NPC's no AI, no Ticking etc
and some other things
in 1.20 the new holograms are not ticked I don't think
yea, but it required resource packs
making them more advantageous then your typical hologram
resource packs are probably still going to be needed for some things
I'd argue they are still going to be needed
Easier Custom blocks ๐ฏ
to stretch and manipulate models or the default ones, probably not, but if you want it to be completely different resource pack going to be needed
well
you can stretch player heads
๐
and by using minecraft education edition skin servers exploit
you can upload hd skins
apply them to the player heads
and have hq resolution textures
automatically downloaded from the server
you can upload skins
with that much quality
with education edition accounts
stretch those out
and voila
you have a custom entity
with custom textures
without resource packs
You could also do that for custom blocks
yep
Since you have hit detection
Hi, guys
Who knows how to realize this?
So that the leash is attached to the block
Someone was doing that here recently
There's an invisible entity in that brewing stand
connect the leash to it and you're done
Yes, I did it for this screenshot)
So why ask the question if you know how?
He asked how to realize it not how to do it smh
I want to do this in code so that I don't use an invisible entity
it was @lost matrix
Packets
To spawn the invisible entity
You're going to need a mod if you don't want an invisible entity
I mean if he is worried about server load I think packets is the way to go vs spawning it fr there
You basically spawn invisible entities and set their holder to other entities.
Preferably with packets ofc. Else you will have problems with the leash detatching
or the entity wandering around, getting killed and more...
help my bow is only shooting straight and to the right
https://paste.md-5.net/imefirites.py
Ok, thx
Yooo, is that progress on the electric system? It looks kinda nice.
thx
What should I do when a plugin encounters an error and cannot continue?
Contact the developer
No I mean like for a plugin that I'm developing
Learn how to read errors and fix the bug
No I mean like how should I gracefully shut down execution of a plugin
thanks
My internet is to slow to find the specific method sorry bout that
Damn data doesn't work in school
but something like getServer().getPluginManager().disablePlugin?
Yeah use that
@lost matrix Is this screenshot your work?
Really love how that looks! Are those entities real, e.g. would they be there if the plugin unloads, or are they client side only?
if you 'spawn' em with packets they only exist for the client the packet is sent to
cuz thats telling the client theres stuff where theres actually none server side
you cant do this without an entity
since that is how that is being rendered
if you use packets you will need to sync that with the server
Yeah, of course, but has smile said that he spawns them with packets? I must have missed that then. Could be real entities for all I know.
they shouldnt be
you can do this with packets, but in that case you need to write your own mini server
that syncs your packet entities with the rest of the server
IIRC, his system does utilize real entities. Back when he first started figuring out the idea he mentioned how the machines would interact when out of all players render distance.
Itโd be one hell of a complicated system if it were packet based.
i once tried something to do like this
but instead of making player entities leashable
and it was all packet based
but that was sooo bad
in terms of how it was written
due to how much you need to handle to make them appear for all of the players
(dimension change, player quit, teleport, unload chunk, etc)
everything would needs to be synced
and you need do this asynchronously (thread locks, method sync, atomic vars classes) just because the packet handling is by default async
it was glitchy af
its just not worth it
unless you've written some packet entity api or smth
to take care of that
but even that would be inefficient to run, because you're still ticking the entity (but you've made your own entity ticking), so there's no need to make it packet based
I know that smile is better at abstracting than I am, and I would not think of this as hard or as destined to end up in a ratsnest. It's not that hard. You just intercept the packet stream of players, spawn fake entities and intercept packets interacting with them, to call your own callbacks. You could also even use the bukkit API to create and configure the NMS entities, while you'd just need to send spawn and meta packets. Not that complicated.
The great thing is that everything your plugin brought would disappear when it's unloaded. That would be pretty impressive, imo.
but that doesnt need to dissapear
Yeah, sure, not necessarily.
anybody know a good path finding library
your server unloads entities that are outside server's render distance anyway
If the server owner decides to remove the plugin again, I'd still think that it would be cool if all those things went by themselves.
So that just a database dump could bring it all back if they so desire.
you can just remove the entities when the server shutdowns
or when the plugin is unloaded
the thing is, by doing packet based entities, you're basically replicating minecraft server functionality
but in more of a glitchy way
its unsafe, not cross compatible and hard to maintain
I mean, yea, thatโs fair. Although, smile only started that project like 2 days ago. I wouldnโt be all that surprised if he were using real entities instead of packets so that he could get the prototype up and running quickly. ๐
That being said, I would be surprised if it is actually packet based from the get go.
if he does this packet based, imo that's overengineering
that doesnt add up any benefit
whatsoever
0 pros, besides that they are not ticked for functionality as much
i've already tried this year ago
but with npcs
it had a customizable render distance
welcome to brasil
in that case i had no choice but implement my own entity tracker since NMS player entities are very hardcoded to the networking classes
or use a citizens api
I hope I didn't come accross in a wrong way. I very much like the idea and I don't say that they have to do anything another way than the one they've decided on... would never do that.
I just like to keep the ideal in high esteem. In an ideal world, plugins don't leave temporary structures behind when unloaded. I'd like to see a world where resource management is actually taken seriously, which is why I even brought that up in the first place. Just as an idea, nothing more.
A bit radical, this opinion, but sure.
i'm skeptical because i've already tried this, and it was not fun ๐
well maybe because my fake entities were being moveable idk
maybe implementing static fake entities is a lot easier
Oh no, itโs all good. I just wanted to clarify since I was around during his original conversation when he was asking for advice about how to handle the machine ticking.
It wasn't fun because you didn't design it well enough. That's not on the idea, that's on you.
Why would you spawn and tick an invisible entity just to spawn a leash? Seems wasteful. That leash is basically static. The blocks, for example, I'd never spawn packet based. That's where I'd draw the line. But the armor stands definitely also would be candidates for packets. The server adds no worth there, so it doesn't need to know of em.
because i wanted to leash player entities
its not possible to that without a separate entity
and those leashed players can move
so i needed to keep the leash tracking entity to player's location
and handle all the edge cases
i could've done this with a simple invisible server entity
but i chose packet way
Of course, the more complex the idea becomes, the more cases you add! :). But for the leashes and armor stands, it's literally dead simple.
?paste
Could anyone help me with this error log?
occours when im using my /clan create <name> command.
why not call it E
But how easy would it be to create your own?
how do i fix this?
Default system encoding may have misread config.yml from plugin jar I think its encoding my unicodes wrong
what itlitterly just logs that
are u stupid
[14:01:00 WARN]: [Plugin] Default system encoding may have misread config.yml from plugin jar
what code am i supposed to send
no
spigot logs that
Well shit i can a problem, /mobkill * does not work to remove this?
It works for other armorstands tho lol
Nope tried that too
forgot to add a remove in code, now its bugged lol -.-
Nope :/
Yep
Luckily its a test server so i guess it will stay there forever lol
server
It does
it makes my unicodes gay
I get it form the config
xโ
v
โ
its supposed to be
but the config has that
like
it has โ
but in game it displays as that nonesense
NORMAL: "&aโ"
what
i can type it in chat tho
with no problem
no
im not gonna do that tho cause i need those
thats all it messes up
Hey, so i wanna start at this of developing plugins and stuff and i dont know if watching youtube videos is good bc i wanna rlly understand whats going on... I actually now that C# and Java are almost equal and i know very good C# OOP. I just wanna know some tips or where to start in this. ;)
Javadocs, Forums and the wikis are also great ways to learn
if you know C# there will be no problem getting hang on the java side as well
try researching spigot api
javadocs
and then move on to NMS and packets
Yes but i dont actually now how to read a documentation
like how to use each thing
ya know?
uh its adding a few lines to your pom.yml and pressing ctrl+q
what
Im using IntelliJ IDE
?jd-s
well yea
like, i know this things are classes that contain x commands and need certain params to work and do their thing but like, where to find how to use the listeners or how the listeners work in a class
Use the searchbar in the javadocs
well if you know what method youre using, if its a spigot one it explains what it does
im actually at this page: https://hub.spigotmc.org/javadocs/spigot/index.html
public void onEnable() {
this.getPluginManager().registerEvents(new YourListener(), this);
}
on that topic, is there a way to add the source to maven such that F4 does show the source instead of the decompiled api?
?eventapi
would register your listener
in the listener you specifiy annotated @EventHandler method
in which you provide one argument that correspond to the event type you're listening
Yes
public class YourListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().sendMessage("Welcome to the server");
}
}
this is a listener to the player join, in which player gets the message welcoming him to the server
you register it with this method i've show inside onEnable() method
the new YourListener() needs smth between the ()?
its a constructor
since i dont have a constructor
inside the class
default one is provided without args
()
Okay
thus no args are passed
Let me try with a join
Does the config contain other utf symbols which are displayed correctly?
no it doesnt
YourListener.class
public class YourListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().sendMessage("Welcome to the server");
}
}
MyPlugin.class
public class MyPlugin extends JavaPlugin {
public void onEnable() {
this.getPluginManager().registerEvents(new YourListener(), this);
}
}
Then you likely read the file as non-utf8
i litterly just do config.getString
in order for the plugin to work
You know all of this is covered in the event api wiki page
you need to add plugin.yml file to your packaged jar
which contains the main key specifying your classpath to your main class file (in the provided case - MyPlugin.class)
Yes, IntelliJ cover me for that
and add other metadata properties of your plugin
How do you load the config?
ive got:
java
cirosanchezb.astralgkits.AstralGKits
AstralGKits.class
onJoinMessage.class
resources
plugin.yml
plugin.yml has authors, name, desc and version
saveDefaultConfig
yea
name: AstralGKits
version: '${project.version}'
main: cirosanchezb.astralgkits.AstralGKits
api-version: 1.19
authors: [ CiroSanchezB ]
description: Astral GKits is a plugin for easy gkits or kits.
that's fine
in other for using event.getPlayer(); i need to import that
That's saving it. How do you load it?
org.bukkit.event ?
You use the import for the event you're listening to
Intellij should be suggesting the correct imports for you
?particles
nope isnt autoimporting
You don't need to write them yourself
I dont
?
override fun onEnable() {
instance = this
saveDefaultConfig()
whats the spigot command for particles
1sec
Where's your config variable assigned? Where do you call getString on?
*1min
config is part of the JavaPlugin and I call getstring in a nametag thread
litterly just Plugin.instance.config.getString("blah")
like look at this:
public void onPlayerJoin(Event event){
Player player = event.getPlayer();
player.sendMessage("Welcome to the server!"+ player.getName());
}```
im getting errors all along in
> Player player = event.getplayer();
> sendMessage and player.getName;
And my little friend intellij isnt autoimporting as it should
You need to listen the the player join event
world.spawnParticle(Particle.TYPE,new Location(),int volume,new Particle())
You're trying to listen to the Event interface which won't work
And theres where i get lost
yes
Ohhh
method name could be anything
the event api doesnt care about the method name
all it cares is what method args annotated with @EventHandler are
but its like for anything? i refer like if someone clicked an inventory it has to be InventoryClick inventoryClick?
to make an example?
@EventHandler
public void onInventoryClick(InventoryClickEvent event){
}
you basically add methods
So theres an event for everything?
k
@EventHandler
public void idkwhattonamethis(InventoryClickEvent i_still_have_no_idea){
...
}
For most things
thank you both
not for everything but for the most part
sorry for being such a stupid
the three things that have to stay are the @EventHandler, the public void and the EventType
If you mean the method name by the lower case version you wrote, that's basically up to you. It's only important that the method is unique, which your compiler will tell you if that's not the case anyways. You should name them in a way they explain themselves tho, still.
about the situation at that moment
regarding your event
InventoryClickEvent holds the information about the clicked slots
allows you to get the current clicker
etc
yes i know how to play with that
also do take note that specifying WHICH event you want to trigger helps
only having trouble with listeners
all the methods of InventoryClickEvent
package index
you can find every available method and fields here ^^
Thanks
doing this is just plain stupid but technically works:
@EventHandler
public void method(Event event){
if(event instanceof PlayerJoinEvent joinEvent){...}
if(event instanceof PlayerPreJoinEvent preJoinEvent){...}
}
so do it in separate methods
you just search via the search bar what you need
thats why you call specific events instead of just Event
It won't. Event doesn't have a HandlerList
It's static
is it called javadoc or javadocs
So extending classes wouldn't be able to have their own if it had one
i've seen both used
idk what ur on about olivio
?eventapi
this.getPluginManager isnt imported by org.bukkit.plugin.PluginManager?
hello, I'm kinda a beginner at developing plugins, I've been trying to figure out how to make a custom potion effect but nothing worked for me. is there a guide, some documentation for this specific issue? I just need the effect to have duration and name, nothing fancy
You can't listen to abstract events nor the interfaces
u cant do it with the same style as vanilla cuz thats hard coded
Since they're missing handlerlists
oh, so there is no way to do it?
i didnt say that
but you have to do it separately
smone?
You don't need to import it unless you're creating a variable
what you can do is:
- Create potions and potion particles with non-natural colors
- write code to make the potion do what you want
- use scoreboard or titles, bossbars etc, to display the potion effect
this.getPluginManager().registerEvents(new onJoinMessage(), this);
in onEnable
Yeah that's fine
did u reload ur maven
You probably forgot to import onJoinMessage
yee like twice
oh okay, makes sense. I'll use a scoreboard then. That's a bummer though, but thanks for letting me know
nah i imported it
What does the error say
technically you could do it with a resource pack, but that introduces... problems. lots of em. I'm not 100% sure you cant use the vanilla display, but it's unlikely
maybe replace the luck potion thingy
thats not used by anything
wdym with toast
Also just to make sure; your on enable is in the main class. You cannot create a new onEnable in the listener
i believe you can set the time
can you edit them?
obviouslyy
yes
i got that
@ember ridge see here
Ah right getPluginManager needs to be called on the server object or Bukkit class
Didn't see that earlier
I might use that, thanks. I don't think it'd be a problem to use scoreboards in my case at all, if I can listen to the player drinking a potion or something
as I said, I'm a beginner but I'll figure it out
Bukkit.getPluginManager... etc
Yeah
if i create anonymous class, and pass outer class field which is final
does it copy the value of the variable
that is final to the inner class
nvm
i answered it myself
all objects are passed by reference
Thought you were asking about the bytecode for a sec there..
except primitive
theyre cloned
nvmind im dumb
i'm trying to shrink the world border by a certain size every day, but it doesn't move when this is called.
is there anything i am doing wrong here?
i mean if its too slow to notice
whats ur shrink amount
about 200, i tried it in a command and it turns red so you can see when it moves
huh?
it should move
the codes correct
print out size and shrink amount before you call the border.setsize
if it does display correctly god help you cuz i certainly cant
yea it's getting 0 for borderShrinkAmount for some reason
thank you for the help ๐
eh its my go to debug
print out shit
i have specific methods for that
i just call p(String s)
and it goes like [Plugin / Info]: s
good luck running a debugger on a spigot server lol
Is this made using spigot or it's a resourcepack ?
i mean how are you going to find whatver ur looking for
spigot 99% sure
I see thanks
?paste
https://paste.md-5.net/uzicejosew.java having error line 14 ' cannot find symbol'
just trying to call my listener
anyone want to help me make my server i need a really good scripter one space left!
Remove it
Best way to make a countdown?
2 minutes
1 minutes
10 seconds
...
3
2
1
Just make 3 runtasklater
and a repeating one?
y personally think that 2m, 1m, 45s, 30s, 15s, 10, 9, etc.
and maybe with a algorithm on depending how much time the user wants adds x time on sleeps
What is the point of this property? https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/Plugin.html#isNaggable()
declaration: package: org.bukkit.plugin, interface: Plugin
AtomicInteger i = new AtomicInteger(10);
Bukkit.getScheduler().scheduleSyncRepeatingTask(Events.getInstance(), () -> {
Bukkit.broadcastMessage(Color.translate("&6The event will start in &e" + i + " &6seconds"));
i.getAndDecrement();
if (i.get() == 0) {
this.cancel();
}
}, 0, 20);```
How can I exit it?
Good question, actually, xD. I think that it would be best to store the points in time at which a broadcast will be printed in a configuration file, either as <x><h/m/s> or just as second values, like 120, 60, 30, etc. Then, just loop these, create a delayed task for every point in time (delay = duration - point) and print the formatted value inside of it's callback. This way, you don't need a ticking countdown timer and save on quite a lot of calls, based on how high your value is.
Exit what? You're already calling cancel on the task. Btw, rather use i.decrementAndGet() == 0 in this case.
i have no idea of AtomicInteger tbh
I just accepted the intellij suggestion
I was reading info about it in the docs
decrementAndGet is equivalent to --x while getAndDecrement is x--
So instead of decrementing and wasting that extra get, you can combine both.
what's the diff between --x and x--?
Post-decrement and pre-decrement. --x decrements first, then returns the value, x-- returns the value first, then decrements
Btw, you could get rid of the atomic all together by just using an anonymous runnable instance with the counter as it's instance variable.
for (int i = 10; i > 0; i--) {
Bukkit.getScheduler().runTaskLater(Events.getInstance(), () -> {
Bukkit.broadcastMessage(Color.translate("&6The event will start in &e" + i + " &6seconds"));
}, 20L * (10 - i));
}```
could I do it this way?
Yeah, that should work. You'll just never reach zero, as you compare strictly greater i > 0.
use >= instead
is there a way to make subtitles not go offscreen
if you use player.sendTitle to send a title and subtitle, there isnt any way to make it go on a new line even with \n
How can I convert a project from gradle to maven
Should I make a new project on IntelliJ selecting the gradle build file?
create a new maven project and then convert the dependencies
And..
anyone know any resources that use specific textures for specific gui names?
im not 100% on how plugins do it, i havent done any messing about with resource packs up until now
I knew that in async task, It's unable to use Bukkit Method. But some of methods like setItemInMainHands, getLocation etc.. does work.
Does anyone know about that?
dont write novels
๐ฟ
Does anyone have a function to paste schematics with fawe api?
Some methods are usable via async, the premise is that the api is largely thread unsafe, however that doesnt mean you cant do things in a way to make it thread safe. Best way to know if something is or isnt thread safe other then reading docs and just knowing the underlying implementation is to just try it and see what happens
Worse that happens is a bunch of cme's get tossed or weird things happen
Yes, thanks ๐
They are only packet based. I dont want to clutter the chunks when the plugin is disabled and i dont want the server to tick those for good reasons 
WHAT? You actually made it packet based from the start? I thought you were using normal entities.
oof that would have been not easy on the server or i would have needed a custom nms implementation for every version.
Because leads sometimes just vanish on normal entities. Those lines stay forever and dont use any server resources 
if(entity.getLocation().getChunk().isEntitiesLoaded() || force)
for (Player p : Bukkit.getOnlinePlayers()){
if(p.hasLineOfSight(entity) || force)
((CraftPlayer) p).getHandle().b.sendPacket(packet);
}
}```
so uhh why is isEntitiesLoaded erroring
Erroring as in? Method not found?
What version are you on?
1.17.1
Thats too old. I believe this method was added to the API just recently
this is why we need to start documenting what game or API version classes or their members were added in
:v
Yeah i think an @Since annotation or something similar would be useful. But someone has to actually go through the whole API and annotate every method...
i think a forever ago (like january) i had talked abt it
#general message
jan 31st :p
I was wondering, what's the difference between Bukkit.reload() and Bukkit.reloadData()? Is Bukkit.reloadData() part of Bukkit.reload()?
reloadData wont reload plugins. Only the mc part of the server.
And reload does all of it?
One should reload stuff like datapacks, the other is the normal /reload
Well... you should never use those methods anyways unless you are debugging.
Even then it will lead to problems and inconsistencies eventually
I'm doing a full overhaul of all commands in my big boy project basically. Including (sadly there's no other way since you cant override it) disabling the /reload command and replacing it with my own
Lol
- more commands ofc
It's basically supposed to be the new Essentials but more
In general it is usually a bad idea to use /reload because some plugins break if onEnable is called more than once and you really can't do much about that
Use ThreadLocalRandom
public int[] randomCoords() {
final ThreadLocalRandom random = ThreadLocalRandom.current();
final int x = random.nextInt(-500, 500);
final int y = random.nextInt(-500, 500);
final int z = random.nextInt(-500, 500);
return new int[]{x, y, z};
}
Also: You dont need to pass x, y or z
Sure. If a method needs no parameters from the caller then you dont need to pass anything.
Use this method:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html#getHighestBlockAt(int,int)
declaration: package: org.bukkit, interface: World
Unless you want them to spawn in caves.
So only generate a random x and z and then use getHighestBlockAt(x, z)
What's the fastest way to make plugin for all versions?
don;t use NMS
everything he told you is about programming
Very much depends on what you are working with. Diff their APIs and write some reflect to unify them for each breaking change. Then, expose one unified API internally. That's what I do.
Mhm
NMS was a typo, and it was about fast, not easy. NMS could be in there, doesn't have to be tho.
true
fastest is to not use NMS and build against 1.8
Most sensible is support latest and forget about older versions
Again, I'd need a use-case, but I could show you an example of how I solve it, if you'd be interested. It's not final yet, but it's pretty fast in terms of getting it done.
Sure
Depends on what you're optimizing for. If speed of writing is only number two and you need to get some features in, you sometimes have no way to avoid interacting with the bare minecraft server.
Don't know if this is of any use to you, but that's what I came up with, after trying many approaches: https://paste.md-5.net/eqeteyusew.java
It's my own library, but it's builder notation, so quite simple to read regardless. I specify version ranges on which certain ways of accessing APIs work, and the underlying system decides on which to use for the current version, then exposes a simple and unified API at the top.
There is still much to be done, but I think that it's way easier than to have to write one implementation for each version. That would only be viable - in my opinion - if you also only write those for breaking changes and patch the classes constantpool to allow for version ranges as well. But you'd have to know all versions.
You could handle ALL commands in one class and still be oop
as it would then just be a command handler
However, with Spigot you would be much better having one class per command, as thats how it's designed
unless you are talking about args
acf my beloved
Yep. That's a good sign, :))
Sometimes I look back and think, damn thats good, no way I wrote this ๐
i began using a framework cuz my onCommand was a mess
i tried to but it was a mess of functional interfaces and looked awful
If my class is a mess I tend to try not looking at it
If I rewrite I get locked in a loop of constant rewrites
if it works ๐
50-75% of learning java?
being able to read is not difficult
about what reading are we talking
Try to stay under a gigabyte, LOL
thats gonna go brr when transferring it with sftp
A binary patch library? :-:
Alrighty, don't know what it's about, but sounds fancy! :)
ayo Wtf is that IDE
NetBeans?
im judgin the Light theme if anything
bc i know what Eclipse and IntelliJ look like
and that was neither
so the logical answer is NetBeans, bc no one uses BlueJ
people in companies work with light themes too
Are we talking patching import statements and FQNs, or are you trying to modify actual logic? xD
I bet netbeans is actually crashing less than IJ
saw it yesterday
I want to make a system where players can look around for scrap metal, which they can find by right-clicking blocks that have particles above them. How would I go about checking if a player has right-clicked a block, with a certain particle on it, that I specified in the same plugin
PlayerInteractEvent
I'll give it a look
Are you sure? I'm on mac, and I haven't seen this yet, xD. I think IJ is designed in a way where there's one window per project.
That's just a module, right? That's cheating.
@tender shard shows it like all the time
Why is External Libraries then only there once, and not once per project?
But to check if I clicked a block that has a particle, I first need a block with a particle. How can I make a command that adds a particle to a block when looking at it (basically specify that it's a block which contains scrap)?
imagine hiding your username
Okay, then it's a maven project. Still not a full standalone project you're loading in.
Imagine
Bro look this name up, you'll find around 5000 people with the same name
how to replicate? i cant find anything that could let me do this
all i get are Modules
Imagine drawing with .99% opacity and getting doxed
wtf do u need the parallel stream for
dunno what that means

Oh, I thought we were talking about the image with black pixels over the path name, xD.
no
Sad stuff
Is a teleport asynchronous?
Otherwise, why do you need to parallelize the iteration over the set
Im pretty sure he was talking about my username
"all at once" means within one tick. So a simple for loop will do.
They are only actually teleported on the next tick, right?
Yes. And chunks will be loaded as well.
That's what I meant, it feels off. That's just because IJ wasn't designed to be a multi project IDE. It's one project per window, that's how it's intended.
I want it like that
Their software is really buggy... either the badge doesn't work, or they don't push updates. I'm happy that it's at least free.
in 0 I will send a message saying the event has started
instead of in 0 seconds the event will start
Of course, but how do you know that the time elapsed? Do you have a delayed task of the full 10s outside of the loop?
20L * (10 - 1) is the last iteration, so you'll never reach the final full 10 seconds.
ik
or I think I do
so when it gets to 0
for (int i = 10; i > 0; i--) {
Bukkit.getScheduler().runTaskLater(Events.getInstance(), () -> {
Bukkit.broadcastMessage(Color.translate("&6The event will start in &e" + i + " &6seconds"));
}, 20L * (10 - i));
}
Bukkit.broadcastMessage(Color.translate("&6The event hast started"));
Events.getInstance().event.joineable = false;```
what if u just runTaskTimer
let me check that
wont need to do a loop, n can just set it to run every 20 ticks
If you want to capture i in the state of your current iteration, you need to create a copy inside the for loop, but outside of the lambda. Something like int currentI = i. Then, the lambda can capture that "effectively final" variable.
and then use like BukkitRunnable so u can cancel it after 10s
or whatever the Task thing is
BukkitTask?
Why get called at every second, if you're only printing in known intervals, and only need to initiate the next state after it elapsed?
oh yeah im thinking of BukkitTask
Oh, btw, weren't you saying that you're not going to print at every second, but at fixed numbers of remaining seconds? That's kinda not what you asked about initially, IIRC.
Someone told me that alternative
I just asked how to do it because I had no idea
Already wrote that, got ignored, lol
nono
Ah ok XD
I did it
for (int i = 10; i > 0; i--) {
int currentI = i;
Bukkit.getScheduler().runTaskLater(Events.getInstance(), () -> {
Bukkit.broadcastMessage(Color.translate("&6The event will start in &e" + currentI + " &6seconds"));
}, 20L * (10 - currentI));
}```
right. No need to use it in the parameter to runTaskLater, just saying.
You need that copy because the callback will be called after the loop already progressed, and thus i would be different by that time. That's why java disallows it.
If i use Bukkit.createInventory() and I add a title for the inventory, can I get that title again for a Listener? I can't find a method
event.getView() ?
np
missed that
