#help-development
1 messages · Page 1732 of 1
its not bad either
so why not
you should just straight up generate the blocks
not first collect all of them
onMove you can use the boolean return of add rather than call the contains and then add
smort
why? they look like util methods
public HashSet<Long> generated = new HashSet<>();
public Material[] materials;
static {
// collect block materials
List<Material> mat = new ArrayList<>(50);
for (Material m : Material.values()) {
if (m.isBlock()) mat.add(m);
}
materials = mat.toArray(new Material[0]);
}
static long getChunkKey(int x, int z) {
return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
} // using olijeffersOn's key function
@EventHandler
public void onMove(PlayerMoveEvent e){
Chunk chunk = e.getTo().getChunk();
if (!(e.getFrom().getChunk().equals(chunk))){
long key = getChunkKey(chunk);
if (chunks.add(key)) {
chunks.add(key);
regenerate(chunk, new Random());
}
}
}
static void regenerate(Chunk c, Random r) {
// get world
World world = c.getWorld();
// get min and max height
int mn = world.getMinHeight();
int mx = world.getMaxHeight();
int l = materials.length;
// loop over blocks and set them to random material
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = mn; y < mx; y++)
Block block = c.getBlock();
if (!block.isEmpty() && !block.isLiquid())
block.setType(materials[r.nextInt(l)]);
}
}
}
yeah
static is invoked faster anyway iirc
no need to make it instance reliant
mm fair enough
@EventHandler
public void onMove(PlayerMoveEvent e){
if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
if (!(hasBeenGenerated.contains(e.getTo().getChunk().getChunkKey()))) {
hasBeenGenerated.add(e.getTo().getChunk().getChunkKey());
World world = e.getTo().getChunk().getWorld();
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();
for (int x = 0; x < 16; x++) {
for (int y = 0; y < maxY; y++) {
for (int z = 0; z < 16; z++) {
Block block = e.getTo().getChunk().getBlock(x, y, z);
BlockState state = block.getState();
if (!(block.isEmpty()) && !(block.isLiquid()) && !(state instanceof TileState)) {
Material random = Material.values()[new Random().nextInt(Material.values().length)];
if (random.isBlock() && !(random.isEmpty())){
block.setType(random);
}
}
}
}
}
}
}
}
There
@regal moat i think this is the best implementation
oh yeah
.
Ah, so sets doesn't let duplicate items
thanks
boolean isExisting = hasBeenGenerated.add(e.getTo().getChunk().getChunkKey());
if (!(isExisting)) {
like this then?
well you can inline it

We did optimize the code a bit
But it's still laggy
How Is this so laggy, but when you are setting blocks with worldedit its not
@regal moat there are some more optimizations you need to do
ur constructing a random every time
Sigh
I am randomizing it when the player moves to a new chunk that has been never entered before
ThreadLocalRandom
Material random = Material.values()[new Random().nextInt(Material.values().length)];
for every single block ur making a new random
https://paste.md-5.net/umoheluseb.cs look at this for a second
you can use one random object
ThreadLocalRandom.current()
what
Random is expensive to instantiate
you should create a single Random or use the instance of ThreadLocalRandom returned by current
wont that make it the same thing every time
What the man said
as the seed is always the same
yeah
right
thanks
Any more optimizations I should do?
i like threadlocalrandom cause it has a lower bound iirc
remove the block.getState()
How do I send a actionbar message in 1.17?
ur not using it
wtf
I believe ThreadLocalRandom may be slower in some way? Idk, I'd have to benchmark.
woah
state instanceof TileState
idk - its just a habit
🤢
oh greate
^
he’s here to shit on muh party
what
SplittableRandom 
It’s bound to the thread
or use
if (this.random == null)
this.random = new Random();
0 reproducibility if something goes wrong
what no
I have this in the class
yeah thats what i meant
And SplittableRandom can be used in a parallel environment by splitting it which creates a new instance but isn’t that expensive
I have 3 projects to manage
no but if you instantiate it when the class is loaded
then the seed might be the same
I like lazy instantiation :)
as it uses the uptime in nanoseconds right?
Random in a multithreaded env is pretty slow yeah
Probably the case for TLR also if you share it across threads that is
but yeah just private static final Random random = new Random();
I am trying to create my own programming language from scratch, with I am not good at, I am also trying to make a game using GameMaker Studio, I am also doing... this!
I am trying to create my own programming language from scratch
good fuckin' luck mate
I made my own lang a while back
lemme find it
it's easy to parse bc it's an assembly lang but
it's still special :)
like me, in many different ways
Lmao
you can't argue that it doesn't work
it's just not very fun to use
it's like
the worst assembly lang in terms of QoL
(which is ironic)
maow it’s a good language lol
Furry language
^
meow
the last statement in a .fur file has to be yif
: )
Random random = new Random(System.currentTimeMillis() * System.nanoTime());
maybe this
that's just the long version of the Random() constructor
oh
yeah that's not, I don't think?
?
I am going for something like python
it's not this anymore
orby you probably want to have a seed where you store it somewhere in case something goes really bad and you screw up, you can at least reuse the seed for reproducibility 
interesting
oh btw you should check out Godot instead of GameMaker
gonna name it lunar
it's not a hard engine to learn
https://paste.md-5.net/adazizuxay.cs the new implementation
i am most familiar with gamemaker
I mean you can keep using GameMaker if you want
but I urge you to at least try out Godot
or just get verified
i added credits https://paste.md-5.net/alonolitep.cs
lol
oops duplicate chunks.add
fuck
use services on the forums if its minecraft related
otherwise seek help at another discord server
for web development
?services
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/
Uh
Well you store a timestamp
And then when you need to, compare the current time against the timestamp by checking if the stored timestamp summed with the delay is greater than or equal to the current time millis, if that’s the case then the cooldown is still on.
remember to have everything in the same time unit
@golden turret
private static final int DELAY = 2 * 1000; // 2 seconds in ms
private static final Map<Player, Long> times = new HashMap<>();
... // in method or something
if (System.currentTimeMillis() - times.getOrDefault(player, DELAY) >= DELAY)
times.put(player, System.currentTimeMillis());
/* do stuff */
i think this may work
arena ur searching doesnt exist
idk
getArena is null
thats what it sais in the error description
thats the same error
you will need to figure out why getArena(int) is returning null
no but why is getArena giving null
you are appereantly trying to get an arena that doesnt exist
yeah so the id that you are passing as a parameter is of a nonexistant arena
so figure out where that id is coming from
and handle it
hey, i tried to implement an update check for my plugin
which version do you get here? https://api.spigotmc.org/legacy/update.php?resource=92028
Don't use legacy api
@chrome beacon what else?
use spiget api or if you push out github releases, github api
hello I need help with Itemstack I was not able to find anything online
buy I have a customenchantplugin that adds enchants to items and I also have a kit plugin whitch so how to I add custom enchant to an item
I don't mean like adding sharpness 10
I mean like a custom enchanment
tried this customItem.addUnsafeEnchantment(Enchantment.getByName("Speed"),1);
ok I get it not supported
some plugin able to do it
advancedenchantment
I think I can try to find how they add it to items in the first place system.out.print the content and use setdata
Ayo so i wanna disable iridium skyblock shop and use another one how do i do it?
ive been trying for a while now cant figure it out
how long does it take to get the latest version from spiget? just some minutes?
the latest version of what?
Do you even know what Spiget is
Hi, what is the best way to scan all loaded chunks for blocks without freezing the main thread? runTaskAsynchronously seems to drop TPS significantly while also dropping a lot of warnings in the console
yes lmao, chill tf out
just sounds funny to me every time
not all tasks are async friendly
You could get a snapshot of each chunk to scan async
But that would still be expensive
Does it mean I need double of the RAM for that?
Hm that might have sounded more rude than I intended, sorey about that
nah it didn’t dw
I'm basically doing that right now
for (World w : Bukkit.getWorlds()) {
for (Chunk c : w.getLoadedChunks()) {
that will take a while depending on what you do
public static int checkChunk(Set<Material> materials, Chunk c) {
int count = 0;
int cx = c.getX() << 4;
int cz = c.getZ() << 4;
for (int x = cx; x < cx + 16; x++) {
for (int z = cz; z < cz + 16; z++) {
for (int y = 0; y < 256; y++) {
if (materials.contains(c.getBlock(x, y, z).getType())) {
count++;
}
}
}
}
return count;
}
I run this method for each chunk
should I take a snapshot of the chunk?
it’s a parameter
😉
I define it like this new HashSet<>(Arrays.asList(...
Is runTaskAsynchronously the best way to run async tasks?
Sets::newHashSet
hmmm, there are many ways
I would prefer not deprecated one 😉
does it make a difference in performance?
i mean you are gonna have to take a chunk snapshot i imagine if you wanna do this off main thread
it is not really more readable lol
it is tho lol
ok, thanks guys
splitting hairs at this point lol
Sets::newHashSet decouples instantiation
by using that you really dont know how the instantiation is which is polite to the reader if it just want to know what you're doing in high, abstract terms
anyways what type of task is it?
I just googled for a way to run async code for spigot
Bukkit.getScheduler().runTaskAsynchronously(plugin, new BukkitRunnable() {
@Override
public void run() {
...
?scheduling
I suggest looking into that
but anyways, if you do async stuff which has no correlation to spigot, then using the executor api and future api might be a better choice than unintentionally growing craft schedulers cached thread pool
it's really complex stuff. I run this thing just a couple of times a day, I'll probably use craft schedulers anyway due to lack of free time
Sure
all good lol
but thanks for your advices
If you run it that infrequently you could stagger it
Check 1 chunk per second or something
Of course you have to worry about loading and unloading
I have 7k of loaded chunks 😄
Right, but will they stay loaded
I could probably unload them manually, but I think it's even more complex
What's your period time
Bukkit has implemented runTaskAsynchronously very poorly where it creates a new thread whenever it runs your task
That's bad as the creation is a more or less heavy task
Before you're working with that many blocks you should create - if possible - a chunk ticket (1.14) so that the chunk doesn't get randomly unloaded
It's not a repeating scheduler nvm
it doesnt necessarily create a new thread
I'm pretty sure that it does that, or at least that's how I remember it when I checked the code of it
afaik cached thread pools might reuse an already created thread assuming it isn't already working on a task
Oh I'm wrong, it's not that bad
Yeah well Idk, I mean it could easily get out of control as its essentially a fixed thread pool with the upper thread bound limit as Integer%MAX_VALUE so yeah the implementation is arguably poor (since threads arent just free ofc which ya know) no doubt about that, was just picking on ur words a bit
I've been going through the source code and it's basically just using https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool()
It depends on what you're doing. If you're doing a short task the it's likely better to just Bukkit's implementation as you're using a more frequently pool in which it's more likely you'll find an already available pool
yeah
but even so, short tasks, even a work stealing pool would suit more, in most cases
Better discordsrv?
yep
also forge/fabric support later on
already migrated everything away from spigot API and made my own API which spigot implements
so core functionality is in one package and platform providers are in their own and a jar is built for each platform
took a while but yeye
Hmm, I think the problem with this would be that the plugin might create a task that has to he run at that given moment, which you can't promise with a work stealing pool
You can create a cached variant of a work stealing pool tho also
Anyways I myself would have created a thread pool per plugin if I were to design it but anyways its hard to generalize the pool implementation if we don't know the exact tasks which will run in the pool, and most percent of the times specifying your own implementation will most likely benefit you assuming you're knowledgeable enough about Java's concurrency api.
Is it possible to see or to decomplie java server, Im asking it here because is more tehnical question to ask
yep
to get source code from .jar file
not source
I'm not sure if a cached/non fixed variant of a stealing pool would be better as it has a larger overhead the more threads there are. I think that what spigot has right now isn't that bad
but you can get decompiled compiled code
you can’t get verbatim the source back
Bungee is actually creating one for each plugin
but you can get back the equivalent src
But that method is deprecated as ig it's better when the plugin is creating its own
yep
just run it thru a decompiler
there are online ones
or something like fernflower works
So that I can just upload a file and decompile it
yep
Yeah Idk a shit about bungee though
it sounds good lol I want to see socket handling and that sort of stuff
no thing is, you'd actually define a size for it ofc where the parallelism and thread count isn't unreasonable and assuming only smaller tasks are submitted (which should be the case) then it's going to work perfectly
With a cached thread pool you literally cant stop it from growing, and small tasks are from what I have experienced less efficiently handled than a fjp
If I'd have created and I'd be certain that that method is only being used with the knowledge that you shouldn't do anything that might block it (like with io things or whatever) then I'd have implemented it the same
yes but should and want to handle io tasks in a separate thread pool than the cached thread pool craftscheduler uses
and assuming you know the blocking coefficient then a fjp would work great with io or whatever "big" tasks you may use it for
thats probably the biggest flaw of having a generic cached thread pool in the first way and people who aren't educated enough about common pool, spigot devs will use it for anything including IO
I think the best solution would be to just make the thread pool accessible
The real benefit of what Spigot has created is a solution that allows you to start something at a given time
People who know what they're doing could just access the thread pool and create their queues from that one
Paper does expose it
Instead of having each plugin creating their own pool that just do nothing the most time
That's amazing
You ofc create it lazily
And thread pools generally do create threads lazily, not eagerly iirc
Idk how that’s any different from using the abstraction Bukkit provides but Ig it would give devs more control
I'm thinking of the way we used to do that on a previous larger server I worked for
We had a thread pool for every plugin
And there were hundreds of them
Meaning that we had hundreds of threads that basically just did nothing most the time
Can you swim in a thread pool
legend says you can 👀 🏊♂️
Allowing devs to just access the pool and do whatever they want with their thread is a so much greater solution, I wish spigot had that
Not with that attitude
and that'd break liskov substition principle which is quite essential for most apis
but they do expose it as an Executor
so in other words, you could use it when for instance creating completablefutures
Ig ExecutorService could be fine
but they'd have to create a delegate to block termination methods etc
Can someone help me with this
wdym
Yes
what does not work?
Y e s
It just isnt working
what isnt working
I dont know what
so what goes wrong?
oh yeah the HOLOGRAM isnt working
VHAT WHAPPANS WHIN START PLOOGIN?
It doesn't say anything
no
you might have forgotten to drop your plugin jar into ur plugins folder
have you tried turning it off and on again?
Does that work for humans
hopefully
No its in the folder but not being used I can delete it without a warning
if I listen to the PacketType.Play.Server.CHAT packet through protocollib, will this include messages they've received from their internal client/server broadcasts (like join messages, server broadcasts or responses from commands)
iirc yes
I wonder if I should bother replacing protocollib with my own Injector
Would free me from waiting when version updates come
maybe use methodhandles?
but ya sounds like smtng I could use if u'd acc do it
You don’t need reflection tho
I’ve done it before with reflection
Based on a forum tutorial
Since the fields are final in a packet iirc
Unsafe 
Hey guys!
I have a question for all you developers out there. What are some questions I can ask to weed out inexperienced developers from hiring on a project?
Looking to bring on a lead engineer to handle the entire backend of a large-scale java network (with kubernetes or an alternative form of automated scaling) so it is fairly difficult for me to know who is really good and motivated compared to those who can talk out their ***
But the thing is the hollogram isnt spawning
Are you listening to packets?
Oh this one’s fun
Or creating them
Me?
So ask them about flaws surrounding some of Bukkit
Ask them also basic interview questions too
I’m listening and modifying them
You could extend channelduplexhandler
Googleable
From netty
You probably want to ask non googleable questions xD
Yeah, but most bad developers are lazy and unprepared too
Lol
Like me
Cap
I showed up to an interview for an organization once
I improvised everything
I still got in tho
XD
But it was bad replies
Ya
See, I don’t want to ask stupid questions that even I won’t know the answer to haha
Maybe also ask like a problem too
Like a spigot problem
And let them describe the solution
Its so hard to find competent developers with serious experience with automated deployment or generally, just backend
Here’s what I did about a year ago https://github.com/Coll1234567/JMisc/blob/master/src/coll1234567/jmisc/listeners/PacketListener.java
It’s private
Scroll down to the PacketListener part
I extended the ChannelDuplexHandler, so I can see all packets being sent out and received with Netty
The downside is that you are left with Objects you know
Finding people who know how to code in a way that is easy to work off of/make changes are a pain too
And also you have to inject:uninject players too
Why should we avoid using common pool in terms of spigot?
|| Blocking other tasks the server is queuing on the common pool ||
Is one also
I think thats more important
Yes that’s what I did too xD
Great minds think alike
Gokor
I am soooo far beyond on Bukkit API knowledge, holy shit.
The best way to learn if someone’s is experienced is by gaining the experience yourself
What is the best way to learn the entire API? :)
Is that async like the protocollib listeners?
Try use every api method maybe, Maow
I don’t think so
not quick enough tho
I want like
docs
or not docs but tutorials
It’s hard to do it asynchronous tho
examples actually
Hmm darn
Don’t really want to loop 1024 values in a fairly hot packet on the main thread
Hmm yeah Idk because there’s a shit ton of outdated examples xD
Can’t exactly learn how to code in a short period of time though
But you’re right
Hire me
I can tell if someone’s experienced I’d say lol
ye and the wiki is waaay behind
plus I find docs to be a lil overwhelming if you're just trying to learn something
Well I have worked professionally under a company which had a spring project but else than that everything I do is more or less unprofessional, so you’ll just have to trust this bloke
But I love code reviews so ya
Indeed
Yeah I vouch you
You should first have them fill out a google form of some sort
Get some basic info
Then setup an actual interview
Have them make a join message plugin
Will probably weed out more people than you would expect
They could just copy code from deluxeasyncjoinleavemessage!
oh no, not DAJLM
oh my god that's a real repo what the fuck
I shall contribute another 100k blank lines for hacktoberfest
event™️
Define approved
#general message
Hahaha
but how fast is it?
Does it run and is it async
Also Gakor, ask if other devs can vouch for the dev ofc, but questions would be the one I sent earlier and some more if you want to I could send in DMs.
Uh
I think it’s async
And it’s possibly slow but since async it must be fast!
Sold, I’ll take 12
🥲
You’ve gone beyond heretere levels of annotation

Please, would be great
if async, it's fast™️
Some facts right there!
It’s a sink, it’s fast
if you open it in an IDE
and remove SuppressWarnings
is the entire thing just yellow on the right
if not, you're doing something wrong
it should look like Kraft cheese if it runs properly
Kraft cheese
Hehehe
i know how im' gonna make my app different from scarz's
he has everyone make their own bot
im gonna see if i can make one bot that everyone can use
Probably not cheap is the issue
You have to host the bot
it ratelimits you if you send to many requests
Where as DiscordSRV uses the server instance to host it, which is definitely ideal IMO
^
🤔
well maybe i won't be better than scarz's
but at least i'll have a fun project
cuz the point of it is to learn anyways
what the fuck is org.bukkit.conversations?
When a player dies or logs in, this is executed:
World world = Bukkit.getWorld("world");
if (world != null){
player.teleport(world.getSpawnLocation());
player.sendMessage("You have teleported to world spawnpoint.");
}``` The very first time a player joins they do not get teleported there. Why is that?
It’s for use with a prompting system
Basically you ask the user for input and they reply and then you can ask for more input etc
does anything actually use it?
Looks like you don’t need to shard until you hit 2500 servers
free till 2500?
my computers pretty beefy, wonder how much it could handle reasonably
You'd have to leave your PC on 24/7
Plus you need the network to handle that
Not free, but you only need a single instance for <2500 servers
Does Discord force you to use shards after 2500 or is that just recommended?
Sharding is only required at 2,500 guilds—at that point, Discord will not allow your bot to login without sharding.
Interesting
you can't charge for spigot plugins i'm betting
gotta look into pricing and see if its cheap or expensive
like $10/mo
for a coulpe hundred servers or somethin
i'd do that
that'd be fun
like from my own money
You can charge for spigot plugins
But people will probably just use discordsrv in that case
does spigot get some of that profit?
Don’t think so
xD
i like md5 anyways
if i made any money i'd donate
he's a good dude
wonder if mojang has any restrictions
didn't they sell to microsoft?
You aren’t suppose to sell things you make for minecraft
But I remember hearing they were okay with spigot so ¯_(ツ)_/¯
i dont think so man, microsoft even collected data for total money that the community got over the year by selling mod (idk if they count plugin as "mod")
All I'm saying is, if it cost money to run and it's worth it
people really cant be mad about developers charging for their work, the plugins take a long time and motivation to create
Yeah. Many plugins that are expensive usually took months of work
that is the dev choice
even if the plugin not expensive or hard to make, the dev still have the choice to charge it
now the rest is that he will get a very little money from it, or maybe the resource would get delete b4 someone see it
well i'll make an alpha
and all that
so i don't go wasting my time lol
i gotta lot to learn before i get there anyways lol
and all i'm really wondering is if its legal lol
seems like it is
guys can we do this?
onenable
registerconstructor();
}
public void registerconstructor() {
something = new someevenweirdthing(this);
}```
https://paste.gg/p/anonymous/049cb4e995824faf81eb157024dfc8fe any idea what causes this when building bungeecord? trying to edit the source
Yes? Though I'm not sure what you're trying to show. You just want to call a method and assign a field in onEnable()? Sure
public void onEnable() {
registerConstructor();
}
public void registerConstructor() {
// Some constructor
}```
hello
i want to show some data in the player's chat
and i want to use pages
and i want it to be automatic
like
if you type, /command 3 <- the page
it will show the page 3
:o
context: the player can have a lot of spawners
uHH
next page runs /command <page + 1>
previous page runs /command <page - 1>
it works: https://paste.md-5.net/galorovide.cs
is there a remove method for the FileConfiguration class?
i want to remove path with its value in my file config
im pretty sure setting it to empty does the same thing
just an empty string
so the key is still there
if i remember correctly, i havent used file config in a while
but the value is null
correct me if im wrong, but setting the value to null will make the key still exist right?
Setting it to null will remove the key
oh i didn't know that, thanks for that
is using the the bungeecord plugin channel needed for plugin channels to work with bungee?
maybe yes maybe not
that doesnt help
Not so sure about this
Yeah it doesn't remove the key
To my knowledge this is an implementation detail though
Different maps work differently, but HashMap is the most commonly-used implementation and setting null as the value does not remove the key
To remove a key you have to explicitly call remove
Ah, yeah
how do i make a command executable only once by a player?
If it’s just 1 you are probably fine just sticking a tag into the players pdc
If it’s several you probably want something external
ye never again
just once
This is assuming you are on >= 1.14
Then you need to save it somewhere persistent
The simplest way to do this?
Give the player a tag
player.addScoreboardTag("usedCommand")
Then later you can do player.getScoreboardTags().contains("usedCommand") to check if they have used the command already
Forgot about scoreboard tags
They can be quite useful
ah ok thank you so much dude
Do those change if you change the players scoreboard
I don't think so
I think that one only changes what is displayed to the player
It doesn't erase any data from the main scoreboard
i think the safest way would be to save in a json/db
Fair
What if they change their username?
or yml
It wouldn't matter
It's attached by uuid not username
Not really
That's so much more effort than just attaching a scoreboard tag
For something simple like this, a scoreboard tag makes sense
Yeah PDC also works
Probably better practice honestly
Good. I know like /scoreboard is still saved by Username for whatever reason so they break when someone changes their name.
But a scoreboard tag is also a perfectly usable solution, you might just want to namespace the tag so there's no chance of collision
What
Is it?
X
Same
I think so, atleast in 1.16.4 they still were. I had a death counter and if someone changed their name it went to 0
If they changed back, they got their old death count
It sure is lmao
If that's the case I would worry scoreboard tags work the same way
Use PDC in that case
Still has to resolve to primitives
bruh tf am i suppose to do then?
do i do with scoreboard
or what
PDC
what is pdc now
?pdc
whats the correct object you must use for UUIDs in arraylists
is it just UUID ?
from java.util?
Yes
any ideas as to why this isn't working when my UUID is in the arraylist? i also tried if(!array1.contains(player.getUniqueID())){
just in case it was an issue w/ my array handling
private Main plugin;
public ToggleBlockDebugger(Main plugin) {
this.plugin = plugin;
plugin.getCommand("wblockdebugger").setExecutor(this);
}
ArrayList<UUID> array1 = new ArrayList<UUID>();
@EventHandler
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
Location b_loc = block.getLocation();
if (array1.contains(player.getUniqueId())) {
player.sendMessage(ChatColor.GREEN + "[/wblockdebugger] You broke: " + block.getType());
player.sendMessage(ChatColor.BLUE + "[/wblockdebugger] Location: ");
player.sendMessage(ChatColor.GOLD + "[/wblockdebugger] World: " + b_loc.getWorld().getName());
player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] X:" + b_loc.getBlockX());
player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Y:" + b_loc.getBlockY());
player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Z:" + b_loc.getBlockZ());
}
}
public void onPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
Location b_loc = block.getLocation();
if (array1.contains(player.getUniqueId())) {
player.sendMessage(ChatColor.GREEN + "[/wblockdebugger] You placed: " + block.getType());
player.sendMessage(ChatColor.BLUE + "[/wblockdebugger] Location: ");
player.sendMessage(ChatColor.GOLD + "[/wblockdebugger] World: " + b_loc.getWorld().getName());
player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] X:" + b_loc.getBlockX());
player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Y:" + b_loc.getBlockY());
player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Z:" + b_loc.getBlockZ());
}
}
no events getting passed through or something idk, nothing happens on blockplace or break rn
is it registered
new ToggleBlockDebugger(this);
and
getServer().getPluginManager().registerEvents(new SQLLogger(this), this);
in main class
sec
thats instantiating it but is it being registered
you also didnt annotation BlockPlaceEvent
@drowsy helm getServer().getPluginManager().registerEvents(new ToggleBlockDebugger(this), this); included in main class
Yeah the lack of annotations would do it
@sullen marlin ah i see that now, onBreak is not working either tho 😒
Where is the onCommand code
public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
Player player = (Player) sender;
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players in-game may execute this command!");
return true;
}
if(player.hasPermission("watchblock.blockdebugger")){
if(args.length == 0) {
if(!array1.contains(player.getUniqueId())){
array1.add(player.getUniqueId());
player.sendMessage(ChatColor.DARK_GREEN + "[WATCHBLOCK] Block debugger enabled, repeat cmd to disable.");
Bukkit.getLogger().info(ChatColor.YELLOW + "[WATCBLOCK] Block debugger enabled for " + player.getName());
}
else if(array1.contains(player.getUniqueId())){
array1.remove(player.getUniqueId());
player.sendMessage(ChatColor.DARK_GREEN + "[WATCHBLOCK] Block debugger disabled, repeat cmd to enable.");
Bukkit.getLogger().info(ChatColor.YELLOW + "[WATCBLOCK] Block debugger disabled for " + player.getName());
}
return true;
}
else{
player.sendMessage(ChatColor.RED + "[WATCHBLOCK] You have specified too many arguments.");
return false;
}
}
if(!player.hasPermission("watchblock.blockdebugger")){
player.sendMessage(ChatColor.RED + "[WATCHBLOCK] You do not have permission to use that command!");
Bukkit.getLogger().info(ChatColor.RED + "[WATCHBLOCK] " + player.getName() + " was denied access to " + cmd.getName());
return true;
}
return false;
}```
further down in the class, all the command does is add/remove people from array1
and the command is successfully adding/removing from the array because my command output is flipping from disabled/enabled when i use /wblockdebugger
heyo, i cant use NMS in 1.17 - im wondering how i should use a nickname system then
mainly because, im not sure how i can change their skin, nametag, etc.
ok english
@young knoll any thoughts or no clue, im stumped lol i feel like this constructor somehow is related?? public ToggleBlockDebugger(Main plugin) { this.plugin = plugin; plugin.getCommand("wblockdebugger").setExecutor(this); }
idk tbh this is the one part of java coding i still fail to understand exactly how it works lol
i dont see how that constructor would be stopping the EventHandler from doing its thing tho
Why can you not use NMS
i guess you arent supposed to or something
- the classes are obfusicated, which i could just de-obfusocate im sure but i really cbb
if i have to de-obfusacate i'm sure that's just gonna need constant work
ok my PDS worked, but i have a query. If i delete my world, will the NBT values reset?
If you delete the player data, yes
Player data is stored in the main world
and i use a command which sets player's nbt value
now if i go to another world
will the values be different?
No
different worlds have same nbt values?
uh kk thanks
Hey guys, i need some help. So i'm storing player data by their UUID. Now when i try to check if the playerUUID exists in the data. it returns false
Even tho its inside the data
@pastel stagAre you having the same issue?
md_5, wat is the first thing you guys do when a new version come out huh
can you send code?
we can't just guess
public boolean isOwner(UUID playerID) {
boolean isOwner = this.Settings.MasterAdminUUID.toString() == playerID.toString();
Bukkit.getLogger().info("Admin = " + isOwner);
return isOwner;
}
I've checked the data and the masterAdminUUID is indeed the playerID
But it returns false
why do you need to compare them both .tostring
if they are both uuids they dont need to be converted
and its probs because you are using == and not .equals
== generally will not work for strings
yeah its a stupid java quirk
thanks for the quick help ❤️
How is it a stupid "java quirk"
One checks to see if its the same object, other checks if they have equal value
@maiden mountain no my issue isnt w/ the array or UUID storage
What is your problem atm? The events not firing or the contains not working
do i have to separate an @EventHandler from my toggle and put it into a different class?
i still am clueless as to why my toggle eventhandler is straight up not working
Also in Java field names should be lower case, but it really doesnt matter. I recommend it to avoid confusion. IntelliJ doesnt handle different naming conventions well
Sorry field i mean
i have a file configuration named "config" what method do i use to get all the contents from it?
if it is config.yml you call in your onEnable() saveDefaultConfig()
no its not my config.yml
then you can access it from yoru main class with getConfig()
no, i already have the file configuration object
what method do i use to get all the contents from it?
config.getKeys(false)
as string
oh so if you put false it'll give you all the keys as a list?
when are enum values loaded into the enum?
or better wehn a make a value with two paramaters when is the constructor called?
Huh? Those are just public static final fields, those are initialized when class loaded
ah
What are you trying to do
i was putting all the values indside a map so i can read from that
and i was wondering if the map was filled correctly
Ah yes that would work without any problems
what is more efficient: getting a value from config or getting it from a map?
negligible difference
does anyone know how to use the Custom Display plugin? or do you have a tutorial to it? the plugin:https://www.spigotmc.org/resources/custom-display.85568/
and uh if try to get a value from the config that doesnt exist? does that return null or an empty string?
ah null
?paste
well the parsing in get0() doesnt work because no arguments are given so i can clear that
change get0 to a static block
pretty sure it returns null unless you give it a default argument
so you fill your map when teh class is instanced
but i cant access non static things in a static block
because if the given value doesnt exists it takes a default
make it not static :)
a static block which is not static 🧠
fivehead
its an enum class so your values shoudl be static
Look at caching and lookup values https://www.baeldung.com/java-enum-values
i have to make them static explicitaly?
@Override
public void onDisable()
{
for(Guild guild : this.getGuilds())
{
for(GuildChunk guildChunk : guild.getOwnedChunks())
{
guildChunk.getChunk().load(true);
this.getLogger().info("Chunk loaded successfully!");
for(Entity entity : guildChunk.getChunk().getEntities())
{
this.getLogger().info("Located entity");
if(entity.getCustomName() != null)
{
this.getLogger().info("Has custom name");
if(entity.getCustomName().startsWith("Verteidiger von "))
{
entity.remove();
this.getLogger().info("Is a guardian: Removed!");
}
}
}
}
}
}
Output:
Chunk loaded successfully!
Chunk loaded successfully!
Chunk loaded successfully!
There is an unloaded chunk, which the plugin loads and then remove the entities. But after loading, the plugin don't recognize the entities in there. How do I remove entities in an unloaded chunk?
you can;t remove entities in an unloaded chunk, however when the chunk is loaded the entities are not actually loaded at the same time. You have to wait a while for the entities to be available.
Hm. I will try with a schedule.
@Override
public void onDisable()
{
for(Guild guild : this.getGuilds())
{
for(GuildChunk guildChunk : guild.getOwnedChunks())
{
guildChunk.getChunk().load(true);
this.getLogger().info("Chunk loaded successfully!");
new BukkitRunnable()
{
@Override
public void run()
{
for(Entity entity : guildChunk.getChunk().getEntities())
{
getLogger().info("Located entity");
if(entity.getCustomName() != null)
{
getLogger().info("Has custom name");
if(entity.getCustomName().startsWith("Verteidiger von "))
{
entity.remove();
getLogger().info("Is a guardian: Removed!");
}
}
}
}
}.runTaskLater(this, 40L);
}
}
}```
Can I do something like this?
you can try it
I hope, the server doesn't stop while this is executing.
I knew it: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register task while disabled
um, you ran it in onDisable?
oh yeah, no you can;t do that.
no scheduler
and chunks will not be loaded in onDisable
Okay. Then I do it in onEnable.
I thought you said you wanted to remove all entities when the chunk loads
It's the same for me.
That makes no sense
Why?
English
This was your question
you can;t load chunks in onDisable
Okay. Sorry. My bad
I am using 1.8.8, and need to get the packet in NMS that teh client sends to tell the server it hit something. what packet is that?
oh wait
i think it is PacketPlayInUseEntity
Hi, I have a few questions about 1.17 nms.
- Are Spigot mappings no longer used at all?
- Running BuildTools with --remapped generates two jars, remapped-of and remapped-mojang. Is remapped-obf equivalent to the jar generated when running without --remapped?
- Internally, is CraftBukkit coded against Mojang mappings or obfuscated code?
can anyone help me understand why @EventHandler in that ^ is not doing its job?
its as if events are not being passed through to that class but i have
getServer().getPluginManager().registerEvents(new ToggleBlockDebugger(this), this);
in main class
so i dont get it
- Spigot mappings are still used for spigot development (e.g. the craftbukkit and bukkit source code are developed against a spigot mapped server version)
- I think the obf mappings are full obfuscation and closer resemble the original server layout you'd get in a vanilla jar (e.g. classnames are obfuscated as well)
- See answer 1
@idle grotto
pretty sure your listener works
but creating two instances of your ToggleBlockDebugger means they obviously do not share their state
it doesnt do anything 😒
oh wait you are not creating two instances
mb
well, I guess grab a debugger or spam broadcasts to validate your code being called/not called
hi
how can I reduce the height of an armorstand like in this picture? https://ibb.co/3m5g8DB
a small armorstand ?
its small already
can you run if() statements in an @EventHandler?
anyone?
yes
are you sure you are not registering your command in some other way with a second instance ?
nah
im going to rewrite a big chunk of this
maybe i made a mistake here im just missing
does event.getPlayer(); somehow work differently than pulling CommandSender from a command executor
this is definitely where my problem is i feel like now after rewriting this
onBreak is looking for my uuid in the array and not finding it FOR SURE
something is different about the data UUID the event.getPlayer().getUniqueID() method from the CommandSender.getPlayer().getUniqueID() data
shouldnt they produce the same exact UUID object
omg
ok so you cant add object UUID you HAVE to use event.getPlayer().getUniqueID().toString()
I need some git help
why does it show all those class files etc
here's the repo https://github.com/JEFF-Media-GbR/JeffLib
.gitignore looks like this:
# Project exclude paths
/target/
*.lst
*.class
/.idea/workspace.xml
*.iml
target/
compile/
*/target
*/compile
somehow both IntelliJ and VSCode still want to commit all those files :/ I have no idea why
e.getItem().getItemMeta().getDisplayName() - From an event
Why does this return a NullPointerException but the code still works?
Makes the console very hard to read..
Item or itemMeta could be null
Material.AIR has null itemmeta
so do I first check for the Item and ItemMeta not to be null?
yes
ah thank you
np^^
buuuut can anyone help me with my git problem pls?
if (e.getItem() != null && e.getItem().getItemMeta() != null) will this work
all my plugin repos are fine, it's just the JeffLib repo that's causing problems
+1
that will work
I feel like if you scroll up there is probably like a parent for it
Not sure tho..
ArmorStand#setSmall(true)
what do you mean?
sorry I don't understand that sentence completely 😄
its small already
you mean a git project in another directory? that actually can't be because all my other projects are working fine and it also happens for other people who clone that repo
parent = something like this
Files
↓
SomeFile.java
but it also happens when other people clone the repo :/
I posted the github link above in case someone wants to troubleshoot 😄
then just reduce the y coord?
Hmm sorry I don't know
thanks anyway 🙂
but just wondering what can your lib be used for? 🤔
Hey guys, i want to have a Custom Tag above the Player Name, it works perfectly with 2 players but if there are more players, the Custom Tag get duplicated:
https://hastebin.com/kaqopufuni.csharp
How i run it:
https://hastebin.com/igapovifat.java
How it looks with 3+ Players:
https://ibb.co/m41FB1c
How it looks with 2 Players:
https://ibb.co/VvvHG9G
I think the Problem is the loop (As an example in the teleport event but I have no ideas.)
it basically has a hundred functions that I need from time to time, like parsing recipes or itemstacks from human readable configs etc
oh i see
I also have very outdated javadocs for it on https://repo.jeff-media.com
but 50% of the methods arent included there
ah i see
do you know any library that can help me get working with config faster
my tiny brain can't handle the config stuff
specially because i just got into plugin development
what problems do you have with configs?
I do it like this all the time:
I have a class called Config and it has public static final Strings with the config node names
like
public static final String USE_PERMISSIONS = "use-permissions";
and then everytime I do things like
if(main.getConfig.getBoolean(Config.USE_PERMISSIONS)) { ... ```
the config class also sets default values for missing config options
my angelchest plugin's config is 1700 lines lol
what.
I'm definitely a junior
oh damn
yeah people like config options lol
but I have to add
there's many comments in the config.yml file
and also translations
@latent dove https://paste.jeff-media.com/?4f6f15ac78b5120f#CMqaYcSk4LAH6DrLFpFGhVz6LpSJoMA1fDHZWc9LUype
Post and share your source code or server logs here.
that's the default main config file
but yeah there are other config files too lol
create a yaml file inside resources and add all the things you wanna be configurable 😄
im kinda dumb so bare with me
i can't find anything that helps me with the code on the internet
ye sure
ima do that
okay sooo lemme try to summarize it
in onLoad(), call saveDefaultConfig
it will save your config.yml so people can edit it, unless that file already exists
mhm
and then you can simply do getConfig().getBoolean("my-option") etc
or getString, getList, getItemStack, etc ....
and how to reload it
getConfig().getInt("age",20);
that will return the age, or 20 if it's not set in the config
JavaPlugin class has a method called reloadConfig
So that means
# Amount of zombies to spawn per player
zombies-amount: 50
and
getConfig().getInt("zombies-amount");
yep it will return 50
i see
or 0 if the config doesn't include any "zombies-amount" setting