#help-development
1 messages · Page 548 of 1
basically what & always did ig
(object++)++ wouldnt work
ah, good to know
always trough increment is basically +
reason why you cant override ++ in c# for example
not really
wait you can
&variable -> memory address
int & -> lvalue reference
int && -> rvalue reference
const int & -> in function args it accepts both lvalue and rvalue
& {} -> only lvalue permitted to execute this block
ampersand in cpp is like in english
many definitions for the same word
https://paste.md-5.net/bojimugexa.cs I am trying to make my plugin tell how long it takes to go from one pressure plate to another. Instead of giving a normal time, it gives something like 1.64598321321E12.
that's some yandere i've seen today
define yandere?
oh my lord
i dont mind it being messy as long as it works lol
have fun debugging that
not too difficult to debug imo
at parkourstarttime and parkourendtime
i might be wrong
but youre measurement unit of time is in milliseconds right
you divide your duration by 1000
instead of multiplying it
maybe that's why
Brr
I thought to get from milliseconds to seconds you divide by 1000
bruh
because there are 1000 milliseconds in one second
yeah bro i was second guessing myself or a second lol
@EventHandler
public void cow(PlayerInteractEntityEvent e) {
if (e.getRightClicked().getType() != EntityType.COW) return;
PersistentDataContainer entity = e.getRightClicked().getPersistentDataContainer();
if (entity.has(new NamespacedKey(Cv_farming.getPlugin(), "milk"), PersistentDataType.LONG)) {
Long time = entity.get(new NamespacedKey(Cv_farming.getPlugin(), "milk"), PersistentDataType.LONG);
if (time != null && System.currentTimeMillis() < time + 10000) {
e.setCancelled(true);
Player p = e.getPlayer();
p.sendMessage("test");
}
else if (time != null && System.currentTimeMillis() > time + 10000) {
entity.set(new NamespacedKey(Cv_farming.getPlugin(), "milk"), PersistentDataType.LONG, System.currentTimeMillis());
}
}
else {
entity.set(new NamespacedKey(Cv_farming.getPlugin(), "milk"), PersistentDataType.LONG, System.currentTimeMillis());
}
}``` someone fix my syntax ? is this code fine ?
i think you may be missing brackets
not getting any errors tho
wdym i new learned pdc
this line, do not cast to double. millis are whole numbers. no fractionsparkourdurationtime.put(event.getPlayer().getUniqueId(), (double) parkourendtime.get(event.getPlayer().getUniqueId())-parkourstarttime.get(event.getPlayer().getUniqueId())/1000);
pdc isnt create custom data and settime ?
get and put longs
that shouldnt impact it for small numbers
no?
it think the problem is here
you divide not the duration but the start time by 1000
his divide by 1000 is fine
Love it when people in the train are talking to themselves
but he divides not the whole duration
but yes he needs to divide the result of the subtraction not the time
Oh yeah your right
parkourdurationtime.put(event.getPlayer().getUniqueId(), (parkourendtime.get(event.getPlayer().getUniqueId())-parkourstarttime.get(event.getPlayer().getUniqueId()))/1000);```
Just work with instants and no more such issues
I only am dividing the start time not the end time
that what i was talking about, yeah
what if he needs not the whole seconds
i mean putting doubles where millis are stored yeah
but putting result as like 2.37 seconds is not bad
then don;t divide by 1000
i would even say that i would store floats here
keep it as longs and convert when you actually want to display it
can i cancel evets with pactets ?
İ mean example i cancel player milking from cow works but do t his i wanna prevent this
comes to inventory and disappears and still got milking sounds
hm
What is the reason to do that via packets
I wonder if they're client-sided
Almost definitely client-sided. Nothing much you do there
welp I should probably write a search index post about diagnosing exceptions
well you sorta can but it involves some trickery
one way to bypass this
is to spawn big invisible packet based slime or other mob with similar hitbox
inside the cow
that way client thinks you're interacting with slime instead
but then you need to do some kind of proxy of damaging from one packet entity to the server one
ah good idea
its a lot of work tbh
yeah you can do anything but the question is if its worth it
like why is the sound so important
preventing from milking the cow is not that hard
i am a perfectionist
managing the damage could be tricky
okay well then its just noth worth it, because there are a billion inconsistencies in how the game works with this kinda stuff
i know and this tilting me
isnt there like a marker entity or something
doesnt that also block other interactions?
i will do custom bucket with paper
can u check my code and fix my syntax ?
it a lot of work in order to get this to work
can i get block without event and give feature ?
nvm
what do you mean by that?
player.getInventory.addwhatever?
i wanna settype of block with timer
but there is no event for do this
i only wanna check block without event and give feature
I dont understand what "check block and give feature" means
also , when do you want to "check block"?
alright can i give PDC to blocks ?
no
yes
wdym yes, how?
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
anything with tile state has it built in, customblockdata for anything else
i wanna change block type when my timer runs
i need do this with bukkitscheduler ?
that or bukkit runnables
alright i try somethings
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
block.setType(Material.POOP)
}, 0L, 20L);```
should be smth like this
Hi, is it normal that my config doesnt work after reloading? 😅
I do:
cfg.set
Main.getInstance().saveConfig()
after a /rl it just doenst work anymore
Caused by: java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Float (java.lang.Double and java.lang.Float are in module java.base of loader 'bootstrap')
dont use reload
command
its bad
What else?
it causes memory leaks
due to the how classloading in java works
if you reload many times it would load all the classes
of the plugins
oh okay
without releasing the objects
PlugMan?
internet O.o
everytime?
well for development reload isnt particularly bad
but you need to see your memory usage
what is this means ? and this is second or ... ?
as it doesnt garbage collect the loaded data of before
L stands for long
f stands for float
d for double
10L -> (long)10
20 ticks = 1 second
I wanted to create simple setspawn and spawn
alright so i can delete this keys
But after I set spawn and reload the /spawn wont work
oh alright
Sounds like you aren't saving the data.
FileConfiguration cfg = Main.getInstance().getConfig();
cfg.set("spawn.world", p.getWorld().getName());
cfg.set("spawn.x", p.getLocation().getX());
cfg.set("spawn.y", p.getLocation().getY());
cfg.set("spawn.z", p.getLocation().getZ());
cfg.set("spawn.yaw", p.getLocation().getYaw());
cfg.set("spawn.pitch", p.getLocation().getPitch());
p.sendMessage("§eDu hast den Spawn gesetzt!");
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP,1, 1);
Main.getInstance().saveConfig();
that's what I did
what is this ? i mean why has two delay ?
TPS basically is how many times per second does server calls tick() method inside NMS
it is doing the same
ideally server would call tick() method every 50ms
but sometimes due to lag that gets delayed
That isn't two delays. You are multiplying values together to make one larger delay.
fr?
like cfg.set("spawn", p.getLocation()) ?
pff
does getLocation include world?
yes
That's crazy wtf
People do that because they don't like how location gets serialized into yaml. It looks ugly af and it worries users that if they touch it, something will break. A clear cut, x, y, z gives end users a much better feeling that they are meant to change those values if they want.
Say thank you to serialization
Maybe, but if your users are scared to touch it, you might as well not make it an option. Cause there would be no point.
It's just one of those situations where you have to accomodate.
I dont have a lot of yml files i want users to actually interact with manually, except for config.yml so I usually just serialize whatever
With that, the /spawn works after a reload. Crazy shit man. Thank you very much
Any free database providers, tryna make a plug-in but I don’t have a DB
If your functionality can be isolated/abstracted away from the files, then there is no issue with storing it however you want. The issue only arrises if your users ever need to modify the files themselves for whatever reason.
SQLite
alright
You can host it locally
Too heavy
SQLite, H2, local mysql... Endless possibilities
Are you kidding ?
Thanks @young knoll
im guessing thats just code for "Idk how to set it up so im not using it"
I’m going to use sqlite
Oh yeah you're a good translator
That is basically local db but yeah go for it 🤣
i need get mushroom but not working i tried sourceblock,block,newstate
@EventHandler
public void onBlockSpread(BlockSpreadEvent e) {
BlockState mushroom = e.getNewState();
if (mushroom.getType() == Material.BROWN_MUSHROOM){
e.setCancelled(true);
e.getBlock().setType(Material.DIAMOND_BLOCK);
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(getPlugin(), () -> e.getBlock().setType(Material.GOLD_BLOCK), 20L);
}
}``` u guys have a idea ?
Yeah but I like Lite things
There are probably like 500 websites that will throw together a tiny MySQL server for you too
Or MariaDB or postgres or whatever
?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.
you just do SECONDS * 20L cuz the method accepts ticks(and 20 ticks = 1 second)
readable
alright
Hey, how do you guys come up with project ideas?
from other games
wdym
i wanna make farm game like stardew valley and i do some systems from stardew valley
have you begun yet?
ok
i did watering and fertilizing system
w8 i upload video
state machine hmm
use the runtasktimer with a bukkittask consumer and call cancel() on the task
runtasktimer(..., task -> if (whatever) task.cancel())
its not
you cant cancel it from the inside without a bukkittask ref or pid
You can technically cancel all plugin tasks with the scheduler approach. BukkitScheduler#cancelTasks(Plugin plugin);
Although, I think a BukkitRunnable is a much better apporach here since you can call the internal #cancel() method inside the runnable.
You have a little finer control with the runnables.
dont
Bukkit.getScheduler().runTaskTimer(plugin, task -> {
if (whatever) {
task.cancel();
return;
}
process();
});```
Is there any way you can blacklist certain servers frim using your pluin?
Not really. That's in the same vein of obfuscating your code. There's always a way around it.
auth systems are not permitted on Spigot
the functional interface param
ill check it out
if i load chunk where the crops are
this will do lag ?
bcs i wanna do crop growth when player away
if you store teh time on teh chunk when it unloads
butter bone
get active item and get if item type is shield
are u using playerinteractevent ?
w8
if (player.isBlocking()) player.getItemInUse()
yes i don't need look after than this
im sorry for ping but can i store chunks to list ? or i need store to file ?
You store in chunk pdc
omg
teh current time
then when teh chunk loads again you grow any plants using the duration now() - stored time
can i store blocks to pdc ?
just get all tripwires in the chunk with the correct data
i try
in 1.12 no clue
Oudated tax
oh thank
@EventHandler
public void loadChunk(ChunkLoadEvent e) {
PersistentDataContainer chunk = e.getChunk().getPersistentDataContainer();
if (chunk.has(new NamespacedKey(Cv_farming.getPlugin(), "time"), PersistentDataType.LONG)) {
Long time = chunk.get(new NamespacedKey(Cv_farming.getPlugin(), "time"), PersistentDataType.LONG);
if (time != null && System.currentTimeMillis() < time + 10000) {
//i will do something
}
else if (time != null && System.currentTimeMillis() > time + 10000) {
chunk.set(new NamespacedKey(Cv_farming.getPlugin(), "time"), PersistentDataType.LONG, System.currentTimeMillis());
}
}
}``` is this true ?
idu what need i do u said i can save chunks to pdc
I'm talking about teh name you gave the variable
is there a way to check if a spawner has no mob in it? it seems to be defaulting to saying pig instead of empty
(1.19.4)
just realized i have an outdated spigot version, gonna check and see if that fixes it
you don;t need to set teh key during chunk load
you actually shoudl delete teh pdc entry
oh
._.
is a typo
alright
i need problem too do u know crop growth times munites ? or do u know crop growth rates in spigot.yml
updated spigot, same issue
using getSpawnedType()
I saw a discussionon this kinda back a few weeks ago in a pr, aren't really sure what to return because EntityType.Empty wouldn't make sense and they aren't sure about returning null as it could break plugins
currently just using a switch case and if it doesnt pick it up it defaults to air
maybe EntityType.Unknown?
EntityType Air doesn't exist
as a material to drop when mined
It's a whole thing
otherwise its a spawn egg
Also wouldn't make sense since you'd be mining a spawner material regardless it's a whole thing, just deal with pig as default for now I'm sure some consensus will be made eventually
alr
Using http requests and a little magic
in the meantime is there any way to check for it being empty aside from getSpawnedType()?
maybe checking the nbt somehow
Mmmm see qhat they do with nbt
Language Apis for discord n spotify and such are just fancy wrappers
Seems promising
How can I check if a player has more than one stack of a certain item?
Count how many they have and see if its more than the max stack size for that material
maybe loop through all of thier inventory slots?
Sockets are also an option, they allow quicker and more frequent communication once a connection is established
and then if its a specific stack add one to a variable, and if the variable its greater than 1 run the code
I actually already have a util method to count items
public static int getTotalAmount(Inventory inventory, ItemStack target) {
int amount = 0;
for (ItemStack item : inventory) {
if (item == null) {
continue;
}
if (item.isSimilar(target)) {
amount += item.getAmount();
}
}
return amount;
}
What api do u want to use
okay thanks!
you can iterate over inventory, cool!
Yup
np
nobody seems to know
But then all the information u need is already there?
Not sure what you're waiting for
It links wrappers for other languages
For how many dollars should a detailed cosmetic plugin be sold on the spigot site?
If you need to give an average price
need to see code
Gonna need to be pretty good to be accepted
Since the common resource list has
- Particle Plugins
- "Hub Gadgets" or similar lobby-centric perks plugins.
how you do a list
add PDC to chunks
will not do lag ?
no
- Bullet
- List
i wanna edit this growth rates
and do wheat growth time to 10 munites (vanilla is 52m) how do i calculate this?
It's just an average
if i do 100 to 200 my crops will growth 2x ?
afaik yes. It's a percent value
wut
You should know by now it's always best to ask a question and get answered by anybody that's available ;p
Say the line!
only players can load and unload chunks ?
and plugins
And commands
World#loadChunk
i need check player on unloadchunk event ?
And for commands there is /forceload
a chunk won;t unload near a player
@EventHandler
public void loadChunk(ChunkUnloadEvent e) {
PersistentDataContainer chunk = e.getChunk().getPersistentDataContainer();
chunk.set(new NamespacedKey(Cv_farming.getPlugin(), "time"), PersistentDataType.LONG, System.currentTimeMillis());
}```
is this code true ? i need do something more ?
thats fine
oke
ah ok 😄
i get plugin
never read the x lines above me
with this method
well fix the naming and use dependency injection
No, that's just a static method call.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
but this not work for use pdc ?
why dont they teach best pratices in school
Cause the schools don't know what the best practices are. They are not up to date with the times.
i havent learnt anything new java related this whole year
half of the time i was just wondering why i was sitting in that class
ah iu
1/4 of time just cleaning up teachers code
Sadly they don't seem to teach much other than fundamentals
And I guess good practices aren't fundamental
2nd year college they teach us java streams, cmon man
i learned too much feature for java in last 4 days
timestamp, threads, savedatabase, savefile
😛
im learning di now
😮
Ehhh, they sometimes struggle with the fundamentals. Or at least they don't do a great job expanding upon them.
I don't think they ever touched streams in my course
Pretty sure my course is just a helldesk tech course with a bit of sugar on top
guys i wonder why i don't getplugin with static method call ?
you need to inject your dependencies rather than depending on stuff that may not be known from outside that class, also easier for refactoring
How can I spawn an NPC using NMS? I am using this:
Player p = (Player) sender;
ServerPlayer sp = ((CraftPlayer) p).getHandle();
ServerGamePacketListenerImpl connection = sp.connection;
ServerPlayer npc = new ServerPlayer(sp.getServer(), sp.getLevel(), new GameProfile(UUID.randomUUID(), "Name"));
connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, npc));
connection.send(new ClientboundAddPlayerPacket(npc));
But no NPC is spawned, or at least I can't see it. What can I do?
Important to incapsulate objects
Also your NPC has no network handler so it's going to either mess up the original player or it's going to crash yrou server as soon as anyone chats
hmm nice naming changes in between versions, is PacketPlayOutNamedEntitySpawn not nms then?
Easier to make entity that extends Player properties?
I am getting this error when I try and reload my plugin: https://paste.md-5.net/nohokonuje.bash. Here is my code: https://paste.md-5.net/qutofoceha.cs
It does tell you what's wrong
I know but it makes no sense because there is a value called InWater1
Also add default is just an annoying way of doing things
Also why the static abuse
people seem to embrace that here
?main
That too
I love 🍝
All of the values that I set to "None" are inside the customconfig file, so I don't understand why it would be null
Me too, especially in code, that's why I do it so much.
Points for honesty I guess
I don't understand why CustomConfig.get() is null if the values are right there in the earlier part
Can you make your own colors with ChatColor ?
like an extension almost. Something Similar to the color library in Swift?
Alrightyy
you are using statics which can cause issues, also you are using addDefaults. That method will always run unless you have something to tell it not to, a better method of adding a defaults is when you use something like .getString() you can specify a default if it didn't find anything .getString("something.something", "defaultValue")
third, don't use server reload unless you designed your plugin to handle it
Is there any easy way that I could get the output of the contents of a collection/list after being blasted?
static 
self plug time
I changed the addDefaults to getString and it still didn't work
Like im getting the same error
well fix all the statics
they shouldn't be static and can cause issues like you are seeing if you don't know how static works.
second, you didn't show us all of the code, you showed us the main class but not your customconfig
but first, fix up all of your code and then we can move from there
I want to smelt whatever the drops from a broken block are
Well, blast so that it's only ores
well there is a getDrops() method
you could go through the collection from the explosion of blocks affected, filter out non ore ones
and then do getDrops() on the ones you want
Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getLore()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
Could someone explain why I am getting this error? I dont understand why it says its null. When I crafted my bow it has its lore.
@EventHandler
public void onBowShoot(EntityShootBowEvent event){
if(event.getEntity() instanceof Player player){
if(player.getInventory().getItemInMainHand().getItemMeta().getLore().contains("Explosive Bow")){
Arrow arrow = (Arrow) event.getProjectile();
Location arrowLocation = arrow.getLocation();
if (arrow.isOnGround()) {
int ExplosionPower = plugin.getConfig().getInt("Bows.ExplosiveArrowBow.ExplosionPower");
boolean setFire = plugin.getConfig().getBoolean("Bows.ExplosiveArrowBow.SetFire");
boolean breakBlocks = plugin.getConfig().getBoolean("Bows.ExplosiveArrowBow.BreakBlocks");
arrow.getWorld().createExplosion(arrowLocation, ExplosionPower, setFire, breakBlocks);
}
}
}
}
Main Class: https://paste.md-5.net/wezovobahu.cs
CustomConfig Class: https://paste.md-5.net/ateyagiron.java
getItemMeta can only return null on air
that can be done better without doing it that way if you just passed an instance of your main class to it
then you could do plugin.getDataFolder()
and then as far as your config stuff goes in main class, there is a better way to do it, then the way you are doing it
which might fix your issue not sure
how do you register the class inside of the Main.java without it being an event?
make each thing that has a number appended its own configuration section, and then put the numbers below it
the e.setcancelled(true) is not working in this code block. In game i am able to move the items around. any ideas ?
public void onMenuClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
InventoryHolder holder = e.getClickedInventory().getHolder();
if (holder instanceof Menu) {
e.setCancelled(true);
if(e.getCurrentItem() == null) {
return;
}
Menu menu = (Menu) holder;
menu.handleMenu(e);
}
}```
do you just say new(CustomConfig(this))
you would require Plugin to be passed into the constructor
there you go
and you will need to hold CustomConfig somewhere too so as to not let it disappear otherwise you can end up with incorrect instances
how would I do that?
public class MainPluginClass extends JavaPlugin {
CustomConfig customConfig;
public void onEnable() {
//set the value so its not just null.
customConfig = new CustomConfig(this);
}
//this is for anything else that needs the config.
public CustomConfig getCustomConfig() {
return this.customConfig;
}
}
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Are you the same person I helped with forcing raids the last time?
Alr
So why do you need the bukkit raid?
Also when working with NMS you need to specify version
My plugin supports multiple NMS versions, so using the bukkit raid class would be preferred.
I assume there is no api to start a raid?
There is not.
Shame
Atleast I couldn't find one.
Do you want to crash the server or stop it…
Well that'd a bad reason to do it
There isn't
Takes notes
I found the NMS method to start a raid, but it returns an NMS raid object.
I can use the CraftRaid constructor though.
I'd prefer not too though
I assume CraftRaid is just a wrapper
Yes
Then use the constructor
Bukkit.shutdown() iirc
ye+
It's alright to use the constructor
but ideally you want to make sure the raid is registered
through the Raids class
hi guys
Im making a plugin that makes bookshelves usable
like give them inventory storage n stuff like that
I'm pretty new to bukkit dev and rn it stores the bookshelf inventory data in a config.yml file which will be really slow once it scales
what are some more efficient ways to store a lot of info like that?
sqlite database?
I think it may require a valid recipe
Or the game just won’t let you take the result
~~(ignore the {message}) List<String> messageList = plugin.getMessageList("commands.message.translations.messageToPlayer"); sendMessages(player, messageList, player.getName());
(send messages class)
`private void sendMessages(Player player, List<String> messageList, String name) {
List<String> replacedList = new ArrayList<>();
for (String message : messageList) {
String replacedMessage = PlaceholderAPI.setPlaceholders(player, message);
replacedList.add(replacedMessage);
}
replacedList.forEach(message -> player.sendMessage(message.replace("{0}", name)));
}`
Why is the %Player% not being converted? I have the expansion~~
im so stupid nvm
nvm
%player_displayname%
I’m trying to use persistent data container and it’s giving me an error? I’m using 1.8 btw
It didn’t land like I thought it would
I was gonna add to it but couldn’t think of anything funny
i got this error: https://paste.md-5.net/egisicegeb.md
Code is: https://paste.md-5.net/wiqebuyucu.java
Literally is creating a folder with the uuid.json name, not a .json file, whats can be happening?
you must be calling mkdir on teh file name
oh damn
Call mkDirs on the parent and then createNewFile on the file
lets see
Iirc
doesnt that require an external server setup
sometimes it works, but other times it makes a file with the name of the path you put
No, SQLite is local
nah its a file database, stored locally
so what are the advantages compared to like a JSON
Worked that way, but now, it doesnt write like, the User object
its just an empty file
or maybe Visual Studio is wrong
What replaced the Banner class if Banner is deprecated?
What? Banner isn't deprecated.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Banner.html
declaration: package: org.bukkit.block, interface: Banner
probably refering to materialdata
Probably the materialdata one
BannerMeta I would guess
thx
helpo?
So they just announced java 21... is adding in a new feature...
It's finally gone... the memes can stop...
We no longer need public static void main (String[] args) 🥳
this is just learning basic java captain 🫡 pls don’t make a new gson instance every time you do this tho
what
why
thats awesome
Lot of new QoL features.
Go watch fire ships latest video on it
Ur very late on that we talked about it in verified like a month ago
Stinky lol
Let me have this 🥳😭
only one i saw was void main() {} lol
what method do i use to set a chest to double? i've been trying for like an hour and i cant find it
how do I set up SQLite?
Google your question before asking it:
https://www.google.com/
@coral brook
or if you don't understand that https://www.javatpoint.com/java-sqlite this is the top search result it provides all the proper code examples you should need to get started
what method do i do that with
.setType()?
setBlockData
what do i put in the method
Block data
You can make a base one with Material.X.createBlockData
Then cast and modify as needed
Iirc there is also one that takes a consumer
ty
oh is it this? i do getServer().createBlockData
would actually be very convenient if i can from the Material itself
does it wrap to server or is it the other way around
cba to check stash for impl rn
hmm
Just calls the Bukkit method
is there a good way to make a scoreboard show up below name for all players
its server wide so its not like its a per player display or anything
Just set the display to below name and make sure every player has that scoreboard
@EventHandler
public void loadChunk(ChunkLoadEvent e) {
PersistentDataContainer chunk = e.getChunk().getPersistentDataContainer();
Chunk chunk1 = e.getChunk();
Block blocks = chunk1.getBlock(15,255,15);
if (chunk.has(new NamespacedKey(plugin, "time"), PersistentDataType.LONG)) {
Long time = chunk.get(new NamespacedKey(plugin, "time"), PersistentDataType.LONG);
if (time != null && System.currentTimeMillis() > time + 10000 && blocks.getType() == Material.WHEAT) {
blocks.setType(Material.TRIPWIRE);
}
}
}```
and its not like my plugins public
getblock isnt getting blocks in chunk ?
That’s the block way in the sky in the corner of the chunk
Are you checking the right spot
wdym ?
You are getting the block at 15,255,15
oh
so i need do with loop ?
or can i check all blocks in chunk ? with one method =
i just wanna check only wheats
can i store blocks in chunk ?
Yes
Store their relative locations inside the chunk
You can compress it into a single integer
There isn’t one
couldn't you do /data ? or is that for something else
aahh im confused i need store block locations when player place block ?
Yes
Better than looping every block on chunk load to find wheat
what u suggest ?
as all you want to do is grow wheat for teh duration the chunk has been unloaded you can do a slow async loop over all blocks
you don;t need toi do it all at once
you can run async and do it slowly
True, but now we are introducing async :p
easier than getting him to keep a chunk pdc up to date with block places/destroy
Fair
what is the async loop ? 😄
Especially since some methods of place and destroy just don’t have events
On the one hand I wish we had events for any time a block goes to/from air
On the other hand that may be really laggy
in your chunk loadEvent use event.getChunk().getChunkSnapshot()
pass that snapshot to a bukkit runnable task
whats is chunk snpashot ?
?scheduling
in the task you create you can loop over all teh blocks in the snapshot, get the ones you need and inside the async task you call runTask to make any changesd you need to the real chunk
I think you can technically read a chunk from another thread
But it’s best to avoid it
yoiu can, but it's not stated to be safe so best to avoid
you need 3 for loops, X and Z, then one inside for Y starting at snapshot.getHighestBlockYAt(x,z) and going down to 0
Are they on old version?
nope
Then go to World.getMinimumHeight
Might not be a bad idea to add that data to the snapshot
Or you can just pass it along side the snapshot
so for (int y = snapshot.getHighestYAt(x,z); y > Bukkit.getWorld(snapshot.getWorldName()).getMinimumHeight(); y--)
wrap a for x and z around that 0 to 15
how do you start writing nms if your plugin doesnt have a pom.xml file
closest thing i have a pluginname.iml
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
I do recommend you start using maven instead though
im clueless on this
what exactly do i have set up xd
and how easy would it be to switch over
most ides have a convert to maven feature
i tried something but i don't understand what need i do after loop ? i did loop btw
after the last loop you do if (snapshot.getBlockType(x,y,z) == Material.WHEAT)
if you only want wheat
then use runTask on a BukkitRunnable to do whatever changes using x,y,z you want
not to the snapshot, you operate on teh actual chunk then
alrgiht ty
so in the runTask Bukkit.getWorld(name).getBlockAt(x*16,y*16,z*16)
err thats wrong
getChunk(snapshot.getX(), snapshot.getZ())
ah
anyone knows how to override the time placeholder api updates my placeholder? asked chatgpt and got this
private BukkitRunnable dataRequestTask;
@Override
public void register() {
super.register();
// Schedule the data request task to run every 1 minute
dataRequestTask = new BukkitRunnable() {
@Override
public void run() {
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (player.isOnline()) {
// Trigger the onRequest method for online players
plugin.getPlaceholderAPI().refresh(player);
}
}
}
};
dataRequestTask.runTaskTimer(plugin, 0L, 20L * 3L);
}
@Override
public void unregister() {
super.unregister();
// Cancel the data request task when the expansion is unregistered
if (dataRequestTask != null) {
dataRequestTask.cancel();
dataRequestTask = null;
}
}
but this doesnt work and there doesnt seem to be any documentation about this
some advice, do not ask ChatGPT for code help
it will hallucinate random shit and even when it doesn't the stuff doesn't work most of the time
are there any other servers that have this looking for paid developer channels?
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Does entity.damage() trigger an entity damage event?
how could i detect if a bounding box is intersecting with terrain
and preferably which direction of the box is intersecting so I can resolve the collision
Yes
It should with damage cause being custom
Unless you specify an entity in the method too
is there any other place?
However if it for some reason doesnt, you can always invoke events to fire too
In which case the entity will be the cause
Quick question:
Does PlayerJoinEvent fire AFTER PlayerAsyncJoinEvent is allowed? Or are they simultaneous? (Wanting to add items to players inv after data is loaded from async join)
Cant quite remember
bb.contains(BoundingBox.of(block))?
Async always fires unless something like a plugin causes it to be sync. Both dont fire. Its one or the other
So then how would i add items to a players inventory after the async join event? Because the async join event i dont think (heavy on the think) the player is actually spawned in the world at this point?
ah yeah re login event mb
Still same question, just wasnt sure if both fire sequentially or not its been a fat min since ive done this
so its perfectly safe to not do anything extra? just set async to allow and then listen to join event? I cant remember if there was something extra we had to do...
Nope
neat, thanks!
Just make sure you listen in monitor for the prelogin event
Incase another plugin disallows it
oh thats important? i think im doing HIGHEST rn
yeah thatll defo be important then
As long as you aren’t changing the result monitor is good
i only change result if theres some error with the mongodb, which should be never hopefully since its an atlas db
Is there an easier way to log somthing with plugin log prefix other than JavaPlugin.getPlugin(Plugin.class).getLogger()?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
What is common in the async events is to listen to both async and sync so that you dont miss it. This way if it happens to be sync you can still load your data. What i said earlier applies
so then I have to loop through every block within the bounding box?
wait the async pre login doesnt always fire? that seems like a major flaw D:
Both dont fire its either one or the other so its safe to listen to both
While true a plugin can cause it to be sync
Deprecated.
This event causes synchronization from the login thread; AsyncPlayerPreLoginEvent is preferred to keep the secondary threads asynchronous.
i wont be using many plugins other than my own
just vault luckperms and maybe essentials
Either way you are fine to listen to both, but async is generally what will fire
If a plugin is doing something that causes the async prelogin event to not fire that’s on them tbh
They can fire it sync if they really must
It’s from a static utility function used to calculate damage, so I guess I could pass the plugin in with the function, but that feels clanky.
True, but still fine to listen to both and no harm in doing so
But both will fire
Both dont fire from my understanding. I could be wrong
You can technically hold your logger as a static field
I don’t think having a static logger is the worst thing ever
i use static loggers everytime
Loggers are typically static anyways
unless i need something more advanced like timers or smthn then ill use a instance
Well loggers are not suppose to go away lol
well you might have multiple timers, so :p
Is JavaPlugin.getPlugin not going to return null if put in a static field? Not sure the plugin would exist at the time of static load.
It will return null if it doesnt find the plugin
Just because its static doesnt mean the value cant be null
i have problems with info, my loggers are always spewing out information lmao, i like to know what going on 
It just means the object cant be null
That is what info is for
JavaPlugin.getPlugin will work fine in a static field
You have like 3-4 levels for logging
I used to use it for making namespaced keys
me who throws everything on the info level:
Info is one of them and its just there when you want to inform something
my logger is jank asf
Doesnt have colors on windows
That is down to which console you use
i thought there was a universal method for spigot logging that made colors work everywhere?
Command prompt is hit or miss if jansi injects properly. If you use git bash you shouldnt have issues
at the root i just use getLogger#info and so on
yeh i use command prompt
wait
you can use git bash as a command prompt for java apps?
If you want to log stuff that isn’t shown by default use fine or finest or whatnot
There is api methods to specify colors, but the implementation responsible for console stuff is jansi and this dependency is what is responsible for translating colors fr the mc console to the terminal
Every so often jansi doesnt fully inject for command prompt
Because windows is dumb like that
A certain fork uses something else that seems to work better
hey can anyone help me as to why when I run .sendMessage("§8[§2Xine§8] §aYou can't damage " + damagedPlayer.getName() + " because your level difference is too high"); on a player after an event, it gets sent to the player but the format comes out like this? no other plugins do this and it just so happens the one i make does https://media.essential.gg/d1b48d8a-7525-4ae6-5df8-e4c1bc960900
then top line here, no colors (using ChatColors#translateAlternateChatCodes method)
That’s not how you color logs
Warn will be yellow and severe will be red by default
Info doesn’t get color
You could try instead using messageFormat
oh so all the hosting companies that make it colored for me are just doing it on theyre own terms (pterodactyl panel specifically)
Yes
ahh
i was under the assumtpion it was kinda just a feature lmao, i normally do my testing on ptero but im using command prompt for the moment
You can color stuff by instead using the console sender
But like, don’t do that
Logs don’t need fancy color
yeah i read about that but it seemed janky to me
The default gray yellow red is fine
And it doesn’t use any special characters so it doesn’t look weird in logs
adding onto what other people said btw
Use ChatColor.translateAlternateChatCodes('&', stringHere); if you wanna send colored messages to people, better to wrap it in a static method so your don't gotta type out that long bs every time, using § is miffy a lot of the times
no s
It can also get messed up by file encoding
ChatColor
Since § isn’t a standard character
its sweedish
its been sooo long since i typed that method out
i barely know how to register a command the normal way, i just use my lib for it 
oh huh seems i made mine to papi too wtf
neat
How can I tell if a bounding box is atleast partially within a distance from a location?
String dmgcanceled = "&8[&2Xine&8] &aYou can't damage " + damagedPlayer.getName() + " because your level difference is too high";
damagerPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', dmgcanceled));```
so for ex:, since this is the 1 and only message i need, i wont make the static method. but in this usecase it should work properly?
Just do ChatColor.color + “Message”. It is so much more readable.
But people are too lazy to type all those constants
^^^^
this dude gets it
yeah i can do it just the once
but surely theres a better alternative i wana learn for future reference
Doesn’t it take more time to look up the color code?
not if youve got them memorized
i would have said that but my brain doesnt have enough space for that
im just mega lazy and use minimessage formatting
My argument to that is you spend more time reading code then writing it, so my personal philosophy is make code as readable as possible.
cant argue with that logic
meh most of the time youll never see hardcoded strings
so, using the constants arent really viable
As most configs will use the & codes for coloring
But minimessage
It’s nicer for end users
<#rrggbb>Hex vs
&x&r&r&b&b&g&gHex
Although making something to allow &#rrggbb isn’t very hard either
shoot i forgot about rgb
you know what imma give it a try cause ik damn well the vanilla way of dealing with rgb is prolly aids
Gotta love going from minimessage to adventure component just to shove it back into a legacy string
Kek
So I’m trying to randomly generate dungeon type things right
HELP im trying to make a back door plugin if i do //pluginmedix ONLY PLAYER NAMED "MedixLorian" will gain OP
And I made a little command called /visualize to test my algorithm with little 3x3 platforms before moving on to actual dungeon rooms
But we’ve just been having fun spamming /visualize
And it lets you set the number of rooms
.
So we were making pretty big ones
But they weren’t big enough of course
So then I had to make it async
And now we are watching it create a 1.05M room “””dungeon”””
Dawg we’re not gonna help you make malware
you just check the senders name ¯_(ツ)_/¯
if you dont know hwo to do that learn to make a normal plugin first
loads of servers actually use op for stuff
@vagrant stratus
prob wanna ping sam or md, bc most of the othther staff are most likely sleeping
@tender forge
There
I dont think md is here right now
Not that we ever know till he speaks
Anyways optic will be up soonish
If sam doesnt notice by then
This is no excuse for breaking the rules
Then he doesnt belong somewhere online if they cant read and understand rules. Its not our job to parent
And you are saying i learned differently?
Online communities were way more harsh then they are now
But anyways its no different then breaking the law. Some minor things may be forgiven but certain offenses are not regardless of age
Its quite the same. You cant just go to online communities break their rules and expect nothing to come of it and then use the excuse well you are a kid
Not allowed to be on discord if you are younger then 13
If discord finds out they ban your account
You sound like someone who believes in not doing about someone who breaks rules
In the US minors go to jail or get fined for stealing just like adults do. Under your view it should be allowed that they steal and no punishment
I care about the community. If rules are not enforced then why have them
Anyways its not my decision to punish rule breakers here anyways
If that were true, then i must have imagined quite a bit of others getting banned from here
yup like getting banned on worldedit discord server for making a cringe developer joke
i feel that perm ban
Lol
I am not advocating they get banned here, but if staff decides that then that is their right
Hi how to fix this :- when I use this comment [/znpcs action add 1 CMD Shop Food ] . It tells [Hey!, The inserted number/id does not look like a number]
If you dont care then why does it bother you
they probably doesn't even bother to learn java
It doesnt, i just report and be on my way
Whether they get punished or not is not my decision
Well thst is just kid mentality to believe you are allowed to break rules just because you are a kid. You dont learn unless you get caught or in trouble
In the US kids go to jail and get fined just like any other adult. They are not allowed to steal just because they are a kid
malicious attempt...
I am not mad
This community basically polices itself for the most part
And tends to make it easier for the staff
Yes i could have chosen to do nothing, but doing nothing is just as wrong
Its called integrity
Leting unhinged bad just run wild leads to disaster, choas and unstructure
in short integrity like @wet breach said
Anyways no matter, it doesnt bother me what your opinion is. It doesnt change or affect my actions in what i do regardless
I meant i dont really care what their opinion is on it. Doesnt change the fact i will still report when rules are broken if its warranted
Their opinion isnt going to prevent me from doing it nor change my mind about it
This is how i view it
And besides as i said, i dont decide the punishment if any
That is for the staff, i just report what i think needs to be reported

