#help-development
1 messages · Page 284 of 1
Okay, that makes more sense. I am bit new to using an API so all of this is overwhelming
My lord, how can there be such controversy to such a simple API, hahaha :,D. I love it tho, keep on going, xDD.
Will it work on 1.7?
No, why? Apis are designed to make things simplier, so there i dont see it viable
It sure is, you have to take your time and just open up a new playground plugin to experiment around with this stuff on a localhost. It makes a lot more sense once you know what the API actually does behind the scenes.
Cause we only build for the newest version obviously?
He is gonna make a pull request to spigot itself
not a plugin
As far as I know, it has been proven that companies that only target one sector have lower average profits compared to those that offer their products to the entire public, dont you think it?
With that it's doomed for mediocrity already. Just don't do anything fancy, proper or version-independent, or you get denied.
shush.
Na haha dont get mad Jan, im just fucking tho because i used to be 1.8 developer. Now only +1.16 comissions
Still gotta work on my @Since stuff lol
They does, great flawless Bedrock version is made with C++
oh nice tho
What properties will you put for a Group object? So far i have name, weight, prefix and nodes
Group object? Parents are missing, if I understand you correctly. And what do you signal with weight?
Group for managing permissions
Their priority (weight)
Yeah then, parents, most definitely. And a list of negative permissions which are subtracted from them and stop propagating down the inheritance chain.
I'd actually call it priority then, not weight tbh, as that's kind of confusing. Weight is a known term in computer science.
Okay, can you explain the propagtion part?
ok, thanks ill take your recommendations
Well, if a group has a parent, it inherits all of those permissions in it's #hasPermission check, but it does not own those permissions itself. If you have Group C inheriting from group B which inherits from group A and group A gets my.example, B gets -my.example, C will not have my.example, as B blocked it. B will also not have it.
Do you think this way of saving/loading is correctly? or will be any better
Mongo 
How I know plugin's RAM usage?
Why? Because they will use it on a large network
I have no idea what that's about without extra context, sorry.
Well, because it perfectly fits a relational model, but sure, pick your tools, you are free to do so.
I mean not only have to sync between a network i have to sync around different proxies 💀
Its not so simple tho
HAHAHAH
Lol
Use one global sqlite file /s
Can someone help me im tryna make a server with a strength 2 area basicly when ever u go inside the area u get strength 2 but if u leave it goes away if that makes sense can someone help me with the script pls
Is SQL more scallable rather NoSQL? How much? Are there unit testings?
Are you planning to have all servers access the DB and use transactions to synchronize, or do you want to pass around info through messaging channels, as in an in-memory event database?
They told me i must use something like RabbitMQ
Well, think of it as you don't have to load an entire object everytime you want something. You can query specific things instead of needing to pull entire documents
Well, mongo allows that tho, that why it contains Filters
But it's still loading the whole document
I mean im not wondering to fuck with this, just understand why most people use Sql
Assuming you're mapping PoJo
Im not using Pojo´s so far, because it cause me lot of issues
SQL allows you to get only the data you need from queries
Since it's relational it also works better for things that require relationships
I must use RabbitMQ, but i dont like as much a Redis because Rabbit doesnt have the ability for catching data in memory, its more like a data broker
Must? Wow, that sounds harsh, xD. You can easily write your own little protocol, you just have to deal with acknowledgement and so on then.
Mongo does too, IIRC? You should be able to select individual fields using a query on any good database implementation.
Yeah, but they told not to reinvent the wheel when its already invented, also it wouldnt so optimized as a software already created and which has years of experience
Sure thing, it's a good choice.
Just wondering how you got into such a massive project.
Because, not trying to be mean, but I think you might bite off a bit more than you can chew with that implementation. LuckPerms (i think) also does this stuff, and it's a huge ass sophisticated project. You might burn yourself out in trying to create something similar.
I join caused a Russians recommend me in that project but i never realize until the owner contacted me and told me if where interested
It does? Damn you, point taken...
I mean... well, that doesn't dictate how one has to design their API, by no means.
Yeah i told them many times, they can use perfectly, but they excuse was "we wanna have every plugin as custom as we can"
And my face was 🤡
I think you should support both, as the tab instance knows it's width, so why make caller have to use their brain to calculate stuff...
Like if you want to use RabbitMQ you will have to implement event driver architecture
Just trying to give you a heads up. Believe me when I tell you that you'll probably burn out and be sad in the end. I've still got a big ass project on my disk where I created a whole server from scratch, used nothing existing, burned out and felt like shit.
It's harder then Http or direct push to database because you will not get response if data has been saved to database
What is scratch?
From scratch just means from the ground up without any libraries.
Or a beginner's "programming language", lol.
More likely a game engine for 10 years olds
Well, you'd have to design that yourself, I think. The bungee-server should write to the DB while all sub-servers only keep state based on received events in memory. But I guess you'd always need an ACK from the bungee instance, otherwise you'd need to throw up all along the call-chain. Basically implementing transactions.
Me neither, no worries, I have a hard time with human languages too.
Nice, german?
Austria, xD. But yes, my native language is German.
Can we just delete this please
if I get hacked idc
this is the most annoying shit at least add google authenticator support
Other people care when users upload malware to spigot
oh also, there is google authenticator support....
I legit use Authy on my account
Hover on your profile -> Two-Step Verification -> Verification Code via App
then they can enable it
I'm not an idiot who downloads random shit
bro why are you typing to me do you have aspergers?
I know its catered to children like you 🙂
Nope. You also don't have to send raw bytes over HTTP just because TCP does. It's called abstraction. If I, as an API designer, think that rows and cols are a better fit, I can translate internally without letting this detail bleed through.
But please, let's just settle on our agreement of adding both slots and grid methods, xDD
It has?=
What are you on about
google 2fa is supported.
lrighty, I'mma head out.
Yes I just noticed it now after I logged in
Yeah both are useful
Hello,
This is my code which is supposed to move the entity to the players position with a vector which is perfectly working, when both locations have the same y-coordinate. If not then the entity flys way higher than the player is and also far beyond the players location. Does anyone have an idea why and what I can do to prevent this?
Entity e = player.getTargetEntity(distance(p), false);
assert e != null;
Location loc = e.getLocation();
Location target = player.getLocation();
int aX = target.getBlockX();
int aY = target.getBlockY();
int aZ = target.getBlockZ();
int bX = loc.getBlockX();
int bY = loc.getBlockY();
int bZ = loc.getBlockZ();
int x = aX - bX;
int y = aY - bY;
int z = aZ - bZ;
Vector v = new Vector(x, y, z).normalize();
v.multiply(loc.distance(target)/2.7);
e.setVelocity(v);
Hmmm, those last three lines seem kind of weird to me tbh. You're normalizing the vector, thus dividing each coordinate by it's length (the distance), then multiplying by the distance divided by 2.7 again. Instead of normalizing, you can just divide by 2.7. That's not solving your problem, but at least helps readability, first of all.
was EntityPickupItemEvent switched to PlayerPickupItemEvent
or did it just not exist in 1.8.8
Shouldn't v be inverted? if player has y 500 and an entity 400 then y is -100 but should be positive to reach player position
because IntelliJ warned me that it could be null but I checked earlier if it was null or not. It's just a formality
I have forgotten how minecraft applies velocities, but from knowing that velocity is speed in m/s, I guess it applies 1/20 * velocity to the target's position at every tick, to apply the whole vector every second. You'd have to consider drag as well, which is dependent on the distance travelled.
What you want to accomplish is move the entity along the vector between the player and itself (end - start, as you correctly calculated). The simplest way of doing this in a linear motion, you could teleport the entity along the path this vector dictates by multiplying it in the range of [0;1] in a loop, taking step sizes in a way that you have consistent velocity no matter of distance. This teleportation could be performed on every tick, as it's not really any more expensive than sending out move packets (which the server essentially does) every tick.
Velocities in minecraft always weirded me out tbh, maybe I'm just stupid.
you mean the entity has y500? because the target is the player. But if the target was below the entity then the entity should move downward
Ye
so you're suggesting to make a scheduler?
and teleport the entity every tick along the vector?
Why tho? They're calculating end - start, which gives the vector from (0, 0) and the length and direction of the distance. Applying that to the position of the entity will result in the vector's pointer to be exactly on the target.
Right exactly. Because - in essence - adding a velocity to it does nothing else, but you have one big issue: simulated physics, which works against what you want to accomplish.
With a scheduler you don't have to compensate for physics.
I'll try that but how do I teleport an entity along a vector?
Not at all meant in a mean way: how good do you know vector math?
I didn't really understand it tbh XD
but that would instanly teleport the entity to the player
loc = playerLoc + (target - playerLoc) * Range(0;1)
Let me come up with a quick example for you, I know that it can be hard to understand if you're not into math as a hobby and haven't done it in a while. I'll get back shortly.
thanks
thanks!!!
playerLoc being the start position all the time
Location playerLoc = player.getLocation().clone(); for (double t = 0 ; t <= 1 ; t += 1/20D) { Location loc = playerLoc.add(targetLoc.clone().subtract(playerLoc).multiply(t)); player.teleport(loc); }
Written on my phone
But in a scheduler
Because that would just teleport to the end within the same tick
oh god please use actual variable names
Is there a way to check if an inventory was opened to the player by a plugin? I'm trying to replace crafting UIs from crafting tables but not from commands owned by other plugins
but yeah you basically want to lerp between 2 points
I'd just be very careful with calling clone all the time. You're generating a hell load of new allocations for no good reasons. It's a shame that all of these utilities mutate in-place. And second of all, your step-size does not compensate for distance and thus won't yield a constant velocity for all distances.
thanks very much for the help!
Which can actually be harder to implement efficiently than one might think on first glance, lol
one-letter variable names should be reserved to x, y and z
What about i, j, k?
nope
Inventory#getLocation is not null even when it is a virtual UI
and Inventory#getHolder is always the player anyway because the crafting table cannot be its holder
Just gonna take a few minutes as I actually want to give you something that's efficient and understandable.
I really appreciate that, you can also dm me if you want
I'm just going to post it here, as it'll be a general solution and might help others too (if they ever manage to find it, haha).
XD
Variable names should be short yet meaningful.
Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.
Yeah okay but it’s still a Oracle convention
And I have seen this in all kinds of programming languages
That’s right, if you want a constant speed for different distances. That method allows to easily set a duration, so it depends on what you want
Which method do you mean? Just having a hard-coded step size doesn't allow to set a duration, as the duration is depending the distance travelled.
t += 1/duration
?conventions
Ah yeah, sorry, I misunderstood that part. Of course the duration is choosable, depending on the delay between iterations.
We had that already
yeah but the bot is better
True
Why is player.getTargetedEntity() only returning LivingEntities and no other entities? Is there a way to return all targeted entities not only the LivingEntities?
That method is not part of the Spigot API
Guy from whereami gif making mistake again
Oh that's why I didn't find it lmao
You could try this approach, although I haven't actually tested it myself: https://paste.md-5.net/fanaruyoci.cs
nonono don't mention it
Because the LivingEntity is the most abstract type there is for entities which still makes sense in this context. You have to check for specific entities using instanceof yourself. But you get all entities which are living.
Oh, you probably mean things like ItemFrames, huh? I actually haven't used that API ever, I think when I needed something similar I actually casted a ray.
bro this helped me A LOT
Thanks so much
Has anyone benchmarked using reflection with cached methods and classes?
I actually hope that it works, because it has been a long ass time since I had to think about all of that, xD. Love to help, as I actually know exactly how it feels to be overwhelmed by things like these.
Probably not, so we should! :). How funny that I just yesterday thought about doing this, lol.
Hi, i bought a server a few weeks ago, everything worked fine. Since today when i run a command of a plugin that i wrote, after 1 minute my server crashes and gives the error Startup script './start.sh' does not exist! Stopping server. Can someone help me? I didn't made any changes on the server, just uploaded my plugin
i implemented cached reflection into my plugin today
Send the server log
?paste
Yeah probably
Btw, just to make sure, what exactly are you guys define as cached reflection?
i cached the fields/classes/methods
so i dont have to get them each time
it should be faster
Yes that
I only use cached reflection then, as my library searches all dependencies (class, method, field, constructor handles) in the constructor of the class trying to work with them so the plugin won't even load if we're not compatible.
Doesn't that java do by default?
but do you load them each time?
Or its only kotlin
i dont call .getDeclaredClass(classname) every time
My command runs titles, after the 6th Title (1minute delayed) it crashes
i dont think getdeclaredclass has cache implemented
I doubt that it's much worse than direct access, as a Field should basically provoke a field access instruction with the overhead of a method call, right?
Well idk how reflection works internally so i cant say but I'd assume so
and for fields i have static fields set to accessible
(when needed)
i know for a fact mine has to be faster than non cached
I also only assume it, but it would be stupid otherwise. I don't get why "reflection is sooo slow" should hold true, as it's perfectly optimizable. You basically wrap the field access instruction in a method called set/get.
It has the lazy access
because to get some classes i have to perform operations with streams (or for loops alternatively), and doing that each time is slower
Depends, the JVM might cache itself. But it's definitely far more sane to do so yourself, yes.
Using something like reflectasm which generates bytecode that runs, it goes wroom wroom
Don't sleep a thread
maybe, but the stream/for operations will still be done each time
Hahahaha :,D. Damn, never heard of that, need to look it up asap, lol.
i call .getdeclaredmethods then filter
what should i do either?
discord?
When you sleep a thread, the server thinks the thread is no longer responsive
how have i not read my own message
damn
What do u want to do?
i am such a idiot haha, bought 5gb extra ram haha
Do something x ticks later?
Same, just differently. https://github.com/BlvckBytes/BBReflection/blob/main/src/main/java/me/blvckbytes/bbreflect/packets/InterceptorFactory.java
It's used heavily in this @dry yacht https://www.spigotmc.org/resources/twerktree.35496/
yeah
?scheduling @young nimbus
thanks
anyways, im having a problem setting a player's gamemode
Wow, what a plugin name, xDD. Going to have a look rn.
What's the problem?
its not working
...
Why don't just... Player#setGamemode or smth
this is the output, and the gamemode is survival
its not working, so i used the nms method which has a return type (boolean)
the api just calls the nms method and ignores its return type iirc
Guys , can it work??
`import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import static org.bukkit.Bukkit.getServer;
public class Eventi implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
FileConfiguration config = getConfig();
if (config.getBoolean("block-break")) {
getServer().getPluginManager().registerEvent((Class<? extends Event>) BlockBreakEvent.class, (Listener) this, EventPriority.NORMAL, (EventExecutor) new BlockBreakListener(), (Plugin) this);
}
return false;
}
private FileConfiguration getConfig() {
return null;
}
}`
<insert your favourite indent hell meme here>
the weird thing is
No, never, actually.
why? pls help me
as oggm (original gamemode) is survival and the gamemode im trying to set is spectator the only way "gm" could be false is if PlayerGameModeChangeEvent is cancelled
Hey guys! i'm having an issue with world creator. When making the new world, players end up being disconnected due to it taking too long. Is there a way I can prevent this
the thing is i only have my plugin, which never cancels that
plus after that p.getGameMode is somehow spectator, which shouldnt be the case if setGameModeForPlayer returns false that way
Man, that hurts my brain
How is something that simple not working
??
How
What mc version?
idk
Looks great
Wait you mean the world takes so long to load?
In actuality its loading an already created world, but while its creating the spawn it takes too long and players get disconnected
Just joking btw, that's normal code, xD. Not one of those "never-nesters", although I love unnested code where ever possible.
haha some of my old plugins have way more
I should probably have used something other than triple, but was too lazy.
The names of the classes are also a bit weird
you can remove the newlines after the first two for loops
if you remove the braces
its not pretty
but ¯_(ツ)_/¯
Btw, what the hell is a ServerPlayer
mojang mapped version of the nms version of craftplayer
NMS Player
which i dont remember the name of
Very broad question to be honest, completely depends on what you're trying to accomplish. Almost unanswerable.
Probably old EntityPlayer
yes that
Oh, okay. I'm just still stuck in 1.8 times, sorry, xD.
Got it after the 10th try 😂
why?
me too lol
I am drunk of course i type badly
This doesn't return a boolean, what version are you on?
I was cheering for you to do it
hey now ive realised my intellij theme is gone
i knew something felt wrong
That was a joke, sorry for the sarcasm involved. I have no idea actually, as I'm about to pass out after multiple nights of next to no sleep and a full day of coding. Sorry, but I cannot help you right now, you ask way too much with way too little context and explanation.
thats the craftbukkit method
Hahaha, yes, that's the theme I've banned from ever coming back.
im calling .a()
oh ok , np
just the mojang mapped version
which in mojmaps is setGameMode
Oh, sorry, I really need to sleep soon. Just want to check out how that boolean is defined.
Oh come on, .a is a void too
What version are you on, 1.19?
huh
@civic apex Delay it by 1 tick
i tried, still didnt work
sometimes it did
didnt test too much
Yeah, at 1.13 it's not a boolean yet, they changed that. I was on 1.13
._.
wdym by whole code
its for debugging aisnduaybdawdmoia
k
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
recentQuitPlayers.remove(p.getName());
if ((!Uhc.gameManager.isStarted()) || Uhc.gameManager.getAlivePlayers().contains(p.getName().toLowerCase())) return;
PlayerDeath.setupDeadPlayer(p);
}```
Hmm, depends on which path gave you the false
uhc plugin yes
Are you sure there are no other plugins listening for events?
not 100%, i only unloaded them with plugman and no errors
setupDeadPlayer sets the game mode?
yeah
Okay now try delaying that by 1 tick
the gamemode set?
i already have previously
Just the entire method call
k
And then show your entire setupDeadPlayer method too
public static void setupDeadPlayer (Player p) {
p.setHealth(20);
p.spigot().respawn();
Player teammate = UHCTeam.findTeammate(p);
p.teleport(teammate);
ServerPlayer sp = ((CraftPlayer) p).getHandle();
Bukkit.broadcastMessage("oggm " + sp.gameMode.getGameModeForPlayer() +"\ngm " + sp.setGameMode(GameType.SPECTATOR));
Bukkit.broadcastMessage(p.getGameMode().toString());
new BukkitRunnable(){
@Override
public void run() {
p.spigot().respawn();
teammate.addPassenger(p);
}
}.runTaskLater(Uhc.getInstance(), 1L);
}```
ik im calling respawn twice also for debug
You call respawn after setting the game mode
does that set it to survival?
Possibly
True that, but it still doesn't fully explain why the method returned false.
ugh i hate eclipse, i get an error in line 69, could someone look over it rq? https://paste.md-5.net/tulelorilo.java
wow respawn's big
index += 2;
why do you add him as passenger and not as spectatorTarget?
what's the error?
idk
its different
preference ig
You cannot change a variable's value inside a lambda expression. It only captures it's value, but that's immutable then.
I'll send an example of how to do it
thank you, appreciate it
You'd need an AtomicInteger, which is a pointer to an integer, which you can then call incrementAndGet on
Is there any good alternatives for teleporting an armor stand every 1 tick, im moving it up and down while rotating it
Make it look as smooth as possible
I could do 3-5 ticks ig
Btw, you're not stopping the task either. Return doesn't stop the task.
Bukkit.getScheduler().runTaskTimer(Main.getInstance(), new Runnable() {
int index = 0;
@Override
public void run() {
if (index >= titles.length) {
// We've displayed all the messages, stop the task
return;
}
String title = titles[index];
String subtitle = titles[index + 1];
// Display the title and subtitle
player.sendTitle(title, subtitle, 1, MESSAGE_DELAY_TICKS, 1);
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f);
index += 2;
}
}, 0, MESSAGE_DELAY_TICKS);
thank you very much!
Alternatives as in what? You could use move packets instead of teleportation, as that interpolates between positions on the client, which in essence makes it look more smooth again.
dont tell me you have titles and subtitles in the same array
Ah yes, the anonymous class, a classic! xD
have a title array anda subtitle array
What's wrong with that?
ArrayIndexOutOfBoundsException
Okay, im just trying to make it as fast as possible
Aka performance
Why? As long as it's member-count is even
String title = titles[index];
String subtitle = titles[index + 1];
sure that work but it's clumsy
Yeah, then you could do move packets and step up the delay between moves a bit, but well... whether that's worth it? Or you send teleportation packets and go async, as you're not altering the world anymore.
Oh come on, it's common practise in low level languages. But okay, I get your point.
Oh, bet okay thank you
low level languages
Use a lambda expression
Also ..
?main
for low level languages anything goes because you want efficiency
that's an anonymous class, cant use lambda
?main
not my plugin lol, was fixing code for someone
@humble tulip at de.can.pravenregelsystem.commands.RegelnCommand.onCommand(RegelnCommand.java:56) ~[?:?] https://paste.md-5.net/ulegibavak.java
I feel that so bad, I really need to go to sleep soon, xDD
i need to go to sleep, ugh
send the exception
that's where it is
but what type of exception?
org.bukkit.command.CommandException: Unhandled exception executing command 'regeln' in plugin PravenRegelSystem v1
Just send the entire thing..
you have int index = 0 twice btw
?paste
send the entire stacktrace
Send Main.java
You probably got a messed up singleton pattern somehow
this
ohhhh
yh
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
eh he's new
Good time to learn good practices
let them have fun first and then learn better practices
Good time to quit also
Di isn't exactly hard?
Maybe not for somebody who knows programming well, no. But programming is not exactly natural logic, you're not born with it. So some people need to take it slowly.
"it just works", haha
thanks @humble tulip
gn
unrelated, but ive read that some times now and still dont get why i shouldnt use a static singleton
Basically because of coupling. You're locking yourself in.
in bukkit development at least
theres one and only one javaplugin, and only one will ever exist
Passing a Plugin (interface) as a parameter doesn't couple you to a main class called "Main", it only couples you to bukkit's API. If you copy the file in another project called "Playground", you'll have to rename all "Main" symbols.
but for the plugin itself its a non issue
di isnt more performant afaik
Almost none of the bad practises really are an "issue", as long as it works. But you do want to become a better developer, don't you? :)
yeah but i see problems with di too
Don't think so, tbh. The compiler is very likely smart enough to notice the singleton pattern and optimize the method call out.
not for the compiler, more for the mantainability
ByteBuf newDS = (ByteBuf) pds.newInstance(Unpooled.buffer());
writeVarInt(newDS, windownID);
writeVarInt(newDS, windowType);
BaseComponent[] component = new ComponentBuilder().bold(true).appendLegacy(ChatColor.RED + "Coool enderChest :)").create();
byte[] newMsgByteArray = ComponentSerializer.toString(component).getBytes(StandardCharsets.UTF_8);
writeVarInt(newDS, newMsgByteArray.length);
newDS.writeBytes(newMsgByteArray);
readPacket(newDS);
Object newPacket = con.newInstance(newDS);
creating packets the wiki.vg way
Sure thing, have a smaller constructor but end up in couple hell.
i've never seen it as "hell"
also i dont know if im going to need a plugin instance
How often do you even have a massive constructor
Then you don't tend to write your own reusable libraries/modules.
so if i dont i make the constructor w/out
i mean thats true
Abstraction of logic requires dependency injection.
i do create utils but per plugin
I know it for a fact, because that's how I thought too before I got into the more advanced architectures.
If a single class has a huge ass constructor, you're not segmenting it's responsibilities well enough.
And having many files in OOP projects is a shitty argument in my opinion.
di only helps make it bigger tho
Yeah, because every number except than zero is bigger than zero, lol.
thats not true
If you hate wiring constructors so much, use an auto-injector.
it's not even that hard
whats that
excuse me, every natural number.
yeah i do that
not saying its hard to make
i just dont like having to specify a plugin instance per constructor
A central registry where you register all your available dependencies and it invokes the constructors and matches instances for you.
then specify JavaPlugin
ofc if i was writing a library i would do that
Not every constructor should need one. But there's no shame in taking one in, lol.
tfw your main has more "this" than actual words
You gotta have the ugly parts somewhere. And if you wanna sweep them under the rug of runtime, use the registry and a java class scanner.
Need a bit of advice, I am in a big project and I am making something to help do something faster and semi automatic, right now it’s a plug-in but I need it to be faster , problem being I am new to making plugins and kind of new to Java so while everything works, it needs to be faster , rn the plug-in can do an area of around 8mil blocks in about 3-4 seconds but when I need it to check an area of around 500m +, maybe up 1 billion blocks, well the plug-in needs to be better, rn when trying to do large areas the plug-in lags the server so much it crashes , rn it’s not asynchronous so it lags the server quite a bit, for every block in the area it has to check some blocks around it, about 12-24 blocks total and then it decides if it is changing the main block so a lot of checks , rn I am the crossroads, do I continue trying to make plug-in better and not crash the server when doing the volumes we need it too, segmenting the total area to do one after another (in game), or piggy back off of fawe and try to Learn and use craftscript , any help for either option or a different option that may be better .
why are you in a big project if you are new to java and plugins?
What's the command for load balancing again? I forgot
that's uglier ig
Just split the scanning of blocks over multiple ticks so the server doesn't crash
It’s a mc project, not a plug-in project, making plugins to replace old datapacks I had made, plugins are better and faster than datapacks.
D:
oh
the plugin class is usually just like a central hub
contains trackers, managers and all
whats a tracker
90% of cases it's just this
?workdistro
no
as it's not explicit
why?
For more context , the world for the project is around 4gb…….. Compressed. Around 20gb on disk , not going through all of it though
wdym
it somewhat breaks single-responsibility principle too
how?
Classes usually stick to a few types
Tbh, I don't think that this is deal. I think the best solution lies somewhere in the middle, where you register all dependencies and all classes which need to be singleton instantiated, and the tool then figures out in which order to create them, if they require each other. That way, you still got references to their symbols and dead code elimination will be applicable, but you can just add another arg to the constructor and don't have to change up the wiring or in the worst case: even the order of instantiation.
No idea why you're against a bit of automation there.
listeners do that, listen, so why not register them (something required for listening) on their own class
You have data classes, handlers, managers
Making a data class register itself to the manager starts to... do the manager's job
It's like getting hired at a company, going to HR and filing in your details yourself into the database
a listener is a data class?
but the main class looks cleaner
¯_(ツ)_/¯
yeah
Depends. The command handler should know what it's invoked by, so why delegate registration to the constructor caller? I usually have an interface which has a method called registerSelf(Plugin).
but you dont need to see that big chunk of text saying .register a million times
instantiation order is often important
you can make separate methods for those
i have
It's difficult to explain grr
but still
hard to explain my code style that I've developed over the past 11 years
Only because of the dependency graph. I don't care about that, the computer should solve it for me.
this just doesnt look the best
It's not about looks...
not about efficiency either
mans coding in the minecraft font
debatable
Yeah make some variables
I write my code strictly focused on performance and readability
It's about how stupid it get's quickly when you actually are at a project with a decent level of complexity. Modules gonna need other modules, so you'll going to have a lot of fun when wiring everything together.
putting everything inside a black box and calling it a day isn't suitable
well whatever that thing isnt that readable
Who cares about initial efficiency when the plugin is loaded up. That's sacrificing at the wrong time and place.
No shot, are you actually coding in the Minecraft font? What an absolute mad lad
I just thought that lmao
module registry, init them all, and they can use each other
thats what im saying, its not about efficiency
its the monocraft font
It is much more readable than whatever underlying code it might be running to do it
I've had plugins that took 5 minutes to start up, not fun
its just one line
If the computer solved the dependency graph ahead of time and instantiated them in the right order. That means that there are no more new() calls, which then means that @civic apex would be happy looks-wise, and I would be happy work-wise.
that calls 1000 others
it would call them if it was in the main class too
I bet that it wasn't because of DI. That would be so sad tho...
i am not
split everything into data classes, handlers or managers
You know, I get what you're saying @echo basalt. But I'm not willing to have a wiring site like this if I can solve everything automatically with a few lines of extra code. It's extremely easy, doesn't hide what's going on and saves me from having to do stupid brainless work.
It ain't brainless ¯_(ツ)_/¯
also I never have problems when it comes to wiring stuff
I can literally hire kids to write constructor calls, lol
just register a couple listeners, couple command handlers
As I've said, it only becomes an issue in projects of a certain level of complexity. Your average listener and commands won't cause that, no.
sure registering listeners is probably the most boring part, but it takes like 30 seconds at most
You're quickly at levels like these when your project is rather complex. I wouldn't want to wire 50 of those bad boys up manually, checking what I need to create first.
Look at NMS, or the client itself. They also sometimes have huge constructors. Not all software just uses a reference to a single main class, it can get quite complicated if you're trying to separate out reusable functionality.
But for literally 80% of plugin developers out there, this is enough and they shouldn't get into automatic DI for that, yes.
something tells me you're putting a lot of responsibility in a single class 🤔
It's the real world. You cannot have 200 line classes everywhere.
tell me about the real world
I literally factored out so much it's not even funny anymore. The class is doing all the basics, but somewhere you gotta join abstractions together.
touch grass
Oh yeah?
You have to stop pulling everything apart at some level, or nothing get's done. As the symbol names of my screenshot show you, I already separated concerns pretty well. But as I've said, you have to write it up somewhere.
It's the server project I abandoned, lol.
But most of it aren't commands.
It's like the nms for mob brain behaviour
oh god the sensor system in nms is so overengineered
Not sorted in to packages everything is a mess
i have one old plugin which only had three files, and the main class (Main.java) had 1200 lines
I'd love to see you write a hologram plugin from scratch on top of packets with persistence, commands, variable support and so on with your style of programming and then check if it's actually cleaner than mine. Not meant in a bad way at all, just curious. Because most people which tell me that my style is not clean or not conform enough mostly work on far too simple things where these patterns are easy to stick to. But it's really hard to keep it clean when you're literally trying to stick a million features together.
also nesting hell
bet
packets are easy, I've done harder things
like fake blocks and fake entities that can collide with them
commands are also easy
Variable support is also easy, just a very abstract collection
Serialize that collection for persistence
And link stuff together
**Guys , can it work???
**
`package me.sussolino.juicehub;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class msg implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
String[] args) {
if(cmd.getName().equalsIgnoreCase("msg")) {
if (!(sender instanceof Player player)) {
return true;
}
if(args.length == 0) {
player.sendMessage(ChatColor.RED + "Usa: /msg <Player> <Messaggio>");
}else if(args.length == 1 ) {
player.sendMessage(ChatColor.RED + "Usa: /msg <Player> <Messaggio>");
}else {
StringBuilder str = new StringBuilder();
for (int i = 1; i < args.length; i++) {
str.append(args[i]);
}
Player targetPlayer = Bukkit.getPlayerExact(args[0]);
if (targetPlayer != null){
targetPlayer.playSound(player.getLocation(),
targetPlayer.sendMessage(ChatColor.AQUA + sender.getName() + ChatColor.GOLD + "" + ChatColor.BOLD + " > " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.WHITE + "" + ChatColor.translateAlternateColorCodes('&', " " + str.toString().trim()));
player.sendMessage(ChatColor.AQUA + sender.getName() + ChatColor.GOLD + "" + ChatColor.BOLD + " > " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.WHITE + "" + ChatColor.translateAlternateColorCodes('&', " " + str.toString().trim()));
} else {
player.sendMessage(ChatColor.RED + "Player non trovato");
}
}
}
return true;
}
}
`
no
You now know why my class has multiple references to other modules. It's methods are dead simple, but they link features together to define higher level behavior.
It's not about being hard, it's about having many moving pices which all need to be injected somewhere.
Really wondering how you're still trolling, lol
So you're saying having a handler like this https://paste.md-5.net/davipohata.java is completely wrong? Having a handler which manages the local cache, writes/reads to/from persistence, looks up and creates holograms (and thus holds their dependencies) and the like? Where would you put the creation of a new hologram and all of it's effects?
Guys , i have a problem.
At line 31 there is this error ";"
IDK how i can fix it , can someone help me?
`package me.sussolino.juicehub;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class msg implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
String[] args) {
if(cmd.getName().equalsIgnoreCase("msg")) {
if (!(sender instanceof Player player)) {
return true;
}
if(args.length == 0) {
player.sendMessage(ChatColor.RED + "Usa: /msg <Player> <Messaggio>");
}else if(args.length == 1 ) {
player.sendMessage(ChatColor.RED + "Usa: /msg <Player> <Messaggio>");
}else {
StringBuilder str = new StringBuilder();
for (int i = 1; i < args.length; i++) {
str.append(args[i]);
}
Player targetPlayer = Bukkit.getPlayerExact(args[0]);
if (targetPlayer != null){
targetPlayer.playSound(player.getLocation(),
targetPlayer.sendMessage(ChatColor.AQUA + sender.getName() + ChatColor.GOLD + "" + ChatColor.BOLD + " > " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.WHITE + "" + ChatColor.translateAlternateColorCodes('&', " " + str.toString().trim()));
player.sendMessage(ChatColor.AQUA + sender.getName() + ChatColor.GOLD + "" + ChatColor.BOLD + " > " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.WHITE + "" + ChatColor.translateAlternateColorCodes('&', " " + str.toString().trim()));
} else {
player.sendMessage(ChatColor.RED + "Player non trovato");
}
}
}
return true;
}
}
`
You really need to use pastes...
??
Yeah I'd split it
getHologram, remove, add
then the hologram would be responsible for its own lines
It is responsible for calculating where to put those lines while only having a central location where it grows from, and to resolve variables inside of it's lines etc, but is it really responsible for persisting itself?
I’m sorry but I was joking, but if I take 1 or add 1 , 2 or 3 , the same error.
now it work , thanks elder god of the world !
Hello !
Is it possible to make enderpearls cross through plain structures like a big wall using chunks?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
which is more preferred?
- plugin development using vscode and wsl or linux
or - intellij/eclipse and windows
i used to work with c++ projects via ubuntu or wsl and using visual studio code for development and was just curious about other thoughts
I use Vscode on linux
but intellij on linux works as well
sure, thanks!
I use Ubuntu 20.04+ Intellij - They works perfect no issues
Guys i have a problem , i can't register event but idk the cause...
in
new ItemEvents();
new ItemManager();
You dont need the linr that just has new itemevents you already register thr listener and does item manager have listeners in
So in the game they will work the same in theory, right?
If the item events class register's listeners for item manager if it has listeners in it, yes
oh ok , thanks for information :))
I'm trying to use NMS with mojang mappings for spigot 1.19.3 and for some reason when I write the code MinecraftServer server = craftPlayer.getHandle().getServer() in the form of a command, an internal server error occurs and the output is "Caused by: java.lang.NoSuchMethodError: 'net.minecraft.server.level.ServerPlayer org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer.getHandle()" Are my mappings corrupted?
you didnt remap your plugin
I implemented the plugins specialsource-maven-plugin and maven-shade-plugin in my pom.xml, installed the remapped 1.19.3 jars, and someone gave me their pom.xml as a reference, but still the error continues. Aren't these the correct steps to remap my plugin?
hey, how to show server on craftbukkit that is in bungee list?
i would guess just like any other server type
"{server}", player.getServer().getName()))); it result "Unknown Server" on my scoreboard
oh that
what would be the best way to go about setting specific heights of terrain in a world... all while keeping the vanilla cave generation underneath the height specified. IE lets say my code says that the ground should go up to y=100 in a specific xz coordinate, I know how i can set it using a custom chunk generator... but how do i ensure that vanilla generation is still occuring underneath
idk what could cause that to be unknown server
iirc theres a setCaveGen method
any solution?
is this in the ChunkGenerator class?
I don't see it there
oh wait its just called "generateCaves"
it says "Shapes the Chunk caves for the given coordinates" but would that generate caves throughout multiple chunks or would each chunk be random?
no idea, i doubt many people use craftbukkit as there server jar now-a-days so it shouldnt cause too many issues
ngl ive looked at chunk generators for hours and they still make little sense to me
yeah, ive got no clue how they work
i just remembered md saying something about that method
public static String getLobby(String input) {
return ConfigFile.getConfig().getString("LOBBY-SELECTOR." + input + ".SERVER");
}
https://ibb.co/VqGMMDB
I want it to merge with what is written in the config but i don't know the code for format {server}
what do you want {server} to be
shows the server name written in the config
if input is HUB-1 then you can just use what you already have, that would return hub-1 from the config
change .SERVER for .NAME if you want Lobby-1
Bukkit.getScheduler().runTaskTimer(JavaPluginInstance, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
player.doSomething();
}
}, 0, 5);
yeah
change player.doSomething to OtherClassName.scoreboard(player)
might need new
hey all. How do i create a boundingbox with 2 coordinates for the corners of the bounding box? I just want to figure out if im in this bounding box as well but have no clue where to start on creating the actual bounding box
created said bounding box, how do i check if enter the bounding box? Im using the player move event and im planning on having a few 100 of these regions all with checks for which bounding box i have entered, shouldnt cause lag should it?
declaration: package: org.bukkit.util, class: BoundingBox
A bounding box is basically a cuboid
so theres the constructor and BoundBox.of(location1, location2)
The thing is
then to check if you're inside you can do .containts(position)
only thing I hate about that class
is that there's no partial contains
like
it only checks if all 4 corners are contained within one another
if you have 2 perpendicular aabb's they don't collide
yep checked docs and did that, now the issue is, im def in the bounding box but my plugin doesnt think so
@EventHandler
public void enterVanguardRegion(PlayerMoveEvent e) {
Player player = e.getPlayer();
Location loc = player.getLocation();
BoundingBox vanguardBox = new BoundingBox(133.0, 71.0, 300.0, 139.0, 71.0, 307.0);
if(vanguardBox.contains(loc.getX(), loc.getY(), loc.getZ())) {
player.sendMessage("Entered Box.");
} else {
player.sendMessage("Not in Box???");
}
}```
yeah good idea
oh yeah btw buoo
the guy from the rpg server keeps begging me to help him out
136.30718410893195 71.0 302.34903518358374 My coords
why am i not in the bounding box
im lost
also on this, its being checked every time someone moves which i imagine is going to cause lag with a lot of people online, is it still safe or time to switch methods?
if anyone has any idea on why this bounding box isnt working, please lmk
Use papi and async bukkit task
Less lag
wut??
making things async just because isn't... ideal
also papi has nothing to do with boundingboxes
both things you said make no sense to me!
making stuff async just because is something I do... more than I should
but ill deal with that when i figure out why this bounding box isnt working
because I like to play it safe :)
so i should make it async?
no
okay gotcha
do you see anything wrong with what im doing?
bc it reallyyyyyyyy doesnt want to work
I mean..
the Y level is always the same
that can cause issues
try like
going in the area, in-game
but 1 block below
make the Y like 3 blocks tall
having it as the same value is.. .not ideal
at least set it to like 1 block above
you're making a bounding box that's like a sheet of paper
instead of a box
that is a good point
ill change it to bedrock to height level
ah yep
look at that
it fixed!
whats the best way for me to make a getPlugin method?
i dont want to run into issues getting an instance of my main class later down the road
Use the current getPlugin method?
If it's for the same plugin, use Dependency Injection
I'm very bad at math and I'm having a bit of brain lag.
I'm trying to create a chest populator that uses a scale of 1-10 to determine how full the chest(s) should be. 1 being empty or nearly empty and 10 being full or nearly full. But I'm having some problems translating that into code. My two variables are the container size, and the "purity" of the chest (being on the 1-10 scale)
Any math chads have any suggestions of how I should go about that?
?paste
LoginEvent doesnt have a .getPlayer method iirc
anyone?
PostLoginEvent
all the necessary components you need are in the constructor
for the event
Yeah, Use the PostLoginEvent instead of the LoginEvent
^^
PostLoginEvent has a getPlayer()
did you copy paste all that code from somewhere?
the LoginEvent
has to be PostLoginEvent
- Remove LoginEvent
- Use PostLoginEvent
- Get the proxied player from the event
@unreal shoal ^
Hey, anyone here know how to make text pop up on your screen? Sort of how theres text right in the middle of your screen
yeah sendTitle
You'd need to create an actionbar. Or Title/subtitle type thing
Player#sendTitle
okay so send title it is
i see what you were trying to tell me, its the one above the hotbar right?
idk why helpchat was the first that popped up
Pretty much
declaration: package: org.bukkit.entity, interface: Player
Think so
Parameters:
title - Title text
subtitle - Subtitle text
fadeIn - time in ticks for titles to fade in. Defaults to 10.
stay - time in ticks for titles to stay. Defaults to 70.
fadeOut - time in ticks for titles to fade out. Defaults to 20.
yeah my fault
Creator of papi
An many other things
oh thats neat
Hellow, what is the best plugin for tab?
Placeholder api is more known imo
TAB
lol what
It's free. You only need to pay if you want support from the dev which isn't really needed.
since its whenever im moving, that title keeps coming up, 1s lemme send my code:
// PDC :
Player player = e.getPlayer();
PersistentDataContainer playerPdc = player.getPersistentDataContainer();
String playerLocation = playerPdc.get(new NamespacedKey(Nebula.getPlugin(), "playerregion"), PersistentDataType.STRING);
Location loc = player.getLocation();
BoundingBox vanguardBox = new BoundingBox(133.0, 0, 300.0, 139.0, 256, 307.0);
if(vanguardBox.contains(loc.getX(), loc.getY(), loc.getZ())) {
if(!playerLocation.equals("vanguard"))
player.sendMessage("Entered City: Vanguard.");
playerPdc.set(new NamespacedKey(Nebula.getPlugin(), "playerregion"), PersistentDataType.STRING, "vanguard");
player.sendTitle("Entered Vanguard", "", 10, 70, 20);
} else {
player.sendMessage("Not in Box???");
playerPdc.set(new NamespacedKey(Nebula.getPlugin(), "playerregion"), PersistentDataType.STRING, "unknown");
System.out.println(loc.getX() + " " + loc.getY() + " " + loc.getZ());
}```
oh, okay
the chat msg only sends once, the title keeps coming up repeatedly
ill send this gain https://nms.screamingsandals.org/1.19/
its super useful
im assuming its bc it never finished its sequence
no idea how to deal with that tho
you sending region entered messages?
you have to keep track of whether a player has entered before
orelse it will spam
how would i send a packet to the server, never sent one to the server
only to a player
like a spoof packet?
sure
uuuh fuck
i dont actually know if thats possible
you would have to have a fake client
thats not a good idea
its gonna cause heaps of desync
and technically the player wont be teleported
just teleport them on the main thread
use a runnable or smth
fuck my idea failed
yeah
okay
yeah uh buo
unless you are using the packet to fake something being in a location
when you say it pops upmultiple times
does it not go away
or just fades in and out
but the chat message only once right
yep
brackets where?
if(vanguardBox.contains(loc.getX(), loc.getY(), loc.getZ())) {
if(!playerLocation.equals("vanguard"))
player.sendMessage("Entered City: Vanguard.");
playerPdc.set(new NamespacedKey(Nebula.getPlugin(), "playerregion"), PersistentDataType.STRING, "vanguard");
player.sendTitle("Entered Vanguard", "", 10, 70, 20);
} else {
vs
if(vanguardBox.contains(loc.getX(), loc.getY(), loc.getZ())) {
if(!playerLocation.equals("vanguard")){
player.sendMessage("Entered City: Vanguard.");
playerPdc.set(new NamespacedKey(Nebula.getPlugin(), "playerregion"), PersistentDataType.STRING, "vanguard");
player.sendTitle("Entered Vanguard", "", 10, 70, 20);
}
} else {
for the playerLocation.equals if statement
wheres the CreaShield class?
if you are trying to load your main class it should be dashspy.main.Main
Show the file structure you have.
?main
lol
is there any way for me to not be forced to restart my server without risking my plugin having a mental breakdown?
it is so slow
Your package would be dashspy.main not dashspy.main.Main
i think plugman
but i use plugwoman cuz it faster
Quick Question. Do you know Java. Or is this your very first time coding
?learnjava!
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
Depends what it does, plugman, plugwoman are all options but then you could use /reload confirm although its not recommended
women 🍵
no
You should learn the basics of java before coding a plugin
well, what would cause issues if i used plug whatever
You can optimise your server to start in less than 10 seconds
Theres a load that could arise
shit takes a solid 40-1m to load
Using plugin management plugins or /reload aren't really a good idea. Unless a plugin has it's own in-built reload command, you should restart the server.
Test environment use as little ugins as possible
my shit takes 0.5m to load
So there isnt really a good way to tell if it would work or not
cuz no code
thats fair
its gonna be fairly big by the time im done
so server load times are an issue
Best bet you have is using a plugin manager and hoping it doesnt break anything or hoping /reload doesnt then
guyzzz me need help with "smooth noise generator"
like plains but somewhere a hole
what if i will say "i like paper" ?
?whereami
i like scissors. I win
egglish
Huh
i asked this yesterday but didnt get the answer i was looking for, how do i make a gun that functions like one from actual triple A games. The gun shoots as long as I hold the left click button down and when my finger goes off the left click button, it stops shooting
Maybe use the PlayerInteractEvent, check if the block was air and the hand was the main hand. Then do the gun mechanics
You'd probably need to mess with particles, vectors and locations
It would be somewhat possible, but would take a bit and lots of trial and error.
see but then it would only fire the event once so id only shoot once
im trying to figure out how to keep the gun shooting while im still holding left click down
Wouldnt the event fire consecutively if you were holding
nope it wouldnt, i tried
No, I think it only fires once.
it only fires nce
I've just had a quick look at the docs and I honestly don't think it's possible without delving into packets.
thats fine with me, whatever to get it done
Because there really isn't a way to check if a player is holding the mouse button
ive been meaning to learn nms, this would force me to
what packet would the player even be sending to inform me that their holding the mouse down
Unless someone else knows of a way to do it, I think packets might be the best option. (not 100% sure if possible with packets but should be)
now that i think abt it, every server with gun mechanics always use right click to shoot, i havent tested it but does right click always fire if held down?
so I updated my plugin and now it's ~4.7MB, but the max size for uploading files is 4MB, so where do I upload the file now? is there a traditional hosting for this maybe?
kidding
^ Didn't know that was a thing. Wouldn't trust it
nvm imma use releases
my friends made it
it is trustworthy
xD
it was custom made fork of paper to patch creative mode exploits
primarily for the free op server they run
did you minimize it
Using a shadowJar or anything for compression? Surely there is a way you could bring that size down. Maybe some of the dependencies could be set to compile instead of implemented
iirc maven shade has a minimize tag so some size would able to come off
hm if class 1 implements cancellable and class 2 extends class 1 if I want class 2 to still implement cancellable the same as class 1 do I need to tell it to implement cancellable again or would it know to do that through polymorphism?
it should be extended right?
Hi, im trying to make a translator for chat, im using Protocollib i manage to make the packet works, but i don't know how to change the message to the new one and resend it to the user
code:
public class Message extends PacketAdapter {
public Message(Translator plugin) {
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.CHAT);
}
@SuppressWarnings("deprecation")
@Override
public void onPacketSending(PacketEvent event) {
if (event.isCancelled()) {
return;
}
PacketContainer packet = event.getPacket();
String message = packet.getStrings().read(0);
String translated = Translate("de", message)
}
}
Class 2 will still impl that interface, you can always override implementation
that's what I assumed, thanks
Why would you use packets for this?
because i can change text from plugins too and its individual for each player
for plugins too?
oh
i need it more for plugins
customising messages another plugin sends i would guess needs packets to intercept
for chat i have already the solution but for plugins im trying to search the way
and im already doing that with Protocolib
how does a baltop gets created, been wondered for awhile, and my plugin needs this command 🥹
best bet i can say is check the event method and see what methods it has
Isn't there write method, same way you get read?
It gets created by a plugin creating it.
Also make sure it's chat packet
getCommand("command").setExecutor(new ClassName())?
It depends how you want to create it.
If you are storing balance in some kind of database, it's just one query
got balance stored on PlayerConfig
@quaint mantle @dry yacht What about TabPosition.ofSlot(2) and TabPosition.ofPos(0, 1);
y/n?
It depends how you want to create it, If in chat, Then just do a simple string list to print out the baltop
Use a for loop to loop through the balances, and add it to a list then print the list
tried to use sort, is that how you create it, then i can just go back to it till i find a way
It's probably better to use correct database for this stuff instead of storing in yaml
You'll need to get an array or list of the balances, then print that list to the player.
its stored in data.db
It's sqlite?
Because it looks exactly like yaml config
If its sqlite, just select player, balance from table order by balance desc limit 15 for example
my programming playlists keep getting weirder
Same concept. You'd need to get a way to Loop through the balances, and add them to a list, with the players name, position and balance and send it to the player
on the File configFile = new()
i set it as data.db, but how i setup players is bad?
Maybe get the balances, put them into an array, sort the array based on the values, then just loop over the array
Because extension doesn't matter, it's still yaml config, which is in pratcice not used for data storage
do you not use a java database api for data.db
i would recommend using hikari cp and sqlite
with a connection pool
HikariCP is really good. I just always get confused trying to implement it, I have always wanted to. Just never actual spent the time to learn it
ive got no clue how it works either lol
one of my friends plugins used it so i just copied the concept
it works as intended so i just use it if i need sqlite
How to get value from async task?
thanks, will try 😄
async task as in
I've had multiple attempts at adding it and gave up each time haha
want me to find the classes that i used?
Well I was wanting actual Database no sqllite 😛
I need get value from db.
is it in plugin.yml
I tried to set value from outside of task
return the value like normal?
Hey, I get a weird error when I run my server, it seems to be something at TabExecutor. Am I doing something wrong?
The error in question
getCommand("chud").setExecutor(new CoordinatesHUDTabExecutor());
getCommand("chud").setTabCompleter(new CoordinatesHUDTabExecutor());
is it in plugin.yml
Is the command in the plugin.yml
oh my fucking god not again
also you dont need to set tab completer, setExecutor does that auto
use TabExecutor instead of CommandExecutor & TabCompleter
Agreed
I did