@wet breach yeah doing the right things keeping the community togther
reporting so staff can deal with it
Fur should have been here for the last person that asked about such things
Last person as i recalled was banned lol
And i didnt even report it, staff happened to be on at the time and they just banned them without a second thought

So that being the case as far as the extent of breaking rules goes. Why should others be treated differently?
I dont mind supporting equal treatment. Seems people have no problems with it unless it is also them getting in trouble. In this case fur just has the perspective from a kids view point and not any others which is understandable
Oh definitely. Lol. But they dont see the perspective of what equal treatment looks like
And that is everyone is treated the same when it comes to breaking rules. That includes getting banned. Age isnt really the factor
If age was a factor for me or even others. I wouldnt have attempted a mature conversation with them about it
Same goes with helping people
I have destroyed countless peoples online playing and computers and i got away with it. But while i didnt have repercussions like some would, it did have consequences in the gaming clan i was part of even though they supported me. I couldnt be fully trusted in the clan and was feared at times even though they liked having me on their team lol
I never cheated in games back then, but we did have clan wars
And clan wars back then were real online wars
there is always consequences
cus and effects
You targeted their sites, their online channels and you did what you could to disrupt them or make them disband
the security use to be worse back then
I personally destroyed 20 clans on battle net 1.0 and was one of few people larger clans feared.
I took over a clan channel once and it happened to be a smaller clan that belonged to a larger one
They spent a week trying to take back the channel from me and they only succeeded because my internet decided to drop one day
in early minecraft you could read people's password files
They attempted to flood the channel to make me dc. But i had special bots that were not susceptible to such things lol
Most of my bots never had guis
i should have gotten bonked hard
Lol
Anyways now that i am older, i definitely should have gotten in some kind of trouble though
truly a learning experience
The last person i attacked only because they were attacking my clan i was part of. I took 58 gaming accounts and 10 email accounts away from them all the while i was talking to them on AIM. And it took me exactly 20 hours to do it
And their aol account was the hardest
holy... jesus
I needed all 3 of their security questions answers so i talked them into conversations to divulge such details.
I need their mothers maiden name, their pets name which turned out to be a dog that had long been deceased and some other one. Took me like 3 hours for just that one email account lol
Checks social media for details
And then after everything was done, about an hour after they realized they lost access to all of their emails they called the police
oh fukt
And this was the point where i thought i might need to start wiping my system
FBI can be lurking and just waiting
Fortunately because i didnt use their emails to do anything or mess with their finances the police couldnt do anything unless something of dollar value was actually stolen
My mom used to introduce me to her friends as a hacker. And she said she always waited for fbi to come busting the door down lmao
dark villian backstory
Least suspecting person with a villain backstory
there is a very interesting psychological aspect to this
Anyways, i ran the blackops stuff for my clan that i am still part of and the ironic part is to this day they have no idea how many people in the clan actually was part of it aside from myself and they have no idea how effective it really was
Or how widespread the clan wars really were
what clans are we talking about
We were really good at not bringing attention to the clan as well as very effectively making it appear to our clan members we dont do such things
i can imagine being 1 number Clan can give certain perks
Battle net
what is battle net
Warcraft, diablo 2, starcraft etc
how personal did it get to be getting into their accounts
Well my clan wasnt the top. But we were known for having members very effective in the black ops world
It wasnt personal. It was just part of war really. They wer simply a casualty for being part of whatever clan we were taking down
Most of the time the accounts targeted are the leader account and ops
As those are the ones that let you take over channels



